In [16]:

```
# Variables
V = 0.1; #volume of mixture required (m**3)
Ve = 0.03; #volume of alcohol
Vw = 0.07; #volume of water
de = 789.; #density of ethanol (kg/m**3)
dw = 997.; #density of water (kg/m**3)
pe = 53.6*10**-6; #partial molar volume of ethanol (m**3/mol)
pw = 18.*10**-6; #partial molar volume of water (m**3/mol)
Me = 46.; #molecular wt of ethanol
Mw = 18.; #molecular wt of water
# Calculations
#To find the volume of mixture
ne = (Ve*de*10**3)/Me; #number of moles of ethanol
nw = (Vw*dw*10**3)/Mw; #number of moles of water
xe = ne/(ne+nw) #mole fraction of ethanol
xw = 1-ne; #mole fraction of water
act_V = (ne*pe)+(nw*pw)
# Results
if (V==act_V) :
print 'It is possible to prepare the required solution'
else:
Ve_act = (Ve/act_V)*V;
Vw_act = (Vw/act_V)*V;
print ' For the given volumes of ethanol and water, it is not possible to prepare 0.1 cubic m of mixture'
print ' Required volume of ethanol is %f cubic m'%Ve_act
print ' Required volume of water is %f cubic m'%Vw_act
```

In [17]:

```
# Variables
V = 2.; #volume of desired solution (m**3)
x1 = 0.3; #moles fraction of methanol
x2 = 0.7; #moles fraction of water
V1 = 38.632*10**-6; #partial molar volume of methanol (m**3/mol)
V2 = 17.765*10**-6; #partial molar volume of water (m**3/mol)
mol_V1 = 40.727*10**-6; #molar volume of ethanol (m**3/mol)
mol_V2 = 18.068*10**-6; #molar volume of water (m**3/mol)
# Calculations
#To find the required volume of methanol and water
V_mol = (x1*V1)+(x2*V2); #molar volume of desired solution
n = V/V_mol; #no. of moles in the desired solution
n1 = x1*n; #moles of methanol
n2 = x2*n; #moles of water
V_m = n1*mol_V1;
V_w = n2*mol_V2;
# Results
print 'Volume of methanol to be taken is %f cubic m'%V_m
print ' Volume of water to be taken is %f cubic m'%V_w
```

In [18]:

```
# Variables
V1_w = 0.816*10**-3; #partial molar volume of water in 96% alcohol solution
V1_e = 1.273*10**-3; #partial molar volume of ethanol in 96% alcohol solution
V2_w = 0.953*10**-3; #partial molar volume of water in 56% alcohol solution
V2_e = 1.243*10**-3; #partial molar volume of ethanol in 56% alcohol solution
d = 0.997*10**3; #density of water (kg/m**3)
# Calculations
#To calculate the volume of water to be added and volume of dilute alcohol solution
#Basis:
V = 2*10**-3; #volume of alcohol solution (m**3)
V_sp = (0.96*V1_e)+(0.04*V1_w); #volume of 1 kg of laboratory alcohol
m_e = V/V_sp; #mass of 2*10**-3 m**3 alcohol
#(a).
#Let mass of water added be m kg
#Taking an alcohol balance
m = (m_e*0.96)/0.56 - m_e;
v = m/d;
# Results
print ' (a).'
print ' Mass of water added is %f kg'%m
print ' Volume of water added is %4.3e cubic m'%v
#(b)
m_sol = m_e + m; #mass of alcohol solution obtained
sp_vol = (0.56*V2_e)+(0.44*V2_w); #specific volume of 56% alcohol
V_dil = sp_vol*m_sol; #volume of dilute alcohol solution
print ' (b)'
print ' Volume of dilute alcohol solution is %5.4e cubic m'%V_dil
```

In [19]:

```
# Variables
x1= .3
x2 = .7
# Calculations and Results
H = 400.*x1 + 600*x2 + x1*x2*(40*x1+20*x2)
H1 = 420.-60+40;
#Using eq. 7.28 (Page no. 264)
#H = H2_bar as x2 = 1
H2 = 600.;
print ' (b).'
print ' Pure state enthalpies are:'
print ' H1 = %i J/mol'%H1
print ' H2 = %i J/mol'%H2
#(c).
#H1_inf = H1_bar as x1 = 0, so from eq. 7.27
H1_inf = 420.;
#H2_inf = H2_bar as x2 = 0. so from eq 7.28
H2_inf = 640.;
print ' (c).'
print ' At infinite dilution:'
print ' H1 = %i J/mol'%H1_inf
print ' H2 = %i J/mol'%H2_inf
```

In [20]:

```
def V(m):
y = 1.003*10**-3 + 0.1662*10**-4*m + 0.177*10**-5*m**1.5 + 0.12*10**-6*m**2
return y
# Variables
m = 0.1; #molality of solution (mol/kg)
# Calculations
#To calculate the partial molar volume of the components
#Differentiating Eq. 7.29 with reference to m, we get
V1_bar = 0.1662*10**-4 + 0.177*1.5*10**-5*m**0.5 + 0.12*2*10**-6*m;
V_sol = V(m) #volume of aqueous soluttion
n1 = m;
n2 = 1000./18;
V2_bar = (V_sol - n1*V1_bar)/n2;
# Results
print 'Partial molar volume of water = %4.3e cubic m/mol'%V2_bar
print ' Partial molar volume of NaCl = %4.3e cubic m/mol'%V1_bar
```

In [21]:

```
# Variables
K = 4.4*10**4; #Henry's law constant (bar)
pp = 0.25; #partial pressure of oxygen in bar
M_O2 = 32.; #molecular wt of oxygen
M_water = 18.; #molecular wt of water
# Calculations and Results
#To estimate the solubility of oxygen in water at 298 K
#Using eq. 7.72 (Page no. 275)
x_O2 = pp/K; #mole fraction of O2
print 'Solubility of oxygen is %5.4e moles per mole of water'%x_O2
#In mass units
sol_O2 = (x_O2*M_O2)/M_water;
print ' Solubility of oxygen in mass units is %4.3e kg oxygen per kg water'%sol_O2
```

In [1]:

```
%matplotlib inline
from numpy import *
from matplotlib.pyplot import *
import numpy
# Variables
xb = array([0, 0.2, 0.4, 0.6, 0.8, 1.0])
pa_bar = [0.457 ,0.355, 0.243, 0.134, 0.049, 0];
pb_bar = [0,0.046, 0.108, 0.187, 0.288, 0.386];
#To confirm mixture conforms to Raoult's Law and to determine Henry's law constant
xa = 1 - xb
plot(xa,pa_bar)
plot(xa,pb_bar)
# Calculations and Results
#For Henry's law plotting
x = [0,0.2, 0.4 ,0.6 ,0.8 ,1.0];
#Form the partial presures plot of component A and B
yh1 = [0,0,0,0,0,0]
yh1[0] = 0;
yh1[1] = 0.049; #For component A
for i in range(2,6):
yh1[i] = yh1[i-1]+(x[i]-x[i-1])*((yh1[1]-yh1[0])/(x[1]-x[0]))
yh_2 = [0,0,0,0,0,0]
yh_2[5] = 0;
yh_2[4] = 0.046; #For component B
i = 3;
while (i>=0):
yh_2[i] = yh_2[i+1] + (x[i]-x[i+1])*((yh_2[5]-yh_2[4])/(x[5]-x[4]))
i = i-1;
plot(x,yh1)
plot(x,yh_2)
#legend("Partial pressure "," ","Raoults law"," ","Henrys Law"
show()
#(a)
print 'From the graph it can be inferred that, in the region where Raoults law is obeyed by A, the Henrys law is obeyed by B, and vice versa'
#(b)
#Slope of Henry's law
print ' For component A, Ka = %f bar'%yh1[5]
print ' For component B, Kb = %f bar'%yh_2[0]
```

In [23]:

```
from numpy import array
# Variables
xa = array([0, 0.2, 0.4, 0.6, 0.8, 1.0]);
Pa_bar = [0 ,0.049, 0.134, 0.243, 0.355, 0.457];
Pb_bar = [0.386 ,0.288, 0.187, 0.108, 0.046, 0];
# Calculations and Results
#To calculate activity and activity coeffecient of chloroform
xb = 1-xa;
Pbo = 0.386; #vapour pressure of pure chloroform
#(a). Based on standard state as per Lewis-Randall rule
print 'Based on Lewis Randall Rule'
print ' Activity Activity coeffecient'
a = [0,0,0,0,0,0]
ac = [0,0,0,0,0,0]
for i in range(6):
a[i] = Pb_bar[i]/Pbo;
print ' %f'%a[i],
if(xb[i]==0):
print ' Not defined',
else:
ac[i] = a[i]/xb[i];
print ' %f'%ac[i]
#(b). Based on Henry's Law
Kb = 0.217; #bar (From Example 7.11 Page no. 276)
print '\n\n Based on Henrys Law'
print ' Activity Activity coeffecient'
for i in range(6):
a[i] = Pb_bar[i]/Kb;
print ' %f'%a[i],
if(xb[i]==0):
print ' Not defined',
else:
ac[i] = a[i]/xb[i];
print ' %f'%ac[i]
```

In [24]:

```
# Variables
P = 20.; #pressure in bar
# Calculations and Results
def f1(x1):
y = (50*x1)-(80*x1**2)+(40*x1**3)
return y
#To determine fugacity fugacity coeffecient Henry's Law constant and activity coeffecient
#(a)
#Fugacity of component in solution becomes fugacity of pure component when mole fraction approaches 1 i.e.
x1 = 1.;
f1_pure = f1(x1);
print '(a). Fugacity f1 of pure component 1 is %i bar'%f1_pure
#(b)
phi = f1_pure/P;
print ' (b). Fugacity coeffecient is %f'%phi
#(c)
#Henry's Law constant is lim (f1/x1)and x1 tends to 0
x1 = 0;
K1 = 50 - (80*x1) + (40*x1**2);
print ' (c). Henrys Law constant is %i bar'%K1
#(d)
print ' (d). This subpart is theoretical and does not involve any numerical computation'
```

