Chapter 3: Statistical Mechanics

Example 3.1, Page 132

In [19]:
from math import *

#Variable Declaration
m = 5.32e-26;   # Mass of one oxygen molecule, kg
k_B = 1.38e-23;  # Boltzmann constant, J/K
T = 200;    # Temperature of the system, K
v = 100;    # Speed of the oxygen molecules, m/s
dv = 1;     # Increase in speed of the oxygen molecules, m/s

#Calculations
P = 4*pi*(m/(2*pi*k_B*T))**(3./2)*exp((-m*v**2)/(2*k_B*T))*v**2*dv;

#Result
print "The probability that the speed of oxygen molecule is %4.2e"%P
The probability that the speed of oxygen molecule is 6.13e-04

Example 3.2, Page 132

In [5]:
#Variable Declaration
A = 32;     # Gram atomic mass of oxygen, g/mol
N_A = 6.023e+026;   # Avogadro's number, per kmol
m = A/N_A;  #mass of the molecule, kg
k_B = 1.38e-23;  # Boltzmann constant, J/K 
T = 273;  # Temperature of the gas, K

#Calculations&Results
v_av = 1.59*sqrt(k_B*T/m);  # Average speed of oxygen molecule, m/s
print "The average speed of oxygen molecule is = %3d m/s"%v_av
v_rms = 1.73*sqrt(k_B*T/m);  # The mean square speed of oxygen molecule, m/s 
print "The root mean square speed of oxygen gas molecule is = %3d m/s"%(ceil(v_rms))
v_mp = 1.41*sqrt(k_B*T/m);  # The most probable speed of oxygen molecule, m/s 
print "The most probable speed of oxygen molecule is = %3d m/s"%(ceil(v_mp))  #incorrect answer in the textbook
The average speed of oxygen molecule is = 423 m/s
The root mean square speed of oxygen gas molecule is = 461 m/s
The most probable speed of oxygen molecule is = 376 m/s

Example 3.3, Page 133

In [8]:
#Variable Declaration
m_H = 2;    # Gram molecular mass of hydrogen, g
m_O = 32.;   # Gram molecular mass of oxygen, g
k_B = 1.38e-23;  # Boltzmann constant, J/K 
v_avO = 1.;  # For simplicity average speed of oxygen gas molecule is assumed to be unity, m/s
v_avH = 2*v_avO;  # The average speed of hydrrogen gas molecule, m/s
T_O = 300.;  # Temperature of oxygen gas, K

#Calculations
# As v_avO/v_av_H = sqrt(T_O/T_H)*sqrt(m_H/m_O), solving for T_H
T_H = (v_avH/v_avO*sqrt(m_H/m_O)*sqrt(T_O))**2; # Temperature at which the average speed of hydrogen gas molecules is the same as that of oxygen gas molecules, K

#Result
print "Temperature at which the average speed of hydrogen gas molecules is the same as that of oxygen gas molecules at 300 K = %2d"%T_H
Temperature at which the average speed of hydrogen gas molecules is the same as that of oxygen gas molecules at 300 K = 75

Example 3.4, Page 133

In [9]:
#Variable Declaration
v_mp = 1;   # Most probable speed of gas molecules, m/s
dv = 1.01*v_mp-0.99*v_mp;   # Change in most probable speed, m/s
v = v_mp;   # Speed of the gas molecules, m/s

#Calculations
Frac = 4/sqrt(pi)*1/v_mp**3*exp(-v**2/v_mp**2)*v**2*dv; 

#Result
print "The fraction of oxygen gas molecules within one percent of most probable speed = %5.3f"%Frac
#rounding-off error
The fraction of oxygen gas molecules within one percent of most probable speed = 0.017

Example 3.5, Page 134

In [1]:
import math 
#Variable Declaration
n = 5.;  # Number of distinguishable particles which are to be distributed among cells
n1 = [5, 4, 3, 3, 2];   # Possible occupancy of particles in first cell
n2 = [0 ,1, 2, 1, 2];   # Possible occupancy of particles in second cell
n3 = [0 ,0, 0, 1, 1];   # Possible occupancy of particles in third cell
BIG_W = 0.;


print("_____________________________________");
print("n1      n2      n3      5/(n1!n2!n3!)");
print("_____________________________________");
for i in range(5):
    W = math.factorial(n)/(math.factorial(n1[i])*math.factorial(n2[i])*math.factorial(n3[i]));
    if BIG_W < W:
        BIG_W = W;
        ms = [n1[i], n2[i] ,n3[i]];

    print "%d      %d      %d          %d"%(n1[i], n2[i], n3[i], W);

print "_____________________________________";
print "The macrostates of most probable distribution with thermodynamic probability %d are:"%(BIG_W);
print "(%d, %d, %d), (%d, %d, %d) and (%d, %d, %d)"%(ms[0], ms[1], ms[2], ms[1], ms[2], ms[0],ms[2], ms[0], ms[1]);
_____________________________________
n1      n2      n3      5/(n1!n2!n3!)
_____________________________________
5      0      0          1
4      1      0          5
3      2      0          10
3      1      1          20
2      2      1          30
_____________________________________
The macrostates of most probable distribution with thermodynamic probability 30 are:
(2, 2, 1), (2, 1, 2) and (1, 2, 2)

Example 3.6, Page 135

In [11]:
#Variable Declaration
g1 = 4;     # Intrinsic probability of first cell
g2 = 2;     # Intrinsic probability of second cell
k = 2;      # Number of cells 
n = 8;     # Number of distinguishable particles
n1 = 8;     # Number of cells in first compartment
n2 = n - n1;     # Number of cells in second compartment

