Challenge

Week 7 - Auto ignition using Cantera

AIM - To perfrom Zero-Dimensional Auto Ignition Using Cantera

OBJECTIVES -

  1. To Simulate Auto ignition for methane with constant initial tempreature 1250K and varying initial pressure form 1 atm to 5 atm conditions.
  2. To Simulate Auto Ignition for methane with constant initial pressure of 5 atm and varying initial temperature from 950K to 1450K conditions.
  3. To Simulate Auto Ignition for methane with temperature 1000K and 500K and pressure 5 Bar and plot the change in molar concentration for the species 'H2O' , 'O2' , 'OH'.

THEORY -

Ignition Delay :

Ignition delay is the time required by the fuel to auto ignite at a particular state. Mostly fuel auto ignite at higher temperture and pressure values. Generally ignition delay is in the order of milli-seconds. but if the temperature is vary high above 1400 or 1500 K the delay can be less than a milli-second as well.

Using the cantera tool we can simulate the 0-Dimensional Auto Ignition. The Reactor Class that helps us to perform this kind of simulations and also the ReactorNet class will be used to advance the state of the Reactor at each time step.

we have 'advance' method that help us advance the state of the ReactorNet to a given time value and we can use this advance method in a for loop to perfrom simulations untill our desired run time is reached.

To Simulate the auto ignition for methane we will be using 'gri30.xml' file to create the gas class as an instance of solutions class. Then we will set the appropiate value for the initial temperature and initial pressures, then we will create the gas intstance and the Reactor and ReactorNet instances later on. Next we will take a time jump value of 1e-3 for the first simulation and using the adavnce method we can simulate the ReactorNet for that time step jump. we will be using a for loop to run the simulations untill our desired run time is reached. also we will be storing the state at each advacement using the SolutionArray that can store the entire state of the ReactorNet and we dont have to store each attribute seperately. Finally we will be plotting the Temperature for the entire run time, this will help us to know the ignition time required for different initial pressures values. Also we will be plotting the trend for the change in the ignition time with the initial pressures.

CODE -

Part 1 :

The code for the simulation for the auto ignition of methane with constant initial temperature and varying initial pressure is shown below

"""
	Code to calculate AUTO IGNITION time for Methane at
 	Part 1: constant temp 1250K and pressure from  1 to 5 atm
 	
"""
import numpy as np
import matplotlib.pyplot as plt
import cantera as ct


T = 1250 # initial temp
P = [ct.one_atm*1,ct.one_atm*2,ct.one_atm*3,ct.one_atm*4,ct.one_atm*5] # pressure 
X = {'CH4':1,'O2':2,'N2':7.52} # species dict for the reaction

# create empty array for ignition delay
ignition_delay = []
# creating empty array to store the presure in atm
P_in_atm = []

for j in range(len(P)):

	# creating gas instanct using the Solution class
	gas = ct.Solution("gri30.cti")
	# calculating pressure in atm
	P_in_atm.append(P[j]/ct.one_atm)  
	# giving inputs to the gas object
	gas.TPX = T,P[j],X
	

	# creating instance of the Reactor using Ideal gas reactor  
	r = ct.IdealGasReactor(gas) 
	
	# creating instance of the reactor network
	sim = ct.ReactorNet([r])

	# start time 
	time = 0.0

	#array to store the states after each advancement 
	states = ct.SolutionArray(gas,extra = 'time_in_ms')

	# empty time array
	time_array = []

	# time loop
	for n in range(10000):# 10sec = 10* 1000ms = 10000ms
		# using the time step value of 1e-3 sec
		time = time + 1e-3
		# simulating using the advance method
		sim.advance(time)
		# storing the state at each time step
		states.append(r.thermo.state,time_in_ms = time*1e3)

		# to find the values of time when the temp is lower than the value of (initial temp + 400) 
		if states.T[n] <= (T + 400):
			# stroring this values in the empty time array
			time_array.append(states.time_in_ms[n])
		
	# getting the ignition value as the maximum form the time value in the time array  		
	ignition_delay.append(np.max(time_array))

	# trend for the temperature throught out the simulation
	plt.figure(0)
	plt.plot(states.time_in_ms,states.T)

# ignition delay output array 
print(ignition_delay)

plt.figure(0)
plt.xlabel('time in milli-seconds')
plt.ylabel('temperature during the ignition')
plt.grid('on')
plt.legend(['1 atm','2 atm','3 atm','4 atm','5 atm'])
plt.title('igniton at various pressure with inital temp = 1250 K')

