:orphan:

Python Examples
===============

.. seealso::

    To find examples covering a specific topic, see the
    :ref:`index of example tags <tagoverview>`.

    If you're just getting started with Cantera, see our
    :doc:`/userguide/python-tutorial` for an introduction to the Cantera Python interface.



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. thumbnail-parent-div-close

.. raw:: html

    </div>

Thermodynamics
--------------



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, air and methane are mixed in stoichiometric proportions. This is a simpler, steady-state version of the example ../reactors/mix1.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_mixing_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_mixing.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Mixing using Quantity objects</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Print the critical state properties for the fluids for which Cantera has built-in liquid/vapor equations of state.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_critical_properties_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_critical_properties.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Critical state properties</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Calculate the area ratio vs. Mach number curve for a mixture accelerating to supersonic speed through a converging--diverging nozzle, assuming isentropic, adiabatic flow.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_isentropic_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_isentropic.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Converging-Diverging Nozzle</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="An equilibrium example with charged species in the gas phase and multiple condensed phases.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_plasma_equilibrium_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_plasma_equilibrium.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Equilibrium with charged species and multiple condensed phases</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Calculate the efficiency of a Rankine vapor power cycle using a pure fluid model for water.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_rankine_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_rankine.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Rankine cycle</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Calculate the efficiency of a Rankine vapor power cycle using a pure fluid model for water. Includes the units of quantities in the calculations.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_rankine_units_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_rankine_units.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Rankine cycle (with units)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Adiabatic flame temperature and equilibrium composition for a fuel/air mixture as a function of equivalence ratio, including formation of solid carbon.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_adiabatic_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_adiabatic.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Adiabatic flame temperature including solid carbon formation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Air-plasma-Phelps.yaml mechanism file is derived from Phelps cross section data A compilation of atomic and molecular cross-section data assembled by A. V. Phelps in the 1970s–1980s for gases such as O₂, N₂, He, Ar, etc. The compilation itself is unpublished; data used from it are cited as: A. V. Phelps, private communication (compilation of electron cross-sections), retrieved [8/1/25], from Phelps collection. (see http://www.lxcat.net/contributors/#d19).">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_plasma-eedf_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_plasma-eedf.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">EEDF calculation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Compute the &quot;equilibrium&quot; and &quot;frozen&quot; sound speeds for a gas. Uses the pint library to include customized units in the calculation.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_sound_speed_units_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_sound_speed_units.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Sound speeds (with units)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Compute the &quot;equilibrium&quot; and &quot;frozen&quot; sound speeds for a gas">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_sound_speed_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_sound_speed.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Sound speeds</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Isentropic, adiabatic flow example - calculate area ratio vs. Mach number curve. Uses the pint library to include customized units in the calculation.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_isentropic_units_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_isentropic_units.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Isentropic, adiabatic flow (with units)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_vapordome_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_vapordome.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vapor Dome</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to set a mixture according to equivalence ratio and mixture fraction.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_equivalenceRatio_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_equivalenceRatio.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Equivalence ratio</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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. See the input file ../../input/covdepsurf for the method of defining the coverage-dependency parameters.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_coverage_dependent_surf_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_coverage_dependent_surf.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Surface with coverage-dependent thermo</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates a comparison between ideal and non-ideal equations of state (EoS) using Cantera and CoolProp.">

.. only:: html

  .. image:: /examples/python/thermo/images/thumb/sphx_glr_equations_of_state_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_thermo_equations_of_state.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Non-ideal equations of state</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

