Reactors and Reactor Networks¶
Cantera Reactors and Reactor Networks model zerodimensional reactors and their interactions with the surroundings.
Reactors¶
A Cantera Reactor()
represents the simplest form of a chemically reacting system. It
corresponds to an extensive thermodynamic control volume \(V\), in which all state variables are
homogeneously distributed. The system is generally unsteady — that is, all states are functions of time.
In particular, transient state changes due to chemical reactions are possible. However,
thermodynamic (but not chemical) equilibrium is assumed to be present throughout the reactor at all
instants of time.
Reactors can interact with the surrounding environment in multiple ways:
Expansion/compression work: By moving the walls of the reactor, its volume can be changed and expansion or compression work can be done by or on the reactor.
Heat transfer: An arbitrary heat transfer rate can be defined to cross the boundaries of the reactor.
Mass transfer: The reactor can have multiple inlets and outlets. For the inlets, arbitrary states can be defined. Fluid with the current state of the reactor exits the reactor at the outlets.
Surface interaction: One or multiple walls can influence the chemical reactions in the reactor. This is not just restricted to catalytic reactions, but mass transfer between the surface and the fluid can also be modeled.
All of these interactions do not have to be constant, but can vary as a function of time or state. For example, heat transfer can be described as a function of the temperature difference between the reactor and the environment, or the wall movement can be modeled depending on the pressure difference. Interactions of the reactor with the environment are defined on one or more walls, inlets, and outlets.
In addition to single reactors, Cantera is also able to interconnect reactors into a Reactor Network. Each reactor in a network may be connected so that the contents of one reactor flow into another. Reactors may also be in contact with one another or the environment via walls that conduct heat or move to do work.
Governing Equations for Single Reactors¶
The state variables for Cantera’s general reactor model are
\(m\), the mass of the reactor’s contents (in kg)
\(V\), the reactor volume (in m^{3}) (not a state variable for
ConstPressureReactor()
andIdealGasConstPressureReactor()
)
A state variable describing the energy of the system, depending on the configuration (see Energy Conservation for further explanation):
General
Reactor()
: \(U\), the total internal energy of the reactors contents (in J)ConstPressureReactor()
: \(H\), the total enthalpy of the reactors contents (in J)IdealGasReactor()
andIdealGasConstPressureReactor()
: \(T\), the temperature (in K)
\(Y_k\), the mass fractions for each species (dimensionless)
Mass Conservation¶
The total mass of the reactor’s contents changes as a result of flow through the reactor’s inlets and outlets, and production of homogeneous phase species on the reactor walls:
Species Conservation¶
The rate at which species \(k\) is generated through homogeneous phase reactions is \(V \dot{\omega}_k W_k\), and the total rate at which species \(k\) is generated is:
The rate of change in the mass of each species is:
Expanding the derivative on the left hand side and substituting the equation for \(dm/dt\), the equation for each homogeneous phase species is:
Reactor Volume¶
The reactor volume changes as a function of time due to the motion of one or more walls:
where \(f_w = \pm 1\) indicates the facing of the wall (whether moving the wall increases or decreases the volume of the reactor), \(A_w\) is the surface area of the wall, and \(v_w(t)\) is the velocity of the wall as a function of time.
For the ConstPressureReactor()
and IdealGasConstPressureReactor()
, the
volume is not a state variable, but instead takes on whatever value is
consistent with holding the pressure constant.
Energy Conservation¶
The solution of the energy equation can be enabled or disabled by changing the
energy_enabled
flag. It is enabled by default.
The implemented formulation of the energy equation depends on which reactor model is used.
Standard Reactor¶
The equation for the total internal energy is found by writing the first law for an open system:
Constant Pressure Reactor¶
For this reactor model, the pressure is held constant. The volume is not a state variable, but instead takes on whatever value is consistent with holding the pressure constant. The total enthalpy replaces the total internal energy as a state variable. Using the definition of the total enthalpy:
Noting that \(dp/dt = 0\) and substituting into the energy equation yields:
Ideal Gas Reactor¶
In case of the Ideal Gas Reactor Model, the reactor temperature \(T\) is used instead of the total internal energy \(U\) as a state variable. For an ideal gas, we can rewrite the total internal energy in terms of the mass fractions and temperature:
Substituting the corresponding derivatives yields an equation for the temperature:
While this form of the energy equation is somewhat more complicated, it significantly reduces the cost of evaluating the system Jacobian, since the derivatives of the species equations are taken at constant temperature instead of constant internal energy.
Ideal Gas Constant Pressure Reactor¶
As for the Ideal Gas Reactor, we replace the total enthalpy as a state variable with the temperature by writing the total enthalpy in terms of the mass fractions and temperature:
Substituting the corresponding derivatives yields an equation for the temperature:
Wall Interactions¶
Walls are stateless objects in Cantera, meaning that no differential equation is integrated to determine any wall property. Since it is the wall (piston) velocity that enters the energy equation, this means that it is the velocity, not the acceleration or displacement, that is specified. The wall velocity is computed from
where \(K\) is a nonnegative constant, and \(v_0(t)\) is a specified function of time. The velocity is positive if the wall is moving to the right.
The total rate of heat transfer through all walls is:
where \(f_w = \pm 1\) indicates the facing of the wall (+1 for the reactor on the left, 1 for the reactor on the right). The heat flux \(\dot{Q}_w\) through a wall \(w\) connecting reactors “left” and “right” is computed as:
where \(U\) is a userspecified heat transfer coefficient (W/m^{2}K), \(A\) is the wall area (m^{2}), \(\epsilon\) is the userspecified emissivity, \(\sigma\) is the StefanBoltzmann radiation constant, and \(q_0(t)\) is a userspecified, timedependent heat flux (W/m^{2}). This definition is such that positive \(q_0(t)\) implies heat transfer from the “left” reactor to the “right” reactor. Each of the userspecified terms defaults to 0.
In case of surface reactions, there can be a net generation (or destruction) of homogeneous (gas) phase species at the wall. The molar rate of production for each homogeneous phase species \(k\) on wall \(w\) is \(\dot{s}_{k,w}\) (in kmol/s/m^{2}). The total (mass) production rate for homogeneous phase species \(k\) on all walls is:
where \(W_k\) is the molecular weight of species \(k\) and \(A_w\) is the area of each wall. The net mass flux from all walls is then:
For each surface species \(i\), the rate of change of the site fraction \(\theta_{i,w}\) on each wall \(w\) is integrated with time:
where \(\Gamma_w\) is the total surface site density on wall \(w\) and \(n_i\) is the number of surface sites occupied by a molecule of species \(i\) (sometimes referred to within Cantera as the molecule’s “size”).
Reactor Networks and Devices¶
While reactors by themselves just define the above governing equations of the reactor, the time integration is performed in reactor networks. A reactor network is therefore necessary even if only a single reactor is considered.
The advantage of reactor networks obviously is that multiple reactors can be interconnected. Not only mass flow from one reactor into another can be realized, but also heat can be transferred, or the wall between reactors can move. To set up a network, the following components can be defined in addition to the reactors previously mentioned:
Reservoir()
: A reservoir can be thought of as an infinitely large volume, in which all states are predefined and never change from their initial values. Typically, it represents a vessel to define temperature and composition of a stream of mass flowing into a reactor, or the ambient fluid surrounding the reactor network. Besides, the fluid flow finally finally exiting a reactor network has to flow into a reservoir. In the latter case, the state of the reservoir (except pressure) is irrelevant.Wall()
: A wall separates two reactors, or a reactor and a reservoir. A wall has a finite area, may conduct or radiate heat between the two reactors on either side, and may move like a piston. See the Wall Interactions section for detail of how the wall affects the connected reactors.
Valve()
: A valve is a flow devices with mass flow rate that is a function of the pressure drop across it. The default behavior is linear:\begin{equation*} \dot m = K_v (P_1  P_2) \end{equation*}if \(P_1 > P_2.\) Otherwise, \(\dot m = 0\). However, an arbitrary function can also be specified, such that
\begin{equation*} \dot m = F(P_1  P_2) \end{equation*}if \(P_1 > P_2\), or \(\dot m = 0\) otherwise. It is never possible for the flow to reverse and go from the downstream to the upstream reactor/reservoir through a line containing a Valve object.
Valve objects are often used between an upstream reactor and a downstream reactor or reservoir to maintain them both at nearly the same pressure. By setting the constant \(K_v\) to a sufficiently large value, very small pressure differences will result in flow between the reactors that counteracts the pressure difference.

