On Feb 16, 2012, at 9:46 AM, Jesper Friis wrote: > I now ran into another problem. I have the following lines of code > >>>> rcrit = 0.0 >>>> f = 4.0 * pi / 3.0 * ((phi * r**3 * dr) * (r > rcrit)).sum() # integrate >>>> from rcrit to infinity >>>> C = (C0 - f * Cp) / (1.0 - f) >>>> rcrit = alpha / log(C / Ceq) > > where C0, Cp, Ceq and alpha are scalar constants and phi is the solution > variable. The problem with this is that rcrit on the second line will still > refer to zero and not the new value calculated on the last line. Is it > possible to handle this kind of circular reference in fipy?
I think you would need to write >>> rcrit = fp.CellVariable(mesh=mesh, value=0.0) >>> f = 4.0 * pi / 3.0 * ((phi * r**3 * dr) * (r > rcrit)).sum() # integrate >>> from rcrit to infinity >>> C = (C0 - f * Cp) / (1.0 - f) and then manually assign >>> rcrit.setValue(alpha / log(C / Ceq)) at each timestep. If you're worried about convergence in any given timestep, then you could repeat the .setValue() until rcrit is stable. > Inspired by your answer, I have tried the following I've tried to do some related things in my own work and I don't think I recommend it. It's really easy to provoke infinite recursion. _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
