Project

Computing Adiabatic Flame Temperature using Python and Cantera

OBJECTIVE:

1. Effect of equivalence ratio on AFT

To write a program in Python to plot the effect of equivalence ratio on the final adiabatic flame temperature for methane contained in a constant volume chamber and compare the results with Cantera.

2. To write a program to calculate the effect of Heat Loss on Adiabatic Flame Temperature for Methane(CH4).

3. To write a programme to calculate the effect of Alkane, Alkene and Alkyne variants of 2 carbon atom chain with heat loss on AFT.

4. Program to plot the effect of the no. of carbon atoms from (1 to 3) on Final Temperature without Heat loss.

1. Effect of equivalence Ratio on AFT

Adiabatic Flame Temperature:

When a combustion reaction takes place energy is released to the combustion products. If no heat is lost in this process, the temperature of the combustion products is known as the "Adiabatic Flame Temperature."

When a flame loses heat to the environment or is diluted with an inert material that has to be heated with the heat released in the combustion reaction, the actual temperature reached is less than the ideal adiabatic flame temperature. This is the actual "Flame Temperature."

In Combustion, there are two types of adiabatic flame temperature depending on how the process is completed. These are constant volume and constant pressure, describing the temperature that the combustion products theoretically reach if no energy is lost to the outside environment.

If lamda=phi=1, it is a Stoichiometric ratioStoichiometric

CH4+2(O2+3.76N2)=CO2+2H2O+7.52N2CH4+2O2+7.52N2=CO2+2H2O+7.52N2

If phi<1 & lamda>1, it is a lean mixture

CH4+2/phi*(O2+3.76N2)=CO2+2H2O+(2/phi-2)*O2+(7.52/phi)*N2

If phi>1 & lamda<1, it is a rich mixture

Ch4+2/phi*(O2+3.76*N2)=(4/phi-3)*CO2+2H2O+(4-4/phi)*CO+(7.52/phi)*N2

"""
Calculating the effect of Equivalence ratio on the Adiabatic Final Temperature
Equivalence Ratio = phi 
Equivalence Ratio = lamda

phi = 1/lamda

Theoretical combustion of methane is:
CH4 + a(O2 + 3.76N2) = bCO2 + c2H2O + dN2
where,
C: b=1
H: 2c=4
O: 2b+c=2a
N: d=3.76a

IF lamda=phi=1, it is a Stoichiometric ratio
Stoichiometric Combustion of methane
CH4+2(O2+3.76N2)=CO2+2H2O+7.52N2
CH4+2O2+7.52N2=CO2+2H2O+7.52N2

IF phi<1 & lamda>1, it is a lean mixture
Combustion of Methane mixture in Air
CH4+2/phi*(O2+3.76N2)=CO2+2H2O+(2/phi-2)*O2+(7.52/phi)*N2

If phi>1 & lamda<1, it is a rich mixture
Ch4+2/phi*(O2+3.76*N2)=(4/phi-3)*CO2+2H2O+(4-4/phi)*CO+(7.52/phi)*N2

Reactants temperature is known (298k stp) and products temperatures are unknown which is what we are trying to calculate(AFT)

By Vaibhav
"""

import matplotlib.pyplot as plt
import numpy as np

