Challenge

Week 3 - Adiabatic Flame Temperature calculation

Calculation of Adiabatic Flame Temperature Various Chemical Reactions

Aim: Calculation of AFT using python and cantera for different chemical reactions.

Objective:

  • To study the effect of equivalence ratio on the Adiabatic flame temperature of different chemical reactions.
  • To program the python program for calculation of AFT for different equivalence ratio and compare it with cantera.
  • To calculate the AFT after heat loss for Ethane, Ethene and Ethyne in constant pressure conditions by using python program.
  • To compare the AFT for Ethane, Ethene and Ethyne in single plot.
  • To calculate the AFT for different carbon atom and compare with bar graph using python program.

Introduction: -

When the combustion takes place, the energy will release. If there is no heat loss chamber, then that chamber is called adiabatic in nature and corresponding temperature of product is called ‘Adiabatic Flame Temperature’. This temperature can be seen at constant pressure and constant volume. As there is no heat loss in the process from the chamber the gas temperature gets increase indefinitely. It is important to calculate the Adiabatic flame temperature of reaction to know the chemical process.

The combustion of natural gas can cause release of heat at high temperature and pressure depending upon the reactant present in chemical reactions. Most of the chemical reaction consist of carbon atoms which reacts with oxygen and nitrogen present in the atmosphere to create mostly water and carbon di-oxide. Rather than this two product there are other products which are uncertain created in the chemical reactions. The stoichiometric reaction is something which`CH_4+2/ϕ (O_2+3.76 N_2 )→(4/ϕ-3)CO_2+2H_2 O+(4-4/ϕ ) CO_2+7.52/ϕ N_2` have also called as balanced chemical reaction, where the number of atoms for each of reactant and product are perfectly balanced. In actual conditions, having stoichiometric reaction is uncertain hence the reaction will be either lean or rich. The condition of lean and rich reaction depend upon the amount of fuel and amount of oxidizer present in reactions. To differentiate the chemical reaction from lean to rich or stoichiometric, equivalence ratio term is used.

The stoichiometric reaction for methane-air is given as:

this reaction contains exact amount of fuel and oxidizer for complete combustion process. This reaction causes to generate highest flame temperature as all the energy is used to create the heat. The reaction is called rich when there is less oxidizer present in the chemical reaction. The equivalence ratio is defined as the ration of actual air-fuel mixture to the stoichiometric ratio. If ϕ<1 the mixture is considered as lean mixture and if ϕ>1 then the mixture is considered as rich mixture. For lean mixture the chemical reaction is given as:

`CH_4+2/∅ (O_2+3.76 N_2 ) →CO_2+2H_2 O+(2/ϕ-2 ) O_2+(7.52/ϕ) N_2`

this reaction contains exact amount of fuel and oxidizer for complete combustion process. This reaction causes to generate highest flame temperature as all the energy is used to create the heat. The reaction is called rich when there is less oxidizer present in the chemical reaction. The equivalence ratio is defined as the ration of actual air-fuel mixture to the stoichiometric ratio. If ϕ<1 the mixture is considered as lean mixture and if ϕ>1 then the mixture is considered as rich mixture. For lean mixture the chemical reaction is given as:

`CH_4+2/∅ (O_2+3.76 N_2 ) →CO_2+2H_2 O+(2/ϕ-2 ) O_2+(7.52/ϕ) N_2`

Similarly, for rich mixture the chemical reaction is given as:

`CH_4+2/ϕ (O_2+3.76 N_2 )→(4/ϕ-3)CO_2+2H_2 O+(4-4/ϕ ) CO_2+7.52/ϕ N_2`

Solution Methodology: -

The calculation of AFT for different scenario is considered in the solution. The solution has been divided in 4 number of cases.

Case 1: - Calculation of AFT for different equivalence ratio and its comparison

Case 2: - Calculation of AFT for constant pressure chamber with heat loss factor of 0.35

Case 3: - Calculation of AFT for different Fuel type i.e. Ethane, Ethene and Ethyne with heat loss factor of 0.35.

Case 4: - Calculation of AFT for different carbon atom reaction considering Methane, Ethane and propane gas reactions.

For calculation of AFT same strategy is used in which flame temperature is calculating from the Enthalpy of reactants and products. To calculate the enthalpy, it required polynomial functions from the NASA data. The polynomial is given as:

