#Finding mole mass or weight fraction of solution
#Variable declaration
mNaOH = 50. #Mass of NaOH in solution in gram
mH2O = 50. #Mass of H2O in solution in gram
MWNaOH = 40 #Molecular weight of NaOH
MWH2O = 18.02 #Molecular weight of H2O
masstolbm = 1/453.6 #Conversion factor for Mass to Lb mass
#Calculation
mT = mNaOH + mH2O #Total mass of solution
mfNaOH = mNaOH/mT #mfNaOH mass fraction of NaOH
mfH2O = mH2O/mT #mfNaOH mass fraction of H2O
nNaOH = mNaOH/MWNaOH #Number of moles of NaOH
nH2O = mH2O/MWH2O #Number of moles of H2O
nT = nNaOH + nH2O #Total number of moles in solution
xNaOH = nNaOH/nT #xNaOH mole fraction of NaOH
xH2O = nH2O/nT #xH2O mole fraction of H2O
lbmNaOH = mNaOH*masstolbm
lbmH2O = mH2O*masstolbm
#Result
print "Mass fraction of NaOH", mfNaOH
print "Mass fraction of H2O", mfH2O
print "Mole fraction of NaOH", round(xNaOH,3)
print "Mole fraction of H2O", round(xH2O,3)
print "Mass of NaOH in Lb mass",round(lbmNaOH,4), "lbm"
print "Mass of H2O in Lb mass", round(lbmH2O,4), "lbm"
#Calculate the value of gas law constant
#Variable declaration
P = 14.7 #Pressure (psia)
V = 359. #Volume of gas(ft3)
Tf = 32 #Temperature in (degF)
n = 1. #Number of moles of Ideal Gas (lbmol)
#Calculation
Tr = 460 + Tf #Deg F to deg Rankine conversion
R = P*V/(n*Tr) #R Gas constant in ft3.psia/(lbmol.degR)
#Result
print 'Gas law constant in lbmole, ft3, °R, and psia units %5.2f ft3.psia/(lbmol.degR)'%(R)
#Variable declarationSI units
P = 101325 #Pressure (Pa)
V = 22.414 #Volume of gas(m3)
T = 0 #Temperature in (deg C)
n = 1. #Number of moles of Ideal Gas (kgmol)
#Calculation
TK = 273.15 + T #Deg C to Kelvin conversion
R = P*V/(n*TK) #R Gas constant in m3.pa/(kgmol.K)
#Result
print 'Gas law constant in kgmole, m3, K, and pa units %5.2f m3.pa/(kgmol.K)'%(R)
#Composition of Gas
#Variable declaration
pCO2 = 75. #Partial pressure of CO2 (mmHg)
pCO = 50. #Partial pressure of CO (mmHg)
pN2 = 595. #Partial pressure of N2 (mmHg)
pO2 = 26. #Partial pressure of O2 (mmHg)
#Calculation
#Total pressure by Dalton's law
P = pCO2 + pCO + pN2 + pO2
xCO2 = pCO2/P
xCO = pCO/P
xN2 = pN2/P
xO2 = pO2/P
#Result
print "Total Pressure P",P, "mmHg"
print "mole fraction of CO2", round(xCO2,3)
print "mole fraction of CO", round(xCO,3)
print "mole fraction of N2", round(xN2,3)
print "mole fraction of O2", round(xO2,3)
#Concentration of Orange Juice using evaporator
#Variable declaration
F = 1000. #Feed rate of orange juice to evaporator (kg/hr)
MpSi = 7.08 #Mass percent of solids in incomming juice
MpSo = 58. #Mass percent of solids in concentrated juice
xW = 0.0
#Calculation
#Overall Mass Balance"
#$F = W + C$"
#Component Mass Balance on solids"
#$F.xF = W.xW + C.xC$
C = F*MpSi/(100)/(MpSo/100)
#Using overall Balance equation
W = 1000-C
#Results
print "Flow rate of Concentrated juice stream", round(C,1) ,"kg/hr"
print "Flow rate of evaporated water stream", round(W,1) ,"kg/hr"
#Crystallization of KNO3 and Recycle
#Variable declaration
F = 1000. #F: Feed to the process, kg/hr
xW = 0. #xW: Weight % of KNO3 in water vaopor stream
xF = 20. #xF: Weight % of KNO3 in Feed
xP = 96. #xP: Weight % of KNO3 in product stream
xR = 37.5 #xR: Weight % of KNO3 in Recycle
xS = 50. #xS: Weight % of KNO3 in stream from evaporator to crystallizer
#Calculation
#Overall material Balance
# F = W + P
# Component material balance on KNO3
# F.xF = W.xW + P.xP
# Solving for P
P = (F*xF/100)/(xP/100) #P: Product rate from process, kg/hr
#Balance over crystallizer
# S = R + P --> P = S - R
#Component balance over crystallizer
# S.xS = R.xR + P.xP --> (R + P).xS = R.xR + P.xP --> ((R + P).xS - P.xP )/xR =
R = P*(xP-xS)/(xS-xR) #R: REcycle rate, kg/hr
S = R + P #S: Concentrate rate from evaporator to crystallizer, kg/hr
#Result
print "Product rate from the process is",round(P,1), "kg/hr"
print "Recycle rate from the process is",round(R,1), "kg/hr"
print "Stream leaving evaporator ",round(S,1), "kg/hr"
#Combustion of fuel gas
#Variable declaration
#Basis 100 kg mol of feed, moles = mole%x100/100
H2=3.1 #Moles of H2 in feed
CO=27.2 #moles of CO in feed
CO2=5.6 #Moles of CO2 in feed
O2=0.5 #Moles of O2 in feed
N2=63.6 #Moles of N2 in feed
#98% CO reacts to form CO2
#Calculation
#CO + (0.5)O2 ----> CO2
#H2 +(0.5)O2 ----> H2O
#Accounting the total number of moles of O2 in the fuel gas theoretically
MthO2=(0.5)*CO + 0.5*H2 - O2 #theoretically required O2 moles
#For 20% excess moles required
MactO2=(1.2)*MthO2 #Actual moles of O2 required
#Since air contains 79 mol% of N2
MN2=(79./21)*MactO2 #moles of N2 in air
#2% CO does not react
MTN2 = MN2 + N2
MO2in = O2 + MactO2
#Mflueg = moles of water + unreacted CO + CO2 (from reacted CO and CO2 in feed ) + N2 + O2
MH2Oflueg = H2
MN2flueg = MTN2
MCOflueg = 0.02*CO
MCO2flueg = CO2 + 0.98*CO
MO2flueg = MO2in - (0.5*H2 + 0.98*CO/2 )
Mflueg = MH2Oflueg + 0.02*CO + CO2 + 0.98*CO + MTN2 + (MO2in - (0.5*H2 + 0.98*CO/2 ))
#Result
print "Moles of CO in exit flue",round(MCOflueg,2),"mol"
print "Moles of CO2 in exit flue",round(MCO2flueg,2),"mol"
print "Moles of O2 in exit flue",round(MO2flueg,2),"mol"
print "Moles of N2 in exit flue",round(MTN2,1),"mol"
print "Moles of H2O in exit flue",round(MH2Oflueg,2),"mol"
#Heating of N2 Gas
#Variable declaration
M=3. #Moles of N2
T1=298. #Temperature of N2 gas (K)
T2=673. #Temperature of N2 gas (K)
T3=1123. #Temperature of N2 gas (K)
# Data
Cpm1=29.68 #Mean heat capacity of N2 gas ranging 298K-673K (J/gmol.k)
Cpm2=31.00 #Mean heat capacity of N2 gas ranging 298K-1123K (J/gmol.k)
#Calculation
#Heat required (Hi)=M*Cpmi*(del T)
H1 = M*Cpm1*(T2-T1) #Heat required in (J)
H2 = M*Cpm2*(T3-T1) #Heat required in (J)
H3 = H2-H1 #Heat required in (J) Since there is no mean heat capacity for the interval 673K-1123K
#Result
print "(a) Heat required to raise the temperature from 298K-673K",H1,"J"
print "(b) Heat required to raise the temperature from 298K-1123K",H2,"J"
print "(c) Heat required to raise the temperature from 673K-1123K",H3,"J"
#Heating of Milk
#Variable declaration
mdot = 4536. #Mass rate of kg/hr
Ti = 4.4 #Temeprature of incomming milk, deg C
To = 54.4 #Temperature of milk leaving exhanger, deg C
C = 3.85 #Heat capacity of cow milk, kJ/(kg.K)
#Data
#Calculation
Mdot = mdot/3600 #Mass rate of kg/s
delT = To - Ti #delT: Temperature difference between milk temperature at outlet and inlet
Q = Mdot*C*delT #Q: Heat required, kW
#Result
print "Rate of Heat Addition: ",Q, "kJ/s or kW"
#Use of Steam Table
#Variable declaration
m = 1 # mass of water in kg or lbm
#Part A SI Units
# Data
H21_11 = 88.60 # Enathalpy at 21.11 degC, kJ/kg
H60 = 251.13 # Enathalpy at 60 degC, kJ/kg
#Calculation
delH = H60 - H21_11
#Result
print "Enthalpy change for heating 1kg of steam", delH, "kJ/kg"
#Part A British Units
# Data
H70 = 38.09 # Enathalpy at 70 degF, btu/lbm
H140 = 107.96 # Enathalpy at 140 degF, btu/lbm
#Calculation
delH = H140 - H70
#Result
print "Enthalpy change for heating 1 lbm of steam", delH, "Btu/lbm"
#Part B SI Units
# Data
H21_11 = 88.60 # Enathalpy at 21.11 degC, kJ/kg
H115_6 = 2699.9 # Enathalpy at 115.6 degC, kJ/kg at 172.2 kPa
#Calculation
delH = H115_6 - H21_11
#Result
print "Enthalpy change for heating 1kg of steam", delH, "kJ/kg"
#Part B British Units
# Data
H70 = 38.09 # Enathalpy at 70 degF, btu/lbm
H240 = 1160.7 # Enathalpy at 140 degF, btu/lbm at 24.97 psia
#Calculation
delH = H240 - H70
#Result
print "Enthalpy change for heating 1 lbm of steam", delH, "Btu/lbm"
#Part C SI Units
# Data
Hv_115_6 = 2699.9 # Enathalpy at 115.6 degC, kJ/kg at 172.2 kPa
Hl_115_6 = 484.9 # Enathalpy at 115.6 degC, kJ/kg at 172.2 kPa
#Calculation
LambdaV = Hv_115_6 - Hl_115_6
#Result
print "Enthalpy of vaporization 1 kg of steam", LambdaV, "kJ/kg"
#Part C British Units
# Data
Hv_115_6 = 1160.7 #Enathalpy water vapor at 240 degF, Btu/lbm at 24.97 psia
Hl_115_6 = 208.44 #Enathalpy saturated water at 240 degF, Btu/lbm at 24.97 psia
#Calculation
LambdaV = Hv_115_6 - Hl_115_6
#Result
print "Enthalpy of vaporization 1 kg of steam", LambdaV, "Btu/lbm"
#Combustion of Carbon
#Variable declaration
n = 10. # gmol of Carbon
nCO2 = 90. #Percent of Carbon converted to CO2
nCO = 10. #Percent of Carbon converted to CO
DelHcCO2 = -393513 # Standard enthalpy change of combustion for CO2 in kJ/kmol
DelHcCO = -110523 # Standard enthalpy change of combustion for CO2 in kJ/kmol
#Calculation
n1 = n/1000
delHc = n1*nCO2*DelHcCO2/100 + n1*nCO*DelHcCO/100
#Result
print " Entahlpy change on incomplete combustion of Carbon:", round(delHc), "kJ"
#Data kcal Units
DelHcCO2 = -94.0518 # Standard enthalpy change of combustion for CO2 in kcal/gmol
DelHcCO = -26.4157 # Standard enthalpy change of combustion for CO2 in kcal/gmol
#Calculation
delHc = n*nCO2*DelHcCO2/100 + n*nCO*DelHcCO/100
#Result
print " Entahlpy change on incomplete combustion of Carbon:", round(delHc), "kcal"
#Reaction of Methane
#Variable declaration
molCH4=1. #MOles of CH4 (kg)
press=101.32 #Pressure (kPa)
temp=298. #temperature (K)
delHfCH4=-74848. #Heat of Formation of CH4 (kJ/kg mol)
delHfH2O=-285840. #Heat of Formation of H2O (kJ/kg mol)
delHfCO=-110523. #Heat of Formation of CO (kJ/kg mol)
delHfH2=0 #Heat of Formation of H2 (kJ/kg mol)
#Calculation
#delH= delHf(products)-delHf(reactants)
delH= (delHfCO + 3*delHfH2) - (delHfCH4 + delHfH2O)
#Result
print 'The standard heat of Formation %5.2e'%(delH),"kJ/kg mol (Endothermic)"
#Heating of Fermentation Medium
#Variable declaration SI Units
F=2000. #Feed rate of Liquid (kg/h)
TLi=30. #Initial temperature of the liquid (°C)
TLo=70. #Final temperature of the liquid (°C)
TWi=95. #Temperature of water while entering (°C)
TWo=85. #Temperature of water while leaving (°C)
Tref=25. #Reference temperature (°C)
CL=4.06 #Enthalpy of liquid at 25 degC (kJ/kg)
Cw=4.21 #Enthalpy of water at 25 degC (kJ/kg)
#Calculations
delTLi=TLi-Tref
delTLo=TLo-Tref
delTW=TWi-Tref
#Input streams
HLi=F*CL*delTLi
#Output streams
HLo=F*CL*delTLo
#Heat gained by the system = Heat gained at outlet - heat at inlet
QL = HLo-HLi
#Heat gained by liquid = Heat lost by water
W = QL/(Cw*(TWi-TWo))
#Result
print 'Rate Enthalpy of the liquid entering %5.2e kJ/kg'%HLi
print 'Rate Enthalpy of the liquid leaving %5.2e kJ/kg'%HLo
print 'Heat added to fermentation medium %5.4e'%(QL),"kJ/h"
print "Feed rate of water supplied",round(W,2),"kg/h"
print 'The answer has been checked using calculator and \ndiffers from answer given in book because of truncation'
print "Heat added to fermentation medium:",round(QL/3600,2),"kW"
#Heat and Material Balance in Combustion
#Variable declaration SI Units
mCO = 1. #Moles of CO burnt in furnace (kmol/h)
delHc=-282989. #Standard heat of combustion of CO (kJ/kmol)
CpmCO = 29.38 #Mean Heat capacity of CO between temperature 298k-478k
CpmCO2 = 49.91 #Mean Heat capacity of CO2 between temperature 298k-478k
CpmN2 = 31.43 #Mean Heat capacity of N2 between temperature 298k-478k
CpmO2 = 33.25 #Mean Heat capacity of O2 between temperature 298k-478k
Cpmair = 29.29 #Mean Heat capacity of Air between temperature 298k-478k
Tref = 298. #Reference temperature for enthalpy calculation
TCOi = 473. #Temperature of CO inlet stream
Tair = 373. #Temperature of inlet air stream
Texit = 1273. #Temperature of outgoing stream
#Calculation
#CO(g) + (0.5)O2(g) ---> CO2(g)
#Since from the above equation we get that 1 mole of CO will require 0.5 mole O2
MthO2 = (0.5)*1. #Theoretically required O2 moles (kmol/h)
MactO2 = (1.9)*(MthO2) #Moles of O2 actually added
MN2 = (0.79/0.21)*MactO2 #Moles of N2 added
xO2 = MactO2 - MthO2 #Moles of O2 in exit flue
xCO2 = mCO #Moles of CO2 formed is equal to moles of CO added
xN2 = MN2 #Moles of N2 in the exit flue
MAir = xN2 + MactO2
#Input streams
HinAir = MAir*Cpmair*(Tair-Tref)
HinCO = mCO*CpmCO*(TCOi-Tref)
HCO2 = xCO2*CpmCO2*(Texit-Tref)
HN2 = xN2*CpmN2*(Texit-Tref)
HO2 = xO2*CpmO2*(Texit-Tref)
Qr = mCO*delHc #Heat removed = total enthalpy of leaving streams - total enthalpy of incoming streams + heat added due to reaction
q = HCO2 + HO2 + HN2 - (HinAir + HinCO-Qr)
#Result
print 'moles of O2 actually added %4.3f kgmol/h'%MactO2
print 'moles of N2 added %4.3f kgmol/h, Notice this value differs from \nthan in book hence following values also change but are correct'%xN2
print 'moles of air added %4.3f kgmol/h'%(MactO2+MN2)
print 'moles of O2 in exit flue gas %4.3f kgmol/h'%xO2
print 'Enthalpy of air entering %4.3f kJ/h'%HinAir
print 'Enthalpy of CO entering %4.3f kJ/h'%HinCO
print 'Enthalpy of CO2 leaving %4.3f kJ/h'%HCO2
print 'Enthalpy of N2 leaving %4.3f kJ/h'%HN2
print 'Enthalpy of O2 leaving %4.3f kJ/h'%HO2
print "Heat Removed: ", round(q), "kJ/hr"
print "Heat Removed: ", round(q*1000./3600.),"W"
#Oxidation of LactoseC12H22O11
#Variable declaration
#HLact37, Total Enthalpy of Lactose stream in at 37 deg C
#HO237, Total Enthalpy of Oxygen stream in at 37 deg C
#HH2O37, Total Enthalpy of Water out at 37 deg C
#HCO237, Total Enthalpy of CO2 stream out at 37 deg C
#delHcLact37, Heat of combustion for Lactose, J/mol
nLact = 1. #Mass of Lactose in gmol
nO2 = 12. #Moles oo O2 fed
nCO2 = 12. #Moles oo CO2
nH2O = 11. #Moles oo H2O
MWLact = 342.3 #Molecular weight of lactose
MWH2O = 18.02 #Molecular weight of water
CpmLact = 1.2 #Mean specific heat of Lactose, J/g.K
CpmO2 = 29.38 #Mean specific heat of O2, J/mol.K
CpmH2O = 4.18 #Mean specific heat of H2O, J/mol.K
CpmCO2 = 37.45 #Mean specific heat of CO2, J/mol.K
delHcLact = 5648.8e3 #Std. Heat of combustion for Lactose, J/mol
Tref = 25. #Reference temperature, deg C
Ts = 37. #Stream temperature, deg C
#Calculation
#H = n*Cpmi*(T-Tref)
#Del T in degC = Del T in K
mLact = nLact*MWLact
HLact37 = mLact*CpmLact*(Ts-Tref)
HO237 = nO2*CpmO2*(Ts-Tref)
HCO237 = nCO2*CpmCO2*(Ts-Tref)
HH2O37 = nH2O*MWH2O*CpmH2O*(Ts-Tref)
delHcLact37 = HCO237 + HH2O37 - (HLact37 + HO237 + delHcLact)
#Result
print "Enthalpy of Lactose stream in at 37 deg C:",round(HLact37),"J/gmol"
print "Enthalpy of Oxygen stream in at 37 deg C :",round(HO237), "J/gmol"
print "Enthalpy of Water out at 37 deg C :",round(HH2O37), "J/gmol"
print "Enthalpy of CO2 stream out at 37 deg C :",round(HCO237), "J/gmol"
print "Heat of combustion for Lactose :",round(HLact37),"J/gmol"
print 'Heat of combustion of Lactose at 37 deg C:%6.3e'%(delHcLact37),"J/gmol"