{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Physico Chemical Calculations"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.1 page number 71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "p1=15.     #in bar\n",
      "p2=1.013  #in bar\n",
      "t1=283.    #in K\n",
      "t2=273.    #in K\n",
      "v1=10.     #in l\n",
      "\n",
      "v2=p1*v1*t2/(t1*p2);\n",
      "\n",
      "print \"volume of oxygen = %f liters\"%(v2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volume of oxygen = 142.842692 liters\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.2 page number 71\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "nCO2 = 2./44;     #moles of CO2\n",
      "nO2 = 4./32;     #moles of O2\n",
      "nCH4 = 1.5/16;   #moles of CH4\n",
      "\n",
      "total_moles = nCO2+nO2+nCH4;\n",
      "yCO2 = nCO2/total_moles;\n",
      "yO2 = nO2/total_moles;\n",
      "yCH4 = nCH4/total_moles;\n",
      "\n",
      "print  \" Composition of mixture = CH4 = %f O2 = %f  CO2 = %f \"%(yCH4,yO2,yCO2)\n",
      "\n",
      "pCO2=nCO2*8.314*273/(6*10**-3);\n",
      "pO2=nO2*8.314*273/(6*10**-3);\n",
      "pCH4=nCH4*8.314*273/(6*10**-3);\n",
      "\n",
      "print  \"pressure of CH4 = %f kPa pressure of O2 = %f kPa pressure of CO2 =%f kPa\"%(pCH4*10**-3,pO2*10**-3,pCO2*10**-3)\n",
      "\n",
      "total_pressure=pCO2+pCH4+pO2;\n",
      "print  \"total pressure =  %f Kpa\"%(total_pressure*10**-3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Composition of mixture = CH4 = 0.354839 O2 = 0.473118  CO2 = 0.172043 \n",
        "pressure of CH4 = 35.464406 kPa pressure of O2 = 47.285875 kPa pressure of CO2 =17.194864 kPa\n",
        "total pressure =  99.945145 Kpa\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.3 page number 72\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "P=104.3     #total pressure in KPa\n",
      "pH2O=2.3    #in KPa\n",
      "pH2=P-pH2O; #in KPa\n",
      "\n",
      "VH2=209*pH2*273/(293*101.3)\n",
      "\n",
      "print \"volume of hydrogen obtained = %f ml\"%(VH2)\n",
      "\n",
      "\n",
      "m=350/196.08*11.2   #mass of metal in grams\n",
      "print \"mass of metal equivalent to 11.2 litre/mol of hydrogen = %f gm\"%(m)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volume of hydrogen obtained = 196.079432 ml\n",
        "mass of metal equivalent to 11.2 litre/mol of hydrogen = 19.991840 gm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.4 page number 72\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "w=2   #in gm\n",
      "m=0.287  #in gm\n",
      "\n",
      "mNaCl=58.5/143.4*m;\n",
      "\n",
      "print \"mass of NaCl = %f gm\"%(mNaCl )\n",
      "\n",
      "percentage_NaCl=mNaCl/w*100;\n",
      "print \"amount of NaCl = %f\"%(percentage_NaCl)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass of NaCl = 0.117082 gm\n",
        "amount of NaCl = 5.854079\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.5 page number 72\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "w=4.73    #in gm5\n",
      "VCO2=5.30    #in liters\n",
      "\n",
      "weight_CO2=44/22.4*VCO2;\n",
      "carbon_content=12./44*weight_CO2;\n",
      "percentage_content=(carbon_content/w)*100;\n",
      "\n",
      "print \"percentage amount of carbon in sample = %f\"%(percentage_content)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage amount of carbon in sample = 60.027182\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.6 page number 73\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "volume_H2=0.5    #in m3\n",
      "volume_CH4=0.35  #in m3\n",
      "volume_CO=0.08   #in m3\n",
      "volume_C2H4=0.02 #in m3\n",
      "volume_oxygen=0.21  #in m3 in air\n",
      "\n",
      "H2=0.5*volume_H2;\n",
      "CH4=2*volume_CH4;\n",
      "CO=0.5*volume_CO;\n",
      "C2H4=3*volume_C2H4;\n",
      "\n",
      "total_O2=H2+CH4+CO+C2H4;\n",
      "oxygen_required=total_O2/volume_oxygen;\n",
      "\n",
      "print \"amount of oxygen required = %f cubic meter\"%(oxygen_required)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of oxygen required = 5.000000 cubic meter\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.7 page number 73\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "\n",
      "density_H2SO4 = 1.10   #in g/ml\n",
      "mass_1 = 100*density_H2SO4;   #mass of 100ml of 15% solution\n",
      "mass_H2SO4 = 0.15*mass_1;\n",
      "density_std = 1.84   #density of 96% sulphuric acid\n",
      "mass_std = 0.96*density_std;   #mass of H2SO4 in 1ml 96% H2SO4\n",
      "\n",
      "volume_std = mass_H2SO4/mass_std;    #volume of 96%H2SO4\n",
      "mass_water = mass_1 - mass_H2SO4;\n",
      "\n",
      "print \"volume of 0.96 H2SO4 required = %f ml\"%(volume_std)\n",
      "print \"mass of water required = %f g\"%(mass_water)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volume of 0.96 H2SO4 required = 9.341033 ml\n",
        "mass of water required = 93.500000 g\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.8 page number 73\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "w_H2SO4=0.15    #in gm/1gm solution\n",
      "density=1.10   #in gm/ml\n",
      "m=density*1000;   #mass per liter\n",
      "weight=m*w_H2SO4;   #H2SO4 per liter solution\n",
      "molar_mass=98;\n",
      "\n",
      "Molarity=weight/molar_mass;\n",
      "print \"Molarity = %f mol/l\"%(Molarity)\n",
      "\n",
      "equivalent_mass=49;\n",
      "normality=weight/equivalent_mass;\n",
      "print \"Normality = %f N\"%(normality)\n",
      "\n",
      "molality=176.5/molar_mass;\n",
      "print \"Molality = %f\"%(molality)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Molarity = 1.683673 mol/l\n",
        "Normality = 3.367347 N\n",
        "Molality = 1.801020\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.9 page number 74\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "molar_mass_BaCl2=208.3;      #in gm\n",
      "equivalent_H2SO4=0.144;\n",
      "\n",
      "normality=equivalent_H2SO4*1000/28.8;\n",
      "\n",
      "print \"Normality = %f N\"%(normality)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normality = 5.000000 N\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.10 page number 74\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "solubility_70=30.2     #in gm/100gm\n",
      "w_solute=solubility_70*350/130.2;     #in gm\n",
      "\n",
      "w_water=350-w_solute;\n",
      "solubility_30=10.1    #in gm/100gm\n",
      "precipitate=(solubility_70-solubility_30)*w_water/100\n",
      "\n",
      "print \"amount precipitated = %f gm\"%(precipitate)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount precipitated = 54.032258 gm\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.11 page number 74\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "absorbtion_coefficient=1.71    #in liters\n",
      "molar_mass=44;\n",
      "\n",
      "solubility=absorbtion_coefficient*molar_mass/22.4;   #in gm\n",
      "pressure=8/solubility*101.3;\n",
      "\n",
      "print \"pressure required = %f kPa\"%(pressure)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pressure required = 241.267411 kPa\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.12 page number 74\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "\n",
      "w_water=540.   #in gm\n",
      "w_glucose=36.  #in gm\n",
      "m_water=18.;      #molar mass of water\n",
      "m_glucose=180.;   #molar mass of glucose\n",
      "\n",
      "x=(w_water/m_water)/(w_water/m_water+w_glucose/m_glucose);\n",
      "p=8.2*x;\n",
      "depression=8.2-p;\n",
      "\n",
      "print \"depression in vapor pressure = %f Pa\"%(depression*1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "depression in vapor pressure = 54.304636 Pa\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.13 page number 75\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "w_glucose=9.    #in gm\n",
      "w_water=100.    #in gm\n",
      "E=0.52;\n",
      "m=90/180.;    #moles/1000gm water\n",
      "\n",
      "delta_t=E*m;\n",
      "boiling_point=100+delta_t;\n",
      "\n",
      "print \"boiling_point of water = %f degreeC\"%(boiling_point)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "boiling_point of water = 100.260000 degreeC\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.14 page number 75\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "K=1.86;\n",
      "c=15   #concentration of alcohol\n",
      "delta_t=10.26;\n",
      "\n",
      "m=delta_t/K;   #molality\n",
      "M=c/(m*85);    #molar mass\n",
      "print \"molar mass = %f gm\"%(M*1000)\n",
      "\n",
      "density=0.97     #g/ml\n",
      "cm=c*density/(M*100);\n",
      "print \"molar concentration of alcohol = %f moles/l\"%(cm)\n",
      "\n",
      "p=cm*8.314*293   #osmotic pressure\n",
      "print \"osmotic pressure = %f Mpa\"%(p/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "molar mass = 31.991744 gm\n",
        "molar concentration of alcohol = 4.548048 moles/l\n",
        "osmotic pressure = 11.079055 Mpa\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.15 page number 75\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "u_in = 0.575   #from the graph\n",
      "u_s = 0.295   #in mPa-s\n",
      "\n",
      "M_v = (u_in/(5.80*10**-5))**(1/0.72);\n",
      "u_red = 0.628;   #in dl/g\n",
      "\n",
      "c = 0.40   #in g/dl\n",
      "k = (u_red-u_in)/((u_in**2)*c);\n",
      "\n",
      "print \"k = %f Mv = %fu_in = %f dl/gm\"%(k,M_v,u_in)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "k = 0.400756 Mv = 355085.654054u_in = 0.575000 dl/gm\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.16 page number 76\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "C=54.5     #% of carbon\n",
      "H2=9.1     #% of hydrogen\n",
      "O2=36.4    #% of oxygen\n",
      "x=C/12.;    #number of carbon molecules\n",
      "y=O2/16.;   #number of oxygen molecules\n",
      "z=H2/2.    #number of hydrogen molecules\n",
      "molar_mass=88.;\n",
      "density=44.;\n",
      "\n",
      "ratio=molar_mass/density;\n",
      "x=ratio*2;\n",
      "y=ratio*1;\n",
      "z=ratio*4;\n",
      "\n",
      "print \"x = %f y = %f z = %f\"%(x,y,z)\n",
      "print \"formula of butyric acid is = C4H8O2\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "x = 4.000000 y = 2.000000 z = 8.000000\n",
        "formula of butyric acid is = C4H8O2\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.17 page number 77\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "C=93.75    #% of carbon\n",
      "H2=6.25    #% of hydrogen\n",
      "x=C/12     #number of carbon atoms\n",
      "y=H2/2     #number of hydrogen atoms\n",
      "molar_mass=64\n",
      "density=4.41*29;\n",
      "\n",
      "ratio=density/molar_mass;\n",
      "x=round(ratio*5);\n",
      "y=round(ratio*4);\n",
      "\n",
      "print \"x = %f y = %f\"%(x,y)\n",
      "print \"formula of butyric acid is = C10H8\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "x = 10.000000 y = 8.000000\n",
        "formula of butyric acid is = C10H8\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.18 page number 77\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "C=50.69     #% of carbon\n",
      "H2=4.23     #% of hydrogen\n",
      "O2=45.08    #% of oxygen\n",
      "a=C/12;    #number of carbon molecules\n",
      "c=O2/16;   #number of oxygen molecules\n",
      "b=H2/2;    #number of hydrogen molecules\n",
      "molar_mass=71;\n",
      "\n",
      "def f(m):\n",
      "    return (2.09*1000)/(60*m);\n",
      "\n",
      "\n",
      "M=f((1.25/5.1));\n",
      "\n",
      "print \"actual molecular mass = %f\"%(M)\n",
      "\n",
      "ratio=M/molar_mass;\n",
      "a=round(ratio*3);\n",
      "b=round(ratio*3);\n",
      "c=round(ratio*2);\n",
      "\n",
      "print \"a = %d, b = %d, c = %d\"%(a,b,c)\n",
      "print \"M = %.1f g/mol\"%M\n",
      "print \"formula of butyric acid is = C6H6O4\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "actual molecular mass = 142.120000\n",
        "a = 6, b = 6, c = 4\n",
        "M = 142.1 g/mol\n",
        "formula of butyric acid is = C6H6O4\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.19 page number 78\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "C=64.6     #% of carbon\n",
      "H2=5.2     #% of hydrogen\n",
      "O2=12.6    #% of oxygen\n",
      "N2=8.8     #% of nitrogen\n",
      "Fe=8.8     #% of iron\n",
      "\n",
      "a=C/12;    #number of carbon molecules\n",
      "c=8.8/14;   #number of nitrogen molecules\n",
      "b=H2;    #number of hydrogen molecules\n",
      "d=O2/16;   #number of oxygen molecules\n",
      "e=Fe/56    #number of iron atoms\n",
      "\n",
      "cm=243.4/(8.31*293)     #concentration\n",
      "\n",
      "molar_mass=63.3/cm;\n",
      " \n",
      "print \"a = %d, b = %d, c = %d, d = %d, e = %d\"%(a*6.5,b*6.5,c*6.5,d*6.5,e*6.5)\n",
      "print \"formula of butyric acid is = C34H33N4O5Fe\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a = 34, b = 33, c = 4, d = 5, e = 1\n",
        "formula of butyric acid is = C34H33N4O5Fe\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.20 page number 78\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "E1=-0.25;\n",
      "E2=0.80;\n",
      "E3=0.34;\n",
      "\n",
      "a=[E1,E2,E3];\n",
      "sorted(a)\n",
      "\n",
      "print \"sorted potential in volts =\"\n",
      "print  (a)\n",
      "print  (\"E2>E3>E1\")\n",
      "print  (\"silver>copper>nickel\")\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "sorted potential in volts =\n",
        "[-0.25, 0.8, 0.34]\n",
        "E2>E3>E1\n",
        "silver>copper>nickel\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.21 page number 79\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "E0_Zn=-0.76;\n",
      "E0_Pb=-0.13;\n",
      "c_Zn=0.1;\n",
      "c_Pb=0.02;\n",
      "\n",
      "E_Zn=E0_Zn+(0.059/2)*math.log10(c_Zn);\n",
      "E_Pb=E0_Pb+(0.059/2)*math.log10(c_Pb);\n",
      "E=E_Pb-E_Zn;\n",
      "\n",
      "print \"emf of cell = %f V\"%(E)\n",
      "print \"Since potential of lead is greater than that of zinc thus reduction will occur at\\\n",
      " lead electrode and oxidation will occur at zinc electrode\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "emf of cell = 0.609380 V\n",
        "Since potential of lead is greater than that of zinc thus reduction will occur at lead electrode and oxidation will occur at zinc electrode\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.22 page number 79\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "E0_Ag=0.80;\n",
      "E0_AgNO3=0.80;\n",
      "c_Ag=0.001;\n",
      "c_AgNO3=0.1;\n",
      "\n",
      "E_Ag=E0_Ag+(0.059)*math.log10(c_Ag);\n",
      "E_AgNO3=E0_AgNO3+(0.059)*math.log10(c_AgNO3);\n",
      "E=E_AgNO3-E_Ag;\n",
      "\n",
      "print \"emf of cell = %f V\" %(E)\n",
      "print \"since E is positive, the left hand electrode will be anode and\\\n",
      " the electron will travel in the external circuit from the left hand to the right hand electrode\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "emf of cell = 0.118000 V\n",
        "since E is positive, the left hand electrode will be anode and the electron will travel in the external circuit from the left hand to the right hand electrode\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.23 page number 79\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "pH=12;    #pH of solution\n",
      "E_H2=0;\n",
      "\n",
      "E2=-0.059*pH;\n",
      "E=E_H2-E2;\n",
      "\n",
      "print \"EMF of cell = %f V\"%(E)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "EMF of cell = 0.708000 V\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.24 page number 80\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "I=3   #in Ampere\n",
      "t=900   #in s\n",
      "m_eq=107.9    #in gm/mol\n",
      "F=96500;\n",
      "\n",
      "m=(I*t*m_eq)/F;\n",
      "\n",
      "print \"mass = %f gm\"%(m)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass = 3.018964 gm\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.25 page number 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "volume=10*10*0.005;    #in cm3\n",
      "mass=volume*8.9;\n",
      "F=96500;\n",
      "atomic_mass=58.7    #in amu\n",
      "current=2.5     #in Ampere\n",
      "\n",
      "charge=(8.9*F*2)/atomic_mass;\n",
      "yield_=0.95;\n",
      "actual_charge=charge/(yield_*3600);\n",
      "t=actual_charge/current;\n",
      "\n",
      "print \"time required = %f hours\"%(t)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "time required = 3.422497 hours\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.26 page number 80\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "m_MgSO4=90.   #in ppm\n",
      "MgSO4_parts=120.;\n",
      "CaCO3_parts=100.;\n",
      "\n",
      "hardness=(CaCO3_parts/MgSO4_parts)*m_MgSO4;\n",
      "\n",
      "print \"hardness of water = %f mg/l\"%(hardness)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "hardness of water = 75.000000 mg/l\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.27 page number 81\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''\n",
      "calculate\n",
      "i) the temporary and total hardness of the sample\n",
      "ii) the amounts of lime and soda needed for softening of 1 l of the sample\n",
      "'''\n",
      "\n",
      "import math \n",
      "\n",
      "m1 = 162.   #mass of calcium bi carbonate in mg\n",
      "m2 = 73.   #mass of magnesium bi carbonate in mg\n",
      "m3 = 136.  # mass of calsium sulfate in mg\n",
      "m4 = 95.   # mass of magnesium cloride\n",
      "m5 = 500.  #mass of sodium cloride in mg\n",
      "m6 = 50.   # mass of potassium cloride in mg\n",
      "\n",
      "content_1 = m1*100/m1;    #content of calcium bi carbonate in mg\n",
      "content_2 = m2*100/(2*m2);   #content of magnesium bi carbonate in mg\n",
      "content_3 = m3*100/m3;  # content of calsium sufate in mg\n",
      "content_4 = m4*100/m4;   # content of magnesium cloride\n",
      "\n",
      "\n",
      "temp_hardness = content_1 + content_2;   #depends on bicarbonate only\n",
      "total_hardness = content_1+content_2+content_3+content_4;\n",
      "print \"total hardness = %.0f mg/l temporary hardness = %.0f mg/l\"%(temp_hardness,total_hardness)\n",
      "\n",
      "wt_lime = (74./100)*(content_1+2*content_2+content_4);\n",
      "actual_lime = wt_lime/0.85;\n",
      "print \"amount of lime required = %.1f mg/l\"%(actual_lime)\n",
      "\n",
      "soda_required = (106./100)*(content_1+content_4);\n",
      "actual_soda = soda_required/0.98;\n",
      "print \"amount of soda required = %.1f mg/l\"%(actual_soda)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "total hardness = 150 mg/l temporary hardness = 350 mg/l\n",
        "amount of lime required = 261.2 mg/l\n",
        "amount of soda required = 216.3 mg/l\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.28 page number 82\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "volume_NaCl=50.    #in l\n",
      "c_NaCl=5000.       #in mg/l\n",
      "\n",
      "m=volume_NaCl*c_NaCl;\n",
      "equivalent_NaCl=50/58.5;\n",
      "\n",
      "hardness=equivalent_NaCl*m;\n",
      "\n",
      "print \"hardness of water = %f mg/l\"%(hardness/1000.)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "hardness of water = 213.675214 mg/l\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.29 page number 82\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "m_benzene = 55.   #in kg\n",
      "m_toluene = 28.   #in kg\n",
      "m_xylene = 17.    # in kg\n",
      "\n",
      "mole_benzene = m_benzene/78.;\n",
      "mole_toluene = m_toluene/92.;\n",
      "mole_xylene = m_xylene/106.;\n",
      "\n",
      "mole_total = mole_benzene+mole_toluene+mole_xylene;\n",
      "x_benzene = mole_benzene/mole_total;\n",
      "x_toluene = mole_toluene/mole_total;\n",
      "x_xylene = mole_xylene/mole_total;\n",
      "\n",
      "P = x_benzene*178.6+x_toluene*74.6+x_xylene*28;\n",
      "print \"total pressure = %f kPa\"%(P)\n",
      "\n",
      "benzene = (x_benzene*178.6*100)/P;\n",
      "toluene = (x_toluene*74.6*100)/P;\n",
      "xylene = (x_xylene*28*100)/P;\n",
      "\n",
      "print \"xylene = %f  toluene = %f  benzene = %f\"%(xylene,toluene,benzene)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "total pressure = 130.897438 kPa\n",
        "xylene = 2.932503  toluene = 14.826766  benzene = 82.240730\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.30 page number 83\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "vapor_pressure=8.    #in kPa\n",
      "pressure=100.       #in kPa\n",
      "\n",
      "volume=1     #in m3\n",
      "volume_ethanol=volume*(vapor_pressure/pressure);\n",
      "volume_air=1-volume_ethanol;\n",
      "print \"volumetric composition:- air composition = %f ethanol compostion = %f\"%(volume_air*100,volume_ethanol*100)\n",
      "\n",
      "molar_mass_ethanol=46;\n",
      "molar_mass_air=28.9;\n",
      "mass_ethanol=0.08*molar_mass_ethanol;    #in kg\n",
      "mass_air=0.92*molar_mass_air;     #in kg\n",
      "fraction_ethanol=(mass_ethanol*100)/(mass_air+mass_ethanol);\n",
      "fraction_air=(mass_air*100)/(mass_air+mass_ethanol);\n",
      "print \"composition by weight:-Air = %f Ethanol vapor = %f\"%(fraction_air,fraction_ethanol)\n",
      "\n",
      "mixture_volume=22.3*(101.3/100)*(299./273);   #in m3\n",
      "weight_ethanol=mass_ethanol/mixture_volume;\n",
      "print \"weight of ethanol/cubic meter = %f Kg\"%(weight_ethanol)\n",
      "\n",
      "w_ethanol=mass_ethanol/mass_air;\n",
      "print \"weight of ethanol/kg vapor free air = %f Kg\"%(w_ethanol)\n",
      "\n",
      "moles_ethanol=0.08/0.92;\n",
      "print \"kmol of ethanol per kmol of vapor free air = %f\"%(moles_ethanol)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volumetric composition:- air composition = 92.000000 ethanol compostion = 8.000000\n",
        "composition by weight:-Air = 87.841945 Ethanol vapor = 12.158055\n",
        "weight of ethanol/cubic meter = 0.148739 Kg\n",
        "weight of ethanol/kg vapor free air = 0.138408 Kg\n",
        "kmol of ethanol per kmol of vapor free air = 0.086957\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.31 page number 84\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "vapor_pressure=8.   #in kPa\n",
      "volume_ethanol=0.05;\n",
      "\n",
      "\n",
      "partial_pressure=volume_ethanol*100;\n",
      "relative_saturation=partial_pressure/vapor_pressure;\n",
      "mole_ratio=volume_ethanol/(1-volume_ethanol);\n",
      "print \"mole ratio = %f \\nrelative saturation = %f %%\"%(mole_ratio,relative_saturation*100)\n",
      "\n",
      "volume_vapor=(8./100)*100;\n",
      "ethanol_vapor=volume_vapor/100.;\n",
      "air_vapor=1-ethanol_vapor;\n",
      "saturation_ratio=ethanol_vapor/air_vapor;\n",
      "percentage_saturation=mole_ratio/saturation_ratio;\n",
      "\n",
      "print \"percentage saturation = %f %%\"%(percentage_saturation*100)\n",
      "\n",
      "print \"corresponding to partial pressure of 5kPa we get a dew point of 17.3 degree celcius\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mole ratio = 0.052632 \n",
        "relative saturation = 62.500000 %\n",
        "percentage saturation = 60.526316 %\n",
        "corresponding to partial pressure of 5kPa we get a dew point of 17.3 degree celcius\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 2.32 page number 84\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "p = 4.24   #in kPa\n",
      "H_rel = 0.8;\n",
      "\n",
      "p_partial = p*H_rel;\n",
      "molal_H = p_partial/(100-p_partial);\n",
      "print \"initial molal humidity = %.3f\"%(molal_H)\n",
      "\n",
      "P = 200.   #in kPa\n",
      "p_partial = 1.70   #in kPa\n",
      "final_H = p_partial/(P-p_partial);\n",
      "print \"final molal humidity = %.4f\"%(final_H)\n",
      "\n",
      "p_dryair = 100 - 3.39;\n",
      "v = 100*(p_dryair/101.3)*(273./303);\n",
      "moles_dryair = v/22.4;\n",
      "vapor_initial = molal_H*moles_dryair;\n",
      "vapor_final = final_H*moles_dryair;\n",
      "water_condensed = (vapor_initial-vapor_final)*18;\n",
      "print \"amount of water condensed = %f kg\"%(water_condensed)\n",
      "\n",
      "total_air = moles_dryair+vapor_final;\n",
      "final_v = 22.4*(101.3/200)*(288./273)*total_air;\n",
      "print \"final volume of wety air = %f m**3\"%(final_v)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "initial molal humidity = 0.035\n",
        "final molal humidity = 0.0086\n",
        "amount of water condensed = 1.832428 kg\n",
        "final volume of wety air = 46.307275 m**3\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}