Chapter 6 : Thermodynamics Properties of Fluids

Example 6.1 page no : 88

In [1]:
import math 

# Variables

#At Temp T1 = 298.15K
T1 = 298.15;			#[K]
P1 = 1.;	    		#[bar]
P2 = 1000.;		    	#[bar]
Cp_T1 = 75.305;			#[KJ Kmol/K]
V1_T1 = 18.071*10**-3;			#[m**3/Kmol]
V2_T1 = 18.012*10**-3;			#[m**3/Kmol]
beta1_T1 = 256.*10**-6;			#[1/K]
beta2_T1 = 366.*10**-6;			#[1/K]

#At Temp T2 = 323.15K
T2 = 323.15;			#[K]
P1 = 1.;			#[bar]
P2 = 1000.;			#[bar]
Cp_T2 = 75.314;			#[KJ Kmol/K]
V1_T2 = 18.234*10**-3;			#[m**3/Kmol]
V2_T2 = 18.174*10**-3;			#[m**3/Kmol]
beta1_T2 = 458.*10**-6;			#[1/K]
beta2_T2 = 568.*10**-6;			#[1/K]

#Solution

#Formula to be used
#Eqn (6.28) del_H = ((Cp)(T2-T1))-((V)(1-(beta)(T2)(P2-P1))
#Eqn (6.29) del_S = ((Cp)ln(T2/T1)-((beta)(V)(P2-P1))

#For P = 1
Cp = (Cp_T1+Cp_T2)/2;
#For T = 323.15K
V = (V1_T2+V2_T2)/2;
beta_T = (beta1_T2+beta2_T2)/2;

del_H = round((Cp*(T2-T1))+(V*(1-(beta_T*T2))*(P2-P1)*10**5*10**-3),0);
del_S = round((Cp*(math.log(T2/T1)))-(beta_T*V*(P2-P1)*10**5*10**-3),2);

print 'Change In Enthalpy',del_H,'KJ/Kmol'
print 'Change In Entropy',del_S,'KJ/Kmol/K'
Change In Enthalpy 3400.0 KJ/Kmol
Change In Entropy 5.13 KJ/Kmol/K

Example 6.3 page no : 89

In [4]:
%matplotlib inline
import math 
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel
from numpy import array

def ICPS(T0,T,A,B,C,D):
    t = T/T0;
    return  ((A)*math.log(t))+(((B*T0)+(((C*T0*T0)+(D/(t*t*T0*T0)))*(t+1)/2))*(t-1))

def ICPH(T0,T,A,B,C,D):
    t = T/T0;
    return (A+((B/2)*T0*(t+1))+((C/3)*T0*T0*((t**2)+t+1))+(D/(t*T0*T0)))*(T-T0)

# Variables
T0 = 300.;			#[K]
T = 360.;			#[K]
R = 8.314;
P = 15.14;			#[bar]
A = 1.7765;
B = 33.037*10**-3;
C = 0;
D = 0;
H0 = 18115.;  			#J/mol
S0 = 295.976;			#J/mol/K

#Graph
X = array([0,0.10,0.50,2,4,6,8,10,12,14,15.41]);
Y1 = array([1.780,1.700,1.514,1.293,1.290,1.395,1.560,1.777,2.073,2.432,2.720]);			#[(dZ/dT)p/P]
Y2 = array([2.590,2.470,2.186,1.759,1.591,1.544,1.552,1.592,1.658,1.750,1.835]);			#[-(Z-1)/P]
plot(Y1,X);
suptitle("(a)")
xlabel("P(bar)")
ylabel("[(dZ/dT)p/P]X10**4(K**-1 bar**-1)");
plot(Y2,X);
suptitle("(b)")
xlabel("P(bar)")
ylabel("[-(Z-1)/P]X10**2(bar**-1)");


#Area Under the Curve (a)
Y1 = Y1*10**-4;
A1 = 0;
for i in range(1,11):
    A1 = A1+((X[i-1]-X[i])*Y1[i]);

print 'Area under the graph(a)',A1*10000,'(X 10**-4) K**-1'
#Area Under the Curve (b)
Y2 = Y2*10**-2;
A2 = 0;
for i in range(1,11):
    A2 = A2+((X[i-1]-X[i])*Y2[i]);

print 'Area under the graph(b)',round(A2,4)