Kinetics
--------



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This script uses Graphviz to generate an image. You must have Graphviz installed and the program &#x27;dot&#x27; must be on your path for this example to work. Graphviz can be obtained from https://www.graphviz.org/ or (possibly) installed using your operating system&#x27;s package manager.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_reaction_path_thumb.svg
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_reaction_path.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Viewing a reaction path diagram</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example computes the growth rate of a diamond film according to a simplified version of a particular published growth mechanism (see ../../input/diamond for details). Only the surface coverage equations are solved here; the gas composition is fixed. (For an example of coupled gas-phase and surface, see ../onedim/catalytic_combustion.) Atomic hydrogen plays an important role in diamond CVD, and this example computes the growth rate and surface coverages as a function of [H] at the surface for fixed temperature and [CH3].">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_diamond_cvd_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_diamond_cvd.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Growth of diamond film using CVD</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simulate species profiles for a shock tube as a function of time, and observe the impact of incorporating the reduced-pressure linear mixture rule (LMR-R) in such calculations.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_shock_tube_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_shock_tube.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Shock-tube species profiles as a function of time</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_extract_submechanism_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_extract_submechanism.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Extracting a sub-mechanism</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A simplistic approach to mechanism reduction which demonstrates Cantera&#x27;s features for dynamically manipulating chemical mechanisms.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_mechanism_reduction_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_mechanism_reduction.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Mechanism reduction</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A simple example to demonstrate the difference between Blowers-Masel reaction and elementary reaction.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_blowers_masel_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_blowers_masel.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Blowers-Masel reaction rates</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simulate temperature profiles and species profiles in a jet-stirred reactor across a range of initial temperatures, and observe the impact of incorporating the reduced-pressure linear mixture rule (LMR-R) in such calculations.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_jet_stirred_reactor_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_jet_stirred_reactor.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Jet-stirred reactor temperature and species profiles</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we illustrate how to calculate the open circuit voltage (voltage when the external applied current is zero) for a lithium ion battery as a function of anode and cathode lithium content. The open circuit voltage here is calculated via two means: kinetically and thermodynamically.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_lithium_ion_battery_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_lithium_ion_battery.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Lithium Ion Battery Discharge Curve</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="An example demonstrating how to use custom reaction objects.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_custom_reactions_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_custom_reactions.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom reaction rates</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A simple model of a solid oxide fuel cell.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_sofc_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_sofc.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Solid oxide fuel cell using elementary kinetics</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example uses ipywidgets to create interactive displays of reaction path diagrams from Cantera simulations.">

