III - 0D computations

The following link may help you to find the answers or the documentation you need : https://cantera.org/documentation/docs-3.0/sphinx/html/cython/zerodim.html https://cantera.org/science/reactors/reactors.html
The first one is about the function that can be used for computing a reactor and the second one explains the equations that are computed.

1. Knowledge of 0D computations

ReactorBase class

0D Reactors are often used in combustion to model auto-ignition time and the chemistry associated to it. For reactors and reservoirs, the class used is the following :
ReactorBase(ThermoPhase contents, name=None, arguments)

Here are the different types of reactors you can have for a 0D computation :

  1. Reservoir
    Reactors with a constant state. The temperature, pressure, and chemical composition in a reservoir never change from their initial values.

  2. Reactor

  3. IdealGasReactor
    Constant volume, zero-dimensional reactor for ideal gas mixtures.
  4. ConstPressureReactor
    Homogeneous, constant pressure, zero-dimensional reactor. The volume of the reactor changes as a function of time in order to keep the pressure constant.
  5. IdealGasConstPressureReactor
    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.
  6. FlowReactor
    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.

FlowDevice class

Reactors can be added inlets and outlets, to be able to loop or chain several reactors, control mass flow rates, volume or pressure. Here are the properties of the common baseclass FlowDevice for flow controllers between reactors and reservoirs :
FlowDevice(upstream, downstream, name=None, arguments)

The FlowDevice controls the fluids passage between an upstream and a downstream object, which should be specified. The arguments depend upon the different types of flow controllers available in Cantera :

  1. MassFlowController
    Mass flow controllers maintain a specified mass flow rate independent of upstream and downstream conditions. Unlike a real mass flow controller, a MassFlowController object will maintain the flow even if the downstream pressure is greater than the upstream pressure.
  2. Valve
    Valves are flow devices with mass flow rate that is a function of the pressure drop across them. 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 Kv to a sufficiently large value, very small pressure differences will result in flow between the reactors that counteracts the pressure difference.
  3. PressureController
    A pressure controller is designed to be used in conjunction, typically, with a MassFlowController. The master flow controller is installed on the inlet of the reactor, and the corresponding PressureController is installed on the 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.

Walls

Reactors can also add heat transfer and heterogeneous reactions at the walls, through a special object "wall". Walls separate 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. They are stateless objects in Cantera, meaning that no differential equation is integrated to determine any wall property. A heterogeneous reaction mechanism may be specified for one or both of the wall surfaces.

ReactorNet

Now, the evolution of a reactor, or a network of reactors -which are 0-D objects- with time, is performed through an integrator object ReactorNet :

... (define gases) ... r1 = Reactor(gas1) r2 = Reactor(gas2) ... (install walls, inlets, outlets, etc)... reactor_network = ReactorNet([r1, r2]) time = 1 #s reactor_network.advance(time) </p>

There are two possibilities to advance a reactor simulation in time :

  • the advance(self, double t) option (shown in the example above)
    This will advance the state of the reactor network in time from the current time to the specified 't' time, taking as many integrator timesteps as necessary.
  • the step(self, double t) option.
    This will take a single internal time step toward the specified time 't' [s]... The use of 'advance' is recommended, unless you need to elucidate a bug.

2. Simple closed vessel

Import statements

In [1]:
import sys
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt
from matplotlib import *

Set the mechanism properties

In [2]:
gas = ct.Solution('gri30.yaml')
gas.TPX = 1000.0, ct.one_atm, 'CH4:0.5,O2:1,N2:3.76'

Create the reactor and the ReactorNet associated to it

In [3]:
# Create Reactor and fill with gas
r = ct.Reactor(gas)

# Prepare the simulation with a ReactorNet object
sim = ct.ReactorNet([r])
time = 4.e-1

Compute the reactor

In [4]:
# Arrays to hold the datas
n_points = 400
times = np.zeros(n_points)
data = np.zeros((n_points, 4))

