{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8 - Consequences of equilibrium"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I1 - Pg 176"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the equlibrium pH\n",
      "#Initialization of variables\n",
      "ph1=6.37\n",
      "ph2=10.25\n",
      "ph3=7.21\n",
      "ph4=12.67\n",
      "#calculations\n",
      "pH1=0.5*(ph1+ph2)\n",
      "pH2=0.5*(ph3+ph4)\n",
      "#results\n",
      "print '%s %.2f' %(\"Equilibrium pH in case 1 = \",pH1)\n",
      "print '%s %.2f' %(\"\\n Equilibrium pH in case 2 = \",pH2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium pH in case 1 =  8.31\n",
        "\n",
        " Equilibrium pH in case 2 =  9.94\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I2 - Pg 178"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the pH of the solution\n",
      "#Initialization of variables\n",
      "import math\n",
      "n=2.5/1000. #mol\n",
      "C=0.2 #mol/L\n",
      "vbase=37.5/1000. #L\n",
      "#calculations\n",
      "V=n/C\n",
      "base=n/vbase\n",
      "H=math.pow(10,-14) /base\n",
      "print '%s' %(\"It follows from example 8.2 that\")\n",
      "pH=10.2\n",
      "#results\n",
      "print '%s %.1f' %(\"\\n pH of the solution = \",pH)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "It follows from example 8.2 that\n",
        "\n",
        " pH of the solution =  10.2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the percent of acetic acid molecules that have donated a proton\n",
      "#Initialization of variables\n",
      "import math\n",
      "C=0.15 #M\n",
      "Ka=1.8*math.pow(10,-5)\n",
      "#calculations\n",
      "x=math.sqrt(C*Ka)\n",
      "f=x/C\n",
      "percent=f*100.\n",
      "#results\n",
      "print '%s %.1f %s' %(\"percent of acetic acid molecules that have donated a proton =\",percent,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percent of acetic acid molecules that have donated a proton = 1.1 percent\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the fraction proportionated\n",
      "#Initialization of variables\n",
      "import math\n",
      "pKa=4.88\n",
      "C=0.01 #M\n",
      "pKw=14\n",
      "#calculations\n",
      "pKb=pKw-pKa\n",
      "Kb=math.pow(10,(-pKb))\n",
      "x=(math.sqrt(C*Kb))\n",
      "pOH=-math.log(x)\n",
      "pH=14-pOH\n",
      "f=x/C\n",
      "#results\n",
      "print '%s %.1e' %(\"fraction protonated = \",f)\n",
      "print '%s %d' %(\"\\n 1 molecule in about \",1./f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "fraction protonated =  2.8e-04\n",
        "\n",
        " 1 molecule in about  3630\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 173"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate te concentration of carbonate ions\n",
      "#Initialization of variables\n",
      "import math\n",
      "pKa2=10.25\n",
      "#calculations\n",
      "C=math.pow(10,(-pKa2))\n",
      "#results\n",
      "print '%s %.1e %s' %(\"Concentration of Carbonate ions =\",C,\" mol/l\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Concentration of Carbonate ions = 5.6e-11  mol/l\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 173"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final pH of the solution\n",
      "#Initialization of variables\n",
      "import math\n",
      "vOH=5*math.pow(10,-3) #L\n",
      "vHClO=25*math.pow(10,-3) #L\n",
      "C=0.2 #mol/L\n",
      "#calculations\n",
      "nOH=vOH*C\n",
      "nHClO=vHClO*C/2.\n",
      "nrem=nHClO-nOH\n",
      "pH=7.53-math.log10(nrem/nOH)\n",
      "#results\n",
      "print '%s %.1f' %(\"Final pH= \",pH)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final pH=  7.4\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}