{
 "metadata": {
  "name": "",
  "signature": "sha256:a0be5f6d37f6b1696997f58d0cc492cc18c5483e1f769555c228f3249920c51f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13: Boltzmann Distribution"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 13.1, Page Number 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import factorial\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "aH = 40\n",
      "N = 100\n",
      "\n",
      "#Calculations\n",
      "aT = 100 - aH\n",
      "We = factorial(N)/(factorial(aT)*factorial(aH))\n",
      "Wexpected = factorial(N)/(factorial(N/2)*factorial(N/2))\n",
      "\n",
      "#Results\n",
      "print 'The observed weight %5.2e compared to %5.2e'%(We,Wexpected)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The observed weight 1.37e+28 compared to 1.01e+29\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 13.2, Page Number 310"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 13.3, Page Number 314"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "p0 = 0.633        #Probabilities of Energy level 1,2,3 \n",
      "p1 = 0.233\n",
      "p2 = 0.086\n",
      "\n",
      "#Calculation\n",
      "p4 = 1. -(p0+p1+p2)\n",
      "\n",
      "#Results\n",
      "print 'Probability of finding an oscillator at energy level of n>3 is %4.3f i.e.%4.1f percent'%(p4,p4*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Probability of finding an oscillator at energy level of n>3 is 0.048 i.e. 4.8 percent\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 13.4, Page Number 315"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "p0 = 0.394        #Probabilities of Energy level 1,2,3 \n",
      "p1by2 = 0.239\n",
      "p2 = 0.145\n",
      "\n",
      "#Calculation\n",
      "p4 = 1. -(p0+p1by2+p2)\n",
      "\n",
      "#Results\n",
      "print 'Probability of finding an oscillator at energy level of n>3 is %4.3f'%(p4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Probability of finding an oscillator at energy level of n>3 is 0.222\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 13.5, Page Number 321"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "\n",
      "#Variable Declaration\n",
      "I2 = 208         #Vibrational frequency, cm-1 \n",
      "T = 298          #Molecular Temperature, K\n",
      "c = 3.00e10      #speed of light, cm/s\n",
      "h = 6.626e-34    #Planks constant, J/K\n",
      "k = 1.38e-23     #Boltzman constant, J/K\n",
      "#Calculation\n",
      "q = 1./(1.-exp(-h*c*I2/(k*T)))\n",
      "p2 = exp(-2*h*c*I2/(k*T))/q\n",
      "\n",
      "#Results\n",
      "print 'Partition function is %4.3f'%(q)\n",
      "print 'Probability of occupying the second vibrational state n=2 is %4.3f'%(p2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Partition function is 1.577\n",
        "Probability of occupying the second vibrational state n=2 is 0.085\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example Problem 13.6, Page Number 322"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Declaration\n",
      "B = 1.45         #Magnetic field streangth, Teslas \n",
      "T = 298          #Molecular Temperature, K\n",
      "c = 3.00e10      #speed of light, cm/s\n",
      "h = 6.626e-34    #Planks constant, J/K\n",
      "k = 1.38e-23     #Boltzman constant, J/K \n",
      "gnbn = 2.82e-26  #J/T\n",
      "#Calculation\n",
      "ahpbyahm = exp(-gnbn*B/(k*T))\n",
      "\n",
      "#Results\n",
      "print 'Occupation Number is %7.6f'%(ahpbyahm)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Occupation Number is 0.999990\n"
       ]
      }
     ],
     "prompt_number": 18
    }
   ],
   "metadata": {}
  }
 ]
}