# Advance the simulation in time
# and print the internal evolution of temperature, volume and internal energy
print(('%10s %10s %10s %14s' % ('t [s]', 'T [K]', 'vol [m3]', 'u [J/kg]')))
for n in range(n_points):
    time += 5.e-3
    sim.advance(time)
    times[n] = time  # time in s
    data[n, 0] = r.T                               # set the temperature in the first column
    data[n, 1:] = r.thermo['O2', 'CO2', 'CH4'].X     # set the molar fractions in the other column
    print(('%10.3e %10.3f %10.3f %14.6e' % (sim.time, r.T,
                                            r.thermo.v, r.thermo.u)))
     t [s]      T [K]   vol [m3]       u [J/kg]
 4.050e-01   1001.116      2.969   2.870629e+05
 4.100e-01   1001.144      2.969   2.870629e+05
 4.150e-01   1001.172      2.969   2.870629e+05
 4.200e-01   1001.201      2.969   2.870629e+05
 4.250e-01   1001.230      2.969   2.870629e+05
 4.300e-01   1001.260      2.969   2.870629e+05
 4.350e-01   1001.291      2.969   2.870629e+05
 4.400e-01   1001.322      2.969   2.870629e+05
 4.450e-01   1001.354      2.969   2.870629e+05
 4.500e-01   1001.386      2.969   2.870629e+05
 4.550e-01   1001.419      2.969   2.870629e+05
 4.600e-01   1001.453      2.969   2.870629e+05
 4.650e-01   1001.487      2.969   2.870629e+05
 4.700e-01   1001.522      2.969   2.870629e+05
 4.750e-01   1001.558      2.969   2.870629e+05
 4.800e-01   1001.594      2.969   2.870629e+05
 4.850e-01   1001.631      2.969   2.870629e+05
 4.900e-01   1001.669      2.969   2.870629e+05
 4.950e-01   1001.708      2.969   2.870629e+05
 5.000e-01   1001.747      2.969   2.870629e+05
 5.050e-01   1001.787      2.969   2.870629e+05
 5.100e-01   1001.828      2.969   2.870629e+05
 5.150e-01   1001.870      2.969   2.870629e+05
 5.200e-01   1001.913      2.969   2.870629e+05
 5.250e-01   1001.956      2.969   2.870629e+05
 5.300e-01   1002.001      2.969   2.870629e+05
 5.350e-01   1002.046      2.969   2.870629e+05
 5.400e-01   1002.092      2.969   2.870629e+05
 5.450e-01   1002.140      2.969   2.870629e+05
 5.500e-01   1002.188      2.969   2.870629e+05
 5.550e-01   1002.237      2.969   2.870629e+05
 5.600e-01   1002.287      2.969   2.870629e+05
 5.650e-01   1002.338      2.969   2.870629e+05
 5.700e-01   1002.391      2.969   2.870629e+05
 5.750e-01   1002.444      2.969   2.870629e+05
 5.800e-01   1002.499      2.969   2.870629e+05
 5.850e-01   1002.555      2.969   2.870629e+05
 5.900e-01   1002.612      2.969   2.870629e+05
 5.950e-01   1002.670      2.969   2.870629e+05
 6.000e-01   1002.729      2.969   2.870629e+05
 6.050e-01   1002.790      2.969   2.870629e+05
 6.100e-01   1002.852      2.969   2.870629e+05
 6.150e-01   1002.916      2.969   2.870629e+05
 6.200e-01   1002.981      2.969   2.870629e+05
 6.250e-01   1003.047      2.969   2.870629e+05
 6.300e-01   1003.115      2.969   2.870629e+05
 6.350e-01   1003.184      2.969   2.870629e+05
 6.400e-01   1003.255      2.969   2.870629e+05
 6.450e-01   1003.328      2.969   2.870629e+05
 6.500e-01   1003.402      2.969   2.870629e+05
 6.550e-01   1003.478      2.969   2.870629e+05
 6.600e-01   1003.556      2.969   2.870629e+05
 6.650e-01   1003.636      2.969   2.870629e+05
 6.700e-01   1003.718      2.969   2.870629e+05
 6.750e-01   1003.801      2.969   2.870629e+05
 6.800e-01   1003.887      2.969   2.870629e+05
 6.850e-01   1003.974      2.969   2.870629e+05
 6.900e-01   1004.064      2.969   2.870629e+05
 6.950e-01   1004.156      2.969   2.870629e+05
 7.000e-01   1004.251      2.969   2.870629e+05
 7.050e-01   1004.348      2.969   2.870629e+05
 7.100e-01   1004.447      2.969   2.870629e+05
 7.150e-01   1004.549      2.969   2.870629e+05
 7.200e-01   1004.653      2.969   2.870629e+05
 7.250e-01   1004.760      2.969   2.870629e+05
 7.300e-01   1004.870      2.969   2.870629e+05
 7.350e-01   1004.983      2.969   2.870629e+05
 7.400e-01   1005.099      2.969   2.870629e+05
 7.450e-01   1005.219      2.969   2.870629e+05
 7.500e-01   1005.341      2.969   2.870629e+05
 7.550e-01   1005.467      2.969   2.870629e+05
 7.600e-01   1005.596      2.969   2.870629e+05
 7.650e-01   1005.730      2.969   2.870629e+05
 7.700e-01   1005.867      2.969   2.870629e+05
 7.750e-01   1006.008      2.969   2.870629e+05
 7.800e-01   1006.153      2.969   2.870629e+05
 7.850e-01   1006.303      2.969   2.870629e+05
 7.900e-01   1006.457      2.969   2.870629e+05
 7.950e-01   1006.616      2.969   2.870629e+05
 8.000e-01   1006.779      2.969   2.870629e+05
 8.050e-01   1006.949      2.969   2.870629e+05
 8.100e-01   1007.123      2.969   2.870629e+05
 8.150e-01   1007.303      2.969   2.870629e+05
 8.200e-01   1007.489      2.969   2.870629e+05
 8.250e-01   1007.682      2.969   2.870629e+05
 8.300e-01   1007.881      2.969   2.870629e+05
 8.350e-01   1008.087      2.969   2.870629e+05
 8.400e-01   1008.300      2.969   2.870629e+05
 8.450e-01   1008.521      2.969   2.870629e+05
 8.500e-01   1008.750      2.969   2.870629e+05
 8.550e-01   1008.987      2.969   2.870629e+05
 8.600e-01   1009.234      2.969   2.870629e+05
 8.650e-01   1009.490      2.969   2.870629e+05
 8.700e-01   1009.756      2.969   2.870629e+05
 8.750e-01   1010.033      2.969   2.870629e+05
 8.800e-01   1010.321      2.969   2.870629e+05
 8.850e-01   1010.622      2.969   2.870629e+05
 8.900e-01   1010.936      2.969   2.870629e+05
 8.950e-01   1011.263      2.969   2.870629e+05
 9.000e-01   1011.605      2.969   2.870629e+05
 9.050e-01   1011.964      2.969   2.870629e+05
 9.100e-01   1012.339      2.969   2.870629e+05
 9.150e-01   1012.733      2.969   2.870629e+05
 9.200e-01   1013.146      2.969   2.870629e+05
 9.250e-01   1013.582      2.969   2.870629e+05
 9.300e-01   1014.040      2.969   2.870629e+05
 9.350e-01   1014.524      2.969   2.870629e+05
 9.400e-01   1015.036      2.969   2.870629e+05
 9.450e-01   1015.578      2.969   2.870629e+05
 9.500e-01   1016.154      2.969   2.870629e+05
 9.550e-01   1016.766      2.969   2.870629e+05
 9.600e-01   1017.420      2.969   2.870629e+05
 9.650e-01   1018.119      2.969   2.870629e+05
 9.700e-01   1018.869      2.969   2.870629e+05
 9.750e-01   1019.676      2.969   2.870629e+05
 9.800e-01   1020.548      2.969   2.870629e+05
 9.850e-01   1021.495      2.969   2.870629e+05
 9.900e-01   1022.526      2.969   2.870629e+05
 9.950e-01   1023.657      2.969   2.870629e+05
 1.000e+00   1024.903      2.969   2.870629e+05
 1.005e+00   1026.286      2.969   2.870629e+05
 1.010e+00   1027.834      2.969   2.870629e+05
 1.015e+00   1029.583      2.969   2.870629e+05
 1.020e+00   1031.582      2.969   2.870629e+05
 1.025e+00   1033.898      2.969   2.870629e+05
 1.030e+00   1036.629      2.969   2.870629e+05
 1.035e+00   1039.920      2.969   2.870629e+05
 1.040e+00   1044.005      2.969   2.870629e+05
 1.045e+00   1049.284      2.969   2.870629e+05
 1.050e+00   1056.527      2.969   2.870629e+05
 1.055e+00   1067.481      2.969   2.870629e+05
 1.060e+00   1087.488      2.969   2.870629e+05
 1.065e+00   1152.418      2.969   2.870629e+05
 1.070e+00   2768.341      2.969   2.870629e+05
 1.075e+00   2768.160      2.969   2.870629e+05
 1.080e+00   2768.160      2.969   2.870629e+05
 1.085e+00   2768.160      2.969   2.870629e+05
 1.090e+00   2768.160      2.969   2.870629e+05
 1.095e+00   2768.160      2.969   2.870629e+05
 1.100e+00   2768.160      2.969   2.870629e+05
 1.105e+00   2768.160      2.969   2.870629e+05
 1.110e+00   2768.160      2.969   2.870629e+05
 1.115e+00   2768.160      2.969   2.870629e+05
 1.120e+00   2768.160      2.969   2.870629e+05
 1.125e+00   2768.160      2.969   2.870629e+05
 1.130e+00   2768.160      2.969   2.870629e+05
 1.135e+00   2768.160      2.969   2.870629e+05
 1.140e+00   2768.160      2.969   2.870629e+05
 1.145e+00   2768.160      2.969   2.870629e+05
 1.150e+00   2768.160      2.969   2.870629e+05
 1.155e+00   2768.160      2.969   2.870629e+05
 1.160e+00   2768.160      2.969   2.870629e+05
 1.165e+00   2768.160      2.969   2.870629e+05
 1.170e+00   2768.160      2.969   2.870629e+05
 1.175e+00   2768.160      2.969   2.870629e+05
 1.180e+00   2768.160      2.969   2.870629e+05
 1.185e+00   2768.160      2.969   2.870629e+05
 1.190e+00   2768.160      2.969   2.870629e+05
 1.195e+00   2768.160      2.969   2.870629e+05
 1.200e+00   2768.160      2.969   2.870629e+05
 1.205e+00   2768.160      2.969   2.870629e+05
 1.210e+00   2768.160      2.969   2.870629e+05
 1.215e+00   2768.160      2.969   2.870629e+05
 1.220e+00   2768.160      2.969   2.870629e+05
 1.225e+00   2768.160      2.969   2.870629e+05
 1.230e+00   2768.160      2.969   2.870629e+05
 1.235e+00   2768.160      2.969   2.870629e+05
 1.240e+00   2768.160      2.969   2.870629e+05
 1.245e+00   2768.160      2.969   2.870629e+05
 1.250e+00   2768.160      2.969   2.870629e+05
 1.255e+00   2768.160      2.969   2.870629e+05
 1.260e+00   2768.160      2.969   2.870629e+05
 1.265e+00   2768.160      2.969   2.870629e+05
 1.270e+00   2768.160      2.969   2.870629e+05
 1.275e+00   2768.160      2.969   2.870629e+05
 1.280e+00   2768.160      2.969   2.870629e+05
 1.285e+00   2768.160      2.969   2.870629e+05
 1.290e+00   2768.160      2.969   2.870629e+05
 1.295e+00   2768.160      2.969   2.870629e+05
 1.300e+00   2768.160      2.969   2.870629e+05
 1.305e+00   2768.160      2.969   2.870629e+05
 1.310e+00   2768.160      2.969   2.870629e+05
 1.315e+00   2768.160      2.969   2.870629e+05
 1.320e+00   2768.160      2.969   2.870629e+05
 1.325e+00   2768.160      2.969   2.870629e+05
 1.330e+00   2768.160      2.969   2.870629e+05
 1.335e+00   2768.160      2.969   2.870629e+05
 1.340e+00   2768.160      2.969   2.870629e+05
 1.345e+00   2768.160      2.969   2.870629e+05
 1.350e+00   2768.160      2.969   2.870629e+05
 1.355e+00   2768.160      2.969   2.870629e+05
 1.360e+00   2768.160      2.969   2.870629e+05
 1.365e+00   2768.160      2.969   2.870629e+05
 1.370e+00   2768.160      2.969   2.870629e+05
 1.375e+00   2768.160      2.969   2.870629e+05
 1.380e+00   2768.160      2.969   2.870629e+05
 1.385e+00   2768.160      2.969   2.870629e+05
 1.390e+00   2768.160      2.969   2.870629e+05
 1.395e+00   2768.160      2.969   2.870629e+05
 1.400e+00   2768.160      2.969   2.870629e+05
 1.405e+00   2768.160      2.969   2.870629e+05
 1.410e+00   2768.160      2.969   2.870629e+05
 1.415e+00   2768.160      2.969   2.870629e+05
 1.420e+00   2768.160      2.969   2.870629e+05
 1.425e+00   2768.160      2.969   2.870629e+05
 1.430e+00   2768.160      2.969   2.870629e+05
 1.435e+00   2768.160      2.969   2.870629e+05
 1.440e+00   2768.160      2.969   2.870629e+05
 1.445e+00   2768.160      2.969   2.870629e+05
 1.450e+00   2768.160      2.969   2.870629e+05
 1.455e+00   2768.160      2.969   2.870629e+05
 1.460e+00   2768.160      2.969   2.870629e+05
 1.465e+00   2768.160      2.969   2.870629e+05
 1.470e+00   2768.160      2.969   2.870629e+05
 1.475e+00   2768.160      2.969   2.870629e+05
 1.480e+00   2768.160      2.969   2.870629e+05
 1.485e+00   2768.160      2.969   2.870629e+05
 1.490e+00   2768.160      2.969   2.870629e+05
 1.495e+00   2768.160      2.969   2.870629e+05
 1.500e+00   2768.160      2.969   2.870629e+05
 1.505e+00   2768.160      2.969   2.870629e+05
 1.510e+00   2768.160      2.969   2.870629e+05
 1.515e+00   2768.160      2.969   2.870629e+05
 1.520e+00   2768.160      2.969   2.870629e+05
 1.525e+00   2768.160      2.969   2.870629e+05
 1.530e+00   2768.160      2.969   2.870629e+05
 1.535e+00   2768.160      2.969   2.870629e+05
 1.540e+00   2768.160      2.969   2.870629e+05
 1.545e+00   2768.160      2.969   2.870629e+05
 1.550e+00   2768.160      2.969   2.870629e+05
 1.555e+00   2768.160      2.969   2.870629e+05
 1.560e+00   2768.160      2.969   2.870629e+05
 1.565e+00   2768.160      2.969   2.870629e+05
 1.570e+00   2768.160      2.969   2.870629e+05
 1.575e+00   2768.160      2.969   2.870629e+05
 1.580e+00   2768.160      2.969   2.870629e+05
 1.585e+00   2768.160      2.969   2.870629e+05
 1.590e+00   2768.160      2.969   2.870629e+05
 1.595e+00   2768.160      2.969   2.870629e+05
 1.600e+00   2768.160      2.969   2.870629e+05
 1.605e+00   2768.160      2.969   2.870629e+05
 1.610e+00   2768.160      2.969   2.870629e+05
 1.615e+00   2768.160      2.969   2.870629e+05
 1.620e+00   2768.160      2.969   2.870629e+05
 1.625e+00   2768.160      2.969   2.870629e+05
 1.630e+00   2768.160      2.969   2.870629e+05
 1.635e+00   2768.160      2.969   2.870629e+05
 1.640e+00   2768.160      2.969   2.870629e+05
 1.645e+00   2768.160      2.969   2.870629e+05
 1.650e+00   2768.160      2.969   2.870629e+05
 1.655e+00   2768.160      2.969   2.870629e+05
 1.660e+00   2768.160      2.969   2.870629e+05
 1.665e+00   2768.160      2.969   2.870629e+05
 1.670e+00   2768.160      2.969   2.870629e+05
 1.675e+00   2768.160      2.969   2.870629e+05
 1.680e+00   2768.160      2.969   2.870629e+05
 1.685e+00   2768.160      2.969   2.870629e+05
 1.690e+00   2768.160      2.969   2.870629e+05
 1.695e+00   2768.160      2.969   2.870629e+05
 1.700e+00   2768.160      2.969   2.870629e+05
 1.705e+00   2768.160      2.969   2.870629e+05
 1.710e+00   2768.160      2.969   2.870629e+05
 1.715e+00   2768.160      2.969   2.870629e+05
 1.720e+00   2768.160      2.969   2.870629e+05
 1.725e+00   2768.160      2.969   2.870629e+05
 1.730e+00   2768.160      2.969   2.870629e+05
 1.735e+00   2768.160      2.969   2.870629e+05
 1.740e+00   2768.160      2.969   2.870629e+05
 1.745e+00   2768.160      2.969   2.870629e+05
 1.750e+00   2768.160      2.969   2.870629e+05
 1.755e+00   2768.160      2.969   2.870629e+05
 1.760e+00   2768.160      2.969   2.870629e+05
 1.765e+00   2768.160      2.969   2.870629e+05
 1.770e+00   2768.160      2.969   2.870629e+05
 1.775e+00   2768.160      2.969   2.870629e+05
 1.780e+00   2768.160      2.969   2.870629e+05
 1.785e+00   2768.160      2.969   2.870629e+05
 1.790e+00   2768.160      2.969   2.870629e+05
 1.795e+00   2768.160      2.969   2.870629e+05
 1.800e+00   2768.160      2.969   2.870629e+05
 1.805e+00   2768.160      2.969   2.870629e+05
 1.810e+00   2768.160      2.969   2.870629e+05
 1.815e+00   2768.160      2.969   2.870629e+05
 1.820e+00   2768.160      2.969   2.870629e+05
 1.825e+00   2768.160      2.969   2.870629e+05
 1.830e+00   2768.160      2.969   2.870629e+05
 1.835e+00   2768.160      2.969   2.870629e+05
 1.840e+00   2768.160      2.969   2.870629e+05
 1.845e+00   2768.160      2.969   2.870629e+05
 1.850e+00   2768.160      2.969   2.870629e+05
 1.855e+00   2768.160      2.969   2.870629e+05
 1.860e+00   2768.160      2.969   2.870629e+05
 1.865e+00   2768.160      2.969   2.870629e+05
 1.870e+00   2768.160      2.969   2.870629e+05
 1.875e+00   2768.160      2.969   2.870629e+05
 1.880e+00   2768.160      2.969   2.870629e+05
 1.885e+00   2768.160      2.969   2.870629e+05
 1.890e+00   2768.160      2.969   2.870629e+05
 1.895e+00   2768.160      2.969   2.870629e+05
 1.900e+00   2768.160      2.969   2.870629e+05
 1.905e+00   2768.160      2.969   2.870629e+05
 1.910e+00   2768.160      2.969   2.870629e+05
 1.915e+00   2768.160      2.969   2.870629e+05
 1.920e+00   2768.160      2.969   2.870629e+05
 1.925e+00   2768.160      2.969   2.870629e+05
 1.930e+00   2768.160      2.969   2.870629e+05
 1.935e+00   2768.160      2.969   2.870629e+05
 1.940e+00   2768.160      2.969   2.870629e+05
 1.945e+00   2768.160      2.969   2.870629e+05
 1.950e+00   2768.160      2.969   2.870629e+05
 1.955e+00   2768.160      2.969   2.870629e+05
 1.960e+00   2768.160      2.969   2.870629e+05
 1.965e+00   2768.160      2.969   2.870629e+05
 1.970e+00   2768.160      2.969   2.870629e+05
 1.975e+00   2768.160      2.969   2.870629e+05
 1.980e+00   2768.160      2.969   2.870629e+05
 1.985e+00   2768.160      2.969   2.870629e+05
 1.990e+00   2768.160      2.969   2.870629e+05
 1.995e+00   2768.160      2.969   2.870629e+05
 2.000e+00   2768.160      2.969   2.870629e+05
 2.005e+00   2768.160      2.969   2.870629e+05
 2.010e+00   2768.160      2.969   2.870629e+05
 2.015e+00   2768.160      2.969   2.870629e+05
 2.020e+00   2768.160      2.969   2.870629e+05
 2.025e+00   2768.160      2.969   2.870629e+05
 2.030e+00   2768.160      2.969   2.870629e+05
 2.035e+00   2768.160      2.969   2.870629e+05
 2.040e+00   2768.160      2.969   2.870629e+05
 2.045e+00   2768.160      2.969   2.870629e+05
 2.050e+00   2768.160      2.969   2.870629e+05
 2.055e+00   2768.160      2.969   2.870629e+05
 2.060e+00   2768.160      2.969   2.870629e+05
 2.065e+00   2768.160      2.969   2.870629e+05
 2.070e+00   2768.160      2.969   2.870629e+05
 2.075e+00   2768.160      2.969   2.870629e+05
 2.080e+00   2768.160      2.969   2.870629e+05
 2.085e+00   2768.160      2.969   2.870629e+05
 2.090e+00   2768.160      2.969   2.870629e+05
 2.095e+00   2768.160      2.969   2.870629e+05
 2.100e+00   2768.160      2.969   2.870629e+05
 2.105e+00   2768.160      2.969   2.870629e+05
 2.110e+00   2768.160      2.969   2.870629e+05
 2.115e+00   2768.160      2.969   2.870629e+05
 2.120e+00   2768.160      2.969   2.870629e+05
 2.125e+00   2768.160      2.969   2.870629e+05
 2.130e+00   2768.160      2.969   2.870629e+05
 2.135e+00   2768.160      2.969   2.870629e+05
 2.140e+00   2768.160      2.969   2.870629e+05
 2.145e+00   2768.160      2.969   2.870629e+05
 2.150e+00   2768.160      2.969   2.870629e+05
 2.155e+00   2768.160      2.969   2.870629e+05
 2.160e+00   2768.160      2.969   2.870629e+05
 2.165e+00   2768.160      2.969   2.870629e+05
 2.170e+00   2768.160      2.969   2.870629e+05
 2.175e+00   2768.160      2.969   2.870629e+05
 2.180e+00   2768.160      2.969   2.870629e+05
 2.185e+00   2768.160      2.969   2.870629e+05
 2.190e+00   2768.160      2.969   2.870629e+05
 2.195e+00   2768.160      2.969   2.870629e+05
 2.200e+00   2768.160      2.969   2.870629e+05
 2.205e+00   2768.160      2.969   2.870629e+05
 2.210e+00   2768.160      2.969   2.870629e+05
 2.215e+00   2768.160      2.969   2.870629e+05
 2.220e+00   2768.160      2.969   2.870629e+05
 2.225e+00   2768.160      2.969   2.870629e+05
 2.230e+00   2768.160      2.969   2.870629e+05
 2.235e+00   2768.160      2.969   2.870629e+05
 2.240e+00   2768.160      2.969   2.870629e+05
 2.245e+00   2768.160      2.969   2.870629e+05
 2.250e+00   2768.160      2.969   2.870629e+05
 2.255e+00   2768.160      2.969   2.870629e+05
 2.260e+00   2768.160      2.969   2.870629e+05
 2.265e+00   2768.160      2.969   2.870629e+05
 2.270e+00   2768.160      2.969   2.870629e+05
 2.275e+00   2768.160      2.969   2.870629e+05
 2.280e+00   2768.160      2.969   2.870629e+05
 2.285e+00   2768.160      2.969   2.870629e+05
 2.290e+00   2768.160      2.969   2.870629e+05
 2.295e+00   2768.160      2.969   2.870629e+05
 2.300e+00   2768.160      2.969   2.870629e+05
 2.305e+00   2768.160      2.969   2.870629e+05
 2.310e+00   2768.160      2.969   2.870629e+05
 2.315e+00   2768.160      2.969   2.870629e+05
 2.320e+00   2768.160      2.969   2.870629e+05
 2.325e+00   2768.160      2.969   2.870629e+05
 2.330e+00   2768.160      2.969   2.870629e+05
 2.335e+00   2768.160      2.969   2.870629e+05
 2.340e+00   2768.160      2.969   2.870629e+05
 2.345e+00   2768.160      2.969   2.870629e+05
 2.350e+00   2768.160      2.969   2.870629e+05
 2.355e+00   2768.160      2.969   2.870629e+05
 2.360e+00   2768.160      2.969   2.870629e+05
 2.365e+00   2768.160      2.969   2.870629e+05
 2.370e+00   2768.160      2.969   2.870629e+05
 2.375e+00   2768.160      2.969   2.870629e+05
 2.380e+00   2768.160      2.969   2.870629e+05
 2.385e+00   2768.160      2.969   2.870629e+05
 2.390e+00   2768.160      2.969   2.870629e+05
 2.395e+00   2768.160      2.969   2.870629e+05
 2.400e+00   2768.160      2.969   2.870629e+05

