# Chapter 14: Ensemble and Molecular Partition Function¶

## Example Problem 14.1, Page Number 332¶

In :
#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
l = 0.01           #Box length, m
n1,n2 = 2,1        #Energy levels states
m = 5.31e-26       #mass of oxygen molecule, kg

#Calculations
dE = (n1+n2)*h**2/(8*m*l**2)
dEcm = dE/(h*c*1e2)
#Results
print 'Difference in energy levels is %3.2e J or %3.2e 1/cm'%(dE,dEcm)

Difference in energy levels is 3.10e-38 J or 1.56e-15


## Example Problem 14.2, Page Number 333¶

In :
from math import pi, sqrt

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
v = 1.0            #Volume, L
T = 298.0          #Temeprature of Ar, K
m = 6.63e-26       #Mass of Argon molecule, kg

#Calculations
GAMA = h/sqrt(2*pi*m*k*T)
v = v*1e-3
qT3D = v/GAMA**3

#Results
print 'Thermal wave length is %3.2e m and\nTranslational partition function is %3.2e'%(GAMA,qT3D)

Thermal wave length is 1.60e-11 m and
Translational partition function is 2.44e+29


## Example Problem 14.4, Page Number 338¶

In :
#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s

J = 4              #Rotational energy level
B = 8.46           #Spectrum, 1/cm

#Calculations
T = (2*J+1)**2*h*c*100*B/(2*k)
#Results
print 'Spectrum will be observed at %4.0f K'%(T)

Spectrum will be observed at  494 K


## Example Problem 14.5, Page Number 340¶

In :
from math import exp

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s

B = 60.589         #Spectrum for H2, 1/cm
T = 1000           #Temperture of Hydrogen, K
#Calculations
qR = k*T/(2*h*c*100*B)
qRs = 0.0
#for J in range(101):
#    print J
#    if (J%2 == 0):
#        qRs = qRs + (2*J+1)*exp(-h*c*100*B*J*(J+1)/(k*T)
#    else:
#        qRs = qRs + 3*(2*J+1)*exp(-h*c*100*B*J*(J+1)/(k*T))
#print qRs/4

#Results
print 'Rotation partition function of H2 at %4.0f is %4.3f'%(T,qR)

Rotation partition function of H2 at 1000 is 5.729


## Example Problem 14.6, Page Number 341¶

In :
#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
B = 0.0374         #Spectrum for H2, 1/cm
T = 100.0          #Temperture of Hydrogen, K
sigma = 2.

#Calculations
ThetaR = h*c*100*B/k
qR = T/(sigma*ThetaR)

#Results
print 'Rotation partition function of H2 at %4.0f K is %4.3f'%(T,qR)

Rotation partition function of H2 at  100 K is 928.121


## Example Problem 14.7, Page Number 342¶

In :
from math import pi, sqrt

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
Ba = 1.48                        #Spectrum for OCS, 1/cm
Bb = [2.84,0.191,0.179]          #Spectrum for ONCI, 1/cm
Bc = [9.40,1.29,1.13]            #Spectrum for CH2O, 1/cm
T = 298.0                        #Temperture of Hydrogen, K
sigmab = 1
sigmac = 2

#Calculations
qRa = k*T/(h*c*100*Ba)
qRb = (sqrt(pi)/sigmab)*(k*T/(h*c*100))**(3./2)*sqrt(1/Bb)*sqrt(1/Bb)*sqrt(1/Bb)
qRc = (sqrt(pi)/sigmac)*(k*T/(h*c*100))**(3./2)*sqrt(1/Bc)*sqrt(1/Bc)*sqrt(1/Bc)

#Results
print 'Rotation partition function for OCS, ONCI, CH2O at %4.0f K are %4.0f, %4.0f, and %4.0f respectively'%(T,qRa,qRb,qRc)

Rotation partition function for OCS, ONCI, CH2O at  298 K are  140, 16926, and  712 respectively


