On Thu, Jul 12, 2018 at 9:59 AM, Pavel Aleynikov
<pavel.aleyni...@ipp.mpg.de> wrote:

> How should such equation be arranged?

fp.numerix.cumsum seems to return a numpy array so won't automatically
update when f1 changes. Probably best to update in the loop like this,

~~~~
import fipy as fp
mesh = fp.Grid1D(dx=0.002, nx=100)
mesh = mesh + [0.002]
f1 = fp.CellVariable(name = "solution",mesh = mesh,value = 1.,hasOld=True)
x      = mesh.x
M1      = lambda f1: fp.numerix.cumsum(f1*mesh.cellVolumes)
M2      = lambda f1: fp.numerix.cumsum(x**2*f1*mesh.cellVolumes)

Conv_pf = fp.CellVariable(mesh=mesh, rank=1)
Diff_pf = fp.CellVariable(mesh=mesh)


eq_steady1 = fp.DiffusionTerm(coeff=Diff_pf) +
fp.PowerLawConvectionTerm(coeff=Conv_pf)
f1.constrain(1,mesh.facesLeft)

for sweep in range(10):
    Conv_pf[:] = M1(f1) / x**2
    Diff_pf[:] = M2(f1) / x**3
    eq_steady1.sweep(var=f1)
print f1
f1.updateOld()
~~~~



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

Reply via email to