Plot results

In [5]:
rcParams['figure.figsize'] = (14, 10)

plt.clf()

plt.subplot(2, 2, 1)
plt.plot(times, data[:, 0])
plt.xlabel('Time (ms)')
plt.ylabel('Temperature (K)')

plt.subplot(2, 2, 2)
plt.plot(times, data[:, 1])
plt.xlabel('Time (ms)')
plt.ylabel('O2 Mole Fraction')

plt.subplot(2, 2, 3)
plt.plot(times, data[:, 2])
plt.xlabel('Time (ms)')
plt.ylabel('CO2 Mole Fraction')

plt.subplot(2, 2, 4)
plt.plot(times, data[:, 3])
plt.xlabel('Time (ms)')
plt.ylabel('CH4 Mole Fraction')

plt.show()

There are the characteristic evolutions that one can observe when simulating 0D cases. You should be aware that your case must auto-ignite (for some temperature, it is not sufficiently hot to auto-ignite, therefore nothing happens) and that the simulated time should be sufficient to capture the time where it ignites.

Try to move the temperature of the gas state :
- at 960 K
- at 1040 K

What do you observe ?

As you can see, slightly shifting the temperature up or down moves the auto-ignition time. As you never know a priori the order of magnitude of the ignition time, it is good to use the step version until you reach burnt gases.

