{
 "metadata": {
  "name": "",
  "signature": "sha256:99c63cd5d461a992de3be34298ef557332677985056a4e6a31ae5dace5faabc1"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9: Statistical Physics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4, Page 303"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "k = 1.38e-023;    # Boltzmann constant, J/K\n",
      "N_A = 6.023e+023;    # Avogadro's number\n",
      "T = 293;    # Room temperature, K\n",
      "e = 1.6e-019;    # Energy equivalent of 1 eV, J\n",
      "\n",
      "#Calculations\n",
      "# For a single molecule\n",
      "K_bar_single = 3./2*k*T/e;    # Mean translational kinetic energy of a single gas molecule, J\n",
      "# For a 1 mole of molecules\n",
      "K_bar_mole = K_bar_single*N_A*e;    # Mean translational kinetic energy of 1 mole of gas molecules, J\n",
      "\n",
      "#Results\n",
      "print \"The mean translational kinetic energy of the single idela gas molecule = %5.3f eV\"%K_bar_single\n",
      "print \"The mean translational kinetic energy of the one mole of ideal gas molecules = %4d J\"%(math.ceil(K_bar_mole))\n",
      "\n",
      "#Answer differs due to rounding error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean translational kinetic energy of the single idela gas molecule = 0.038 eV\n",
        "The mean translational kinetic energy of the one mole of ideal gas molecules = 3654 J\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.3, Page 310"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "k = 1.38e-023;    # Boltzmann constant, J/K\n",
      "u = 1.67e-027;    # Mass equivalent of one atomic mass unit, kg\n",
      "T = 293;    # Room temperature, K\n",
      "m_H = 1.008*u;    # Gram atomic mass of hydrogen, kg\n",
      "\n",
      "#Calculations&Results\n",
      "m = 2*m_H;    # Gram molecular mass of hydrogen molecule, kg\n",
      "v_bar = 4/math.sqrt(2*math.pi)*math.sqrt(k*T/m);    # Mean molecular speed in the light gas hydrogen, m/s\n",
      "print \"The mean molecular speed in the light gas hydrogen = %4d m/s\"%(math.ceil(v_bar))\n",
      "m = 222*u;    # Gram atomic mass of Radon, kg\n",
      "v_bar = 4/math.sqrt(2*math.pi)*math.sqrt(k*T/m);    # Mean molecular speed in the heavy radon gas, m/s\n",
      "print \"The mean molecular speed in the heavy radon gas = %3d m/s\"%(math.ceil(v_bar))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean molecular speed in the light gas hydrogen = 1749 m/s\n",
        "The mean molecular speed in the heavy radon gas = 167 m/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4, Page 310"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import scipy\n",
      "from scipy.integrate import quad\n",
      "\n",
      "#Variable declaration\n",
      "m = 1;    # For simplicity assume mass of gas molecule to be unity, kg\n",
      "k = 1.38e-023;    # Boltzmann constant, J/K\n",
      "T = 293;    # Room temperature, K\n",
      "\n",
      "#Calculations\n",
      "bita = k*T;    # Energy associated with three degrees of freedom, J\n",
      "v_mps = math.sqrt(2/(bita*m));    # For simplcity assume most probable speed to be unity, m/s\n",
      "C = (bita*m/(2*math.pi))**(3./2);    # Constant in the distribution function\n",
      "p = lambda v: 4*math.pi*C*math.exp(-1./2*bita*m*v**2)*v**2\n",
      "P,err = scipy.integrate.quad(p,0.99*v_mps, 1.01*v_mps)\n",
      "\n",
      "#Result\n",
      "print \"The fraction of molecules in an ideal gas in equilibrium which have speeds within 1 percent above and below the most probable speed = %5.3f\"%P"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The fraction of molecules in an ideal gas in equilibrium which have speeds within 1 percent above and below the most probable speed = 0.017\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.6, Page 315"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "k = 1.38e-023;    # Boltzmann constant, J/K\n",
      "T = [293, 5000, 1e+006];    # Room temperature, temperature at the surface of the star and temperature at the star interior respectively, K\n",
      "e = 1.6e-019;    # Energy equivalent of 1 eV, J\n",
      "g_E1 = 2;    # Possible configuration of the electrons in ground state of H-atom\n",
      "g_E2 = 8;    # Possible configuration of the electrons in the first excited state of H-atom\n",
      "E1 = -13.6;    # Energy of the ground state, eV\n",
      "E2 = -3.4;    # Energy of the first excited state state, eV\n",
      "\n",
      "#Calculations&Results\n",
      "n_ratio = numpy.zeros(3);\n",
      "for i in range(0,3):\n",
      "    n_ratio[i] = g_E2/g_E1*math.exp(1./(k*T[i])*(E1 - E2)*e);\n",
      "    print \"For T = %4.2e K, n_E2/n_E1 = %4.2e\"%(T[i], n_ratio[i])\n",
      "\n",
      "#Incorrect answer given in textbook for the first part"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For T = 2.93e+02 K, n_E2/n_E1 = 2.05e-175\n",
        "For T = 5.00e+03 K, n_E2/n_E1 = 2.14e-10\n",
        "For T = 1.00e+06 K, n_E2/n_E1 = 3.55e+00\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.7, Page 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "e = 1.6e-019;    # Energy equivalent of 1 eV, J\n",
      "n = 8.47e+028;    # Number density of conduction electrons in copper, per metre cube\n",
      "k = 1.38e-023;    # Boltzmann constant, J/K\n",
      "h = 6.626e-034;    # Planck's constant, Js\n",
      "m = 9.11e-031;    # Mass of an electron, kg\n",
      "\n",
      "#Calculations\n",
      "E_F = h**2/(8*m*e)*(3*n/math.pi)**(2./3);    # Fermi energy for copper, eV\n",
      "T_F = E_F*e/k;    # Fermi temperature for copper, K\n",
      "\n",
      "#Results\n",
      "print \"The Fermi energy for copper = %4.2f eV\"%E_F\n",
      "print \"The Fermi temperature for copper = %4.2e K\"%T_F"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Fermi energy for copper = 7.04 eV\n",
        "The Fermi temperature for copper = 8.16e+04 K\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.8, Page 323"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "R = 1;    # For simplicity assume the molar gas constant to be unity, J/mol/K\n",
      "T = 293;    # Room temperature, K\n",
      "T_F = 8.16e+004;    # The Fermi temperature for copper\n",
      "\n",
      "#Calculations&Results\n",
      "C_V = math.pi**2*T/(2*T_F)*R;    # Electronic contribution to the molar heat capacity for copper, J/mol/K\n",
      "print \"The electronic contribution to the molar heat capacity for copper = %6.4fR\"%C_V\n",
      "T_F = 6.38e+004;    # The Fermi temperature for silver\n",
      "C_V = math.pi**2*T/(2*T_F)*R;    # Electronic contribution to the molar heat capacity for silver, J/mol/K\n",
      "print \"The electronic contribution to the molar heat capacity for silver = %6.4fR\"%C_V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The electronic contribution to the molar heat capacity for copper = 0.0177R\n",
        "The electronic contribution to the molar heat capacity for silver = 0.0227R\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}