Thanks for the reply. What's the format of the array when the variable is defined on a 2D grid? Both methods seem to return a 1D array. Is there a way to get out the values in a 2D array? -Ranjit
On Mon, Aug 24, 2009 at 11:05 AM, Daniel Wheeler <[email protected]>wrote: > > On Fri, Aug 21, 2009 at 11:27 AM, Ranjit Chacko<[email protected]> wrote: > > Hi, > > I'm starting to learn how to use fipy, and I can't quite figure out how > to > > represent a non-local interaction I have in my model. I need to do a > > convolution of the field with the interaction potential. How do I get > values > > of the field out into an array that I can perform FFT's on, and then how > > should I assign the result of the convolution to a term in the evolution > > equation? > > Sorry for the slow reply. To get a CellVariable as an array simply do > "numerix.array(var)" or "var.getValue()", either one should work, you > can then call scipy's fft. Not sure about the second part of the > question, but you will have to recast the result back into a > CellVariable before adding it into the evolution equation. Here is one > way to do it: > > def convolution(var): > a = numerix.array(var) > return scipy.something(a) > > resultOfConvolution = CellVariable(mesh=mesh) > > eqn = someTerms + resultOfConvolution > > while True: > resultOfConvolution,setValue(convolution(var)) > eqn.solve(var) > > Cheers > > > Thanks, > > -Ranjit > > > > > > -- > Daniel Wheeler > >
