I have a coupled nonlinear PDE system in 1 spatial dimension, in which I want to solve using FiPy. The dependent variables are $n$ and $T$: \begin{align} \frac{\partial n}{\partial t} \,&=\, D\,\frac{\partial^2 n}{\partial x^2} \\ \frac{\partial T}{\partial t} \,&=\, \frac{D}{\zeta}\,\frac{\partial^2 T}{\partial x^2} \,+\, \left(\frac{\zeta + 1}{\zeta}\right) \frac{D}{n} \, \frac{\partial n}{\partial x} \, \frac{\partial T}{\partial x} \end{align}

As of now, both $D$ and $\zeta$ are simple numerical parameters.

I am having serious trouble representing the second term in the $\frac{\partial T}{\partial t}$ equation, as there seems to be no nice way of writing it. Should it be written as a Convection term, or as a Source term?

This is the code so far, omitting some things:

L = 5.0
nx = 100
mesh = Grid1D(nx=nx, dx=L/nx)
x = mesh.cellCenters[0]

density = CellVariable(name=r"$n$", mesh=mesh)     # The n dependent variable
temperature = CellVariable(name=r"$T$", mesh=mesh) # The T dependent variable

D = 5.0
zeta = 0.5

density_equation = TransientTerm(var=density) == \
                    DiffusionTerm(coeff=D, var=density)

temp_equation = TransientTerm(var=temperature) == \
                 DiffusionTerm(coeff= D / zeta, var=temperature) \
                          + S_T    # <- What should be filled in for this?

semifull_eq = density_equation & temp_equation

if __name__ == '__main__':
    viewer = Viewer((density, temperature))

timeStepDuration = dx**2 / (2*diffusivity)
for steps in range(100):
    if __name__ == '__main__':

I have left out the boundary and initial conditions for brevity.

  • $\begingroup$ Welcome to SciComp.SE! It's definitely not a source term, since it involves $T$. Some would classify this as an advection term, but this terminology is far from standard. How FiPy deals with such terms is off-topic here, though, and should be asked on their mailing list (ctcms.nist.gov/fipy/documentation/MAIL.html). $\endgroup$ Dec 8 '17 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.