1

I am trying to solve the following coupled pde's in fipy. I tried the following

eq1 = (DiffusionTerm(coeff=1, var=f)-f*DiffusionTerm(coeff=1, var=phi)
       +f-f**3 == 0)
eq2 = (2*DiffusionTerm(coeff=f, var=phi)+f*DiffusionTerm(coeff=1, var=phi)
       == 0)
eq = eq1 & eq2
eq.solve()

but it does not like "f*DiffusionTerm(coeff=1, var=phi)" and I get the error. "TermMultiplyError: Must multiply terms by int or float." Is there a way that I can implement a cell variable times a diffusion term?

1 Answers1

1

Neither of the following will work in FiPy,

from fipy import CellVariable, DiffusionTerm, Grid1D
mesh = Grid1D(nx=10)
var = CellVariable(mesh=mesh)
# eqn = var * DiffusionTerm(coeff=1)
eqn = ImplicitSourceTerm(coeff=DiffusionTerm(coeff=1))
eqn.solve(var)

They both simply don't make sense with respect to the discretization in the finite volume method. Regardless, you can use the following identity to rewrite the term of interest

Basically, instead of using

var * DiffusionTerm(coeff=1)

you can use

DiffusionTerm(coeff=var) - var.grad.mag**2

Giving a regular diffusion term and an extra explicit source term.

wd15
  • 1,068
  • 5
  • 8