from scipy.optimize import fsolve
a=3.61 #atm L**2 mol**-2
b=4.29*10**-2 #L mol**-1
R=0.082 #L atm K**-1 mol**-1
T=500 #K
P=100 #atm
C1=b+(R*T/P) #L mol**-1 [aSsume]
C2=a/P #L^2 mol^-2 [assume]
C3=C2*b #L^3mol**-3
def f(x):
return(x**3-C1*x**2+C2*x-C3)
x=fsolve(f,0.3)
print "x=",round(x,3)
Vm=round(x,3)
print"Therefore,the value of molar volume,Vm=",Vm,"L mol^-1"
b=0.0391 #Van der waals constant[dm3/mol]
R=0.082 #Universal gas constant[dm3*atm/mol]
P2=1000 #pressure [atm]
P1=0 #pressure [atm]
T=1273 #Temperature [K]
import math
x=b*(P2-P1)
y=R*T
fc=math.exp(x/y) #fugacity coefficient
f=P2*fc #fugacity[atm]
print"The fugacity coefficient is",round(fc,3)
print"The fugacity is",round(f),"atm"
m1=0.03 #mass of CO2(g)[gm]
w1=44.01 #molecular weight of CO2(g)[gm/mol]
m2=250 #mass of water[gm]
w2=18.02 #molecular weight of water[gm/mol]
k=1.25*10**6 #Henry's law constant[Torr]
T=298 #Temperature[K]
n1=m1/w1 #no. of moles of CO2
n2=m2/w2 #no. of moles of water
x1=n1/(n1+n2) #mole fraction of CO2
Pco2=k*x1 #Partial pressure of CO2[Torr]
print"The partial pressure of CO2 gas is",round(Pco2,2),"Torr"
W=1000 #Total mass of a solution[gm]
x1=0.5 #mole fraction of Chloroform
x2=0.5 #mole fraction of Acetone
V1m=80.235 #Partial molar volume of chloroform[cm3/mol]
V2m=74.166 #Partial molar volume of Acetone[cm3/mol]
M1=119.59 #molecular weight of chloroform[gm/mol]
M2=58 #molecular weight of Acetone[gm/mol]
nT=W/(x1*M1+x2*M2) #Total no. of moles
V=nT*(x1*V1m+x2*V2m) #Total volume[cm3]
print"The volume of the solution is",round(V,1),"cm^3 (approx)"
x1=0.5 #mole fraction of chloroform
x2=0.5 #mole fraction of p-xylene
T=298 #Temperature[K]
Ve=x1*x2*(0.585+0.085*(x1-x2)-0.165*(x1-x2)**2) #Excess volume measured by using a dilatometer
print"Ve/(cm3.mol**-1) = ",round(Ve,3)
m1=0.01 #molality[m]
v11=1.0
v12=2.0
Y1=0.71
m2=0.005 #molality[m]
v21=1.0
v22=1.0
Y2=0.53
v1=(v11)+(v12)
v2=(v21)+(v22)
a1=(m1**v1)*(v11**v11)*(v12**v12)*(Y1**v1)
a2=(m2**v2)*(v21**v21)*(v22**v22)*(Y2**v2)
x=1.0/v1
a1m=a1**x
m1m=m1*(v11**v11*v12**v12)**x #molality[m]
y=1.0/v2
m2m=m2*(v21*v21*v22**v22)**y #molality[m]
a2m=a2**y
print"The activity of the electrolyte ZnCl2 is",round(a1,8)
print"The activity of the electrolyte CuSO4 is",round(a2,8)
print"The mean molality of ZnCl2 in [m]",round(m1m,4)
print"The mean molality of CuSO4 in [m]",m2m
m2=3 #mass of the sucrose[gm]
m1=0.1 #mass of water [Kg]
Kf=1.86 #cryoscopic constant of water[K*Kg/mol]
dTf=0.16 #Lowering in freezing point[K]
a=m1*dTf
b=Kf*m2
M2=b/a #molecular weight
print"M2=molecular weight , then M2=",M2
dTf=0.088 #Lowering in freezing point[K]
m2=0.45 #mass of sulphur[gm]
m1=0.09955 #mass of benzene[gm]
Kf=5.07 #cryoscopic constant for benzene[K*Kg/mol]
a=m1*dTf
b=Kf*m2
M2=b/a #molecular weight of sulphur
print"The molecular weight of sulphur is",round(M2,1)
x=M2/32 #no. of sulphur atoms
print"\n The molecular formula of sulphur is S",round(x)
m2=1.35 #mass of a macromolecule[gm]
V=100 #volume of solution[cm^3]
R=82 #Universal gas constant[atm.cm^3.K^-1]
T=300 #Temperature[K]
II=9.9 #osmotic pressure of the solution[cm]
d=1 #density
p=1013250 #Atmospheric pressure
g=980.67 #gravitational field
a=m2*R*T*p
b=V*9.9*d*g
M2=a/b #molar mass of macromolecule
print" M2 = molar mass of macromolecule , therefore M2 = ",round(M2),"g.mol^-1"
R=82 #Universal gas constant[atm.ml.K^-1.mol^-1]
T=298 #Temperature[K]
V=250 #volume of water[ml]
m2=2.6 #mass of the protein
M2=85000 #molar mass of protein[g.mol^-1]
n2=m2/M2 #no. of moles of protein
II=(n2*R*T)/V #Osmotic pressure of a solution[atm]
print"The osmotic pressure is",round(II,5),"atm "
R=8.314 #Universal gas constant[J.K**-1.mol**-1]
Tb=373.15 #Boiling point temperature[K]
M1=0.018 # mass of water[kg]
Hvap=40.7 #Enthalpy of vaporization[KJ.mol**-1]
a=R*0.001*Tb**2*M1
b=Hvap
Kb=a/b #Ebullioscopic constant of water[K.Kg.mol**-1]
print"The Ebullioscopic constant of water is",round(Kb,2),"K.Kg.mol-1"
print"CaF2(s)<=>CaF2(aq)<=>Ca+2(aq) + 2F-(aq)"
Ksp=4.0*(10**-11) #Solubility product of sparingly soluble salt CaF2
x=Ksp/4.0
Cs=x**(1.0/3.0) #Solubility
y=Cs**2
Y=(x/y)**(1.0/3.0) #activity coefficient
print"The activity coefficient is",Y
print"NOTE:please note that the value of Cs is wrongly calculated as 4.64*10^-11 in book"
R=8.314 #Universal gas constant[J/K/mol]
T=298 #Temperature[K]
F=96500 #Faraday's constant
Eo=0.98 #Standard e.m.f of the cell[Volts]
E=1.16 #e.m.f of the cell[Volts]
m=0.01
import math
a=R*T
b=2*F
x=a/b
Y=math.exp((Eo-E-(x*math.log(4*m*m*m)))/(3*x)) #mean activity coefficient
print"The mean activity coefficient is",round(Y,2)
M1=0.01 #no. of moles of KCl
M2=0.005 #no. of moles of MgCl2
M3=0.002 #no. of moles of MgSO4
M=0.1 #mass of water[Kg]
z11=1
z12=1
z21=2
z22=1
z31=2
z32=2
m1=M1/M #molality of KCL[m]
m2=M2/M #molality of MgCl2[m]
m3=M3/M #molality of MgSO4[m]
I=0.5*((m1*z11**2+m1*z12**2+m2*z21**2+2*m2*z22**2+m3*z31**2+m3*z32**2)) #[mol/Kg]
print"The Ionic strength of a solution is",I,"mol/Kg"
T=298 #Temperature[K]
P=1 #pressure [atm]
m=0.02 #Ionic strength of HCl solution in CH3OH[mol/Kg]
E=32.6 #Di-electric constant
d=0.787 #Density[gm/cm3]
I=0.5*(0.02*1*1+0.02*1*1) #Ionic strength of HCl solution[mol/Kg]
a=I*d
b=(E**3)*(298**3)
x=(a/b)**0.5
Y=10**(-1.825*1000000*1*1*x) #mean activity coefficient
print"The mean activity coefficient is",round(Y,2)