## Example Problem 14.8, Page Number 344¶

In :
from math import pi, exp

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s

Ba = 1.48                        #Frequency for OCS, 1/cm
Bb = [2.84,0.191,0.179]          #Frequency for ONCI, 1/cm
Bc = [9.40,1.29,1.13]            #Frequency for CH2O, 1/cm
T298 = 298.0                     #Temperture of Hydrogen, K
T1000 = 1000                     #Temperture of Hydrogen, K
nubar  =  208

#Calculations
qv298 = 1./(1.-exp(-h*c*100*nubar/(k*T298)))
qv1000 = 1./(1.-exp(-h*c*100*nubar/(k*T1000)))

#Results
print 'Vibrational partition function for I2 at %4d and %4d are %4.2f K and %4.2f respectively'%(T298, T1000,qv298, qv1000)

Vibrational partition function for I2 at  298 and 1000 are 1.58 K and 3.86 respectively


## Example Problem 14.9, Page Number 346¶

In :
from math import exp

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s

T = 298            #Temeprature, K
nubar = [450, 945, 1100]   #Vibrational mode frequencies for OClO, 1/cm

#Calculations
Qv = 1.
for i in nubar:
qv = 1./(1.-exp(-h*c*100*i/(k*T)))
print 'At %4.0f 1/cm the q = %4.3f'%(i,qv)
Qv = Qv*qv
#Results
print 'Total Vibrational partition function for OClO at %4.1f K is %4.3f'%(T, Qv)

At  450 1/cm the q = 1.128
At  945 1/cm the q = 1.010
At 1100 1/cm the q = 1.005
Total Vibrational partition function for OClO at 298.0 K is 1.146 respectively


## Example Problem 14.10, Page Number 348¶

In :
from math import exp

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
T = 298            #Temeprature, K
nubar = 917        #Vibrational mode frequencies for F2, 1/cm

#Calculations
ThetaV = h*c*100*nubar/k
Th = 10*ThetaV
qv = 1/(1.-exp(-ThetaV/Th))

#Results
print 'Vibrational partition function for F2 at %4.1f K is %4.3f'%(T, qv)

Vibrational partition function for F2 at 298.0 K is 10.508


## Example Problem 14.11, Page Number 348¶

In :
from math import exp

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
T = 1000           #Temeprature, K
nubar = [1388, 667.4,667.4,2349]   #Vibrational mode frequencies for CO2, 1/cm

#Calculations
Qv = 1.
for i in nubar:
qv = 1./(1.-exp(-h*c*100*i/(k*T)))
print 'At %4.0f 1/cm the q = %4.3f'%(i,qv)
Qv = Qv*qv
#Results
print 'Total Vibrational partition function for OClO at %4.1f K is %4.3f'%(T, Qv)

At 1388 1/cm the q = 1.157
At  667 1/cm the q = 1.619
At  667 1/cm the q = 1.619
At 2349 1/cm the q = 1.035
Total Vibrational partition function for OClO at 1000.0 K is 3.139


## Example Problem 14.12, Page Number 352¶

In :
from math import exp

#Variable Declarations
h = 6.626e-34      #Planks constant, J.s
k = 1.38e-23       #Boltzman constant, J/K
c = 3.0e8          #speed of light, m/s
T = 298.           #Temeprature, K
n = [0,1,2,3,4,5,6,7,8]   #Energy levels
E0 = [0,137.38,323.46,552.96,2112.28,2153.21,2220.11,2311.36,2424.78]      #Energies, 1/cm
g0 = [4,6,8,10,2,4,6,8,10]

#Calculations
qE = 0.0
for i in range(9):
a =g0[i]*exp(-h*c*100*E0[i]/(k*T))
qE = qE + a

#Results
print 'Electronic partition function for F2 at %4.1f K is %4.2f'%(T, qE)

Electronic partition function for F2 at 298.0 K is 9.45