.. only:: html

  .. image:: /examples/python/kinetics/images/thumb/sphx_glr_interactive_path_diagram_thumb.svg
    :alt:

  :ref:`sphx_glr_examples_python_kinetics_interactive_path_diagram.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Interactive Reaction Path Diagrams</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

Transport
---------



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The dusty gas model is a multicomponent transport model for gas transport through the pores of a stationary porous medium. This example shows how to create a DustyGasTransport transport manager and use it to compute the multicomponent diffusion coefficients and thermal conductivity.">

.. only:: html

  .. image:: /examples/python/transport/images/thumb/sphx_glr_dusty_gas_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_transport_dusty_gas.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Porous media transport using the dusty gas model</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how Cantera can be used with the multiprocessing module.">

.. only:: html

  .. image:: /examples/python/transport/images/thumb/sphx_glr_multiprocessing_viscosity_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_transport_multiprocessing_viscosity.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Parallelizing transport property calculations</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Two high-pressure gas transport models are available in Cantera: the high-pressure and the high-pressure-Chung models. These models utilize critical fluid properties and other fluid-specific parameters to calculate transport properties at high pressures. These models are useful for fluids that are supercritical where ideal gas assumptions do not yield accurate results.">

.. only:: html

  .. image:: /examples/python/transport/images/thumb/sphx_glr_high_pressure_transport_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_transport_high_pressure_transport.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">High-Pressure transport using two models</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

Reactor networks
----------------



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Since reactors can have multiple inlets and outlets, they can be used to implement mixers, splitters, etc. In this example, air and methane are mixed in stoichiometric proportions. Due to the low temperature, no reactions occur. Note that the air stream and the methane stream use different reaction mechanisms, with different numbers of species and reactions. When gas flows from one reactor or reservoir to another one with a different reaction mechanism, species are matched by name. If the upstream reactor contains a species that is not present in the downstream reaction mechanism, it will be ignored. In general, reaction mechanisms for downstream reactors should contain all species that might be present in any upstream reactor.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_mix1_thumb.svg
    :alt:

  :ref:`sphx_glr_examples_python_reactors_mix1.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Mixing two streams</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example illustrates a continuously stirred tank reactor (CSTR) with steady inputs but periodic interior state.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_periodic_cstr_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_periodic_cstr.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Continuously stirred tank reactor with periodic behavior</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Calculate steady-state solutions for a combustor, modeled as a single well-stirred reactor, for different residence times.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_combustor_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_combustor.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Combustor residence time</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Requires: cantera &gt;= 3.2.0, matplotlib &gt;= 2.0">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_reactor1_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_reactor1.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Constant-pressure, adiabatic kinetics simulation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This file uses a similar approach as custom.py, where the governing equations are implemented in Python, to solve the electron concentration in a plasma.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_plasma_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_plasma.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plasma Reactor</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Two reactors separated by a piston that moves with a speed proportional to the pressure difference between the reactors.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_piston_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_piston.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Reactors separated by a moving piston</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Solve a constant pressure ignition problem where the governing equations are implemented in Python.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_custom_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_custom.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Integrating constant pressure ignition using SciPy</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Requires: cantera &gt;= 3.2.0, matplotlib &gt;= 2.0">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_sensitivity1_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_sensitivity1.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Constant-pressure, adiabatic kinetics simulation with sensitivity analysis</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example simulates 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.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_surf_pfr_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_surf_pfr.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plug flow reactor with surface chemistry</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Ideal gas, constant-pressure, adiabatic kinetics simulation that compares preconditioned and non-preconditioned integration of n-hexane.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_preconditioned_integration_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_preconditioned_integration.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Acceleration of reactor integration using a sparse preconditioned solver</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Two reactors connected with a piston, with heat loss to the environment">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_reactor2_thumb.svg
    :alt:

  :ref:`sphx_glr_examples_python_reactors_reactor2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Reactors with walls and heat transfer</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simulation of fuel injection into a vitiated air mixture to show formation of soot precursors.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_fuel_injection_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_fuel_injection.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Soot precursor formation with time-varying mass flow rate</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Solve an ignition problem where the normal reactor governing equations are extended with additional equations implemented in Python.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_custom2_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_custom2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Using ExtensibleReactor to implement wall inertia</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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 for a more advanced implementation that solves the DAE system directly.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_surf_pfr_chain_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_surf_pfr_chain.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plug flow reactor modeled as a chain of well stirred reactors</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A 1-D steady state plug-flow reactor demonstrating silicon nitride (Si3N4) deposition from ammonia (NH3) and silicon tetrafluoride (SiF4).">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_1D_pfr_surfchem_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_1D_pfr_surfchem.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plug flow reactor: silicon nitride deposition</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_pfr_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_pfr.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plug flow reactor modeling approaches</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example simulates a nanosecond-scale pulse discharge in a reactor. A Gaussian-shaped electric field pulse is applied over a short timescale. The plasma reaction mechanism used is based on Colin Pavan&#x27;s mechanism for methane-air plasmas which is described in his Ph.D. dissertation and the corresponding AIAA SciTech conference papers:">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_nanosecond_pulse_discharge_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_nanosecond_pulse_discharge.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Nanosecond Pulse Plasma Simulation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example we will illustrate how Cantera can be used to simulate a continuously stirred tank reactor (CSTR), also interchangeably referred to as a perfectly stirred reactor (PSR), a well stirred reactor (WSR), a jet stirred reactor (JSR), or a Longwell reactor (and there may well be more &quot;aliases&quot;).">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_continuous_reactor_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_continuous_reactor.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Continuously Stirred Tank Reactor</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example we illustrate how to setup and use a constant volume, adiabatic reactor to simulate reflected shock tube experiments. This reactor is then used to compute the ignition delay of a gas at a specified initial temperature and pressure.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_non_ideal_shock_tube_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_non_ideal_shock_tube.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Ignition delay time using the Redlich-Kwong real gas model</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The simulation uses n-dodecane as fuel, which is injected close to top dead center. Note that this example uses numerous simplifying assumptions and thus serves for illustration purposes only.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_ic_engine_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_ic_engine.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Diesel-type internal combustion engine simulation with gaseous fuel</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The model shown in this example simulates heterogeneous catalytic processes inside packed-bed, catalytic membrane reactors. The gas-phase and surface-phase species conservation equations are derived and the system of differential-algebraic equations (DAE) is solved using the scikits.odes.dae IDA solver.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_1D_packed_bed_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_1D_packed_bed.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">One-dimensional packed-bed, catalytic-membrane reactor</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Showcases the use of ExtensibleReactor to add a temperature equation for a solid-phase and custom heat transfer/radiation models.">

.. only:: html

  .. image:: /examples/python/reactors/images/thumb/sphx_glr_porous_media_burner_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_reactors_porous_media_burner.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Reactor cascade model for reactive flows in inert porous media</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

1D reacting flows
-----------------



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simulate flame speeds across a range of equivalence ratios, and observe the impact of incorporating the reduced-pressure linear mixture rule (LMR-R) in such calculations.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_flame_speed_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_flame_speed.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Flame speed as a function of equivalence ratio</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A burner-stabilized premixed methane-air flame with charged species.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_ion_burner_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_ion_burner_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Burner-stabilized flame including ionized species</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A burner-stabilized lean premixed hydrogen-oxygen flame at low pressure.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_burner_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_burner_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Burner-stabilized flame</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="An opposed-flow ethane/air diffusion flame">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_diffusion_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_diffusion_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Counterflow diffusion flame</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This script simulates a lean hydrogen-oxygen flame stabilized in a strained flowfield, with an opposed flow consisting of equilibrium products.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_premixed_counterflow_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_premixed_counterflow_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Opposed-flow premixed strained flame</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A freely-propagating, premixed methane-air flat flame with charged species.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_ion_free_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_ion_free_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Freely-propagating flame with charged species</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example we simulate a freely-propagating, adiabatic, premixed methane-air flame, calculate its laminar burning velocity and perform a sensitivity analysis of its kinetics with respect to each reaction rate constant.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_flamespeed_sensitivity_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_flamespeed_sensitivity.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Laminar flame speed sensitivity analysis</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This script solves a catalytic combustion problem. A stagnation flow is set up, with a gas inlet 10 cm from a platinum surface at 900 K. The lean, premixed methane/air mixture enters at ~6 cm/s (0.06 kg/m2/s), and burns catalytically on the platinum surface. Gas-phase chemistry is included too, and has some effect very near the surface.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_catalytic_combustion_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_catalytic_combustion.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Catalytic combustion of methane on platinum</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This script simulates a lean hydrogen-oxygen flame stabilized in a strained flowfield at an axisymmetric stagnation point on a non-reacting surface. The solution begins with a flame attached to the inlet (burner), and the mass flow rate is progressively increased, causing the flame to detach and move closer to the surface.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_stagnation_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_stagnation_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Detached flat flame stabilized at a stagnation point</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A freely-propagating, premixed hydrogen flat flame with multicomponent transport properties.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_adiabatic_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_adiabatic_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Laminar flame speed calculation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A burner-stabilized, premixed methane/air flat flame with multicomponent transport properties and a specified temperature profile.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_flame_fixed_T_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_flame_fixed_T.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Burner-stabilized flame with imposed temperature profile</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A freely-propagating, premixed methane-air flame. Examples of saving and loading a flame and restarting with different initial guesses.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_flame_initial_guess_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_flame_initial_guess.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Saving, loading, and restarting 1D calculations</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Simulate two counter-flow jets of premixed reactants shooting into each other. This simulation differs from the similar premixed_counterflow_flame example as the latter simulates a jet of reactants shooting into products.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_premixed_counterflow_twin_flame_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_premixed_counterflow_twin_flame.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Symmetric premixed twin flame</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example computes the extinction point of a counterflow diffusion flame. A hydrogen-oxygen diffusion flame at 1 bar is studied.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_diffusion_flame_extinction_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_diffusion_flame_extinction.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Diffusion flame extinction strain rate</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example uses the two-point flame control feature to march solutions down the stable and unstable burning branch for a counterflow diffusion flame. A hydrogen-oxygen diffusion flame at 1 bar is studied.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_diffusion_flame_continuation_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_diffusion_flame_continuation.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Diffusion flame unstable branch</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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.">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_diffusion_flame_batch_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_diffusion_flame_batch.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Scaling of diffusion flames with pressure and strain rate</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Requires: cantera &gt;= 3.0.0, matplotlib &gt;= 2.0, pandas">

.. only:: html

  .. image:: /examples/python/onedim/images/thumb/sphx_glr_flame_speed_convergence_analysis_thumb.png
    :alt:

  :ref:`sphx_glr_examples_python_onedim_flame_speed_convergence_analysis.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Flame Speed with Convergence Analysis</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:
   :includehidden:


   /examples/python/thermo/index.rst
   /examples/python/kinetics/index.rst
   /examples/python/transport/index.rst
   /examples/python/reactors/index.rst
   /examples/python/onedim/index.rst


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: python_python.zip </examples/python/python_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: python_jupyter.zip </examples/python/python_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
