diff options
author | Jovina Dsouza | 2014-06-18 12:43:07 +0530 |
---|---|---|
committer | Jovina Dsouza | 2014-06-18 12:43:07 +0530 |
commit | 206d0358703aa05d5d7315900fe1d054c2817ddc (patch) | |
tree | f2403e29f3aded0caf7a2434ea50dd507f6545e2 /Thermodynamics:_A_Core_Course/CH7.ipynb | |
parent | c6f0d6aeb95beaf41e4b679e78bb42c4ffe45a40 (diff) | |
download | Python-Textbook-Companions-206d0358703aa05d5d7315900fe1d054c2817ddc.tar.gz Python-Textbook-Companions-206d0358703aa05d5d7315900fe1d054c2817ddc.tar.bz2 Python-Textbook-Companions-206d0358703aa05d5d7315900fe1d054c2817ddc.zip |
adding book
Diffstat (limited to 'Thermodynamics:_A_Core_Course/CH7.ipynb')
-rw-r--r-- | Thermodynamics:_A_Core_Course/CH7.ipynb | 603 |
1 files changed, 603 insertions, 0 deletions
diff --git a/Thermodynamics:_A_Core_Course/CH7.ipynb b/Thermodynamics:_A_Core_Course/CH7.ipynb new file mode 100644 index 00000000..71226c1e --- /dev/null +++ b/Thermodynamics:_A_Core_Course/CH7.ipynb @@ -0,0 +1,603 @@ +{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 7:Statistical Thermodynamics"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.1,Page number:193"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.1\n",
+ "\n",
+ "#To find the number of ways of distributing N particles\n",
+ "#Variable declaration\n",
+ "N=20 \t\t\t\t#no, of particles\n",
+ "N1=4 \t\t\t\t#no. of particles in E1 energy level\n",
+ "N2=4 \t\t\t\t#no. of particles in E2 energy level\n",
+ "N3=6 \t\t\t\t#no. of particles in E3 energy level\n",
+ "N4=3 \t\t\t\t#no. of particles in E4 energy level\n",
+ "N5=3 \t\t\t\t#no. of particles in E5 energy level\n",
+ "import math\n",
+ "#Calculation\n",
+ "\t\n",
+ "Nf=math.factorial(N) \n",
+ "N1f=math.factorial(N1) \n",
+ "N2f=math.factorial(N2) \n",
+ "N3f=math.factorial(N3) \n",
+ "N4f=math.factorial(N4) \n",
+ "N5f=math.factorial(N5) \n",
+ "n=N1f*N2f*N3f*N4f*N5f \n",
+ "W=Nf/n \t\t\t#no. of ways of distributing\n",
+ "#Result\n",
+ "print\"The no. of ways of distributing the particles is\",W"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The no. of ways of distributing the particles is 162954792000\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.2,Page number:194"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.2\n",
+ "#To find the fraction of molecules present in vibrational level\n",
+ "#Variable declaration\n",
+ "T=298.0 \t\t\t#Temperature [K]\n",
+ "v=6.5*10**13 \t\t#Frequency in [sec-1]\n",
+ "\t#Consider zero point energy = 0.\n",
+ "h=6.627*10**-34 \t#planck's constant[J.s]\n",
+ "k=1.381*10**-23 \t#Boltzmann constant \n",
+ "N=1.0 \t\t\t#Since N=summation(gj*exp(-Ej/kT))\n",
+ "#Calculation\n",
+ "\n",
+ "E1=h*v \t\t\t#for energy level 1[J]\n",
+ "E2=2*h*v \t\t#for energy level 2[J]\n",
+ "x=k*T \n",
+ "g1=1.0 \n",
+ "g2=1.0 \n",
+ "import math\n",
+ "N1=(g1*math.exp(-E1/x)) #molecules present in energy level 1\n",
+ "N2=(g2*math.exp(-E2/x)) #molecules present in energy level 2\n",
+ "n1=N1/N \t\t#fraction of molecules present in energy level 1\n",
+ "n2=N2/N \t\t#fraction of molecules present in energy level 2\n",
+ "#Result\n",
+ "print\"The fraction of molecule s present in energy level 1 is\",'{0:.7f}'.format(round(n1,7)) \n",
+ "\n",
+ "\n",
+ "print\"The fraction of molecules present in energy level 2 is\",round(n2,10) \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The fraction of molecule s present in energy level 1 is 0.0000285\n",
+ "The fraction of molecules present in energy level 2 is 8e-10\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.3,Page number:194"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.3\n",
+ "#To find the ratio of no. of particle per state for two states separated by an energy dE\n",
+ "#Variable declaration\n",
+ "dE=4.3*10**-20 \t\t\t#difference in energy levels[J]\n",
+ "T1=0.000001 \t\t\t#Initial Temperature[K](approximately zero , needed for \t\t\t\texecution)\n",
+ "T2=300 \t\t\t\t#Final Temperature[K]\n",
+ "k=1.381*10**-23 \t\t#Boltzmann constant [J/K]\n",
+ "import math\n",
+ "#Calculation\n",
+ "\t\n",
+ "x1=k*T1 \n",
+ "r1=math.exp(-dE/x1) \n",
+ "x2=k*T2 \n",
+ "r2=math.exp(-dE/x2) \n",
+ "#Result\n",
+ "print\"The ratio of no. of particles per state at 0K is\",r1 \n",
+ "print\"The ratio of no. of particles per state at 300K is\",round(r2,6) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The ratio of no. of particles per state at 0K is 0.0\n",
+ "The ratio of no. of particles per state at 300K is 3.1e-05\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.4,Page number:195"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.4\n",
+ "#To find the no. of atoms in first-excited singlet state\n",
+ "#Variable declaration\n",
+ "T1=273.0 \t\t\t\t#[K]\n",
+ "T2=14273.0 \t\t\t#[K]\n",
+ "E1=-13.6 \t\t\t#Energy of ground state [eV]\n",
+ "k=8.617*10.0**-5.0 \t\t\t#Boltzmann constant[eV/K]\n",
+ "g2=8.0 \t\t\t\t#total no. of states with energy E2\n",
+ "g1=2.0 \t\t\t\t#total no. of states with energy E1\n",
+ "#Calculation\n",
+ "import math\n",
+ "\t\n",
+ "E2=E1/(2.0**2) \t\t#Energy for n=2 (i.e.E2=E1/n2)\n",
+ "x1=k*T1 \n",
+ "r1=(g2/g1)*math.exp(-(E2-E1)/x1) \n",
+ "x2=k*T2 \n",
+ "r2=(g2/g1)*math.exp(-(E2-E1)/x2) \n",
+ "#Result\n",
+ "print\"The fraction of atoms present in level n=2 at 273K is\", round(r1,190) \n",
+ "print\"Therefore total 3*10**25 atoms we say that all are present at ground state\" \n",
+ "print\"\\n\\nThe fraction of atoms present in level n=2 at 14273 is\",round(r2,3) \n",
+ "x=r2*3.0*10**25.0 \n",
+ "print\"Therefore no. of atoms in level n=2 is\",x \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The fraction of atoms present in level n=2 at 273K is 1.97e-188\n",
+ "Therefore total 3*10**25 atoms we say that all are present at ground state\n",
+ "\n",
+ "\n",
+ "The fraction of atoms present in level n=2 at 14273 is 0.001\n",
+ "Therefore no. of atoms in level n=2 is 3.0021673634e+22\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.5,Page number:195"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.5\n",
+ "#To find the Temperature at this condition \n",
+ "\n",
+ "#Variable declaration\n",
+ "r1=0.001 \t\t\t#the population of the states at a higher energy to that at a \t\t\t\tlower energy \n",
+ "dE=8*10**-20 \t\t\t#The difference in energy[J]\n",
+ "k=1.381*10**-23 \t\t\t#Boltzmann constant [J/K]\n",
+ "\n",
+ "#Calculation\n",
+ "\n",
+ "x=k*math.log(r1) \n",
+ "T=-dE/x #[K]\n",
+ "#Result\n",
+ "print\"The Temperature at this condition is\",round(T,1),\"K\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Temperature at this condition is 838.6 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.6,Page number:196"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.6\n",
+ "#To find the entropy of the system\n",
+ "\n",
+ "#section(1)\n",
+ "#Variable declaration\n",
+ "#The energy levels are not degenerate \n",
+ "w=1 \t\t\t#no. of ways of distributing the molecules\n",
+ "k=1.381*10**-23 \t#Boltzmann constant[J/K]\n",
+ "#Calculation\n",
+ "import math\n",
+ "\t\n",
+ "S1=k*math.log(w) \t\t#Entropy of system at 0K\n",
+ "print\"The Entropy of System at 0K and non-degenerate eng level is\",S1,\"J/K/mol\"\n",
+ "\n",
+ "#section(2)\n",
+ "#Here the energy levels are degenerate\n",
+ "n=2 \n",
+ "R=8.314 #Universal gas constant[J/K/mol]\n",
+ "\n",
+ "#To find the entropy of the system\n",
+ "#S=kmath.log(n**N)=>S=R*math.log(n)\n",
+ "S2=R*math.log(n) #Entropy of the system[J/K/mol]\n",
+ "#Result\n",
+ "print\"\\nThe Entropy of system at 0K and degenerete eng level is\",round(S2,2),\"J/K/mol\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Entropy of System at 0K and non-degenerate eng level is 0.0 J/K/mol\n",
+ "\n",
+ "The Entropy of system at 0K and degenerete eng level is 5.76 J/K/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.9,Page number:202"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.9\n",
+ "\n",
+ "#To find the Transitional partition function of an oxygen molecule confined in a 1-litre \tvessel at 300K\n",
+ "#Variable declaration\n",
+ "V=0.001 \t\t\t#Volume of vessel[m3]\n",
+ "T=300 \t\t\t\t#Temperature [K]\n",
+ "k=1.381*10**-23 \t\t#Boltzmann constant[J/K]\n",
+ "mol_wt=32 \t\t\t#molecular mass of oxygen molecule\n",
+ "h=6.626*10**-34 \t\t#planck's constant[J.s}\n",
+ "\n",
+ "\n",
+ "#Calculation\n",
+ "\t\n",
+ "m=32*1.66*(10**-27) \t\t#mass of oxygen molecule[Kg]\n",
+ "x=((2*3.14*m*k*T)**(3.0/2.0))*V \n",
+ "y=h**3 \n",
+ "zt=x/y \t\t\t\t#Transitional partition function of an oxygen molecule\n",
+ "#Result\n",
+ "print\"The Transitional partition function of an oxygen molecule confined in a 1-litre vessel at 300K is\",zt\n",
+ "print\"Wrongly calculated in book as 5.328*10^33\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Transitional partition function of an oxygen molecule confined in a 1-litre vessel at 300K is 1.76621948031e+29\n",
+ "Wrongly calculated in book as 5.328*10^33\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.12,Page number:204"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.12\n",
+ "#To find the Entropy of argon at 273K and 1 atmospheric pressure\n",
+ "#Variable declaration\n",
+ "R=1.99 \t\t\t#Universal gas constant [cal/K]\n",
+ "e=2.718 \n",
+ "V=22414 \t\t#volume[cm3]\n",
+ "L=6.023*10**23 \n",
+ "h=6.626*10**-27 \t#Planck's constant [erg.sec]\n",
+ "m=6.63*10**-23 \t\t#mass[gm]\n",
+ "k=1.381*10**-16 \t#Boltzmann constant[erg/K]\n",
+ "T=273.2 \t\t#Temperature[K]\n",
+ "import math\n",
+ "#Calculation\n",
+ "\t\n",
+ "x=V*(e**2.5) \n",
+ "y=L*(h**3) \n",
+ "z=(2*3.14*m*k*T)**1.5 \n",
+ "S=R*math.log(x*z/y) #Entropy [cal/degree/mol]\n",
+ "#Result\n",
+ "print\"The Entropy of argon at 273K and 1 atm is\",round(S,1),\"cal/degree/mol\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Entropy of argon at 273K and 1 atm is 36.6 cal/degree/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.14,Page number:207"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.14\n",
+ "\n",
+ "#To find the rotational entropy and free energy for O2 gas\n",
+ "#Variable declaration\n",
+ "T=298 \t\t\t\t#Temperature[K]\n",
+ "I=1.9373*10**-46 \t\t#moment of inertia of O2 gas [Kg/m2]\n",
+ "h=6.626*10**-34 \t\t\t#Planck's constant[J.s]\n",
+ "k=1.381*10**-23 \t\t\t#Boltzmann constant[J/K]\n",
+ "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
+ "u=2 \t\t\t\t#Homonuclear diatomic molecule\n",
+ "import math\n",
+ "#Calculation\n",
+ "\t\n",
+ "Sr=R+R*math.log(8*3.14*3.14*I*k*T/(u*h*h)) #[J/K/mol]\n",
+ "Gr=-R*0.001*T*math.log(8*3.14*3.14*I*k*T/(u*h*h)) #[KJ/mol]\n",
+ "#Result\n",
+ "print\"The rotational entropy for O2 gas is\",round(Sr,3),\"J/K/mol\"\n",
+ "print\"The rotational free energy for O2 gas is\",round(Gr,3),\"KJ/mol\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The rotational entropy for O2 gas is 43.826 J/K/mol\n",
+ "The rotational free energy for O2 gas is -10.583 KJ/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.15,Page number:208"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.15\n",
+ "#To find the vibrational contribution to the entropy of F2 at 298K\n",
+ "#Variable declaration\n",
+ "T=298 \t\t\t\t#Temperature[K]\n",
+ "v=892.1*3*10**10 \t\t#frequency[sec-1]\n",
+ "h=6.626*10**-27 \t\t#Planck's constant [J.s]\n",
+ "k=1.381*10**-16 \t\t#Boltzmann constant[erg/K]\n",
+ "e=2.718 \n",
+ "R=1.998 \t\t\t#Universal gas constant[cal/K]\n",
+ "\t\n",
+ "#Calculation\n",
+ "import math\n",
+ "x=h*v/(k*T) \n",
+ "a=R*x*e**-x/(1-e**-x) \t\t#a=E-Eo/T\n",
+ "b=R*math.log(1-e**-x) \t\t#b=G-Eo/T\n",
+ "S=a-b \t\t\t\t#[cal/deg]\n",
+ "#Result\n",
+ "print\"The vibrational contribution to the entropy of F2 is\",round(S,4),\"cal/deg APPROX\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The vibrational contribution to the entropy of F2 is 0.1445 cal/deg APPROX\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.16,Page number:211"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.16\n",
+ "#To find the equilibrium constant\n",
+ "#Variable declaration\n",
+ "T=1273 \t\t\t\t#Temperature[K]\n",
+ "h=6.26*10**-27 \t\t\t#Planck's constant[J.s]\n",
+ "k=1.381*10**-16 \t\t\t#Boltzmann constant[erg/K]\n",
+ "T=1000 \t\t\t\t#Temperature[degrees]\n",
+ "m=3.82*10**-23 \t\t\t#mass of Na [gm]\n",
+ "I=(1.91*10**-23)*(3.078*10**-8)**2 \t#moment of inertia[gm.cm2]\n",
+ "dE=0.73*1.602*10**-12 \t\t\t#[erg]\n",
+ "v=159.23*(3*10**10)\t \t\t#frequency [s-1]\n",
+ "R=82 \t\t\t\t\t#universal gas constant[cm3.atm/deg]\n",
+ "u=2 \t\t\t\t\t#symmetry number\n",
+ "L=6.023*10**23 \t\t\t\t#avogadro's number\n",
+ "import math\n",
+ "#Calculation\n",
+ "\t\n",
+ "p=((3.14*m*k*T)**1.5)/h/h/h \n",
+ "s=R*u*h*h/L/8/3.14/3.14/I/k \n",
+ "q=1-(math.exp(-h*v/k/T)) \n",
+ "r=math.exp(-dE/k/T) \n",
+ "Kp=p*s*q*r \t\t\t\t#Equilibrium constant \n",
+ "#Result\n",
+ "print\"The equilibrium constant is\",round(Kp,3) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The equilibrium constant is 0.608\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.17,Page number:212"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#example 7.17\n",
+ "#To find the equilibrium constant for isotopic exchange reaction\n",
+ "#Variable declaration\n",
+ "T=298.0 #Temperature[K]\n",
+ "m1=32.0 \n",
+ "m2=36.0 \n",
+ "m3=34.0 \n",
+ "u1=8.0 \n",
+ "u2=9.0 \n",
+ "u3=16.0*18.0/34.0 \n",
+ "z1=0.99924 \n",
+ "z2=0.99951 \n",
+ "z3=0.99940 \n",
+ "h=6.26*10**-27 #Planck's constant[J.s]\n",
+ "c=3.0*10**10 #Speed of light[m/s]\n",
+ "k=1.38*10**-16 #Boltzman's constant[erg/K]\n",
+ "vo1=1535.8 #vibration frequency of 16O18O [cm-1]\n",
+ "vo2=1580.4 #vibration frequency of 16O2 [cm-1]\n",
+ "vo3=1490.0 #vibration frequency of 18O2 [cm-1]\n",
+ "dE=0.5*h*c*(2*vo1-vo2-vo3) #[erg]\n",
+ "r=dE/k/T \n",
+ "#Calculation\n",
+ "import math\n",
+ "\n",
+ "a=m3**3/m2**1.5/m1**1.5 \n",
+ "b=(u3**2)*4/u2/u1 \n",
+ "c=z3**2/z2/z1 \n",
+ "Kp=a*b*c*math.exp(-r) \n",
+ "#Result\n",
+ "print\"The value of equilibrium constant for isotopic exchange reaction is\",round(Kp,3) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of equilibrium constant for isotopic exchange reaction is 3.996\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |