On Mon, Jul 30, 2012 at 10:58 PM, Daniel Farrell <[email protected]>wrote:
> Dear list, > > I see how integration can be included by converting to a sum (as explained > here, http://thread.gmane.org/gmane.comp.python.fipy/2231/focus=2232), > > x = mesh.getCellVolumes() > area = (y * x).sum() > > However, I want to integrate a cell variable where the upper limit of > integration is the current position. See here for the actual expression, > > http://i.imgur.com/4tNUt.jpg > > This can be solved really easily by integrating the numpy arrays over the > specific range. For example, using scipy.quad function, > > import scipy > import numpy > numpy.exp( -scipy.quad( lambda x: phi(x), 0, x)[0] ) > > How can I perform this integral using Fipy? It is possible to incorporate > this function call to scipy? > Just use what you have written. Should work as is. Actually, it should be numpy.exp( -scipy.quad( lambda x: phi([[x]]), 0, x)[0] ) if phi is a cell variable. The __call__ method of cell variable is used to pass in an array of positions of shape (dim, numberOfPositions) and then the returned array with shape (numberOfPositions,) is the interpolated value of the cell variable at the given positions. -- Daniel Wheeler
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
