Pantera is a Python library that implements several monkey patches and convenience functions for Cantera.
Link to Github repo: https://github.com/charlesreid1/pantera
The Pantera Library Layout
This section describes the layout of the core source code of Pantera.
Pantera provides classes that interface with and extend Cantera classes.
Pantera also monkey-patches Cantera. Monkey patches are modifications to existing objects that add new features or bring back useful but deprecated features.
- Cantera Monkey-Patches - patches existing Cantera classes (adds essential functionality ONLY!)
- Gases submodule - gas compositions, gas mixing, gas objects
- Configurations submodule - extends Cantera reactor networks to be more useful and flexible (plug flow reactors, packed bed reactors, ignition reactors, recycle reactors, etc.)
- Reactors submodule - extends Cantera reactors to be more useful (but most of the useful stuff is in the configurations)
- Engineering submodule - applied engineering problems solved with Cantera
There are a couple of monkey patches applied to Cantera. The two classes affected are:
Solution class Monkey-Patches
The Solution class is monkey-patched to more easily obtain mass and mole fractions for particular species.
If you have a Solution (bascially a gas phase object) using the Cantera library, you can obtain mass and mole fractions using the somewhat clunky notation:
speciesName = ['CH4','O2'] Xs = my_solution[speciesName].X Ys = my_solution[speciesName].Y
This monkey-patch allows for the much more intuitive:
speciesName = ['CH4','O2'] Xs = my_solution.mole_fraction( speciesName ) Ys = my_solution.mass_fraction( speciesName )
This works when passing a single species names or a lists of species names as a parameter.
Reactor class Monkey-Patches
The Reactor class monkey-patches are actually provided in the PanteraReactors.py file in the pantera.reactors submodule. It is described here anyway, since it is still a monkey-patch.
In Cantera 2.0, you could access the state of a Cantera reactor like this:
# Cantera 2.0 r = Reactor(my_solution) print r.temperature() print r.pressure() print r.moleFractions()
However, Cantera 2.1 created problems by doing away with this. Now, you can only access the temperature of the reactor.
What's worse, if you want to access the pressure and mole fractions of a reactor, you need to use the contents, but Cantera 2.1 also did away with ways of accessing the contents of the reactor. You used to be able to do this:
# Cantera 2.0 r = Reactor(my_solution) c = r._contents T = c.temperature() P = c.pressure() X = c.moleFractions()
Again, Cantera 2.1 created problems by doing away with this.
These monkey-patches fix this. Now you can do this:
r = Reactor(my_solution) print r.T print r.P print r.X print r.Y c = r._contents print c.T print c.P print c.X print c.Y
A reactor "configuration" is the Pantera equivalent of a pre-configured Cantera RectorNet. A ReactorNet is a network of reactors that are connected together and must be integrated in time together because the state of each reactor depends on other reactors in the network.
The Pantera configurations are designed to construct a reactor (or set of reactors) and any associated inlets and outlets, and solve it.
They extend Cantera ReactorNets, but have a constructor like Cantera Reactors. This is more intuitive for the user to specify.
Visit the configurations README.md for details: https://github.com/charlesreid1/pantera/blob/master/pantera/configurations/README.md
Pantera defines several utility functions for things like specification of composition, conversion of formats, mixing of gases, and others.
from pantera.gases import * ready_to_ignite = MethaneAir(phi=0.5)
Visit the gases README.md for details: https://github.com/charlesreid1/pantera/blob/master/pantera/gases/README.md
You can create Pantera reactor objects. These extend Cantera's Reactor classes.
You can create them once you import Pantera:
from pantera import * pr = PanteraReactor()
Visit the reactors README.md for details: https://github.com/charlesreid1/pantera/blob/master/pantera/reactors/README.md
Cantera is very handy for everyday engineering calculations, with an emphasis on reaction engineering and reactor design. This submodule creates some objects and methods that assist in these kinds of calculations.
from pantera import * h = Heater()
A Note on Namespaces
The Pantera library keeps the namespace clean by importing Cantera like this:
import cantera as ct
This prevents conflicting functions and objects.
If you have to use Cantera and Pantera together, import them like this:
import cantera as ct import pantera as pt
That way, you don't end up importing Cantera multiple times under multiple names.
Canteraall pages on the wiki related to the Cantera combustion microkinetics and thermodynamics (a.k.a. "thermochemistry") software.
Understanding Cantera's Structure: Cantera Structure
Cantera from Matlab: Using_Cantera#Matlab
Cantera from Python: Using_Cantera#Python
Cantera from C++: Using_Cantera#C++
Cantera + Fipy (PDE Solver): Fipy and Cantera/Diffusion 1D
Cantera Gas Objects: Cantera/Gases
Cantera Gas Mixing: Cantera_Gas_Mixing
Topics in Combustion:
Sensitivity Analysis: Cantera/Sensitivity Analysis
Analysis of the Jacobian Matrix in Cantera: Jacobian_in_Cantera
Chemical Equilibrium: Chemical_Equilibrium
Kinetic Mechanisms: Cantera/Kinetic_Mechanisms
Reactor Equations: Cantera/Reactor_Equations
Differential vs. Integral Reactors: Cantera/Integral_and_Differential_Reactors
Effect of Dilution on Adiabatic Flame Temperature: Cantera/Adiabatic_Flame_Temperature_Dilution
Topics in Catalysis:
Cantera for Catalysis: Cantera_for_Catalysis
Steps for Modeling 0D Multiphase Reactor: Cantera_Multiphase_Zero-D
Reaction Rate Source Terms: Cantera/Reaction_Rate_Source_Terms
Surface coverage: Cantera/Surface_Coverage
Surface reactions: Cantera/Surface_Reactions
Cantera Input Files:
Chemkin file format: Chemkin
Pantera (monkey patches and convenience functions for Cantera): Pantera
Extending Cantera's C API: Cantera/Extending_C_API
Extending Cantera with Python Classes: Cantera/Adding Python Class
Debugging Cantera: Cantera/Debugging_Cantera
Debugging Cantera from Python: Cantera/Debugging_Cantera_from_Python
Gas Mixing Functions: Cantera_Gas_Mixing
Residence Time Reactor (new Cantera class): Cantera/ResidenceTimeReactor
Cantera Resources: Cantera Resources
Cantera Lecture Notes: Cantera_Lecture
Flags · Template:CanteraFlag · e
Installing Canteranotes on the wiki related to installing the Cantera thermochemistry software library.
Mac OS X 10.5 (Leopard): Installing_Cantera#Leopard
Mac OS X 10.7 (Lion): Installing_Cantera#Lion
Mac OS X 10.8 (Mountain Lion): Installing_Cantera#Mountain_Lion
Ubuntu 12.04 (Precise Pangolin): Installing_Cantera#Ubuntu
Windows XP: Installing_Cantera#Windows_XP
Windows 7: Installing_Cantera#Windows_7
In old versions of Cantera, a preconfig file was used to specify library locations and options.
Mac OS X 10.5 (Leopard) preconfig: Cantera_Preconfig/Leopard_Preconfig
Mac OS X 10.6 (Snow Leopard) preconfig: Cantera_Preconfig/Snow_Leopard_Preconfig
Mac OS X 10.8 (Mountain Lion) preconfig: Cantera_Config/MountainLion_SconsConfig
Ubuntu 12.04 (Precise Pangolin) preconfig: Cantera_Config/Ubuntu1204_SconsConfigFlags · Template:InstallingCanteraFlag · e