Hi, I am trying to solve a pure convection problem with a dirac-shaped source term depending both in size and position on the solution variable. The problem is that the source term becomes a OperatorVariable, while a CellVariable is required by the equation. If I try to do something like this
>>> import fipy as fp >>> mesh = fp.Grid1D(dx=L/nr, nx=nr) >>> b = mesh.getFaceCenters()[0] >>> dr = mesh.getCellVolumes() >>> j = some_scalar_function(phi) >>> rbirth = another_scalar_function(phi) >>> S = j / dr * (b[:-1] <= rbirth) * (rbirth < b[1:]) # Convert S to a CellVariable as required by the equation >>> _S = fp.CellVariable(name='$S$', mesh=mesh, value=S) _S will behave as a constant. E.g. if I perform the integration as >>> t = 0.0 >>> dt = 1e-4 >>> while t < 1e5: ... dt *= 1.5 ... t += dt ... eq.solve(var=phi, boundaryConditions=BCs, dt=dt) ... print 'S.max = %10.5g _S.max = %10.5g' % (S.max(), _S.max()) I see that S will change while _S doesn't. Is there a way to get this working? Another question. When coupling FiPy with other models, it would be very useful if one could construct a Variable or CellVariable that will call an user-supplied function when it needs to calculate its value. How can this be achieved? Best regards /Jesper _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
