{
 "metadata": {
  "name": "",
  "signature": "sha256:b3b8e3a1df1ec221a5596f2fd615d0e7df4ba35a4012aeb734d5820e6983cd64"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13 - Thermodynamic changes accompanying chemical reaction"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - pg 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the dHp value\n",
      "#Initialization of variables\n",
      "n1=10 #mol\n",
      "n2=12 #mol\n",
      "#calculations\n",
      "dn=n1-n2\n",
      "#results\n",
      "print '%s %d %s' %(\"dHp = dEv-\",dn,\"*RT\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dHp = dEv- -2 *RT\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - pg 322"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Enthalpy\n",
      "#Initialization of variables\n",
      "Ht1=-22063 #cal\n",
      "T=298.15 #K\n",
      "#calculations\n",
      "H=Ht1 +0.5293*T + 0.3398*10**-3 *T**2 - 2.039*10**-7 *T**3\n",
      "#results\n",
      "print '%s %d %s' %(\"Enthalpy =\",H,\"cal\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Enthalpy = -21880 cal\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - pg 326"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Entropy\n",
      "#Initialization of variables\n",
      "Cp=0.797 #cal/deg/mol\n",
      "#calculations\n",
      "S=Cp/3.\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Entropy =\",S,\" eu/mol\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Entropy = 0.266  eu/mol\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - pg 328"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Change in entropy\n",
      "#Initialization of variables\n",
      "T1=77.32 #K\n",
      "P=1 #atm\n",
      "T2=126 #K\n",
      "Pc=33.5 #atm\n",
      "#calculations\n",
      "dS=27/32. *1.987*P/Pc *(T2/T1)**3\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Change in entropy =\",dS,\"eu/mol\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy = 0.22 eu/mol\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - pg 330"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Change in entropy, enthalpy and free energy\n",
      "#Initialization of variables\n",
      "S1=57.47\n",
      "S2=50.34\n",
      "S3=49\n",
      "H1=8.09\n",
      "H2=21.06\n",
      "H3=0\n",
      "F1=12.39\n",
      "F2=20.72\n",
      "F3=0\n",
      "#calculations\n",
      "dS=S1-S2-0.5*S3\n",
      "dH=H1-H2-0.5*H3\n",
      "dF=F1-F2-0.5*F3\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Change in entropy =\",dS,\" eu\")\n",
      "print '%s %.2f %s' %(\"\\n Change in enthalpy =\",dH,\" kcal\")\n",
      "print '%s %.2f %s' %(\"\\n Change in free energy =\",dF,\"kcal\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy = -17.37  eu\n",
        "\n",
        " Change in enthalpy = -12.97  kcal\n",
        "\n",
        " Change in free energy = -8.33 kcal\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - pg 334"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the change in free energy\n",
      "#Initialization of variables\n",
      "import math\n",
      "P1=0.01\n",
      "P2=0.1\n",
      "P3=0.01\n",
      "dF0=-54640 #cal\n",
      "T=298.15 #K\n",
      "R=1.987 #cal/deg\n",
      "#calculations\n",
      "Qp=P1/(P2*P3**0.5)\n",
      "dF=dF0+R*T*math.log(Qp)\n",
      "#results\n",
      "print '%s %d %s' %(\"change in free energy =\",dF,\"cal\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in free energy = -54640 cal\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - pg 335"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Equilibrium constant\n",
      "#Initialization of variables\n",
      "print \"From table 13.4 \"\n",
      "logKfwater=40.04724\n",
      "logKfH2=0\n",
      "logKfO2=0\n",
      "#calculations\n",
      "logK=logKfwater-logKfH2-0.5*logKfO2\n",
      "K=10**logK\n",
      "#results\n",
      "print '%s %.4e' %(\"Equilibrium constant = \",K)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 13.4 \n",
        "Equilibrium constant =  1.1149e+40\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - pg 339"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the value of Kc\n",
      "#Initialization of variables\n",
      "Kp=1.1*10**40 #atm**-0.5\n",
      "dn=-0.5\n",
      "R=0.08206 #lt atm/deg mol\n",
      "T=298.15 #K\n",
      "#calculations\n",
      "Kc=Kp*(R*T)**(-dn)\n",
      "#results\n",
      "print '%s %.1e %s' %(\"Kc =\",Kc,\" (mol/lt)^-0.5\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Kc = 5.4e+40  (mol/lt)^-0.5\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9 - pg 339"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Density of equilibrium mixture\n",
      "#Initialization of variables\n",
      "import numpy\n",
      "Kp=0.141 #atm\n",
      "P=1 #atm\n",
      "nu=2\n",
      "R=0.08206 #lt atm/deg mol\n",
      "T=298.15 #K\n",
      "M=92.02 #g/mol\n",
      "#calculations\n",
      "p=([Kp+ 4*P,0, -Kp])\n",
      "z=numpy.roots(p)\n",
      "alpha=z[0]\n",
      "wbyV=P*M/(R*T*(1+(nu-1)*alpha))\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Density of the equilibrium mixture =\",wbyV,\" g/lt\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Density of the equilibrium mixture = 3.18  g/lt\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10 - pg 340"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Final pressure after equilibrium\n",
      "#Initialization of variables\n",
      "x=0.5\n",
      "P=0.468 #atm\n",
      "#calculations\n",
      "P1=x*P\n",
      "P2=x*P\n",
      "Kp=P1*P2\n",
      "#results\n",
      "print '%s %.4f %s' %(\"Final pressure after equilibrium =\",Kp,\" atm^2\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final pressure after equilibrium = 0.0548  atm^2\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}