`h(T)=(a1+ a2*(T/2)+a3*(T^2/3)+a4*(T^3/4)+a5*(T^4/5)+a6*(T/6))*R*T`

Where

h = enthalpy

ai = coefficient of each species

T = Temperature

R = Gas constant

The coefficient of each species can be extracted from gri30 file as thermos.dat file. This value can be used to for reactant side also to the product side. It is important to consider at which this species is interacting with each other. The reactants side species are reacting at lower temperature as compared to product side. The AFT can be calculated using Newton Raphson iterative technique in which specific value of Temperature is guessed and will be iterate until the convergence is reached. The equation is given as:

`T_(New)=T_guess-α [f(T_guess )/(f^' (T_guess ) )]`

where,

Tnew = New value of Temperature after every iteration

Tguess = Initial guess temperature

alpha = Relaxation factor (<1 under relaxed, >1 over relaxed)

# Calculation of AFT of Methane Air Combustion for different equivalence Ratio using Constant Volume Chamber
# Written by Shubham K. Chaudhari
"""
Specification of Reaction used in the Program
Stoichiometric Reactions
CH4 + 2(O2+3.76 N2) = CO2 + 2H20 + 7.52 N2 + O2 + CO

Lean Mixture reaction (phi<1)
CH4 + (2/phi)(O2+3.76 N2) = CO2 + 2H20 + (7.52/phi) N2 + (2*(1-phi)/phi) O2 + CO

Rich Mixture (Phi>1)
CH4 + (2/phi)(O2+3.76 N2) = (4/phi-3)CO2 + 2H20 + (7.52/phi) N2 + O2 + (4-4/phi) CO

"""

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

# Defining funciton of Constant for calculating Enthaply from NASA Equation

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

# Defining coefficient from the thermo.30.dat file

# Reactants Coefficients
ch4_co_effs_l = [5.14987613E+00, -1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11, -1.02466476E+04,
                -4.64130376E+00]
o2_co_effs_l =  [3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03,
                3.65767573E+00]
n2_co_effs_l =  [0.03298677E+02, 0.14082404E-02, -0.03963222E-04, 0.05641515E-07, -0.02444854E-10, -0.10208999E+04,
                0.03950372E+02]

# Product Coefficients
co2_co_effs_h = [3.85746029E+00, 4.41437026E-03, -2.21481404E-06, 5.23490188E-10, -4.72084164E-14, -4.87591660E+04,
                2.27163806E+00]
h2o_co_effs_h = [3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04,
                4.96677010E+00]
n2_co_effs_h =  [0.02926640E+02, 0.14879768E-02,  -0.05684760E-05, 0.10097038E-09, -0.06753351E-13, -0.09227977E+04,
                0.05980528E+02]
o2_co_effs_h = [3.28253784E+00, 1.48308754E-03, -7.57966669E-07,  2.09470555E-10, -2.16717794E-14, -1.08845772E+03,
               5.45323129E+00]

# Defining of Moles of Air and Fuel
m_of_fuel = 1
m_of_air = np.linspace(2,10,num=50)
m_of_st_air = 2

# Stoichiometric condition
st_cond = m_of_fuel/m_of_st_air
# Actual Condition of
act_cond = m_of_fuel/m_of_air

# Using Numpy for storing the value of Temperature and equivalence ratio
AFT_stored = phi_stored = np.array([])

