Challenge

Week 9 - Senstivity Analysis Assignment

Aim :- To perform sensitivity analysis for Auto-Ignition in combustion using Cantera.

Introduction :-

Combustion in engines with a practical fuel is very complex and is commonly described by a detailed mechanism which may involve dozens or even hundreds of reactions. However, the detailed mechanism is not well understood especially for reaction rate coefficients which may be uncertain by one or more orders of magnitude. For many gas-phase elementary reactions, reaction rates have uncertainty of 10% to 30%. The uncertainties in the rate coefficients will significantly affect the production rate of species and ultimately affect the combustion behaviors such as temperature profile, ignition delay time, and laminar flame speed. In order to investigate the detailed mechanism with large uncertainties in the reaction rate coefficients, sensitivity analysis is employed to study how the uncertainties in the outputs can be apportioned to different sources of uncertainties in its inputs. This investigation can help researchers to determine the important reactions and reaction pathways for practical fuels and model detailed mechanism.

Theory :-

Sensitivity analysis:-

Sensitivity analysis is a management tool that helps in determining how different values of an independent variable can affect a particular dependent variable. It can be useful in wide range of subjects apart from finance, such as engineering, geography, biology, etc.

When sensitivity analysis is done, each independent & dependent variable is studied in-depth. Their movements are studied and how independent variable affects dependent variable is also studied. In the pursuit of understanding the relationship between the variables, the cause and effect reaction between the two establishes. Such in-depth analysis will bring more accurate future forecast.

For example,

Effect of reaction 1 rate on the temperature or species concentration.

Here in this assignment , We have tried our best to calculate the sensitivity analysis of the reactions so that we can predict out which reaction is slowing down the ignition delay and which one is enhancing the ignition delay in whole reaction mechanism.

Here , We have calculated the sensitive analysis of reaction at preassumed temperature of 1500K and pressure 1 atm. Also, fuel and oxidiser composition have been maintained at stiochiometric equivalence ratio. The analysis have been done upto 2ms(milisecond) where 10 most reactive reaction have been recorded.

Application:-

1. It have wide application in chemical kinetics where it can be used to predict out the reaction rate of any reaction which helps us in determining the production rate of any specie.

2. Also, it has application in Auto-ignition, where a lot of reactions takes place during ignition. So it can predict the reaction which can slow down the reaction or enhance the reaction reflecting back in the ignition delay.

"""
  Program to calculate 10 most sensitive reactions on the basis of temperature from the list of GRI mechanism reaction file.

  Plot on molar concentrations of 'CH4','OH' and 'H' with respect to the Ignition delay(ms).

  Plot on Temperature with respect to Ignition delay(ms).

"""

import sys                          # to create reactor network system .
import cantera as ct                # to create reactor.
import numpy as np                  # to perform numerical calculations.
import matplotlib.pyplot as plt     # for plotting desired results.

gas=ct.Solution('gri30.xml')        # intiating object from solution class of GRI reaction mechanism file.
T=1500                              # temperature
P=ct.one_atm                        # pressure
  
gas.TPX=T,P,{'CH4':1,'O2':2,'N2':1}   
r=ct.IdealGasConstPressureReactor(gas,name='R1')           # creating constant pressure reactor.
sim=ct.ReactorNet([r])                                     # creating reactor system.    

n=gas.n_reactions                 # calculates number of reactions from object class "gas" from GRI mechanism file.

N=10                              # paramter to define number of most senstive reactions.

snst_para=n*[0]                   # variable to store sensitivity value.

for i in range(324):
	r.add_sensitivity_reaction(i)

sim.rtol=1e-6                    # defines relative tolerance. 
sim.atol=1e-15                   # defines absolute tolerance.
 
sim.rtol_sensitivity=1e-6        # defines relative tolerance for sensitivity.
sim.atol_sensitivity=1e-6        # defines absolute tolerance for sensitivity.

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

s_m=N*[0]                       # to store number of maximum senstive reaction orderwise.
react_name=[]                   # to store reaction mechanism name.
react_id=N*[0]

for t in np.arange(0,2e-3,2e-6):
	sim.advance(t)

	for j in range(n-1):
		snst_para[j]= sim.sensitivity(1,j)

	states.append(r.thermo.state,time_in_ms=1000*t,t=t)

print(N,"most sensitive reactions are:")
print("  Senstivity value",'|',"Reaction ID",'|',"Reaction Name")

for m in range(N):
	maximum=np.max(snst_para)              # stores maximum sensitive value.
	minimum=np.min(snst_para)              # stores minimum sensitive value.

	if np.abs(maximum)>=np.abs(minimum):    # condition if sensitivity of forward reaction is greater.
		s_m[m]=maximum
		react_id[m]=snst_para.index(maximum)
		react_name.append(sim.sensitivity_parameter_name(react_id[m]))
		snst_para.remove(maximum)

	if np.abs(maximum)<np.abs(minimum):                                 # condition if sensitivity of backward reaction is greater.
		s_m[m]=minimum
		react_id[m]=snst_para.index(minimum)
		react_name.append(sim.sensitivity_parameter_name(react_id[m]))
		snst_para.remove(minimum)

np.sort(np.abs(s_m))

for i in range(N):
	print('\t  %5.9f %2s %7d \t %s %15s'  %(s_m[i],'|',react_id[i],'|',react_name[i]))


# plot on Temperature vs ignition delay.
plt.figure(1)
plt.subplot(2,2,1)
plt.plot(states.time_in_ms,states.T)
plt.xlabel('Time (ms)',weight='bold')
plt.ylabel('Temperature',weight='bold')
plt.title("Effect of Ignition Delay on Temperature",weight='bold')

# plot for molar concentration of 'CH4' vs ignition delay.
plt.subplot(2,2,2)
plt.plot(states.time_in_ms,states('CH4').X)
plt.xlabel('Time (ms)',weight='bold')
plt.ylabel('CH4 Mole fraction',weight='bold')
plt.title("Effect of time on 'CH4'concentrations",weight='bold')

# plot for molar concentration of 'OH' vs ignition delay.
plt.subplot(2,2,3)
plt.plot(states.time_in_ms,states('OH').X)
plt.xlabel('Time (ms)',weight='bold')
plt.ylabel('OH Mole fraction',weight='bold')
plt.title("Effect of time on 'OH'concentrations",weight='bold')

# plot for molar concentration of 'H' vs ignition delay.
plt.subplot(2,2,4)
plt.plot(states.time_in_ms,states('H').X)
plt.xlabel('Time (ms)',weight='bold')
plt.ylabel('H Mole fraction',weight='bold')
plt.tight_layout()
plt.title("Effect of time on 'H' concentrations",weight='bold')
plt.show()

# plot on effect of reactions on senstivity paramter.
plt.figure(2)
plt.barh(react_name,s_m,color='red')
plt.title("Effect of reactions on Temperature sensitivity",weight='bold')
plt.show()

Result :-

Fig 1:

Fig 2:

Observation:-

From fig 1, I observed following things:-

  • In 1st plot, There is ignition delay of 0.39 ms in ignition of methane fuel.
  • In 2nd plot, CH4 mole fraction gets totally consumed in time-period of 0.39 ms.
  • In 3rd plot, OH formation takes place in same time period as CH4 gets exhausted in same time period of 0.39 ms. In other words, As CH4 gets consume totally, there is sudden rapid formation of OH.
  • In 4th plot, just like as OH forms in 3rd plot hydrogen formation takes place in similar that way.

From fig 2, I observed following things:-

  • Most of the sensitivity reaction are reverse reaction and only few of them are forward reaction.
  • The highest sensitive reaction is backward reaction which have value of
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.