Week 7 - Auto ignition using Cantera
Introduction: Solving for the ignition time/ignition delay for combustion of methane
Approach/Explanation: Solving in python using cantera,
Ignition temperature here is theortically considered here as the temperature during the combustion process when the initial temperature exceeds by 400K.
T_ignitiontemperature=T_Initial temperature+400k
Running the simulation for 10 seconds,
time step increment everytime=1e-3 ran for 10000 times ,i.e. 10 seconds
r=instance object for ideal gas reactor
sim=instance object for reactor network
states =instance object for solution array
Running the reactor for 10 sec but noting the time only till the moment where temperature is less than T+400k.
The code:
Variating initial temperatures and finding ignition delay:
#temperature part of assignment
import sys
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt
gas=ct.Solution('gri30.xml')
T_1=[]
ignition_time_1=[]
for T in range(950,1550,100):
P=5*101325
gas.TPX=T,P,{'CH4':1,'O2':2,'N2':7.52}
r=ct.IdealGasReactor(gas)
sim=ct.ReactorNet([r])
time=0
iter=1
states=ct.SolutionArray(gas,extra=['time_in_ms','t'])
for n in range(10000):
time +=1e-3
sim.advance(time)
states.append(r.thermo.state,time_in_ms=time,t=time)
k=max(states.T)
if k<T+400:
k_1=k
#print(k_1)
#print(time)
ignition_time=time
iter=iter+1
#print(time)
T_ignition=T+400
#print(T)
print(T_ignition)
#print(k_1)
print(ignition_time)
print(iter)
#print(states.T)
T_1.append(T)
ignition_time_1.append(ignition_time)
#plt.subplot(2,1,1)
plt.plot(T_1,ignition_time_1,'-',color='blue')
plt.xlim(950,1450)
plt.ylim(0,0.45)
plt.xlabel('Initial temperature')
plt.ylabel('Ignition delay')
plt.grid('on')
print('finish')
plt.show()
Observation:
Conclusion: As the initial temperature increases, the ignition delay i.e. the time taken to reach ignition lowers ,i.e the hotter the fuel mixture initially, the lesser the time taken for reaching ignition point.
Variation of ignition time for combustion of methane with pressure
Pressure variating with 1 atm to 5 atm,
Running the reactor for 10 sec and noting the time till temperature reaches value greater than 400 K.
The code:
#pressure part of assignment
import sys
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt
gas=ct.Solution('gri30.xml')
ignition_time_1=[]
p_1=[]
for P_atm in range(1,6,1):
T=1250
P=P_atm*101325
gas.TPX=T,P,{'CH4':1,'O2':2,'N2':7.52}
r=ct.IdealGasReactor(gas)
sim=ct.ReactorNet([r])
time=0
iter=1
states=ct.SolutionArray(gas,extra=['time_in_ms','t'])
for n in range(10000):
time +=1e-3
sim.advance(time)
states.append(r.thermo.state,time_in_ms=time,t=time)
k=max(states.T)
l=max(states.P)
if k<T+400:
k_1=k
#print(k_1)
#print(time)
ignition_time=time
iter=iter+1
#print(time)
T_ignition=T+400
#print(T)
print(P)
print(T_ignition)
#print(k_1)
print(ignition_time)
print(iter)
#print(states.T)
p_1.append(P_atm)
ignition_time_1.append(ignition_time)
plt.plot(p_1,ignition_time_1,'-',color='blue')
plt.xlim(1,5)
plt.ylim(0,0.025)
plt.xlabel('Initial Pressure')
plt.ylabel('Ignition delay')
plt.grid('on')
print('finish')
plt.show()
Observation:
Conclusion: As the initial pressure increases, the ignition temperature of the fuel also reduces,i.e. it gets ignited fast with the increment of pressure in the fuel mixture.
Change of concentration of moles of h20,O2 and H during the combustion in reactor
Initial temperature-1000k and pressure-5bar
Keeping the simulation time =10 seconds
time increment=1e-3
n=10000
Running advance method in reactor for time integration,
The code:
#normal code video
import sys
import numpy
import cantera as ct
import matplotlib.pyplot as plt
gas=ct.Solution('gri30.xml')
T_initial=1000
P=5*101325
w_1=[]
o_1=[]
h_1=[]
time_1=[]
gas.TPX=T_initial,P,{'CH4':1,'O2':2,'N2':7.52}
r=ct.IdealGasReactor(gas)
sim=ct.ReactorNet([r])
time=0
states=ct.SolutionArray(gas)
for n in range(10000):
time+=1e-3
sim.advance(time)
states.append(r.thermo.state)
water=states.X[:,gas.species_index('H2O')]
oxygen=states.X[:,gas.species_index('O2')]
hydrogen=states.X[:,gas.species_index('H')]
w=water[n]
o=oxygen[n]
h=hydrogen[n]
#printing the molar cncentrations
#print(k)
#print(hydrogen)
time_1.append(time)
w_1.append(w)
o_1.append(o)
h_1.append(h)
plt.subplot(3,1,1)
plt.plot(time_1,w_1,'-',color='red')
plt.ylim(1e-9,0.18)
plt.ylabel('conc. of h2o')
plt.xlabel('time')
plt.subplot(3,1,2)
plt.plot(time_1,o_1,'-',color='blue')
plt.ylim(0.012,0.193)
plt.xlabel('time')
plt.ylabel('conc. of o2')
plt.subplot(3,1,3)
plt.plot(time_1,h_1,'-',color='green')
plt.ylim(1e-13,0.0033)
plt.xlabel('time')
plt.ylabel('conc. of h')
print(water)
print(oxygen)
print(hydrogen)
print('finish')
#print(states.X[:,gas.species_index('H2O')])
plt.show()
Observation:
Conclusion: Concentration of oxygen decreases with time as it is on the reactant side and its concentration decreases with time, concentration of hydrogen and water increase with time as they are on the product side of the reaction and formed during the reaction and their concentration increases with time.
Change of concentration of moles of h20,O2 and H during the combustion in reactor
Initial temperature-500 and pressure-5bar
The code:
#normal code video
import sys
import numpy
import cantera as ct
import matplotlib.pyplot as plt
gas=ct.Solution('gri30.xml')
T_initial=500
P=5*101325
w_1=[]
o_1=[]
h_1=[]
time_1=[]
gas.TPX=T_initial,P,{'CH4':1,'O2':2,'N2':7.52}
r=ct.IdealGasReactor(gas)
sim=ct.ReactorNet([r])
time=0
states=ct.SolutionArray(gas)
for n in range(10000):
time+=1e-3
sim.advance(time)
states.append(r.thermo.state)
water=states.X[:,gas.species_index('H2O')]
oxygen=states.X[:,gas.species_index('O2')]
hydrogen=states.X[:,gas.species_index('H')]
w=water[n]
o=oxygen[n]
h=hydrogen[n]
#printing the molar cncentrations
#print(w)
#print(k)
#print(hydrogen)
time_1.append(time)
w_1.append(w)
o_1.append(o)
h_1.append(h)
plt.subplot(3,1,1)
plt.plot(time_1,w_1,'-',color='red')
plt.ylim(7e-24,1.6e-16)
plt.ylabel('conc. of h2o')
plt.xlabel('time')
plt.subplot(3,1,2)
plt.plot(time_1,o_1,'-',color='blue')
plt.ylim(0.1901140684410641,0.19011406844106465)
plt.xlabel('time')
plt.ylabel('conc. of o2')
plt.subplot(3,1,3)
plt.plot(time_1,h_1,'-',color='green')
plt.ylim(5.1e-35,5.8e-31)
plt.xlabel('time')
plt.ylabel('conc. of h')
#print(water)
#print(oxygen)
#print(hydrogen)
print('finish')
#print(states.X[:,gas.species_index('H2O')])
plt.show()
Observation:
Conclusion: The temp reduction from 1000k to 500 k keeping everything same showed that in observations that the concentration change within 10 seconds of the simulation is more prominent and stable for the higher temperature i.e. 1000k rather than 500k. Concentration of oxygen decreases with time as it is on the reactant side and its concentration decreases with time, concentration of hydrogen and water increase with time as they are on the product side of the reaction and formed during the reaction and their concentration increases with time.