#given data
mO2=3.0;#moles of oxygen
mN2=5.0;#moles of nitrogen
mCH4=12.0;#moles of methane
#molecular masses in kg
MO2=32.0;
MN2=28.0;
MCH4=16.0;
#constants used
Ru=8.314;#in kJ/kg - K
#calculations
#part - a
mm=mO2+mN2+mCH4;
mfO2=mO2/mm;
mfN2=mN2/mm;
mfCH4=mCH4/mm;
print'mass fraction of oxygen is %f'%round(mfO2,2);
print'mass fraction of nitrogen is %f'%round(mfN2,2);
print'mass fraction of methane is %f'%round(mfCH4,2);
#part - b
NO2=mO2/MO2;
NN2=mN2/MN2;
NCH4=mCH4/MCH4;
Nm=NO2+NN2+NCH4;
yO2=NO2/Nm;
yN2=NN2/Nm;
yCH4=NCH4/Nm;
print'mole fraction of oxygen is %f'%round(yO2,3);
print'mole fraction of nitrogen is %f'%round(yN2,3);
print'mole fraction of methane is %f'%round(yCH4,3);
#part - c
Mm=mm/Nm;
print'average molecular mass %f kg/kmol'%round(Mm,1);
Rm=Ru/Mm;
print'gas constant of mixture %f kJ/kg - K'%round(Rm,3)
#given data
NN2=2.0;#moles of nitrogen
NCO2=6.0;#moles of carbon dioxide
Tm=300.0;#temperature of gases in K
Pm=15000.0;#pressure of gases in kPa
#constants used
Ru=8.314;#in kJ/kmol - K
#calculations
#part - a
Nm=NN2+NCO2;
Vm=Nm*Ru*Tm/Pm;
print'the volume of the tank on the basis of the ideal-gas equation of state %f m^3'%round(Vm,3);
#part - b
#from Table A-1
#for nitrogen
TcrN=126.2;
PcrN=3390;
#for Carbondioxide
TcrC=304.2;
PcrC=7390;
yN2=NN2/Nm;
yCO2=NCO2/Nm;
Tcr=yN2*TcrN+yCO2*TcrC;
Pcr=yN2*PcrN+yCO2*PcrC;
Tr=Tm/Tcr;
Pr=Pm/Pcr;
#from Fig A-15b
Zm=0.49;
Vm=Zm*Nm*Ru*Tm/Pm;
print'the volume of the tank on the basis Kay’s rule %f m^3'%round(Vm,3);
#part - c
#for nitrogen
TrN=Tm/TcrN;
PrN=Pm/PcrN;
#from Fig A-15b
Zn=1.02;
#for Carbondioxide
TrC=Tm/TcrC;
PcrC=Pm/PcrC;
#from Fig A-15b
Zc=0.3;
Zm=yN2*Zn+yCO2*Zc;
Vm=Zm*Nm*Ru*Tm/Pm;
print'the volume of the tank on the basis compressibility factors and Amagat’s law %f m^3'%round(Vm,3);
#part - d
VRN=(Vm/NN2)/(Ru*TcrN/PcrN);
VRC=(Vm/NCO2)/(Ru*TcrC/PcrC);
#from Fig A-15b
Zn=0.99;
Zc=0.56;
Zm=yN2*Zn+yCO2*Zc;
Vm=Zm*Nm*Ru*Tm/Pm;
#When the calculations are repeated we obtain 0.738 m3 after the second iteration, 0.678 m3 after the third iteration, and 0.648 m3 after the fourth iteration.
Vm=0.648;
print'compressibility factors and Dalton’s law the volume of the tank on the basis %f m^3'%round(Vm,3);
#given data
mN=4.0;#mass of nitrogen in kg
T1N=20.0;#temperature of nitrogen in K
P1N=150.0;#pressure of nitrogen in kPa
mO=7.0;#mass of oxygen in kg
T1O=40.0;#temperature of oxygen in K
P1O=100.0;#pressure of oxygen in kPa
#molecular masses in kg
MO=32.0;
MN=28.0;
#constants used
Ru=8.314;#in kJ/kg - K
#from Table A-2a
CvN=0.743;
CvO=0.658;
#calculations
#part - a
#Ein - Eout = dEsystem
# (m*cv*dT)N2 + (m*cv*dT)= 0;
Tm= (mN*CvN*T1N+ mO*CvO*T1O)/(mN*CvN+mO*CvO);
print'the mixture temperature %f C'%round(Tm,1);
#part - b
NO=mO/MO;
NN=mN/MN;
Nm=NO+NN;
VO=NO*Ru*(T1O+273)/P1O;
VN=NN*Ru*(T1N+273)/P1N;#Exergy Destruction during Mixing of Ideal Gases
Vm=VO+VN;
Pm=Nm*Ru*(Tm+273)/Vm;
print'the mixture pressure after equilibrium has been established %f kPa'%round(Pm,1)
from math import log
#given data
NO=3.0;#moles of oxygen
NC=5.0;#moles of carbondioxide
T0=25+273.0;#temperature of gasses in K
#constants used
Ru=8.314;#in kJ/kg - K
#calculations
Nm=NO+NC;
yO=NO/Nm;
yC=NC/Nm;
#dSm= -Ru*(NO*log(yO)+NC*log(yC))
Sm=-Ru*(NO*log(yO)+NC*log(yC));
print'the entropy change %f kJ/K'%round(Sm);
Xdestroyed=T0*Sm/1000;
print'exergy destruction associated %f MJ'%round(Xdestroyed,1)
#given data
T1=220;#intial temperature in K
T2=160;#final temperature in K
Pm=10;#pressure of air in MPa
yN=0.79;#mole fraction of nitrogen
yO=0.21;#mole fractions of oxygen
#critical properties
#for Nitrogen
TcrN=126.2;
PcrN=3.39;
#for Oxygen
TcrO=154.8;
PcrO=5.08;
#constants used
Ru=8.314;#in kJ/kg - K
#from Tables A-18 & 19
#at T1
h1N=6391;
h1O=6404;
#for T2
h2N=4648;
h2O=4657;
#calculations
#part - a
qouti=yN*(h1N-h2N)+yO*(h1O-h2O);
print'the heat transfer during this process using the ideal-gas approximation %i kJ/kmol'%round(qouti);
#part - b
Tcrm=yN*TcrN+yO*TcrO;
Pcrm=yN*PcrN+yO*PcrO;
Tr1=T1/Tcrm;
Tr2=T2/Tcrm;
Pr=Pm/Pcrm;
#at these values we get
Zh1=1;
Zh2=2.6
qout=qouti-Ru*Tcrm*(Zh1-Zh2);
print'the heat transfer during this process using Kay’s rule %i kJ/kmol'%round(qout);
#part - c
#for nitrogen
TrN1=T1/TcrN;
TrN2=T2/TcrN;
PrN=Pm/PcrN;
#from Fig A-15b
Zh1n=0.9;
Zh2n=2.4;
#for Oxygen
TrO1=T1/TcrO;
TrO2=T2/TcrO;
PcrO=Pm/PcrO;
#from Fig A-15b
Zh1O=1.3;
Zh2O=4.0;
#from Eq 12-58
h12N=h1N-h2N-Ru*TcrN*(Zh1n-Zh2n);# h1 - h2 for nitrogen
h12O=h1O-h2O-Ru*TcrO*(Zh1O-Zh2O);# h1 - h2 for oxygen
qout=yN*h12N+yO*h12O;
print'the heat transfer during this process using Amagat’s law %i kJ/kmol'%round(qout);
from math import log
#13.6 (d) answer not matching as float datatype is giving more accurate answer in comparison to textbook that has given approximate due to rounding off to two decimal places
#given data
mfs=0.0348;#salinity mass fraction
mfw=1-mfs;
T0=288.15;#temperature of sea water in K
#constants used
Mw=18;
Ms=58.44;
Rw=0.4615;
pm=1028;
Ru=8.314;
#calculations
#part - a
Mm=1/((mfs/Ms)+(mfw/Mw));
yw=mfw*Mm/Mw;
ys=1-yw;
print'the mole fraction of the water is %f'%round(yw,4);
print'the mole fraction of the saltwater is %f'%round(ys,5);
#part - b
wmin=-Ru*T0*(ys*log(ys)+yw*log(yw));
wm=wmin/Mm;
print'the minimum work input required to separate 1 kg of seawater completely into pure water and pure salts %f kJ'%round(wm,2);
#part - c
wmin=Rw*T0*log(1/yw);
print'the minimum work input required to obtain 1 kg of fresh water from the sea %f kJ'%round(wmin,2);
#part - d
Pmin=pm*Rw*T0*log(1/yw);
print'the minimum gauge pressure that the seawater must be raised if fresh water is to be obtained by reverse osmosis using semipermeable membranes %i kPa'%round(Pmin)