Cantera Structure
From charlesreid1
Contents
Background Information
Overview of Cantera's Structure
The structure of Cantera is bicephalous (meaning, two-headed). This two-layered structure can be explained using the following diagram:
Typically, the user is interfacing with the solvers and numerics layer, because Cantera was written such that the Reactor and ReactorNet classes, or Sim1D or OneDim equations, which wrap differential equation solvers, could be used to solve practical engineering problems. However, the user can interface with the bookeeping layer of Cantera directly, if, for example, they want to use Cantera as part of an external routine to evaluate kinetics and transport properties for a CFD solver or a more sophisticated numerical solver.
The Bookkeeping Layer
The first layer of Cantera, the Kinetics/Thermo/Transport Bookkeeping layer, consists of the classes that handle tasks such as importing XML or CTI files, which contain reaction mechanisms, transport mechanisms, and thermodynamic data, and using that information to set the state of particular phases. It also consists of Cantera phase objects, such as ideal gases. Some classes in the bookkeeping layer include, but are not limited to:
- ChemEquil
- GasKinetics
- ReactionStoichMgr
- Phase
- IdealGasPhase
- SurfPhase
- MultiTransport
- MixTransport
The Numerics Layer
The second layer of Cantera, the Solvers/Numerics layer, contains most of the pieces that the user typically interfaces with - the reactors, the reactor networks, the 1D domains, the stagnation or symmetric flames, and so on. This is also the layer that interfaces with the Sundials library. Some classes in the numerics layer include, but are not limited to:
- Reactor
- ReactorNet
- Domain1D
- Sim1D
- OneDim
- CVodesIntegrator
Why Is Identifying Cantera's Layers Important?
Now, you may raise the question: why is this important?
If you're using a stock install of Cantera to simulate precisely the kinds of problems that Cantera's numerical routines were designed to solve, you'll run into few limitations.
However, as soon as you want to extend Cantera's non-combustion capabilities to solve 1D problems or to incorporate transport effects, or extend Cantera's combustion examples to use more complex numerical schemes, or couple Cantera to an already-existing equation solver like OpenFoam, you quickly run up against the limitations of the numerical layer of Cantera. This is because the numerical layer of Cantera is intended primarily to solve ordinary differential equations - which is why Cantera is linked to the Sundials library - and is not intended to solve more complex partial differential equations. And while the Sundials library is powerful, it is only powerful for ordinary differential equations, i.e., equations that are function of a single dimension.
Furthermore, while it is possible to extend Cantera's equation solvers to larger and more complex problems, this is reinventing the wheel. There are many libraries that already provide the classes and interfaces needed to solve these problems, and do it much better than the average user implementing their own version within the confines of Cantera.
Here is why these observations are important: Cantera's primary usefulness is not its numerical routines, as there are huge number of libraries that provide various approaches to solving various differential equations.
Cantera's primary usefulness is in its bookkeeping capabilities.
What Does This Mean For Future Cantera Development?
All of this is important to figuring out a direction for Cantera, moving forward.
Currently, Cantera's installation procedure is onerous and temperamental, subject to the constantly-changing compiler toolchains of operating systems (cough cough, APPLE).
In order to make Cantera a more widely-used and ubiquitous tool, and a truly competitive alternative to Chemkin, the complications involved in installing Cantera must be resolved, and an installation procedure developed that is as simple as:
pip install cantera
(or even
brew install cantera
). Developing either of these options with Cantera as it stands would be difficult. But much of the difficulty comes from the Numerics layer.
A Modest Proposal
The modest proposal I put forward, then, is to strip Cantera of its numerics layer, making the code base simple enough that pip install cantera
would be feasible. This would eliminate parts of Cantera that do things that other software does better anyway, and focus Cantera (and future Cantera development) on the things that Cantera does well - kinetics, thermodynamics, and transport bookkeeping.
The new structure looks something like this:
The Pros
- Simplified program structure, allowing simplified installation procedure, e.g.,
pip install cantera
- A wider user-base, thanks to simplified installation procedure
- Greater flexibility in Cantera applications; the user is no longer limited to Cantera's numerical capabilities
- Smaller code base, covering less redundant topics (e.g., not implementing numerical solvers and routines that dozens of other libraries have already implemented) and encouraging further development
The Cons
- More work is required of the user: writing or selecting appropriate numerical solvers. This would depend on governing equations and physics, and could heighten the barrier to entry.
- There are ways to ease this difficulty, e.g., by creating Cantera "modules" or APIs for different solvers like Sundials or Scipy.
- Additional examples and documentation for examples would be needed (but, as mentioned above, a smaller code base and a wider user base would help alleviate some of this.)
Bottom Line
Eliminating the Numerics layer from Cantera would lead to a simpler, more flexible, and less redundant library that would be easier to install and have a wider user base.
Flags
Cantera all pages on the wiki related to the Cantera combustion microkinetics and thermodynamics (a.k.a. "thermochemistry") software.
Cantera · Cantera Outline · Category:Cantera
Outline of Cantera topics: Cantera Outline · Cantera Outline/Brief 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 1D Domains, Stacks: Cantera_One-D_Domains · Cantera_Stacks Cantera Gas Mixing: Cantera_Gas_Mixing
Topics in Combustion: Diffusion: Cantera/Diffusion · Cantera/Diffusion Coefficients 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 CTI files: Cantera/CTI_Files · Cantera/CTI_Files/Phases · Cantera/CTI_Files/Species · Cantera/CTI_Files/Reactions
Hacking Cantera: 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
Resources: Cantera Resources: Cantera Resources Cantera Lecture Notes: Cantera_Lecture
Category:Cantera · Category:Combustion Category:C++ · Category:Python Flags · Template:CanteraFlag · e |
Installing Cantera notes on the wiki related to installing the Cantera thermochemistry software library.
Cantera Installation: Mac OS X 10.5 (Leopard): Installing_Cantera#Leopard Mac OS X 10.6 (Snow Leopard): Installing_Cantera#Snow_Leopard · Cantera2 Config 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
Cantera Preconfig: 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_SconsConfig Flags · Template:InstallingCanteraFlag · e |