# Variables
m1_CO = 1.; # Moles of CO input- [g mol]
m1_O2 = 1. ; # Moles of O2 input - [g mol]
m1_N2 = 3.76 ; # Moles of N2 input - [g mol]
#Output compounds
m2_CO2 = 1. ; # Moles of CO2 output - [g mol]
m2_O2 = .50 ; # Moles of O2 output - [g mol]
m2_N2 = 3.76 ; # Moles of N2 output - [g mol]
H1_fCO = -110520 ; # Heat of formation of CO - [J/g mol]
H1_fO2 = 0 ; # Heat of formation of O2 - [J/g mol]
H1_fN2 = 0 ; # Heat of formation of N2 - [J/g mol]
H1_CO = 2917. - 728 ; # Change in enthalpy during temperature change from 298K to 373 K of CO - [J/g mol]
H1_O2 = 2953. - 732 ; # Change in enthalpy during temperature change from 298K to 373 K of input O2 - [J/g mol]
H1_N2 = 2914. - 728 ; # Change in enthalpy during temperature change from 298K to 373 K of input N2 - [J/g mol]
# Calculations
H_in = (H1_fCO + H1_CO)*m1_CO + (H1_fO2 + H1_O2)*m1_O2 + (H1_fN2 + H1_N2)*m1_N2; # Enthalpy change for inputs -[J]
H2_fCO2 = -393510 ; # Heat of formation of CO2 - [J/g mol]
H2_fO2 = 0 ; # Heat of formation of O2 - [J/g mol]
H2_fN2 = 0 ; # Heat of formation of N2 - [J/g mol]
H2_CO2 = 92466. - 912 ; # Change in enthalpy during temperature change from 298K to 2000 K of CO2 - [J/g mol]
H2_O2 = 59914.-732 ; # Change in enthalpy during temperature change from 298K to 2000 K of output O2 - [J/g mol]
H2_N2 = 56902. - 728 ; # Change in enthalpy during temperature change from 298K to 2000 K of output O2 - [J/g mol]
H1_out = (H2_fCO2 + H2_CO2)*m2_CO2 + (H2_fO2 + H2_O2)*m2_O2 + (H2_fN2 + H2_N2)*m2_N2 ; # Enthalpy change for outputs at 2000 K -[J]
del_H1 = H1_out - H_in ; # Net enthalpy change of process -[J]
H2_fCO2 = -393510. ; # Heat of formation of CO2 - [J/g mol]
H3_CO2 = 77455. - 912 ; # Change in enthalpy during temperature change from 298K to 1750 K of CO2 - [J/g mol]
H3_O2 = 50555. -732 ; # Change in enthalpy during temperature change from 298K to 1750 K of output O2 - [J/g mol]
H3_N2 = 47940. - 728 ; # Change in enthalpy during temperature change from 298K to 1750 K of output O2 - [J/g mol]
H2_out = (H2_fCO2 + H3_CO2)*m2_CO2 + (H2_fO2 + H3_O2)*m2_O2 + (H2_fN2 + H3_N2)*m2_N2 ; # Enthalpy change for outputs at 1750 K -[J]
del_H2 = H2_out - H_in ; # Net enthalpy change of process -[J]
# Results
print 'Heat of above reaction when output is assumed to be at 2000 K is %.0f J.'%del_H1
print ' Heat of above reaction when output is assumed to be at 1750 K is %.0f J.'%del_H2
# Energy balance here reduce to del_H = 0
print ' So we can see that our desired result del_H = 0 is bracketed between 2000 K and 1750 K , hence we will use interpolation to get the theoretical flame temperature.'
# Use interpolation to get the theoretical flame temperature
del_H = 0. ; # Requred condition
Ft = 1750 + ((del_H - del_H2)/(del_H1 - del_H2))*(2000 - 1750) ; # Interpolation to get Flame temperature(Ft)-[K]
print ' Theoretical flame temperature by interpolation is %.0f K.'%Ft
# Variables
v_CH4 = 1000. ; # Volume of CH4 taken - [ cubic feet]
CH4 = 1. ; # assumed for convenience- [ g mol]
ex_air = .5 ; # Fraction of excess O2 required
hp_CaCO3 = 0.130 ; # Heat capacity of CaCO3 -[kJ/g mol]
hp_CaO = 0.062 ; # Heat capacity of CaO -[kJ/g mol]
w_CaCO3 = 100.09 ; # Mol. wt. of CaCO3 -[g]
w_CaO = 56.08 ; # Mol. wt. ofCaO - [g]
# Calculations
req_O2 = 2. ; # By eqn. (b), O2 required by CH4 - [g mol]
ex_O2 = ex_air*req_O2 ; # Excess O2 required - [ g mol]
O2 = req_O2 + ex_O2 ; # Total O2 entering - [ g mol]
N2 = O2 *(.79/.21) ; # Total N2 entering - [ g mol]
nG_N2 = N2 ; # N2 balance - [ g mol]
nG_H2O = 4*CH4/2. ; # H2O balance - [ g mol]
nG_O2 = ex_O2 ; # [g mol]
del_Hi_out = [ -393.250,0,0,-241.835,-635.6] ; # # Heat of formation - [kJ/g mol]
del_Hf_out = [21.425,15.043,14.241,17.010,54.25] ; #Change in enthalpy during temperature change -[kJ/g mol]
del_H_out =del_Hi_out + del_Hf_out ; # Change in enthalpy final - [kJ/g mol]
del_Hi_in = [ -49.963,-1206.9,0,0] ; # # Heat of formation - [kJ/g mol]
del_Hf_in = [0,0,0,0] ; #Change in enthalpy during temperature change -[kJ/g mol]
del_H_in = del_Hi_in + del_Hf_in ; # Change in enthalpy final - [kJ/g mol]
from numpy import matrix
a = matrix([[1,-1],[(del_H_in[1]-del_H_out[4]),-del_H_out[0]]]) ; # Matrix of coefficients
b = matrix([[-1],[(del_H_out[1]*nG_O2 + del_H_out[2]*nG_N2 +del_H_out[3]*nG_H2O-del_H_in[0]*CH4)]]) ; # Matrix of constants
a = a.I
x = a*b ; # Matrix of solutions, L = x(1), nG_CO2 = x(2)
g_CaCO3 = x[0]*w_CaCO3 ; #CaCO3 processed for each g mol of CH4 - [g]
# Results
print ' CaCO3 processed for each g mol of CH4 is %.0f g.'%g_CaCO3
m_CaCO3 = (v_CH4*g_CaCO3)/359.05 ;
print ' Therefore, CaCO3 processed per 1000 ft**3 of CH4 is %.0f lb.'%m_CaCO3
# Variables
SO2_in = 2200. ; # Amount of SO2 entering reactor 2-[lb mol/hr]
R1_CO_in = 1. ; #CO entering reactor 1-[lb mol]
air = .80 ; # Fraction of air used in burning
R2_fSO2_in = 0.667 ; # Fraction of SO2 entering reactor 2
R2_fO2_in = 0.333 ; # Fraction of O2 entering reactor 2
R2_fSO3_out = 0.586 ; # Fraction of SO3 exiting reactor 2
R2_fSO2_out = 0.276 ; # Fraction of SO2 exiting reactor 2
R2_fO2_out = 0.138 ; # Fraction of O2 exiting reactor 2
# Main Reaction: CO , (1/2)*O2 ---> CO2
R1_O2_in = (1.0/2)*air ; # O2 entering reactor 1-[g mol]
R1_N2_in = R1_O2_in*(79./21) ; # N2 entering reactor 1-[g mol]
# Calculations
#Output of reactor 1
R1_CO_out = R1_CO_in*(1 - air) ; # [g mol]
R1_CO2_out = 1*( air) ; # [g mol]
R1_N2_out = R1_N2_in ; #[g mol]
del_Hi_out = [ -109.054,-393.250,0.,-296.855,-395.263,0.] ; # Heat of formation - [kJ/g mol]
del_Hf_out = [35.332,35.178,22.540,20.845,34.302,16.313] ; #Change in enthalpy during temperature change -[kJ/g mol]
del_H_out =del_Hi_out + del_Hf_out ; #[-371.825,15.043,160.781,-449.650,-581.35] # Change in enthalpy final - [kJ/g mol]
del_Hi_in = [ -109.054,-393.250,0.,-296.855,0.] ; # # Heat of formation - [kJ/g mol]
del_Hf_in = [17.177,17.753,11.981,0.,0.] ; #Change in enthalpy during temperature change -[kJ/g mol]
del_H_in = del_Hi_in+ del_Hf_in ; # Change in enthalpy final - [kJ/g mol]
from numpy import matrix
# Solve eqn. (a), (b) and (c) to get F ,P , ex
a = matrix([[(R2_fSO3_out),0,-1],
[(R2_fSO2_out),-(R2_fSO2_in),1],
[- 285.50, -(del_H_in[3]*R2_fSO2_in), 0]]) ; # Matrix of coefficients
b = matrix([[0],[0],[- 33.459781 ]]) ; # Matrix of constants
#a = a.I
#x = a*b ; # Matrix of solutions, P = x(1), F = x(2) ,ex = x(3)
from numpy import *
x = linalg.solve(a,b)
F = x[1] ; #exit stream of reactor 2 - [lb mol]
R2_SO2_in = R2_fSO2_in*F ; # Moles of SO2 required per lb mol of CO - [lb mol]
CO = (R1_CO_in*SO2_in)/R2_SO2_in ; #Mole of CO burned in reactor 1 - [lb mol]
# Results
print 'Mole of CO burned in reactor 1 is %.0f lb mol.'%CO
# Variables
CA = 10000. ; # Produced citric acid - [kg]
f_glucose = .30 ; # Fraction of glucose in solution
con_glucose = .60 ; # Fraction of glucose consumed
w_glucose = 180.16 ; # Mol. wt. of d,alpha glucose -[g]
H_glucose = -1266 ; # Specific enthalpy change of glucose - [kJ/g mol]
w_CA = 192.12; # Mol. wt. of citric acid -[g]
H_CA = -1544.8 ; # Specific enthalpy change of citric acid - [kJ/g mol]
w_BM = 28.6 ; # Mol. wt. of biomass -[g]
H_BM = -91.4 ; # Specific enthalpy change of biomass - [kJ/g mol]
H_CO2 = -393.51 ; # Specific enthalpy change of CO2 - [kJ/g mol]
# Calculations
mol_CA = CA/w_CA ; # Mole of citric acid produced - [kg mol]
g_soln = (mol_CA*(3/2.22)*w_glucose*1)/(con_glucose*f_glucose) ; #Mass of 30 % glucose solution introduced -[kg]
i_glucose = g_soln* f_glucose / w_glucose ; # Initial moles of glucose - [kg mol]
f_glucose = (1 - con_glucose)*i_glucose ; # Final moles of glucose - [kg mol]
f_CA = mol_CA ; # Final moles of citric acid - [kg mol]
f_BM = f_CA*(5.35/2.22) ; # Using the reaction (a)- Final moles of biomass - [kg mol]
i_O2 = i_glucose*(7.8/3) ; # Using the reaction (a)- Initial moles of O2 - [kg mol]
f_CO2 = i_glucose*(4.5/3)*con_glucose ; # Using the reaction (a) - Final moles of CO2 - [kg mol]
power = 100 ; # Power of aerator -[hp]
time = 220 ; # Time taken for reaction - [ hr ]
W = (power*745.7*time*3600)/1000 ; # Work done by aerator - [kJ]
Hi_glucose = i_glucose*H_glucose*1000 ; # Enthalpy change of glucose input - [kJ]
Hi_O2 = i_O2*0*1000 ; # Enthalpy change of O2 input - [kJ]
H_in = Hi_glucose + Hi_O2 ; # Enthalpy change of input - [kJ]
Hf_glucose = f_glucose*H_glucose*1000 ; # Enthalpy change of glucose output - [kJ]
Hf_BM = f_BM * H_BM*1000 ; #Enthalpy change of biomass output - [kJ]
Hf_CA = f_CA *H_CA*1000 ; #Enthalpy change of citric acid output - [kJ]
Hf_CO2 = f_CO2 *H_CO2*1000 ; #Enthalpy change of CO2 output - [kJ]
H_out = Hf_glucose + Hf_BM +Hf_CA + Hf_CO2 ; # Enthalpy change of output - [kJ]
del_H = H_out - H_in ; # Total enthalpy change in process - [kJ]
Q = del_H - W ; # Heat removed - [kJ]
# Results
print 'Heat exchange from the fermentor during production of 10,000 kg citric acid is %.2e kJ(minus sign indicates heat is removed).'%Q