0

I'm trying to model a multi-component reaction diffusion system using FiPy. Each component, \phi_i, has a diffusive term and multiple bi-molecular reaction terms (\phi_m, \phi_n). Each component's time evolution is given by the following equation:

\frac{d\phi_i}{dt} = D_i\nabla \phi_i + \sum_{m,n} k_{m,n}\phi_m \phi_n  , 

which I represent in FiPy as

eq = TransientTerm() ==  DiffusionTerm(D_i) + ReactionTerm

where

if i!=m and i!=n:    ReactionTerm = k_mn * \phi_m * phi_n    
elif i==m and i!=n:  ReactionTerm = ImplicitSourceTerm(k_mn * \phi_n)
elif i!=m and i==n:  ReactionTerm = ImplicitSourceTerm(k_mn * \phi_m)

How do I represent the ReactionTerm in the case that i==m==n? In other words, how does one represent a term quadratically dependent on the variable being solved for, as shown in the following equation:

\frac{d\phi_i}{dt} = \phi_i \cdot \phi_i

Until now, I have been representing it explicitly, but I wonder if there is a way to represent it implicitly like I do for the other terms which include the component being solved for.

1 Answers1

0

Implicitness is linear in all cases. ImplicitSourceTerm(coeff=k_mn * phi_i) will do.

In all cases, you need to sweep the nonlinearities, whether they come from quadratic terms in the solution variable or dependencies on other solution variables.

jeguyer
  • 2,379
  • 1
  • 11
  • 15