{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6:The Question of Ideality"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2,Page no:144"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.optimize import fsolve\n",
      "\n",
      "a=3.61            #atm L**2 mol**-2\n",
      "b=4.29*10**-2     #L mol**-1\n",
      "R=0.082           #L atm K**-1 mol**-1\n",
      "T=500             #K\n",
      "P=100             #atm\n",
      "\n",
      "\n",
      "C1=b+(R*T/P)       #L mol**-1   [aSsume]\n",
      "C2=a/P             #L^2 mol^-2  [assume]\n",
      "C3=C2*b           #L^3mol**-3\n",
      "def f(x):\n",
      "    return(x**3-C1*x**2+C2*x-C3)\n",
      "x=fsolve(f,0.3)\n",
      "\n",
      "\n",
      "print \"x=\",round(x,3)\n",
      "Vm=round(x,3)\n",
      "print\"Therefore,the value of molar volume,Vm=\",Vm,\"L mol^-1\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "x= 0.366\n",
        "Therefore,the value of molar volume,Vm= 0.366 L mol^-1\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5,Page no:149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "b=0.0391 \t\t\t#Van der waals constant[dm3/mol]\n",
      "R=0.082 \t\t\t#Universal gas constant[dm3*atm/mol]\n",
      "P2=1000 \t\t\t#pressure [atm]\n",
      "P1=0 \t\t\t\t#pressure [atm]\n",
      "T=1273\t\t \t\t#Temperature [K]\n",
      "import math\n",
      "\n",
      "x=b*(P2-P1) \n",
      "y=R*T \n",
      "fc=math.exp(x/y) \t\t#fugacity coefficient\n",
      "\n",
      "f=P2*fc #fugacity[atm]\n",
      "print\"The fugacity coefficient is\",round(fc,3) \n",
      "print\"The fugacity is\",round(f),\"atm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The fugacity coefficient is 1.454\n",
        "The fugacity is 1454.0 atm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10,Page no:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "m1=0.03 #mass of CO2(g)[gm]\n",
      "w1=44.01 #molecular weight of CO2(g)[gm/mol]\n",
      "m2=250 #mass of water[gm]\n",
      "w2=18.02 #molecular weight of water[gm/mol]\n",
      "k=1.25*10**6 #Henry's law constant[Torr]\n",
      "T=298 #Temperature[K]\n",
      "\n",
      "n1=m1/w1 #no. of moles of CO2\n",
      "n2=m2/w2 #no. of moles of water\n",
      "x1=n1/(n1+n2) #mole fraction of CO2\n",
      "Pco2=k*x1 #Partial pressure of CO2[Torr]\n",
      "print\"The partial pressure of CO2 gas is\",round(Pco2,2),\"Torr\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The partial pressure of CO2 gas is 61.41 Torr\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.11,Page no:161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "W=1000 \t\t\t#Total mass of a solution[gm]\n",
      "x1=0.5 \t\t\t#mole fraction of Chloroform\n",
      "x2=0.5 \t\t\t#mole fraction of Acetone\n",
      "V1m=80.235 \t\t#Partial molar volume of chloroform[cm3/mol]\n",
      "V2m=74.166 \t\t#Partial molar volume of Acetone[cm3/mol]\n",
      "M1=119.59 \t\t#molecular weight of chloroform[gm/mol]\n",
      "M2=58 \t\t\t#molecular weight of Acetone[gm/mol]\n",
      "\n",
      "nT=W/(x1*M1+x2*M2) \t#Total no. of moles\n",
      "V=nT*(x1*V1m+x2*V2m) \t#Total volume[cm3]\n",
      "print\"The volume of the solution is\",round(V,1),\"cm^3 (approx)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The volume of the solution is 869.4 cm^3 (approx)\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12,Page no:163"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "x1=0.5 #mole fraction of chloroform\n",
      "x2=0.5 #mole fraction of p-xylene\n",
      "T=298 #Temperature[K]\n",
      "\n",
      "Ve=x1*x2*(0.585+0.085*(x1-x2)-0.165*(x1-x2)**2) #Excess volume measured by using a dilatometer\n",
      "print\"Ve/(cm3.mol**-1) = \",round(Ve,3) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ve/(cm3.mol**-1) =  0.146\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.14,Page no:169"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "m1=0.01 \t\t#molality[m]\n",
      "v11=1.0 \n",
      "v12=2.0 \n",
      "Y1=0.71 \n",
      "m2=0.005 \t\t#molality[m]\n",
      "v21=1.0 \n",
      "v22=1.0 \n",
      "Y2=0.53 \n",
      "\n",
      "\n",
      "v1=(v11)+(v12) \n",
      "v2=(v21)+(v22) \n",
      "a1=(m1**v1)*(v11**v11)*(v12**v12)*(Y1**v1) \n",
      "a2=(m2**v2)*(v21**v21)*(v22**v22)*(Y2**v2) \n",
      "x=1.0/v1 \n",
      "a1m=a1**x \n",
      "m1m=m1*(v11**v11*v12**v12)**x #molality[m]\n",
      "y=1.0/v2 \n",
      "m2m=m2*(v21*v21*v22**v22)**y #molality[m]\n",
      "a2m=a2**y \n",
      "print\"The activity of the electrolyte ZnCl2 is\",round(a1,8)\n",
      "print\"The activity of the electrolyte CuSO4 is\",round(a2,8)\n",
      "print\"The mean molality of ZnCl2 in [m]\",round(m1m,4)\n",
      "print\"The mean molality of CuSO4 in [m]\",m2m \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The activity of the electrolyte ZnCl2 is 1.43e-06\n",
        "The activity of the electrolyte CuSO4 is 7.02e-06\n",
        "The mean molality of ZnCl2 in [m] 0.0159\n",
        "The mean molality of CuSO4 in [m] 0.005\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.15,Page no:172"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "m2=3 \t\t\t#mass of the sucrose[gm]\n",
      "m1=0.1 \t\t\t#mass of water [Kg]\n",
      "Kf=1.86 \t\t#cryoscopic constant of water[K*Kg/mol]\n",
      "dTf=0.16 \t\t#Lowering in freezing point[K]\n",
      "\t\n",
      "a=m1*dTf \n",
      "b=Kf*m2 \n",
      "M2=b/a \t\t\t#molecular weight\n",
      "print\"M2=molecular weight ,    then M2=\",M2  "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "M2=molecular weight ,    then M2= 348.75\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.16,Page no:173"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "dTf=0.088 \t\t\t#Lowering in freezing point[K]\n",
      "m2=0.45 \t\t\t#mass of sulphur[gm]\n",
      "m1=0.09955 \t\t\t#mass of benzene[gm]\n",
      "Kf=5.07 \t\t\t#cryoscopic constant for benzene[K*Kg/mol]\n",
      "\n",
      "a=m1*dTf \n",
      "b=Kf*m2 \n",
      "M2=b/a \t\t\t\t#molecular weight of sulphur\n",
      "print\"The molecular weight of sulphur is\",round(M2,1) \n",
      "x=M2/32 \t\t\t#no. of sulphur atoms\n",
      "print\"\\n The molecular formula of sulphur is S\",round(x) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The molecular weight of sulphur is 260.4\n",
        "\n",
        " The molecular formula of sulphur is S 8.0\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.17,Page no:174"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "m2=1.35 \t\t\t#mass of a macromolecule[gm]\n",
      "V=100\t \t\t\t#volume of solution[cm^3]\n",
      "R=82 \t\t\t\t#Universal gas constant[atm.cm^3.K^-1]\n",
      "T=300 \t\t\t\t#Temperature[K]\n",
      "II=9.9 \t\t\t\t#osmotic pressure of the solution[cm]\n",
      "d=1 \t\t\t\t#density\n",
      "p=1013250 \t\t\t#Atmospheric pressure\n",
      "g=980.67 \t\t\t#gravitational field\n",
      "\n",
      "\n",
      "a=m2*R*T*p \n",
      "b=V*9.9*d*g \n",
      "M2=a/b #molar mass of macromolecule\n",
      "print\" M2 = molar mass of macromolecule , therefore M2 = \",round(M2),\"g.mol^-1\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " M2 = molar mass of macromolecule , therefore M2 =  34660.0 g.mol^-1\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.18,Page no:175"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R=82 \t\t\t#Universal gas constant[atm.ml.K^-1.mol^-1]\n",
      "T=298 \t\t\t#Temperature[K]\n",
      "V=250 \t\t\t#volume of water[ml]\n",
      "m2=2.6 \t\t\t#mass of the protein\n",
      "M2=85000 \t\t#molar mass of protein[g.mol^-1]\n",
      "\n",
      "\t\n",
      "n2=m2/M2 \t\t\t#no. of moles of protein\n",
      "II=(n2*R*T)/V \t\t\t#Osmotic pressure of a solution[atm]\n",
      "print\"The osmotic pressure is\",round(II,5),\"atm \"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The osmotic pressure is 0.00299 atm \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.19,Page no:175"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "R=8.314 \t\t\t#Universal gas constant[J.K**-1.mol**-1]\n",
      "Tb=373.15 \t\t\t#Boiling point temperature[K]\n",
      "M1=0.018 \t\t\t# mass of water[kg]\n",
      "Hvap=40.7 \t\t\t#Enthalpy of vaporization[KJ.mol**-1]\n",
      "\n",
      "a=R*0.001*Tb**2*M1 \n",
      "b=Hvap \n",
      "Kb=a/b \t\t\t\t#Ebullioscopic constant of water[K.Kg.mol**-1]\n",
      "print\"The Ebullioscopic constant of water is\",round(Kb,2),\"K.Kg.mol-1\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Ebullioscopic constant of water is 0.51 K.Kg.mol-1\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.20,Page no:176"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print\"CaF2(s)<=>CaF2(aq)<=>Ca+2(aq) + 2F-(aq)\"\n",
      "\n",
      "Ksp=4.0*(10**-11) \t#Solubility product of sparingly soluble salt CaF2\n",
      "\n",
      "x=Ksp/4.0 \n",
      "Cs=x**(1.0/3.0) \t\t#Solubility \n",
      "y=Cs**2 \n",
      "Y=(x/y)**(1.0/3.0) \t\t#activity coefficient\n",
      "print\"The activity coefficient is\",Y \n",
      "print\"NOTE:please note that the value of Cs is wrongly calculated as 4.64*10^-11 in book\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CaF2(s)<=>CaF2(aq)<=>Ca+2(aq) + 2F-(aq)\n",
        "The activity coefficient is 0.0599484250319\n",
        "NOTE:please note that the value of Cs is wrongly calculated as 4.64*10^-11 in book\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.21,Page no:177"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "T=298 \t\t\t\t#Temperature[K]\n",
      "F=96500 \t\t\t#Faraday's constant\n",
      "Eo=0.98 \t\t\t#Standard e.m.f of the cell[Volts]\n",
      "E=1.16 \t\t\t\t#e.m.f of the cell[Volts]\n",
      "m=0.01 \n",
      "import math\n",
      "\n",
      "a=R*T \n",
      "b=2*F \n",
      "x=a/b \n",
      "Y=math.exp((Eo-E-(x*math.log(4*m*m*m)))/(3*x)) #mean activity coefficient\n",
      "print\"The mean activity coefficient is\",round(Y,2) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean activity coefficient is 0.59\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.22,Page no:184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "M1=0.01 \t\t\t#no. of moles of KCl\n",
      "M2=0.005 \t\t\t#no. of moles of MgCl2\n",
      "M3=0.002 \t\t\t#no. of moles of MgSO4\n",
      "M=0.1 \t\t\t\t#mass of water[Kg]\n",
      "z11=1 \n",
      "z12=1 \n",
      "z21=2 \n",
      "z22=1 \n",
      "z31=2 \n",
      "z32=2 \n",
      "\t\n",
      "m1=M1/M \t\t\t#molality of KCL[m]\n",
      "m2=M2/M \t\t\t#molality of MgCl2[m]\n",
      "m3=M3/M \t\t\t#molality of MgSO4[m]\n",
      "\n",
      "I=0.5*((m1*z11**2+m1*z12**2+m2*z21**2+2*m2*z22**2+m3*z31**2+m3*z32**2)) #[mol/Kg]\n",
      "print\"The Ionic strength of a solution is\",I,\"mol/Kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Ionic strength of a solution is 0.33 mol/Kg\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.23,Page no:185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "T=298 \t\t\t\t#Temperature[K]\n",
      "P=1 \t\t\t\t#pressure [atm]\n",
      "m=0.02\t \t\t\t#Ionic strength of HCl solution in CH3OH[mol/Kg]\n",
      "E=32.6 \t\t\t\t#Di-electric constant\n",
      "d=0.787 \t\t\t#Density[gm/cm3]\n",
      "\t\n",
      "I=0.5*(0.02*1*1+0.02*1*1) \t#Ionic strength of HCl solution[mol/Kg]\n",
      "a=I*d \n",
      "b=(E**3)*(298**3) \n",
      "x=(a/b)**0.5 \n",
      "Y=10**(-1.825*1000000*1*1*x) \t#mean activity coefficient\n",
      "print\"The mean activity coefficient is\",round(Y,2) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean activity coefficient is 0.58\n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}