Chapter 4 : Minimization of Gibbs Free energy

Example 4.1 Page: 67

In [4]:
import math 

T = 671.7               #[R] Equilibrium temperature
m_steam = 1.            #[lbm] Condenmath.sing amount of the steam
delta_h_condensation = -970.3       #[Btu/lbm] Enthalpy change of the steam
delta_s_condensation = -1.4446      #[Btu/(lbm*R)] Entropy change of the steam

delta_g_condensation = delta_h_condensation - T*delta_s_condensation        #[Btu/lbm]


print "Gibb''s free energy change of the steam is %0.1f Btu/lbm"%(delta_g_condensation)
Gibb''s free energy change of the steam is 0.0 Btu/lbm

Example 4.2 Page: 77

In [3]:
from numpy import *
from matplotlib.pyplot import *
import math 

%matplotlib inline

g_g = 0.00          #[kJ/mol] 
g_d = 2.90          #[kJ/mol]

v_g = 5.31*10**(-1)             #[kJ/(mol*kbar)]
v_d = 3.42*10**(-1)             #[kJ/(mol*kbar)]


D_g = v_g               #[J/(mol*Pa)] For graphite
D_d = v_d               #[J/(mol*Pa)] For diamond


P = linspace(0,30,30).T

plot(P, D_d*P+g_d )
plot(P,D_g*P+g_g )
xlabel("Pressure, P, kbar");
ylabel("Gibb''s free energy per mol, g, kJ/mol");
legend(['Diamond, slope = 0.342 (kJ/mol)/kbar','Graphite, slope = 0.532 (kJ/mol)/kbar']);

show()
print " Gibb's free energy-pressure diagram for graphite-diamond system at 25 degC is as shown in the graphic window. "
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['draw_if_interactive']
`%pylab --no-import-all` prevents importing * from pylab and numpy
 Gibb's free energy-pressure diagram for graphite-diamond system at 25 degC is as shown in the graphic window. 

Example 4.3 Page: 80

In [6]:
from scipy.optimize import fsolve 
import math 


K = 4.52


def f(x_iso): 
	 return  x_iso/(1-x_iso)-K
x_iso = fsolve(f,0)

print " Mole fraction of isobumath.tane isomer in equilibrium is %0.2f"%(x_iso)
 Mole fraction of isobumath.tane isomer in equilibrium is 0.82
In [ ]: