{
 "metadata": {
  "name": "",
  "signature": "sha256:d710461b968e986411ee49bb4f3e24c283e59536cefcb736abd7424eef7f3627"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 11: Electrochemical Cells, Batteries, and Fuel Cells"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.1, Page Number 256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log, sqrt\n",
      "\n",
      "#Variable Declaration\n",
      "aH = 0.770        #Activity of \n",
      "fH2 = 1.13        #Fugacity of Hydrogen gas\n",
      "E0 = 0.0          #Std. electrode potential, V\n",
      "n = 1.0           #Number of electrons transfered\n",
      "\n",
      "#Calculations\n",
      "E = E0 - (0.05916/n)*log(aH/sqrt(fH2),10)\n",
      "\n",
      "#Results\n",
      "print 'The potential of H+/H2 half cell %5.4f V'%E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "THe potential of H+/H2 half cell 0.00829 V\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.2, Page Number 256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log, sqrt\n",
      "\n",
      "#Variable Declaration\n",
      "E0r1 = -0.877       #Std Electrod potential for Rx2 : Al3+ + 3e- ------> Al (s)                   \n",
      "E0r2 = -1.660       #Std Electrod potential for Rx2 : Al3+ + 3e- ------> Al (s)\n",
      "E0r3 = +0.071       #Std Electrod potential for Rx3 : AgBr (s) + e- ------> Ag(s) +Br- (aq.)\n",
      "\n",
      "#Calculations\n",
      "#3Fe(OH)2 (s)+ 2Al (s)  <---------> 3Fe (s)  + 6(OH-) + 2Al3+\n",
      "E0a = 3*E0r1 + (-2)*E0r2\n",
      "#Fe (s) + 2OH- +   2AgBr (s) -------> Fe(OH)2 (s)  + 2Ag(s) +  2Br- (aq.)\n",
      "E0b = -E0r1 + (2)*E0r3\n",
      "\n",
      "#Results\n",
      "print '%5.3f %5.3f'%(E0a,E0b)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0.689 1.019\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.3, Page Number 257"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration\n",
      "E01 = 0.771      #Rx1 : Fe3+ + e- -----> Fe2+\n",
      "E02 = -0.447     #Rx2 : Fe2+ + 2e- -----> Fe\n",
      "F = 96485        #Faraday constant, C/mol\n",
      "n1,n2,n3 = 1.,2.,3.\n",
      "\n",
      "#Calculations\n",
      "dG01 = -n1*F*E01\n",
      "dG02 = -n2*F*E02\n",
      "                #For overall reaction\n",
      "dG0 = dG01 + dG02\n",
      "E0Fe3byFe = -dG0/(n3*F)\n",
      "\n",
      "#Results\n",
      "print 'E0 for overall reaction is %5.3f V'%(E0Fe3byFe)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "E0 for overall reaction is -0.041 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.4, Page Number 258"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "E01 = +1.36             #Std. electrode potential for Cl2/Cl\n",
      "dE0bydT = -1.20e-3      #V/K\n",
      "F = 96485               #Faraday constant, C/mol\n",
      "n = 2.\n",
      "S0H = 0.0               #Std. entropy J/(K.mol) for H+ ,Cl-,H2, Cl2 \n",
      "S0Cl = 56.5\n",
      "S0H2 = 130.7\n",
      "S0Cl2 = 223.1\n",
      "nH, nCl, nH2, nCl2 = 2, 2, -1,-1\n",
      "#Calculations\n",
      "dS01 = n*F*dE0bydT\n",
      "dS02 =nH*S0H + nCl*S0Cl + nH2*S0H2 + nCl2*S0Cl2\n",
      "\n",
      "#Results\n",
      "print 'Std. entropy change of reaction from dE0bydT is %4.2e and\\nStd entropy values is %4.2e V'%(dS01,dS02)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Std. entropy change of reaction from dE0bydT is -2.32e+02 and\n",
        "Std entropy values is -2.41e+02 V\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.5, Page Number 259"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "#Variable Declaration\n",
      "E0 = +1.10              #Std. electrode potential for Danniel cell, V\n",
      "                        #Zn(s) + Cu++ ----->  Zn2+   +  Cu\n",
      "T = 298.15              #V/K\n",
      "F = 96485               #Faraday constant, C/mol\n",
      "n = 2.\n",
      "R = 8.314               #Gas constant, J/(mol.K)\n",
      "\n",
      "#Calculations\n",
      "K = exp(n*F*E0/(R*T))\n",
      "\n",
      "#Results\n",
      "print 'Equilibrium constant for reaction is %4.2e'%(K)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant for reaction is 1.55e+37\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.6, Page Number 259"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "E = +0.29               #Cell emf, V\n",
      "\n",
      "#Calculations\n",
      "Ksp = 10**(-n*E/0.05916)\n",
      "\n",
      "#Results\n",
      "print 'Equilibrium constant for reaction is %4.2e'%(Ksp)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant for reaction is 1.57e-10\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 11.8, Page Number 262"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "E = +1.51               #EMF for reduction of permangnet, V\n",
      "E01 = -0.7618           #Zn2+  + 2e-  -------->  Zn (s)\n",
      "E02 = +0.7996           #Ag+  + e-  -------->  Ag (s)\n",
      "E03 = +1.6920           #Au+  + e-  -------->  Au (s)        \n",
      "\n",
      "#Calculations\n",
      "EZn = E - E01\n",
      "EAg = E - E02\n",
      "EAu = E - E03\n",
      "animals = {\"parrot\": 2, \"fish\": 6}\n",
      "Er = {\"Zn\":EZn,\"Ag\":EAg,\"Au\":EAu}\n",
      "#Results\n",
      "print 'Cell potentials for Zn, Ag, Au are %4.2f V, %4.2f V, and %4.2f V'%(EZn, EAg,EAu)\n",
      "for i in Er:\n",
      "    if Er[i] >0.0:\n",
      "        print '%s has positive cell potential of %4.3f V and Can be oxidized bypermangnate ion' %(i,Er[i])\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cell potentials for Zn, Ag, Au are 2.27 V, 0.71 V, and -0.18 V\n",
        "Zn has positive cell potential of 2.272 V and Can be oxidized bypermangnate ion\n",
        "Ag has positive cell potential of 0.710 V and Can be oxidized bypermangnate ion\n"
       ]
      }
     ],
     "prompt_number": 25
    }
   ],
   "metadata": {}
  }
 ]
}