Warning

This documentation is for an old version of Cantera. You can find docs for newer versions here.

Index of Python Examples

This is an index of the examples included with the Cantera Python module. They can be found in the examples subdirectory of the Cantera Python module’s installation directory. To determine the location of this directory, run the following in your Python interpreter:

import cantera.examples
print(cantera.examples.__path__)

Thermodynamics

critical_properties.py: Print the critical state properties for the fluids for which Cantera has built-in liquid/vapor equations of state.

isentropic.py: Isentropic, adiabatic flow example - calculate area ratio vs. Mach number curve

mixing.py: Mixing two streams using Quantity objects.

rankine.py: A Rankine vapor power cycle

sound_speed.py: Compute the “equilibrium” and “frozen” sound speeds for a gas

Kinetics

extract_submechanism.py: An example demonstrating how to use Species and Reaction objects to programmatically extract a reaction submechanism. In this example, the CO/H2 oxidation reactions are extracted from the GRI 3.0 mechanism.

mechanism_reduction.py: A simplistic approach to mechanism reduction which demonstrates Cantera’s features for dynamically manipulating chemical mechanisms.

reaction_path.py: Viewing a reaction path diagram.

Transport

dusty_gas.py: Dusty Gas transport model.

multiprocessing_viscosity.py: This example demonstrates how Cantera can be used with the ‘multiprocessing’ module.

Reactor Networks

combustor.py: A combustor. Two separate stream - one pure methane and the other air, both at 300 K and 1 atm flow into an adiabatic combustor where they mix and burn.

custom.py: Solve a constant pressure ignition problem where the governing equations are implemented in Python.

ic_engine.py: Simulation of a (gaseous) Diesel-type internal combustion engine.

mix1.py: Mixing two streams.

periodic_cstr.py: This example illustrates a continuously stirred tank reactor (CSTR) with steady inputs but periodic interior state.

pfr.py: This example solves a plug-flow reactor problem of hydrogen-oxygen combustion. The PFR is computed by two approaches: The simulation of a Lagrangian fluid particle, and the simulation of a chain of reactors.

piston.py: Two reactors separated by a piston

reactor1.py: Constant-pressure, adiabatic kinetics simulation.

reactor2.py: Two reactors connected with a piston, with heat loss to the environment

sensitivity1.py: Constant-pressure, adiabatic kinetics simulation with sensitivity analysis

surf_pfr.py: This example solves a plug flow reactor problem, where the chemistry is surface chemistry. The specific problem simulated is the partial oxidation of methane over a platinum catalyst in a packed bed reactor.

One-dimensional Flames

adiabatic_flame.py: A freely-propagating, premixed hydrogen flat flame with multicomponent transport properties.

burner_flame.py: A burner-stabilized lean premixed hydrogen-oxygen flame at low pressure.

diffusion_flame.py: An opposed-flow ethane/air diffusion flame

diffusion_flame_batch.py: This example creates two batches of counterflow diffusion flame simulations. The first batch computes counterflow flames at increasing pressure, the second at increasing strain rates.

diffusion_flame_extinction.py: This example computes the extinction point of a counterflow diffusion flame. A hydrogen-oxygen diffusion flame at 1 bar is studied.

flame_fixed_T.py: A burner-stabilized, premixed methane/air flat flame with multicomponent transport properties and a specified temperature profile.

flamespeed_sensitivity.py: Sensitivity analysis for a freely-propagating, premixed methane-air flame. Computes the sensitivity of the laminar flame speed with respect to each reaction rate constant.

premixed_counterflow_flame.py: An opposed-flow premixed strained flame

premixed_counterflow_twin_flame.py: Simulate two counter-flow jets of reactants shooting into each other. This simulation differs from the similar premixed_counterflow_flame.py example as the latter simulates a jet of reactants shooting into products.

stagnation_flame.py: A detached flat flame stabilized at a stagnation point

Multiphase Mixtures

adiabatic.py: Adiabatic flame temperature and equilibrium composition for a fuel/air mixture as a function of equivalence ratio, including formation of solid carbon.

plasma_equilibrium.py: An equilibrium example with charged species in the gas phase and multiple condensed phases.

Surface Chemistry

catalytic_combustion.py: CATCOMB – Catalytic combustion of methane on platinum.

diamond_cvd.py: A CVD example simulating growth of a diamond film

sofc.py: A simple model of a solid oxide fuel cell.