#Calculations
W = factorial(n)*1/factorial(n1)*1/factorial(n2)*(g1)**n1*(g2)**n2;

#Result
print "The thermodynamic probability of the macrostate (8,0) = %5d"%W
The thermodynamic probability of the macrostate (8,0) = 65536

Example 3.7, Page 135

In [2]:
import math 
#Variable Declaration
def st(val):
    str1 = ""
    if val == 3 :
        str1 = 'aaa';
    elif val == 2 :
        str1 = 'aa'; 
    elif val == 1 :
        str1 = 'a';
    elif val == 0:
        str1 = '0';           
    return str1

g = 3; # Number of cells in first compartment
n = 3; # Number of bosons
p = 3;
r = 1;   # Index for number of rows
print("All possible meaningful arrangements of three particles in three cells are:")
print("__________________________");
print("Cell 1    Cell 2    Cell 3");
print("__________________________");

for i in range(0,g+1):
    for j in range(0,n+1):
        for k in range(0,p+1):
            if (i+j+k == 3):
                print "%4s     %4s      %4s"%(st(i), st(j), st(k));  
    print "__________________________";
All possible meaningful arrangements of three particles in three cells are:
__________________________
Cell 1    Cell 2    Cell 3
__________________________
   0        0       aaa
   0        a        aa
   0       aa         a
   0      aaa         0
__________________________
   a        0        aa
   a        a         a
   a       aa         0
__________________________
  aa        0         a
  aa        a         0
__________________________
 aaa        0         0
__________________________

Example 3.8, Page 136

In [13]:
#Variable Declaration
g1 = 3; # Number of cells in first compartment
g2 = 4; # Number of cells in second compartment
k = 2;  # Number of compartments
n1 = 5; # Number of bosons
n2 = 0; # Number of with no bosons

#Calculations
W_50 = factorial(g1+n1-1)*factorial(g2+n2-1)/(factorial(n1)*factorial(g1-1)*factorial(n2)*factorial(g2-1));

#Result
print "The probability for the macrostate (5,0) is = %2d"%W_50
The probability for the macrostate (5,0) is = 21

Example 3.11, Page 138

In [25]:
#Variable Declaration
r = 1.86e-10;  # Radius of Na, angstrom
m = 9.1e-31;  # Mass of electron,in kg
h = 6.62e-34;  # Planck's constant, J-s
N = 2;  # Number of free electrons in a unit cell of Na

#Calculations
a = 4*r/sqrt(3);  # Volume of Na, m
V = a**3;  # Volume of the unit cell of Na, meter cube
E = h**2/(2*m)*(3*N/(8*pi*V))**(2./3);

#Result
print "The fermi energy of the Na at absolute zero is = %4.2e J"%E
#rounding-off error
The fermi energy of the Na at absolute zero is = 5.02e-19 J

Example 3.12, Page 13

In [26]:
#Variable Declaration
m = 9.1e-31;  # mass of electron, kg
h = 6.62e-34;  # Planck's constant, J-s
V = 108/10.5*1e-06;  # Volume of 1 gm mole of silver, metre-cube
N = 6.023e+023;    # Avogadro's number

#Calculations
E_F = h**2/(2*m)*(3*N/(8*pi*V))**(2./3);    # Fermi energy at absolute zero, J

#Result
print "The fermi energy of the silver at absolute zero = %4.2e J"%E_F
#rounding-off error
The fermi energy of the silver at absolute zero = 8.80e-19 J

Example 3.13, Page 13

In [46]:
#Variable Declaration
pbe = 24.2e22     #electrons/cm^3
pcs = 0.91e22      #electrons/cm^3
efbe = 14.44         #ev

#Calculations
Efcs = efbe*((pcs/pbe)**(2./3))

#Result
print "Fermi energy of free electrons in cesium = %.3f eV"%Efcs
#rounding-off error
Fermi energy of free electrons in cesium = 1.621 eV

Example 3.14, Page 140

In [47]:
#Variable Declaration
e = 1.6e-019;    # Energy equivalent of 1 eV, J/eV
m = 9.1e-31;  # Mass of the elecron, kg 
h = 6.63e-34;    # Planck's constant, Js
EF = 4.72*e;  # Fermi energy of free electrons in Li, J

#Calculations
rho = 8*pi/3*(2*m*EF/h**2)**(3./2);    # Electron density at absolute zero, electrons/metre-cube

#Result
print "The electron density in lithium at absolute zero = %4.2e electrons/metre-cube"%rho
The electron density in lithium at absolute zero = 4.63e+28 electrons/metre-cube

Example 3.15, Page 140

In [49]:
#Variable Declaration
e = 1.6e-019;    # Energy equivalent of 1 eV, J/eV
k_B = 1.38e-023;    # Boltzmann constant, J/K
f_E = 0.01;  # Probability that a state with energy 0.5 eV above the Fermi energy is occupied by an electron, eV 
delta_E = 0.5;    # Energy difference (E-Ef)of fermi energy, eV

#Calculations
# Since f_E = 1/(exp((E-Ef)/(k_B*T))+1), solvinf for T 
T = delta_E/(log((1-f_E)/f_E)*k_B/e);  # Temperature at which the level above the fermi level is occupied by the electron, K

#Result
print "The temperature at which the level above the fermi level is occupied by the electron = %4d K"%ceil(T)
#rounding-off error
The temperature at which the level above the fermi level is occupied by the electron = 1262 K