From charlesreid1

Cantera Evaluation of Properties

Some notes, from an algorithmic perspective, on hooking up Cantera with a finite-volume solver for computing solutions.

Using the Python interface to Cantera, if I create a gas phase object, I can see all the methods available for that gas phase:

In [1]: from Cantera import *

In [2]: g = GRI30()

In [3]: dir(g)

Wow. That's a lot of methods. And that's exactly why we want to interface with Cantera from an equation solver.

The Cantera Outline page contains a comprehensive list of pages on Cantera and its formulations. Those pages cover how to do things with these gas objects.


Covered here:

Called through the methods:

  • g.mixDiffCoeffs()
  • g.multiDiffCoeffs()

Note that if we use multicomponent diffusion coefficients, we have to specify that when we create the gas:


In [4]: g = GRI30()

In [5]: g.multiDiffCoeffs()
error                                     Traceback (most recent call last)
<ipython-input-5-c8f3cc1dc781> in <module>()
----> 1 g.multiDiffCoeffs()

/Users/charlesreid/codes/cantalysis/build/lib/python2.7/site-packages/Cantera/Transport.pyc in multiDiffCoeffs(self)
    156         coefficients. Not implemented in all transport managers."""
    157         return _cantera.tran_multiDiffCoeffs(self.__tr_id,
--> 158                                            self.trnsp)
    160     def setParameters(self, type, k, params):


                Cantera Error!

Procedure: Transport Base Class

**** Method getMultiDiffCoeffs not implemented in model 0 ****
(Did you forget to specify a transport model?)


In [6]: g = GRI30('Multi')

In [7]: g.multiDiffCoeffs()
array([[  0.00000000e+00,   2.16211927e-04,   1.08401378e-04, ...,
          4.68401619e-05,   5.73411067e-05,   5.73117527e-05],
       [  2.16211927e-04,   0.00000000e+00,   2.16802755e-04, ...,
          9.36803238e-05,   1.14682213e-04,   1.14623505e-04],
       [  1.08401378e-04,   2.72421028e-05,   0.00000000e+00, ...,
          5.90173041e-06,   7.22482032e-06,   7.22112180e-06],
       [  4.68401619e-05,   9.88416546e-06,   4.95558763e-06, ...,
          0.00000000e+00,   2.62135856e-06,   2.62001664e-06],
       [  5.73411067e-05,   1.01255679e-05,   5.07661871e-06, ...,
          2.19360351e-06,   0.00000000e+00,   2.68400570e-06],
       [  5.73117527e-05,   9.89389411e-06,   4.96046525e-06, ...,
          2.14341368e-06,   2.62393867e-06,   0.00000000e+00]])

Fipy-Only Pieces

A simple transient problem with Fipy:

0D Reaction Equation

A Fipy script that will solve a very simple 0D reaction equation:

with reaction source terms computed by Cantera.

Fipy and Cantera/0D Reaction

0D Reaction Model: Batch Reactor

Filpy script that solves the 0D reaction equation, as well as other governing equations, for a 0D batch reactor model.

Fipy and Cantera/Batch Reactor

1D Convection-Reaction Equation

Using Fipy+Cantera to solve the one-dimensional convection reaction equation:

Fipy and Cantera/1D Convection Reaction

1D Convection-Reaction Model: Axial Profile

Once you can solve the one-dimensional convection reaction equation, you can reproduce an axial profile model for a PFR.

Fipy and Cantera/PFR Axial Profile Model

1D Diffusion Equation

A 1D diffusion problem solved by Fipy, with diffusion coefficients computed by Cantera. Illustrates how to solve a variable-diffusivity problem and sweep over the solution.

Fipy and Cantera/1D Diffusion

1D Diffusion Model: Boundary Value Problem

Fipy and Cantera/PFR Boundary Value Problem