In [25]:

```
# Variables
H1_pure = 400.; #enthalpy of pure liquid 1 at 298 K and 1 bar (J/mol)
H2_pure = 600.; #enthalpy of pure liquid 2 (J/mol)
x1 = 0.;
# Calculations
delH1_inf = 20*((1-x1)**2)*(2*x1+1);
H1_inf = H1_pure + delH1_inf; #(J/mol)
#For infinite dilution of 2, x1 = 1 and delH2_inf = H2_bar
x1 = 1.;
delH2_inf = 40.*x1**3;
H2_inf = delH2_inf + H2_pure; #(J/mol)
# Results
print 'Enthalpy at infinite dilution for component 1 is %i J/mol'%H1_inf
print ' Enthalpy at infinite dilution for component 2 is %i J/mol'%H2_inf
```

In [26]:

```
# Variables
R = 8.314; #ideal gas constant
n1 = 100.; #moles of nitrogen
n2 = 100.; #moles of oxygen
# Calculations
#To determine the change in entropy of the contents of the vessel
x1 = n1/(n1+n2);
x2 = n2/(n1+n2);
import math
#Using eq. 7.122 (Page no. 292)
S = -R*(x1*math.log (x1) + x2*math.log (x2));
S_tot = S*(n1+n2);
# Results
print 'Change in entropy of components are %f J/K'%S_tot
```

In [27]:

```
# Variables
Hf = -408.610; #heat of formation (kJ)
#For reaction 2
#LiCl + 12H2O --> LiCl(12H2O)
H_sol = -33.614; #heat of solution (kJ)
#To determine heat of formation of LiCl in 12 moles of water
#Adding reaction 1 and 2% we get
# Calculations
#Li + 1/2Cl2 + 12H2O --> LiCl(12H2O)
H_form = Hf+H_sol;
# Results
print 'Heat of formation of LiCl in 12 moles of water is %f kJ'%H_form
```

In [28]:

```
# Variables
R = 8.314; #ideal gas constant
n1 = 3.; #moles of hydrogen
n2 = 1.; #moles of nitrogen
T = 298.; #temperature in K
P1 = 1.; #pressure of hydrogen in bar
P2 = 3.; #pressure of nitrogen in bar
import math
# Calculations
#To calculate the free energy of mixing
V1 = (n1*R*T)/(P1*10**5); #volume occupied by hydrogen
V2 = (n2*R*T)/(P2*10**5); #volume occupied by nitrogen
V = V1+V2; #total volume occupied
P = ((n1+n2)*R*T)/(V*10**5); #final pressure attained by mixture (bar)
G1 = R*T*(n1*math.log(P/P1) + n2*math.log(P/P2));
#For step 2, using eq. 7.121 (Page no. 292)
x1 = n1/(n1+n2);
x2 = n2/(n1+n2);
G2 = (n1+n2)*R*T*(x1*math.log (x1) + x2*math.log (x2));
G = G1+G2; #free energy in J
# Results
print 'The free energy of mixing when partition is removed is %f kJ'%(G/1000)
```

In [29]:

```
# Variables
C_water = 4.18*10**3; #heat capacity of water (J/kg K)
C_ethanol = 2.58*10**3; #heat capacity of ethanol (J/kg K)
G1 = -758.; #heat of mixing 20 mol percent ethanol water at 298 K(J/mol)
G2 = -415.; #heat of mixing 20 mol percent ethanol water at 323 K (J/mol)
n_wat = 0.8; #moles of water
n_eth = 0.2; #moles of ethanol
T1 = 323.; #initial temperature in K
T2 = 298.; #final temperature in K
# Calculations
#Step 1: Water is cooled from 323 K t0 298 K
H1 = n_wat*18*C_water*(T2-T1)/1000; #(J)
#Step 2: Ethanol is cooled from 323 to 298 K
H2 = n_eth*46*C_ethanol*(T2-T1)/1000; #(J)
#Step 3: 0.8 mol water and 0.2 mol ethanol are mixed at 298 K
H3 = G1; #(J)
#Step 4:
H = G2;
Cpm = (H-H1-H2-H3)/(T1-T2);
# Results
print 'Mean heat capacity of solution is %f J/mol K'%Cpm
```

In [30]:

```
# Variables
To = 298.; #initial temperature (K)
Cpm = 97.65; #Mean heat capacity of solution (J/mol K)
Hs = -758.; #heat of mixing (J/mol)
H = 0.;
# Calculations
T = (H-Hs)/Cpm + To;
# Results
print 'The final temperature attained by the mixing is %f K'%T
```