# Calculation of Enthalpy and Number of Moles in Product side & Reactant side
for phi in (act_cond/st_cond):

    def cv_func(T):
        R = 8.314
        Tstd = 298.15

        h_co2_p = h(T,co2_co_effs_h)
        h_n2_p =  h(T,n2_co_effs_h)
        h_h2o_p = h(T,h2o_co_effs_h)
        h_o2_p = h(T,o2_co_effs_h)
        h_ch4_r = h(Tstd,ch4_co_effs_l)
        h_o2_r = h(Tstd,o2_co_effs_l)
        h_n2_r = h(Tstd,n2_co_effs_l)

        # Calculation of Enthalpy and No. of Moles at Reactant Side
        H_React = h_ch4_r + ((m_of_st_air/phi)*h_o2_r) + ((m_of_st_air/phi)*3.76*h_n2_r)
        n_React = 1 + (m_of_st_air/phi) + (m_of_st_air/phi)*3.76

        # Calculation of Enthalpy and No. of Moles at Product side
        H_Prodt = (h_co2_p + 2*h_h2o_p + ((m_of_st_air/phi)-2)*h_o2_p) + (m_of_st_air/phi*3.76*h_n2_p)
        n_Prodt = 1 + 2 + ((m_of_st_air/phi)-2) + ((m_of_st_air)*3.76)

        return (H_React-H_Prodt) - (R*(n_React*Tstd - n_Prodt*T))

    def f_number(T):
        return (cv_func(T+1e-6) - cv_func(T))/(1e-6)
    tol = 1e-6
    T_guess = 1500
    iter = 0
    alpha = 0.1

    while (abs((cv_func(T_guess)))>tol):
        T_guess = T_guess - alpha*(cv_func(T_guess))/f_number(T_guess)
        iter = iter + 1

    AFT_stored = np.append(AFT_stored,T_guess)
    phi_stored = np.append(phi_stored,phi)

    print('Equivalence Ratio=' ,'%.2f'%phi)
    print('AFT(Cv)=',T_guess,'k')

print('--------------------------------------------------------------------------------------')

# Calculation of AFT using Cantera
print(' ')
print('AFT Using Cantera')
gas = ct.Solution('gri30.xml')
AFT_stored_Can = phi_stored_Can = np.array([])

for phi in (act_cond/st_cond):
    gas.TPX = 298.15,101325, {'CH4': m_of_fuel, 'O2': (m_of_st_air/phi), 'N2': (m_of_st_air/phi)*3.76}
    gas.equilibrate('UV', solver='auto')
    AFT_stored_Can = np.append(AFT_stored_Can, gas.T)
    phi_stored_Can = np.append(phi_stored_Can, phi)
    print('Equivalence Ratio=', '%f' %phi)
    print('AFT(Cv)=', gas.T, 'k')

# Plotting of Solution
plt.plot(phi_stored_Can, AFT_stored, label='Python_Program', color='b')
plt.scatter(phi_stored, AFT_stored, color='b')
plt.plot(phi_stored_Can, AFT_stored_Can, label='Cantera Result', color='r')
plt.scatter(phi_stored_Can, AFT_stored_Can, color='r')
plt.xlabel('Equivalence Ratio')
plt.ylabel('AFT')
plt.title('AFT(k) Vs Equivalence Ratio')
plt.legend(loc='lower right')
plt.show()

Resutls: -

1) Comparison of Python and Cantera Code on AFT

2) Program Output

Case 2: - Calculation of AFT for constant pressure chamber with heat loss factor of 0.35

# Calculation of AFT for different working condition
# Case1 - Effect of Loss of Heat on AFT In Constant Pressure Reactor
# Case2 - Calculation of AFT Temperature for Alkane, Alkene and Alkyne without any heat loss factor
# Case3 - Calculation of AFT Temperature with variation of Number of carbon Atoms without any heat loss factor


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

# Defining function of Constant for calculating Enthalpy from NASA Equation

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

# Defining coefficient from the thermo.30.dat file

# Reactants Coefficients
ch4_co_effs_l = [5.14987613E+00, -1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11, -1.02466476E+04,
                 -4.64130376E+00]
c2h6_co_effs_l = [4.29142492E+00, -5.50154270E-03, 5.99438288E-05, -7.08466285E-08, 2.68685771E-11, -1.15222055E+04,
                  2.66682316E+00]
c3h8_co_effs_l = [0.93355381E+00, 0.26424579E-01, 0.61059727E-05, -0.21977499E-07, 0.95149253E-11, -0.13958520E+05,
                  0.19201691E+02]
c2h4_co_effs_l = [3.95920148E+00, -7.57052247E-03, 5.70990292E-05, -6.91588753E-08, 2.69884373E-11, 5.08977593E+03,
                  4.09733096E+00]
c2h2_co_effs_l = [8.08681094E-01, 2.33615629E-02, -3.55171815E-05, 2.80152437E-08, -8.50072974E-12, 2.64289807E+04,
                  1.39397051E+01]
o2_co_effs_l = [3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03,
                 3.65767573E+00]
n2_co_effs_l = [0.03298677E+02, 0.14082404E-02, -0.03963222E-04, 0.05641515E-07, -0.02444854E-10, -0.10208999E+04,
                 0.03950372E+02]

# Product Coefficients
co2_co_effs_h = [3.85746029E+00, 4.41437026E-03, -2.21481404E-06, 5.23490188E-10, -4.72084164E-14, -4.87591660E+04,
                 2.27163806E+00]
h2o_co_effs_h = [3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04,
                 4.96677010E+00]
n2_co_effs_h = [0.02926640E+02, 0.14879768E-02,  -0.05684760E-05, 0.10097038E-09, -0.06753351E-13, -0.09227977E+04,
                 0.05980528E+02]

U = 500
R = 8.314
Tstd = 298.15
A = 1

# Case1 - Effect of Loss of Heat on AFT In Constant Pressure Reactor

'''
The Reactor is working on STP condition and 0.35 Heat loss is calculated from AFT Temperature
The Stoichiometric Reaction is consider for the Calculation i.e
CH4 + 2(O2+3.76 N2) = CO2 + 2H20 + 7.52 N2 + O2 + CO
'''

# Consideration of Heat loss factor for case 1
H_loss = 0.35
print('Methane:')
def func_ch4(T):

    h_ch4_r = h(Tstd,ch4_co_effs_l)
    h_o2_r = h(Tstd,o2_co_effs_l)
    h_n2_r = h(Tstd,n2_co_effs_l)

    # Enthalpy for Reactants of Chemical reaction
    H_react_ch4 = h_ch4_r + (2*h_o2_r) + (7.52*h_n2_r)

    h_co2_p = h(T,co2_co_effs_h)
    h_h20_p = h(T,h2o_co_effs_h)
    h_n2_p = h(T,n2_co_effs_h)

    # Enthalpy for Products of Chemical Reaction
    H_prodt_ch4 = (h_co2_p + 2* h_h20_p + 7.52*h_n2_p)

    max_heat_loss = U*A*(T-Tstd)

    return (H_react_ch4 - H_prodt_ch4) - H_loss*(max_heat_loss)

def nd_ch4(T):

    return (func_ch4(T+1e-6)-func_ch4(T))/(1e-6)

T_guess_ch4 = 1500
tol = 1e-6
alpha = 1
iter = 0

while (abs(func_ch4(T_guess_ch4))>tol):
    T_guess_ch4 = T_guess_ch4 - alpha*(func_ch4(T_guess_ch4))/nd_ch4(T_guess_ch4)
    iter = iter + 1

print('AFT of Methane with heat loss of 0.35 =', T_guess_ch4,'k')

print('----------------------------------------------------------------------------------------------------')

In this case we are considering heat loss phenomenon at a constant pressure chamber. The specific reaction which has been used in this case will be similar to stoichiometric reaction of methane-air.

The heat loss factor is considered as 0.35 and another variable Heat_loss_stored is used to determine the heat loss at the specific tempeature. Similar Newton Raphson method is used to calcuate the guessed tempeature at 0.35 heat loss. The result for the program is given as:

The temperature of AFT after heat loss of 0.35 at constant pressure is around 1744.05 Kelvin.

Case 3: - Calculation of AFT for different Fuel type i.e. Ethane, Ethene and Ethyne with heat loss factor of 0.35.

In this case the AFT for different fuel type such as Alkane, Alkene and Alkyne is considered. The respective fuel type for reaction is given as:

1) Ethane

`C_2 H_6+3.5(O_2+3.76N_2 )→2CO_2+3H_2 O+3.5(3.76N_2)`

2) Ethene

`C_2 H_4+3(O_2+3.76N_2 )→2CO_2+2H_2 O+3(3.76N_2)`

3) Ethyne

`C_2 H_2+2.5(O_2+3.76N_2 )→2CO_2+H_2 O+2.5(3.76N_2)`

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

# Defining function of Constant for calculating Enthalpy from NASA Equation

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

# Defining coefficient from the thermo.30.dat file

# Reactants Coefficients
ch4_co_effs_l = [5.14987613E+00, -1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11, -1.02466476E+04,
                 -4.64130376E+00]
c2h6_co_effs_l = [4.29142492E+00, -5.50154270E-03, 5.99438288E-05, -7.08466285E-08, 2.68685771E-11, -1.15222055E+04,
                  2.66682316E+00]
