:orphan:
.. _examples:
Examples
========
This section shows how to use PyChemkin utilities and reactor models to perform different types of simulations. Early examples demonstrate how to perform essential operations, such as loading and preprocessing the chemistry set. Later examples explain how to tackle more complex simulations, such as running an ignition delay parameter study. Thus, you should go through the examples in the order listed.
.. raw:: html
.. thumbnail-parent-div-open
.. thumbnail-parent-div-close
.. raw:: html
Chemistry
=========
PyChemkin examples to demonstrate basic operations for
instantiating *Chemistry Set* from the gas-phase mechanism
and the thermodynamic/transport data files.
The examples walk through the steps about how to pre-process the
*Chemistry Set*, retrieve mechanism information and the species properties,
as well as how to handle multiple *Chemistry Sets* in a **Python Chemkin**
project.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/chemistry/images/thumb/sphx_glr_loadmechanism_thumb.png
:alt:
:doc:`/examples/chemistry/loadmechanism`
.. raw:: html
Preprocess a gas-phase mechanism
.. raw:: html
.. only:: html
.. image:: /examples/chemistry/images/thumb/sphx_glr_multiplemechanisms_thumb.png
:alt:
:doc:`/examples/chemistry/multiplemechanisms`
.. raw:: html
Work with multiple mechanisms
.. raw:: html
.. only:: html
.. image:: /examples/chemistry/images/thumb/sphx_glr_simple_thumb.png
:alt:
:doc:`/examples/chemistry/simple`
.. raw:: html
Set up a PyChemkin project
.. raw:: html
.. only:: html
.. image:: /examples/chemistry/images/thumb/sphx_glr_speciesproperties_thumb.png
:alt:
:doc:`/examples/chemistry/speciesproperties`
.. raw:: html
Evaluate gas species properties
.. thumbnail-parent-div-close
.. raw:: html
Mixture
=======
*Mixture* is the "core" token in **PyChemkin**. It represents a gas-phase mixture by storing
its pressure, temperature, and species composition. *Stream* is an extended "Class" of *Mixture*
with the additional attribute of "mass/volumetric flow rate". *Mixture* and *Stream* include utilities
that can be used to evaluate the mixture properties (density, mixture enthalpy, mixture viscosity, ...)
and the reaction rates. There are also methods to manipulate the *Mixture*/*Stream* such as merging two mixtures
adiabatically.
The examples demonstrate how to instantiate the *Mixture*/*Stream* objects, how to extract information and properties
of a *Mixture*/*Stream*, and how to manipulate *Mixture*/*Stream* objects.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_adiabaticflametemperature_thumb.png
:alt:
:doc:`/examples/mixture/adiabaticflametemperature`
.. raw:: html
Estimate the adiabatic flame temperature of a gas mixture
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_createmixture_thumb.png
:alt:
:doc:`/examples/mixture/createmixture`
.. raw:: html
Create a mixture
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_detonation_thumb.png
:alt:
:doc:`/examples/mixture/detonation`
.. raw:: html
Calculate the detonation wave speed of a real-gas mixture
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_equilibriumcomposition_thumb.png
:alt:
:doc:`/examples/mixture/equilibriumcomposition`
.. raw:: html
Estimate the steady-state NO emission level of a complete burned fuel-air mixture
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_heatingvalues_thumb.png
:alt:
:doc:`/examples/mixture/heatingvalues`
.. raw:: html
Calculate the heating values of fuel mixtures
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_mixturemixing_thumb.png
:alt:
:doc:`/examples/mixture/mixturemixing`
.. raw:: html
Combine gas mixtures
.. raw:: html
.. only:: html
.. image:: /examples/mixture/images/thumb/sphx_glr_reactionrates_thumb.png
:alt:
:doc:`/examples/mixture/reactionrates`
.. raw:: html
Rank reaction rates
.. thumbnail-parent-div-close
.. raw:: html
Batch reactor
=============
The *batch reactor* is an idealized 0-D transient closed reactor model in which the gas inside
the reactor is assumed to be homogeneous. When the pressure of the *batch reactor* is constrained,
the reactor volume would vary to conserve the total gas mass. Likewise, the reactor pressure might
change when the reactor volume is "given". The gas temperature can be "given" by piecewise linear
profile data or solved by the energy equation.
The examples consist of projects that utilize the *batch reactor* model to perform simulations of
various complexities, from tracking the evolution of the mixture properties to the A-factor sensitivity
analysis.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/batch/images/thumb/sphx_glr_closed_homogeneous__transient_thumb.png
:alt:
:doc:`/examples/batch/closed_homogeneous__transient`
.. raw:: html
Simulate hydrogen combustion in a constant-pressure reactor
.. raw:: html
.. only:: html
.. image:: /examples/batch/images/thumb/sphx_glr_ignitiondelay_thumb.png
:alt:
:doc:`/examples/batch/ignitiondelay`
.. raw:: html
Predict the ignition delay time of a combustible mixture
.. raw:: html
.. only:: html
.. image:: /examples/batch/images/thumb/sphx_glr_rcm_thumb.png
:alt:
:doc:`/examples/batch/rcm`
.. raw:: html
Simulate a rapid compression machine
.. raw:: html
.. only:: html
.. image:: /examples/batch/images/thumb/sphx_glr_sensitivity_thumb.png
:alt:
:doc:`/examples/batch/sensitivity`
.. raw:: html
Perform brute-force sensitivity analysis
.. raw:: html
.. only:: html
.. image:: /examples/batch/images/thumb/sphx_glr_vapor_thumb.png
:alt:
:doc:`/examples/batch/vapor`
.. raw:: html
Explore cooling water vapor
.. thumbnail-parent-div-close
.. raw:: html
0-D engine models
=================
**PyChemkin** offers two types of 0-D engine models: the *Homogeneous Charged Compression Ignition (HCCI)* engine model
and the *Spark Ignition (SI)* engine model. These 0-D engine models simulate the combustion process (or the lack of, in case of a misfire)
inside an engine cylinder between the *Intake Valve Close (IVC)* and the *Exhaust Valve Open (EVO)* when the
cylinder is considered as a closed system. The Chemkin *Theory* manual has detailed descriptions of these 0-D engine models.
The examples show the steps of setting up simulations with different *Chemkin* engine models.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/engine/images/thumb/sphx_glr_hcciengine_thumb.png
:alt:
:doc:`/examples/engine/hcciengine`
.. raw:: html
Simulate a single-zone HCCI engine
.. raw:: html
.. only:: html
.. image:: /examples/engine/images/thumb/sphx_glr_multizone_thumb.png
:alt:
:doc:`/examples/engine/multizone`
.. raw:: html
Simulate a multi-zone HCCI engine
.. raw:: html
.. only:: html
.. image:: /examples/engine/images/thumb/sphx_glr_sparkignitioengine_thumb.png
:alt:
:doc:`/examples/engine/sparkignitioengine`
.. raw:: html
Simulate a spark ignition engine
.. thumbnail-parent-div-close
.. raw:: html
Perfectly stirred reactor
=========================
The *perfectly Stirred reactor (PSR)* model is a 0-D steady-state reactor.
This ideal reactor model assumes the gas mixture inside is uniform and
the properties of the outlet stream are exactly the same as the gas properties
inside the reactor. A PSR can have either its pressure or its volume "specified",
and the reactor temperature can either be solved from the energy equation or
be "given" as an input parameter.
The examples will show the procedures of setting up single PSR simulations with
different constraints and with multiple inlet streams.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/PSR/images/thumb/sphx_glr_PSRgas_thumb.png
:alt:
:doc:`/examples/PSR/PSRgas`
.. raw:: html
Set up a PSR parameter study for the inlet stream equivalence ratio
.. raw:: html
.. only:: html
.. image:: /examples/PSR/images/thumb/sphx_glr_jetstirredreactor_thumb.png
:alt:
:doc:`/examples/PSR/jetstirredreactor`
.. raw:: html
Run PSR calculations for mechanism validation
.. raw:: html
.. only:: html
.. image:: /examples/PSR/images/thumb/sphx_glr_multi-inletPSR_thumb.png
:alt:
:doc:`/examples/PSR/multi-inletPSR`
.. raw:: html
Determine the impact of residence time on combustion in a PSR
.. thumbnail-parent-div-close
.. raw:: html
Plug-flow reactor
=================
*Plug-Flow Reactor (PFR)* model is an idealized 1-D steady-state flow reactor model with single
inlet stream. The reactor pressure is assumed to be given, and the mass (flow rate) conservation
is maintained by the velocity change. The gas temperature along the reactor can be either specified
or solved by the energy equation.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/PFR/images/thumb/sphx_glr_plugflow_thumb.png
:alt:
:doc:`/examples/PFR/plugflow`
.. raw:: html
Simulate NO reduction in combustion exhaust
.. thumbnail-parent-div-close
.. raw:: html
PSR network
===========
**PyChemkin** can be used to create an *Equivalence Reactor Network (ERN)* as a reduced-order
(in geometry) model for complex combustion applications such as gas turbine combustor.
Each reactor in the network represents a sub-region (zone) in the actual equipment. Normally these zones
are created according to specific criteria such as temperature, equivalence ratio, or location; and the gas flow
(mean, turbulent, and diffusive) between the zones becomes the internal streams between the reactors.
There are several ways to build an *ERN* in **PyChemkin**. The first method is to create and solve the reactors one-by-one
starting from the most upstream (first) reactor. Adjust/manipulate the external and outlet streams from connected reactors
(that is, solutions from the reactors) using the *Mixture*/*Stream* utilities and apply the desired stream as the inlet for
the downstream reactors. The second method takes advantage of the *hybridreactornetwork* "model" of **PyChemkin**.
Simply defined the reactors with the associated external inlets and add the reactors to the *hybridreactornetwork*.
If there are *recycling* streams from the downstream reactor to the upstream ones, the *hybridreactornetwork* will solve the
entire *ERN* iteratively. In this case, a *tear point* must be explicitly specified. The last method, the coupled method,
is to create the network and its connectivity first, and the entire *ERN* will be solved in a coupled manner. This method
is the default method in Chemkin GUI and is available as the *PSRCluster* "model" in **PyChemkin**.
Chemkin *ERN* has a few limitations:
* The first reactor of the reactor network must have at least one external inlet.
* when using the *coupled* model, the entire reactor network can have only one outlet to the surroundings, and the outlet must be attached to
the last reactor in the network.
* PSR is the only reactor model allowed in the *PSRCluster* and the *hybridreactornetwork* reactor networks.
The *PSRChain_xxx* examples show the two methods to build and run a series of linked PSRs (no stream recycling) can be modeled in **PyChemkin**.
The *PSRnetwork* example goes over the steps of creating and running an *ERN* with recycling streams by using the *hybridreactornetwork* method.
The *PSRnetwork_coupled* example solves the same *ERN* as the *PSRnetwork* example but utilizes the *coupled* method. Because the sole outlet from
the *coupled ERN* must be attached to the last reactor, the order of the downstream zones is different from the *PSRnetwork* example.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/reactor_network/images/thumb/sphx_glr_PSRChain_declustered_thumb.png
:alt:
:doc:`/examples/reactor_network/PSRChain_declustered`
.. raw:: html
Use a chain of individual reactors to model a gas combustor
.. raw:: html
.. only:: html
.. image:: /examples/reactor_network/images/thumb/sphx_glr_PSRChain_network_thumb.png
:alt:
:doc:`/examples/reactor_network/PSRChain_network`
.. raw:: html
Use a chain reactor network to model a gas combustor
.. raw:: html
.. only:: html
.. image:: /examples/reactor_network/images/thumb/sphx_glr_PSRnetwork_thumb.png
:alt:
:doc:`/examples/reactor_network/PSRnetwork`
.. raw:: html
Simulate a combustor using an equivalent reactor network with stream recycling
.. thumbnail-parent-div-close
.. raw:: html
Premixed flame models
=====================
The *Premixed Flame* model is a 1-D steady-state application, and it contains two sub-models:
*"flame speed calculator"* (or the freely propagating flame model) and *"flat flame"* model.
The *flame speed calculator* is commonly used to calculate the laminar flame speed of a premixed
fuel-oxidizer mixture. The predicted/computed flame speeds can be used to validate a combustion
mechanism or can serve as a prre-processor to construct a "flame speed table" or a
"combustion progress table" for other applications. The *flat flame* burner-stablized model is
primarily used to study the flame chemistry in conjunction with the flat flame experiments.
The examples show different ways to perform the "premixed flame" calculations.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/premixed_flame/images/thumb/sphx_glr_flamespeed_thumb.png
:alt:
:doc:`/examples/premixed_flame/flamespeed`
.. raw:: html
Compute the laminar flame speed of diluted hydrogen at low pressure
.. raw:: html
.. only:: html
.. image:: /examples/premixed_flame/images/thumb/sphx_glr_methane_flamespeed_table_thumb.png
:alt:
:doc:`/examples/premixed_flame/methane_flamespeed_table`
.. raw:: html
Construct atmospheric methane-air flame speed versus equivalence ratio table
.. raw:: html
.. only:: html
.. image:: /examples/premixed_flame/images/thumb/sphx_glr_premixedburnerflame_thumb.png
:alt:
:doc:`/examples/premixed_flame/premixedburnerflame`
.. raw:: html
Simulate a burner stabilized premixed flame
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
:includehidden:
/examples/chemistry/index.rst
/examples/mixture/index.rst
/examples/batch/index.rst
/examples/engine/index.rst
/examples/PSR/index.rst
/examples/PFR/index.rst
/examples/reactor_network/index.rst
/examples/premixed_flame/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: examples_python.zip `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download all examples in Jupyter notebooks: examples_jupyter.zip `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_