{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 20 - Statistical thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I1 - Pg 477"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the relative populations of boat and chair conformations\n",
      "#Initialization of variables\n",
      "import math\n",
      "E=22*1000. #kJ/mol\n",
      "T=293. #K \n",
      "#calculations\n",
      "ratio=math.pow(math.e,(-E/(8.31451*T)))\n",
      "#results\n",
      "print '%s %.1e' %(\"Relative populations of boat and chair conformations is \",ratio)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Relative populations of boat and chair conformations is  1.2e-04\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I2 - Pg 478"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the required ratio\n",
      "#Initialization of variables\n",
      "import math\n",
      "g2=5.\n",
      "g1=3.\n",
      "E2=6.\n",
      "E1=2.\n",
      "k=1.38*math.pow(10,-23) #J/K\n",
      "h=6.626*math.pow(10,-34) #J s\n",
      "B=3.18*math.pow(10,11) #Hz\n",
      "T =298 #K\n",
      "#calculations\n",
      "ratio=g2/g1 *(math.pow(math.e,((E1-E2)*h*B/(k*T))))\n",
      "#results\n",
      "print '%s %.2f' %(\"Ratio= \",ratio)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ratio=  1.36\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I3 - Pg 481"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the translational partition function\n",
      "#Initialization of variables\n",
      "import math\n",
      "T=298  #K\n",
      "m=32*1.66054*math.pow(10,-27) #kg\n",
      "k=1.38066*math.pow(10,-23) #j/k\n",
      "V=math.pow(10,-4) #m^3\n",
      "h=6.62608*math.pow(10,-34) #J/s\n",
      "#calculations\n",
      "q=math.pow((2*math.pi*m*k*T),1.5) *V/h/h/h \n",
      "#results\n",
      "print '%s %.2e' %(\"Translational partition function = \",q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Translational partition function =  1.75e+28\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 479"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the partition function at 20 C\n",
      "#Initialization of variables\n",
      "import math\n",
      "E=22 #kJ/mol\n",
      "R=8.214 #J/K mol\n",
      "T=293 #K\n",
      "#Calculations\n",
      "q=1+math.pow(math.e,(-E*1000. /(R*T)))\n",
      "#results\n",
      "print '%s %.4f' %(\"At 20 C, partition function = \",q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At 20 C, partition function =  1.0001\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 485"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the contribution to rotational motion\n",
      "#Initialization of variables\n",
      "import math\n",
      "k=1.38*math.pow(10,-23) #J/K\n",
      "h=6.626*math.pow(10,-34) #J s\n",
      "B=3.18*math.pow(10,11) #Hz\n",
      "T=298 #K\n",
      "R=8.314 #J/K mol\n",
      "#calculations\n",
      "Sm=R*(1+math.log(k*T/(h*B)))\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Contribution to rotational motion=\",Sm,\"J/ K mol\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Contribution to rotational motion= 33.0 J/ K mol\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 488"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Equilibrium constant\n",
      "#Initialization of variables\n",
      "import math\n",
      "me=9.10939*math.pow(10,-31) #kg\n",
      "k=1.38*math.pow(10,-23) #J/K\n",
      "h=6.626*math.pow(10,-34) #J s\n",
      "p=math.pow(10,5) #Pa\n",
      "T=1000 #K\n",
      "R=8.314 #J/K mol\n",
      "I=376*1000. #J/mol\n",
      "#calculations\n",
      "K=math.pow((2*math.pi*me),1.5) *math.pow((k*T),2.5) /(p*h*h*h) *math.pow(math.e,(-I/(R*T)))\n",
      "#results\n",
      "print '%s %.2e' %(\"Equilibrium constant = \",K)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant =  2.41e-19\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}