Re: Question on accessing internal matrices of the system being solved

2017-02-09 Thread Guyer, Jonathan E. Dr. (Fed)
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  
> 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: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of 
> Guyer, Jonathan E. Dr. (Fed)
> Sent: 26 January 2017 14:42
> To: FIPY 
> 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 
>>  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: fipy-boun...@nist.gov  on behalf of 
>> Daniel Wheeler 
>> 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 
>>  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 mat

RE: Question on accessing internal matrices of the system being solved

2017-02-09 Thread Campbell, Ian
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: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of Guyer, 
Jonathan E. Dr. (Fed)
Sent: 26 January 2017 14:42
To: FIPY 
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 
>  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: fipy-boun...@nist.gov  on behalf of 
> Daniel Wheeler 
> 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 
>  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
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] 
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Question on accessing internal matrices of the system being solved

2017-01-26 Thread Guyer, Jonathan E. Dr. (Fed)
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 
>  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: fipy-boun...@nist.gov  on behalf of Daniel 
> Wheeler 
> 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
>  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/scipyMatrix.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
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Question on accessing internal matrices of the system being solved

2017-01-25 Thread Gopalakrishnan, Krishnakumar
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: fipy-boun...@nist.gov  on behalf of Daniel Wheeler 

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
 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/scipyMatrix.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
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Question on accessing internal matrices of the system being solved

2017-01-24 Thread Daniel Wheeler
Hi Ian,

Sorry for the slow response.

On Thu, Jan 12, 2017 at 12:20 PM, Campbell, Ian
 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/scipyMatrix.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
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


RE: Question on accessing internal matrices of the system being solved

2017-01-12 Thread Campbell, Ian
Dear Daniel, Jonathan,

Thank you both very much for your helpful replies. Krishna and I can now access 
the 'L' discretisation matrix in Lx = b, as desired, using the code example at 
the bottom of this e-mail.

We have some follow-up questions, though:

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.

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?

3) How do we implement a higher (e.g. 8th & 12th order central-difference) 
order schemes in FiPy?

Thanks again.

With best regards,

- Ian & Krishna

Modified diffusionmesh20x20.py example:

from __future__ import division
from fipy import *
from scipy.sparse import csc_matrix

SparseMatrix = LinearLUSolver()._matrixClass

nx = 3
ny = nx
dx = 1.
dy = dx
L = dx * nx
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)

phi = CellVariable(name = "solution variable",
   mesh = mesh,
   value = 1.)

D = 1.
eq = TransientTerm() == DiffusionTerm(coeff=D)

valueTopLeft = -10
valueBottomRight = 20

X, Y = mesh.faceCenters
facesTopLeft = ((mesh.facesLeft & (Y > L / 2))
| (mesh.facesTop & (X < L / 2)))
facesBottomRight = ((mesh.facesRight & (Y < L / 2))
| (mesh.facesBottom & (X > L / 2)))

phi.constrain(valueTopLeft, facesTopLeft)
phi.constrain(valueBottomRight, facesBottomRight)

v, L, b = DiffusionTerm(D)._buildMatrix(phi, SparseMatrix)
print(type(L))
print(L)
print("\n")

numerixed_L = numerix.array(L)
print(type(numerixed_L))
print(numerixed_L.shape)
print(numerixed_L.ndim)
print(numerixed_L)




-Original Message-
From: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of Guyer, 
Jonathan E. Dr. (Fed)
Sent: 12 January 2017 16:05
To: FIPY 
Subject: Re: Question on accessing internal matrices of the system being solved

By "display", I mean show a color map. It's not quantitative, but it can be 
useful to understand the stencil being generated.

