Week 3 - Adiabatic Flame Temperature calculation
# Solution to Problem 1 : Python Program
# Calculating AFT for methane at various Equivalence ratio
# Reaction : CH4 + 2( O2 + 3.76N2 ) = CO2 + 2H2O + 7.52N2
import matplotlib.pyplot as plt
import math
def h( T, co_effs):
# to import enthalpy
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
#return(a1 + a2*T/2 + a3*pow(T,2)/3 + a4*pow(T,3)/4 + a5*pow(T,4)/5 + a6*pow(T,5)/6)*R*T
# Changes are made in the following equation only.
CH4_coeffs_l = [ 5.14987613, -1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11, -1.02466476E+04, -4.64130376]
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]
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]
N2_coeffs_h = [ 0.02926640E+02, 0.14879768E-02, -0.05684760E-05, 0.10097038E-09, -0.06753351E-13, -0.09227977E+04, 0.05980528E+02]
def f(T):
# Root finding operation
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_Product = h_co2_p + 2*h_h2o_p + 7.52*h_n2_p
print(H_Product)
Tstd = 298.15 # 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_Reactant = h_ch4_r + 2*h_o2_r + 7.52*h_n2_r
print(H_Reactant)
return(H_Product - H_Reactant)
def f_Prime(T):
return (f(T+1e-6) - f(T))/1e-6
T_guess = 1500 # Kelvin
tol = 1e-03
ct = 0
alpha= 0.2
while(abs(f(T_guess)) > tol):
T_guess = T_guess - alpha*((f(T_guess)/f_Prime(T_guess)))
plt.plot(ct, T_guess, '*', color = 'red')
# print(T_guess)
ct = ct + 1
plt.show()
print(ct)
print(T_guess)
# Output : 2330 K
----------------------------------------------------------------------------------------------------------------
# Solution to Problem 1 : Cantera Program :
# Lets try cantera
import cantera as ct
gas = ct.Solution('gri30.xml')
gas.TPX = 298.15,101325,{'CH4':1, 'O2':2, 'N2':7.52}
gas.equilibrate('HP','auto')
print(gas.T)
print(gas())
# Output : 2224.6 K
The AFT differ in the two cases because in the second case we have considered allthe species involved, which will result in loss of heat in form of AFT.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Solution to Problem 2 :
def f(T):
# Root finding operation
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_Product = h_co2_p + 2*h_h2o_p + 7.52*h_n2_p
print(H_Product)
Tstd = 298.15 # 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_Reactant = h_ch4_r + 2*h_o2_r + 7.52*h_n2_r
print(H_Reactant)
Max_Rexn_Heat_Lost = H_Product - H_Reactant
H_loss_factor = 0.1
Actual_Heat_Loss = H_loss_factor * Max_Rexn_Heat_Lost
for H_loss_factor in range(0.1,1,0.02)
plt.plot(H_loss_factor, T_guess, '*', color = 'red')
return(Max_Rexn_Heat_Lost)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Solution to Problem 3 :
# For alkane : C2H6 + 3.5( O2 + 3.76N2 ) = 2CO2 + 3H2O + 13.16N2
H_Product = 2*h_co2_p + 3*h_h2o_p + 13.16*h_n2_p
H_Reactant = h_c2h6_r + 3.5*h_o2_r + 13.16*h_n2_r
# In this case we shall have to note down the values of C2H6 from GRIMECH #thermodynamics data table and use the above equations, other things will remain #same as in problem 1.
# Similarly for Alkene : C2H4 + 3( O2 + 3.76N2 ) = 2CO2 + 2H2O + 11.28N2
H_Product = 2*h_co2_p + 2*h_h2o_p + 11.28*h_n2_p
H_Reactant = h_c2h4_r + 3*h_o2_r + 11.28*h_n2_r
# Alkyne : C2H2 + 2.5( O2 + 3.76N2 ) = 2CO2 + H2O + 9.4N2
H_Product = 2*h_co2_p + h_h2o_p + 9.4*h_n2_p
H_Reactant = h_c2h2_r + 2.5*h_o2_r + 9.4*h_n2_r
plt.plot(ct, T_guess, '*', color = 'red')
# We shall plot for these 3 cases by this individually.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Solution to Problem 4 :
# For alkane : C(n)H(2n+2) + (3n+1)( O2 + 3.76N2 )/2 = nCO2 + (n+1)H2O + 1.88(3n+1)N2
n = 1
for n in range(1,3)
H_Product = n*h_co2_p + (n+1)*h_h2o_p + (5.64n+1.88)*h_n2_p
H_Reactant = n*h_cnh2n+2_r + (3n+1)*h_o2_r + (5.64n+1.88)*h_n2_r
plt.plot(ct, T_guess, '*', color = 'red')
Max_Rexn_Heat_Lost = H_Product - H_Reactant
return(Max_Rexn_Heat_Lost)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------