{
 "metadata": {
  "name": "",
  "signature": "sha256:f51aa40f01063be99829dfd06c53ed90029beb6946cceb4b92469b9c50e91012"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 - Development and use of activity concepts"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - pg 350"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the moles of Iodine present\n",
      "#Initialization of variables\n",
      "x1=0.0200\n",
      "Kx=812.\n",
      "#calculations\n",
      "print \"Neglecting 2x in comparision with x1,\"\n",
      "x=x1/Kx\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Moles of Iodine present =\",x,\" mole\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Neglecting 2x in comparision with x1,\n",
        "Moles of Iodine present = 2.46e-05  mole\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - pg 350 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentration of H+ ions\n",
      "#Initialization of variables\n",
      "Kc=1.749*10**-5 #M\n",
      "n1=0.1 #mole\n",
      "n2=0.01 #mole\n",
      "#calculations\n",
      "c=n1/n2 *Kc\n",
      "#results\n",
      "print '%s %.1e %s' %(\"Concentration of Hplus ions =\",c,\" M\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Concentration of Hplus ions = 1.7e-04  M\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - pg 351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentraton of Hplus ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "c=0.01 #M\n",
      "kc=1.749*10**-5 #M\n",
      "#calculations\n",
      "x2=c*kc\n",
      "x=math.sqrt(x2)\n",
      "#results\n",
      "print '%s %.1e %s' %(\"Concentration of Hplus ions =\",x,\"M\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Concentration of Hplus ions = 4.2e-04 M\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - pg 351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentration of OH- ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "K2=1.0008*10**-14 #m^2\n",
      "K1=1.754*10**-5 #m\n",
      "c=0.1\n",
      "#calculations\n",
      "print \"Neglecting x w.r.t c,\"\n",
      "x2=c*K2/K1\n",
      "x=math.sqrt(x2)\n",
      "#results\n",
      "print '%s %.1e %s' %(\"Concentration of OH minus ions =\",x,\" m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Neglecting x w.r.t c,\n",
        "Concentration of OH minus ions = 7.6e-06  m\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - pg 352"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentration of H plus ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "print \"from table 14.1,\"\n",
      "r1=7.47*10**-5 #m\n",
      "r2=4.57*10**-3 #m\n",
      "mp=1.008*10**-14 #m**2\n",
      "#calculations\n",
      "r3=r2/r1\n",
      "mH2=r3*mp\n",
      "mH=math.sqrt(mH2)\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Concentration of Hplus ions = \",mH,\" M\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from table 14.1,\n",
        "Concentration of Hplus ions =  7.85e-07  M\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - pg 354"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentraton of H+ ions\n",
      "#Initialization of variables\n",
      "print \"from table 14.1,\"\n",
      "import math\n",
      "r1=1.75*10**-5 #m\n",
      "r2=1.772*10**-4 #m\n",
      "mp=1.008*10**-14 #m**2\n",
      "#calculations\n",
      "r3=r2/r1\n",
      "mH2=r3*mp\n",
      "mH=math.sqrt(mH2)\n",
      "#results\n",
      "print '%s %.1e %s' %(\"Concentration of Hplus ions =\",mH,\" M\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from table 14.1,\n",
        "Concentration of Hplus ions = 3.2e-07  M\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - pg 355"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentration of H+ ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "c=1*10**-6 #m\n",
      "K=1.754*10**-5 #m\n",
      "Kp=1.008*10**-14 #m**2\n",
      "#calculations\n",
      "mH=c\n",
      "#Iteration 1\n",
      "mOH=Kp/mH\n",
      "mA=mH-mOH\n",
      "mHA=mH*mA/K\n",
      "mH2=mH-mHA+mOH\n",
      "#Iteration 2\n",
      "mOH2=Kp/mH2\n",
      "mA2=mH2-mOH2\n",
      "mHA2=mH2*mA2/K\n",
      "mH3=mH2-mHA2+mOH2\n",
      "#From x2\n",
      "x2=math.sqrt(Kp)\n",
      "x1=c\n",
      "mOH3=Kp/x2\n",
      "y2=x1\n",
      "#From x1\n",
      "mOH4=Kp/c\n",
      "mA4=mH-mOH4\n",
      "mHA4=mH*mA4/K\n",
      "y1=c-mHA4-mA4\n",
      "#upon further iterations, we get\n",
      "mHplus=mH3\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Concentration of H plus ions =\",mHplus,\"m\")\n",
      "print 'The answer is a bit different due to rounding off error.'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Concentration of H plus ions = 9.13e-07 m\n",
        "The answer is a bit different due to rounding off error.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - pg 358"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the values of dS0, dH0, Krm\n",
      "#Initialization of variableH\n",
      "print \"From table 14-3,\"\n",
      "HH=0\n",
      "HHcoo=-98.\n",
      "HHcooh=-98.\n",
      "SH=0\n",
      "SHcoo=21.9\n",
      "SHcooh=39.1\n",
      "KH=0\n",
      "KHcoo=58.64\n",
      "KHcooh=62.38\n",
      "#calculationH\n",
      "dH=HH+HHcoo-HHcooh\n",
      "dS=SH+SHcoo-SHcooh\n",
      "dK=KH+KHcoo-KHcooh\n",
      "K=10**dK\n",
      "#results\n",
      "print '%s %.1f %s' %(\" dS0 =\",dS,\"eu\")\n",
      "print '%s %.1f %s' %(\"\\n dH0 =\",dH,\"kcal\")\n",
      "print '%s %.2f' %(\"\\n log Krm =\",dK)\n",
      "print '%s %.1e %s' %(\"\\n Krm =\",K,\"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 14-3,\n",
        " dS0 = -17.2 eu\n",
        "\n",
        " dH0 = 0.0 kcal\n",
        "\n",
        " log Krm = -3.74\n",
        "\n",
        " Krm = 1.8e-04 m\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9 - pg 369"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Activity of cl and ca\n",
      "#Initialization of variables\n",
      "mca=0.01 #m\n",
      "mcl=0.02 #m\n",
      "#calculations\n",
      "Mu=0.5*(mca*4 + mcl*1)\n",
      "print \"From table 14-5,\"\n",
      "aca=6 #A\n",
      "acl=3 #A\n",
      "print \"From table 14-6,\"\n",
      "gaca=0.555 \n",
      "gacl=0.843\n",
      "Aca=gaca*mca\n",
      "Acl=gacl*mcl\n",
      "#results\n",
      "print '%s %.4f' %(\"Activity of cl = \",Acl)\n",
      "print '%s %.4f' %(\"\\n Activity of ca = \",Aca)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 14-5,\n",
        "From table 14-6,\n",
        "Activity of cl =  0.0169\n",
        "\n",
        " Activity of ca =  0.0056\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10 - pg 369"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentration of H+ ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "m1=0.1 #m\n",
      "m2=0.1 #m\n",
      "K=1.754*10**-5 #m\n",
      "#calculations\n",
      "mu=0.5*(m1*1**2 + m2*1**2)\n",
      "print(\"From table 14.5,\")\n",
      "aH=9 #A\n",
      "aA=4.5 #A\n",
      "print(\"From table 14.6\")\n",
      "gH=0.825\n",
      "gA=0.775\n",
      "gHA=1\n",
      "x1=gHA*K/(gH*gA)\n",
      "print(\"Assuming x to be small w.r.t m1,\")\n",
      "x=math.sqrt(x1*m1)\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Concentration of H plus ions =\",x,\" m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 14.5,\n",
        "From table 14.6\n",
        "Assuming x to be small w.r.t m1,\n",
        "Concentration of H plus ions = 1.66e-03  m\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11 - pg 372"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the concentration of H+ ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "import numpy\n",
      "K=1.754*10**-5 #m\n",
      "c=0.1\n",
      "#calculations\n",
      "print(\"Neglecting x w.r.t c,\")\n",
      "x2=K\n",
      "x=math.sqrt(K)\n",
      "mu=x\n",
      "print(\"From tables 14-5 and 14-6,\")\n",
      "gH=0.963\n",
      "gA=0.960\n",
      "x22=K/(gH*gA)\n",
      "p=([1,x22, -c*x22])\n",
      "z=numpy.roots(p)\n",
      "alpha=z[1]\n",
      "#results\n",
      "print '%s %.2e %s' %(\"concentration of H plus ions =\",alpha,\" m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Neglecting x w.r.t c,\n",
        "From tables 14-5 and 14-6,\n",
        "concentration of H plus ions = 1.37e-03  m\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12 - pg 373"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Solubility of Agcl\n",
      "#Initialization of variables\n",
      "print(\"From table 14.3\")\n",
      "import math\n",
      "K1=-13.5089\n",
      "K2=-22.9792\n",
      "K3=19.2218\n",
      "c=0.1 #m\n",
      "#calculations\n",
      "logK=K1-K2-K3\n",
      "K=10**logK\n",
      "mu=0.5*(c*1**2 + c*1**2)\n",
      "print(\"From tables 14-5 and 14-6,\")\n",
      "gAg=0.745\n",
      "gCl=0.755\n",
      "x2=K/(gAg*gCl)\n",
      "x=math.sqrt(x2)\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Solubility of Agcl =\",x,\"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 14.3\n",
        "From tables 14-5 and 14-6,\n",
        "Solubility of Agcl = 1.78e-05 m\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13 - pg 376"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Concentration of Na and Cl in both cases\n",
      "#Initialization of variables\n",
      "import numpy\n",
      "Cna=0.11\n",
      "Ccl=0.1\n",
      "#calculations\n",
      "p=([99, - 2.1, Cna*Ccl])\n",
      "z=numpy.roots(p)\n",
      "alpha=z[1]\n",
      "Na1=Cna-10*alpha\n",
      "Cl1=Ccl-10*alpha\n",
      "#results\n",
      "print '%s %.4f %s' %(\" Concentration of Na in 1  =\",Na1,\"M\")\n",
      "print '%s %.4f %s' %(\"\\n Concentration of Cl in 1  =\",Cl1,\" M\")\n",
      "print '%s %.4f %s' %(\"\\n Concentration of Na in 2  =\",alpha,\"M\")\n",
      "print '%s %.4f %s' %(\"\\n Concentration of Cl in 2  =\",alpha,\"M\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Concentration of Na in 1  = 0.0157 M\n",
        "\n",
        " Concentration of Cl in 1  = 0.0057  M\n",
        "\n",
        " Concentration of Na in 2  = 0.0094 M\n",
        "\n",
        " Concentration of Cl in 2  = 0.0094 M\n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}