Dear List,
I have a FiPy model of the following form:
from fipy import Grid1D, CellVariable
from fipy import TransientTerm, DiffusionTerm
from fipy.tools.numerix import linspace, zeros
cs = ('a','b',)
class Toy:
def __init__(self):
self.L = 1.0
self.nx = 10
self.dx = self.L/self.nx
self.m = Grid1D(dx=self.dx,nx=self.nx)
for v in cs:
c = CellVariable(self.m, name=v, hasOld=1)
setattr(self,v,c)
def setInitial(self):
self.a.setValue(linspace(1,7,self.nx))
self.b.setValue(1)
def evaluate(self,o):
self.setInitial()
a = self.a
b = self.b
D = -0.00004 * b
v = o[0] * a/(1+a)
w = o[1] * b/(1+b)
e = TransientTerm() + DiffusionTerm(D) == v - w
zs = 10
du = 0.1
err = 10**-6
res = zeros((zs,self.nx))
for z in range(zs):
r = 10**3
res[z] = b.getValue()
while r > err:
r = min(r, e.sweep(b,dt=du))
b.updateOld()
return res
if __name__ == "__main__":
t = Toy()
o = [1.,1.]
print t.evaluate(o)
This is a stripped down version of the problem I'm solving. In reality
I have twelve PDEs and some hairy non-linear source terms. I've had
problems when I converted my "script" version, i.e. not classes of my
own, to a version where my problem is neatly packaged into a class and
all instances of CellVariables etc. are local to some method. My
question is: will this confuse FiPy or not? What I mean is: will all
variables be updated as they should be after each iteration of sweep &
updateOld?
Thanks in advance,
Lafras
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]