3. A simple constant pressure reactor

Here, we want to create a simple constant pressure reactor. To do so, it is necessary to create a reactor and its environment (which will be a Reservoir). The interface between the two objects created is handled by a wall, of which the expansion rate can be defined by the user.

Set the mechanism properties

In [6]:
# Mechanisms used for the process
gri3 = ct.Solution('gri30.yaml')
air = ct.Solution('air.yaml')

# Gas state
gri3.TPX = 1000.0, ct.one_atm, 'CH4:0.5,O2:1,N2:3.76'

Set the reservoir

Try to set :
- an IdealGasReactor object with the gri3 object created above
- a Reservoir representing the environment with the air object created above

In [7]:
# Reactor and environment
r = ct.IdealGasReactor(gri3)
env = ct.Reservoir(air)

# Wall
w = ct.Wall(r, env)
w.expansion_rate_coeff = 1.0e6  # set expansion parameter. dV/dt = KA(P_1 - P_2)
w.area = 1.0

# Prepare the simulation with a ReactorNet object
sim = ct.ReactorNet([r])
time = 4.e-1

As explained in the lecture, note that the environment defines the air in which the reactor is set in. We also define a wall between the reactor and the environment, and make it flexible, so that the pressure in the reactor is held at the environment pressure.

Simulate the reactor

In [8]:
# Arrays to hold the datas
times = np.zeros(200)
data = np.zeros((200, 4))

# Advance the simulation in time
print(('%10s %10s %10s %14s' % ('t [s]', 'T [K]', 'P [Pa]', 'h [J/kg]')))
for n in range(200):
    time += 5.e-3
    sim.advance(time)
    times[n] = time  # time in s
    data[n, 0] = r.T
    data[n, 1:] = r.thermo['O2', 'CO2', 'CH4'].X
    print(('%10.3e %10.3f %10.3f %14.6e' % (sim.time, r.T,
                                            r.thermo.P, r.thermo.h)))
     t [s]      T [K]     P [Pa]       h [J/kg]
 4.050e-01   1000.862 101325.000   5.879462e+05
 4.100e-01   1000.883 101325.000   5.879462e+05
 4.150e-01   1000.905 101325.000   5.879462e+05
 4.200e-01   1000.927 101325.000   5.879462e+05
 4.250e-01   1000.950 101325.000   5.879462e+05
 4.300e-01   1000.973 101325.000   5.879462e+05
 4.350e-01   1000.996 101325.000   5.879462e+05
 4.400e-01   1001.020 101325.000   5.879462e+05
 4.450e-01   1001.044 101325.000   5.879462e+05
 4.500e-01   1001.069 101325.000   5.879462e+05
 4.550e-01   1001.094 101325.000   5.879462e+05
 4.600e-01   1001.120 101325.000   5.879462e+05
 4.650e-01   1001.146 101325.000   5.879462e+05
 4.700e-01   1001.173 101325.000   5.879462e+05
 4.750e-01   1001.200 101325.000   5.879462e+05
 4.800e-01   1001.228 101325.000   5.879462e+05
 4.850e-01   1001.257 101325.000   5.879462e+05
 4.900e-01   1001.285 101325.000   5.879462e+05
 4.950e-01   1001.315 101325.000   5.879462e+05
 5.000e-01   1001.345 101325.000   5.879462e+05
 5.050e-01   1001.376 101325.000   5.879462e+05
 5.100e-01   1001.407 101325.000   5.879462e+05
 5.150e-01   1001.439 101325.000   5.879462e+05
 5.200e-01   1001.471 101325.000   5.879462e+05
 5.250e-01   1001.504 101325.000   5.879462e+05
 5.300e-01   1001.538 101325.000   5.879462e+05
 5.350e-01   1001.573 101325.000   5.879462e+05
 5.400e-01   1001.608 101325.000   5.879462e+05
 5.450e-01   1001.644 101325.000   5.879462e+05
 5.500e-01   1001.680 101325.000   5.879462e+05
 5.550e-01   1001.717 101325.000   5.879462e+05
 5.600e-01   1001.756 101325.000   5.879462e+05
 5.650e-01   1001.794 101325.000   5.879462e+05
 5.700e-01   1001.834 101325.000   5.879462e+05
 5.750e-01   1001.875 101325.000   5.879462e+05
 5.800e-01   1001.916 101325.000   5.879462e+05
 5.850e-01   1001.958 101325.000   5.879462e+05
 5.900e-01   1002.001 101325.000   5.879462e+05
 5.950e-01   1002.045 101325.000   5.879462e+05
 6.000e-01   1002.090 101325.000   5.879462e+05
 6.050e-01   1002.136 101325.000   5.879462e+05
 6.100e-01   1002.183 101325.000   5.879462e+05
 6.150e-01   1002.231 101325.000   5.879462e+05
 6.200e-01   1002.280 101325.000   5.879462e+05
 6.250e-01   1002.330 101325.000   5.879462e+05
 6.300e-01   1002.381 101325.000   5.879462e+05
 6.350e-01   1002.433 101325.000   5.879462e+05
 6.400e-01   1002.486 101325.000   5.879462e+05
 6.450e-01   1002.541 101325.000   5.879462e+05
 6.500e-01   1002.596 101325.000   5.879462e+05
 6.550e-01   1002.653 101325.000   5.879462e+05
 6.600e-01   1002.712 101325.000   5.879462e+05
 6.650e-01   1002.771 101325.000   5.879462e+05
 6.700e-01   1002.832 101325.000   5.879462e+05
 6.750e-01   1002.895 101325.000   5.879462e+05
 6.800e-01   1002.958 101325.000   5.879462e+05
 6.850e-01   1003.024 101325.000   5.879462e+05
 6.900e-01   1003.091 101325.000   5.879462e+05
 6.950e-01   1003.159 101325.000   5.879462e+05
 7.000e-01   1003.229 101325.000   5.879462e+05
 7.050e-01   1003.301 101325.000   5.879462e+05
 7.100e-01   1003.374 101325.000   5.879462e+05
 7.150e-01   1003.450 101325.000   5.879462e+05
 7.200e-01   1003.527 101325.000   5.879462e+05
 7.250e-01   1003.606 101325.000   5.879462e+05
 7.300e-01   1003.687 101325.000   5.879462e+05
 7.350e-01   1003.771 101325.000   5.879462e+05
 7.400e-01   1003.856 101325.000   5.879462e+05
 7.450e-01   1003.943 101325.000   5.879462e+05
 7.500e-01   1004.033 101325.000   5.879462e+05
 7.550e-01   1004.125 101325.000   5.879462e+05
 7.600e-01   1004.220 101325.000   5.879462e+05
 7.650e-01   1004.317 101325.000   5.879462e+05
 7.700e-01   1004.417 101325.000   5.879462e+05
 7.750e-01   1004.520 101325.000   5.879462e+05
 7.800e-01   1004.625 101325.000   5.879462e+05
 7.850e-01   1004.734 101325.000   5.879462e+05
 7.900e-01   1004.845 101325.000   5.879462e+05
 7.950e-01   1004.960 101325.000   5.879462e+05
 8.000e-01   1005.078 101325.000   5.879462e+05
 8.050e-01   1005.200 101325.000   5.879462e+05
 8.100e-01   1005.325 101325.000   5.879462e+05
 8.150e-01   1005.454 101325.000   5.879462e+05
 8.200e-01   1005.587 101325.000   5.879462e+05
 8.250e-01   1005.724 101325.000   5.879462e+05
 8.300e-01   1005.865 101325.000   5.879462e+05
 8.350e-01   1006.011 101325.000   5.879462e+05
 8.400e-01   1006.162 101325.000   5.879462e+05
 8.450e-01   1006.317 101325.000   5.879462e+05
 8.500e-01   1006.478 101325.000   5.879462e+05
 8.550e-01   1006.644 101325.000   5.879462e+05
 8.600e-01   1006.816 101325.000   5.879462e+05
 8.650e-01   1006.994 101325.000   5.879462e+05
 8.700e-01   1007.179 101325.000   5.879462e+05
 8.750e-01   1007.370 101325.000   5.879462e+05
 8.800e-01   1007.568 101325.000   5.879462e+05
 8.850e-01   1007.774 101325.000   5.879462e+05
 8.900e-01   1007.987 101325.000   5.879462e+05
 8.950e-01   1008.209 101325.000   5.879462e+05
 9.000e-01   1008.440 101325.000   5.879462e+05
 9.050e-01   1008.681 101325.000   5.879462e+05
 9.100e-01   1008.931 101325.000   5.879462e+05
 9.150e-01   1009.192 101325.000   5.879462e+05
 9.200e-01   1009.464 101325.000   5.879462e+05
 9.250e-01   1009.749 101325.000   5.879462e+05
 9.300e-01   1010.047 101325.000   5.879462e+05
 9.350e-01   1010.359 101325.000   5.879462e+05
 9.400e-01   1010.686 101325.000   5.879462e+05
 9.450e-01   1011.029 101325.000   5.879462e+05
 9.500e-01   1011.390 101325.000   5.879462e+05
 9.550e-01   1011.770 101325.000   5.879462e+05
 9.600e-01   1012.171 101325.000   5.879462e+05
 9.650e-01   1012.595 101325.000   5.879462e+05
 9.700e-01   1013.043 101325.000   5.879462e+05
 9.750e-01   1013.518 101325.000   5.879462e+05
 9.800e-01   1014.023 101325.000   5.879462e+05
 9.850e-01   1014.562 101325.000   5.879462e+05
 9.900e-01   1015.137 101325.000   5.879462e+05
 9.950e-01   1015.752 101325.000   5.879462e+05
 1.000e+00   1016.414 101325.000   5.879462e+05
 1.005e+00   1017.128 101325.000   5.879462e+05
 1.010e+00   1017.901 101325.000   5.879462e+05
 1.015e+00   1018.741 101325.000   5.879462e+05
 1.020e+00   1019.659 101325.000   5.879462e+05
 1.025e+00   1020.667 101325.000   5.879462e+05
 1.030e+00   1021.782 101325.000   5.879462e+05
 1.035e+00   1023.024 101325.000   5.879462e+05
 1.040e+00   1024.418 101325.000   5.879462e+05
 1.045e+00   1026.001 101325.000   5.879462e+05
 1.050e+00   1027.817 101325.000   5.879462e+05
 1.055e+00   1029.935 101325.000   5.879462e+05
 1.060e+00   1032.448 101325.000   5.879462e+05
 1.065e+00   1035.501 101325.000   5.879462e+05
 1.070e+00   1039.328 101325.000   5.879462e+05
 1.075e+00   1044.333 101325.000   5.879462e+05
 1.080e+00   1051.305 101325.000   5.879461e+05
 1.085e+00   1062.049 101325.000   5.879461e+05
 1.090e+00   1082.093 101325.000   5.879460e+05
 1.095e+00   1146.090 101325.000   5.879460e+05
 1.100e+00   2549.420 101325.000   5.879460e+05
 1.105e+00   2545.389 101325.000   5.879460e+05
 1.110e+00   2543.192 101325.000   5.879460e+05
 1.115e+00   2542.105 101325.000   5.879460e+05
 1.120e+00   2541.590 101325.000   5.879460e+05
 1.125e+00   2541.351 101325.000   5.879460e+05
 1.130e+00   2541.240 101325.000   5.879460e+05
 1.135e+00   2541.189 101325.000   5.879460e+05
 1.140e+00   2541.166 101325.000   5.879460e+05
 1.145e+00   2541.155 101325.000   5.879460e+05
 1.150e+00   2541.150 101325.000   5.879460e+05
 1.155e+00   2541.148 101325.000   5.879460e+05
 1.160e+00   2541.147 101325.000   5.879460e+05
 1.165e+00   2541.147 101325.000   5.879460e+05
 1.170e+00   2541.146 101325.000   5.879460e+05
 1.175e+00   2541.146 101325.000   5.879460e+05
 1.180e+00   2541.146 101325.000   5.879460e+05
 1.185e+00   2541.146 101325.000   5.879460e+05
 1.190e+00   2541.146 101325.000   5.879460e+05
 1.195e+00   2541.146 101325.000   5.879460e+05
 1.200e+00   2541.146 101325.000   5.879460e+05
 1.205e+00   2541.146 101325.000   5.879460e+05
 1.210e+00   2541.146 101325.000   5.879460e+05
 1.215e+00   2541.146 101325.000   5.879460e+05
 1.220e+00   2541.146 101325.000   5.879460e+05
 1.225e+00   2541.146 101325.000   5.879460e+05
 1.230e+00   2541.146 101325.000   5.879460e+05
 1.235e+00   2541.146 101325.000   5.879460e+05
 1.240e+00   2541.146 101325.000   5.879460e+05
 1.245e+00   2541.146 101325.000   5.879460e+05
 1.250e+00   2541.146 101325.000   5.879460e+05
 1.255e+00   2541.146 101325.000   5.879460e+05
 1.260e+00   2541.146 101325.000   5.879460e+05
 1.265e+00   2541.146 101325.000   5.879460e+05
 1.270e+00   2541.146 101325.000   5.879460e+05
 1.275e+00   2541.146 101325.000   5.879460e+05
 1.280e+00   2541.146 101325.000   5.879460e+05
 1.285e+00   2541.146 101325.000   5.879460e+05
 1.290e+00   2541.146 101325.000   5.879460e+05
 1.295e+00   2541.146 101325.000   5.879460e+05
 1.300e+00   2541.146 101325.000   5.879460e+05
 1.305e+00   2541.146 101325.000   5.879460e+05
 1.310e+00   2541.146 101325.000   5.879460e+05
 1.315e+00   2541.146 101325.000   5.879460e+05
 1.320e+00   2541.146 101325.000   5.879460e+05
 1.325e+00   2541.146 101325.000   5.879460e+05
 1.330e+00   2541.146 101325.000   5.879460e+05
 1.335e+00   2541.146 101325.000   5.879460e+05
 1.340e+00   2541.146 101325.000   5.879460e+05
 1.345e+00   2541.146 101325.000   5.879460e+05
 1.350e+00   2541.146 101325.000   5.879460e+05
 1.355e+00   2541.146 101325.000   5.879460e+05
 1.360e+00   2541.146 101325.000   5.879460e+05
 1.365e+00   2541.146 101325.000   5.879460e+05
 1.370e+00   2541.146 101325.000   5.879460e+05
 1.375e+00   2541.146 101325.000   5.879460e+05
 1.380e+00   2541.146 101325.000   5.879460e+05
 1.385e+00   2541.146 101325.000   5.879460e+05
 1.390e+00   2541.146 101325.000   5.879460e+05
 1.395e+00   2541.146 101325.000   5.879460e+05
 1.400e+00   2541.146 101325.000   5.879460e+05
