Index of Python Examples

This is an index of Python examples included with Cantera.

Cantera's Python examples can be downloaded by clicking the "Source" link at the top of each example page.

Table of Contents

Thermodynamics

coverage_dependent_surf.py

This example demonstrates (1). the four different dependency models available for coverage-dependent enthalpy and entropy calculations and (2). capability of including self-interaction but also cross-interaction among different surface species.

critical_properties.py

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

equivalenceRatio.py

This example demonstrates how to set a mixture according to equivalence ratio and mixture fraction.

isentropic.py

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

isentropic_units.py

Isentropic, adiabatic flow example - calculate area ratio vs. Mach number curve. Uses the pint library to include customized units in the calculation.

mixing.py

Mixing two streams using `Quantity` objects.

rankine.py

Calculate the efficiency of a Rankine vapor power cycle using a pure fluid model for water.

rankine_units.py

Calculate the efficiency of a Rankine vapor power cycle using a pure fluid model for water. Includes the units of quantities in the calculations.

sound_speed.py

Compute the "equilibrium" and "frozen" sound speeds for a gas.

sound_speed_units.py

Compute the "equilibrium" and "frozen" sound speeds for a gas. Uses the pint library to include customized units in the calculation.

vapordome.py

This example generates a saturated steam table and plots the vapor dome. The steam table corresponds to data typically found in thermodynamic text books and uses the same customary units.

Kinetics

blowers_masel.py

A simple example to demonstrate the difference between Blowers-Masel reaction and elementary reaction.

custom_reactions.py

An example demonstrating how to use custom reaction objects.

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

Calculate transport properties in a porous medium using the dusty gas transport model.

multiprocessing_viscosity.py

This example demonstrates how Cantera can be used with the 'multiprocessing' module.

Reactor Networks

combustor.py

Calculate steady-state solutions for a combustor, modeled as a single well-stirred reactor, for different residence times.

custom2.py

Solve an ignition problem where the normal reactor governing equations are extended with additional equations implemented in Python.

custom.py

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

fuel_injection.py

Simulation of fuel injection into a vitiated air mixture to show formation of soot precursors.

ic_engine.py

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

mix1.py

Mixing two streams.

NonIdealShockTube.py

Ignition delay time computations in a high-pressure reflected shock tube reactor, comparing ideal gas and Redlich-Kwong real gas models.

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 that moves with a speed proportional to the pressure difference between the reactors.

PorousMediaBurner.py

Short description: reactor cascade model for reactive flows in inert porous media based on extensible reactors. Showcases adding a temperature equation for a solid-phase and custom heat transfer/radiation models.

preconditioned_integration.py

Ideal gas, constant-pressure, adiabatic kinetics simulation that compares preconditioned and non-preconditioned integration of nDodecane.

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 with surface chemistry. The specific problem simulated is the partial oxidation of methane over a platinum catalyst in a packed bed reactor. This example solves the DAE system directly, using the FlowReactor class and the SUNDIALS IDA solver, in contrast to the approximation as a chain of steady-state WSRs used in surf_pfr_chain.py.

surf_pfr_chain.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. To avoid needing to solve a DAE system, the PFR is approximated as a chain of successive WSRs. See surf_pfr.py for a more advanced implementation that solves the DAE system directly.

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.

flame_initial_guess.py

A freely-propagating, premixed methane-air flame. Examples of saving and loading a flame and restarting with different initial guesses.

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.

ion_burner_flame.py

A burner-stabilized premixed methane-air flame with charged species.

ion_free_flame.py

A freely-propagating, premixed methane-air flat flame with charged species.

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

1D_pfr_surfchem.py

A 1-D steady state plug-flow reactor demonstrating silicon nitride (Si3N4) deposition from ammonia (NH3) and silicon tetrafluoride (SiF4).

catalytic_combustion.py

Catalytic combustion of methane on platinum.

diamond_cvd.py

A CVD example simulating growth of a diamond film.

lithium_ion_battery.py

This example calculates the cell voltage of a lithium-ion battery at given temperature, pressure, current, and range of state of charge (SOC).

sofc.py

A simple model of a solid oxide fuel cell.