K = A1*T;			#Hr/RT
#From Eqn(6.47)
Hr = R*T*(K);			#[J/mol]
#From Eqn(6.48)
Sr = R*(K-(A2));			#[J/mol/K]

#From Eqn(6.49) and Eqn(6.50)
H1 = R*ICPH(T0,T,A,B,C,D);
S1 = R*ICPS(T0,T,A,B,C,D);

H = H0+H1+Hr;
S = round(S0+S1+Sr-(R*math.log(P)),3);

print 'Enthalpy',H,'J/mol'
print 'Entropy',S,'J/mol/K'
print ('Note: The Answer is different with that of the Book because the Method Used\
 to find the Area under the Graph is done by finding the area of small Rectangles')
 Area under the graph(a) -27.6043 (X 10**-4) K**-1
Area under the graph(b) -0.2572
Enthalpy 21465.2998298 J/mol
Entropy 286.433 J/mol/K
Note: The Answer is different with that of the Book because the Method Used to find the Area under the Graph is done by finding the area of small Rectangles

Example 6.4 page no : 92

In [6]:
import math 

# Variables
T = 500.;			#[K]
R = 8.314;
Tc = 425.1;			#[K]
P = 50.;			#[bar]
Pc = 37.96;			#[bar]
omega = 0.08664;
si = 0.4636;
Tr = T/Tc;
Pr = P/Pc;
alpha_Tr = Tr**(-0.5);			#a(Tr)
#Using Eqn(3.50)
Beta = omega*(Pr/Tr);
#Using Eqn(3.51)
q = si*alpha_Tr/(omega*(Tr**1.5));

#using eqn(3.49)
#Z = 1+beta-q*beta*((Z-beta)/((Z+(epsilon*beta))*(Z+(sigma*beta)))

#calculation of Z
Z = 1;			#Initial
a = Z;
for i in range(11):
    b = 1+Beta-(q*Beta*((a-Beta)/(a*(a+Beta))));
    if((b-a) == 0.0001):
        break;
    a = b;
    i = i+1;

Z = round(b,3)

#Umath.sing Eqn(6.64) and eqn(6.65)
#(Hr/RT) = Z-1+[(d ln(alpha_Tr)/d ln Tr)-1]qI   I = ln((Z+beta)/Z)  d ln(alpha_Tr)/d ln Tr = -0.5
#Sr/R) = ln(Z-beta)+[d ln(alpha_Tr)/d ln Tr]qI  I = ln((Z+beta)/Z)  d ln(alpha_Tr)/d ln Tr = -0.5
I = math.log((Z+Beta)/Z);
Hr = round(R*T*(Z-1+((-0.5-1)*q*I)),0);
Sr = round(R*(math.log(Z-Beta)+(-0.5*q*I)),3);

print ('Using Redlich/Kwong Equation')
print 'Residual Enthalpy',Hr,'J/mol'
print 'Residual Entropy',Sr,'J/mol/K'
Using Redlich/Kwong Equation
Residual Enthalpy -4504.0 J/mol
Residual Entropy -6.545 J/mol/K

Example 6.6 page no : 93

In [7]:
# Variables
P1 = 1000.;			#[KPa]
T = 533.15;			#[K]
P2 = 200.;			#[KPa]
H1 = 2965.2;			#[KJ/kg]  from Steam tables
S1 = 6.9680;			#[KJ/Kg/K] From steam tables
S2 = S1;
S_l = 1.5301;			#[KJ/Kg/K]  Entropy Of Saturated Liquid @ 200KPa
S_v = 7.1268;			#[KJ/Kg/K]  Entropy Of Saturated vapor  @ 200KPa
H_l = 504.7;			#[KJ/Kg]     Enthalpy Of saturated liquid @ 200KPa
H_v = 2706.7;			#[KJ/Kg]    Enthalpy Of saturated vapor @ 200KPa

# Calculations
#find x_v from the eqn S = (1-x_v)S_l+x_c*S_v
x_v = round((S1-S_l)/(S_v-S_l),4);

#From Eqn(6.73a)
H2 = ((1-x_v)*H_l)+(x_v*H_v);
del_H = round(H2-H1,0);			#[KJ/Kg]

