import math
# Variables
P1 = 760. #mmHg standard conditions
T1 = 273.15; #K
# Calculation and Result
V1 = 22.4143 * 10**-3; #m**3/mol
R1 = P1 * V1 / T1;
print "Gas constant R = %.4e m**3 mmHg / (molK)"%R1
P2 = 101325; #N/m**2
T2 = 273.15; #K
V2 = 22.4143 * 10**-3; #m**3/mol
R2 = P2 * V2 / T2; #J/molK
R3 = R2 / 4.184; #cal/molK
print "Gas constant R in MKS system = %.3f cal/molK"%R3
# Variables
T = 350. #K
P = 1; #bar
# Calculation
V1 = 22.4143 * 10**-3; #m**3 (suffix 1 represents at STD)
P1 = 1.01325; #bar
T1 = 273.15; #K
V = P1 * V1 * T/(T1 * P);
# Result
print "Molar volume = %.2e m**3/mol"%V
# Variables
P = 10. #bar oxygen cylinder gas
T = 300.; #K
V = 150.; #L
P1 = 1.01325; #bar ( \suffix 1 represents at STD)
T1 = 273.15; #K
# Calculation
V2 = T1 * P * V /(T * P1); #m**3
V1 = 22.4143; #m**3/mol
N = V2 / V1; #mol
MO2 = 32.;
m = N * MO2/1000;
# Result
print "Mass of oxygen in the cylinder = %.4f kg"%m
# variables
P = 195. #kPa pressure
T = 273. #K automobile tyre
P1 = 250 #kPa pressure
# Calculation
T1 = P1 * T / P;
# Result
print "Maximum temperature to which tyre may be heated = ",T1,"K"
# variables
V = 250. #L carbon dioxide
T = 300. #K temperature
V1 = 1000. #L
P1 = 100. #kPa cylinder
T1 = 310. #K temperature
# Calculation
P = T * P1 * V1 /(T1 * V);
# Result
print "Original pressure in the cylinder = %.1f kPa"%P
# variables
Vper1 = 70. #% ( 1 = HCl) rubber showed
Vper2 = 20. #% ( 2 = Cl2) volume
Vper3 = 10. #% ( 3 = CCl4)
M1 = 36.45 # molecular weights
M2 = 70.90
M3 = 153.8
# Calculation
m1 = Vper1 * M1
m2 = Vper2 * M2
m3 = Vper3 * M3
mper1 = m1 * 100/(m1+ m2 + m3);
mper2 = m2 * 100/(m1+ m2 + m3);
mper3 = m3 * 100/(m1+ m2 + m3);
# Result
print " (a) weight percent of HCl= %.2f%%"%mper1
print "weight percent of Cl2 = %.2f %%"%mper2
print "weight percent of CCl4 = %.2f %%"%mper3
m = (m1 + m2 + m3)/(Vper1 + Vper2 + Vper3);
print "(b)average molecular weight = %.3f kg"%m
v = 22.4143; #m**3/kmol
Vtotal = v * (Vper1 + Vper2 + Vper3);
D = (m1 + m2 + m3)/Vtotal;
print "(c)Density at standard condiions = %.4f kg/m**3"%D
# variables
per1 = 93. #% ( 1 = methane)
per2 = 4.5; #% (2 = ethane)
per3 = 100 - (per1 + per2); #% ( 3 = N2);
T = 300. #K natural gas
p = 400. #kPa
P3 = p * per3 / 100;
v = 10. #m**3
V2 = per2 * v / 100;
M1 = 16.032;
M2 = 30.048;
M3 = 28;
N1 = per1;
N2 = per2;
N3 = per3;
# Calculation
m1 = M1 * N1;
m2 = M2 * N2;
m3 = M3 * N3;
m = m1 + m2 + m3;
Vstp = 100 * 22.4143 * 10**-3; #m3 at STP
D = m /(1000 * Vstp);
Pstp = 101.325; #kPa
T1 = 273.15; #K
V = T * Pstp * Vstp / ( T1 * p);
D1 = m /(1000 * V);
Mavg = m /100;
mper1 = m1 * 100 / (m1 + m2 + m3);
mper2 = m2 * 100 / (m1 + m2 + m3);
mper3 = m3 * 100 / (m1 + m2 + m3);
# Result
print "(a) Partial pressure of nitrogen = ",P3,"kPa"
print "(b) pure-component volume of ethane = ",V2,"m**3"
print "(c) Density at standard conditions = %.4f kg/m**3"%D
print "(d) Density at given condition = %.4f kg/m**3"%D1
print "(e) Average molecular weight = %.2f"%Mavg
print "(f) weight percent of Methane = %.2f %%"%mper1
print "weight percent of Ethane = %.2f %%"%mper2
print "weight percent of Nitrogen = %.2f %%"%mper3
# variables
per1 = 20. #% ( 1 = ammonia)
Vstp = 22.4143; #m**3/kmol
Pstp = 101.325; #kPa
Tstp = 273.15; #K
V1 = 100. #m**3 ammonia air
P1 = 120. #kPa absorption column
T1 = 300. #K
P2 = 100. #kPa gas leaves
T2 = 280. #K gas leaves
per2 = 90. #% (absorbed)
# Calculation
N = V1 * P1 * Tstp / (Vstp * Pstp * T1); #kmol
Nair = (1 - per1 / 100) * N;
N1 = per1 * N/100;
Nabs = per2 * N1 / 100;
N2 = N1 - Nabs; #leaving
Ntotal = Nair + N2;
Vstp1 = Ntotal * Vstp; #m**3
V2 = Vstp1 * Pstp * T2 / (Tstp * P2);
# Result
print "Volume of gas leaving = ",V2, "m**3"
# variables
V = 100. #m**3 air
Ptotal = 100. #kPa air
Pwater = 4. #kPa pressure
Pair = Ptotal - Pwater;
T = 300. #K air
T1 = 275. #K air cooled
Vstp = 22.4143; #m**3/kmol
Tstp = 273.15; #K
Pstp = 101.325; #kPa
Pwater1 = 1.8; #kPa
# Calculation
Pair1 = Ptotal - Pwater1;
V1 = V * Pair * T1 / ( T * Pair1);
Nwater = V * Pwater * Tstp/ (Vstp * Pstp * T);
Nwater1 = V1 * Pwater1 * Tstp/ (Vstp * Pstp * T1);
m = (Nwater - Nwater1) * 18.02;
# Result
print "(a) volume of air after dehumidification = %.2f m**3"%V1
print "(b) Mass of water vapour removed = %.3f kg"%m
# variables
V = 100. #m**3 rate
P = 600. #kPa gas
T = 310. #K gas
per1 = 20. #% ( H2S entering )
per2 = 2. #% ( H2S leaving )
Pstp = 101.325; #kPa
Tstp = 273.15; #K
Vstp = 22.414; #m**3/kmol
# Calculation
Vstp1 = V * P * Tstp / ( T * Pstp)
N = Vstp1 / Vstp;
N1 = N * per1 / 100;
N2 = N - N1; # ( 2 = inerts)
Nleaving = N2 / ( 1 - per2 / 100);
N1leaving = per2 * Nleaving / 100;
mabsorbed = (N1 - N1leaving) * 34.08; #( molecular wt. = 34.08)
mgiven = 100. #kg/h
Vactual = mgiven * V / mabsorbed;
Nactual = Nleaving * Vactual / V; # actual moles leaving
Vstpl = Nactual * Vstp; # volume leaving at STP
P2 = 500. #kPa
T2 = 290. #K
V2 = Vstpl * Pstp * T2 / ( P2 * Tstp);
Precovery = (N1 - N1leaving)*100 / N1;
# Result
print "(a)Volume of gas entering per hour %.2f m**3/h"%Vactual
print "(b)Volume of gas leaving per hour %.2f m**3/h"%V2
print "(c)Percentage recovery of H2S %.2f %%"%Precovery
# variables
#N2 + 3H2 = 2NH3
V1 = 100. #m**3 ( 1 = N2) cubic metres
V2 = V1 * 3 # ( According to Avagadros principle, equal
#volumes of all gases under similar condition
# contains same no. of moles)
print "(a)Volume of hydrogen required at same condition = ",V2,"m**3"
P1 = 20. #bar
T1 = 350. #K nitrogen
P2 = 5. #bar
T2 = 290. #K hydrogen
# Calculation and Result
V3 = 3 * V1 * P1 * T2 / ( P2 * T1)
print "(b)Volume required at 50 bar and 290K = %.3f m**3"%V3
m = 1000 #kg ( ammonia )
N = m / 17.03 #kmol
N1 = N/2. # ( nitrogen)
N2 = N * 3 / 2. #(hydrogen)
P3 = 50. #bar
T3 = 600. #K
Pstp = 1.01325 #bar
Tstp = 273.15 #K
Vstp = 22.414 #m**3/kmol
V1stp = N1 * Vstp
V4 = V1stp * Pstp * T3 / (P3 * Tstp) # ( nitrogen at 50 bar and 600K)
V5 = V4 * 2 # ( ammonia at 50 bar and 600K)
V6 = V4 * 3 # ( hydrogen at 50 bar and 600K)
print "(c)Volume of nitrogen at 50 bar and 600K = %.1f m**3"%V4
print " Volume of hydrogen at 50 bar and 600K = %.1f m**3"%V6
print " Volume of ammonia at 50 bar and 600K = %.1f m**3"%V5
# note : answers may vary because of rounding error.
# variables
N = 100. #kmol producer gas
P1 = 25. #% ( Carbon monoxide )
P2 = 4. #% ( Carbon Dioxide )
P3 = 3. #% ( Oxygen )
P4 = 68. #% ( Nitrogen )
# Calculation
N1 = N * P1/100
N2 = N * P2/100
N3 = N * P3/100
N4 = N * P4/100
NC = N1 + N2
m = NC * 12
Ngas = N / m #moles of gas for 1 kg of Carbon
Vstp = 22.4143 #m**3/kmol
Vstp1 = Vstp * Ngas
P = 1. #bar
T = 290. #k
Pstp = 1.01325 #bar
Tstp = 273.15 #K
V = T * Vstp1 * Pstp / (Tstp * P )
print "(a)Volume of gas at 1 bar and 290 K per kg Carbon = %.2f m**3"%V
#CO + 1/2 * O2 = CO2
Nrequired = N1/2 - N3 #(oxygen required)
Nsupplied = Nrequired * 1.2
PO1 = 21. #% ( Oxygen percent in air)
Nair = Nsupplied * 100/PO1
V1 = 100. #m**3
Vair = V1 * Nair / N
print "(b)Volume of air required = %.2f m**3"%Vair
NCO2 = N2 + N1
NO2 = Nsupplied - Nrequired
NN2 = N4 + (Vair * (1 - PO1/ 100))
Ntotal = NCO2 + NO2 + NN2
PCO2 = NCO2 * 100 / Ntotal
PO2 = NO2 * 100 / Ntotal
PN2 = NN2 * 100 / Ntotal
# Result
print "Percent composition of Carbon Dioxide = %.2f %%"%PCO2
print "Percent composition of Oxygen = %.2f %%"%PO2
print "Percent composition of Nitrogen = %.2f %%"%PN2
# variables
#4HCl + O2 = 2Cl2 + 2H2O
n = 1. #mol ( Basis 1 mol of HCl )
NO2 = n / 4
NO2supp = 1.5 * NO2
Nair = NO2supp * 100 / 21
V = 100. #m**3
Vair = V * Nair / n
print "(a)Volume of air admitted = %.1f m**3"%Vair
# Calculation
P1 = 80. #% ( HCl converted)
Ncon = n * P1 /100
N2 = Ncon/4 # oxygen required
NH2O = Ncon / 2
NCl2 = Ncon / 2
nHCl = n - Ncon
nO2 = NO2supp - N2
Nnitro = Nair - NO2supp
Ntotal = nHCl + nO2 + NH2O + NCl2 + Nnitro
V1 = V * Ntotal
P1 = 1. #bar
T1 = 290. #K
P2 = 1.2 #bar
T2 = 400. #K
V2 = V1 * P1 * T2 / ( P2 * T1)
print "(b)Volume of gas leaving = %.2f m**3"%V2
VCl2 = NCl2 * V
Pstp = 1.01325 #bar
Tstp = 273. #K
Vstp = 22.4143 #m**3/kmol
Vstp1 = Tstp * P1 * VCl2 / (T1 * Pstp)
Nstp = Vstp1/Vstp
m = Nstp * 70.90
print "(c)Kilograms of Chlorine produced = %.1f kg"%m
Ntotaldry = nHCl + nO2 + NCl2 + Nnitro #dry basis
p1 = nHCl*100/Ntotaldry
p2 = nO2*100/Ntotaldry
p3 = NCl2*100/Ntotaldry
p4 = Nnitro*100/Ntotaldry
# Result
print "(d)Percent composition of HCl in exit stream = %.2f %%"%p1
print " Percent composition of Oxygen in exit stream = %.1f %%"%p2
print " Percent composition of Chlorine in exit stream = %.2f %%"%p3
print " Percent composition of nitrogen in exit stream = %.2f %%"%p4
# note : answers may vary because of rouding error.
# variables
# CO2 = CO + 1/2 * O2
P1 = 1. #bar
T1 = 3500. #K pressure
P2 = 1. #bar
T2 = 300. #K heated
V2 = 25. #L CO2
# Calculation
V1 = V2 * P2 * T1 / ( P1 * T2 )
# Result
print "(a)Final volume of gas if no dissociation occured = %.3f m**3"%(V1/1000)
Pstp = 1.01325 #bar
Tstp = 273. #K
Vstp = 22.4143 #m**3
N2 = V2 * P2 * Tstp / ( Vstp * Pstp * T2)
# let x be the fraction dissociated, then after dissociation,
# CO2 = (1 - x)mol, CO = xmol, O2 = (0.5*x)mol
#total moles = 1 - x + x + o.5 * x = 1 + 0.5 * x
V = 350. #L
N1 = V * P1 * Tstp / (Vstp * Pstp * T1)
# 1 + 0.5 * x = N1, therefore
x = (N1 - 1) / 0.5
p = x*100
print "(b)CO2 converted = %.f %%"%p