plt.figure(1)
plt.plot(P_in_atm,ignition_delay,'-o')
plt.xlabel('pressure in atm')
plt.ylabel('ignition delay')
plt.grid('on')
plt.title('igniton delay with at various pressure with inital temp = 1250 K')

plt.show()

the output for this code is as follows

if we zoom in the range of 0-40 ms for the above plot we get to see the more clearly

Second plot for this simulation is the ignition delay over the initial pressure

the output window shows the array for the ignition delay values

For the above images we can see that as the initial pressure is increased the ignition delay reduces.

Part 2:

The code for the auto ignition simulation of methane with constant initial pressure and varying initial temperature values is shown below also here we have had to use the time step value of 1e-4 rather tha 1e-3 is to capture the ignition time for the higher intial temperature case of 1450K. We will be running this code for run time of 1 second only as in this period we can see that all the cases have ignited properly and further simulation for longer run time will be adding to the computational cost and time.

"""
	Code to calculate AUTO IGNITION time for Methane at
 	2. constant pressure 5 atm and temp 950K to 1450K

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


T = [950,1050,1150,1250,1350,1450] #  intial temp
P = 5*ct.one_atm # pressure 
X = {'CH4':1,'O2':2,'N2':7.52} # species dict

# create empty array for ignition delay
ignition_delay = []

for j in range(len(T)):


	# creating gas instanct using the Solution class
	gas = ct.Solution("gri30.cti") 
	# giving inputs to the gas object
	gas.TPX = T[j],P,X
	

	# creating instance of the Reactor using Ideal gas reactor  
	r = ct.IdealGasReactor(gas) 
	
	# creating instance of the reactor network
	sim = ct.ReactorNet([r])

	# start time 
	time = 0.0

	#array to store the states
	states = ct.SolutionArray(gas,extra = 'time_in_ms')

	# creating empty time array  
	time_array = []

	# time loop
	for n in range(10000):# run time 1 sec
		# using time step value of 1e-4 sec
		time = time + 1e-4 
		# simulating using advance method
		sim.advance(time)
		# storing the state at each time step
		states.append(r.thermo.state,time_in_ms = time*1e3)

		# to find the time when temp is lower than value of (initial temp + 400K)
		if states.T[n] <= (T[j] + 400):
			# storing this value in the time array
			time_array.append(states.time_in_ms[n])
		
	# storing the maximum of the time values as the ignition delay for each case
	ignition_delay.append(np.max(time_array))


	# trend for temperature throughtout the simulation
	plt.figure(0)
	plt.plot(states.time_in_ms,states.T)

# ignition delay output array
print(ignition_delay)

plt.figure(0)
plt.xlabel('time(milli-seconds)')
plt.ylabel('temperature during the ignition(K)')
plt.grid('on')
plt.legend([str(T[0])+'K',str(T[1])+'K',str(T[2])+'K',str(T[3])+'K',str(T[4])+'K',str(T[5])+'K'] )
plt.title('igniton at various temperature with inital pressure = 5 atm')


plt.figure(1)
plt.plot(T,ignition_delay,'-o')
plt.xlabel('Temperature (K)')
plt.ylabel('ignition delay(milli-seconds)')
plt.grid('on')
plt.title('igniton delay with at various temperature with inital preassure = 5 atm')

plt.show()

the output for this simualtion are given below

zooming in to see the trend for the 1350K and 1450K cases

plot for the ignition delay with varying initial temperature

Output window show the array for the ignition delay values

from the above plots we can observe that as the initial temperature is increased the ignition delay reduced and as the temperature is higher than 1450 K the ignition delay is even less than one milli-second.

Part 3:

The code for the auto ignition simulation of methane with constant initial pressure and for intial temperature values of 500K, 100K and 1500K is shown below .Here we be plotting the varition in concentration for the species 'H2O','O2,'OH' in the form of mole fractions throught the simulation.

"""
	Code to calculate AUTO IGNITION time for Methane at
 	5 bar pressure and initial temperatures 500K,1000K and 1500K
 	also we have to plot the concentration for Species H2O,O2,OH

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


T = [500,1000,1500] # temp
P = 5*1e5 # pressure in bar 
X = {'CH4':1,'O2':2,'N2':7.52} # species dict

# create empty array for ignition delay
ignition_delay = []