c3h8_co_effs_l = [0.93355381E+00, 0.26424579E-01, 0.61059727E-05, -0.21977499E-07, 0.95149253E-11, -0.13958520E+05,
                  0.19201691E+02]
c2h4_co_effs_l = [3.95920148E+00, -7.57052247E-03, 5.70990292E-05, -6.91588753E-08, 2.69884373E-11, 5.08977593E+03,
                  4.09733096E+00]
c2h2_co_effs_l = [8.08681094E-01, 2.33615629E-02, -3.55171815E-05, 2.80152437E-08, -8.50072974E-12, 2.64289807E+04,
                  1.39397051E+01]
o2_co_effs_l = [3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03,
                3.65767573E+00]
n2_co_effs_l = [0.03298677E+02, 0.14082404E-02, -0.03963222E-04, 0.05641515E-07, -0.02444854E-10, -0.10208999E+04,
                0.03950372E+02]

# Product Coefficients
co2_co_effs_h = [3.85746029E+00, 4.41437026E-03, -2.21481404E-06, 5.23490188E-10, -4.72084164E-14, -4.87591660E+04,
                 2.27163806E+00]
h2o_co_effs_h = [3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04,
                 4.96677010E+00]
n2_co_effs_h = [0.02926640E+02, 0.14879768E-02,  -0.05684760E-05, 0.10097038E-09, -0.06753351E-13, -0.09227977E+04,
                0.05980528E+02]

U = 500
R = 8.314
Tstd = 298.15
A = 1
alpha = 1
print('Case 2')
# Case2 - Calculation of AFT Temperature for Alkane, Alkene and Alkyne with any heat loss factor
# In this case Alkane(Ethane), Alkene(Ethene) and Alkyne(Ethyne) are considered.
'''
Chemical Reaction for Ethane is given as:
C2H6 + 3.5(O2+3.76N2) ---> 2CO2 + 3H2O + 3.5(3.76N2)

Chemical Reaction for Ethene is given as:
C2H4 + 3(O2 + 3.76 N2) ---> 2CO2 + 3H2O + 3(3.76 N2)

Chemical Reaction for Ethyne is given as:
C2H2 + 2.5(O2 + 3.76 N2) ---> 2CO2 + H20 + 2.5(3.76 N2)
'''

# Consideration of Array for storing the value of AFT and heat loss:
T_Ethane = T_Ethene = T_Ethyne = H_loss_stored = np.array([])

