import math
eps_e = 0.27 # Constant
P = 1.0 # Atmospheric pressure in bar
K = (4*eps_e**2*P)/(1-eps_e**2)
P1 = 100.0/760.0 # Pressure in Pa
eps_e_1 = math.sqrt((K/P1)/(4.0+(K/P1)))
T1 = 318.0 # Temperature in K
T2 = 298.0# Temperature in K
R = 8.3143 # Gas constant
K1 = 0.664 # dissociation constant at 318K
K2 = 0.141# dissociation constant at 298K
dH = 2.30*R*((T1*T2)/(T1-T2))*(math.log10(K1/K2))
print "\n Example 16.2\n"
print "\n K is ",K ," atm"
print "\n Epsilon is ",eps_e_1
print "\n The heat of reaction is ",dH ," kJ/kg mol"
#The answers vary due to round off error
import math
v1 = 1.0 # Assumed
v2 = v1# Assumed
v3 = v2 # Assumed
v4 = v2# Assumed
e = 0.56 # Degree of reaction
P = 1.0 # Dummy
T = 1200.0 # Reaction temperature in K
R = 8.3143 # Gas constant
x1 = (1-e)/2.0 #
x2 = (1-e)/2.0
x3 = e/2.0
x4 = e/2.0
K = (((x3**v3)*(x4**v4))/((x1**v1)*(x2**v2)))*P**(v3+v4-v1-v2) # Equilibrium constant
dG = -R*T*math.log(K) #Gibbs function change
print "\n Example 16.3\n"
print "\n Equilibrium constant is ",K
print "\n Gibbs function change is ",dG ,"J/gmol"
#The answers vary due to round off error
import math
Veo = 1.777 # Ve/Vo
e = 1.0-Veo # Degree of dissociation
P = 0.124 # in atm
K = (4*e**2*P)/(1.0-e**2)
print "\n Example 16.5\n"
print "\n The value of equillibrium constant is ",K ," atm"
import math
v1 = 1.0 # Assumed
v2 = 0 # Assumed
v3 = 1.0 # Assumed
v4 = 1.0/2.0# Assumed
dH = 250560.0 # Enthalpy change in j/gmol
e = 3.2e-03 # Constant
R = 8.3143 # Gas constant
T = 1900.0 # Reaction temperature
Cp = ((dH**2)*(1+e/2)*e*(1+e))/(R*T**2*(v1+v2)*(v3+v4))
print "\n Example 16.6\n"
print "\n Cp is ",Cp ," J/g mol K"
#The answers vary due to round off error
import math
a = 21.89 # stochiometric coefficient
y = 18.5 # stochiometric coefficient
x = 8.9 # stochiometric coefficient
PC = 100*(x*12)/((x*12)+(y)) # Carbon percentage
PH = 100-PC # Hydrogen percentage
AFR = ((32*a)+(3.76*a*28))/((12*x)+y) #Air fuel ratio
EAU = (8.8*32)/((21.89*32)-(8.8*32)) # Excess air used
print "\n Example 16.7\n"
print "\n The composition of fuel is ",PH ," percent Hydrogen and ",PC ," percent Carbon"#The answer provided in the textbook is wrong
print "\n Air fuel ratio is ",AFR
print "\n Percentage of excess air used is ",EAU*100 ," percent"
#The answers vary due to round off error
import math
hf_co2 = -393522.0 # Enthalpy of reaction in kJ/kg mol
hf_h20 = -285838.0# Enthalpy of reaction in kJ/kg mol
hf_ch4 = -74874.0# Enthalpy of reaction in kJ/kg mol
D = hf_co2 + (2*hf_h20) #Heat transfer
QCV = D-hf_ch4 # Q_cv
print "\n Example 16.8\n"
print "\n Heat transfer per kg mol of fuel is ",D ," kJ"
print "\n Q_cv is ",QCV ," kJ"
#The answers vary due to round off error
import math
# Below values are taken from table
Hr = -249952+(18.7*560)+(70*540)
Hp = 8*(-393522+20288)+9*(-241827+16087)+6.25*14171+70*13491
Wcv = 150.0 # Energy out put from engine in kW
Qcv = -205.0 # Heat transfer from engine in kW
n = (Wcv-Qcv)*3600/(Hr-Hp)
print "\n Example 16.9 \n"
print "\n Fuel consumption rate is ",n*114 ," kg/h"
#The answers vary due to round off error
import math
# Refer table 16.4 for values
T0 = 298.0 # Atmospheric temperature in K
Wrev = -23316-3*(-394374)-4*(-228583) # Reversible work in kJ/kg mol
Wrev_ = Wrev/44 # Reversible work in kJ/kg
Hr = -103847 # Enthalpy of reactants in kJ/kg
T = 980.0 # Through trial and error
Sr = 270.019+20*205.142+75.2*191.611 # Entropy of reactants
Sp = 3*268.194 + 4*231.849 + 15*242.855 + 75.2*227.485 # Entropy of products
IE = Sp-Sr # Increase in entropy
I = T0*3699.67/44 # Irreversibility
Si = Wrev_ - I# Availability of products of combustion
print "\n Example 16.11 \n"
print "\n Reversible work is ",Wrev_ ," kJ/kg"
print "\n Increase in entropy during combustion is ",Sp-Sr ," kJ/kg mol K"
print "\n Irreversibility of the process ",I ," kJ/kg"
print "\n Availability of products of combustion is ",Si ," kJ/kg"
#The answers vary due to round off error
import math
T0 = 298.15 # Environment temperature in K
P0 = 1 # Atmospheric pressure in bar
R = 8.3143# Gas constant
xn2 = 0.7567 # mole fraction of nitrogen
xo2 = 0.2035 # mole fraction of oxygen
xh2o = 0.0312 # mole fraction of water
xco2 = 0.0003# mole fraction of carbon dioxide
# Part (a)
g_o2 = 0 # Gibbs energy of oxygen
g_c = 0 # Gibbs energy of carbon
g_co2 = -394380 # Gibbs energy of carbon dioxide
A = -g_co2 + R*T0*math.log(xo2/xco2) # Chemical energy
# Part (b)
g_h2 = 0 # Gibbs energy of hydrogen
g_h2o_g = -228590# # Gibbs energy of water
B = g_h2 + g_o2/2 - g_h2o_g + R*T0*math.log(xo2**0.5/xh2o)
# Chemical energy
# Part (c)
g_ch4 = -50790 # Gibbs energy of methane
C = g_ch4 + 2*g_o2 - g_co2 - 2*g_h2o_g + R*T0*math.log((xo2**2)/(xco2*xh2o))
# Chemical energy
# Part (d)
g_co = -137150# # Gibbs energy of carbon mono oxide
D = g_co + g_o2/2 - g_co2 + R*T0*math.log((xo2**0.5)/xco2)
# Chemcal energy
# Part (e)
g_ch3oh = -166240 # Gibbs energy of methanol
E = g_ch3oh + 1.5*g_o2 - g_co2 - 2*g_h2o_g + R*T0*math.log((xo2**1.5)/(xco2*(xh2o**2)))
# Chemical energy
# Part (f)
F = R*T0*math.log(1/xn2)
# Chemical energy
# Part (g)
G = R*T0*math.log(1/xo2)
# Chemical energy
# Part (h)
H = R*T0*math.log(1/xco2)
# Chemical energy
# Part (i)
g_h2o_l = -237180 # Gibbs energy of liquid water
I = g_h2o_l - g_h2o_g + R*T0*math.log(1/xh2o)
# Chemical energy
print "\n Example 6.12\n"
print "\n The chemical energy of carbon is ",A ," kJ/k mol"
print "\n The chemical energy of hydrogen is ",B ," kJ/k mol"
print "\n The chemical energy of methane is ",C ," kJ/k mol"
print "\n The chemical energy of Carbon monoxide is ",D ," kJ/k mol"
print "\n The chemical energy of liquid methanol is ",E ," kJ/k mol"
print "\n The chemical energy of nitrogen is ",F ," kJ/k mol"
print "\n The chemical energy of Oxygen is ",G ," kJ/k mol"
print "\n The chemical energy of Carbon dioxide is ",H ," kJ/k mol"
print "\n The chemical energy of Water is ",I ," kJ/k mol"
#The answers vary due to round off error
import math
# Environmet
T0 = 298.15 # Environment temperature in K
P0 = 1.0 # Atmospheric pressure in atm
R = 8.3143# Gas constant
xn2 = 0.7567 # mole fraction of nitrogen
xo2 = 0.2035 # mole fraction of oxygen
xh2o = 0.0312 # mole fraction of water
xco2 = 0.0003# mole fraction of carbon dioxide
xother = 0.0083 # Mole fraction of other gases
# Liquid octane
t1 = 25.0 # Temperature of liquid octane in degree centigrade
m = 0.57 # Mass flow rate in kg/h
T2 = 670 # Temperature of combustion product at exit in K
x1 = 0.114 # Mole fraction of CO2
x2 = .029 # Mole fraction of CO
x3 = .016 # Mole fraction of O2
x4 = .841 # Mole fraction of N2
Wcv = 1 # Power developed by the engine in kW
print "\n Example 6.13\n"
# By carbon balance
b = 55.9
# By hydrogen balace
c=9
# By oxygen balance
a = 12.58
Qcv = Wcv- 3845872*(.57/(3600*114.22))
E = 5407843.0 # Chemical exergy of C8H18
nII = Wcv/(E*.57/(3600*114.22))
print "\n The rate of heat transfer from the engine = ",Qcv ," kW,\n The second law of efficiency of the engine = ",nII*100 ," percent"