{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9 - Electrochemistry"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I1 - Pg 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the potential of the cell\n",
      "#Initialization of variables\n",
      "import math\n",
      "Gr=-math.pow(10,5) #kJ/mol\n",
      "v=1\n",
      "F=9.6485*10000. #C/mol\n",
      "#calculations\n",
      "E=-Gr/(v*F)\n",
      "#results\n",
      "print '%s %d %s' %(\"potential of the cell =\",E,\"V\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "potential of the cell = 1 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I2 - Pg 202"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the equilibrium constant of the reaction\n",
      "#Initialization of variables\n",
      "import math\n",
      "V=1.1 #V\n",
      "F=9.6485*10000. #C/mol\n",
      "R=8.314 #J/K mol\n",
      "T=298.15 #K\n",
      "#calculations\n",
      "lnK=2*F*V/(R*T)\n",
      "k=math.pow(math.e,(lnK))\n",
      "#results\n",
      "print '%s %.1e' %(\"Equilibrium constant =\",k)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant = 1.5e+37\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 189"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the acidity constant of the acid\n",
      "#Initialization of variables\n",
      "import math\n",
      "lw=34.96 #mS m^2 /mol\n",
      "la=4.09 #mS m^2 /mol\n",
      "C=0.010 #M\n",
      "K=1.65 #mS m^2 /mol\n",
      "#calculations\n",
      "lmd=lw+la\n",
      "alpha=K/lmd\n",
      "Ka=C*alpha*alpha\n",
      "pKa=-math.log10(Ka)\n",
      "#results\n",
      "print '%s %.2f' %(\"Acidity constant of the acid = \",pKa)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acidity constant of the acid =  4.75\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 203"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate if the reaction is favoring the products or not. Also calculate the E value\n",
      "#Initialization of variables\n",
      "ER=1.23 #V\n",
      "EL=-0.44 #V\n",
      "#calculations\n",
      "E=ER-EL\n",
      "#results\n",
      "if(E>0):\n",
      "    print '%s %.2f %s' %(\"The reaction is favouring products and E is\",E,\"V\")\n",
      "else:\n",
      "    print '%s %.2f %s' %(\"The reaction is not favouring products and E is\",E,\" V\")\n",
      "    \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reaction is favouring products and E is 1.67 V\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 203"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the equilibrium constant \n",
      "#Initialization of variables\n",
      "import math\n",
      "ER=0.52 #V\n",
      "EL=0.15 #V\n",
      "#calculations\n",
      "E=ER-EL\n",
      "lnK=E*1000./(25.69)\n",
      "K=math.exp(lnK)\n",
      "#results\n",
      "print '%s %.1e' %(\"Equilbrum constant K= \",K)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilbrum constant K=  1.8e+06\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E8 - Pg 205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the biological standard potential\n",
      "#Initialization of variables\n",
      "import math\n",
      "E0=-0.11 #V\n",
      "H=math.pow(10,-7)\n",
      "#calculations\n",
      "pH=-math.log10(H)\n",
      "E=E0-29.59*pH*math.pow(10,-3)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Biological standard potential =\",E,\"V\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Biological standard potential = -0.32 V\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the equilibrium constant for the reaction\n",
      "#Initialization of variables\n",
      "import math\n",
      "ER=-0.21 #V\n",
      "EL=-0.6 #V\n",
      "#calculations\n",
      "E=ER-EL\n",
      "lnK=2*E*1000./(25.69)\n",
      "K=math.exp(lnK)\n",
      "#results\n",
      "print '%s %.1e' %(\"Equilibrium constant for the reaction = \",K)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant for the reaction =  1.5e+13\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 - Pg 209"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the electric potential\n",
      "#Initialization of variables\n",
      "E1=2*(-0.340)\n",
      "E2=-0.522 \n",
      "#calculations\n",
      "FE=-E1+E2\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Electric potential =\",FE,\"V\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Electric potential = 0.158 V\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 - Pg 210"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Gibbs enthalpy, Standard entropy and enthalpy of the process\n",
      "#Initialization of variables\n",
      "import math\n",
      "v=2\n",
      "F=9.6485*10000. #C/mol\n",
      "E=0.2684 #V\n",
      "V1=0.2699 #V\n",
      "V2=0.2669 #V\n",
      "T1=293. #K\n",
      "T=298. #K\n",
      "T2=303. #K\n",
      "#calculations\n",
      "Gr= -v*F*E/1000.\n",
      "Sr=v*F*(V2-V1)/(T2-T1)\n",
      "Hr=Gr+T*Sr/1000.\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Gibbs enthalpy =\",Gr,\"kJ/mol\")\n",
      "print '%s %.1f %s' %(\"\\n Standard Entropy =\",Sr,\"J /K mol\")\n",
      "print '%s %.1f %s' %(\"\\n Enthalpy =\",Hr,\"kJ/mol\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gibbs enthalpy = -51.79 kJ/mol\n",
        "\n",
        " Standard Entropy = -57.9 J /K mol\n",
        "\n",
        " Enthalpy = -69.0 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}