In [9]:
rcParams['figure.figsize'] = (14, 10)

plt.clf()

plt.subplot(2, 2, 1)
plt.plot(times, data[:, 0])
plt.xlabel('Time (ms)')
plt.ylabel('Temperature (K)')

plt.subplot(2, 2, 2)
plt.plot(times, data[:, 1])
plt.xlabel('Time (ms)')
plt.ylabel('O2 Mole Fraction')

plt.subplot(2, 2, 3)
plt.plot(times, data[:, 2])
plt.xlabel('Time (ms)')
plt.ylabel('CO2 Mole Fraction')

plt.subplot(2, 2, 4)
plt.plot(times, data[:, 3])
plt.xlabel('Time (ms)')
plt.ylabel('CH4 Mole Fraction')

plt.show()
Try to modify the script by creating an IdealGasConstPressureReactor instead of setting the environment into a reservoir to maintain the pressure.

Reset gas state and set the new IdealGasConstPressureReactor

In [9]:
# Mechanisms used for the process
gri3 = ct.Solution('gri30.yaml')

# Gas state
gri3.TPX = 1000.0, ct.one_atm, 'CH4:0.5,O2:1,N2:3.76'

r = ct.IdealGasConstPressureReactor(gri3)

# Prepare the simulation with a ReactorNet object
sim = ct.ReactorNet([r])
time = 4.e-1

Simulate the new case

In [10]:
# Arrays to hold the datas
times = np.zeros(200)
data = np.zeros((200, 4))

