## Calculate the critical free energy of nucleation of ice from water and critical radius
import math
del_t1 = 0.## temperature difference in degree Celsius
del_t2 = -5. ## temperature difference in degree Celsius
del_t3 = -40. ## temperature difference in degree Celsius
del_h = 6.02 ## enthalpy of fusion in kJ/mol
T_m = 273. ## mean temperature
Gamma = 0.076 ## energy of ice water interface in J /m**2
v = 19 ## molar volume of ice
print("\n Example 9.1")
print("\n Part A")
print'%s %.2f %s '%("\n At del_t = ",del_t1,", there is no supercooling. So there is no critical radius")
print("\n\n Part B")
del_f = 16./3.*math.pi*(Gamma)**3.*T_m**2./((del_h*1e3*1e6/v)**2.*del_t2**2.)
r = 2.*T_m*Gamma/(-del_h*1e3*1e6/v*del_t2)
print'%s %.2e %s '%("\n Critical free energy of nucleation is ",del_f,"J")
print'%s %.2f %s '%("\n Critical radius is ",math.ceil(r*1e10),"angstrom")
print("\n\n Part C")
temp_r = del_t3/del_t2
del_f_ = del_f/temp_r**2
r_ = r/temp_r
print'%s %.2e %s '%("\n Critical free energy of nucleation is ",del_f,"J")
print'%s %.2f %s '%("\n Critical radius is ", math.ceil(r_*1e10),"angstrom")
## Calculate the change in del_f required to increase nucleation rate
import math
T= 300. ## temperature in kelvin
R = 8.314 ## universal gas constant
k = 2.303 ## conversion factor
a1 = 1e42
a2 = 1e6 ## nucleation rate
a3 = 1e10 ## nucleation rate
print("Example 9.2")
I1 = (math.log10(a1)-math.log10(a2))*k*R*T ## exponent factor
I2 = (math.log10(a1)-math.log10(a3))*k*R*T## exponent factor
del_f = I1-I2 ## difference
a = 10**(math.log10(a3)-math.log10(a2))
print'%s %.2f %s %.2e %s %.2e %s '%("\n A change of",math.ceil(del_f/1e3)," KJ mol^-1" "energy is required to increase nucleation factor from \n",a," m^-3 s^-1 to " "",a3," m^-3 s^-1 ")
## Calculate del_f_het as a fraction of del_f_homo
import math
Gamma_alpha_del = 0.5 ## in J m**-2
Gamma_alpha_beta = 0.5 ## in J m**-2
Gamma_beta_del = 0.01 ## in J m**-2
print("\n Example 9.4")
theta = math.cos((Gamma_alpha_del -Gamma_beta_del)/Gamma_alpha_beta)*57.3
del_f_ratio = 1/4.*(2.-3.*math.cos(theta)+(math.cos(theta))**3)
print'%s %.2f %s '%("\n del_f_het is ",del_f_ratio,"th fraction of del_f_homo.")
#due to round off error
## Calculate the free energy change during recrystallization
mu = 45.5e9
b = 2.55e-10
n1 = 1e9 ## initial dislocation density
n2 = 1e13 ## final dislocation density
print("\n Example 9.6")
E = 1./2.*mu*b**2.*n2
del_g = E ## as difference between initial and final dislocation energy is four order magnitude
print'%s %.2f %s '%("\n Free energy change during recrystallization is ",-del_g," J m^-3")
## Numerical value of answer in book is 14800