Hi Iñaki,
Thanks for your questions. This shouldn't be a problem for FiPy.
There are some notable errors in the code you have in the image in
your email. Rather than point out the issues I'm just going to provide
an example that works.
~~~~
from fipy import CellVariable, Grid2D, FaceVariable, DiffusionTerm,
Viewer, TransientTerm
mesh = Grid2D(nx=2, ny=2, Lx=1.0, Ly=1.0)
phi = CellVariable(mesh=mesh, value=0.01, hasOld=True)
X, Y = mesh.faceCenters
coeff = phi.faceValue * (X != 0.5)
print(coeff)
# bcs on left side
phi.constrain(0.01, where=(X < 0.5) & (Y == 0.0))
phi.constrain(1, where=(X < 0.5) & (Y == 1.0))
# bcs on right side
phi.constrain(1, where=(X > 0.5) & (Y == 0.0))
phi.constrain(0.01, where=(X > 0.5) & (Y == 1.0))
eqn = (TransientTerm() == DiffusionTerm(coeff))
for i in range(10):
phi.updateOld()
eqn.solve(phi, dt=0.1)
Viewer(phi).plot()
print(phi)
input('stop')
~~~~
The internal faces in the Y direction have 0 diffusion in the above
while the diffusion coefficient is also dependent on phi. The left and
right side are therefore independent problems. Here the mask is X !=
0.5. In your example define the diffusion coefficient with
coeff = diff.faceValue * mask
diff.faceValue is a face variable. coeff will then depend on diff and
diff with depend on phi. You can check that your coeff has the correct
dependencies using "print(repr(coeff))" in your code to make
absolutely sure you trust the lazy evaluation. That will print the
dependency tree. Probably avoid having a function to construct the
diffusion coefficient. It shouldn't matter if done correctly, but
doesn't buy you anything as it won't be called more than once.
I hope that helps.
Cheers,
Daniel
> --
> To unsubscribe from this group, send email to
fipy+uns...@list.nist.gov
>
> View this message at
https://list.nist.gov/fipy
> ---
> To unsubscribe from this group and stop receiving emails from it, send an email to
fipy+uns...@list.nist.gov.
--
Daniel Wheeler