Ian -
I have no experience with the method of lines, so I don't understand what you
do with the matrix once you have it.
If you omit the TransientTerm, then the remainder of the terms will build a
matrix and RHS for the spatial discretization. Time discretization is only
provided by TransientTerm. I proposed subclassing TransientTerm so that your
equation retained a placeholder for the time derivative that you could then
manipulate as you need.
To do so, you would not edit fipy/terms/transientTerm.py directly, but rather
in your own code, write something like:
from fipy import TransientTerm
class MyTransientTerm(TransientTerm):
def _buildMatrix(self, var, SparseMatrix, boundaryConditions=(), dt=None,
transientGeomCoeff=None, diffusionGeomCoeff=None):
** do something **
return (var, L, b)
I'm afraid I have no idea what ** do something ** looks like for you.
You would then build your equation with
eq = MyTransientTerm() == DiffusionTerm() + ConvectionTerm() + ...
At that point, I don't know whether you eq.solve()/eq.sweep() or instead call
eq._prepareLinearSystem() and then do something completely different.
- Jon
> On Feb 9, 2017, at 12:21 PM, Campbell, Ian <[email protected]>
> wrote:
>
> Hi Jonathan,
>
> Thank you for your reply.
>
> I'm afraid neither Krishna nor I fully understand what you mean by 'subclass'
> the TransientTerm. Could you please elaborate?
>
> Could we simply set the transient term's coefficient equal to zero, so that
> it doesn't feature in the matrices? We would like to use method of lines.
>
> If you mean editing the class in the file at
> "site-packages/fipy/terms/transientTerm.py", is it possible that you could
> provide a code example? I'm afraid we don't know where to start in this case.
>
> With best regards,
>
> - Ian & Krishna
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of
> Guyer, Jonathan E. Dr. (Fed)
> Sent: 26 January 2017 14:42
> To: FIPY <[email protected]>
> Subject: Re: Question on accessing internal matrices of the system being
> solved
>
> I would imagine you could subclass TransientTerm such that it did not
> contribute to the matrix and RHS.
>
>> On Jan 25, 2017, at 2:16 PM, Gopalakrishnan, Krishnakumar
>> <[email protected]> wrote:
>>
>> Hi Dan,
>>
>> Thanks a lot for your reply. Based on this, Ian and I have a further
>> question.
>>
>> Is it possible to instruct FiPy to discretise only the spatial domain,
>> leaving the time-domain continuous?
>> Ian and I are planning to implement the standard method of lines for our
>> problem at hand. Although we have derived the Ax=b system matrices and
>> vectors by hand-derivation for a fixed-spaced 2D mesh, this becomes messy
>> and intractable for higher dimensions and non-uniformly spaced Cartesian
>> meshes.
>>
>> Thus, our plan is to get FiPy generate the matrices for us, and we can use
>> standard ode/dae adaptive time-stepping solvers for the actual simulation of
>> the system.
>>
>> Can FiPy return the system matrices and RHS vector by discretising only the
>> spatial domain?
>>
>> Best Regards,
>>
>> Krishna
>>
>> From: [email protected] <[email protected]> on behalf of
>> Daniel Wheeler <[email protected]>
>> Sent: Tuesday, January 24, 2017 5:00:23 PM
>> To: Multiple recipients of list
>> Subject: Re: Question on accessing internal matrices of the system
>> being solved
>>
>> Hi Ian,
>>
>> Sorry for the slow response.
>>
>> On Thu, Jan 12, 2017 at 12:20 PM, Campbell, Ian
>> <[email protected]> wrote:
>>>
>>> 1) Applying numerix.array() to ‘L’, when ’L’ is of type
>>> 'fipy.matrices.scipyMatrix._ScipyMeshMatrix', creates a
>>> zero-dimensional ndarray, with no shape. This isn’t what we expected
>>> because L has diagonal numerical values & ‘---‘ where its sparse “entries”
>>> are.
>>> Our goal is to obtain ‘L’ using your suggested method and then to
>>> convert it into the SciPy sparse.csc_matrix format for further
>>> processing. The input to SciPy’s csc_matrix function must be a
>>> rank-2 ndarray, but (reasonably
>>> enough!) this fails when we pass csc_matrix a zero-dimensional ‘L’ matrix.
>>
>> See,
>>
>>
>> https://github.com/usnistgov/fipy/blob/develop/fipy/matrices/scipyMatr
>> ix.py#L266
>>
>> I think you need the "matrix" attribute of
>> "fipy.matrices.scipyMatrix._ScipyMeshMatrix" and I think that is the
>> raw Scipy version of the matrix (whatever format that is). You can
>> then call "toarray()" on that is seems. My previous instructions were
>> wrong. So just using "L.numpyArray" should also achieve the same.
>>
>>> 2) We see from the 2009 paper that it’s a three-point stencil used
>>> for the generation of the discretisation matrix in a first order
>>> scheme. What stencil is used for 2nd order schemes?
>>
>> Depends on the term of course, but for a diffusion term on a square
>> grid it is the same as finite difference which would be a 5 point
>> stencil. The convection terms are mostly first order as currently
>> implemented in FiPy.
>>
>> This is a good book for FV method,
>> http://www.springer.com/us/book/9783319168739, which describes some of
>> the schemes.
>>
>>> 3) How do we implement a higher (e.g. 8th & 12th order
>>> central-difference) order schemes in FiPy?
>>
>> That's not easy at all. I don't think it is designed well enough for
>> that. It would require a major rewrite to easily add new convection
>> schemes.
>>
>> Cheers,
>>
>> Daniel
>>
>> --
>> Daniel Wheeler
>>
>> _______________________________________________
>> fipy mailing list
>> [email protected]
>> http://www.ctcms.nist.gov/fipy
>> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>> _______________________________________________
>> fipy mailing list
>> [email protected]
>> http://www.ctcms.nist.gov/fipy
>> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
>
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]