Week 7 - Auto ignition using Cantera
Aim: - To simulate Auto Ignition time for combustion of Methane using Cantera in Python.
Objective: -
- To 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 of Methane with a constant pressure of 5 atm and temperature varying from 950K to 1450K.
- To observe and print the rate of change of molar concentrations of the elements "H2O, O2, OH" with respect to the time.
- When Temperature is 1000K and pressure 5 bar
- When Temperature is 500K and pressure 5 bar
Theory: -
Auto Ignition – It a state in which an Air-Fuel mixture start combustion without any external source of ignition such spark or flame. It depends on type of fuel used and its thermodynamic state.
Auto Ignition Temperature – the auto-ignition temperature or kindling point of a substance is the lowest temperature in which it spontaneously ignites in a normal atmosphere without an external source of ignition.
Ignition Delay – It is defined as the time period between the start of fuel injection to the start of combustion. It could occur due to physical as well as chemical delay.
Physical delay is caused due to improper atomization of mixing of air fuel.
Chemical delay is caused due to delay in time to reach certain state so as to start the combustion. This is caused by time taken in pre-combustion reaction or time taken to reach certain temperature and pressure.
It is determined by using following equation
`Time_(Ignition Delay)=Time_(Intial Temperature+400K)`
Coding Approach –
- A gas object is created using Cantera Solution(‘gri.xml’) and required range is created along with it.
- Temperature, pressure and Mole Fraction of mixture is assigned using gas.TPX.
- An object r is created using gas object in IdealGasReactor, which specify the equation to be solved for the species such as species equation and energy equation. There is other reactor as well, which is used in specific conditions prescribed for it such s IdealGasConstantVolume reactor, constant volume reactor, constant pressure reactor etc.
- A reactor Network is setup using r as input and named sim.
- Attributes of Solution Array from Cantera is grouped as an instance of states with addition of Time in milli seconds and time in seconds.
- A for loop is set and value are calculated for specific Time period using Advance command.
- Appropriate equation are used to calculate Ignition delay and ignition time and are plotted as required.
Code: -
case 1: Constant temp = 1250 K Pressure = [1:5] atm
"""
Simulating auto ignition time for combustion of Methane
for constant T = 1250 and pressure = [1:5] atm
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
T = 1250
Pr = np.arange(1*101325,5.5*101325,0.5*101325)
gas = ct.Solution('gri30.xml')
temp_autoi = []
t_autoi = []
for q,p in enumerate(Pr):
gas.TPX = T,p,{'CH4':1, 'O2':2, 'N2':7.52}
r=ct.IdealGasReactor(gas)
sim = ct.ReactorNet([r])
states = ct.SolutionArray(gas, extra = ['t_ms','t'])
#help(r.thermo)
sim_t = 10000
time = 0
for i in range(sim_t):
time += 1e-3
sim.advance(time)
states.append(r.thermo.state, t_ms = time/1e-3, t = time)
#print('time(ms) ={:f}, temperature={:f},Pressure = {:f}'.format(time,r.T,r.thermo.P))
for k in range(sim_t):
if ((states.T[k]-T - 400) >= 0):
temp_autoi.append(states.T[k])
t_autoi.append(states.t_ms[k])
break
print(p,t_autoi[q])
patm = p/101325
plt.figure(1)
plt.plot(states.T, label = '%.1f atm' %patm)
plt.xlabel('No of time steps')
plt.ylabel('Auto Ignition Temperature')
plt.title('Auto Ignition Temperature Vs time-step')
plt.legend()
print(Pr,t_autoi,temp_autoi)
plt.figure(2)
plt.plot(Pr/101325,t_autoi,'*-')
plt.xlabel('Pressure (in atm)')
plt.ylabel('Ignition delay (in ms)')
plt.title('Ignition delay Vs Pressure')
for j in range(len(Pr)):
plt.text((Pr[j]/101325),t_autoi[j]+0.5,'({0:.0f},{1:.0f})'.format(Pr[j]/101325,t_autoi[j]), fontsize=8)
plt.grid(True)
plt.show()
Resut: -
Case 2:
Constant pressure = 5 atm temp = [950:1450] K
"""
Simulating auto ignition time for combustion of Methane
for constant pressure= 5 atm and Temp = [950:1450] K
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
p = 5*101325
temp = np.arange(950,1450,50)
gas = ct.Solution('gri30.xml')
temp_autoi = []
t_autoi = []
for q,Tp in enumerate(temp):
gas.TPX = Tp,p,{'CH4':1, 'O2':2, 'N2':7.52}
r=ct.IdealGasReactor(gas)
sim = ct.ReactorNet([r])
states = ct.SolutionArray(gas, extra = ['t_ms','t'])
#help(r.thermo)
sim_t = 10000
time = 0
for i in range(sim_t):
time += 1e-3
sim.advance(time)
states.append(r.thermo.state, t_ms = time/1e-3, t = time)
#print('time(ms) ={:f}, temperature={:f},Pressure = {:f}'.format(time,r.T,r.thermo.P))
for k in range(sim_t):
if ((states.T[k]-Tp - 400) >= 0):
temp_autoi.append(states.T[k])
t_autoi.append(states.t_ms[k])
break
print(Tp,t_autoi[q])
plt.figure(1)
plt.plot(states.T, label = '%.0f K' %Tp)
plt.xlabel('No of time steps')
plt.ylabel('Auto Ignition Temperature')
plt.title('Auto Ignition Temperature Vs time-step')
plt.legend()
print(temp,t_autoi,temp_autoi)
plt.figure(2)
plt.plot(temp,t_autoi,'*-')
plt.xlabel('Temperature (in K)')
plt.ylabel('Ignition delay (in ms)')
plt.title('Ignition delay Vs Temperature')
plt.grid(True)
for j in range(len(temp)):
plt.text(temp[j]-20,t_autoi[j]+10,'({0:.0f},{1:.0f})'.format(temp[j],t_autoi[j]), fontsize=8)
plt.show()
Result: -
Case 3: Plotting Molar Concerntration or [H2O,O2,OH] at pressure 5 atm , temp =[500K , 1000 K]
"""
Calculating Moler fraction for combustion of species = {H20,O2,OH}
for combustion of Methane at
constant pressure= 5 atm and Temp = [500,1000] K
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
p = 5*101325
temp = [500,1000]
gas = ct.Solution('gri30.xml')
for q,Tp in enumerate(temp):
gas.TPX = Tp,p,{'CH4':1, 'O2':2, 'N2':7.52}
r=ct.IdealGasReactor(gas)
sim = ct.ReactorNet([r])
states = ct.SolutionArray(gas, extra = ['t_ms','t'])
#help(r.thermo)
sim_t = 10000
time = 0
for i in range(sim_t):
time += 1e-3
sim.advance(time)
states.append(r.thermo.state, t_ms = time/1e-3, t = time)
plt.figure(q+1)
plt.suptitle('Molar Concerntration of species at %.0f K' %Tp)
plt.subplot(3,1,1)
plt.plot(states.t,states.X[:,gas.species_index('H2O')])
plt.ylabel('$H_2O$ Mole Fraction', fontsize = 10)
plt.subplot(3,1,2)
plt.plot(states.t,states.X[:,gas.species_index('O2')])
plt.ylabel('$O_2$ Mole Fraction', fontsize = 10)
plt.subplot(3,1,3)
plt.plot(states.t,states.X[:,gas.species_index('OH')])
plt.xlabel('time (sec)')
plt.ylabel('$OH$ Mole Fraction',fontsize = 10)
plt.tight_layout()
plt.show()
Result: -
Conclusion: -
- From case 1 - With increase In pressure at inlet Auto-Ignition temperture increcease while Ignition delay decreases.
- From case 2 - With increase In Temperature at inlet Auto-Ignition temperture increcease while Ignition delay decreases.
- From case 3 - As when temperature is 500 K auto ignition oes not happen and with pssing of time only few molecules of reactant reacts hence moler fraction of OH and H20 increses whie O2 remains lmost same, while in case of 1000K the Ignition delay is 174 milli second and Auto Ignition Temperature is 2898.86 K and hence after few sec the molar concerntration of H20 and OH increases as its on product Side while Reactant O2 decresases/consumed in the process.