0

How can I express the term like diffusion term but with a transposed matrix in FIPY?

1

2 Answers2

0

FiPy allows for general diffusion terms of the form

enter image description here

The coefficient requires 2x2 components in 2D or 3x3 components in 3D, but can still be spatially varying in each of those components. See the FiPy FAQ for more details.


Updated Solution

The above is not particularly useful now that I understand that is supposed to be a vector. Let's assume a set of equations of the form,

where k is not summed, but signifies the equation and particually components of being solved. That results in the following for the diffusion term,

In your case . In FiPy, you'll need to represent this with multiple diffusion terms since there is more than one variable being solved for in each equation now. Assuming that we have k=x,y, only then the first equation's diffusion terms will be

eq_x = ... ==
DiffusionTerm(coeff=[[1, 0], [0, 0]], var=phi_x) + DiffusionTerm(coeff=[[0, 1], [0, 0]], var=phi_y)

The equations will then need to be combined into a single equation using eq = eq_x & eq_y

wd15
  • 1,068
  • 5
  • 8
0

I'm not seeing how to use @wd15's suggestion to use an anisotropic diffusion coefficient to achieve transposition.

Working my slow wits through Einstein notation, it looks to me like:

Maybe that's an obvious result, but it wasn't obvious to me.

FiPy doesn't have a Term that represents this, so I think you'll just need to calculate it explicitly, e.g.

grad_div_phi = phi.divergence.grad
u_eq = TransientTerm(...) == ... + grad_div_phi.dot([1, 0, 0])
v_eq = TransientTerm(...) == ... + grad_div_phi.dot([0, 1, 0])
w_eq = TransientTerm(...) == ... + grad_div_phi.dot([0, 0, 1])

If @wd15 agrees with my interpretation of this term, he may see a more implicit way to incorporate it into your equation.

jeguyer
  • 2,379
  • 1
  • 11
  • 15
  • I think that the maths is equivalent to my answer so the implicit formulation stated above will work. Also possible to not have coupled equations but have one part implicit and one part explicit. – wd15 Jul 27 '20 at 19:43
  • Thank you for your help. It helped me a lot. Wish you have a nice day. – Xiukai Wang Jul 29 '20 at 00:36