On Wed, Dec 4, 2013 at 2:21 PM, Larrue, Tara T. (ARC-TI)[UNIVERSITIES SPACE RESEARCH ASSOCIATION] <tara.t.lar...@nasa.gov> wrote: > > I am trying to represent this Hostetler 1-D Lake Equation: > $$ > \frac{\partial T}{\partial t} = \nabla ([km + K(z,t)] \nabla T ) + > \frac{1}{C}\nabla \Phi > $$
I assume you mean $\frac{1}{C}\nabla \cdot \Phi$ for the last term in that equation. > with these boundary conditions (first is for the surface [z=0], seconds is > for the bottom of the lake): > > $$[km + K(z,t)] \nabla T = EnergyBalanceEquation $$ > > $$[km + K(z,t)] \nabla T = 0 $$ > > > Here is my representation: > > (D[0]*temp).grad.constrain([fluxLeft],mesh.facesLeft) > (D[0]*temp).grad.constrain([fluxRight],mesh.facesRight) I don't think the above will work at all. It won't do anything. See http://www.ctcms.nist.gov/fipy/documentation/USAGE.html#applying-fixed-flux-boundary-conditions. It is a much safer way to work with FiPy. Basically, just add in an extra term to the equation to account for the boundary conditions. > eqX = TransientTerm() == (DiffusionTerm(coeff=D) + > (1./C))*Phi.arithmeticFaceValue.divergence) > > where D is the diffusion coefficient calculated from km + K(z,t) . > Throughout the iterations, I reset the surface boundary with the following > lines: > fluxLeft = heatEnergy*(1./C) > (D[0]*temp).grad.constrain([fluxLeft],mesh.facesLeft) You shouldn't need to reset anything inside the loop using the method suggested. > I am not sure if I represented the heat source term correctly. With this > current representation, the temperature is is being inversely affected by > the heat source (energy goes up, temperature drops.) There is also a major > scaling issue, as I am getting temperature values in the negative thousands. Fix the boundary condition issue and see what happens and then send the entire code and we can try and debug it. Good luck. -- Daniel Wheeler _______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]