# Creation of Path to plot the comparison of Temperature of Ethane, Ethene and Ethyne
for H_loss in np.linspace(0,1,num = 11):
    H_loss_stored = np.append(H_loss_stored,H_loss)
    def func_c2h6(T):
        # Defining Reactants side
        h_c2h6_r = h(Tstd,c2h6_co_effs_l)
        h_o2_r = h(Tstd,o2_co_effs_l)
        h_n2_r = h(Tstd,n2_co_effs_l)

        # Defining Product side
        h_co2_p = h(T,co2_co_effs_h)
        h_h20_p = h(T,h2o_co_effs_h)
        h_n2_p = h(T,n2_co_effs_h)

        # Calculation of Enthalpy Reactants
        H_react_c2h6 = h_c2h6_r + (3.5*h_o2_r) + (13.16*h_n2_r)

        # Calculation of Ethanlpy Products
        H_prodt_c2h6 = (2*h_co2_p + 3* h_h20_p + 13.16*h_n2_p)

        max_heat_loss = U*A*(T-Tstd)

        return (H_react_c2h6 - H_prodt_c2h6) - H_loss*(max_heat_loss)

    def func_c2h4(T):
        # Defining Reactants side
        h_c2h4_r = h(Tstd,c2h4_co_effs_l)
        h_o2_r = h(Tstd,o2_co_effs_l)
        h_n2_r = h(Tstd,n2_co_effs_l)

        # Defining Product side
        h_co2_p = h(T,co2_co_effs_h)
        h_h20_p = h(T,h2o_co_effs_h)
        h_n2_p = h(T,n2_co_effs_h)

        # Calculation of Enthalpy Reactants
        H_react_c2h4 = h_c2h4_r + (3*h_o2_r) + (11.28*h_n2_r)

        # Calculation of Ethanlpy Products
        H_prodt_c2h4 = (2*h_co2_p + 2*h_h20_p + 11.28*h_n2_p)

        max_heat_loss = U*A*(T-Tstd)

        return (H_react_c2h4 - H_prodt_c2h4) - H_loss*(max_heat_loss)

    def func_c2h2(T):
        # Defining Reactants side
        h_c2h2_r = h(Tstd,c2h2_co_effs_l)
        h_o2_r = h(Tstd,o2_co_effs_l)
        h_n2_r = h(Tstd,n2_co_effs_l)

        # Defining Product side
        h_co2_p = h(T,co2_co_effs_h)
        h_h20_p = h(T,h2o_co_effs_h)
        h_n2_p = h(T,n2_co_effs_h)

        # Calculation of Enthalpy Reactants
        H_react_c2h2 = h_c2h2_r + (2.5*h_o2_r) + (9.3*h_n2_r)

        # Calculation of Ethanlpy Products
        H_prodt_c2h2 = (2*h_co2_p + 1* h_h20_p + 9.3*h_n2_p)

        max_heat_loss = U*A*(T-Tstd)

        return (H_react_c2h2 - H_prodt_c2h2) - H_loss*(max_heat_loss)

    # Defining Numerical Derivatives of Temperature

    def nd_c2h6(T):
        return (func_c2h6(T+1e-6)-func_c2h6(T))/(1e-6)


    def nd_c2h4(T):
        return (func_c2h4(T+1e-6)-func_c2h4(T))/(1e-6)


    def nd_c2h2(T):
        return (func_c2h2(T+1e-6)-func_c2h2(T))/(1e-6)

    # Defining Initial Guess for all Reactions

    T_guess_c2h6 = T_guess_c2h4 = T_guess_c2h2 = 1500

    tol = 1e-6
    iter = 0
    aplha = 1

    while (abs(func_c2h6(T_guess_c2h6))>tol):
        T_guess_c2h6 = T_guess_c2h6 - alpha*(func_c2h6(T_guess_c2h6))/nd_c2h6(T_guess_c2h6)
        iter = iter + 1

    T_Ethane = np.append(T_Ethane,T_guess_c2h6)



    while (abs(func_c2h4(T_guess_c2h4))>tol):
        T_guess_c2h4 = T_guess_c2h4 - alpha*(func_c2h4(T_guess_c2h4))/nd_c2h4(T_guess_c2h4)
        iter = iter + 1

    T_Ethene = np.append(T_Ethene,T_guess_c2h4)


    while (abs(func_c2h2(T_guess_c2h2))>tol):
        T_guess_c2h2 = T_guess_c2h2 - alpha*(func_c2h2(T_guess_c2h2))/nd_c2h2(T_guess_c2h2)
        iter = iter + 1

    T_Ethyne = np.append(T_Ethyne,T_guess_c2h2)

    print('AFT for Ethane (K):',T_guess_c2h6)
    print('AFT for Ethene (K):',T_guess_c2h4)
    print('AFT for Ethyne (K):',T_guess_c2h2)
    print('--------------------------------------------------------------------------------')


plt.figure(1)
plt.xlabel('Heat Loss')
plt.ylabel('AFT (k)')
plt.title('Heat Loss Vs AFT (K)')
plt.plot(H_loss_stored,T_Ethane,'*',label = 'Ethane',color = 'b')
plt.plot(H_loss_stored,T_Ethene,'*',label = 'Ethene',color = 'r')
plt.plot(H_loss_stored,T_Ethyne,'*',label = 'Ethyne',color = 'g')
plt.legend()
plt.show()

Results

1) Plot of Fuel Type for AFT

2) Program Outcome

Observation: -

1) The heat loss in AFT is inversely proportional, increase in heat loss cause decrease in AFT.

2) The maximum tempeature is reached for Ethyne for the no heat loss value as compared to Ethane and Ethene.

Case 4 : - Calculation of AFT for different carbon atom reaction considering Methane, Ethane and propane gas reactions.

In this case chemical reaction in which the gas fuel is consider as type of carbon atom from 1 to 3. The chemical reaction of Methan and Ethane are done in case 1 and 3 respectively only the calculation of AFT for propane gas need to be done.

The chemical reaction for propane gas is given as:

`C_2 H_8+5(O_2+3.76N_2 )→3CO_2+4H_2 O+5(3.76N_2)`

