-1

C(h) \frac{\partial h}{\partial t}=\nabla \cdot(K(h) \nabla(h+z)) I have two questions:

  1. How do I represent a diffusive source that involve coordinate? The governing equation is for h; k(h) is a function of h; z was the z coordinate. I knew how to write a diffusive source without the coordinate z, but I did not know how to represent a diffusive source that involve coordinate.
    1. Do "phi[0].updateOld()"in the "...\fipy\examples\diffusion\mesh1D.py" update the "eq =transientTerm() == DiffusionTerm(coeff=D0 * (1 - phi[0]))" when just use "res = eq.sweep(var=phi[0], dt=timeStepDuration)"

Thanks for your help.

Liu
  • 3
  • 2
  • I'm voting to close this question as off-topic because this is nothing to do with programming – Kalana Jan 16 '20 at 17:02

1 Answers1

2
  1. equation using Online Equation Editor

and

equation using Online Equation Editor

so

equation using Online Equation Editor

The second term on the RHS is then written explicitly as (K(h).faceValue * [[0], [0], [1]]).divergence.

If K(h) is a linear function of h, then you could express this as a ConvectionTerm. E.g., if K(h) = h * K1(h), then you could write ConvectionTerm(coeff=K1(h).faceValue * [[0], [0], [1]]).

  1. Do you mean, does coeff=D0 * (1 - phi[0]) get updated? Yes.
jeguyer
  • 2,379
  • 1
  • 11
  • 15
  • Thank you very much for your answer. I test the (Krel*[[0],[1]]).divergence for 2D mesh, but it showed"AttributeError: 'binOp' object has no attribute 'divergence'".So I changed it to "(Krel.faceValue*[[0],[1]]).divergence". Now it works. But I was confused by the "facevalue". Which "facevalue"should be used? – Liu Oct 18 '19 at 04:56
  • you mean "psi.updateOld()" update all coeff related to psi. If I want "psi_tmp=psi" did not update. How can I deal with it? – Liu Oct 18 '19 at 04:58
  • @Liu: Yes, you're right. It should be `K(h).faceValue`. I've edited the answer to reflect this. – jeguyer Oct 18 '19 at 13:44
  • @Liu: Please ask 2. as a separate question. StackOverflow isn't conducive to answering independent questions like this. – jeguyer Oct 18 '19 at 13:44
  • I read other tag in [fipy]. Found "psi_tmp=psi.copy()" is work. Thanks for your answers. – Liu Oct 20 '19 at 01:38