> On Jan 12, 2017, at 10:53 AM, Guyer, Jonathan E. Dr. (Fed) 
>  wrote:
>
> In addition to this, if you define an environment variable 
> FIPY_DISPLAY_MATRIX, then FiPy will display the matrix and RHS vector. If 
> FIPY_DISPLAY_MATRIX contains "terms", then the contribution of each term will 
> be displayed before the aggregate matrix and vector are displayed.
> If FIPY_DISPLAY_MATRIX contains "print", then the numerical values of the 
> matrix and vector will be printed to the shell. This is overwhelmingly 
> useless for any but very tiny meshes.
>
>> On Jan 12, 2017, at 10:27 AM, Daniel Wheeler  
>> wrote:
>>
>> Hi Krishna,
>>
>> Yes you can do this, see
>>
>> https://github.com/usnistgov/fipy/blob/develop/fipy/terms/term.py#L33
>> 2
>>
>> The following should work,
>>
>>   equation.cacheMatrix()
>>   equation.solve(...)
>>   the_matrix = equation.matrix
>>
>> The cacheMatrix is require because otherwise the reference to the
>> matrix is lost.
>>
>> I'm not exactly certain on the matrix format, but you should be able
>> to do
>>
>>  np.arrray(the_matrix)
>>
>> to make it into a 2D numpy array.
>>
>> Hope that helps.
>>
>> On Wed, Jan 11, 2017 at 3:39 PM, Gopalakrishnan, Krishnakumar
>>  wrote:
>>> Hi,
>>>
>>> I was wondering if there is a way to access the internal matrices of
>>> the system of equations formulated by Fipy , given the coefficient
>>> terms of the general conservation equation.
>>>
>>> Let's say I have a simple diffusion equation (eg. Heat equation). I
>>> can hand-code the differentiation matrix and BC vector for a
>>> constant dx using the 2nd order central difference formula.
>>>
>>> Is there a way to see the matrix/vector system of the discretised
>>> system that FiPy has internally formed before we call solve() or
>>> sweep() ? I am still learning basics of discretisarion schemes and
>>> it will be helpful to visualise how FiPy internally forms th

Re: Question on accessing internal matrices of the system being solved

2017-01-12 Thread Guyer, Jonathan E. Dr. (Fed)
By "display", I mean show a color map. It's not quantitative, but it can be 
useful to understand the stencil being generated.

