import math
from numpy import *
# Variables
T = 0 + 273.15; #[K] - Temperature
P = 1; #[atm] - Pressure
x_methanol = 0.5; #Mole fraction of methanol at which molar volume is to be calculated
x_water = 0.5; #Mole fraction at which molar volume is to be calculated
#V = V1 at x1 = 1 and V = V2 at x1 = 0, therefore
V1 = 40.7; #[cm**(3)/mol] - Molar volume of pure component 1
V2 = 18.1; #[cm**(3)/mol] - Molar volume of pure component 2
from numpy import zeros,linalg
x1=[0.114,0.197,0.249,0.495,0.692,0.785,0.892]; # Values of mole fraction of component 1
V=[20.3,21.9,23.0,28.3,32.9,35.2,37.9]; # Values of molar volume
x2=zeros(7); # Mole fraction of component 2
x_V=zeros(7); # x_V = x1*V_1 + x2*V_2
V_mix=zeros(7); # V_mix = V - x1*V_1 - x2*V_2
del_V=zeros(7); #del_V = V_mix/(x1*x2)
# Calculations
for i in range(7):
x2[i]=1-x1[i];
x_V[i]=x1[i]*V1 + x2[i]*V2;
V_mix[i]=V[i]-x1[i]*V1- x2[i]*V2;
del_V[i]=V_mix[i]/(x1[i]*x2[i]);
x1 = array(x1)
#From the matrix method to solve simultaneous linear equations, we have
a=array([[7, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2), sum(x1**3)],[sum(x1**2), sum(x1**3), sum(x1**4)]])
b=array([sum(del_V),sum(x1*del_V),sum((x1**2)*del_V)])
soln=linalg.solve(a,b);
a0=soln[0]
a1=soln[1]
a2=soln[2]
#del_V = V_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)
#V_mix = (a0 + a1*x1 + a2*x1**(2))*(x1*(1 - x1))
# For x1 = 0.5
x1 = 0.5;
V_mix_prime = (a0+(a1*x1)+(a2*x1**2))*(x1*(1-x1)); #[cm**(3)/mol]
#Now differentiating the above equation with respect to x we get
#d/dx(V_mix) = (-4*a2*x1**3) + (3*(a2-a1)*x1**2) + (2*(a1-a0)*x1)+ a0
#Again for x1 = 0.5
x1_prime = 0.5;
del_V_mix_prime = (-4*a2*x1_prime**3)+(3*(a2-a1)*x1_prime**2)+(2*(a1-a0)*x1_prime)+a0;
#Finally,calculating the partial molar volumes
V1_bar = V1 + V_mix_prime + x_water*del_V_mix_prime; #[cm**(3)/mol]
V2_bar = V2 + V_mix_prime - x_methanol*del_V_mix_prime; #[cm**(3)/mol]
# Results
print "The partial molar volume of methanol component 1) is %f cm**3)/mol"%(V1_bar);
print "The partial molar volume of water component 2) is %f cm**3)/mol"%(V2_bar);
# Variables
#component 1 = water
#component 2 = methanol
T = 25 + 273.15; #[K] - Temperature
#delta_V_mix = x_1*x_2*(-3.377 - 2.945*x_1 + 3.31*x_1**(2))
V1 = 18.0684; #[cm**(3)/mol] - Molar volume of pure component 1
V2 = 40.7221; #[cm**(3)/mol] - Molar volume of pure component 2
Vol_1 = 1000; #[cm**(3)] - Volume of pure component 1
Vol_2 = 1000; #[cm**(3)] - Volume of pure component 2
# Calculations
#Moles of the componenets can be calculated as
n_1 = round(Vol_1/V1,4); #[mol]
n_2 = round(Vol_2/V2,4); #[mol]
#Mole fraction of the components
x_1 = round(n_1/(n_1 + n_2),4);
x_2 = round(n_2/(n_1 + n_2),4);
delta_V_mix = round(x_1*x_2*(-3.377 - 2.945*x_1 + 3.31*x_1**(2)),4); #[cm**(3)/mol]
#Differentiating the above equation, we get
#d/dx(delta_V_mix) = (1 - 2*x_1)*(-3.377 - 2.945*x_1 + 3.31*x_1**(2)) + (x_1 - x_1**(2))*(-2.945 + 6.62*x_1)
del_delta_V_mix = round((1 - 2*x_1)*(-3.377 - 2.945*x_1 + 3.31*x_1**(2)) + (x_1 - x_1**(2))*(-2.945 + 6.62*x_1),4); #[cm**(3)/mol]
#Now calculating the partial molar volumes
V1_bar = V1 + delta_V_mix + x_2*del_delta_V_mix; #[cm**(3)/mol]
V2_bar = V2 + delta_V_mix - x_1*del_delta_V_mix; #[cm**(3)/mol]
print del_delta_V_mix, V1_bar, V2_bar
#Finally molar volume of the solution is given by
V_sol = x_1*V1_bar + x_2*V2_bar; #[cm**(3)/mol]
# Total volume of the solution is given by
V_total = (n_1 + n_2)*V_sol; #[cm**(3)]
# Results
print "The molar volume of the solution is %.4f cm**3)/mol"%(V_sol);
print "The total volume of the solution is %.2f cm**3)"%(V_total);
Vol = 20; #[cm**(3)] - Volume of the solution
T = 22 + 273.15; #[K] - Temperature
W_bottle = 11.5485; #[g] - Weight of density bottle
Mol_meth = 32.04; #Molecular weight of methanol
Mol_water = 18.015; # Molecular weight of water
#Density of pure components can be found out at 0% and 100% of volume percent.
den_meth = 0.7929; #[cm**(3)/mol] - Density of pure methanol
den_water = 0.9937; #[cm**(3)/mol] - Density of pure water
Vol_perc=[5,10,20,30,40,50,60,70,80,90,95]; # Volumes percent of component 1 (methanol)
W_total=[31.2706,31.1468,30.8907,30.6346,30.3396,30.0053,29.5865,29.1453,28.5978,28.0325,27.7320]; # Weight of solution + weight of density bottle
W_sol=zeros(11); # Weight of 20 cm**(3) of solution
den=zeros(11); # density of the solution
x1=zeros(11); # Mole fraction of methanol
x2=zeros(11); # Mole fraction of water
# Calculations
for i in range(11):
W_sol[i]=W_total[i]-W_bottle;
den[i]=W_sol[i]/Vol;
x1[i]=((Vol_perc[i]*den_meth)/Mol_meth)/(((Vol_perc[i]*den_meth)/Mol_meth)+(((100-Vol_perc[i])*den_water)/Mol_water));
x2[i]=1-x1[i];
#Again we have,
V_kg=zeros(11); #[cm**(3)] - Volume of 1 kg of solution
n_mol=zeros(11); #[mol] - Number of moles in 1 kg of solution
V_mol=zeros(11); #[cm**(3)/mol] - Volume of 1 mol of solution
x_V=zeros(11); #[cm**(3)/mol] - x_V = x1*V_meth + x2*V_water
V_mix=zeros(11); #[cm**(3)/mol] - V_mix = V_mol - x1*V_meth - x2*V_water
del_V=zeros(11); # [cm**(3)/mol] - del_V = V_mix/(x1*x2)
#V_mol = V_meth at x1 = 1 and V_mol = V_water at x1 = 0, therefore
V_meth = 40.4114; #[cm**(3)/mol] - Molar volume of pure component 1 (methanol)
V_water = 18.1286; #[cm**(3)/mol] - Molar volume of pure component 2 (water)
for i in range(11):
V_kg[i]=1000/den[i];
n_mol[i]=1000/(x1[i]*Mol_meth+x2[i]*Mol_water);
V_mol[i]=V_kg[i]/n_mol[i];
x_V[i]=V_meth*x1[i]+V_water*x2[i];
V_mix[i]=V_mol[i]-x1[i]*V_meth-x2[i]*V_water;
del_V[i]=V_mix[i]/(x1[i]*x2[i]);
#Now employing the concept of quadratic regression of the data ( x1 , del_V ) to solve the equation of the type
#y = a0 + a1*x + a2*x**(2)
#Here the above equation is in the form of
#del_V = V_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)
#From the matrix method to solve simultaneous linear equations, we have
a = array([[11, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2), sum(x1**3)],[sum(x1**2), sum(x1**3), sum(x1**4)]])
b = array([sum(del_V),sum(x1*del_V),sum((x1**2)*del_V)])
soln=linalg.solve(a,b);
a0=soln[0]
a1=soln[1]
a2=soln[2]
#del_V = V_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)
#V_mix = (a0 + a1*x1 + a2*x1**(2))*(x1*(1 - x1))
#Solving the above equation for x1,
def f(x1):
return (a0+(a1*x1)+(a2*x1**2))*(x1*(1-x1))
#Now differentiating the above equation with respect to x we get
#d/dx(V_mix) = (-4*a2*x1**3) + (3*(a2-a1)*x1**2) + (2*(a1-a0)*x1)+ a0
#Again solving it for x1
def f1(x1):
return (-4*a2*x1**3)+(3*(a2-a1)*x1**2)+(2*(a1-a0)*x1)+a0
#Now
x1_prime=[0,0.25,0.50,0.75,1.0];
V_mix_prime=zeros(5); #[cm**(3)/mol] - V_mix = V - x1*V_meth - x2*V_water
del_V_prime=zeros(5); #[cm**(3)/mol] - del_V = V_mix/(x1*x2)
V1_bar=zeros(5); #[cm**(3)/mol] - Partial molar volume of component 1
V2_bar=zeros(5); #[cm**(3)/mol] - Partial molar volume of component 1
# Results
for j in range(5):
V_mix_prime[j]=f(x1_prime[j]);
del_V_prime[j]=f1(x1_prime[j]);
V1_bar[j]=V_meth+V_mix_prime[j]+(1-x1_prime[j])*del_V_prime[j];
V2_bar[j]=V_water+V_mix_prime[j]-x1_prime[j]*del_V_prime[j];
print "For x1 = %f"%(x1_prime[j]);
print "The partial molar volume of methanol component 1) is %f cm**3)/mol"%(V1_bar[j])
print "The partial molar volume of water component 2) is %f cm**3)/mol"%(V2_bar[j])
from numpy import *
# Variables
T = 20 + 273.15; #[K] - Temperature
Mol_form = 46.027; #Molecular weight of formic acid
Mol_water = 18.015; # Molecular weight of water
Wt_perc=[10,18,30,50,72,78]; #Weight percent of formic acid
den=[1.0246,1.0441,1.0729,1.1207,1.1702,1.1818]; #[g/cm**(3)] - Density of solution
V_g=zeros(6); #[cm**(3)/g] - Volume of 1 g of solution
x1=zeros(6); # Mole fraction of component 1
x2=zeros(6); # Mole fraction of component 2
n=zeros(6); # Number of moles in 1 g
V_mol=zeros(6); #[cm**(3)/mol] - Volume of 1 mol of solution
x_V=zeros(6); #[cm**(3)/mol] - x_V = x1*V_form + x2*V_water
V_mix=zeros(6); #[cm**(3)/mol] - V_mix = V - x1*V_form - x2*V_water
del_V=zeros(6); # [cm**(3)/mol] - del_V = V_mix/(x1*x2)
#V_mol = V_form at x1 = 1 and V_mol = V_water at x1 = 0, therefore
V_form = 37.737; #[cm**(3)/mol] - Molar volume of pure formic acid (component 1)
V_water = 18.050; #[cm**(3)/mol] - Molar volume of pure water (component 2)
# Calculations
for i in range(6):
V_g[i]=1/den[i];
x1[i]=(Wt_perc[i]/Mol_form)/((Wt_perc[i]/Mol_form)+((100-Wt_perc[i])/Mol_water));
x2[i]=1-x1[i];
n[i]=((Wt_perc[i]/100.)/Mol_form)+(((100-Wt_perc[i])/100.)/Mol_water);
V_mol[i]=V_g[i]/n[i];
x_V[i]=V_form*x1[i]+V_water*x2[i];
V_mix[i]=V_mol[i]-x1[i]*V_form-x2[i]*V_water;
del_V[i]=V_mix[i]/(x1[i]*x2[i]);
a = array([[11, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2) ,sum(x1**3)],[sum(x1**2), sum(x1**3) ,sum(x1**4)]])
b = array([sum(del_V),sum(x1*del_V),sum((x1**2)*del_V)])
soln = linalg.solve(a,b)
a0=soln[0]
a1=soln[1]
a2=soln[2]
def f(x1):
return (a0+(a1*x1)+(a2*x1**2))*(x1*(1-x1))
def f1(x1):
return (-4*a2*x1**3)+(3*(a2-a1)*x1**2)+(2*(a1-a0)*x1)+a0
#At 15 Wt% of formic acid, x1 is given by
x1_prime_1 = round((15/Mol_form)/((15/Mol_form)+((100-15)/Mol_water)),3);
#Similarly at 75 Wt% of formic acid, x1 is given by
x1_prime_2 = round((75/Mol_form)/((75/Mol_form)+((100-75)/Mol_water)),4);
Wt_perc_prime=[15,75];
x1_prime=[x1_prime_1,x1_prime_2];
V_mix_prime=zeros(2); #[cm**(3)/mol] - V_mix = V - x1*V_meth - x2*V_water
del_V_prime=zeros(2); #[cm**(3)/mol] - del_V = V_mix/(x1*x2)
V1_bar=zeros(2); #[cm**(3)/mol] - Partial molar volume of component 1
V2_bar=zeros(2); #[cm**(3)/mol] - Partial molar volume of component 1
# Results
for j in range(2):
V_mix_prime[j]=f(x1_prime[j]);
del_V_prime[j]=f1(x1_prime[j]);
V1_bar[j]=V_form+V_mix_prime[j]+(1-x1_prime[j])*del_V_prime[j];
V2_bar[j]=V_water+V_mix_prime[j]-x1_prime[j]*del_V_prime[j];
print "For weight percent of formic acid = %f percent"%(Wt_perc_prime[j]);
print "The partial molar volume of formic acid component 1) is %f cm**3)/mol"%(V1_bar[j]);
print "The partial molar volume of water component 2) is %f cm**3)/mol"%(V2_bar[j]);
# answers are vary because of rounding error. Please review it manually.
from numpy import *
# Variables
T = 40 + 273.15; #[K] - Temperature
x1=array([0.083,0.176,0.268,0.353,0.428,0.720,0.780,0.850,0.900]) # Mole fraction of component 1
delta_H_mix=array([0.250,0.488,0.670,0.790,0.863,0.775,0.669,0.510,0.362]) #[kJ/mol] - Enthalpy of the solution
x2=zeros(9); # Mole fraction of component 2
del_H=zeros(9); #[kJ/mol] - del_H = delta_H_mix/(x1*x2)
for i in range(9):
x2[i]=1-x1[i];
del_H[i]=delta_H_mix[i]/(x1[i]*x2[i]);
# Calculations
#Now employing the concept of quadratic regression of the data ( x1 , del_H ) to solve the equation of the type
#y = a0 + a1*x + a2*x**(2)
#Here the above equation is in the form of
#del_H = delta_H_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)
#From the matrix method to solve simultaneous linear equations, we have
a = array([[9, sum(x1), sum(x1**2)],[sum(x1), sum(x1**2), sum(x1**3)],[sum(x1**2), sum(x1**3), sum(x1**4)]])
b = array([sum(del_H),sum(x1*del_H),sum((x1**2)*del_H)])
soln= linalg.solve(a,b)
a0=soln[0]
a1=soln[1]
a2=soln[2]
#del_H = delta_H_mix/(x1*x2) = a0 + a1*x1 + a2*x1**(2)
#delta_H_mix = (a0 + a1*x1 + a2*x1**(2))*(x1*(1 - x1))
#At x1 = 0.25,
x_1 = 0.25; #[mol]
delta_H_mix = (a0+(a1*x_1)+(a2*x_1**2))*(x_1*(1-x_1)); #[kJ/mol]
#Now differentiating the above equation with respect to x we get
#d/dx(delta_H_mix) = del_delta_H_mix = (-4*a2*x1**3) + (3*(a2-a1)*x1**2) + (2*(a1-a0)*x1)+ a0
#Again for x1 = 0.25
x_1_prime = 0.25; #[mol]
del_delta_H_mix = (-4*a2*x_1_prime**3)+(3*(a2-a1)*x_1_prime**2)+(2*(a1-a0)*x_1_prime)+a0; #[kJ/mol]
#We have the relation
# H1_bar - H1 = delta_H_mix + x2*del_delta_H_mix, and
# H2_bar - H2 = delta_H_mix - x1*del_delta_H_mix
#Let us suppose
#k_1 = H1_bar - H1 , and
#k_2 = H2_bar - H2
k_1 = delta_H_mix + (1-x_1_prime)*del_delta_H_mix; #[kJ/mol]
k_2 = delta_H_mix - x_1_prime*del_delta_H_mix; #[kJ/mol]
# Results
print "The value of H1_bar - H1) at x1 = 0.25 is %f kJ/mol"%(k_1);
print "The value of H2_bar - H2) at x1 = 0.25 is %f kJ/mol"%(k_2);