import math
# Variables
h_cap_H2O = 2676.0 ; #[kJ/kg],From steam table
S_cap_H2O = 7.3548 ; #[kJ/kgK],From steam table
h_cap_0_H2O = 2687.5 ; #[kJ/kg],From Appendix B
S_cap_0_H2O = 8.4479 ; #[kJ/kgK],From Appendix B
P_0_H2O = 10. ; #[kPa]
T = 373.15 ; #[K]
R = 8.314 / 18 ;
P_sys = 101.35 ; #[kPa]
# Calculations
g_cap_H2O = h_cap_H2O - T * S_cap_H2O ;
g_cap_0_H2O = h_cap_0_H2O - T * S_cap_0_H2O ;
f_H2O = P_0_H2O * math.exp((g_cap_H2O - g_cap_0_H2O ) / (R * T)) ;
Sai_H2O = f_H2O / P_sys ;
# Results
print "The fugacity = %.2f kPa The fugacity coefficient = %.3f"%(f_H2O,Sai_H2O);
# Variables
P = 50. #[bar]
T = 25. + 273.2 #[K]
P_c = 48.7 ; #[bar] , From Appendix A.1 Table C.7 & C.8
T_c = 303.5 ; #[K] , From Appendix A.1 Table C.7 & C.8
w = 0.099 ; # From Appendix A.1 Table C.7 & C.8
log_w_0 = -0.216 ; # By interpolation
log_w_1 = -0.060 ; # By interpolation
# Calculations
X = log_w_0 + w * log_w_1 ;
sai_eth = 10**(X) ;
f_eth = sai_eth * P ;
# Results
print "Fugacity = %.f bar"%(f_eth);
# Variables
import math
gama_a_inf = 0.88 ;
gama_b_inf = 0.86 ;
R = 8.314 ;
T = 39.33 + 273 ;
# Calculations
A_1 = R * T * math.log(gama_a_inf) ;
A_2 = R * T * math.log(gama_b_inf) ;
A = (A_1 + A_2) / 2 ;
# Results
print "The average value of two-suffix Margules parameter A = %.f J/mol"%(A);
# Variables
A_T1 = 1401. ; #[J/mol]
T1 = 10 + 273. ; #[K]
T2 = 60 + 273. ; #[K]
C = 3250. ;
A_T2_prev = 1143. ; #[J/mol]
# Calculations and Results
A_T2 = T2 * (C *(1./T2 - 1./T1) + A_T1 / T1);
print "Value of A at 60*C = %.f J/mol"%(A_T2) ;
x = (A_T2_prev - A_T2) / A_T2_prev* 100 ;
print "The values differ by = %.f %%"%(x)
# Note: Answer may vary because of rounding off error.