def h(T,co_effs):

	R = 8.314 #j/mol-k

	a1=co_effs[0]
	a2=co_effs[1]
	a3=co_effs[2]
	a4=co_effs[3]
	a5=co_effs[4]
	a6=co_effs[5]


	return (a1 + (a2*T/2) + (a3*pow(T,2)/3) + (a4*pow(T,3)/4) + (a5*pow(T,4)/5) + (a6/T))*R*T
	"""
	THERMO
   	300.000  1000.000  5000.000
	! GRI-Mech Version 3.0 Thermodynamics released 7/30/99
	! NASA Polynomial format for CHEMKIN-II
	"""

ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02,4.91800599E-05,-4.84743026E-08,1.66693956E-11,-1.02466476E+04,-4.64130376E+00]
co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14,-1.41518724E+04,7.81868772E+00]
o2_coeffs_l = [3.78245636E+00,-2.99673416E-03,9.84730201E-06,-9.68129509E-09,3.24372837E-12,-1.06394356E+03,3.65767573E+00]
o2_coeffs_h = [3.28253784E+00,1.48308754E-03,-7.57966669E-07,2.09470555E-10,-2.16717794E-14,-1.08845772E+03,5.45323129E+00]
n2_coeffs_l = [0.03298677E+02,0.14082404E-02,-0.03963222E-04, 0.05641515E-07,-0.02444854E-10, -0.10208999E+04, 0.03950372E+02]
n2_coeffs_h = [0.02926640E+02,0.14879768E-02,-0.05684760E-05, 0.10097038E-09,-0.06753351E-13, -0.09227977E+04, 0.05980528E+02]
co2_coeffs_h = [3.85746029E+00,4.41437026E-03,-2.21481404E-06,5.23490188E-10,-4.72084164E-14,-4.87591660E+04,2.27163806E+00]
h2o_coeffs_h = [3.03399249E+00,2.17691804E-03,-1.64072518E-07,-9.70419870E-11,1.68200992E-14,-3.00042971E+04,4.96677010E+00]