# to preform simulation for each value of Inital Temperature
for j in range(len(T)):

	# creating gas instanct using the Solution class
	gas = ct.Solution("gri30.cti") 
	# giving inputs to the gas object
	gas.TPX = T[j],P,X
	
	
	# creating instance of the Reactor using Ideal gas reactor  
	r = ct.IdealGasReactor(gas) 
	
	# creating instance of the reactor network
	sim = ct.ReactorNet([r])

	# start time 
	time = 0.0

	#array to store the states
	states = ct.SolutionArray(gas,extra = 'time_in_ms')

	# empty time array
	time_array = []

	# time loop
	for n in range(10000): # keeping run time as 1 sec
		# using time step value of 1e-4 seconds
		time = time + 1e-4
		# simulating using the advance method
		sim.advance(time)
		#stroring the state after each time step
		states.append(r.thermo.state,time_in_ms = time*1e3)

		# to find the values of time when the temp is lower than the value of (initial temp + 400) 
		if states.T[n] <= (T[j] + 400):
			# stroring this values in the empty time array
			time_array.append(states.time_in_ms[n])
		
	# getting the ignition value as the maximum form the time value in the time array  		
	ignition_delay.append(np.max(time_array))

	# plotting the temperature for each state
	plt.figure(0)
	plt.plot(states.time_in_ms,states.T)
	# plotting the concentration of various species f
	plt.figure(2)
	plt.plot(states.time_in_ms,states.X[:,gas.species_index('H2O')])
	plt.figure(3)
	plt.plot(states.time_in_ms,states.X[:,gas.species_index('O2')])
	plt.figure(4)
	plt.plot(states.time_in_ms,states.X[:,gas.species_index('OH')])
	

# ignition delay output array
print(ignition_delay)


plt.figure(0)
plt.xlabel('time in milli-seconds')
plt.ylabel('temperature during the ignition')
plt.grid('on')
plt.legend([str(T[0])+'K',str(T[1])+'K',str(T[2])+'K'])
plt.title('igniton at various temperature with inital pressure = 1 bar')

plt.figure(1)
plt.plot(T,ignition_delay,'-o')
plt.xlabel('Temperature(K)')
plt.ylabel('ignition delay(milli-seconds)')
plt.grid('on')
plt.title('igniton delay with at various temperature with inital preassure = 5 bar')

plt.figure(2)
plt.xlabel('time(milli-seconds)')
plt.ylabel('mole fraction of H2O')
plt.title('concentration of H2O ')
plt.legend([str(T[0])+'K',str(T[1])+'K',str(T[2])+'K'])
plt.grid('on')

plt.figure(3)
plt.xlabel('time(milli-seconds)')
plt.ylabel('mole fraction of O2')
plt.title('concentration of O2 ')
plt.legend([str(T[0])+'K',str(T[1])+'K',str(T[2])+'K'])
plt.grid('on')

plt.figure(4)
plt.xlabel('time(milli-seconds)')
plt.ylabel('mole fraction of OH')
plt.title('concentration of OH ')
plt.legend([str(T[0])+'K',str(T[1])+'K',str(T[2])+'K'])
plt.grid('on')


plt.show()

The output plots for this simulation are given below

plot for the trend of varying initial temp

plot for the concentration of species 'H2O'

plot for the concentration of species 'O2'

plot for the concentration of species 'OH'

from the above plots we can see the nature of the ignition delay is similar to the case in Part 2 . here we notice that the ignition for the initial temperature value of 500K does not take place and so the temperature is constant also increasing the run time will have no effect beacuse the ignition for methane takes place above 800K .

here we get the time for the 1st case as 999.999 milli-seconds but actually ignition doesnt takes place do we do not consider that value.

The concentration of the species 'H2O' increases after ignition as H2O is formed during combusiton and it is higher in concentration for 1000K case than for 1500K

The concentration of the species 'O2' decrease after ingition as oxygen is consumed during the combustion and the concentration is lower for the 1000K rather than the 1500K

The concentration of the species 'OH' increase during the ignition due to it formation ,also we can see that concentration of OH is higher at the moment when ignition takes place but after that the concentration again drops by some value. Here the concentration of OH is higher for initial temp 1500K

CONCLUSION -

  1. The ignition delay time is the time required by a fuel for auto ignition at a particular state.
  2. The ignition delay time reduces as the initial presure of the system is increased
  3. The ignition delay time reduces as the initial temperature of the system is increased
  4. The concentration of the species varies when ignition takes place and for the reactants such as 'O2' the concentration decreases and for the products such as 'H2O' the concentration increases.
  5. There are also some intermidiate species like 'OH' for which the concentration increases at the moment of ignition but then as they are consumed their concentration decreases.
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.