# Results
print 'Percent vapor',x_v*100,'%'
print 'Percent Liquid',(1-x_v)*100,'%'
print 'Change In Enthalpy',del_H,'KJ/Kg'
Percent vapor 97.16 %
Percent Liquid 2.84 %
Change In Enthalpy -321.0 KJ/Kg

Example 6.7 page no : 96

In [10]:
import math 
from numpy import array,linalg

# Variables(from steam tables)
H = 293.;			#[KJ/Kg]  at 343.15K
H_liquid = 419.1;			#[KJ/Kg]  at 373.15K
H_vapor = 2676;			#[KJ/Kg]    at 373.15K
V_vapor = 1.5;			#[m**3]
m1_liquid = 500.;			#[Kg]
rho_liquid = 0.001044;			#[m**3/Kg]
rho_vapor = 1.673;			#[m**3/Kg]
del_m = 750.;			#[Kg]

# Calculations
#using the eqn Q = (m2H2)math.tank-(m1H1)math.tank-(H*del_m)math.tank
m1_vapor = (V_vapor-(m1_liquid*rho_liquid))/rho_vapor;
#Term2 = ((m1H1)math.tank
Term2 = (m1_liquid*H_liquid)+(m1_vapor*H_vapor);
mT = m1_liquid+del_m+m1_vapor;
#Solving Eqn By matrix Method
#m_vapor+m_liquid = mT  and   (rho_vapor*m_vapor)+(rho_liquid*rho_vapor) = V_vapor
A = array([[1,1],[rho_vapor,rho_liquid]]);
B = array([mT,V_vapor]);
X = linalg.solve(A,B);
m2_vapor = X[0]
m2_liquid = X[1]

Term1 = (m2_liquid*H_liquid)+(m2_vapor*H_vapor);
Q = round(Term1-Term2-del_m*H,0);

print 'Heat Required',Q,'KJ'
print ('Note: The Answer Varies With That of The Book because the calculations as \
 in Book do not give the Answer the Book results')
Heat Required 93518.0 KJ
Note: The Answer Varies With That of The Book because the calculations as  in Book do not give the Answer the Book results

Example 6.8 page no : 98

In [13]:
import math 
from numpy import array,linalg


def SRB(Tr,Pr,omega):
    B0 = 0.083-(0.422/(Tr**1.6));
    diffr_B0 = 0.675/(Tr**2.6);			#dB0/dTr
    B1 = 0.139-(0.172/(Tr**4.2));
    diffr_B1 = 0.722/(Tr**5.2);			#dB0/dTr
    Q = -Pr*(diffr_B0+(omega*diffr_B1));
    return Q

def HRB(Tr,Pr,omega):
    B0 = 0.083-(0.422/(Tr**1.6));
    diffr_B0 = 0.675/(Tr**2.6);			#dB0/dTr
    B1 = 0.139-(0.172/(Tr**4.2));
    diffr_B1 = 0.722/(Tr**5.2);			#dB0/dTr
    H = Pr*(B0-(Tr*diffr_B0)+(omega*(B1-(Tr*diffr_B1))));
    return H

def ICPS(T0,T,A,B,C,D):
    t = T/T0;
    return ((A)*math.log(t))+(((B*T0)+(((C*T0*T0)+(D/(t*t*T0*T0)))*(t+1)/2))*(t-1))

def ICPH(T0,T,A,B,C,D):
    t = T/T0;
    return (A+((B/2)*T0*(t+1))+((C/3)*T0*T0*((t**2)+t+1))+(D/(t*T0*T0)))*(T-T0)

# Variables(from steam tables)
Tc = 420.;			#[K]
Pc = 40.43;			#[bar]
omega = 0.191;
Tn = 266.9;			#[K]
A0 = 1.967;
B0 = 31.630*10**-3;
C0 = -9.837*10**-6;
D0 = 0;
T1 = 473.15;			#[K]
P = 70.;			#[bar]
R = 8.314;
#From Table(E.3) And Table(E.4)
Z0 = 0.485;
Z1 = 0.142;

Tr = T1/Tc;
Pr = P/Pc;
Z = Z0+(omega*Z1);
V = round((Z*R*T1*10**-2)/P,4);			#[m**3/Kmol]

