Project

Auto igniton using Cantera

Aim:-

In this challenge, we will write code for calculating Autoignition time for methane under various conditions using Cantera.

Here we have further two challenges.

Case-1 :

Calculate the autoignition time for methane to below conditions

i)variation of Auto Ignition time of Methane with a constant pressure of 5 atm and temperature varying from 950K to 1450K.

ii)variation of Auto Ignition time of Methane with a constant temperature of 1250K and pressure varying from 1 to 5 atm.

Case-2 :

The rate of change of molar concentrations of the given elements \"H2O, O2, OH\".

Observe the behavior of graphs of

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

Case-1 :

i)variation of Auto Ignition time of Methane with a constant pressure of 5 atm and temperature varying from 950K to 1450K.

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\')

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)# Advancing the reactor w.r.t the time s=step

				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 the constant pressure of 5ATM and Temperature varying from 950k and 1450k

\"\"

In the above figure, there are two plots. the top plot shows the auto-ignition of Methane with five varying temperature which can be seen in the legend. the auto-ignition is occurring approximately in the range of 0 to 55 milliseconds for the given temperature range.

The bottom plots show the ignition delay with respect to the temperature values taken. We can clearly see the ignition delay is decreasing as the temperature increases. But in this plot, we observe that the ignition delay is decreasing way faster than when compared to pressure. this is obvious because as the temperature increases the auto-ignition is occurring very fast. this infers that ignition delay is sensitive to temperature.

ii)

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

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\')

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)# Advancing the reactor w.r.t the time s=step

				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_start = \' + str(P/101325) + \'[atm]\' for P in press])
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'Temperature [k]\')

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

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

Result:

Autoignition time plot of methane of constant temperature 1250k and pressure varying from 1 to 5 atm.

\"\"

In the above figure, there are two plots. the top plot shows the auto-ignition of Methane with five varying pressure which is seen in the legend. the auto-ignition is occurring approximately in the range of 0 to 25 milliseconds for the given temperature range.

The bottom plot shows the Ignition delay with respect to the pressure values taken. We can clearly see that the ignition delay is decreasing as the pressure increases. This infers that the Ignition delay is sensitive to pressure.

Inference:-

The following are the conclusions we have gathered from the above results:-

  • The ignition delay plot shows that the ignition delay is exponential.
  • Ignition delay is sensitive to both pressure and temperature showing that the combustion is occurring quickly when these parameters are increasing.
  • Ignition delay is more sensitive to temperature.

CASE - 2:

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 sec)

Observe and explain the behavior of graphs of

  • 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}
		# Reactor
		r = ct.IdealGasReactor(gas)
		# Reactor Network
		sim = ct.ReactorNet([r])

		#Initial Time
		time = 0.0

		#States of Reactor---> attribiutes of the reactor
		states = ct.SolutionArray(gas, extra = [\'t_ms\', \'t\'])


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

				# Advancing the reactor w.r.t then the time step
				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.grid(\'on\')
		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.grid(\'on\')
		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.grid(\'on\')
		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 the H2O mole fraction is increases and becomes stable as the autoignition time increase.
  • This is because H2O is the product formed in the Methane combustion reaction.
  • O2 mole fraction is a decrease and because of the stable as the autoignition time increases. This is because O2 is the reactant in the Methane combustion reaction.
  • OH, mole fraction also increases and becomes stable as the autoignition 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 does not take place because the auto-ignition temperature of methane is around 875k which is higher than the considered temperature.
  • We can see some variation in the mole fraction of H2O and OH molecules. this is because they are single bond molecules and hence required less temperature to break the bonds.
  • O2 is constant because it has double bonds and requires high energy to break the bonds.

From the above phenomena, we can observe the variation of molar concentration with respect to the auto-ignition 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.