# Calculation of AFT for different working condition
# Case1 - Effect of Loss of Heat on AFT In Constant Pressure Reactor
# Case2 - Calculation of AFT Temperature for Alkane, Alkene and Alkyne without any heat loss factor
# Case3 - Calculation of AFT Temperature with variation of Number of carbon Atoms without any heat loss factor

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

# Defining function of Constant for calculating Enthalpy from NASA Equation

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

# Defining coefficient from the thermo.30.dat file

# Reactants Coefficients
ch4_co_effs_l = [5.14987613E+00, -1.36709788E-02, 4.91800599E-05, -4.84743026E-08, 1.66693956E-11, -1.02466476E+04,
                 -4.64130376E+00]
c2h6_co_effs_l = [4.29142492E+00, -5.50154270E-03, 5.99438288E-05, -7.08466285E-08, 2.68685771E-11, -1.15222055E+04,
                  2.66682316E+00]
c3h8_co_effs_l = [0.93355381E+00, 0.26424579E-01, 0.61059727E-05, -0.21977499E-07, 0.95149253E-11, -0.13958520E+05,
                  0.19201691E+02]
c2h4_co_effs_l = [3.95920148E+00, -7.57052247E-03, 5.70990292E-05, -6.91588753E-08, 2.69884373E-11, 5.08977593E+03,
                  4.09733096E+00]
c2h2_co_effs_l = [8.08681094E-01, 2.33615629E-02, -3.55171815E-05, 2.80152437E-08, -8.50072974E-12, 2.64289807E+04,
                  1.39397051E+01]
o2_co_effs_l = [3.78245636E+00, -2.99673416E-03, 9.84730201E-06, -9.68129509E-09, 3.24372837E-12, -1.06394356E+03,
                3.65767573E+00]
n2_co_effs_l = [0.03298677E+02, 0.14082404E-02, -0.03963222E-04, 0.05641515E-07, -0.02444854E-10, -0.10208999E+04,
                0.03950372E+02]

# Product Coefficients
co2_co_effs_h = [3.85746029E+00, 4.41437026E-03, -2.21481404E-06, 5.23490188E-10, -4.72084164E-14, -4.87591660E+04,
                 2.27163806E+00]
h2o_co_effs_h = [3.03399249E+00, 2.17691804E-03, -1.64072518E-07, -9.70419870E-11, 1.68200992E-14, -3.00042971E+04,
                 4.96677010E+00]
n2_co_effs_h = [0.02926640E+02, 0.14879768E-02,  -0.05684760E-05, 0.10097038E-09, -0.06753351E-13, -0.09227977E+04,
                0.05980528E+02]

U = 500
R = 8.314
Tstd = 298.15
A = 1
alpha = 1

print('Case 3')
# Case3 - Calculation of AFT Temperature with variation of Number of carbon Atoms without any heat loss factor

'''
In this code structure The number of carbon atom has been varied for Methane, Ethane and Propane gas.

The Methane gas Reaction for combustion phenomenon is given as:
CH4 + 2(O2 + 3.76 N2) ---> CO2 + 2H20 + 2(3.76N2)

The Ethane gas Reaction for combustion phenomenon is given as:
C2H4 + 3.5(O2 + 3.76 N2) ---> 2CO2 + 3H2O + 3.5(3.76N2)

The Propane gas Reaction for combustion phenomenon is given as:
C3H8 + 5(O2 + 3.76 N2) ---> 3CO2 + 4H2O + 5(3.76N2)
'''

# Considering Heat loss for this case as Zero
H_loss = 0

def func_ch4(T):
    h_ch4_r = h(Tstd,ch4_co_effs_l)
    h_o2_r = h(Tstd,o2_co_effs_l)
    h_n2_r = h(Tstd,n2_co_effs_l)

    # Enthalpy for Reactants of Chemical reaction
    H_react_ch4 = h_ch4_r + (2*h_o2_r) + (7.52*h_n2_r)

    h_co2_p = h(T,co2_co_effs_h)
    h_h20_p = h(T,h2o_co_effs_h)
    h_n2_p = h(T,n2_co_effs_h)

    # Enthalpy for Products of Chemical Reaction
    H_prodt_ch4 = (h_co2_p + 2* h_h20_p + 7.52*h_n2_p)

    max_heat_loss = U*A*(T-Tstd)

    return (H_react_ch4 - H_prodt_ch4) - H_loss*(max_heat_loss)