# Advance the simulation in time
print(('%10s %10s %10s %14s' % ('t [s]', 'T [K]', 'P [Pa]', 'h [J/kg]')))
for n in range(200):
    time += 5.e-3
    sim.advance(time)
    times[n] = time  # time in s
    data[n, 0] = r.T
    data[n, 1:] = r.thermo['O2', 'CO2', 'CH4'].X
    print(('%10.3e %10.3f %10.3f %14.6e' % (sim.time, r.T,
                                            r.thermo.P, r.thermo.h)))
     t [s]      T [K]     P [Pa]       h [J/kg]
 4.050e-01   1000.862 101325.000   5.879464e+05
 4.100e-01   1000.883 101325.000   5.879464e+05
 4.150e-01   1000.905 101325.000   5.879464e+05
 4.200e-01   1000.927 101325.000   5.879464e+05
 4.250e-01   1000.950 101325.000   5.879464e+05
 4.300e-01   1000.973 101325.000   5.879464e+05
 4.350e-01   1000.996 101325.000   5.879464e+05
 4.400e-01   1001.020 101325.000   5.879464e+05
 4.450e-01   1001.044 101325.000   5.879464e+05
 4.500e-01   1001.069 101325.000   5.879464e+05
 4.550e-01   1001.094 101325.000   5.879464e+05
 4.600e-01   1001.120 101325.000   5.879464e+05
 4.650e-01   1001.146 101325.000   5.879464e+05
 4.700e-01   1001.173 101325.000   5.879464e+05
 4.750e-01   1001.201 101325.000   5.879464e+05
 4.800e-01   1001.228 101325.000   5.879464e+05
 4.850e-01   1001.257 101325.000   5.879464e+05
 4.900e-01   1001.286 101325.000   5.879464e+05
 4.950e-01   1001.315 101325.000   5.879464e+05
 5.000e-01   1001.345 101325.000   5.879464e+05
 5.050e-01   1001.376 101325.000   5.879464e+05
 5.100e-01   1001.407 101325.000   5.879464e+05
 5.150e-01   1001.439 101325.000   5.879464e+05
 5.200e-01   1001.471 101325.000   5.879464e+05
 5.250e-01   1001.504 101325.000   5.879464e+05
 5.300e-01   1001.538 101325.000   5.879464e+05
 5.350e-01   1001.573 101325.000   5.879464e+05
 5.400e-01   1001.608 101325.000   5.879464e+05
 5.450e-01   1001.644 101325.000   5.879464e+05
 5.500e-01   1001.680 101325.000   5.879464e+05
 5.550e-01   1001.718 101325.000   5.879464e+05
 5.600e-01   1001.756 101325.000   5.879464e+05
 5.650e-01   1001.795 101325.000   5.879464e+05
 5.700e-01   1001.834 101325.000   5.879464e+05
 5.750e-01   1001.875 101325.000   5.879464e+05
 5.800e-01   1001.916 101325.000   5.879464e+05
 5.850e-01   1001.958 101325.000   5.879464e+05
 5.900e-01   1002.001 101325.000   5.879464e+05
 5.950e-01   1002.045 101325.000   5.879464e+05
 6.000e-01   1002.090 101325.000   5.879464e+05
 6.050e-01   1002.136 101325.000   5.879464e+05
 6.100e-01   1002.183 101325.000   5.879464e+05
 6.150e-01   1002.231 101325.000   5.879464e+05
 6.200e-01   1002.280 101325.000   5.879464e+05
 6.250e-01   1002.330 101325.000   5.879464e+05
 6.300e-01   1002.381 101325.000   5.879464e+05
 6.350e-01   1002.433 101325.000   5.879464e+05
 6.400e-01   1002.486 101325.000   5.879464e+05
 6.450e-01   1002.541 101325.000   5.879464e+05
 6.500e-01   1002.596 101325.000   5.879464e+05
 6.550e-01   1002.653 101325.000   5.879464e+05
 6.600e-01   1002.712 101325.000   5.879464e+05
 6.650e-01   1002.771 101325.000   5.879464e+05
 6.700e-01   1002.832 101325.000   5.879464e+05
 6.750e-01   1002.895 101325.000   5.879464e+05
 6.800e-01   1002.959 101325.000   5.879464e+05
 6.850e-01   1003.024 101325.000   5.879464e+05
 6.900e-01   1003.091 101325.000   5.879464e+05
 6.950e-01   1003.159 101325.000   5.879464e+05
 7.000e-01   1003.229 101325.000   5.879464e+05
 7.050e-01   1003.301 101325.000   5.879464e+05
 7.100e-01   1003.375 101325.000   5.879464e+05
 7.150e-01   1003.450 101325.000   5.879464e+05
 7.200e-01   1003.527 101325.000   5.879464e+05
 7.250e-01   1003.606 101325.000   5.879464e+05
 7.300e-01   1003.687 101325.000   5.879464e+05
 7.350e-01   1003.771 101325.000   5.879464e+05
 7.400e-01   1003.856 101325.000   5.879464e+05
 7.450e-01   1003.944 101325.000   5.879464e+05
 7.500e-01   1004.033 101325.000   5.879464e+05
 7.550e-01   1004.126 101325.000   5.879464e+05
 7.600e-01   1004.220 101325.000   5.879464e+05
 7.650e-01   1004.317 101325.000   5.879464e+05
 7.700e-01   1004.417 101325.000   5.879464e+05
 7.750e-01   1004.520 101325.000   5.879464e+05
 7.800e-01   1004.625 101325.000   5.879464e+05
 7.850e-01   1004.734 101325.000   5.879464e+05
 7.900e-01   1004.845 101325.000   5.879464e+05
 7.950e-01   1004.960 101325.000   5.879464e+05
 8.000e-01   1005.078 101325.000   5.879464e+05
 8.050e-01   1005.200 101325.000   5.879464e+05
 8.100e-01   1005.325 101325.000   5.879464e+05
 8.150e-01   1005.454 101325.000   5.879464e+05
 8.200e-01   1005.587 101325.000   5.879464e+05
 8.250e-01   1005.724 101325.000   5.879464e+05
 8.300e-01   1005.865 101325.000   5.879464e+05
 8.350e-01   1006.011 101325.000   5.879464e+05
 8.400e-01   1006.162 101325.000   5.879464e+05
 8.450e-01   1006.317 101325.000   5.879464e+05
 8.500e-01   1006.478 101325.000   5.879464e+05
 8.550e-01   1006.645 101325.000   5.879464e+05
 8.600e-01   1006.817 101325.000   5.879464e+05
 8.650e-01   1006.995 101325.000   5.879464e+05
 8.700e-01   1007.179 101325.000   5.879464e+05
 8.750e-01   1007.370 101325.000   5.879464e+05
 8.800e-01   1007.568 101325.000   5.879464e+05
 8.850e-01   1007.774 101325.000   5.879464e+05
 8.900e-01   1007.988 101325.000   5.879464e+05
 8.950e-01   1008.210 101325.000   5.879464e+05
 9.000e-01   1008.440 101325.000   5.879464e+05
 9.050e-01   1008.681 101325.000   5.879464e+05
 9.100e-01   1008.931 101325.000   5.879464e+05
 9.150e-01   1009.192 101325.000   5.879464e+05
 9.200e-01   1009.465 101325.000   5.879464e+05
 9.250e-01   1009.749 101325.000   5.879464e+05
 9.300e-01   1010.047 101325.000   5.879464e+05
 9.350e-01   1010.359 101325.000   5.879464e+05
 9.400e-01   1010.686 101325.000   5.879464e+05
 9.450e-01   1011.029 101325.000   5.879464e+05
 9.500e-01   1011.390 101325.000   5.879464e+05
 9.550e-01   1011.770 101325.000   5.879464e+05
 9.600e-01   1012.171 101325.000   5.879464e+05
 9.650e-01   1012.595 101325.000   5.879464e+05
 9.700e-01   1013.043 101325.000   5.879464e+05
 9.750e-01   1013.518 101325.000   5.879464e+05
 9.800e-01   1014.024 101325.000   5.879464e+05
 9.850e-01   1014.562 101325.000   5.879464e+05
 9.900e-01   1015.137 101325.000   5.879464e+05
 9.950e-01   1015.753 101325.000   5.879464e+05
 1.000e+00   1016.415 101325.000   5.879464e+05
 1.005e+00   1017.129 101325.000   5.879464e+05
 1.010e+00   1017.901 101325.000   5.879464e+05
 1.015e+00   1018.741 101325.000   5.879464e+05
 1.020e+00   1019.659 101325.000   5.879464e+05
 1.025e+00   1020.668 101325.000   5.879464e+05
 1.030e+00   1021.783 101325.000   5.879464e+05
 1.035e+00   1023.024 101325.000   5.879464e+05
 1.040e+00   1024.419 101325.000   5.879464e+05
 1.045e+00   1026.001 101325.000   5.879464e+05
 1.050e+00   1027.818 101325.000   5.879464e+05
 1.055e+00   1029.936 101325.000   5.879464e+05
 1.060e+00   1032.449 101325.000   5.879464e+05
 1.065e+00   1035.502 101325.000   5.879464e+05
 1.070e+00   1039.329 101325.000   5.879464e+05
 1.075e+00   1044.335 101325.000   5.879464e+05
 1.080e+00   1051.308 101325.000   5.879464e+05
 1.085e+00   1062.054 101325.000   5.879464e+05
 1.090e+00   1082.104 101325.000   5.879464e+05
 1.095e+00   1146.143 101325.000   5.879464e+05
 1.100e+00   2549.418 101325.000   5.879464e+05
 1.105e+00   2545.389 101325.000   5.879464e+05
 1.110e+00   2543.191 101325.000   5.879464e+05
 1.115e+00   2542.105 101325.000   5.879464e+05
 1.120e+00   2541.590 101325.000   5.879464e+05
 1.125e+00   2541.351 101325.000   5.879464e+05
 1.130e+00   2541.240 101325.000   5.879464e+05
 1.135e+00   2541.189 101325.000   5.879464e+05
 1.140e+00   2541.166 101325.000   5.879464e+05
 1.145e+00   2541.155 101325.000   5.879464e+05
 1.150e+00   2541.151 101325.000   5.879464e+05
 1.155e+00   2541.148 101325.000   5.879464e+05
 1.160e+00   2541.147 101325.000   5.879464e+05
 1.165e+00   2541.147 101325.000   5.879464e+05
 1.170e+00   2541.147 101325.000   5.879464e+05
 1.175e+00   2541.147 101325.000   5.879464e+05
 1.180e+00   2541.146 101325.000   5.879464e+05
 1.185e+00   2541.146 101325.000   5.879464e+05
 1.190e+00   2541.146 101325.000   5.879464e+05
 1.195e+00   2541.146 101325.000   5.879464e+05
 1.200e+00   2541.146 101325.000   5.879464e+05
 1.205e+00   2541.146 101325.000   5.879464e+05
 1.210e+00   2541.146 101325.000   5.879464e+05
 1.215e+00   2541.146 101325.000   5.879464e+05
 1.220e+00   2541.146 101325.000   5.879464e+05
 1.225e+00   2541.146 101325.000   5.879464e+05
 1.230e+00   2541.146 101325.000   5.879464e+05
 1.235e+00   2541.146 101325.000   5.879464e+05
 1.240e+00   2541.146 101325.000   5.879464e+05
 1.245e+00   2541.146 101325.000   5.879464e+05
 1.250e+00   2541.146 101325.000   5.879464e+05
 1.255e+00   2541.146 101325.000   5.879464e+05
 1.260e+00   2541.146 101325.000   5.879464e+05
 1.265e+00   2541.146 101325.000   5.879464e+05
 1.270e+00   2541.146 101325.000   5.879464e+05
 1.275e+00   2541.146 101325.000   5.879464e+05
 1.280e+00   2541.146 101325.000   5.879464e+05
 1.285e+00   2541.146 101325.000   5.879464e+05
 1.290e+00   2541.146 101325.000   5.879464e+05
 1.295e+00   2541.146 101325.000   5.879464e+05
 1.300e+00   2541.146 101325.000   5.879464e+05
 1.305e+00   2541.146 101325.000   5.879464e+05
 1.310e+00   2541.146 101325.000   5.879464e+05
 1.315e+00   2541.146 101325.000   5.879464e+05
 1.320e+00   2541.146 101325.000   5.879464e+05
 1.325e+00   2541.146 101325.000   5.879464e+05
 1.330e+00   2541.146 101325.000   5.879464e+05
 1.335e+00   2541.146 101325.000   5.879464e+05
 1.340e+00   2541.146 101325.000   5.879464e+05
 1.345e+00   2541.146 101325.000   5.879464e+05
 1.350e+00   2541.146 101325.000   5.879464e+05
 1.355e+00   2541.146 101325.000   5.879464e+05
 1.360e+00   2541.146 101325.000   5.879464e+05
 1.365e+00   2541.146 101325.000   5.879464e+05
 1.370e+00   2541.146 101325.000   5.879464e+05
 1.375e+00   2541.146 101325.000   5.879464e+05
 1.380e+00   2541.146 101325.000   5.879464e+05
 1.385e+00   2541.146 101325.000   5.879464e+05
 1.390e+00   2541.146 101325.000   5.879464e+05
 1.395e+00   2541.146 101325.000   5.879464e+05
 1.400e+00   2541.146 101325.000   5.879464e+05