MassFlowController()
: A mass flow controller maintains a specified mass flow rate independent of upstream and downstream conditions. The equation used to compute the mass flow rate is\begin{equation*} \dot m = \max(\dot m_0, 0.0) \end{equation*}where \(\dot m_0\) is either a constant value or a function of time. Note that if \(\dot m_0 < 0\), the mass flow rate will be set to zero, since reversal of the flow direction is not allowed.
Unlike a real mass flow controller, a
MassFlowController()
object will maintain the flow even if the downstream pressure is greater than the upstream pressure. This allows simple implementation of loops, in which exhaust gas from a reactor is fed back into it through an inlet. But note that this capability should be used with caution, since no account is taken of the work required to do this. 
PressureController()
: A pressure controller is designed to be used in conjunction with another ‘master’ flow controller, typically a MassFlowController. The master flow controller is installed on the inlet of the reactor, and the correspondingPressureController()
is installed on on outlet of the reactor. ThePressureController()
mass flow rate is equal to the master mass flow rate, plus a small correction dependent on the pressure difference:\begin{equation*} \dot m = \dot m_{\mathrm{master}} + K_v(P_1  P_2). \end{equation*}
Time Integration¶
Cantera provides an ODE solver for solving the stiff equations of reacting systems. If Cantera is installed with SUNDIALS (the default), the optimized solver from SUNDIALS is used. Starting off the current state of the system, it can be advanced in time by one of the following methods:
step()
: The step method computes the state of the system at the a priori unspecified time \(t_{\mathrm{new}}\). The time \(t_{\mathrm{new}}\) is internally computed so that all states of the system only change within a (specifiable) band of absolute and relative tolerances. Additionally, the time step must not be larger than a predefined maximum time step \(\Delta t_{\mathrm{max}}\). The new time \(t_{\mathrm{new}}\) is returned by this function.advance
\((t_{\mathrm{new}})\): This method computes the state of the system at time \(t_{\mathrm{new}}\). \(t_{\mathrm{new}}\) describes the absolute time from the initial time of the system. By calling this method in a for loop for predefined times, the state of the system is obtained for exactly the times specified. Internally, severalstep()
calls are typically performed to reach the accurate state at time \(t_{\mathrm{new}}\).advance_to_steady_state(max_steps, residual_threshold, atol, write_residuals)
[Python interface only]: If the steady state solution of a reactor network is of interest, this method can be used. Internally, the steady state is approached by time stepping. The network is considered to be at steady state if the featurescaled residual of the state vector is below a given threshold value (which by default is 10 times the time steprtol
).
The use of the advance
method in a loop has the advantage that it produces
results corresponding to a predefined time series. These are associated with a
predefined memory consumption and well comparable between simulation runs with
different parameters. However, some detail (for example, a fast ignition process)
might not be resolved in the output data due to the typically large time steps.
The step
method results in much more data points because of the small
timesteps needed. Additionally, the absolute time has to be kept track of manually.
Even though Cantera comes predefined with typical parameters for tolerances and the maximum internal time step, the solution sometimes diverges. To solve this problem, three parameters can be tuned: The absolute time stepping tolerances, the relative time stepping tolerances, and the maximum time step. A reduction of the latter value is particularly useful when dealing with abrupt changes in the boundary conditions (for example, opening/closing valves; see also the IC engine example).
General Usage in Cantera¶
In Cantera, the following steps are typically necessary to investigate a reactor network:
Define
Solution
objects for the fluids to be flowing through your reactor network.Define the reactor type(s) and reservoir(s) that describe your system. Chose Ideal Gas (Constant Pressure) Reactor(s) if you only consider ideal gas phases.
Optional: Set up the boundary conditions and flow devices between reactors or reservoirs.
Define a reactor network which contains all the reactors previously created.
Advance the simulation in time, typically in a for or whileloop. Note that only the current state is stored in Cantera by default. If you want to observe the transient states, you manually have to keep track of them.
Analyze the data.
Note that Cantera always solves a transient problem. If you are interested in steadystate conditions, you can run your simulation for a long time until the states are converged (see the surface reactor example and the combustor example).
Cantera comes with a broad variety of wellcommented example scrips for reactor networks. Please see the Cantera Examples for further information.
Common Reactor Types and their Implementation in Cantera¶
Batch Reactor at Constant Volume or at Constant Pressure¶
If you are interested in how a homogeneous chemical composition changes in time when it is left to its own devices, a simple batch reactor can be used. Two versions are commonly considered: A rigid vessel with fixed volume but variable pressure, or a system idealized at constant pressure but varying volume.
In Cantera, such a simulation can be performed very easily. The initial state of the solution can be specified by composition and a set of thermodynamic parameters (like temperature and pressure) as a standard Cantera solution object. Upon its base, a general (Ideal Gas) Reactor or an (Ideal Gas) Constant Pressure Reactor can be created, depending on if a constant volume or constant pressure batch reactor should be considered, respectively. The behavior of the solution in time can be simulated as a very simple Reactor Network containing only the formerly created reactor.
An example for such a Batch Reactor is given in the examples.
Continuously Stirred Tank Reactor¶
A Continuously Stirred Tank Reactor (CSTR), also often referred to as WellStirred Reactor (WSR), Perfectly Stirred Reactor (PSR), or Longwell Reactor, is essentially a single Cantera reactor with an inlet, an outlet, and constant volume. Therefore, the Governing Equations for Single Reactors defined above apply accordingly.
Steady state solutions to CSTRs are often of interest. In this case, the mass flow rate \(\dot{m}\) is constant and equal at inlet and outlet. The mass contained in the confinement \(m\) divided by \(\dot{m}\) defines the mean residence time of the fluid in the confinement.
At steady state, the time derivatives in the governing equations become zero, and the system of ordinary differential equations can be reduced to a set of coupled nonlinear algebraic equations. A Newton solver could be used to solve this system of equations. However, a sophisticated implementation might be required to account for the strong nonlinearities and the presence of multiple solutions.
Cantera does not have such a Newton solver implemented. Instead, steady CSTRs are simulated by considering a timedependent constant volume reactor with specified in and outflow conditions. Starting off at an initial solution, the reactor network containing this reactor is advanced in time until the state of the solution is converged. An example for this procedure is the combustor example.
A problem can be the ignition of a CSTR: If the reactants are not reactive
enough, the simulation can result in the trivial solution that inflow and
outflow states are identical. To solve this problem, the reactor can be
initialized with a high temperature and/or radical concentration. A good
approach is to use the equilibrium composition of the reactants (which can be
computed using Cantera’s equilibrate
function) as an initial guess.
PlugFlow Reactor¶
A PlugFlow Reactor (PFR) represents a steadystate channel with a crosssectional area \(A\). Typically an ideal gas flows through it at a constant mass flow rate \(\dot{m}\). Perpendicular to the flow direction, the gas is considered to be completely homogeneous. In the axial direction \(z\), the states of the gas is allowed to change. However, all diffusion processes are neglected.
PlugFlow Reactors are often used to simulate ignition delay times, emission formation, and catalytic processes.
The governing equations of PlugFlow Reactors are [Kee2017]:

Mass conservation:
\begin{equation*} \frac{d(\rho u A)}{dz} = P’ \sum_k \dot{s}_k W_k \end{equation*}where:math: u is the axial velocity in (m/s) and \(P’\) is the chemically active channel perimeter in m (chemically active perimeter per unit length).
Continuity equation of species \(k\):
\begin{equation*} \rho u \frac{d Y_k}{dz} + Y_k P’ \sum_k \dot{s}_k W_k = \dot{\omega}_k W_k + P’ \dot{s}_k W_k \end{equation*}

Energy conservation:
\begin{equation*} \rho u A c_p \frac{d T}{d z} =  A \sum_k h_k \dot{\omega}_k W_k  P’ \sum_k h_k \dot{s}_k W_k + U P (T_w  T) \end{equation*}where \(U\) is the heat transfer coefficient in W/m/K, \(P\) is the perimeter of the duct in m, and \(T_w\) is the wall temperature in K. Kinetic and potential energies are neglected.

Momentum conservation in the axial direction:
\begin{equation*} \rho u A \frac{d u}{d z} + u P’ \sum_k \dot{s}_k W_k =  \frac{d (p A)}{dz}  \tau_w P \end{equation*}where \(\tau_w\) is the wall friction coefficient (which might be computed from Reynolds number based correlations).
Even though this problem extends geometrically in one direction, it can be modeled via zerodimensional reactors. Due to the neglecting of diffusion, downstream parts of the reactor have no influence on upstream parts. Therefore, PFRs can be modeled by marching from the beginning to the end of the reactor.
Cantera does not (yet) provide dedicated class to solve the PFR equations (The
FlowReactor
class is currently under development). However, there are two
ways to simulate a PFR with the reactor elements previously presented. Both
rely on the assumption that pressure is approximately constant throughout the
PlugFlow Reactor and that there is no friction. The momentum conservation
equation is thus neglected.
PFR Modeling by Considering a Lagrangian Reactor¶
A PlugFlow Reactor can also be described from a Lagrangian point of view. An unsteady fluid particle is considered which travels along the axial streamline through the PFR. Since there is no information traveling upstream, the state change of the fluid particle can be computed by a forward (upwind) integration in time. Using the continuity equation, the speed of the particle can be derived. By integrating the velocity in time, the temporal information can be translated into the spatial resolution of the PFR.
An example for this procedure can be found in the PFR example.
PFR Modeling as a Series of CSTRs¶
The PlugFlow Reactor is spatially discretized into a large number of axially distributed volumes. These volumes are modeled to be steadystate CSTRs.
The only reason to use this approach as opposed to the Lagrangian one is if you need to include surface reactions, because the system of equations ends up being a DAE system instead of an ODE system.
In Cantera, it is sufficient to consider a single reactor and march it forward in time, because there is no information traveling upstream. The mass flow rate \(\dot{m}\) through the PFR enters the reactor from an upstream reservoir. For the first reactor, the reservoir conditions are the inflow boundary conditions of the PFR. By performing a time integration as described in Continuously Stirred Tank Reactor until the state of the reactor is converged, the steadystate CSTR solution is computed. The state of the CSTR is the inlet boundary condition for the next CSTR downstream.
An example for this procedure can be found in the PFR example and the surface PFR example.
Advanced Concepts¶
In some cases, Cantera’s solver is insufficient to describe a certain configuration. In this situation, Cantera can still be used to provide chemical and thermodynamic computations, but external ODE solvers can be applied. See an example of a custom ODE solver.
References
 Kee2017

R. J. Kee, M. E. Coltrin, P. Glarborg, and H. Zhu. Chemically Reacting Flow: Theory and Practice. 2nd Ed. John Wiley and Sons, 2017.