Week 3 - Adiabatic Flame Temperature calculation
# 4. Adiabatic flame temperature variation with respect to number of Carbon atom chains :
"""
ADIABATIC FLAME TEMPERATURE VARIATION WITH RESPECT TO ALKANE, ALKENE AND ALKYNE
Alkane: CnH(2n+2)
Alkene: CnH(2n)
Alkyne: CnH(2n-2)
type of hydrocarbon (c=2)
general hydrocarbon: CxHy + [x + (y/4)](O2 + 3.76N2) => xC02 + (y/2)H20 + 3.76[x + (y/4)]N2
METHENE : CH4 + 2(O2 +3.76N2) => CO2 + 2H20 + 7.52N2
ETHANE : C2H6 + 3.5(O2 + 3.76N2) => 2CO2 + 3H20 + 13.16 N2
PROPANE : C3H8 + 5(O2 + 3.76N2) => 3C02 + 4H20 + 18.8N2
#Ch4 + 2(O2 + 3.76N2) = Co2 + 2H2O + 7.52N2 # STOICHIOMETRIC MIXTURE
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
def h(T,co_effs):
"""
function to evaluate enthaphy
"""
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]
enthalpy = (a1 + a2*T /2 + a3*pow(T,2) /3 + a4*pow(T,3) /4 + a5*pow(T,4)/5 + a6/T)*R*T
return enthalpy
#low tempearture coefficient
Ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11,-1.02466476E+04,-4.64130376E+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]
C3h8_coeffs_l = [0.75341368E+01,0.18872239E-01,-0.62718491E-05,0.91475649E-09,-0.47838069E-13,-0.16467516E+05,-0.17892349E+02]
O2_coeffs_l = [3.78245636E+00,-2.99673416E-03,9.84730201E-06,-9.68129509E-09, 3.24372837E-12,-1.06394356E+03, 3.65767573E+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 ]
#high tempearture coefficient
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_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 ]
Co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14, -1.41518724E+04,7.81868772E+00]
#standard temperature
Tstd = 298.15
def f(T,phi,ntype):
Tstd = 298.15
"""function that represents the root finding problem
"""
h_CO2_p = h(T,CO2_coeffs_h)
h_N2_p = h(T,N2_coeffs_h)
h_H2O_p = h(T,H2O_coeffs_h)
h_Ch4_r = h(Tstd,Ch4_coeffs_l)
h_C2h6_r = h(Tstd,C2h6_coeffs_l)
h_C3h8_r = h(Tstd,C3h8_coeffs_l)
h_O2_r = h(Tstd,O2_coeffs_l)
h_N2_r = h(Tstd,N2_coeffs_l)
if ntype == 1:
x = 1
y = 4
h_fuel = h_Ch4_r
elif ntype == 2:
x = 2
y = 6
h_fuel = h_C2h6_r
elif ntype == 3:
x = 3
y = 8
h_fuel = h_C3h8_r
H_products = x*h_CO2_p + (y/2)*h_H2O_p + 3.76*(x+y/4)*h_N2_p
H_reactants = h_fuel + (x+y/4) * h_O2_r + 3.76*(x + y/4) * h_N2_r
return (H_products - H_reactants)
def fprime(T,phi,ntype):
return (f(T+1e-6,phi,ntype) - f(T,phi,ntype))/1e-6
#Newton raphson method
T_guess = 1500
tol = 1e-03
alpha = 0.8
ntype = [1,2,3]
T_ad = []
phi = 0.1
for i in range(0,len(ntype)) :
while(abs(f(T_guess,phi,ntype[i])) > tol) :
T_guess = T_guess - (alpha*(f(T_guess,phi,ntype[i])/(fprime(T_guess,phi,ntype[i]))))
print(T_guess)
T_ad.append(T_guess)
#plotting
plt.bar(['Methane (CH4)', 'Ethane (C2H6)', 'Propane (C3H8)'],T_ad,color='yellow')
plt.ylabel('Adiabatic Flame Temperature')
plt.title("Effect of AFT with respect to methane, ethane, propane")
plt.show()
"""
cantera solution
gas = ct.Solution('gri30.xml')
t = []
gas.TPX = 298.15,101325,{'CH4':1,'O2':2 ,'N2':7.52}
gas.equilibrate('HP','auto')
T_methene_AFT = gas.T
gas.TPX = 298.15,101325,{'C2H6':1,'O2':3.5,'N2':13.16}
gas.equilibrate('HP','auto')
T_ethene_AFT = gas.T
gas.TPX = 298.15,101325,{'C3H8':1,'O2':5 ,'N2':18.8}
gas.equilibrate('HP','auto')
T_propane_AFT = gas.T
T_AFT_cantera = [T_methene_AFT,T_ethene_AFT,T_propane_AFT]
#plotting
plt.figure(2)
plt.plot(ntype,T_ad,"-*",color = "red",label = "custum_Enthalpy code")
plt.plot(ntype,T_AFT_cantera,"-o",color ="blue",label = "AFT_cantera")
plt.xlabel('no. of carbons bonds')
plt.ylabel('Adiabatic Flame Temperature')
plt.title("effect of AFT with respect to alkane,alkene,alkyne")
plt.legend()
plt.grid("on")
plt.show()
# IN gri30.xml FILE SPECIFICALLY FOR METHANE AS FUEL SO FOR ethane and propane we can not calculate in cantera
"""
# 3.Adiabatic flame temperature variation with respect to Alkane, Alkene, Alkyne :
"""
ADIABATIC FLAME TEMPERATURE VARIATION WITH RESPECT TO ALKANE, ALKENE AND ALKYNE
Alkane: CnH(2n+2)
Alkene: CnH(2n)
Alkyne: CnH(2n-2)
type of hydrocarbon
general hydrocarbon: CxHy + [x + (y/4)](O2 + 3.76N2) => xC02 + (y/2)H20 + 3.76[x + (y/4)]N2
ETHANE : C2H6 + 3.5(O2 +3.76N2) => 2CO2 + 3H20 + 13.16N2
ETHENE : C2H4 + 3(O2 + 3.76N2) => 2CO2 + 2H20 + 11.28 N2
ETHYNE : C2H2 + 2.5(O2 + 3.76N2) => 2C02 + H20 + 9.4N2
#Ch4 + 2(O2 + 3.76N2) = Co2 + 2H2O + 7.52N2 # STOICHIOMETRIC MIXTURE
#Ch4 + (2/phi)(O2 +3.76N2) = Co2 + 2H2O + (2/phi-2)O2 + (7.52/phi)N2 # LEAN MIXTURE
#Ch4 + (2/phi)(O2 +3.76N2) = (4/phi-3)CO2 +2H2O + (4-4/phi)Co + (7.52/phi)N2 # RICH MIXTURE
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
def h(T,co_effs):
"""
function to evaluate enthaphy
"""
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]
enthalpy = (a1 + a2*T /2 + a3*pow(T,2) /3 + a4*pow(T,3) /4 + a5*pow(T,4)/5 + a6/T)*R*T
return enthalpy
#low tempearture coefficient
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.55171815E-05,2.80152437E-08,-8.50072974E-12,2.64289807E+04,1.39397051E+01]
ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11,-1.02466476E+04,-4.64130376E+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]
N2_coeffs_l = [0.03298677E+02, 0.14082404E-02,-0.03963222E-04,0.05641515E-07,-0.02444854E-10,-0.10208999E+04, 0.03950372E+02 ]
#high tempearture coefficient
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_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 ]
Co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14, -1.41518724E+04,7.81868772E+00]
#standard temperature
Tstd = 298.15
def f(T,phi,ntype):
Tstd = 298.15
"""function that represents the root finding problem
"""
h_CO2_p = h(T,CO2_coeffs_h)
h_H2O_p = h(T,H2O_coeffs_h)
h_N2_p = h(T,N2_coeffs_h)
h_c2h6_r = h(Tstd,c2h6_coeffs_l)
h_c2h4_r = h(Tstd,c2h4_coeffs_l)
h_c2h2_r = h(Tstd,c2h2_coeffs_l)
h_O2_r = h(Tstd,O2_coeffs_l)
h_N2_r = h(Tstd,N2_coeffs_l)
if ntype == 1: #C-C bonds = 1
x = 2
y = 6
h_fuel = h_c2h6_r
elif ntype == 2:
x = 2
y = 4
h_fuel = h_c2h4_r
elif ntype == 3:
x = 2
y = 2
h_fuel = h_c2h2_r
H_products = x*h_CO2_p + (y/2)*h_H2O_p + 3.76*(x+y/4)*h_N2_p
H_reactants = h_fuel + (x+y/4) * h_O2_r + 3.76*(x + y/4) * h_N2_r
return (H_products - H_reactants)
def fprime(T,phi,ntype):
return (f(T+1e-6,phi,ntype) - f(T,phi,ntype))/1e-6
#Newton raphson method
T_guess = 1500
phi = 1
tol = 1e-03
alpha = 0.8
ntype = [1,2,3]
T_ad = []
for i in range(0,len(ntype)) :
while(abs(f(T_guess,phi,ntype[i])) > tol) :
T_guess = T_guess - (alpha*(f(T_guess,phi,ntype[i])/(fprime(T_guess,phi,ntype[i]))))
print(T_guess)
T_ad.append(T_guess)
#plotting
plt.figure(1)
plt.bar(['Ethane (C2H6)', 'Ethene (C2H4)', 'Ethyne (C2H2)'],T_ad,color='orange')
plt.xlabel('no. of carbons bonds')
plt.ylabel('Adiabatic Flame Temperature')
plt.title("Effect of AFT with respect to ethane, ethene, ethyne")
plt.show()
"""
cantera solution
gas = ct.Solution('gri30.xml')
t = []
gas.TPX = 298.15,101325,{'C2H6':1,'O2':3.5 ,'N2':13.16}
gas.equilibrate('HP','auto')
T_alkane_AFT = gas.T
gas.TPX = 298.15,101325,{'C2H4':1,'O2':3 ,'N2':11.28}
gas.equilibrate('HP','auto')
T_alkene_AFT = gas.T
gas.TPX = 298.15,101325,{'C2H2':1,'O2':2.5 ,'N2':9.4}
gas.equilibrate('HP','auto')
T_alkyne_AFT = gas.T
T_AFT_cantera = [T_alkane_AFT,T_alkene_AFT,T_alkyne_AFT]
#plotting
plt.figure(2)
plt.plot(ntype,T_ad,"-*",color = "red",label = "custum_Enthalpy code")
plt.plot(ntype,T_AFT_cantera,"-o",color ="blue",label = "AFT_cantera")
plt.xlabel('no. of carbons bonds')
plt.ylabel('Adiabatic Flame Temperature')
plt.title("effect of AFT with respect to alkane,alkene,alkyne")
plt.legend()
plt.grid("on")
plt.show()
# IN gri30.xml FILE SPECIFICALLY FOR ethane AS FUEL SO FOR ethene and ethyne we can not calculate in cantera
"""
# 1. Adiabatic flame temperature variation with Equivalence ratio (In constant volume-chamber) :
"""
ADIABATIC FLAME TEMPERATURE
Ch4 + 2(O2 + 3.76N2) = Co2 + 2H2O + 7.52N2 # STOICHIOMETRIC MIXTURE
Ch4 + (2/phi)(O2 +3.76N2) = Co2 + 2H2O + (2/phi-2)O2 + (7.52/phi)N2 # LEAN MIXTURE
Ch4 + (2/phi)(O2 +3.76N2) = (4/phi-3)CO2 +2H2O + (4-4/phi)Co + (7.52/phi)N2 # RICH MIXTURE
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
def h(T,co_effs):
"""
function to evaluate enthaphy
"""
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]
enthalpy = (a1 + a2*T /2 + a3*pow(T,2) /3 + a4*pow(T,3) /4 + a5*pow(T,4)/5 + a6/T)*R*T
return enthalpy
#low tempearture coefficient
ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11,-1.02466476E+04,-4.64130376E+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]
N2_coeffs_l = [0.03298677E+02, 0.14082404E-02,-0.03963222E-04,0.05641515E-07,-0.02444854E-10,-0.10208999E+04, 0.03950372E+02 ]
#high tempearture coefficient
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_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 ]
Co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14, -1.41518724E+04,7.81868772E+00]
def f(T,phi):
h_Co2_p = h(T,Co2_coeffs_h)
h_N2_p = h(T,N2_coeffs_h)
h_H2O_p = h(T,H2O_coeffs_h)
h_O2_p = h(T,O2_coeffs_h)
h_Co_p = h(T,Co_coeffs_h)
R =8.314
#lean mixture
if phi < 1:
H_products = h_Co2_p + 2*h_H2O_p + ((2/phi)-2)*h_O2_p + (7.52/phi)*h_N2_p
n_products = 1 + (7.52/phi) + 2 +((2/phi)-2)
#stoichiometric mixture
if phi == 1:
H_products = h_Co2_p + 2*h_H2O_p + 7.52*h_N2_p
n_products = 1 + 7.52 +2
# rich mixture
if phi > 1:
H_products = ((4/phi)-3)*h_Co2_p + 2*h_H2O_p + (7.52/phi)*h_N2_p + (4-(4/phi))*h_Co_p
n_products = ((4/phi)-3) + (7.52/phi) + 2 + (4-(4/phi))
T_std = 298.15
h_ch4_r = h(T_std,ch4_coeffs_l)
h_O2_r = h(T_std,O2_coeffs_l)
h_N2_r = h(T_std,N2_coeffs_l)
H_reactants = h_ch4_r + (2/phi)*(h_O2_r + (3.76*h_N2_r))
n_reactants = 1 + (2/phi) + 3.76*(2/phi)
return ((H_products - n_products*R*T) - (H_reactants - n_reactants*R*T_std))
def fprime(T,phi):
return (f(T+1e-6,phi) - f(T,phi))/1e-6
#Newton raphson method
T_guess = 1500
tol = 1e-03
alpha = 0.8
X = np.arange(0.1,2,0.05)
T_ad = []
for phi in X:
while (abs(f(T_guess,phi)) > tol):
T_guess = T_guess - alpha*((f(T_guess,phi)/fprime(T_guess,phi)))
print(T_guess)
T_ad.append(T_guess)
gas = ct.Solution('gri30.xml')
temp = []
for i in X:
gas.TPX = 298.15,101325,{'CH4':1,'O2':2/i ,'N2':3.76*2/i}
gas.equilibrate('UV','auto')
temp.append(gas.T)
plt.plot(X,T_ad)
plt.plot(X,temp,color = 'red')
plt.xlabel('phi')
plt.ylabel('T')
plt.title("ATF for methane")
plt.legend(["python","cantera"])
plt.grid("on")
plt.show()
What is Combustion - The combustion is a chemical process in which a substance reacts rapidly with oxygen and gives off heat. The original substance is called the fuel, and the source of the oxygen is called the oxidizer. The fuel can be a solid, liquid or gas although for airplane propulsion the fuel is usually a liquid. The oxidizer, likewise, could be a solid,liquid or gas, but is usually a gas for airplanes . For solid rockets ,solid fuel and oxidizer are used.
What is Adiabatic Flame Temperature (AFT)
The purpose of burning fuel in combustion chamber is to increase the temperature of the gas stream, and the flame temperature is one of the factors because it influences the reaction rate of combustion. Another parameters that influences the reaction rate is the combustion pressure.
To summarize, the adiabatic flame temperature for a given fuel-oxidizer combination is determined by finding the final state temperatures (i.e AFT) for which the sum of the enthalpies of the reactants equals to the sum of the enthalpies of the products.
To calculate it theoratically i am going to use Newton-Raphson method as an iterative solver .
There are two type of adiabatic flame tempearture depends on its own process.
1. constant Volume
2. constant Pressure
Adiabatic Flame Temperature is defined as the temperature attained when all of the chemical reaction heat released heats combustion products.
In the study of combustion , there are two types of adiabatic flame temperature depending on how the process is completed : the constant volume and constant pressure, both of which describe temperature that combustion products theoretically can reach if no energy is lost to the outside environment.
THE CONCEPT OF AIR-FUEL MIXTURE
STOICHIOMETRIC COMBUSTION:
The air-fuel ratio for complete combustion is called stoichiometric combustion.
LEAN COMBUSTION
If the amount of air is more than fuel for complete combustion. This is called lean combustion.
RICH MIXTURE
If the amount of fuel is more than air for complete combustion. This is called rich combustion.
EQUIVALENCE RATIO (phi) :
The air-fuel equivalence ratio of a system is defined as the ratio of the fuel to the oxidizer ratio to the stoichiometric fuel to the oxidizer ratio.
ϕ = (Mfuel/Mair)actual/(Mfuel/Mair)stio.
phi <1 , lean combustion
phi =1 , stoichiometric combustion
phi >1 , rich combustion
GENERAL EQUATION FOR ANY HYDROCARBON COMBUSTION:
CxHy + [ x+ y/4 ] [ O2 + 3.76N2] ------> (y/2)H2O+ 3.76 [ x +y/2 ]N2
CHEMICAL REACTION OF COMBUSTION OF METHANE:
STOICHIOMETRIC COMBUSTION:
Ch4 + 2(O2 + 3.76N2) ---> Co2 + 2H2O + 7.52N2
LEAN COMBUSTION
Ch4 + (2/phi)(O2 +3.76N2) ----> Co2 + 2H2O + (2/phi-2)O2 + (7.52/phi)N2(4-4/phi)Co +
RICH MIXTURE
Ch4 + (2/phi)(O2 +3.76N2) ----> (4/phi-3)CO2 + 2H2O + (4-4/phi)Co + (7.52/phi)N2
Figure 1 : By comparing both the graph of python and cantera , the cantera profile is more smother than python profile. From the grapgh the maximum temperature attained in the case of cantera is 2600 k and in the case of python the maximum temperature achieved to 2850k .
Figure 2:
- From the graph we can easily seen that the increase in heat loss the Adiabatic Flame temperature is gradually decreasing .
- The grapgh is linearly decraeses
Figure 3 : The graph elaborates the relation between the alkyne, alkane and alkene. Coming to the type of bonds that the three species have are Alkane - it consists of a single bond or covalent bond between the two carbon atoms and between the carbon and hydrogen. Alkene consists of a double bond between the carbon atom and covalent bond between the carbon and hydrogen. On the other hand, alkyne consists of a triple bond between the two carbon atoms. The triple bond which is seen in the alkyne is much more stronger than the double bond and covalent bond which tell the triple bond has much bond strength or enregy than the double bond and single bond.
Obseravtion -
- The temperature for Ethane is 2382 k.
- The temperature for Ethene is 2564 k
- The temperature for Ethyne is 2911 k
Figure 4 : The graph clearly shows that an increase in the carbon atom in alkanes will results in higher adiabatic flame temperatures. As number of carbon atoms increases the number of bons increases , as a result , this has a high bonding strength which increases the Adiabatic Flame Temperature.
Obseravtion -
- The temperature for Methane is 2325 k.
- The temperature for Ethane is 2373 k
- The temperature for Propane is 2379 k
- The Difference in AFT is not much enough but it slightly in which propane has maximum AFT and methane has minimum AFT.
PROCEDURE -
PYTHON
1. Firstly, importing the required library such as matplotlib,cantera & numpy.
2. Define a function who will evaluate enthalpy.
3. Declare the coefficient of reactants and products of the enthaphy.
4. Declare a function which takes the inputs parametrs such as temperature (T), equivalance ratio(phi), no. of carbon bonds(ntype) .
5. Declare fprime which takes the inputs temperature (T), equivalance ratio(phi), no. of carbon bonds(ntype) provide the derivatives as an output. fprime is basically a derivative of f Function.
6. Now, start Newton Raphson Method declaring essential values and starting with declaring for loop. we are trying to check the convergence criteria ( while loop is converging criteria) and updating the values of Newton Raphson Method next to the while loop line.
7. With the append command i will going to store the values in empty matrix.
CANTERA
So in the cantera part i m going to import gri30.xml file and declare a empty matrix in the name of 't'
in addition to it, gas.TPX ..this is basically for (temperature,pressure, mole fraction) the value of temperature is 298.15k and pressure is 101325 k and declare the compositions of of reactants such as Ch4,O2 and N2 , these values going to be varies in the cases of ethane, methane ,propane, ethyene etc.
gas.equilibrate is used to solve for adiabatic flame temperature and its automatically to solve HP (constant enthalpy and constant pressure)
in order to evaluate the values of temperature i am going to print the gas.T command ,whatever the values of temperature inside the gas command will come out.
Finally, i am going to plot the figure by using plt.plot and describe the xlabel, ylabel, grid, legend and title command one by one.
On the other hand, in the case of heat loss factor . i was replaced number of carbon atoms(ntype) i everywhere , wherever ntype define.
# 2. Flame temperature variation with Heat loss (In constant pressure-chamber) :
"""
ADIABATIC FLAME TEMPERATURE
Ch4 + 2(O2 + 3.76N2) = Co2 + 2H2O + 7.52N2 # STOICHIOMETRIC MIXTURE
Ch4 + (2/phi)(O2 +3.76N2) = Co2 + 2H2O + (2/phi -2)O2 + (7.52/phi)N2 # LEAN MIXTURE
Ch4 + (2/phi)(O2 +3.76N2) = (4/phi-3)CO2 +2H2O + (4-4/phi)Co + (7.52/phi)N2 # RICH MIXTURE
"""
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
def h(T,co_effs):
"""
function to evaluate enthaphy
"""
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]
enthalpy = (a1 + a2*T /2 + a3*pow(T,2) /3 + a4*pow(T,3) /4 + a5*pow(T,4)/5 + a6/T)*R*T
return enthalpy
#low tempearture coefficient
ch4_coeffs_l = [5.14987613E+00,-1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11,-1.02466476E+04,-4.64130376E+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]
N2_coeffs_l = [0.03298677E+02, 0.14082404E-02,-0.03963222E-04,0.05641515E-07,-0.02444854E-10,-0.10208999E+04, 0.03950372E+02 ]
#high tempearture coefficient
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_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 ]
Co_coeffs_h = [2.71518561E+00, 2.06252743E-03,-9.98825771E-07, 2.30053008E-10,-2.03647716E-14, -1.41518724E+04,7.81868772E+00]
def f(T,phi,heat_loss_factor):
h_Co2_p = h(T,Co2_coeffs_h)
h_N2_p = h(T,N2_coeffs_h)
h_H2O_p = h(T,H2O_coeffs_h)
h_O2_p = h(T,O2_coeffs_h)
h_Co_p = h(T,Co_coeffs_h)
T_std = 298.15
h_Co2_p_T_std = h(T_std,Co2_coeffs_h)
h_N2_p_T_std = h(T_std,N2_coeffs_h)
h_H2O_p_T_std = h(T_std,H2O_coeffs_h)
h_O2_p_T_std = h(T_std,O2_coeffs_h)
h_Co_p_T_std = h(T_std,Co_coeffs_h)
R =8.314
#lean mixture
if phi < 1:
H_products = h_Co2_p + 2*h_H2O_p + ((2/phi)-2)*h_O2_p + (7.52/phi)*h_N2_p
H_products_std = h_Co2_p_T_std + 2*h_H2O_p_T_std + ((2/phi)-2)*h_O2_p_T_std + (7.52/phi)*h_N2_p_T_std
n_products = 1 + (7.52/phi) + 2 +((2/phi)-2)
#stoichiometric mixture
if phi == 1:
H_products = h_Co2_p + 2*h_H2O_p + 7.52*h_N2_p
H_products_std = h_Co2_p_T_std + 2*h_H2O_p_T_std + 7.52*h_N2_p_T_std
n_products = 1 + 7.52 +2
# rich mixture
if phi > 1:
H_products = ((4/phi)-3)*h_Co2_p + 2*h_H2O_p + (7.52/phi)*h_N2_p + (4-(4/phi))*h_Co_p
H_products_std = ((4/phi)-3)*h_Co2_p_T_std + 2*h_H2O_p_T_std + (7.52/phi)*h_N2_p_T_std + (4-(4/phi))*h_Co_p_T_std
n_products = ((4/phi)-3) + (7.52/phi) + 2 + (4-(4/phi))
h_ch4_r = h(T_std,ch4_coeffs_l)
h_O2_r = h(T_std,O2_coeffs_l)
h_N2_r = h(T_std,N2_coeffs_l)
H_reactants = h_ch4_r + (2/phi)*(h_O2_r + (3.76*h_N2_r))
n_reactants = 1 + (2/phi) + 3.76*(2/phi)
LHV = H_reactants - H_products_std
loss = heat_loss_factor*LHV
return ((H_products) - (H_reactants) - loss)
def fprime(T,phi,heat_loss_factor):
return (f(T+1e-6,phi,heat_loss_factor) - f(T,phi,heat_loss_factor))/1e-6
#Newton raphson method
T_guess = 1500
tol = 1e-03
alpha = 0.8
heat_loss_factor = np.linspace(0,1,10)
T_ad = [] # required temp
phi = 0.1;
for i in range(0,len(heat_loss_factor)) :
while(abs(f(T_guess,phi,heat_loss_factor[i])) > tol) :
T_guess = T_guess - alpha*(f(T_guess,phi,heat_loss_factor[i])/fprime(T_guess,phi,heat_loss_factor[i]))
print(T_guess)
T_ad.append(T_guess)
plt.plot(heat_loss_factor,T_ad)
plt.grid('on')
plt.legend()
plt.xlabel('Heat loss factor')
plt.ylabel('Adiabatic Flame temperature')
plt.title("Effect of Heat Loss Factor on AFT")
plt.show()