from math import exp
#given data
T=298.15;#reaction temperature in K
#from Table A-26
g=455510;
#constants used
R=8.314;#in kJ/kmol K
#calculations
# N2 = 2N
dG=2*g;
logKp=-dG/(R*T);
Kp=exp(logKp);
print('Kp = ',Kp)
print'in comparison to Table A-28 ln Kp value of -367.5 our result is %i'%logKp;
#given data
P=10;#pressure in atm
#constants
vH2=1;
vH=2;
#calculations
# H2 = 0.9H2 + 0.2H
NH=0.2;
NH2=0.9;
Nt=NH+NH2;
#from Eq. 16-15
Kp=((NH**vH)/(NH2**vH2))*(P/Nt)**(vH-vH2);
#at this value of Kp from Table A-28
T=3535;
print'temperature %i K is'%T;
from math import log
#reaction
# H2 + 0.5O2 = H2O
#enthalpy datas in kJ/kmol
#of H2
hfH=-241820;
h2000H=82593;
h298H=9904;
#of O2
hfO=0;
h2000O=61400;
h298O=8468;
#of H2O
hfw=0;
h2000w=67881;
h298w=8682;
#Kp data from A-28
Kp2=869.6;
Kp1=18509;
T1=1800;
T2=2200;
#constants used
Ru=8.314;#in kJ/kmol K
#calculations
#part - a
hR=1*(hfH+h2000H-h298H)-1*(hfO+h2000O-h298O)-0.5*(hfw+h2000w-h298w);
print'enthalpy of the reaction %i kJ/kmol using enthalpy data'%round(hR);
#part - b
hR=Ru*(T1*T2)/(T2-T1)*log(Kp2/Kp1);
print'enthalpy of the reaction %i kJ/kmol using enthalpy data'%round(hR);
#given data
T=120+273.15;#temperature of saturated water in K
#from Table A-4
hf=503.81;
hg=2706;
sf=1.5279;
sg=7.1292;
#calculations
print('liquid phase');
gf=hf-T*sf;
print'gf value %f kJ/kg'%round(gf,1);
print('vapour phase');
gg=hg-T*sg;
print'gg value %f kJ/kg'%round(gg,1);
#given data
T=15;#lake temperature in C
P=92.0;#atmospheric pressure in kPa
#from Table A-4
Pv=1.7057;
#calculations
yv=Pv/P;
print'mole fraction of water vapor at the surface is %f'%round(yv,4);
yw=1-yv;
print'mole fraction of water in the lake is %f percent'%(round(yw)*100)
#given data
T=17.0;#lake temperature in C
P=92.0;#atmospheric pressure in kPa
#from Table A-4
Pv=1.96;
#constants from Table 16-2
H=62000.0;
#calculations
Pda=P-Pv;#dry air
yda=Pda/H/100;#in bar
print'mole fraction of air is %f'%(yda)
#given data
T=358;#hydrogen gas temperature in K
P=300/100;#pressure of hydrogen gas in bar
#constants used
M=2;
s=0.00901;#solubility in kmol/m^3 bar
p=0.027;
#calculations
pH2=s*P;
print'molar density of H2 %f kmol/m^3'%round(pH2,3);
pH2=p*M;
print'mass density of H2 %f kg/m^3'%round(pH2,3)
#given data
yw=0.30;#water mole fraction
ya=0.70;#ammonia mole fraction
T=40;#mixture temperature in C
#saturation pressure
pw=7.3851;
pa=1554.33;
#calulations
Pw=yw*pw;
Pa=ya*pa;
Pt=Pw+Pa;
yw=Pw/Pt;
ya=Pa/Pt;
print'mole fraction of water vapour %f'%round(yw,4);
print'mole fraction of ammonia %f'%round(ya,4);