Project

Auto igniton using Cantera

Aim:

In this challenge we will write code for calculating Auto Ignition time for Methane under various conditions using Cantera.

Here we have further two challanges.

A)

Calculate the auto ignition time for methane for below conditions

i)Variation of auto ignition time under constant temperature i.e 1250K, while pressure is varying from 1 to 5 atm.

ii)Variation of auto ignition time under constant pressure .e 5atm, while temperature is varying from 950K to 1450K.

B)

Print the rate of change of molar concentrations of elements OH,H2O,O2.

Observe the behaviour of graphs of

  • When Temperature is 1000K and pressure 5 bar
  • When Temperature is 500K and pressure 5 bar

Coding:

A)

Here we are going to simulate and show the variation of auto ignition of methane with respect to given temperature and pressure using Cantera.

We are considering an ideal gas reactor and its corresponding reactor network. Simulation time is 10 sec.

i)

In this case we are considering the constant pressure of 5ATM and temperature is varying between 950K and 1450K.

import sys
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt

gas=ct.Solution(\'gri30.xml\')
T_start=950
T_end=1450
P=5*101325

sim_time=10*1000

n=5
temp = np.linspace(T_start,T_end,n)
Ignition_delay=[]

for T in temp:
	gas.TPX=T,P,{\'CH4\':1, \'O2\':2, \'N2\':7.52}

	r=ct.IdealGasReactor(gas)
	sim=ct.ReactorNet([r])

	time=0.0

	states=ct.SolutionArray(gas, extra=[\'t_ms\', \'t\'])

	T_old = T

	i=1
	for i in range (sim_time+1):
		time += 1e-03

		sim.advance(time)

		states.append(r.thermo.state, t_ms = time*1e3, t=time)

		T_new=states.T
		T_new=T_new[i-1]

		if ((T_new-T_old)>=400):

			Ignition_delay.append(time)

		T_old=states.T
		T_old=T_old[i-1]

	plt.subplot(2,1,1)
	plt.plot(states.t_ms, states.T)


plt.legend([\'T_initial = \'+str(T)+\'[K]\' for T in temp ])
plt.xlabel(\'Time[ms]\')
plt.ylabel(\'Temperature[K]\')

plt.subplot(2,1,2)
plt.plot(temp, Ignition_delay, \'-o\')  
plt.xlabel(\'Initial Temperature[K]\')
plt.ylabel(\'Ignition_delay[ms]\')

print(\'Ignition_delay = \', Ignition_delay)
print(\'Temperature= \', temp)
plt.show()

Result:

Auto Ignition plot of Methane with constant pressure of 5 ATM and temperature varying from 950K and 1450K.

From the above figure we can conclude that Ignition time decreases as the initial temperature increases.

ii)

In this case we are considering the constant temperature of 1250K and pressure varying from 1 to 5 ATM.

import sys
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt

gas=ct.Solution(\'gri30.xml\')
T=1250
P_start=101325
P_end=5*101325

sim_time=10*1000

n=5
press = np.linspace(P_start,P_end,n)
Ignition_delay=[]

for P in press:
	gas.TPX=T,P,{\'CH4\':1, \'O2\':2, \'N2\':7.52}

	r=ct.IdealGasReactor(gas)
	sim=ct.ReactorNet([r])

	time=0.0

	states=ct.SolutionArray(gas, extra=[\'t_ms\', \'t\'])

	T_old = T

	i=1
	for i in range (sim_time+1):
		time += 1e-03

		sim.advance(time)

		states.append(r.thermo.state, t_ms = time*1e3, t=time)

		T_new=states.T
		T_new=T_new[i-1]

		if ((T_new-T_old)>=400):

			Ignition_delay.append(time)

		T_old=states.T
		T_old=T_old[i-1]

	plt.subplot(2,1,1)
	plt.plot(states.t_ms, states.T)


plt.legend([\'P_initial = \'+str(P/101325)+\'[atm]\' for P in press ])
plt.xlabel(\'Time[ms]\')
plt.ylabel(\'Temperature[K]\')

plt.subplot(2,1,2)
plt.plot(temp, Ignition_delay, \'-o\')  
plt.xlabel(\'Initial Pressure[atm]\')
plt.ylabel(\'Ignition_delay[ms]\')

print(\'Ignition_delay = \', Ignition_delay)
print(\'Pressure= \', press)
plt.show()

Result:

Auto ignition time plot of Merhan of constant temperature 1250K and pressure varying from 1 to 5 atm.

B)

Here we observe and print the rate of change of molar concentrations of the given elements \"H2O, O2, OH\" with respect to the time, (simulation time = 10 secs)

and explain the behavior of the graph for 2 cases,

  • When Temperature is 1000K and pressure 5 bar
  • When Temperature is 500K and pressure 5 bar

Python code for the above case:

import sys
import numpy as np
import cantera as ct
import matplotlib.pyplot as plt

gas=ct.Solution(\'gri30.xml\')

temp=[500,1000]
P=5*101325

sim_time=10*1000

species = {\'CH4\':1, \'O2\':2, \'N2\':7.52}

for T in temp:
	gas.TPX=T,P,{\'CH4\':1, \'O2\':2, \'N2\':7.52}

	r=ct.IdealGasReactor(gas)
	sim=ct.ReactorNet([r])

	time=0.0

	states=ct.SolutionArray(gas, extra=[\'t_ms\', \'t\'])


	i=1
	for i in range (sim_time+1):
		time += 1e-03

		sim.advance(time)

		states.append(r.thermo.state, t_ms = time*1e3, t=time)


	plt.subplot(3,1,1)
	plt.plot(states.t_ms, states.X[:,gas.species_index(\'H2O\')])
	plt.xlabel(\'Time[ms]\')
	plt.ylabel(\'H2O mole fraction\')

	plt.subplot(3,1,2)
	plt.plot(states.t_ms, states.X[:,gas.species_index(\'O2\')])
	plt.xlabel(\'Time[ms]\')
	plt.ylabel(\'O2 mole fraction\')

	plt.subplot(3,1,3)
	plt.plot(states.t_ms, states.X[:,gas.species_index(\'OH\')])
	plt.xlabel(\'Time[ms]\')
	plt.ylabel(\'OH mole fraction\')

	plt.show()

Results:

  • When Temperature is 1000K and pressure 5 bar

From the figure we can conclude that H2O mole fraction is increases and becomes stable as the auto ignition time increases. This is because H2O is the product formed in the Methane combustion reaction. O2 mole fraction is decreases and becomes stable as the auto ignition time increases. This is because O2 is the reactant in the Methane combustion reaction. OH mole fraction is also increases and becomes stable as the auto ignition time increases. This is because OH is also the product formed in the Methane combustion reaction.

  • When Temperature is 500K and pressure 5 bar

Initially at 500K combustion of methane doesnot take place because auto ignition temperature of methane is around 875K which is higher than the considered temperature. Still we can see some variation in mole fraction of H2O and OH molecules. This is because they are single bond molecules and hence required less temperature to break the bonds. But O2 is constant because it has double bonds and require high energy to break the bonds.

From the above phenomena we can observe the variation of molar concentration with respect to the auto iginition temperature.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.