> On Jan 12, 2017, at 10:53 AM, Guyer, Jonathan E. Dr. (Fed) 
>  wrote:
> 
> In addition to this, if you define an environment variable 
> FIPY_DISPLAY_MATRIX, then FiPy will display the matrix and RHS vector. If 
> FIPY_DISPLAY_MATRIX contains "terms", then the contribution of each term will 
> be displayed before the aggregate matrix and vector are displayed. 
> If FIPY_DISPLAY_MATRIX contains "print", then the numerical values of the 
> matrix and vector will be printed to the shell. This is overwhelmingly 
> useless for any but very tiny meshes.
> 
>> On Jan 12, 2017, at 10:27 AM, Daniel Wheeler  
>> wrote:
>> 
>> Hi Krishna,
>> 
>> Yes you can do this, see
>> 
>> https://github.com/usnistgov/fipy/blob/develop/fipy/terms/term.py#L332
>> 
>> The following should work,
>> 
>>   equation.cacheMatrix()
>>   equation.solve(...)
>>   the_matrix = equation.matrix
>> 
>> The cacheMatrix is require because otherwise the reference to the
>> matrix is lost.
>> 
>> I'm not exactly certain on the matrix format, but you should be able to do
>> 
>>  np.arrray(the_matrix)
>> 
>> to make it into a 2D numpy array.
>> 
>> Hope that helps.
>> 
>> On Wed, Jan 11, 2017 at 3:39 PM, Gopalakrishnan, Krishnakumar
>>  wrote:
>>> Hi,
>>> 
>>> I was wondering if there is a way to access the internal matrices of the
>>> system of equations formulated by Fipy , given the coefficient terms of the
>>> general conservation equation.
>>> 
>>> Let's say I have a simple diffusion equation (eg. Heat equation). I can
>>> hand-code the differentiation matrix and BC vector for a constant dx using
>>> the 2nd order central difference formula.
>>> 
>>> Is there a way to see the matrix/vector system of the discretised system
>>> that FiPy has internally formed before we call solve() or sweep() ? I am
>>> still learning basics of discretisarion schemes and it will be helpful to
>>> visualise how FiPy internally forms the matrices, and how they compare to
>>> the hand-derived matrices/vectors
>>> 
>>> Regards,
>>> 
>>> Krishna
>>> 
>>> 
>>> ___
>>> fipy mailing list
>>> fipy@nist.gov
>>> http://www.ctcms.nist.gov/fipy
>>> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>>> 
>> 
>> 
>> 
>> -- 
>> Daniel Wheeler
>> ___
>> fipy mailing list
>> fipy@nist.gov
>> http://www.ctcms.nist.gov/fipy
>> [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
> 
> 
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Question on accessing internal matrices of the system being solved

2017-01-12 Thread Guyer, Jonathan E. Dr. (Fed)
In addition to this, if you define an environment variable FIPY_DISPLAY_MATRIX, 
then FiPy will display the matrix and RHS vector. If FIPY_DISPLAY_MATRIX 
contains "terms", then the contribution of each term will be displayed before 
the aggregate matrix and vector are displayed. 
If FIPY_DISPLAY_MATRIX contains "print", then the numerical values of the 
matrix and vector will be printed to the shell. This is overwhelmingly useless 
for any but very tiny meshes.

> On Jan 12, 2017, at 10:27 AM, Daniel Wheeler  
> wrote:
> 
> Hi Krishna,
> 
> Yes you can do this, see
> 
> https://github.com/usnistgov/fipy/blob/develop/fipy/terms/term.py#L332
> 
> The following should work,
> 
>equation.cacheMatrix()
>equation.solve(...)
>the_matrix = equation.matrix
> 
> The cacheMatrix is require because otherwise the reference to the
> matrix is lost.
> 
> I'm not exactly certain on the matrix format, but you should be able to do
> 
>   np.arrray(the_matrix)
> 
> to make it into a 2D numpy array.
> 
> Hope that helps.
> 
> On Wed, Jan 11, 2017 at 3:39 PM, Gopalakrishnan, Krishnakumar
>  wrote:
>> Hi,
>> 
>> I was wondering if there is a way to access the internal matrices of the
>> system of equations formulated by Fipy , given the coefficient terms of the
>> general conservation equation.
>> 
>> Let's say I have a simple diffusion equation (eg. Heat equation). I can
>> hand-code the differentiation matrix and BC vector for a constant dx using
>> the 2nd order central difference formula.
>> 
>> Is there a way to see the matrix/vector system of the discretised system
>> that FiPy has internally formed before we call solve() or sweep() ? I am
>> still learning basics of discretisarion schemes and it will be helpful to
>> visualise how FiPy internally forms the matrices, and how they compare to
>> the hand-derived matrices/vectors
>> 
>> Regards,
>> 
>> Krishna
>> 
>> 
>> ___
>> fipy mailing list
>> fipy@nist.gov
>> http://www.ctcms.nist.gov/fipy
>>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>> 
> 
> 
> 
> -- 
> Daniel Wheeler
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: Question on accessing internal matrices of the system being solved

2017-01-12 Thread Daniel Wheeler
Hi Krishna,

Yes you can do this, see

https://github.com/usnistgov/fipy/blob/develop/fipy/terms/term.py#L332

The following should work,

equation.cacheMatrix()
equation.solve(...)
the_matrix = equation.matrix

The cacheMatrix is require because otherwise the reference to the
matrix is lost.

I'm not exactly certain on the matrix format, but you should be able to do

   np.arrray(the_matrix)

to make it into a 2D numpy array.

Hope that helps.

On Wed, Jan 11, 2017 at 3:39 PM, Gopalakrishnan, Krishnakumar
 wrote:
> Hi,
>
> I was wondering if there is a way to access the internal matrices of the
> system of equations formulated by Fipy , given the coefficient terms of the
> general conservation equation.
>
> Let's say I have a simple diffusion equation (eg. Heat equation). I can
> hand-code the differentiation matrix and BC vector for a constant dx using
> the 2nd order central difference formula.
>
> Is there a way to see the matrix/vector system of the discretised system
> that FiPy has internally formed before we call solve() or sweep() ? I am
> still learning basics of discretisarion schemes and it will be helpful to
> visualise how FiPy internally forms the matrices, and how they compare to
> the hand-derived matrices/vectors
>
> Regards,
>
> Krishna
>
>
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>



-- 
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Question on accessing internal matrices of the system being solved

2017-01-11 Thread Gopalakrishnan, Krishnakumar
Hi,

I was wondering if there is a way to access the internal matrices of the system 
of equations formulated by Fipy , given the coefficient terms of the general 
conservation equation.

Let's say I have a simple diffusion equation (eg. Heat equation). I can 
hand-code the differentiation matrix and BC vector for a constant dx using the 
2nd order central difference formula.

Is there a way to see the matrix/vector system of the discretised system that 
FiPy has internally formed before we call solve() or sweep() ? I am still 
learning basics of discretisarion schemes and it will be helpful to visualise 
how FiPy internally forms the matrices, and how they compare to the 
hand-derived matrices/vectors

Regards,

Krishna
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]