Warning
This documentation is for an old version of Cantera. You can find docs for newer versions here.
Bases: object
This class is used as a wrapper for a function of one variable, i.e. \(y = f(t)\), that is defined in Python and can be called by the Cantera C++ core. Func1 objects are constructed from callable Python objects, e.g. functions or classes which implement the __call__ method:
>>> f1 = Func1(math.sin)
>>> f1(math.pi/4)
0.7071067811865475
>>> f2 = Func1(lambda t: t**2 + 1)
>>> f2(3)
10
>>> class Multiplier(object):
... def __init__(self, factor):
... self.factor = factor
... def __call__(self, t):
... return self.factor * t
>>> f3 = Func1(Multiplier(5))
>>> f3(6)
30.0
For simplicity, constant functions can be defined by passing the constant value directly:
>>> f4 = Func1(2.5)
>>> f4(0.1)
2.5
Note that all methods which accept Func1 objects will also accept the callable object and create the wrapper on their own, so it is generally unnecessary to explicitly create a Func1 object.
Bases: object
ReactorBase(ThermoPhase contents=None, name=None, **kwargs)
Common base class for reactors and reservoirs.
The temperature [K] of the reactor’s contents.
The mass fractions of the reactor’s contents.
The density [kg/m^3 or kmol/m^3] of the reactor’s contents.
List of flow devices installed as inlets to this reactor
Set solution to be the object used to compute thermodynamic properties and kinetic rates for this reactor.
The mass of the reactor’s contents.
The name of the reactor.
List of flow devices installed as outlets to this reactor
The ThermoPhase object representing the reactor’s contents.
The volume [m^3] of the reactor.
List of walls installed on this reactor
Bases: object
FlowDevice(upstream, downstream, name=None, *)
Base class for devices that allow flow between reactors.
FlowDevice objects are assumed to be adiabatic, non-reactive, and have negligible internal volume, so that they are internally always in steady-state even if the upstream and downstream reactors are not. The fluid enthalpy, chemical composition, and mass flow rate are constant across a FlowDevice, and the pressure difference equals the difference in pressure between the upstream and downstream reactors.
The mass flow rate [kg/s] through this device at time t [s].
Bases: object
ReactorNet(reactors=())
Networks of reactors. ReactorNet objects are used to simultaneously advance the state of one or more coupled reactors.
Example:
>>> r1 = Reactor(gas1)
>>> r2 = Reactor(gas2)
>>> <... install walls, inlets, outlets, etc...>
>>> reactor_network = ReactorNet([r1, r2])
>>> reactor_network.advance(time)
Add a reactor to the network.
Advance the state of the reactor network in time from the current time to time t [s], taking as many integrator timesteps as necessary.
The absolute error tolerance used while integrating the reactor equations.
The absolute error tolerance for sensitivity analysis.
The maximum number of error test failures permitted by the CVODES integrator in a single time step.
The relative error tolerance used while integrating the reactor equations.
The relative error tolerance for sensitivity analysis.
Set the initial time. Restarts integration from this time using the current state as the initial condition. Default: 0.0 s.
Set the maximum time step t [s] that the integrator is allowed to use.
Take a single internal time step toward time t [s]. The time after taking the step is returned.
The current time [s].
If True, verbose debug information will be printed during integration. The default is False.
Bases: cantera._cantera.ReactorBase
A reservoir is a reactor with a constant state. The temperature, pressure, and chemical composition in a reservoir never change from their initial values.
Bases: cantera._cantera.ReactorBase
Reactor(contents=None, name=None, *, energy=’on’, **kwargs)
A homogeneous zero-dimensional reactor. By default, they are closed (no inlets or outlets), have fixed volume, and have adiabatic, chemically-inert walls. These properties may all be changed by adding appropriate components, e.g. Wall, MassFlowController and Valve.
Parameters: |
|
---|
Some examples showing how to create Reactor objects are shown below.
>>> gas = Solution('gri30.xml')
>>> r1 = Reactor(gas)
This is equivalent to:
>>> r1 = Reactor()
>>> r1.insert(gas)
Arguments may be specified using keywords in any order:
>>> r2 = Reactor(contents=gas, energy='off',
... name='isothermal_reactor')
>>> r3 = Reactor(name='adiabatic_reactor', contents=gas)
Returns the index of the component named name in the system. This determines the (relative) index of the component in the vector of sensitivity coefficients. name is either a species name or the name of a reactor state variable, e.g. ‘U’, ‘T’, depending on the reactor’s equations.
True when the energy equation is being solved for this reactor. When this is False, the reactor temperature is held constant.
Bases: cantera._cantera.Reactor
A constant volume, zero-dimensional reactor for ideal gas mixtures.
Parameters: |
|
---|
Some examples showing how to create Reactor objects are shown below.
>>> gas = Solution('gri30.xml')
>>> r1 = Reactor(gas)
This is equivalent to:
>>> r1 = Reactor()
>>> r1.insert(gas)
Arguments may be specified using keywords in any order:
>>> r2 = Reactor(contents=gas, energy='off',
... name='isothermal_reactor')
>>> r3 = Reactor(name='adiabatic_reactor', contents=gas)
Bases: cantera._cantera.Reactor
A homogeneous, constant pressure, zero-dimensional reactor. The volume of the reactor changes as a function of time in order to keep the pressure constant.
Parameters: |
|
---|
Some examples showing how to create Reactor objects are shown below.
>>> gas = Solution('gri30.xml')
>>> r1 = Reactor(gas)
This is equivalent to:
>>> r1 = Reactor()
>>> r1.insert(gas)
Arguments may be specified using keywords in any order:
>>> r2 = Reactor(contents=gas, energy='off',
... name='isothermal_reactor')
>>> r3 = Reactor(name='adiabatic_reactor', contents=gas)
Bases: cantera._cantera.Reactor
A homogeneous, constant pressure, zero-dimensional reactor for ideal gas mixtures. The volume of the reactor changes as a function of time in order to keep the pressure constant.
Parameters: |
|
---|
Some examples showing how to create Reactor objects are shown below.
>>> gas = Solution('gri30.xml')
>>> r1 = Reactor(gas)
This is equivalent to:
>>> r1 = Reactor()
>>> r1.insert(gas)
Arguments may be specified using keywords in any order:
>>> r2 = Reactor(contents=gas, energy='off',
... name='isothermal_reactor')
>>> r3 = Reactor(name='adiabatic_reactor', contents=gas)
Bases: cantera._cantera.Reactor
A steady-state plug flow reactor with constant cross sectional area. Time integration follows a fluid element along the length of the reactor. The reactor is assumed to be frictionless and adiabatic.
Parameters: |
|
---|
Some examples showing how to create Reactor objects are shown below.
>>> gas = Solution('gri30.xml')
>>> r1 = Reactor(gas)
This is equivalent to:
>>> r1 = Reactor()
>>> r1.insert(gas)
Arguments may be specified using keywords in any order:
>>> r2 = Reactor(contents=gas, energy='off',
... name='isothermal_reactor')
>>> r3 = Reactor(name='adiabatic_reactor', contents=gas)
The distance of the fluid element from the inlet of the reactor.
Mass flow rate per unit area [kg/m^2*s]
Speed [m/s] of the flow in the reactor at the current position
Bases: object
Wall(left, right, name=None, *, A=None, K=None, U=None, Q=None, velocity=None, kinetics=(None, None))
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.
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 non-negative constant, and \(v_0(t)\) is a specified function of time. The velocity is positive if the wall is moving to the right.
The heat flux through the wall is computed from
where \(U\) is the overall heat transfer coefficient for conduction/convection, and \(\epsilon\) is the emissivity. The function \(q_0(t)\) is a specified function of time. The heat flux is positive when heat flows from the reactor on the left to the reactor on the right.
A heterogeneous reaction mechanism may be specified for one or both of the wall surfaces. The mechanism object (typically an instance of class Interface) must be constructed so that it is properly linked to the object representing the fluid in the reactor the surface in question faces. The surface temperature on each side is taken to be equal to the temperature of the reactor it faces.
Parameters: |
|
---|
The wall area [m^2].
The emissivity (nondimensional)
The coefficient K [m/s/Pa] that determines the velocity of the wall as a function of the pressure difference between the adjacent reactors.
the overall heat transfer coefficient [W/m^2/K]
The left surface of this wall.
Total heat flux [W] through the wall at time t. A positive value corresponds to heat flowing from the left-hand reactor to the right-hand one.
The right surface of this wall.
Heat flux [W/m^2] across the wall. May be either a constant or an arbitrary function of time. See Func1.
The wall velocity [m/s]. May be either a constant or an arbirary function of time. See Func1.
The rate of volumetric change [m^3/s] associated with the wall at time t. A positive value corresponds to the left-hand reactor volume increasing, and the right-hand reactor volume decreasing.
Bases: cantera._cantera.FlowDevice
MassFlowController(upstream, downstream, name=None, *, mdot=None)
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
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.
Bases: cantera._cantera.FlowDevice
Valve(upstream, downstream, name=None, *, K=None)
In Cantera, 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:
if \(P_1 > P_2.\) Otherwise, \(\dot m = 0\). However, an arbitrary function can also be specified, such that
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.
Set the relationship betwen mass flow rate and the pressure drop across the valve. If a number is given, it is the proportionality constant [kg/s/Pa]. If a function is given, it should compute the mass flow rate [kg/s] given the pressure drop [Pa].
>>> V = Valve(res1, reactor1)
>>> V.set_valve_coeff(1e-4)
>>> V.set_valve_coeff(lambda dP: (1e-5 * dP)**2)
Bases: cantera._cantera.FlowDevice
PressureController(upstream, downstream, name=None, *, master=None, K=None)
A PressureController 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 corresponding PressureController is installed on on outlet of the reactor. The PressureController mass flow rate is equal to the master mass flow rate, plus a small correction dependent on the pressure difference:
Set the “master” FlowDevice used to compute this device’s mass flow rate.
Set the proportionality constant k [kg/s/Pa] between the pressure drop and the mass flow rate.