def func_c2h6(T):
    # Defining Reactants side
    h_c2h6_r = h(Tstd,c2h6_co_effs_l)
    h_o2_r = h(Tstd,o2_co_effs_l)
    h_n2_r = h(Tstd,n2_co_effs_l)

    # Defining Product side
    h_co2_p = h(T,co2_co_effs_h)
    h_h20_p = h(T,h2o_co_effs_h)
    h_n2_p = h(T,n2_co_effs_h)

    # Calculation of Enthalpy Reactants
    H_react_c2h6 = h_c2h6_r + (3.5*h_o2_r) + (13.16*h_n2_r)

    # Calculation of Enthalpy Products
    H_prodt_c2h6 = (2*h_co2_p + 3* h_h20_p + 13.16*h_n2_p)

    max_heat_loss = U*A*(T-Tstd)

    return (H_react_c2h6 - H_prodt_c2h6) - H_loss*(max_heat_loss)

def func_c3h8(T):
    # Defining Reactants Side
    h_c3h8_r = h(Tstd,c3h8_co_effs_l)
    h_o2_r = h(Tstd,o2_co_effs_l)
    h_n2_r = h(Tstd,n2_co_effs_l)

    # Defining Product side
    h_co2_p = h(T,co2_co_effs_h)
    h_h20_p = h(T,h2o_co_effs_h)
    h_n2_p = h(T,n2_co_effs_h)

    # Calculation of Ethalpy Reactants
    H_react_c3h8 = h_c3h8_r + (5*h_o2_r) + (18.8*h_n2_r)

    # Calculation of Enthalpy Product
    H_prodt_c3h8 = (3*h_co2_p + 4*h_h20_p + 18.8*h_n2_p)

    max_heat_loss = U*A*(T - Tstd)

    return (H_react_c3h8 - H_prodt_c3h8) - H_loss*(max_heat_loss)

    # Defining Numerical Derivatives of Temperature

def nd_ch4(T):
    return (func_ch4(T+1e-6)-func_ch4(T))/(1e-6)


def nd_c2h6(T):
    return (func_c2h6(T+1e-6)-func_c2h6(T))/(1e-6)


def nd_c3h8(T):
    return (func_c3h8(T+1e-6)-func_c3h8(T))/(1e-6)

    # Defining Initial Guess for all Reactions

T_guess_ch4 = T_guess_c2h6 = T_guess_c3h8 = 1500

tol = 1e-6
iter = 0
aplha = 1

while (abs(func_ch4(T_guess_ch4))>tol):
    T_guess_ch4 = T_guess_ch4 - alpha*(func_ch4(T_guess_ch4))/nd_ch4(T_guess_ch4)
    iter = iter + 1


while (abs(func_c2h6(T_guess_c2h6))>tol):
    T_guess_c2h6 = T_guess_c2h6 - alpha*(func_c2h6(T_guess_c2h6))/nd_c2h6(T_guess_c2h6)
    iter = iter + 1


while (abs(func_c3h8(T_guess_c3h8))>tol):
    T_guess_c3h8 = T_guess_c3h8 - alpha*(func_c3h8(T_guess_c3h8))/nd_c3h8(T_guess_c3h8)
    iter = iter + 1

print('AFT for Methane (K):',T_guess_ch4)
print('AFT for Ethane (K):',T_guess_c2h6)
print('AFT for Propane (K):',T_guess_c3h8)

temp = (T_guess_ch4,T_guess_c2h6,T_guess_c3h8)

temp = np.array(temp)
print(temp)
plt.figure(2)
plt.bar(['CH4 = 1','C2H6 = 2','C3H8 = 3'],temp)
plt.ylabel('AFT')
plt.xlabel('Number of Atoms')
plt.title('AFT Vs Fuel Types')
plt.show()

Result: -

1) Bar Graph for carbon atoms

2) Program outcome

Observations:

1) From above bar graph it is seen that increase carbon atom will have increased AFT.

2) The changes in the AFT from different carbon atom are not varied in much difference.

Link for Program

https://drive.google.com/file/d/1vy6c-0Ny3lJptgEcSehMSXMU-tDI4MrS/view?usp=sharing

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.