On Jun 9, 2006, at 11:19 AM, Trevor M Cickovski wrote:
Hi,
I am trying to run your implicit diffusion solver on a 2D 500x500
mesh. However, I would like to repeatedly run this solver to
evolve the same mesh, without losing previous values. So for example:
mesh = Grid2D(dx = 0.000002, nx=500, ny=500)
var = CellVariable(name="solution variable", mesh=mesh, value=0)
if __name__ == '__main__':
i = 0
while (i < steps):
# <do something to var>
ImplicitDiffusionTerm(coeff = 1).solve(var, dt=2)
# <do something else to var>
i = i + 1
However, I can't currently do this because whenever I call the solve
() method, it resets 'var' to all zeros. Is there anyway I can
stop this from happening? Appreciate it!
We probably need to know a bit more about what's involved in <do
something to var> and <do something else to var>, but I think I can
guess what's happening to you. If I'm right, then we discuss this
situation near the beginning of Example 9.1, phase.simple. The
source term of the phase equation isn't important here; it's the
behavior of trying to solve a steady-state diffusion term that causes
the problem. Since you supply no boundary conditions, then FiPy gives
you no-flux BCs by default. You don't have a TransientTerm, so the
timestep dt=2 doesn't get used in any way. At that point, FiPy is
simply solving Laplace's equation \nabla^2 var = 0, with \nabla var
\cdot \vec{n} = 0 on all boundaries. It doesn't matter what your
initial condition is, the solution to this problem is var=0. In order
for FiPy to take account of your initial condition, and of the
changes you make to var along the way, you'll need to introduce a
TransientTerm to the equation.
--
Jonathan E. Guyer, PhD
Metallurgy Division
National Institute of Standards and Technology
<http://www.metallurgy.nist.gov/>