All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: To study auto-ignition using Cantera. Following are the tasks to perform using Cantera: Plot the variation of Auto Ignition time of Methane with a constant temperature of 1250K and pressure varying from 1 to 5 atm. Plot the variation of Auto Ignition time…
GAURAV KHARWADE
updated on 06 Dec 2020
Objective: To study auto-ignition using Cantera.
Following are the tasks to perform using Cantera:
Explain the behavior of the graph for 2 cases,
Theory:
Auto-Ignition Temperature
In the context of a combustible fuel mixture, the auto-ignition temperature is the lowest temperature at which the fuel will spontaneously ignite in a normal atmosphere without an external source of ignition such as a flame or spark.
This temperature is sometimes referred to as the kindling point of the fuel. Raising the temperature of the fuel to its auto-ignition point provides the energy required to initiate the chemical reaction needed for combustion. The auto-ignition temperature for a given fuel decreases as the pressure increases or as the oxygen concentration increases.
Reactor & Rector Networks
Reactor:
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 i.e. all states are a function of time. In particular, transient state changes due to chemical reactions are possible. However, the thermodynamic (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:
All of this interaction does not have to be constant but can vary as a function of time or states. 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.
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.
The state variables for Cantera’s general reactor model are
ConstPressureReactor()
and IdealGasConstPressureReactor()
)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()
and IdealGasConstPressureReactor()
: T, the temperature (in K)
4.Yk, the mass fractions for each species (dimensionless)
In the case of the Ideal Gas Reactor Model, the reactor temperature TT is used instead of the total internal energy UU 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:
mcvdUdt=−pdVdt−.Q+∑in.min(hin−∑kukYk,in)−pVm∑out.mout−∑k.mk,genuk
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.
In Cantera, the following steps are typically necessary to investigate a reactor network:
Solution
objects for the fluids to be flowing through your reactor network.Note that Cantera always solves a transient problem. If you are interested in steady-state conditions, you can run your simulation for a long time until the states are converged
Solutions:
CASE-1: Effect of Variation of pressure from 1 bar to 5 bar on auto-ignition.
Python script:
import sys
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
# Tp define initial pressure and temperature
T= 1250; # Initial Temperature in Kelvin
Pressure= np.linspace(1,5,5); # Range of Inlet Pressure
# Array to store state values
state_T= []
t_autoI = []
# For loop to execute for all values of pressure
for i in Pressure:
P= i * 101325 # in kPa
gas = ct.Solution('gri30.xml')
gas.TPX= T,P,{'CH4':1,'O2':2,'N2':7.52}
# Instance object to create a reactor which defines governing equation to solve
r= ct.IdealGasReactor()
r.insert(gas)
# To define reactor network to do solving part
sim= ct.ReactorNet([r])
time= 0.0 # Start time
t_end= 10 # Total simulation time
timestep= 1e-3 # timesteps to perform time integration
n= int((t_end-time)/timestep);
# To create solution array contianing temperature, pressure, species etc. values
states= ct.SolutionArray(gas, extra=['time_in_ms','t'])
for n in range(n):
time+= 1e-3
sim.advance(time)
states.append(r.thermo.state, time_in_ms= time*1e3, t=time)
state_T.append(states.T)
print(states.T)
# To find out time at which autoignition starts
for j in range(n):
Error= states.T[j] - T - 400
if Error > 0:
t_auto= states.time_in_ms[j]
break
t_autoI.append(t_auto)
state_T= np.array(state_T)
for k in range(len(Pressure)):
plt.figure(1)
plt.plot(state_T[k])
plt.xlabel("Timesteps")
plt.ylabel("Temperature")
plt.title("Variation of Auto-ignition Temperature with initial Pressure")
plt.legend(['1 Bar','2 Bar','3 Bar','4 Bar','5 Bar'])
plt.figure(2)
plt.plot(Pressure,t_autoI,'r-*')
plt.xlabel("Pressure in [Bar] ")
plt.ylabel("Ignition Delay in [ms]")
plt.title("Ignition Delay VS Initial Pressure")
plt.show()
Results:
Observations:
CASE-2: Effect of Variation of temperature from 950 k to 1450 k on auto-ignition.
Python script:
import sys
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
P= 5 * 101325; # Range of Inlet Pressure
Temperature= np.linspace(950,1450,5,endpoint=True); # Initial Temperature in Kelvin
state_T= []
t_autoI = []
for i in Temperature:
T= i
gas = ct.Solution('gri30.xml')
gas.TPX= T,P,{'CH4':1,'O2':2,'N2':7.52}
r= ct.IdealGasReactor()
r.insert(gas)
sim= ct.ReactorNet([r])
time= 0.0
t_end= 10 # in sec
timestep= 1e-3
n= int((t_end-time)/timestep);
states= ct.SolutionArray(gas, extra=['time_in_ms','t'])
for n in range(n):
time+= 1e-3
sim.advance(time)
states.append(r.thermo.state, time_in_ms= time*1e3, t=time)
state_T.append(states.T)
print(states.T)
for j in range(n):
Error= states.T[j] - T - 400
if Error > 0:
t_auto= states.time_in_ms[j]
break
t_autoI.append(t_auto)
state_T= np.array(state_T)
for k in range(len(Temperature)):
plt.figure(1)
q= Temperature[k]
plt.plot(state_T[k],label=str(q))
plt.xlabel("Timesteps")
plt.ylabel("Temperature")
plt.title("Variation of Auto-ignition Temperature with initial Temperature")
plt.legend()
plt.figure(2)
plt.plot(Temperature,t_autoI,'r-*')
plt.xlabel("Temperature in [Kelvin] ")
plt.ylabel("Ignition Delay in [ms]")
plt.title("Ignition Delay VS Initial Temperature")
plt.show()
Results:
Observation:
CASE-3: Plot the rate of change of molar concentrations of the given elements "H2O, O2, OH" with respect to the time.
Python script(Variation of temperature and mole fraction):
import sys
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
P= 5 * 101325; # Range of Inlet Pressure
Temperature= np.linspace(950,1450,5,endpoint=True); # Initial Temperature in Kelvin
state_T= []
t_autoI = []
for i in Temperature:
T= i
gas = ct.Solution('gri30.xml')
gas.TPX= T,P,{'CH4':1,'O2':2,'N2':7.52}
r= ct.IdealGasReactor()
r.insert(gas)
sim= ct.ReactorNet([r])
time= 0.0
t_end= 10 # in sec
timestep= 1e-3
n= int((t_end-time)/timestep);
states= ct.SolutionArray(gas, extra=['time_in_ms','t'])
for n in range(n):
time+= 1e-3
sim.advance(time)
states.append(r.thermo.state, time_in_ms= time*1e3, t=time)
state_T.append(states.T)
print(states.T)
for j in range(n):
Error= states.T[j] - T - 400
if Error > 0:
t_auto= states.time_in_ms[j]
break
t_autoI.append(t_auto)
state_T= np.array(state_T)
for k in range(len(Temperature)):
plt.figure(1)
q= Temperature[k]
plt.plot(state_T[k],label=str(q))
plt.xlabel("Timesteps")
plt.ylabel("Temperature")
plt.title("Variation of Auto-ignition Temperature with initial Temperature")
plt.legend()
plt.figure(2)
plt.plot(Temperature,t_autoI,'r-*')
plt.xlabel("Temperature in [Kelvin] ")
plt.ylabel("Ignition Delay in [ms]")
plt.title("Ignition Delay VS Initial Temperature")
# For mole fraction calculation of species
H2O_species= states.X[:,gas.species_index('H2O')]
O2_species= states.X[:,gas.species_index('O2')]
OH_species= states.X[:,gas.species_index('OH')]
print(H2O_species)
print(O2_species)
print(OH_species)
fig, ax= plt.subplots(3)
ax[0].plot(H2O_species)
ax[0].set_title('H2O_species')
ax[0].set_xlabel('Timesteps')
ax[0].set_ylabel('H2O mole fraction')
ax[0].grid('on')
fig.suptitle("Rate of change of molar concentrations of species H20, O2 & OH with respect to timesteps")
ax[1].plot(O2_species)
ax[1].set_title('O2_species')
ax[1].set_xlabel('Timesteps')
ax[1].set_ylabel('O2 mole fraction')
ax[1].grid('on')
ax[2].plot(OH_species)
ax[2].set_title('OH_species')
ax[2].set_xlabel('Timesteps')
ax[2].set_ylabel('OH mole fraction')
ax[2].grid('on')
fig.tight_layout()
plt.show()
Results:
Python script(Variation of pressure and mole fraction):
import sys
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
# Tp define initial pressure and temperature
T= 1250; # Initial Temperature in Kelvin
Pressure= np.linspace(1,5,5); # Range of Inlet Pressure
# Array to store state values
state_T= []
t_autoI = []
# For loop to execute for all values of pressure
for i in Pressure:
P= i * 101325 # in kPa
gas = ct.Solution('gri30.xml')
gas.TPX= T,P,{'CH4':1,'O2':2,'N2':7.52}
# Instance object to create a reactor which defines governing equation to solve
r= ct.IdealGasReactor()
r.insert(gas)
# To define reactor network to do solving part
sim= ct.ReactorNet([r])
time= 0.0 # Start time
t_end= 10 # Total simulation time
timestep= 1e-3 # timesteps to perform time integration
n= int((t_end-time)/timestep);
# To create solution array contianing temperature, pressure, species etc. values
states= ct.SolutionArray(gas, extra=['time_in_ms','t'])
for n in range(n):
time+= 1e-3
sim.advance(time)
states.append(r.thermo.state, time_in_ms= time*1e3, t=time)
state_T.append(states.T)
print(states.T)
# To find out time at which autoignition starts
for j in range(n):
Error= states.T[j] - T - 400
if Error > 0:
t_auto= states.time_in_ms[j]
break
t_autoI.append(t_auto)
state_T= np.array(state_T)
for k in range(len(Pressure)):
plt.figure(1)
plt.plot(state_T[k])
plt.xlabel("Timesteps")
plt.ylabel("Temperature")
plt.title("Variation of Auto-ignition Temperature with initial Pressure")
plt.legend(['1 Bar','2 Bar','3 Bar','4 Bar','5 Bar'])
plt.figure(2)
plt.plot(Pressure,t_autoI,'r-*')
plt.xlabel("Pressure in [Bar] ")
plt.ylabel("Ignition Delay in [ms]")
plt.title("Ignition Delay VS Initial Pressure")
# For mole fraction calculation of species
H2O_species= states.X[:,gas.species_index('H2O')]
O2_species= states.X[:,gas.species_index('O2')]
OH_species= states.X[:,gas.species_index('OH')]
print(H2O_species)
print(O2_species)
print(OH_species)
fig, ax= plt.subplots(3)
ax[0].plot(H2O_species)
ax[0].set_title('H2O_species')
ax[0].set_xlabel('Timesteps')
ax[0].set_ylabel('H2O mole fraction')
ax[0].grid('on')
fig.suptitle("Rate of change of molar concentrations of species H20, O2 & OH with respect to timesteps")
ax[1].plot(O2_species)
ax[1].set_title('O2_species')
ax[1].set_xlabel('Timesteps')
ax[1].set_ylabel('O2 mole fraction')
ax[1].grid('on')
ax[2].plot(OH_species)
ax[2].set_title('OH_species')
ax[2].set_xlabel('Timesteps')
ax[2].set_ylabel('OH mole fraction')
ax[2].grid('on')
fig.tight_layout()
plt.show()
Results:
Observation:
CASE-4: Behaviour graphs with two different conditions
Python scripts:
import sys
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
T= 500
P= 5* 101325
gas = ct.Solution('gri30.xml')
gas.TPX= T,P,{'CH4':1,'O2':2,'N2':7.52}
r= ct.IdealGasReactor()
r.insert(gas)
sim= ct.ReactorNet([r])
time= 0.0
t_end= 10 # in sec
timestep= 1e-3
n= int((t_end-time)/timestep);
states= ct.SolutionArray(gas, extra=['time_in_ms','t'])
for n in range(n):
time+= 1e-3
sim.advance(time)
states.append(r.thermo.state, time_in_ms= time*1e3, t=time)
H2O_species= states.X[:,gas.species_index('H2O')]
O2_species= states.X[:,gas.species_index('O2')]
OH_species= states.X[:,gas.species_index('OH')]
print(H2O_species)
print(O2_species)
print(OH_species)
fig, ax= plt.subplots(3)
ax[0].plot(H2O_species)
ax[0].set_title('H2O_species')
ax[0].set_xlabel('Timesteps')
ax[0].set_ylabel('H2O mole fraction')
ax[0].grid('on')
fig.suptitle("Rate of change of molar concentrations of species H20, O2 & OH with respect to timesteps")
ax[1].plot(O2_species)
ax[1].set_title('O2_species')
ax[1].set_xlabel('Timesteps')
ax[1].set_ylabel('O2 mole fraction')
ax[1].grid('on')
ax[2].plot(OH_species)
ax[2].set_title('OH_species')
ax[2].set_xlabel('Timesteps')
ax[2].set_ylabel('OH mole fraction')
ax[2].grid('on')
fig.tight_layout()
plt.show()
Results:
2. When Temperature is 1000K and pressure 5 bar
Observation:
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 9 - Senstivity Analysis Assignment
Objective: To write the code which will take entire reactions of GRI mechanism 3.0 and take out the most sensitive top 10 reactions. The main parameters are as follows: Write code to list out the top 10 most sensitive reactions from a list of all reactions from the GRI mechanism. The sensitivity parameters should be with…
04 Jan 2021 05:51 PM IST
Auto ignition analysis of combustible mixture methane under different conditions using Cantera and Python
Objective: To study auto-ignition using Cantera. Following are the tasks to perform using Cantera: Plot the variation of Auto Ignition time of Methane with a constant temperature of 1250K and pressure varying from 1 to 5 atm. Plot the variation of Auto Ignition time…
06 Dec 2020 04:55 AM IST
Week 6 - Multivariate Newton Rhapson Solver
Objective: To solve a given set of Ordinary Differential equations using the Multi-Variate Newton Raphson Method. Given: The set of ODE's are given below: dy1dt=−0.04⋅y1+104⋅y2⋅y3 dy2dt=0.04⋅y1−104⋅y2⋅y3−3⋅107⋅y22 dy3dt=3⋅107⋅y22 The jacobian should be estimated numerically and not analytically.…
01 Nov 2020 03:50 AM IST
Week 5 - Literature review: ODE Stability
Objective: To review the literature about ODE and to write the python program to substantiate our results. Theory: …
20 Oct 2020 03:52 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.