On Jan 8, 2015, at 10:30 AM, Christopher Jones <[email protected]> wrote:
> I am modelling nonlinear heat conduction using time steps and sweeps. > > Basic equation is: > > du/dt = A(u) * d2u/dx2 + S(x, t) > > where u(x, t) > > I have functions written for A(u), the DiffusionTerm coefficient, and S(x, > t), the ImplicitSourceTerm. I implement them with the following snippet: > > eq = TransientTerm() == DiffusionTerm(coeff=A) + ImplicitSourceTerm(coeff=S) DiffusionTerm represents d/dx(A(u) * du/dx) (or, more rigorously, nabla\cdot(A(u) \nabla u)). If your functional form *really* is A(u) * d2u/dx2, then you need to run the chain rule to obtain \nabla\cdot(A(u) \nabla u) - \nabla A(u) \cdot \nabla u, which equates to DiffusionTerm(coeff=A) + A.grad.dot(u.grad). It is rare, however for this to be needed. The form of DiffusionTerm (with A inside the first derivative) is the one almost invariably encountered. > S is really the whole source term, not the coefficient, so have I coded this > correctly? Raymond has already pointed out the linearity of ImplicitSourceTerm. If your source is linear in u, then using +ImplicitSourceTerm(coeff=S1) is more efficient than using +S1*u. If your source isn't linear in u, then don't worry about it and write the source explicitly. > I have declared A as a FaceVariable (because diffusion happens from cell to > cell, and S as a CellVariable, is this correct? Yes. > Since S depends on t as well, I created a Variable t. I then created a small > function and included it with S with this snippet: > > B = 50 * numerix.exp(-t) > > S.setValue(B) > > After sweeping, I increment the elapsed time and then t, with > > t.setValue(elapsedTime) > > I can print B's value to see that it does decay. .setValue() sets the instantaneous value of S. S won't change with further changes in t. Skip B and just write S = 50 * numerix.exp(-t) _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
