In [10]:

```
import math
T = 300. #[K] Temperature of the natural gas well
R = 8.314 #[J/(mol*K)] universal gas consmath.tant
z_1 = 0 #[m]
y_methane_surf = 85./100 #[mol%]
y_ethane_surf = 10/100. #[mol%]
y_propane_surf = 5/100. #[mol%]
P = 2. #[MPa] Total equilibrium pressure
z_2 = 1000. #[m] Depth of the well
M_methane = 16./1000 #[kg/mol]
M_ethane = 30./1000 #[kg/mol]
M_propane = 44./1000 #[kg/mol]
g = 9.81 #[m/s**(2)]
f_methane_1 = y_methane_surf*P #[MPa]
f_ethane_1 = y_ethane_surf*P #[MPa]
f_propane_1 = y_propane_surf*P #[MPa]
f_methane_2 = f_methane_1*math.exp((-M_methane*g*(z_1-z_2))/(R*T)) #[MPa]
f_ethane_2 = f_ethane_1*math.exp((-M_ethane*g*(z_1-z_2))/(R*T)) #[MPa]
f_propane_2 = f_propane_1*math.exp((-M_propane*g*(z_1-z_2))/(R*T)) #[MPa]
P_2 = (f_methane_2 + f_ethane_2 + f_propane_2 ) #[MPa]
y_methane_2 = f_methane_2/P_2
y_ethane_2 = f_ethane_2/P_2
y_propane_2 = f_propane_2/P_2
print "The mol fraction of the methane at the depth 1000m is %f"%(y_methane_2)
print "The mol fraction of the ethane at the depth 1000m is %f"%(y_ethane_2)
print "The mol fraction of the propane at the depth 1000m is %f"%(y_propane_2)
```

In [11]:

```
import math
T = 288. #[K] Atmospheric temperature
R = 8.314 #[J/(mol*K)] universal gas consmath.tant
z_2 = 15000. #[m] Thickness of the atmosphere
z_1 = 0. #[m] Surface
y_N2_1 = 0.79
y_O2_1 = 0.21
M_N2 = 28./1000 #[kg/mol]
M_O2 = 32./1000 #[kg/mol]
g = 9.81 #[m/s**(2)]
a = math.exp(-(M_N2-M_O2)*g*(z_2-z_1)/(R*T))
yi2_by_yi1 = 1/(y_N2_1 + y_O2_1/a)
print " Concentration of the nitrogen at the top of atmosphere with respect to the concentration of nitrogen \
at the surface of the earth is yi2_by_yi1 = %0.2f"%(yi2_by_yi1)
```

In [12]:

```
import math
T = 288. #[K] Atmospheric temperature
R = 8.314 #[J/(mol*K)] Universal gas consmath.tant
z_2 = 10. #[m] Height of the reactor
z_1 = 0. #[m] Surface
g = 9.81 #[m/s**(2)] Accelaration due to gravity
y_N2_1 = 0.79
y_O2_1 = 0.21
M_N2 = 28./1000 #[kg/mol]
M_O2 = 32./1000 #[kg/mol]
a = math.exp(-(M_N2-M_O2)*g*(z_2-z_1)/(R*T))
yi2_by_yi1 = 1/(y_N2_1 + y_O2_1/a)
print " Concentration of the nitrogen at the top of reactor with respect to the concentration of nitrogen \
at the bottom of reactor is yi2_by_yi1 = %f"%(yi2_by_yi1)
```

In [4]:

```
import math
T = 300. #[K] Temperature of the centrifuge
R = 8.314 #[J/(mol*K)] Universal gas consmath.tant
y_UF6_238_1 = 0.993 # Mole fraction of UF6 with 238 isotope of uranium in feed
y_UF6_235_1 = 0.007 # Mole fraction of UF6 with 235 isotope of uranium in feed
M_UF6_238 = 352./1000 #[kg/mol] Molecular weight of UF6 with 238 isotope of uranium
M_UF6_235 = 349./1000 #[kg/mol] Molecular weight of UF6 with 235 isotope of uranium
r_in = 2./100 #[m] Interanal raddi of the centrifuge
r_out = 10./100 #[m] outer raddi of the centrifuge
f = 800. #[revolution/second] Rotational frequency of centrifuge
a = math.exp((M_UF6_235-M_UF6_238)*(2*3.141592*f)**(2)*(r_out**(2)-r_in**(2))/(2*R*T))
A = 1./(y_UF6_235_1 + y_UF6_238_1/a)
B = 1./A
print "The ratio of the mole fraction of UF6 with uranium 235 isotope) at the 2 cm radius to\
that at the 10 cm radius is %0.3f"%(B)
```