def f(T,phi):

	#Enthalpy of the reactants
	Tstd=298.15 # in kelvin
	R = 8.314 # j/mol.k

	h_ch4_r=h(Tstd,ch4_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_ch4_r + (2/phi)*h_o2_r + (7.52/phi)*h_n2_r
	N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products

	if (phi<1): # lean mixture
		h_co2_p = h(T,co2_coeffs_h)
		h_h2o_p = h(T,h2o_coeffs_h)
		h_o2_p = h(T,co_coeffs_h)
		h_n2_p = h(T,n2_coeffs_h)


		H_products = h_co2_p + 2*h_h2o_p + (7.52/phi)*h_n2_p + (2/phi - 2)*h_o2_p 
		N_products = 1 + 2 + 3.76*(2/phi) + (2/phi - 2) 


	else: #rich mixture

		h_co2_p = h(T,co2_coeffs_h)
		h_h2o_p = h(T,h2o_coeffs_h)
		h_co_p = h(T,co_coeffs_h)
		h_n2_p = h(T,n2_coeffs_h)

		H_products = (4/phi - 3)*h_co2_p + 2*h_h2o_p + (4 - 4/phi)*h_co_p + (7.52/phi)*h_n2_p
		N_products = (4/phi - 3) + 2 + (4 - 4/phi) + (7.52/phi)



	return (H_products - H_reactants - R*(N_products*T - N_reactants*Tstd))
	 


def fprime(T,phi):
	return (f(T+1e-6,phi)-f(T,phi))/1e-6

T_guess = 1500
ct = 0
tol = 1e-3
alpha = 0.2
phi= np.linspace(0.6,1.6,11)
aft_t= []

for i in range (0,len(phi)):
	while(abs(f(T_guess,phi[i])) > tol):
		T_guess = T_guess - alpha*((f(T_guess,phi[i]) / fprime(T_guess,phi[i])))
		ct=ct+1
	aft_t.append(T_guess)


"""
Using Cantera for evaluating Adiabatic Flame Temperature

"""
import cantera as ct 

gas = ct.Solution('gri30.xml')

Temp_cantera=[]

for i in range (0, len(phi)):
	Total_mole = 1 + 2*phi[i] +7.52*phi[i]
	mole_fraction_ch4= 1/Total_mole
	mole_fraction_o2= (2*phi[i])/Total_mole
	mole_fraction_n2= (7.52*phi[i])/Total_mole
	

	gas.TPX= 298.15,101325,{'CH4':mole_fraction_ch4,'O2':mole_fraction_o2,'N2':mole_fraction_n2}
	
	#gas.TPX= 298.15,101325,{'CH4':0.095,'O2':0.19,'N2':0.7148}
	gas.equilibrate('UV','auto')
	Temp_cantera.append(gas.T) 

Equivalence_ratio = 1/phi
plt.plot(Equivalence_ratio,aft_t,'*',color = 'green')
plt.plot(Equivalence_ratio,Temp_cantera,'*',color = 'red')
plt.xlabel('Equivalence Ratio')
plt.ylabel('Adiabatic Flame Temperature(K)')
plt.title('Effect of Equivalence ratio on AFT')
plt.grid()
plt.legend(['Python','Cantera'])
plt.show()

Observation and Conclusion:

We see here adiabatic flame temperature reaching its highest value at approx. equivalence ratio(psi) = 1 i.e. the mixture is stoichiometric. On the left of psi=1, we see the behaviour pattern of lean mixture and on right behaviour pattern of the rich mixture. Overall, the effect of Equivalence Ratio shows a curvilinear pattern moving from lean mixture to rich mixture.

In the above plot, the same task is carried out using Python and Cantera and compared on the same graph. The highest temperature in Python is 2800k and that in Cantera is 2600k. We get different results for the same equivalence ratio for methane reacting with an oxidizer because in Cantera various minute product and reactants are taken into consideration from a huge library of chemical kinetics, thermodynamics and transport processes. Whereas in python these are not taken into account we manually state the elements in the chemical equation.

2. Effect of Heat Loss on Adiabatic Flame Temperature for Methane(CH4)

AFT of CH4 with H_loss = 0.35 was determined with the value of lambda and psi = 1.

With psi=1,

CH4+2(O2+3.76N2)=CO2+2H2O+7.52N2

"""
To calculate the effect of heat loss on Adiabatic Flame Temperature for CH4

(stoichiometric mixture)
CH4+2(O2+3.76N2)=CO2+2H2O+7.52N2
"""


import matplotlib.pyplot as plt
import numpy as np

def h(T,co_effs):

	R = 8.314 #j/mol-k

	a1=co_effs[0]
	a2=co_effs[1]
	a3=co_effs[2]
	a4=co_effs[3]
	a5=co_effs[4]
	a6=co_effs[5]


	return (a1 + (a2*T/2) + (a3*pow(T,2)/3) + (a4*pow(T,3)/4) + (a5*pow(T,4)/5) + (a6/T))*R*T
	"""
	THERMO
   	300.000  1000.000  5000.000
	! GRI-Mech Version 3.0 Thermodynamics released 7/30/99
	! NASA Polynomial format for CHEMKIN-II
	"""

ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02,4.91800599E-05,-4.84743026E-08,1.66693956E-11,-1.02466476E+04,-4.64130376E+00]
co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14,-1.41518724E+04,7.81868772E+00]
o2_coeffs_l = [3.78245636E+00,-2.99673416E-03,9.84730201E-06,-9.68129509E-09,3.24372837E-12,-1.06394356E+03,3.65767573E+00]
o2_coeffs_h = [3.28253784E+00,1.48308754E-03,-7.57966669E-07,2.09470555E-10,-2.16717794E-14,-1.08845772E+03,5.45323129E+00]
n2_coeffs_l = [0.03298677E+02,0.14082404E-02,-0.03963222E-04, 0.05641515E-07,-0.02444854E-10, -0.10208999E+04, 0.03950372E+02]
n2_coeffs_h = [0.02926640E+02,0.14879768E-02,-0.05684760E-05, 0.10097038E-09,-0.06753351E-13, -0.09227977E+04, 0.05980528E+02]
co2_coeffs_h = [3.85746029E+00,4.41437026E-03,-2.21481404E-06,5.23490188E-10,-4.72084164E-14,-4.87591660E+04,2.27163806E+00]
h2o_coeffs_h = [3.03399249E+00,2.17691804E-03,-1.64072518E-07,-9.70419870E-11,1.68200992E-14,-3.00042971E+04,4.96677010E+00]

def f(T,H_loss):

	#CH4+2(O2+3.76N2)=CO2+2H2O+7.52N2+0.35*maximum possible heat loss
	#Enthalpy of the reactants

	R = 8.314 # j/mol.k
	LHV = 800950  #J/mole
	#H_loss=0.35
	loss = H_loss*LHV
	Tstd=298.15

	h_ch4_r=h(Tstd,ch4_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_ch4_r + 2*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 1*h_co2_p + 2*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (H_products - H_reactants + loss)
	 


def fprime(T,H_loss): #Forward Differencing scheme
	return (f(T+1e-6,H_loss)-f(T,H_loss))/1e-6

T_guess = 1500
ct = 0
tol = 1e-3
alpha = 0.2
H_loss= np.linspace(0,1,10)
aft_t= []

# Newton-Raphson Method
for i in range (0,len(H_loss)):
	while(abs(f(T_guess,H_loss[i])) > tol):
		T_guess = T_guess - alpha*((f(T_guess,H_loss[i]) / fprime(T_guess,H_loss[i])))
		ct=ct+1
	aft_t.append(T_guess)


plt.plot(H_loss,aft_t,'*',color = 'blue')
print(aft_t)
print(T_guess)
print(ct)
print(H_loss)
plt.xlabel('Heat Loss Factor')
plt.ylabel('Adiabatic Flame Temperature')
plt.title('Effect of Heat loss on AFT')
plt.grid()
plt.show()

Observation and Conclusion:

The effect of Heat loss factor on Adiabatic Flame Temperature shows a linear and inversely proportional relation i.e. as the heat loss factor increases the AFT decreases with negative slope dropping from 2250k to 250k.

3. Effect of Alkane, Alkene and Alkyne variants of 2 carbon atom chain with heat loss on AFT

Chemical Equations:

Alkane: C2H6 + 3.5O2 + 7.5N2 = 2CO2 + 3H2O + 7.5N2 + 0.35*LHV

Alkene: C2H4 + 3O2 + 7.5N2 = 2CO2 + 2H2O + 7.5N2 + 0.35*LHV

Alkyne: C2H2 + 2.5O2 + 7.5N2 = 2CO2 H2O + 7.5N2 + 0.35*LHV

35% heat loss of maximum heat loss (LHV) was determined.

"""
Test it only for -ane, -ene and -yne variants of 2 Carbon atom chain with heat loss
#general Formula

Alkane: CnH2n+2
Alkene: CnH2n
Alkyne: CnH2n-2

Alkane: C2H6 + 3.5O2 + 7.5N2 = 2CO2 + 3H2O + 7.5N2 + 0.35*LHV
Alkene: C2H4 + 3O2 + 7.5N2 = 2CO2 + 2H2O + 7.5N2 + 0.35*LHV
Alkyne: C2H2 + 2.5O2 + 7.5N2 = 2CO2  H2O + 7.5N2 + 0.35*LHV
"""

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

def h(T,co_effs):

	R = 8.314 #j/mol-k

	a1=co_effs[0]
	a2=co_effs[1]
	a3=co_effs[2]
	a4=co_effs[3]
	a5=co_effs[4]
	a6=co_effs[5]


	return (a1 + (a2*T/2) + (a3*pow(T,2)/3) + (a4*pow(T,3)/4) + (a5*pow(T,4)/5) + (a6/T))*R*T
	"""
	THERMO
   	300.000  1000.000  5000.000
	! GRI-Mech Version 3.0 Thermodynamics released 7/30/99
	! NASA Polynomial format for CHEMKIN-II
	"""

ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02,4.91800599E-05,-4.84743026E-08,1.66693956E-11,-1.02466476E+04,-4.64130376E+00]
co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14,-1.41518724E+04,7.81868772E+00]
o2_coeffs_l = [3.78245636E+00,-2.99673416E-03,9.84730201E-06,-9.68129509E-09,3.24372837E-12,-1.06394356E+03,3.65767573E+00]
o2_coeffs_h = [3.28253784E+00,1.48308754E-03,-7.57966669E-07,2.09470555E-10,-2.16717794E-14,-1.08845772E+03,5.45323129E+00]
n2_coeffs_l = [0.03298677E+02,0.14082404E-02,-0.03963222E-04, 0.05641515E-07,-0.02444854E-10, -0.10208999E+04, 0.03950372E+02]
n2_coeffs_h = [0.02926640E+02,0.14879768E-02,-0.05684760E-05, 0.10097038E-09,-0.06753351E-13, -0.09227977E+04, 0.05980528E+02]
co2_coeffs_h = [3.85746029E+00,4.41437026E-03,-2.21481404E-06,5.23490188E-10,-4.72084164E-14,-4.87591660E+04,2.27163806E+00]
h2o_coeffs_h = [3.03399249E+00,2.17691804E-03,-1.64072518E-07,-9.70419870E-11,1.68200992E-14,-3.00042971E+04,4.96677010E+00]
c2h6_coeffs_l = [4.29142492E+00,-5.50154270E-03,5.99438288E-05,-7.08466285E-08, 2.68685771E-11,-1.15222055E+04,2.66682316E+00]
c2h4_coeffs_l = [3.95920148E+00,-7.57052247E-03,5.70990292E-05,-6.91588753E-08, 2.69884373E-11,5.08977593E+03,4.09733096E+00]
c2h2_coeffs_l = [8.08681094E-01,2.33615629E-02,-3.55171815,-052.80152437E-08,-8.50072974E-12,2.64289807E+04,1.39397051E+01]

