Cantera Open-Source

Sensitivity analysis of Methane combustion using Cantera Open-Source

Objective-Write a code that takes all the reactions from the GRI mechanism and calculates 10 most sensitive reactions.The sensitivity parameter should be with respect to the Temperature (It should find the sensitivity with respect to the temperature.)

Sensitivity Analysis:

In chemistry sensitivity analysis is peformed to check how the reactions behave to a given parameter such as temperature,pressure,concentration etc.Sensitivity analysis is highly used in combustion chemistry. A combustion process is associated with a lot of intermediate reactions.So sensitivity analysis is performed on the most sensitive reactions which affect the combustion as a whole.

The important use of the analysis is to get the knowledge of ignition delay for the system.This analysis helps in controling the parameter and rate of reaction and perform the combustion process in a controlled manner as required for the application.

Coding Approach:

1. A instance gas object is created from solution class and temperature,pressure and moles are set using gas.TPX function.

2. A reactor object ‘r’ is created using “IdealGasConstPressureReactor” and gas object is passed to it.

3. A reactor network using “ReactorNet” is created by passing the reactor to it.

4. Sensitivity of all the 325 reactions in GRI mechanism file is simulated using add_sensitivity_reaction().The realative and absolute tolerance is set to check convergence.

5. A states array is created using SolutionArray for gas,for easy access of properties.

5. “Advance” command is used to advance the reaction with time.

6. Sensitivity is caclulated by passing the parameter ‘temperature’ and reaction index

Python Code:

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

gas =ct.Solution('gri30.cti')
temp=1500
pres=ct.one_atm

gas.TPX= temp,pres,{'CH4':1,'O2':2,'N2':7.52}

r=ct.IdealGasConstPressureReactor(gas)
sim=ct.ReactorNet([r])

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

sim.rtol=1e-6
sim.atol=1e-15

sim.rtol_sensitivity=1e-6
sim.atol_sensitivity=1e-6
n=gas.n_reactions
s_max=[0]*n
#parameter=temperature
states=ct.SolutionArray(gas,extra=['t'])
for t in np.arange(0,2e-3,5e-6):
	sim.advance(t)
	states.append(r.thermo.state,t=1000*t)
	for j in range(n):
		s2=sim.sensitivity('temperature',j)
		if np.abs(s2)>=np.abs(s_max[j]):
			s_max[j]=s2	
n_number=10
s_max_abs=np.abs(s_max)
s_maximum=sorted(s_max_abs,reverse=True)
sensitivities=s_maximum[0:n_number]
sensitivity_final=[]
indexr=[]
eq=[]
for i in range(n_number):
	for j in range(n):
		if np.abs(s_max[j])==sensitivities[i]:
			sensitivity_final.append(s_max[j])
			indexr.append(j)
			eq+=gas.reaction_equations([j])
print(sensitivities)
print(sensitivity_final)
print(indexr)
print(eq)
plt.figure(1)
plt.barh(eq,sensitivity_final)
plt.yticks(fontsize=6)
plt.gca().invert_yaxis()
plt.xlabel('sensitivities')
plt.title('10 most temperature sensitive reaction in methane combustion')
plt.figure(2)
plt.subplot(2,2,1)
plt.plot(states.t,states.T,color='red')
plt.xlabel('time(ms)')
plt.ylabel('Temperature')
plt.subplot(2,2,2)
plt.plot(states.t,states('OH').X,color='blue')
plt.xlabel('time(ms)')
plt.ylabel('OH mole fraction')
plt.subplot(2,2,3)
plt.plot(states.t,states('H').X,color='green')
plt.xlabel('time(ms)')
plt.ylabel('H mole fraction')
plt.subplot(2,2,4)
plt.plot(states.t,states('CH4').X,color='orange')
plt.xlabel('time(ms)')
plt.ylabel('CH4 mole fraction')
plt.show()

Results:

Graph for 10 most temperature sensitive reaction in methane combustion.

The below graph shows the 10 most temperature sensitive reaction in methane combustion.

By changing the rate of these reaction the parameters like ignition delay can be controlled.

Variation of Temperature and concentrations with time

The above graph shows the emperature and concentrations with time.As we can see that the temperature has increased suddenly indicating the time of auto ignition from a intial value of 1500K.

The mole fraction of OH and H has increased showing the formation these species and finally attaining equilibrium at the end.The CH4 concentration has decreased with time showing that it has been consumed.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *