All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM - To perfrom Zero-Dimensional Auto Ignition Using Cantera OBJECTIVES - To Simulate Auto ignition for methane with constant initial tempreature 1250K and varying initial pressure form 1 atm to 5 atm conditions. To Simulate Auto Ignition for methane with constant initial pressure of 5 atm and varying…
Amol Patel
updated on 23 Sep 2021
AIM - To perfrom Zero-Dimensional Auto Ignition Using Cantera
OBJECTIVES -
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 -
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 6: Conjugate Heat Transfer Simulation
AIM- To simulate a Conjugate Heat Transfer flow through a pipe, while the inlet Reynolds number should be 7000. To run the grid independance test on 3 grids and show that the outlet temperature converges to a particular value To observe the effect of various supercycle stage interval on the total simulation time.…
09 Nov 2022 06:55 AM IST
Week 7: Shock tube simulation project
AIM - To set up a transient shock tube simulation Plot the pressure and temperature history in the entire domain Plot the cell count as a function of time SHOCK TUBE- The shock tube is an instrument used to replicate and direct blast waves at a sensor or a model in order to simulate actual explosions…
07 Nov 2022 09:18 PM IST
Week 5: Prandtl Meyer Shock problem
AIM - 1. To understand what is a shock wave. 2. To understand the what are the different boundary conditions used for a shock flow problems. 3. To understand the effect of SGS parameter on shock location. 4. To simulate Prandalt Meyer Shcok Wave. OBJECTIVE - Que 1. What is Shock Wave? A shock wave or shock,…
01 Nov 2022 06:36 PM IST
Week 4.2: Project - Transient simulation of flow over a throttle body
AIM - Transient simulation of flow over a throttle body. OBJECTIVE - Setup and run transient state simulation for flow over a throttle body. Post process the results and show pressure and velocity contours. Show the mesh (i.e surface with edges) Show the plots for pressure, velocity, mass flow rate and total…
12 Feb 2022 07:08 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.