#Alkane: C2H6 + 3.5O2 + 7.5N2 = 2CO2 + 3H2O + 7.5N2 + 0.35*LHV

def f_alkane(T):

	R = 8.314 # j/mol.k
	LHV = 1428275  #J/mole
	H_loss=0.35
	loss = H_loss*LHV
	Tstd=298.15

	h_c2h6_r=h(Tstd,c2h6_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_c2h6_r + 3.5*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 2*h_co2_p + 3*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (-H_products + H_reactants + loss)
	 


def fprime_alkane(T): #Forward Differencing scheme
	return (f_alkane(T+1e-6)-f_alkane(T))/1e-6

#Alkene: C2H4 + 3O2 + 7.5N2 = 2CO2 + 2H2O + 7.5N2 + 0.35*LHV

def f_alkene(T):

	R = 8.314 # j/mol.k
	LHV = 1323474  #J/mole
	H_loss=0.35
	loss = H_loss*LHV
	Tstd=298.15

	h_c2h4_r=h(Tstd,c2h4_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_c2h4_r + 3*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 2*h_co2_p + 2*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (-H_products + H_reactants + loss)

def fprime_alkene(T): #Forward Differencing scheme
	return (f_alkene(T+1e-6)-f_alkene(T))/1e-6

#Alkyne: C2H2 + 2.5O2 + 7.5N2 = 2CO2 + H2O + 7.5N2 + 0.35*LHV

def f_alkyne(T):

	R = 8.314 # j/mol.k
	LHV = 1258020  #J/mole
	H_loss=0.35
	loss = H_loss*LHV
	Tstd=298.15

	h_c2h2_r=h(Tstd,c2h2_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_c2h2_r + 2.5*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 2*h_co2_p + 1*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (-H_products + H_reactants + loss)


def fprime_alkyne(T): #Forward Differencing scheme
	return (f_alkyne(T+1e-6)-f_alkyne(T))/1e-6


T_guess_alkane = 1500
T_guess_alkene = 1500
T_guess_alkyne = 1500

ct = 0
tol = 1e-3
alpha = 0.2
#H_loss= np.linspace(0,1,10)
aft_t= []

# Newton-Raphson Method (Alkane)

while(abs(f_alkane(T_guess_alkane)) > tol):
	T_guess_alkane = T_guess_alkane - alpha*((f_alkane(T_guess_alkane) / fprime_alkane(T_guess_alkane)))
	ct=ct+1
aft_t.append(T_guess_alkane)

# Newton-Raphson Method (Alkene)

while(abs(f_alkene(T_guess_alkene)) > tol):
	T_guess_alkene = T_guess_alkene - alpha*((f_alkene(T_guess_alkene) / fprime_alkene(T_guess_alkene)))
	ct=ct+1
aft_t.append(T_guess_alkene)

# Newton-Raphson Method (Alkene)

while(abs(f_alkyne(T_guess_alkyne)) > tol):
	T_guess_alkyne = T_guess_alkyne - alpha*((f_alkyne(T_guess_alkyne) / fprime_alkyne(T_guess_alkyne)))
	ct=ct+1
aft_t.append(T_guess_alkyne)

Fuels = ['Alkane','Alkene','Alkyne']
plt.bar(Fuels,aft_t)
print(aft_t)
print(T_guess_alkane)
print(T_guess_alkene)
print(T_guess_alkyne)
print(ct)

plt.xlabel('Fuels')
plt.ylabel('Adiabatic Flame Temperature')
plt.title('Calculating Adiabatic Flame Temperature')
plt.grid()
plt.show()

Observation and Conclusion:

Here, Alkyne among the 3 fuels shows the maximum AFT. The high amount of energy gets released because of Carbon triple bond. Alkene and Alkyne behave similarly to each other.

4. Effect of the no. of carbon atoms from (1 to 3) on Final Temperature without Heat loss

General formula of alkaneCnH2n+2

for n=1,

CH4+2O2+7.52N2 = CO2+2H2O+7.52N2

for n=2,

C2H6+2O2+7.5N2 = 2CO2+3H2O+7.5N2

for n=3,

C3H8+5O2+7.5N2 = 3CO2+4H2O+7.5N2

"""
To plot the effect of the number of carbon atoms of alkane (from 1 to 3) on the final temperature without considering heat loss

General formula of alkane
CnH2n+2

for n=1,
CH4+2O2+7.52N2 = CO2+2H2O+7.52N2

for n=2,
C2H6+2O2+7.5N2 = 2CO2+3H2O+7.5N2

for n=3,
C3H8+5O2+7.5N2 = 3CO2+4H2O+7.5N2
"""

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

def h(T,co_effs):

	R = 8.314 #j/mol-k

	a1=co_effs[0]
	a2=co_effs[1]
	a3=co_effs[2]
	a4=co_effs[3]
	a5=co_effs[4]
	a6=co_effs[5]


	return (a1 + (a2*T/2) + (a3*pow(T,2)/3) + (a4*pow(T,3)/4) + (a5*pow(T,4)/5) + (a6/T))*R*T
	"""
	THERMO
   	300.000  1000.000  5000.000
	! GRI-Mech Version 3.0 Thermodynamics released 7/30/99
	! NASA Polynomial format for CHEMKIN-II
	"""

ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02,4.91800599E-05,-4.84743026E-08,1.66693956E-11,-1.02466476E+04,-4.64130376E+00]
co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14,-1.41518724E+04,7.81868772E+00]
o2_coeffs_l = [3.78245636E+00,-2.99673416E-03,9.84730201E-06,-9.68129509E-09,3.24372837E-12,-1.06394356E+03,3.65767573E+00]
o2_coeffs_h = [3.28253784E+00,1.48308754E-03,-7.57966669E-07,2.09470555E-10,-2.16717794E-14,-1.08845772E+03,5.45323129E+00]
n2_coeffs_l = [0.03298677E+02,0.14082404E-02,-0.03963222E-04, 0.05641515E-07,-0.02444854E-10, -0.10208999E+04, 0.03950372E+02]
n2_coeffs_h = [0.02926640E+02,0.14879768E-02,-0.05684760E-05, 0.10097038E-09,-0.06753351E-13, -0.09227977E+04, 0.05980528E+02]
co2_coeffs_h = [3.85746029E+00,4.41437026E-03,-2.21481404E-06,5.23490188E-10,-4.72084164E-14,-4.87591660E+04,2.27163806E+00]
h2o_coeffs_h = [3.03399249E+00,2.17691804E-03,-1.64072518E-07,-9.70419870E-11,1.68200992E-14,-3.00042971E+04,4.96677010E+00]
c2h6_coeffs_l = [4.29142492E+00,-5.50154270E-03,5.99438288E-05,-7.08466285E-08, 2.68685771E-11,-1.15222055E+04,2.66682316E+00]
c2h4_coeffs_l = [3.95920148E+00,-7.57052247E-03,5.70990292E-05,-6.91588753E-08, 2.69884373E-11,5.08977593E+03,4.09733096E+00]
c2h2_coeffs_l = [8.08681094E-01,2.33615629E-02,-3.55171815,-052.80152437E-08,-8.50072974E-12,2.64289807E+04,1.39397051E+01]
c3h8_coeffs_l = [0.93355381E+00,0.26424579E-01,0.61059727E-05,-0.21977499E-07,0.95149253E-11,-0.13958520E+05,0.19201691E+02]

"""
for n=1,
CH4+2O2+7.52N2 = CO2+2H2O+7.52N2
"""
def f_ch4(T):

	R = 8.314 # j/mol.k
	#LHV = 1428275  #J/mole
	#H_loss=0.35
	#loss = H_loss*LHV
	Tstd=298.15

	h_ch4_r=h(Tstd,ch4_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_ch4_r + 2*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 1*h_co2_p + 2*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (H_products - H_reactants)
	 


def fprime_ch4(T): #Forward Differencing scheme
	return (f_ch4(T+1e-6)-f_ch4(T))/1e-6

"""
for n=2,
C2H6+2O2+7.5N2 = 2CO2+3H2O+7.5N2

"""

def f_c2h6(T):

	R = 8.314 # j/mol.k
	#LHV = 1323474  #J/mole
	#H_loss=0.35
	#loss = H_loss*LHV
	Tstd=298.15

	h_c2h6_r=h(Tstd,c2h6_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_c2h6_r + 2*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 2*h_co2_p + 3*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (H_products - H_reactants)

def fprime_c2h6(T): #Forward Differencing scheme
	return (f_c2h6(T+1e-6)-f_c2h6(T))/1e-6

"""
for n=3,
C3H8+5O2+7.5N2 = 3CO2+4H2O+7.5N2
"""
def f_c3h8(T):

	R = 8.314 # j/mol.k
	#LHV = 1258020  #J/mole
	#H_loss=0.35
	#loss = H_loss*LHV
	Tstd=298.15

	h_c3h8_r=h(Tstd,c3h8_coeffs_l)
	h_o2_r=h(Tstd,o2_coeffs_l)
	h_n2_r=h(Tstd,n2_coeffs_l)

	H_reactants = h_c3h8_r + 5*h_o2_r + 7.52*h_n2_r
	print(H_reactants)
	#N_reactants = 1+(2/phi)+(7.52/phi)


	#Enthalpy of the products
	h_co2_p = h(T,co2_coeffs_h)
	h_h2o_p = h(T,h2o_coeffs_h)
	h_o2_p = h(T,co_coeffs_h)
	h_n2_p = h(T,n2_coeffs_h)

	H_products = 3*h_co2_p + 4*h_h2o_p + 7.52*h_n2_p  
	print(H_products)
	
	return (H_products - H_reactants)


def fprime_c3h8(T): #Forward Differencing scheme
	return (f_c3h8(T+1e-6)-f_c3h8(T))/1e-6


T_guess_ch4 = 1500
T_guess_c2h6 = 1500
T_guess_c3h8 = 1500

ct = 0
tol = 1e-3
alpha = 0.2
#H_loss= np.linspace(0,1,10)
aft_t= []

# Newton-Raphson Method (ch4)

while(abs(f_ch4(T_guess_ch4)) > tol):
	T_guess_ch4 = T_guess_ch4 - alpha*((f_ch4(T_guess_ch4) / fprime_ch4(T_guess_ch4)))
	ct=ct+1
aft_t.append(T_guess_ch4)

# Newton-Raphson Method (Alkene)

while(abs(f_c2h6(T_guess_c2h6)) > tol):
	T_guess_c2h6 = T_guess_c2h6 - alpha*((f_c2h6(T_guess_c2h6) / fprime_c2h6(T_guess_c2h6)))
	ct=ct+1
aft_t.append(T_guess_c2h6)

# Newton-Raphson Method (Alkene)

while(abs(f_c3h8(T_guess_c3h8)) > tol):
	T_guess_c3h8 = T_guess_c3h8 - alpha*((f_c3h8(T_guess_c3h8) / fprime_c3h8(T_guess_c3h8)))
	ct=ct+1
aft_t.append(T_guess_c3h8)

Fuels = ['ch4','c2h6','c3h8']
plt.bar(Fuels,aft_t)
print(aft_t)
print(T_guess_ch4)
print(T_guess_c2h6)
print(T_guess_c3h8)
print(ct)

plt.xlabel('No. of Carbon atoms')
plt.ylabel('Adiabatic Flame Temperature')
plt.title('Effect of no. of carbon atoms on AFT')
plt.grid()
plt.show()

Observation and Conclusion:

Here we see, as the no. of carbon atom increases the Final temperature also increases. This tells the more the hydrocarbon bond present, the more energy and temperature gets produced. C3H8(Propane)

has the highest AFT compared to Methane and Ethane.

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.