Quoting "Ionut Vancea" <[email protected]>:

from math import e

As a general rule, don't ever directly import anything from math, numpy, or scipy. Use equivalent definitions from fipy.tools.numerix. In this case, e**(-faceVar) will not produce at all the same thing as fipy.tools.numerix.exp(-faceVar).


from fipy.variables.cellVariable import CellVariable
from fipy.tools.numerix import random

var = CellVariable(name = "Simulations",
                   mesh = mesh,
                   value = random.random(nx * ny))

faceVar = var.getArithmeticFaceValue()
fDerivative = e**(-faceVar)-(b/(faceVar**3))

OK, this is the problem. fDerivative is a FaceVariable. To get the proper order for the discretization, you want the second derivative of f(\phi) to be a FaceVariable, so fDerivative needs to be a CellVariable. So, either

  fDerivative = exp(-var) - (b / var**3)
  (h**3 * fDerivative.getFaceGrad()).getDivergence()

or, better,

  fSecondDerivative = -exp(-faceVar) + (3 * b / faceVar**4)
  DiffusionTerm(coeff=fSecondDerivative)



Reply via email to