1

This may be a simple question but what is the correct FiPy syntax to use if I want to solve PDE with spatially varying coefficient that is outside of gradient? All the examples I've seen so far only talk about coefficient inside of the gradient.

For example:

d/dt(Sigma) = (1/r) d/dr (r^0.5 d/dr(nu Sigma r^0.5))

(I'm ignoring numerical factors)

and I want to solve for Sigma(t,r). How do I handle (1/r) in front of d/dr?

I know this simple equation can be massaged so that I don't need to worry about spatially varying coefficient that is outside of gradient (or simply move the coefficient inside the time derivative term) but I'll have to add in more terms for the actual problem I'm trying to solve and the trick will no longer be valid. For instance, what should I do if my equation looks like:

d/dt (var) = f(r) d^2/dr^2 (var) + g(r) d/dr (var)

Any help would be greatly appreciated!

equel
  • 11
  • 1

1 Answers1

0

This may be a simple question but what is the correct FiPy syntax to use if I want to solve PDE with spatially varying coefficient that is outside of gradient?

I think that the general equation can always be rewritten in such a way that FiPy can still operate implicitly on the solution variable. This does require an extra source term in most cases.

I know this simple equation can be massaged so that I don't need to worry about spatially varying coefficient that is outside of gradient (or simply move the coefficient inside the time derivative term) but I'll have to add in more terms for the actual problem I'm trying to solve and the trick will no longer be valid.

The example equation,

eqn1

can be represented as

eqn2

in FiPy, which doesn't add any extra terms. For the general case,

eqn3

the equation can be represented as

\frac{\partial}{\partial t} \left( \frac{\phi}{f} \right ) =  \frac{\partial^2 \phi}{\partial r^2} + \frac{\partial}{\partial r} \left( \frac{g \phi}{f} \right ) - \phi \frac{\partial}{\partial r} \left(\frac{g}{f} \right )

Although there is an extra term, the terms are still implicit in \phi and the extra term can be represented as an implicit source term for \phi depending on the sign of g/f. FiPy should handle the sign issue just by using the ImplicitSourceTerm.

Note that often r occurs outside of the operator when using cylindrical coordinates. FiPy has a mesh class, CylindricalGrid1D that handles cylindrical coordinates while using the standard terms (no need to and the r spatial variable in the equations).

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
wd15
  • 1,068
  • 5
  • 8