Plot the results and compare with the previous one

In [11]:
rcParams['figure.figsize'] = (14, 10)

plt.clf()

plt.subplot(2, 2, 1)
plt.plot(times, data[:, 0])
plt.xlabel('Time (ms)')
plt.ylabel('Temperature (K)')

plt.subplot(2, 2, 2)
plt.plot(times, data[:, 1])
plt.xlabel('Time (ms)')
plt.ylabel('O2 Mole Fraction')

plt.subplot(2, 2, 3)
plt.plot(times, data[:, 2])
plt.xlabel('Time (ms)')
plt.ylabel('CO2 Mole Fraction')

plt.subplot(2, 2, 4)
plt.plot(times, data[:, 3])
plt.xlabel('Time (ms)')
plt.ylabel('CH4 Mole Fraction')

plt.show()

4. An example of application : mixing two streams

Up until now, we have seen how to generate simple closed vessels. However, it is sometimes interesting to mix different streams, or to feed the exhaust of a reservoir with constant parameters to a reacting reactor. In this exercise, we will design a script that simulates the stoichiometric constant volume mixing of a stream of air with a stream of pure gaseous methane.

title

Set the two gases and the molar mass associated

You will have to :
- set a first gas a with an air mixture at 0.21 of O2, 0.01 of AR and 0.78 of N2
- set a second gas b with a gri30 mixture at 1 of CH4
In [12]:
gas_a = ct.Solution('air.yaml')
gas_a.TPX = 300, ct.one_atm, 'O2:0.21, N2:0.78, AR:0.01'
mw_a = gas_a.mean_molecular_weight/1000 #kg/mol

gas_b = ct.Solution('gri30.yaml')
gas_b.TPX = 300.0, ct.one_atm, 'CH4:1'
mw_b = gas_b.mean_molecular_weight/1000 #kg/mol

Creation of two reservoirs and an exhaust one (ReactorBase)

You will have to :
- set a first reservoir from gas a
- set a second reservoir from gas b
- set a downstream reservoir filled with gas b
In [13]:
res_a = ct.Reservoir(gas_a)
res_b = ct.Reservoir(gas_b)
downstream = ct.Reservoir(gas_b)

Generate the reactor that will receive the mixed stream (ReactorBase)

You will have to :
- change the condition of the gas b to respect an air mix.
- create and IdealGasReactor with the energy equation set to 'on'.
In [14]:
gas_b.TPX = 300, ct.one_atm, 'O2:1., N2:3.78, CH4:0.5'
mixer = ct.IdealGasReactor(gas_b, energy='on')

Watch out here, the mixture should be the one of gas_b, as the reactions will occur with the mechanism from gri30 (and not from the air).

Creation of the mass flow controller that will control the mixing (FlowDevice)

Now that you have specified all the elements of the reactor, you need to detail the link between them. This is what is done in the following lines :

In [15]:
mfca = ct.MassFlowController(res_a, mixer)
mdota = mfca.mass_flow_rate = mw_a*2./0.21
mfcb = ct.MassFlowController(res_b, mixer)
mdotb = mfcb.mass_flow_rate = mw_b*1.0

Creation of the valve between the mixer and the downstream (FlowDevice)

Finally, the valve is created.

In [16]:
outlet = ct.Valve(mixer, downstream, K=10.0)

This valve will enable the system to keep a constant pressure at the inlet of the mixer and at the outlet.

Creation of the net reactor to compute simulation

You need to create the ReactorNet with the mixer.
In [17]:
sim = ct.ReactorNet([mixer])
In [18]:
# Since the mixer is a reactor, we need to integrate in time to reach steady
# state. A few residence times should be enough.
print('{0:>14s} {1:>14s} {2:>14s} {3:>14s} {4:>14s}'.format('t [s]', 'T [K]', 'h [J/kg]', 'P [Pa]', 'X_CH4'))
t = 0.0
for n in range(100):
    tres = mixer.mass/(mdota + mdotb)
    t += 2*tres
    sim.advance(t)
    print('{0:14.5g} {1:14.5g} {2:14.5g} {3:14.5g} {4:14.5g}'.format(t, mixer.T, mixer.thermo.h, mixer.thermo.P, mixer.thermo['CH4'].X[0]))