In [13]:

```
import math
x_water_1 = 0.98 # mole fraction of water in phase 1 i.e. in seawater
x_water_2 = 1. # mole fraction of water in the phase 2 i.e. in water
R = 10.73 #[(psi*ft**(3))/(lbmol*R)] Universal gas consmath.tant
T = 500. #[R] temperature
v_water_1 = 18/62.4 # [ft**(3)/(lbmol)]
delta_P = (-(R*T)*math.log(x_water_1))/v_water_1#[psi]
print "The pressure difference between the two phases is %0.1f psi"%(delta_P)
```

In [14]:

```
import math
T = 100. #[C] Temperature of the outside
P_outside = 1. #[atm]
T = 0.05892 #[N/m] From metric steam table (7, page 267)
d_1 = 0.001 #[m]
delta_P_1 = (4*T)/d_1 #[Pa]
d_2 = 10**(-6) #[m]
delta_P_2 = (4*T)/d_2 #[Pa]
d_3 = 0.01*10**(-6) #[m]
delta_P_3 = (4*T)/d_3 #[Pa]
print "Pressure difference with the change in radius of the drop of the water is given as in the following table"
print " Diameter of the droplet d_iin meter Pressure difference P_inside - P_outside in atm"
print " %0.2e %0.2e"%(d_1,delta_P_1)
print " %0.2e %0.2e"%(d_2,delta_P_2)
print " %0.2e %0.2e"%(d_3,delta_P_3)
```

In [15]:

```
import math
P_NBP = 1. #[atm]
Temp =273.15+100 #[C] Temperature
D = 0.01*10**(-6) #[m] Diameter of the condensation nuclei( due to impurity )
T = 0.05892 #[N/m] Surface tension between water drops and gas
R = 8.314 #[J/(mol*K)]
v_water_liquid = 1/958.39*0.018 #[m**(3)/mol]
I = math.exp(v_water_liquid*(4*T/D)/(R*Temp))
P_gas_minus_P_NBP = (I-1)*P_NBP #[atm]
delta_P = P_gas_minus_P_NBP*1.01325 #[bar]
delta_P_1 = delta_P*100*0.1450377 #[psi]
print "The equilibrium pressure at which the steam begin to condence at this temperature on \
the nuclei is %f psi above the normal boiling point."%(delta_P_1)
```

In [16]:

```
import math
from scipy.integrate import quad
Temp = 273.15+100 #[K] Temperature of the water drop
R = 8.314 #[J/(mol*K)] Universal gas consmath.tant
D = 0.01*10**(-6) #[m] Diameter of the water drop
P_g = 0.15 #[bar] guage pressure
T = 0.05892 #[N/m] Surface tension between water drop and gas
v_water_liquid = 0.018/958.39 #[m**(3)/mol]
P_NBP = 1.013 #[bar]
P_gas = 1.013+0.15 #[bar]
P_1 = P_gas + 4*T/D #[bar]
def f2(P):
return v_water_liquid*P**(0)
delta_g_1 = quad(f2,P_NBP,P_1)[0]
def f3(P):
return (R*Temp)/P
delta_g_2 = quad(f3,P_NBP,P_gas)[0]
delta_g = (delta_g_1 - delta_g_2)
print "The liquid can lower its free energy %0.2f J/mol by Changing to gas,"%(delta_g)
print "So that even at 0.15 bar above the normal boiling point, a drop of this small size is unstable and will quickly evaporate."
```

In [17]:

```
from scipy.optimize import fsolve
import math
Temp = 904.7 #[R] Temperature of the pure liquid water
P_NBP = 400. #[psia] Saturation pressure of the pure liquid water at the given temperature
T = 1.76*10**(-4) #[lbf/inch] Surface tension of water
R = 10.73 #[(psi*ft**(3))/(lbmol*R)]
v_water_liquid = 18*0.01934 #[ft**(3)/lbmol]
D = 10**(-5.) #[inch]
def f(p):
return v_water_liquid*(p - P_NBP)-(R*Temp)*math.log((p+4*T/D)/P_NBP)
P_liquid = fsolve(f,300)
P_inside = P_liquid + 4*T/D #[psia]
print "The liquid pressure at which these boiling nuclei will begin to grow and intiate boiling is %0.1f psia"%(P_liquid)
print "At this external pressure the pressure inside the bubble is %0.1f psia"%(P_inside)
```

In [ ]:

```
```