#step(a) vaporization at T1 and P1 = P_saturated
#umath.sing eqn(6.70)  lnP_sat = A-(B/T)
#Solving eqn ln(1.0133) = A-(B/266.9) and ln(40.43) = A-(B/420)
a = array([[1,(-1/266.9)],[1,(-1./420)]])
b = array([math.log(1.0133),math.log(40.43)]);
x = linalg.solve(a,b)
A = x[0]
B = x[1]
#umath.sing eqn(4.12)  del_Hn/RTn = 1.092*(ln Pc-1.013)/(0.930-Tr_n)
Tr_n = Tn/Tc;
del_Hn = R*Tn*(1.092*(math.log(Pc)-1.013)/(0.93-Tr_n));			#[J/mol]
T2 = 273.15;			#[K]
Tr = T2/Tc;
#Umath.sing Eqn(4.13)  del_H/del_Hn = ((1-Tr)/(1-Tr_n))**0.38
del_H_a = del_Hn*((1-Tr)/(1-Tr_n))**0.38;
del_S_a = round(del_H_a/T2,2);

#Step(b)transition to ideal gas State at(T1,P1)
P_sat = math.exp(A-(B/273.15));
Pr = P_sat/Pc;
Tr = T2/Tc;
Hr_b = round(R*Tc*HRB(Tr,Pr,omega),0)			#[J/mol]
Sr_b = round(R*SRB(Tr,Pr,omega),2)			#[J/mol/K]

#Step(c) Change to (T2,P2) in ideal-gas state

H_c = round(R*ICPH(T2,T1,A0,B0,C0,D0),0);			#[J/mol]
S = R*ICPS(T2,T1,A0,B0,C0,D0);			#[J/mol/K]
del_S_c = round(S-(R*math.log(P/P_sat)),2);			#[J/mol/K]

#Step(d) Transition to actual final state at(T2,P2)
#Umath.sing eqn(6.76) and eqn(6.77)
#Hr/RTc = Hr0/RTc+(omega*Hr1/RTc)
#Sr/R = Sr0/R+(omega*Sr1/R)  Sr0,Sr1 from Tables(E.5)
Tr = T1/Tc;
Pr = P/Pc;
Hr_d = R*Tc*(-2.294+(omega*-0.713));
Sr_d = R*(-1.566+(omega*-0.726));

H = round(del_H_a-Hr_b+H_c+Hr_d,0);
S = round(del_S_a-Sr_b+del_S_c+Sr_d,2);
U = round(H-(P*V*10**2),0);

print 'Volume(V) = ',V,'m**3/Kmol'
print 'Internal energy(U) = ',U,'J/mol'
print 'Enthalpy(H) = ',H,'J/mol'
print 'Entropy(S) = ',S,'J/mol/K'

print ('Note: The Answer here Slightly Varies with That of Book because of the different approximation')
Volume(V) =  0.2878 m**3/Kmol
Internal energy(U) =  32163.0 J/mol
Enthalpy(H) =  34178.0 J/mol
Entropy(S) =  88.55 J/mol/K
Note: The Answer here Slightly Varies with That of Book because of the different approximation

Example 6.9 page no : 97

In [14]:
# Variables
T = 450.;			#[K]
P = 140;			#[bar]

#pseudo parameters
Tc1 = 304.2;			#[K]
Tc2 = 369.8;			#[K]
Pc1 = 73.83;			#[bar]
Pc2 = 42.48;			#[bar]
Tpc = (0.5*Tc1)+(0.5*Tc2);
Ppc = (0.5*Pc1)+(0.5*Pc2);

# Calculations
Tpr = T/Tpc;
Ppr = P/Ppc;

Z0 = 0.697;
Z1 = 0.205;

omega1 = 0.224;
omega2 = 0.152;
omega = (0.5*omega1)+(0.5*omega2);

Z = Z0+(omega*Z1);

V = round(Z*R*T*10/P,1);			#[cm**3/mol]

#(H/RT)0 = -1.73 (H/RT)1 = -0.169
H = round(R*Tpc*(-1.73+(omega*-0.169)),0);			#[J/mol]
S = round(R*(-0.967+(omega*-0.330)),2);			#[J/mol/K]

# Results
print 'Volume(V) = ',V,'cm**3/mol'
print 'Residual Enthaply(H) = ',H,'J/mol'
print 'Residual Entropy(S) = ',S,'J/mol/K'
Volume(V) =  196.6 cm**3/mol
Residual Enthaply(H) =  -4936.0 J/mol
Residual Entropy(S) =  -8.56 J/mol/K