print(mixer.thermo.report())
         t [s]          T [K]       h [J/kg]         P [Pa]          X_CH4
        7.6903            300    -2.5352e+05     1.0133e+05       0.094978
        15.406            300    -2.5351e+05     1.0133e+05       0.095017
        23.126            300    -2.5351e+05     1.0133e+05       0.095022
        30.846            300    -2.5351e+05     1.0133e+05       0.095023
        38.566            300    -2.5351e+05     1.0133e+05       0.095023
        46.286            300    -2.5351e+05     1.0133e+05       0.095023
        54.006            300    -2.5351e+05     1.0133e+05       0.095023
        61.726            300    -2.5351e+05     1.0133e+05       0.095023
        69.446            300    -2.5351e+05     1.0133e+05       0.095023
        77.166            300    -2.5351e+05     1.0133e+05       0.095023
        84.886            300    -2.5351e+05     1.0133e+05       0.095023
        92.606            300    -2.5351e+05     1.0133e+05       0.095023
        100.33            300    -2.5351e+05     1.0133e+05       0.095023
        108.05            300    -2.5351e+05     1.0133e+05       0.095023
        115.77            300    -2.5351e+05     1.0133e+05       0.095023
        123.49            300    -2.5351e+05     1.0133e+05       0.095023
        131.21            300    -2.5351e+05     1.0133e+05       0.095023
        138.93            300    -2.5351e+05     1.0133e+05       0.095023
        146.65            300    -2.5351e+05     1.0133e+05       0.095023
        154.37            300    -2.5351e+05     1.0133e+05       0.095023
        162.09            300    -2.5351e+05     1.0133e+05       0.095023
        169.81            300    -2.5351e+05     1.0133e+05       0.095023
        177.53            300    -2.5351e+05     1.0133e+05       0.095023
        185.25            300    -2.5351e+05     1.0133e+05       0.095023
        192.97            300    -2.5351e+05     1.0133e+05       0.095023
        200.69            300    -2.5351e+05     1.0133e+05       0.095023
        208.41            300    -2.5351e+05     1.0133e+05       0.095023
        216.13            300    -2.5351e+05     1.0133e+05       0.095023
        223.85            300    -2.5351e+05     1.0133e+05       0.095023
        231.57            300    -2.5351e+05     1.0133e+05       0.095023
        239.29            300    -2.5351e+05     1.0133e+05       0.095023
        247.01            300    -2.5351e+05     1.0133e+05       0.095023
        254.73            300    -2.5351e+05     1.0133e+05       0.095023
        262.45            300    -2.5351e+05     1.0133e+05       0.095023
        270.17            300    -2.5351e+05     1.0133e+05       0.095023
        277.89            300    -2.5351e+05     1.0133e+05       0.095023
        285.61            300    -2.5351e+05     1.0133e+05       0.095023
        293.33            300    -2.5351e+05     1.0133e+05       0.095023
        301.05            300    -2.5351e+05     1.0133e+05       0.095023
        308.77            300    -2.5351e+05     1.0133e+05       0.095023
        316.49            300    -2.5351e+05     1.0133e+05       0.095023
        324.21            300    -2.5351e+05     1.0133e+05       0.095023
        331.93            300    -2.5351e+05     1.0133e+05       0.095023
        339.65            300    -2.5351e+05     1.0133e+05       0.095023
        347.37            300    -2.5351e+05     1.0133e+05       0.095023
        355.09            300    -2.5351e+05     1.0133e+05       0.095023
        362.81            300    -2.5351e+05     1.0133e+05       0.095023
        370.53            300    -2.5351e+05     1.0133e+05       0.095023
        378.25            300    -2.5351e+05     1.0133e+05       0.095023
        385.97            300    -2.5351e+05     1.0133e+05       0.095023
        393.69            300    -2.5351e+05     1.0133e+05       0.095023
        401.41            300    -2.5351e+05     1.0133e+05       0.095023
        409.13            300    -2.5351e+05     1.0133e+05       0.095023
        416.85            300    -2.5351e+05     1.0133e+05       0.095023
        424.57            300    -2.5351e+05     1.0133e+05       0.095023
        432.29            300    -2.5351e+05     1.0133e+05       0.095023
        440.01            300    -2.5351e+05     1.0133e+05       0.095023
        447.73            300    -2.5351e+05     1.0133e+05       0.095023
        455.45            300    -2.5351e+05     1.0133e+05       0.095023
        463.17            300    -2.5351e+05     1.0133e+05       0.095023
        470.89            300    -2.5351e+05     1.0133e+05       0.095023
        478.61            300    -2.5351e+05     1.0133e+05       0.095023
        486.33            300    -2.5351e+05     1.0133e+05       0.095023
        494.05            300    -2.5351e+05     1.0133e+05       0.095023
        501.77            300    -2.5351e+05     1.0133e+05       0.095023
        509.49            300    -2.5351e+05     1.0133e+05       0.095023
        517.21            300    -2.5351e+05     1.0133e+05       0.095023
        524.93            300    -2.5351e+05     1.0133e+05       0.095023
        532.65            300    -2.5351e+05     1.0133e+05       0.095023
        540.37            300    -2.5351e+05     1.0133e+05       0.095023
        548.09            300    -2.5351e+05     1.0133e+05       0.095023
        555.81            300    -2.5351e+05     1.0133e+05       0.095023
        563.53            300    -2.5351e+05     1.0133e+05       0.095023
        571.25            300    -2.5351e+05     1.0133e+05       0.095023
        578.97            300    -2.5351e+05     1.0133e+05       0.095023
        586.69            300    -2.5351e+05     1.0133e+05       0.095023
        594.41            300    -2.5351e+05     1.0133e+05       0.095023
        602.13            300    -2.5351e+05     1.0133e+05       0.095023
        609.85            300    -2.5351e+05     1.0133e+05       0.095023
        617.57            300    -2.5351e+05     1.0133e+05       0.095023
        625.29            300    -2.5351e+05     1.0133e+05       0.095023
        633.01            300    -2.5351e+05     1.0133e+05       0.095023
        640.73            300    -2.5351e+05     1.0133e+05       0.095023
        648.45            300    -2.5351e+05     1.0133e+05       0.095023
        656.17            300    -2.5351e+05     1.0133e+05       0.095023
        663.89            300    -2.5351e+05     1.0133e+05       0.095023
        671.61            300    -2.5351e+05     1.0133e+05       0.095023
        679.33            300    -2.5351e+05     1.0133e+05       0.095023
        687.05            300    -2.5351e+05     1.0133e+05       0.095023
        694.77            300    -2.5351e+05     1.0133e+05       0.095023
        702.49            300    -2.5351e+05     1.0133e+05       0.095023
        710.21            300    -2.5351e+05     1.0133e+05       0.095023
        717.93            300    -2.5351e+05     1.0133e+05       0.095023
        725.65            300    -2.5351e+05     1.0133e+05       0.095023
        733.37            300    -2.5351e+05     1.0133e+05       0.095023
        741.09            300    -2.5351e+05     1.0133e+05       0.095023
        748.81            300    -2.5351e+05     1.0133e+05       0.095023
        756.53            300    -2.5351e+05     1.0133e+05       0.095023
        764.25            300    -2.5351e+05     1.0133e+05       0.095023
        771.97            300    -2.5351e+05     1.0133e+05       0.095023

  gri30:

       temperature   300 K
          pressure   1.0133e+05 Pa
           density   1.1269 kg/m^3
  mean mol. weight   27.742 kg/kmol
   phase of matter   gas

                          1 kg             1 kmol     
                     ---------------   ---------------
          enthalpy       -2.5351e+05       -7.0327e+06  J
   internal energy       -3.4342e+05       -9.5271e+06  J
           entropy            7221.9        2.0035e+05  J/K
    Gibbs function       -2.4201e+06       -6.7137e+07  J
 heat capacity c_p            1070.4             29695  J/K
 heat capacity c_v            770.71             21381  J/K

                      mass frac. Y      mole frac. X     chem. pot. / RT
                     ---------------   ---------------   ---------------
                O2            0.2192           0.19005           -26.334
               CH4          0.054952          0.095023           -54.676
                N2           0.71281           0.70588           -23.381
                AR          0.013032         0.0090498           -23.315
     [  +49 minor]         3.888e-33        4.4903e-33  

Notice that the gas did not ignite, and that the composition is indeed stoichiometric. We could trigger the ignition, by assuming that the reactor is 'already lit'. To do so, you need to initialize the content of the reactor with hot gases. The simplest way to do so is by filling it with stoichiometric mixture of air and methane at equilibrium. This is easily done by replacing the lines :
gas_b.TPX = 300.0, ct.one_atm, 'O2:0.21, N2:0.78, AR:0.01' mixer = ct.IdealGasReactor(gas_b)
with :
gas_b.TPX = 300.0,ct.one_atm,'O2:1., N2:3.78, CH4:0.5' gas_b.equilibrate("HP") mixer = ct.IdealGasReactor(gas_b)

5. Autoignition timing

An interesting feature of 0D simulations is that it allows to compute the temporal evolution of a mixture under specific conditions towards its equilibrium state. That evolution can be viewed as a sort of autoignition of the mixture.
To go further, that last exercise will guide you through such a computation of the autoignition timing of a methane/air mixture. Several definitions of the autoignition timing can be found in the literature. The most commonly accepted definition relies on the temperature gradient : the time of the sharpest temperature increase is spotted as being the autoignition point. In order to catch this time with precision, the time step of the simulation should be as small as possible.

Create the gas object

In [22]:
gas = ct.Solution('gri30.yaml')
gas.TPX = 1250, ct.one_atm, 'CH4:0.5, O2:1, N2:3.76'

Initialisation of the different values

In [23]:
# Initial temperatures
Temperature_range = list(range(800, 1700, 100))

# Specify the number of time steps and the time step size
nt = 100000
dt = 1.e-4  # s

# Storing auto ignitions
auto_ignitions = []
In [24]:
for index, Temperature in enumerate(Temperature_range):
    #################################################################
    # Initial temperature, Pressure and stoichiometry
    gas.TPX = Temperature, ct.one_atm, 'CH4:0.5, O2:1, N2:3.76'
    # Create the batch reactor
    r = ct.IdealGasReactor(gas)
    # Now create a reactor network consisting of the single batch reactor
    sim = ct.ReactorNet([r])
    # Storage space
    mfrac = []
    # ...
    time = []
    temperature = []
    HR = []
    # Run the simulation
    # Initial simulation time
    current_time = 0.0
    # Loop for nt time steps of dt seconds.
    for n in range(nt):
        current_time += dt
        sim.advance(current_time)
        time.append(current_time)
        temperature.append(r.T)
        mfrac.append(r.thermo.Y)
        HR.append(- np.dot(gas.net_production_rates, gas.partial_molar_enthalpies))
    #################################################################
    # Catch the autoignition timing
    #################################################################
    # Get the ignition delay time by the maximum value of the Heat Release rate
    auto_ignition = time[HR.index(max(HR))]
    print('For T = ' + str(Temperature) + ', Autoignition time = ' + str(auto_ignition) + ' s')
    # Posterity
    FinalTemp = temperature[nt - 1]
    auto_ignitions.append(auto_ignition)
    # #################################################################
    # # Save results
    # #################################################################
    # # write output CSV file for importing into Excel
    # csv_file = '3-Output/Phi-1_P-1_T-' + str(Temperature) + '_UV.csv'
    # with open(csv_file, 'w') as outfile:
    # writer = csv.writer(outfile)
    # writer.writerow(['Auto ignition time [s]', 'Final Temperature [K]'] + gas.species_names)
    # writer.writerow([auto_ignition, FinalTemp] + list(mfrac[:]))
    # print('output written to ' + csv_file)
T_invert = [1000 / Temperature for Temperature in Temperature_range]
For T = 800, Autoignition time = 9.999999999990033 s
For T = 900, Autoignition time = 7.055299999996896 s
For T = 1000, Autoignition time = 1.066899999999899 s
For T = 1100, Autoignition time = 0.19789999999999452 s
For T = 1200, Autoignition time = 0.043400000000000216 s
For T = 1300, Autoignition time = 0.011099999999999988 s
For T = 1400, Autoignition time = 0.0032999999999999982 s
For T = 1500, Autoignition time = 0.0011000000000000003 s
For T = 1600, Autoignition time = 0.0004 s
In [25]:
#################################################################
# Plot results
#################################################################
# create plot
plt.plot(Temperature_range, auto_ignitions, 'b-o')
plt.xlabel(r'Temperature [K]', fontsize=20)
plt.ylabel("Auto ignition [s]", fontsize=20)
plt.yscale('log')
plt.title(r'Autoignition of $CH_{4}$ + Air mixture at $\Phi$ = 1, and P = 1 bar',
fontsize=22, horizontalalignment='center')
plt.axis()
plt.grid()
plt.show()

This is a typical curve of the auto-ignition time as a function of the initial temperature, meaning that when the temperature increases, this time is reduced.