Auto ignition using Cantera
Objective:
- Write the reaction network code for stoichiometric methane combustion.
- Plot the variation of auto-ignition time with the change in pressure from one bar to 5 bar.
- Plot the auto-ignition time with the temperature from 950K to 1450K
- Plot the rate of change of molar concentration of H20, O2, OH with respect to time.
Auto-ignition time:
The auto-ignition temperature of a substance is the lowest temperature in which it spontaneously ignites in normal atmosphere without an external source of ignition, such as a flame or spark. This temperature is required to supply the activation energy needed for combustion. Ignition delay is the time required to ignition to takes place.
Auto Ignition time is the time when the temperature of the reactor is Initial Temperature plus 400K.
`Time_(ignition delay)=Time_(Initial temperature+400K)`
In order to get the ignition delay for different temperatures and pressure conditions, a function is created with inputs as temperature and pressure and return the ignition delay. And using this function change in ignition delay with temperature and pressure are plotted.
Python code
"""
Reaction network
combustion of methane
"""
import sys
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
#Defining function for calculating ignition delay of methane combustion
Temp1 = []
def tig(T,P):
#defining gas and properties
gas=ct.Solution('gri30.xml')
gas.TPX=T,P,{'CH4':1,'O2':2,'N2':7.52}
r =ct.IdealGasReactor(gas)
sim=ct.ReactorNet([r])
#initial time
time=0
#number of time steps
nt=1000
#step size
dt=1e-3
tdel=[]
states=ct.SolutionArray(gas, extra=['time_in_ms','t'])
#time loop
for n in range(nt):
time+=dt
sim.advance(time)
states.append(r.thermo.state,time_in_ms = time*1e3, t=time)
Temp=states.T
Temp1.append(Temp)
for n in range(nt):
if ((states.T[n]-T)>=400):
tdel = states.time_in_ms[n]
break
return tdel
#pressure loop
P_bar=[]
t_igp=[]
for i in range(1,6):
T=1250 #K
P=i*101325
P_bar.append(i)
t_igp.append(tig(T,P))
plt.plot(P_bar,t_igp)
plt.xlabel('pressure(bar)')
plt.ylabel('Time(S)')
plt.show()
#temperature
NT=5
t_igt=[]
for j in range(950,1450,50):
T=j
P=101325
t_igt.append(tig(T,P))
Temp2=np.linspace(950,1450,7)
plt.plot(Temp2,t_igt[2:9])
plt.xlabel('Temperature(K)')
plt.ylabel('time(ms)')
plt.show()
Python code for plotting concentrations of given elements
"""
reactornetwork
Methane combustion
"""
import sys
import cantera as ct
import numpy as np
import matplotlib.pyplot as plt
#number of time step and step size
nt=10000
dt=1e-3
Temp=1000 #k
Pres=5*101325#pa
gas=ct.Solution('gri30.xml')
gas.TPX=Temp,Pres,{'CH4':1,'O2':2,'N2':7.52}
r=ct.IdealGasReactor(gas)
sim=ct.ReactorNet([r])
time=0
#x_H2O=[]
tim=[]
states=ct.SolutionArray(gas)
for n in range (nt):
time+=dt
sim.advance(time)
states.append(r.thermo.state,time_in_ms = time*1e3, t=time)
tim.append(time)
x_H2O=states.X[:,gas.species_index('H2O')]
plt.plot(tim,x_H2O)
plt.xlabel('Time')
plt.ylabel('H2O Mole fraction')
plt.show()
x_O2=states.X[:,gas.species_index('O2')]
plt.plot(tim,x_O2)
plt.xlabel('Time')
plt.ylabel('O2 Mole fraction ')
plt.show()
x_OH=states.X[:,gas.species_index('OH')]
plt.plot(tim,x_OH)
plt.xlabel('Time')
plt.ylabel('OH Mole fraction')
plt.show()
Result
The change in ignition delay with different pressure and temperature conditions
Case 1: Constant temperature and various pressure values
Case 2: Constant pressure and various temperature values
From the above plots, we can see that ignition delay decreases with an increase in temperature and pressure values.
Part II
The change in concentration of H20, O2, OH with time
a) At Temperature is 1000K and pressure 5 bar
From the above plots, The H2O concentration increases rapidly at a particular time. Since H2O is a product of methane combustion its concentration increases rapidly after ignition delay. O2 is a reactant species of methane combustion so the concentration of O2 decreases rapidly after ignition delay.
b) Temperature is 500K and pressure 5 bar
Since temperature is very low, The temperature is less than the autoignition temperature. Combustion does not take place so there is no change in the concentration of O2.