#Given:
betta = 1.25*10**-3; #coeffecient of math.expansion (K**-1)
V = 0.1; #molar volume of organic liquid (m**3/kmol)
P2 = 20.; #final pressure (bar)
P1 = 1.; #initial pressure (bar)
# Calculations
#To determine the change in entropy of system
#betta = (1/V)*(del V/del T)p
#Let k = (del V/del T)p
k = betta*V;
#Considering Maxwell's relation Eq. 6.24 (Page no. 193)
#dS = -k*(dP)
S = -k*(P2-P1)*10**5; #entropy change (J/kmol K)
# Results
print 'Change in entropy is %f J/kmol K'%S
print ' It is assumed that (del V/del T)p is constant in the pressure range 1 to 20 bar'
import math
# Variables
T1 = 363.; #temperature (K)
T2 = 373.; #temperature (K)
P2 = 101.3; #vapour pressure at 373 K (kPa)
H = 2275.*18; #mean heat of vaporisation (kJ/kmol)
R =8.314; #ideal gas constant (kJ/kmol K)
# Calculations
#To calculate vapour pressure of water at 363 K
#Using eq. 6.28 (Page no. 196)
P1 = P2/(math.e**((H/R)*((1./T1)-(1./T2))))
# Results
print ' Vapour pressure of water at 363 K is %f kPa'%P1
# Variables
d_l = 13.69*10**3; #density of mercury in liquid state (kg/m**3)
d_s = 14.193*10**3; #density of mercury in solid state (kg/m**3)
T1 = 234.33; #temperature in K
P1 = 1.; #initial pressure in bar
P2 = 10.; #final pressure in bar
Hf = 9.7876; #heat of fusion of mercury (kJ/kg)
# Calculations
#Assuming del_V/del_H remains constant% math.log(T2/T1) = (del_V/del_H)*(P2-P1)
del_V = (1./d_l)-(1./d_s)
T2 = T1*(math.e**((del_V/Hf)*(P2-P1)))
# Results
print 'The melting point of mercury at 10 bar is %f K'%T2
# Variables
T1 = 300.; #initial temperature (K)
T2 = 800.; #final temperature (K)
# Calculations
#Heat capacity (J/mol K)
#Cp = 26.04+(5.586*10**-3*T)+(28.476*10**4*T**-2)
import math
S = 26.04*math.log(T2/T1)+5.586*10**-3*(T2-T1)+28.476*10**4/(-2)*(T2**-2-T1**-2)
# Results
print 'The increase in entropy of solid magnesium is %f J/mol K'%S
# Variables
T = 773.; #temperature (K)
P = 100.; #pressure (bar)
Ho = 0; #enthalpy of nitrogen at 273 K and 1 bar
So = 192.4; #entropy of nitrogen at 298 K and 1 bar
To = 273.; #(K)
Po = 1.; #(bar)
R = 8.314; #ideal gas constant (kJ/kmol K)
# Calculations
#Cp = 27.3+(4.2*10**-3*T) molal heat capacity at 1 bar
#To calculate internal energy enthalpy entropy and free energyfor one mole of nitrogen
#Step 1:
#Assuming that nitrogen is initially at 273 K and 1 bar
#del_H1 = intg(CpdT)
del_H1 = 27.3*(T-To)+4.2*10**-3*(T**2-To**2)/2;
#Assuming that nitrogen is initially at 298 K and 1 bar
#del_S1 = intg(Cp*(dT/T))
del_S1 = 27.3*math.log(T/To)+4.2*10**-3*(T-To)
H1 = Ho + del_H1;
S1 = So + del_S1;
#Step 2:
#del_H2 = [V - T*(del_V/del_T)p]dP
#Since nitrogen behaves as ideal gas
#(del_V/del_T)p = R/P% V-(R*T)/P = 0
del_H2 = 0.;
del_S2 = -R*math.log(P/Po)
H = H1 + del_H2;
S = S1 + del_S2;
#Internal energy: U = H-PV = H-RT (J/mol)
U = H - (R*T)
#Gibbs free energy (J/mol)
G = H-(T*S)
# Results
print 'Enthalpy is %5.3e J/mol'%H
print ' Entropy is %f J/mol K'%S
print ' Internal energy is %4.3e J/mol'%U
print ' Gibbs free energy is %4.3e J/mol'%G
# Variables
#Equation of state: P(V-B) = RT + (A*P**2)/T
Cp = 33.6; #mean specific heat at atmosheric pressure (J/mol K)
A = 1*10**-3; #m**3 K/(bar)mol
B = 8.0*10**-5; #m**3/mol
R = 8.314*10**-5; #ideal gas constant (m**3 (bar)/mol K)
import math
#For step 1:
Po = 4.; #pressure at A (bar)
P1 = 1.; #pressure at C (bar)
T = 300.; #temperature (K)
# Calculations and Results
#del_S1 = intg[(del_V/del_T)pdP]
del_S1 = (R*math.log(Po/P1) - (A/T**2)*(Po**2-P1**2)/2)*10**5; #(J/mol K)
#For step 2:
T1 = 300.; #temperature at C (K)
T2 = 400.; #temperature at D (K)
del_S2 = Cp*math.log(T2/T1) #(J/mol K)
#For step 3:
P2 = 1.; #pressure at D (bar)
P3 = 12.; #pressure at B (bar)
T = 400.; #temperature (K)
del_S3 = (R*math.log(P2/P3) - (A/T**2)*(P2**2-P3**2)/2)*10**5; #(J/mol K)
S = del_S1+del_S2+del_S3; #total entropy change
print '(a). Total entropy change is %f J/mol K'%S
#(b). The mean heat capacity at 12 bar
P1 = 4.; #pressure at A (bar)
P2 = 12.; #pressure at Co (bar)
T = 300.; #temperature (K)
del_S1 = R*math.log(P1/P2) - (A/T**2)*(P1**2-P2**2)/2;
#For CoB
T2 = 400.; #temperature at B (K)
T1 = 300.; #temperature at Co (K)
del_S2 = S-del_S1;
Cpm = del_S2/(math.log(T2/T1))
print ' (b). The mean heat capacity at 12 bar is %f J/mol K'%Cpm
# Variables
betta = 1.8*10**-4; #coeffecient of volume math.expansion (K**-1)
k = 3.9*10**-6; #coeffecient of compressibility (bar**-1)
T = 273.; #temperature in K
d = 13.596*10**3; #density (kg/m**3)
Cp = 0.14*10**3; #(J/kg K)
# Calculations
#To calculate Cv for mercury
#Using equation 6.55 (Page no. 208)
Cv = Cp - (betta**2*T*10**5)/(k*d)
# Results
print 'Cv for mercury is %f J/kg K'%Cv
# Variables
#Eqution of state: P(V-b) = RT
P = 10.; #pressure (bar)
T = 298.; #temperature (K)
b = 3.707*10**-5; #Vander Waal's constant (m**3/mol)
R = 8.314; #ideal gas constant
# Calculations
#To estimate the fugacity of ammonia
#Since PV = RT + Pb% Z = 1 + (Pb/RT)
#Using equation 6.127 (Page no. 228)
f = P*(math.e**((b*P*10**5)/(R*T)))
# Results
print 'Fugacity f = %f bar'%f
# Variables
#intg(alphadP) = -556.61 J/mol
P = 50.; #pressure in bar
T = 300.; #temperature in K
R = 8.314; #ideal gas constant
# Calculations
#To determine the fugacity of gas
#Using equation 6.130 (Page no. 230)
f = P*math.e**(-556.61/(R*T))
# Results
print 'Fugacity of gas at 50 bar and 300 K is %i bar'%f
# Variables
#Equation of state: PV = RT(1-0.00513P)
P = [1, 5, 10]; #pressures in bar
phi = [0,0,0]
# Calculations and Results
for i in range(3):
phi[i] = math.e**(-0.00513*P[i])
print ' Fugacity coeffecient at %i bar is %f'%(P[i],phi[i])
# Variables
P = 100.; #pressure in bar
T = 373.; #temperature in K
a = 0.453; #Vander Waal's constant (J m**3/mol**2)
b = 0.571*10**-4; #Vander Waal's constant (m**3/mol)
V = 2.072*10**-4; #molar volume (m**3/mol)
R = 8.314; #ideal gas constant
# Calculations
#To determine the fugacity of pure ethylene
#Using eq. 6.139 (Page no. 233)
ln_f = (b/(V-b)) - ((2*a)/(R*T*V)) + math.log((R*T*10**-5)/(V-b) )
f = math.e**ln_f;
# Results
print 'Fugacity is %f bar'%f
# Variables
T = 623.; #temperature in K
#Data from steam tables:
H = 3159.; #enthalpy at 1000 kPa and 623 K (kJ/kg)
S = 7.3; #entropy at 1000 kPa and 623 K (kJ/kg K)
Ho = 3176.; #enthalpy at 101.3 kPa and 623 K (kJ/kg)
So = 8.38; #entropy at 101.3 kPa and 623 K (kJ/kg K)
fo = 101.3; #fugacity at 101.3 kPa (kPa)
R = 8.314/18; #ideal gas consatnt (kJ/kg K)
# Calculations
#To determine fugacity and fugacity coeffecient of steam
ln_phi = (1/(R*T))*((H-Ho)-T*(S-So))
f = fo*math.e**ln_phi;
phi = f/fo;
# Results
print 'Fugacity of steam is %f bar'%(f/100)
print ' Fugacity coeffecient is %f'%phi
# Variables
T = 473.; #temperature in K
P = 50.*10**5; #pressure in Pa
d = 24.3; #density of ammonia (kg/m**3)
m = 17.; #molecular wt of ammonia
R = 8.314; #ideal gas constant
# Calculations
#To estimate the fugacity of ammonia
V = m/(d*1000) #molar volume of ammonia (m**3/kmol)
#Using eq. 6.142 (Page no. 234)
f = (V*(P**2))/(R*T)
# Results
print 'The fugacity of ammonia is %f bar'%(f/10**5)
# Variables
T = 303.; #temperature in K
P = 10.; #pressure in bar
Ps = 4.241/100; #saturation pressure (bar)
sp_vol = 1.004 *10**-3; #specific volume at 303 K (m**3/kg)
R = 8.314; #ideal gas constant
# Calculations
#To calculate the fugacity of liquid water
V = sp_vol*10**-3*18; #molar volume (m**3/mol)
#Assuming vapour behaves as an ideal gas
f_sat = Ps;
#Using Eq. 6.144 (Page no. 235)
ln_phi = (V/(R*T))*(P-Ps)*10**5;
f = f_sat*math.e**ln_phi;
# Results
print 'Fugacity of liquid water at given conditions is %f bar'%f
# Variables
T = 350.; #temperature in K
P = 60.; #pressure in bar
Ps = 9.35; #vapour pressure at 350 K (bar)
V = 0.1072*10**-3; #molar volume (m**3/mol
phi = 0.834; #fugacity coeffecient
R = 8.314; #ideal gas constant
import math
# Calculations
#To determine fugaity of n butane in liquid state at given conditions
f_sat = phi*Ps;
#Using eq. 6.144 (Page no. 235)
ln_phi = (V/(R*T))*(P-Ps)*10**5;
f = f_sat*math.e**ln_phi;
# Results
print 'Fugacity of n-butane in liquid state at given conditions is %f bar'%f
# Variables
M = 24.32; #molecular wt of solid magnesium
T = 300.; #temperature in K
P = 10.; #pressure in bar
Po = 1.; #reference state pressure (bar)
R = 8.314
d = 1.745*10**3; #density of Mg at 300 K in kg/m**3
# Calculations
#To determine the ativity of solid magnesiun
#Using eq. 6.149 (Page no. 237)
ln_a = (M/(d*10**3*R*T))*(P-Po)*10**5;
a = (math.e)**ln_a;
# Results
print 'Acivity of solid magnesium at 300 K and 10 bar is %f'%a