import math
from scipy.integrate import quad
# Variables
T_1 = 298.15; #[K] - standard reaction temperature
T_2 = 500; #[K] - Reaction temperature
P = 1; #[atm] - Pressure
a_CO2 = 5.316;
a_O2 = 6.085;
a_N2 = 6.903;
a_H2O = 7.700;
a_C3H8 = -0.966;
b_CO2 = 1.4285*10**(-2);
b_O2 = 0.3631*10**(-2);
b_N2 = -0.03753*10**(-2);
b_H2O = 0.04594*10**(-2);
b_C3H8 = 7.279*10**(-2);
c_CO2 = -0.8362*10**(-5);
c_O2 = -0.1709*10**(-5);
c_N2 = 0.1930*10**(-5);
c_H2O = 0.2521*10**(-5);
c_C3H8 = -3.755*10**(-5);
d_CO2 = 1.784*10**(-9);
d_O2 = 0.3133*10**(-9);
d_N2 = -0.6861*10**(-9);
d_H2O = -0.8587*10**(-9);
d_C3H8 = 7.580*10**(-9);
# The smath.tan(math.radiansard enthalpy of formation at 298.15 K is given by
delta_H_for_CO2 = -94.052; #[kcal/mol]
delta_H_for_C3H8 = -24.820; #[kcal/mol]
delta_H_for_H2O = -57.7979; #[kcal/mol]
# The reaction with stoichiometric amount of air is
# C3H8 + 5(O2 + 3.7N2) - 3CO2 + 4H2O + 18.8N2
# The reaction with 100% excess air is
# C3H8 + 10(O2 + 3.7N2) - 3CO2 + 4H2O + 5O2 + 37.6N2
# Calculations
# The smath.tan(math.radiansard enthalpy change of reaction at 298.15 K
delta_H_rkn_298 = 3*delta_H_for_CO2 + 4*delta_H_for_H2O - delta_H_for_C3H8;
# For exit stream
sum_ai_ni = 3*a_CO2 + 4*a_H2O + 5*a_O2 + 37.6*a_N2;
sum_bi_ni = 3*b_CO2 + 4*b_H2O + 5*b_O2 + 37.6*b_N2;
sum_ci_ni = 3*c_CO2 + 4*c_H2O + 5*c_O2 + 37.6*c_N2;
sum_di_ni = 3*d_CO2 + 4*d_H2O + 5*d_O2 + 37.6*d_N2;
# To raise the exit species from 298.15 to 500 K the enthalpy change is
def f1(T):
return sum_ai_ni+sum_bi_ni*T+sum_ci_ni*T**(2)+sum_di_ni*T**(3)
delta_H_rkn = quad(f1,T_1,T_2)[0]
delta_H_rkn = delta_H_rkn*10**(-3); #[kcal]
# Therefore per mole of fuel the heat exchange is
# Q = Heat exchange in step 1 + Heat exchange in step 2
Q = delta_H_rkn_298 + delta_H_rkn;
# Results
print " The heat transfer from the combustion chamber per mole of fuel is %f kcal (per mol of C3H8)"%(Q);
from scipy.optimize import fsolve
# Variables
T_1 = 298.15; #[K] - Smath.tan(math.radiansard reaction temperature
a_CO2 = 5.316;
a_H2O = 7.700;
a_O2 = 6.085;
a_C2H6 = 1.648;
b_CO2 = 1.4285*10**(-2);
b_H2O = 0.04595*10**(-2);
b_O2 = 0.3631*10**(-2);
b_C2H6 = 4.124*10**(-2);
c_CO2 = -0.8362*10**(-5);
c_H2O = 0.2521*10**(-5);
c_O2 = -0.1709*10**(-5);
c_C2H6 = -1.530*10**(-5);
d_CO2 = 1.784*10**(-9);
d_H2O = -0.8587*10**(-9);
d_O2 = 0.3133*10**(-9);
d_C2H6 = 1.740*10**(-9);
# The stabdard enthalpy of formation at 298.15 K is given by
delta_H_for_CO2 = -94.052; #[kcal/mol]
delta_H_for_C2H6 = -20.236; #[kcal/mol]
delta_H_for_H2O = -57.7979; #[kcal/mol]
# Calculations
# The reaction with stoichiometric amount of air is
# C2H6 + (7/2)O2 - 2CO2 + 3H2O
# The reaction with 4 mol of O2 and 10 mol CO2 is
# C2H6 + 4O2 + 10CO2 - 12H2O + 3H2O + 0.5O2
# The product consists of 12 mol of CO2, 3 mol of water vapour and 0.5 mol of oxygen
delta_H_rkn_298 = 2*delta_H_for_CO2 + 3*delta_H_for_H2O - delta_H_for_C2H6; #[kcal]
delta_H_rkn_298 = delta_H_rkn_298*10**(3); #[cal]
# For exit stream
sum_ai_ni = 12*a_CO2 + 3*a_H2O + 0.5*a_O2;
sum_bi_ni = 12*b_CO2 + 3*b_H2O + 0.5*b_O2;
sum_ci_ni = 12*c_CO2 + 3*c_H2O + 0.5*c_O2;
sum_di_ni = 12*d_CO2 + 3*d_H2O + 0.5*d_O2;
# From energy balance equation we get
# delta_H_rkn_298 + sum_ai_ni*(T_2 - T_1) + (sum_bi_ni/2)*(T_2**(2) - T_1**(2)) + (sum_ci_ni/3)*(T_2**(3) - T_1**(3)) + (sum_di_ni/4)*(T_2**(4) - T_1**(4))
# Solving above equation for T_2
def f(T_2):
return delta_H_rkn_298 +sum_ai_ni*(T_2-T_1)+(sum_bi_ni/2)*(T_2**(2)-T_1**(2))+(sum_ci_ni/3)*(T_2**(3)-T_1**(3))+(sum_di_ni/4)*(T_2**(4)-T_1**(4))
T_2 = fsolve(f,-1)
# Results
print " The adiabatic flame temperature is %f K"%(T_2);
# Variables
T_1 = 298.15; #[K] - Standard reaction temperature
# The reaction with theoritical air is
# CH4 + 2(O2 + 3.76N2) - CO2 + 2H20 + 7.52N2
# Calculations and Results
#(1)
n_product = (1 + 2 + 7.52); # Total number of moles of product
# The mole fraction of water vapour is
y_H2O = 2/(n_product);
print " 1).The mole fraction of water vapour is %f"%(y_H2O);
#(2)
delta_H_rkn_298 = -730*10**(3); #[J/mol]
C = 40; #[J/mol-K] - Average molar heat capacity
# From energy balance we have
# delta_H_rkn_298 + n_product*C(T_2 - T_1) = 0
T_2 = - delta_H_rkn_298/(n_product*C) + T_1; #[K]
T_max = T_2 - T_1;
print " 2).The maximum temperature rise of the exhaust gases is %f K"%(T_max);
from scipy.optimize import fsolve
# Variables
T_1 = 298.15; #[K] - Standiansard reaction temperature
# The standard enthalpy of formation at 298.15 K is given by
delta_H_for_CO2 = -94.052; #[kcal/mol]
delta_H_for_C8H18 = -59.780; #[kcal/mol]
delta_H_for_H2O = -57.7979; #[kcal/mol]
a_CO2 = 5.316;
a_H2O = 7.700;
a_N2 = 6.903;
b_CO2 = 1.4285*10**(-2);
b_H2O = 0.04595*10**(-2);
b_N2 = -0.03753*10**(-2);
c_CO2 = -0.8362*10**(-5);
c_H2O = 0.2521*10**(-5);
c_N2 = 0.1930*10**(-5);
d_CO2 = 1.784*10**(-9);
d_H2O = -0.8587*10**(-9);
d_N2 = -0.6861*10**(-9);
# Calculations and Results
#(a)
# The reaction with stoichiometric amount of air is
# C3H18 + 12.5(O2 + 3.76N2) - 8CO2 + 9H2O + 47N2
# The standard enthalpy change of reaction at 298.15 K is
delta_H_rkn_298 = 8*delta_H_for_CO2 + 9*delta_H_for_H2O - delta_H_for_C8H18; #[kcal]
delta_H_rkn_298 = delta_H_rkn_298*10**(3); #[cal]
# For exit stream
sum_ai_ni = 8*a_CO2 + 9*a_H2O + 47*a_N2;
sum_bi_ni = 8*b_CO2 + 9*b_H2O + 47*b_N2;
sum_ci_ni = 8*c_CO2 + 9*c_H2O + 47*c_N2;
sum_di_ni = 8*d_CO2 + 9*d_H2O + 47*d_N2;
# From energy balance equation we get
# delta_H_rkn_298 + sum_ai_ni*(T_2 - T_1) + (sum_bi_ni/2)*(T_2**(2) - T_1**(2)) + (sum_ci_ni/3)*(T_2**(3) - T_1**(3)) + (sum_di_ni/4)*(T_2**(4) - T_1**(4))
# Solving above equation for T_2
def f(T_2):
return delta_H_rkn_298 +sum_ai_ni*(T_2-T_1)+(sum_bi_ni/2)*(T_2**(2)-T_1**(2))+(sum_ci_ni/3)*(T_2**(3)-T_1**(3))+(sum_di_ni/4)*(T_2**(4)-T_1**(4))
T_2 = fsolve(f,-1)
print " 1).The adiabatic flame temperature is %f K"%(T_2);
#(2)
# The mean standard heat capacity of various components over the temperature range from 25 to 3000 C is
Cp_CO2 = 13.91; #[cal/mol-K]
Cp_H2O = 10.16; #[cal/mol-K]
Cp_O2 = 7.88; #[cal/mol-K]
Cp_N2 = 7.45; #[cal/mol-K]
# From energy balance equation we get
# delta_H_rkn_298 + (8*Cp_CO2 + 9*Cp_H2O + 47*Cp_N2)*(T_2_prime)
T_2_prime = - delta_H_rkn_298/(8*Cp_CO2 + 9*Cp_H2O + 47*Cp_N2); #[K]
print " 2).The adiabatic flame temperature is %f K"%(T_2_prime);
# The answer is correct. Please calculate it manually. Wrong answer is given in book.
# Variables
# N2 + 3H2 - 2NH3
T_1 = 700; #[K] - Reaction temperature
Max_adia_rise = 100; #/[K] - Maximum adiabatic rise in temperature
T_2 = T_1 + Max_adia_rise; #[K] -
delta_H_rkn_700 = -94.2; #[kJ] - Smath.tan(math.radiansard enthalpy of reaction at 700 K
delta_H_rkn_700 = delta_H_rkn_700*10**(3); #[J]
# The mean standard heat capacity of various components over the temperature range from 700 to 800 K is
Cp_N2 = 30.0; #[cal/mol-K]
Cp_H2 = 28.9; #[cal/mol-K]
Cp_NH3 = 49.2; #[cal/mol-K]
# Calculations
# The energy balance equation is
def f46(T):
return (sum_ni_Cpi_exit)*dT
# X*delta_H_rkn_700 + quad(f46,T_1,T_2)[0]
#At exit, let moles of NH3 = (1-X), moles of H2 = (3-3X), moles of NH3 = 2X . Therefore we have,
# delta_H_rkn_700*X + {(1-X)*Cp_N2 + (3-3X)*Cp_H2 + (2X)*Cp_NH3}*(T_2 - T_1)
# On simplification we get, 960.3*X = 116.7
X = 116.7/960.3;
# Results
print " The maximum allowable conversion fraction in the reactor is given by X = %f "%(X);
from scipy.optimize import fsolve
import math
from scipy.integrate import quad
# Variables
T_1 = 298.15; #[K] - standard reaction temperature
V = 2.0*10**(-3); #[m**(3)] - Volume of calorimeter
m = 10.; #[g] - Mass of liquid octane
Mol_wt = 114.; #[g/mol] - Molecular weight of octane
n = m/Mol_wt; #[mol] - No of moles of octane
R = 8.314; #[J/mol*K] - Universal gas constant
# The standard enthalpy of formation at 298.15 K is given by
delta_H_for_CO2 = -94.052; #[kcal/mol]
delta_H_for_C8H18 = -59.780; #[kcal/mol]
delta_H_for_H2O = -57.7979; #[kcal/mol]
# The standard molar heat capacity of various components in high temperature range from is given by
# Cp_H2O = 6.970 + 0.3464*10**(-2)*T - 0.04833*10**(-5)*T**(2);
# Cp_O2 = 6.732 + 0.1505*10**(-2)*T - 0.01791*10**(-5)*T**(2);
# Cp_CO2 = 18.036 - 4.474*10**(-5)*T - 158.08/(T**(1/2));
# Therefore we have
# Sum_ni_Cpi_exit = 249.09 + 0.04*T - 0.547*10**(-5)*T**(2) - 1264.64/(T**(1/2))
# The reaction with stoichiometric amount of oxygen is
# C8H18 + 12.5O2 - 8CO2 + 9H2O
# The reaction with 50% excess oxygen is
# C8H18 + 18.75O2 - 8CO2 +9H2O + 6.25O2
# Calculations
# The standard enthalpy change of reaction at 298.15 K is
delta_H_rkn_298 = 8*delta_H_for_CO2 + 9*delta_H_for_H2O - delta_H_for_C8H18; #[kcal]
delta_H_rkn_298 = delta_H_rkn_298*10**(3); #[cal]
# From the energy balance equation we get
def f10(T):
return (sum_ni_Cpi_exit)*dT
# delta_H_rkn_298 + quad(f10,T_1,T_2)[0]
# delta_H_rkn_298 + 249.09*(T_2 - T_1) + (0.04/2)*(T_2**(2) - T_1**(2)) - ((0.547*10**(-5))/3)*(T_2**(3)-T_1**(3)) - (1264.64*2)*(T_2**(1/2)-T_1**(1/2))
# Solving above equation for T_2
def f(T_2):
return delta_H_rkn_298 + 249.09*(T_2 - T_1) + (0.04/2)*(T_2**(2)-T_1**(2)) - ((0.547*10**(-5))/3)*(T_2**(3)-T_1**(3)) - (1264.64*2)*(T_2**(1./2)-T_1**(1./2))
T_2 = fsolve(f,1000)
# When 1 mol of octane reacts the final number of moles in the calorimeter is 23.25
# When n mol of octane reacts the final number of moles in the calorimeter is
n_total = n*23.25; #[mol]
# Thus maximum explosion pressure is given by
P = (n_total*R*T_2)/V; #[N/m**(2)]
P = P*10**(-5); #[bar]
# Results
print " The maximum explosion pressure inside the bomb calorimeter is %f bar"%(P);
from scipy.optimize import fsolve
import math
# Variables
T_1 = 400 + 273.15; #[K]
# SO2(g) + 1./2*(O2) (g) - SO3 (g)
a_SO2 = 6.157;
a_SO3 = 3.918;
a_O2 = 6.085;
a_N2 = 6.903;
b_SO2 = 1.384*10**(-2);
b_SO3 = 3.483*10**(-2);
b_O2 = 0.3631*10**(-2);
b_N2 = -0.03753*10**(-2);
c_SO2 = -0.9103*10**(-5);
c_SO3 = -2.675*10**(-5);
c_O2 = -0.01709*10**(-5);
c_N2 = 0.1930;
d_SO2 = 2.057*10**(-9);
d_SO3 = 7.744*10**(-9);
d_O2 = 0.3133*10**(-9);
d_N2 = -0.6861*10**(-9);
# Calculations
# At 400 C, from the given math.expressions
delta_H_rkn_T_1 = -22630.14 - 5.2815*T_1 + 0.9587*10**(-2)*T_1**(2) - 0.5598*10**(-5)*T_1**(3) + 1.3826*10**(-9)*T_1**(4); #[cal]
# delta_H_rkn_T_X (for X moles of SO2 reacted) = delta_H_rkn_T_1*X
# Let the number of moles at equilibrium be
# n_O2 = 9-0.5*X
# n_SO2 = 12-X
# n_SO3 = X
# n_N2 = 79
# Total moles at equilibrium = 100-0.5X
# Ky = y_SO3/(y_SO2*y_O2**(1./2))
# Ky = (X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))
# We know that K = Ky*Kp. Since P = 1 atm, therefore Ky = K
# Now we have to account for the heat required to raise 9-0.5*X mol of O2, 12-X mol of SO2, X mol of SO3 and 79 mol of N2 from T to ART
# sum_ni_Cp_i = (12-X)*(a + b*T + c*T**(2) + d*T**(3)) + (9-0.5*X)*(a + b*T + c*T**(2) + d*T**(3)) + X*(a + b*T + c*T**(2) + d*T**(3)) + 79*(a + b*T + c*T** (2) + d*T**(3))
# From energy balance equation we get
def f19(T):
return sum_ni_Cp_i
# delta_H_rkn_T_1 + quad(f19,T_1,T)[0]
# The above equation on simplification becomes
# (673.99-5.2815*X)*(T-T_1) + (16.91+1.9175*X)*(10**(-2)/2)*(T**(2)-T_1**(2)) + (2.79-1.6793*X)*(10**(-5)/3)*(T**(3)-T_1**(3)) + (-26.70+5.5304*X)*(10**(-9) /4)*(T**(4)-T_1**(4)) = delta_H_rkn_T_1*X
# Let us assume a temperature, say
T = 800; #[K]
fault = 10;
def f(X):
return K - (X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))
def f1(X):
return (673.99-5.2815*X)*(T-T_1)+(16.91+1.9175*X)*(10**(-2)/2)*(T**(2)-T_1**(2))+(2.79-1.6793*X)*(10**(-5)/3)*(T**(3)-T_1**(3))+(-26.70+5.5304*X)*(10**(-9)/4)*(T**(4)-T_1**(4))+delta_H_rkn_T_1*X
while(fault>0.01):
K = math.exp(3.87 + (11389.10/T) - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3));
X1 = fsolve(f,0.1)
X2 = fsolve(f1,1)
fault = abs(X1-X2);
T = T + 0.01;
# Results
print " The moles of SO2 reacted are %f mol"%(X1);
print " The adiabatic reaction temperature is %f K"%(T);