Project

Autoignition delay calculation using Cantera

The aim of this project is to determine the effect of initial temperature and pressure in the ignition delay of the methane combustion process. A constant volume reactor and corresponding network objects are created in Cantera and the combustion process is simulated.

Objectives:

  1. Auto Ignition Delay for Methane Combustion.

a) By varying pressure from 1 atm to 5 atm while keeping the temperature at 1250K.

b) By varying temperature from 950K to 1450K while keeping the pressure at 5 atm.

2. To determine the change in molar concentration of H2O, O2, and OH.

a) When Temperature is 1000K and pressure 5 atm.

b) When Temperature is 500K and pressure 5 atm.

At first, a \'gas\' instance of Solution class is generated then it is passed through Constant Volume Reactor class and a network object is used to determine the thermodynamic states by passing the reactor through the Network object.

A function is created which is passed through initial temperature & pressure, species dictionary, integral time interval, and total integration time.

def cv_combust_ignition_delay(T, P, species_dict, time_integ_interval, total_integ_time):      # T in K, P in atm, Species {}, time is seconds

	import cantera as ct

	gas = ct.Solution(\'gri30.xml\')    # creating gas instance of Solution class

	gas.TPX = T, P*101325, species_dict      # stating the initial state of gas

	r =ct.IdealGasReactor(gas)        # Creating the Reactor Object

	sim = ct.ReactorNet([r])          # Creating the Network Object

	time = 0.0                        # initializing time

	states = ct.SolutionArray(gas,extra= [\'time_in_ms\',\'t\'])   # array to record states of gas at different time

	for n in range (round(total_integ_time/time_integ_interval)):
		time+=time_integ_interval                              # time interval for integration, not the time step size it is selected default from Cantera
		sim.advance(time)
		states.append(r.thermo.state, time_in_ms = time*1e3, t= time)

	return states

The code is written to determine the ignition delay at a constant temperature of 1250K and varying the pressure from 1 atm to 5 atm. Here total integration time is taken as 25 ms.

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


P_initial = 1
P_dP =1
P_final=5+P_dP

P_lin = np.arange(P_initial,P_final,P_dP)
len_P = len(P_lin)

T=1250
ignition_delay=[]
t_new1=[]


for i in range (0,len_P):

	b= cv_combust_ignition_delay(T, P_lin[i], {\'CH4\':1,\'O2\':2,\'N2\':7.52},1e-5,25e-3)
	plt.figure(1)
	plt.plot(b.time_in_ms,b.T)
	plt.figure(2)
	plt.plot(b.time_in_ms,b.P/101325)

	T_new=b.T
	t_new = b.time_in_ms

	check=0

	for i in range(np.size(T_new)):
		t_error = T_new[i] - T -400

		if (t_error >0 and check==0):
			T_1 = T_new[i] 
			time1 = t_new[i]
			t_new1.append(time1)
			check=check+1

# Data Visualization
plot1 =plt.figure(1)
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'Temperature [K]\')
legends = [\'P_initial = \' + str(P) + \'[atm]\' for P in P_lin]
plt.legend(legends)
plt.title(\'Auto Ignition Time for Methane\')

plot2 =plt.figure(2)
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'Pressure [atm]\')
#legends = [\'P_initial = \' + str(P) + \'[atm]\' for P in P_lin]
plt.legend(legends)
plt.title(\'Auto Ignition Time for Methane\')


plot3 =plt.figure(3)
plt.plot(P_lin, t_new1,\'-o\')
plt.xlabel(\'Pressure [atm]\')
plt.ylabel(\'Ignition Delay [ms]\')
plt.title(\'Ignition Delay at Constant Initial Pressure & 1250K\')
for x,y in zip(P_lin, t_new1):

    label = \"{:.2f}\".format(y)

    plt.annotate(label, # this is the text
                 (x,y), # this is the point to label
                 textcoords=\"offset points\", # how to position the text
                 xytext=(0,10), # distance from text to points (x,y)
                 ha=\'left\')

plt.show()

The code is written to determine the ignition delay at a constant pressure of 5 atm and varying the temperature from 950K to 1450K. Here total integration time is taken as 500 ms.

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


T_initial = 950
T_dT =100
T_final=1450+T_dT

T_lin = np.arange(T_initial,T_final,T_dT)
len_T = len(T_lin)

P=5
ignition_delay=[]
#t_new1=[]
t_new1=np.array(np.zeros(np.size(T_lin)))


for i in range (0,len_T):

	b= cv_combust_ignition_delay(T_lin[i], P, {\'CH4\':1,\'O2\':2,\'N2\':7.52},1e-5,500e-3)
	plt.figure(1)
	plt.plot(b.time_in_ms,b.T)
	plt.figure(2)
	plt.plot(b.time_in_ms,b.P/101325)

	T_new=b.T
	t_new = b.time_in_ms

	check=0

	for j in range(np.size(T_new)):
		t_error = T_new[j] - T_lin[i] -400

		if (t_error >0 and check==0):
			T_1 = T_new[j] 
			time1 = t_new[j]
			t_new1[i]=time1
			#t_new1.append(time1)
			check=check+1

		
print(t_new1)
print(T_lin)

# Data Visualization
plot1 =plt.figure(1)
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'Temperature [K]\')
legends = [\'T_initial = \' + str(T) + \'[K]\' for T in T_lin]
plt.legend(legends)
plt.title(\'Auto Ignition Time for Methane\')

plot2 =plt.figure(2)
plt.xlabel(\'Time [ms]\')
plt.ylabel(\'Pressure [atm]\')
#legends = [\'P_initial = \' + str(P) + \'[atm]\' for P in P_lin]
plt.legend(legends)
plt.title(\'Auto Ignition Time for Methane\')


plot3 =plt.figure(3)
plt.plot(T_lin, t_new1,\'-o\')
plt.xlabel(\'Temperature [K]\')
plt.ylabel(\'Ignition Delay [ms]\')
plt.title(\'Ignition Delay at Constant Initial Temperature & 5 atm.\')
for x,y in zip(T_lin, t_new1):

    label = \"{:.2f}\".format(y)

    plt.annotate(label, # this is the text
                 (x,y), # this is the point to label
                 textcoords=\"offset points\", # how to position the text
                 xytext=(0,10), # distance from text to points (x,y)
                 ha=\'left\')

plt.show()

Results:

At Constant Initial Temperature of 1250K:

Variation of Temperature w.r.t time

Variation of Pressure w.r.t time

Ignition Delay wrt varying Pressure

Upon increasing the pressure, ignition delay time reduces. With the increase in pressure, the density within the chamber increases, and the temperature of the mixture increases rapidly and leads to faster burning of fuel.

At Constant Initial Pressure of 5 atm:

Variation of Temperature w.r.t time

Variation of Pressure w.r.t time

Ignition Delay wrt varying Temperature

Upon increasing the temperature, ignition delay time reduces. With the increase in temperature, the chemical reaction time decreases and leads to the reduction of ignition delay time.

Rate of change of molar concentration:

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

b= cv_combust_ignition_delay(500, 5, {\'CH4\':1,\'O2\':2,\'N2\':7.52},1e-3,10)
c= cv_combust_ignition_delay(1000, 5, {\'CH4\':1,\'O2\':2,\'N2\':7.52},1e-3,10)


# Data Visualisation
# plotting for H2O
plt.figure(1)
plt.subplot(1,2,1)
plt.plot(c.time_in_ms,c(\'H2O\').X, label=\'@1000K\')
plt.xlabel(\'Time (s)\')
plt.ylabel(\'Species Concentration [H2O]\')
plt.legend()
plt.subplot(1,2,2)
plt.plot(b.time_in_ms,b(\'H2O\').X, label=\'@500K\')
plt.xlabel(\'Time (s)\')
plt.ylabel(\'Species Concentration [H2O]\')
plt.legend()
plt.tight_layout()


# plotting for O2
plt.figure(2)
plt.subplot(1,2,1)
plt.plot(c.time_in_ms,c(\'O2\').X, label=\'@1000K\')
plt.xlabel(\'Time (s)\')
plt.ylabel(\'Species Concentration [O2]\')
plt.legend()
plt.subplot(1,2,2)
plt.plot(b.time_in_ms,b(\'O2\').X, label=\'@500K\')
plt.xlabel(\'Time (s)\')
plt.ylabel(\'Species Concentration [O2]\')
plt.legend()
plt.tight_layout()


# plotting for OH
plt.figure(3)
plt.subplot(1,2,1)
plt.plot(c.time_in_ms,c(\'OH\').X, label=\'@1000K\')
plt.xlabel(\'Time (s)\')
plt.ylabel(\'Species Concentration [OH]\')
plt.legend()
plt.subplot(1,2,2)
plt.plot(b.time_in_ms,b(\'OH\').X, label=\'@500K\')
plt.xlabel(\'Time (s)\')
plt.ylabel(\'Species Concentration [OH]\')
plt.legend()
plt.tight_layout()
plt.show()

Concentration of H2O:

Concentration of O2:

Concentration of OH:

Above are the graphs representing the molar concentration of H2O, O2, and OH at 500K and 1000K & 5 atm.

At 500K methane does not combust because the autoignition temperature of methane is around 875K which is higher than the 500K. Still, we can see some variation in the mole fractions of H2O and OH. This is because they have single bonds and require less temperature to break the bonds. But, O2 is constant because it has a double bond and requires high energy to break the bonds. And, the concentration of very low order at 500K is observed.

At 1000K H2O mole fraction increases and becomes stable due to the combustion i.e., the formation of H2O is evident due to combustion. Concentration of O2 decreases as it is the reactant and OH is formed on the products side. Hence, the concentration of OH increases with time.

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.