FaceVariable as Diffusion Tensor Coefficient Component

20 views
Skip to first unread message

Harun Ardiansyah

unread,
Apr 8, 2022, 12:11:17 PM4/8/22
to fipy
Dear Developers,

I am currently trying to solve a problem that is similar to the 1-D Diffusion Coupled example. However, I would like to expand the coefficients of the diffusion term so that it will be a face variable. My intention is so that each mesh will have different value of diffusion coefficient along x-axis.
Here is the code that I wrote,

## Import variables and tools
from fipy import CellVariable, FaceVariable, Grid1D, DiffusionTerm, Viewer
from fipy.terms.transientTerm import TransientTerm
from fipy.tools import numerix

m = Grid1D(nx=100, Lx=5.0)
nx = 100
group = 2
v = CellVariable(name="$\phi$", mesh=m, elementshape=(group,))

X = m.faceCenters[0]

D3 = FaceVariable(mesh=m, value=1.0)
D3.setValue(2.0,where=(2.0<=X))

v.constrain([[0], [1]], m.facesLeft)
v.constrain([[1], [0]], m.facesRight)

eqn = TransientTerm([[1, 0],[0, 1]]) == DiffusionTerm([[[D3, -1],[1, D3]]])

vi = Viewer((v[0], v[1]))

from builtins import range
for t in range(1):
eqn.solve(var=v, dt=1.e-3)
vi.plot()
input("Finished")

In this case I just change one of the diffusion tensor component into a facevariable D3. Is there any better way to represent this condition? Thank you.

Regards,
Harun

Daniel Wheeler

unread,
Apr 11, 2022, 11:28:55 AM4/11/22
to Harun Ardiansyah, fipy
Hi Harun,

Thanks for your question. Could you possibly write down the
mathematical statement of the problem? It might be easier to figure
out the best way forward. You might want to write down two separate
equations to start and then couple them later once we understand that
things are working unless you're already happy that things are working
correctly.

Regarding the diffusion coefficient. I would be worried that FiPy
could get confused by spatial versus variable indices in the
coefficient. As I said, it might be better to try two separate
equations and then couple them and check that your vector
representation is identical in outcome. That would be a way to test
internal consistency (FiPy has two ways to couple equations (vector
coupling and regular coupling)). Vector coupling can get confusing in
terms of spatial versus variable indices.

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
Reply all
Reply to author
Forward
0 new messages