summaryrefslogtreecommitdiff
path: root/Engineering_Physics_by_Shyam_Rajeev/Chapter15.ipynb
blob: 365987ffd3dee4d0567fd8e0a164ce89696ebcda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
{
 "metadata": {
  "name": "",
  "signature": "sha256:42ca728e6260f85c33ceec306bfa76eadd9931a7ca67b2244aa9a2e681dff896"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "15: Statistical mechanics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 15.1, Page number 341"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "import fractions\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "n = 10;       #number of identical coins\n",
      "r1 = 10;       #number of heads in 1st case\n",
      "r2 = 5;        #number of heads in 2nd case\n",
      "r3 = 3;        #number of heads in 3rd case\n",
      "\n",
      "#Calculation\n",
      "P10_0 = math.factorial(n)/(math.factorial(r1)*math.factorial(n-r1)*(2**n));        #probability of getting all heads\n",
      "P10_0 = fractions.Fraction(P10_0);        #probability in fraction\n",
      "P5_5 = math.factorial(n)/(math.factorial(r2)*math.factorial(n-r2)*(2**n));         #probability of getting 5 heads and 5 tails\n",
      "P5_5 = fractions.Fraction(P5_5);          #probability in fraction\n",
      "P3_7 = math.factorial(n)/(math.factorial(r3)*math.factorial(n-r3)*(2**n));         #probability of getting 3 heads and 7 tails\n",
      "P3_7 = fractions.Fraction(P3_7);          #probability in fraction\n",
      "Pmax = math.factorial(n)/(((math.factorial(n/2))**2)*(2**n))            #most probable combination\n",
      "Pmax = fractions.Fraction(Pmax);          #probability in fraction\n",
      "Pmin = 1/(2**n);              #least probable combination\n",
      "Pmin = fractions.Fraction(Pmin);            #probability in fraction\n",
      "\n",
      "#Result\n",
      "print \"probability of getting all heads is\",P10_0\n",
      "print \"probability of getting 5 heads and 5 tails is\",P5_5\n",
      "print \"probability of getting 3 heads and 7 tails is\",P3_7\n",
      "print \"most probable combination is\",Pmax\n",
      "print \"least probable combination is\",Pmin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "probability of getting all heads is 1/1024\n",
        "probability of getting 5 heads and 5 tails is 63/256\n",
        "probability of getting 3 heads and 7 tails is 15/128\n",
        "most probable combination is 63/256\n",
        "least probable combination is 1/1024\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 15.2, Page number 342"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "import fractions\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "n = 3;          #number of particles\n",
      "N = 2;          #number of compartments\n",
      "ms = 4;         #number of macrostates\n",
      "n1_03 = 0;        #value of n1 for (0,3)\n",
      "n2_03 = 3;        #value of n2 for (0,3)\n",
      "n1_12 = 1;        #value of n1 for (1,2)\n",
      "n2_12 = 2;        #value of n2 for (1,2)\n",
      "n1_21 = 2;        #value of n1 for (2,1)\n",
      "n2_21 = 1;        #value of n2 for (2,1)\n",
      "n1_30 = 3;        #value of n1 for (3,0)\n",
      "n2_30 = 0;        #value of n2 for (3,0)\n",
      "\n",
      "#Calculation\n",
      "#the macrostates are (n1,n2) = [(0,3),(1,2),(2,1),(3,0)]\n",
      "ms_03 = math.factorial(n)/(math.factorial(n1_03)*math.factorial(n2_03));          #number of microstates in the macrostate (0,3)\n",
      "mis_03 = \"(0,xyz)\";                   #microstates in the macrostate (0,3)\n",
      "ms_12 = math.factorial(n)/(math.factorial(n1_12)*math.factorial(n2_12));          #number of microstates in the macrostate (1,2)\n",
      "mis_12 = \"[(x,yz),(y,zx),(z,xy)]\";             #microstates in the macrostate (1,2)\n",
      "ms_21 = math.factorial(n)/(math.factorial(n1_21)*math.factorial(n2_21));          #number of microstates in the macrostate (2,1)\n",
      "mis_21 = \"[(xy,z),(yz,x),(zx,y)]\";             #microstates in the macrostate (2,1)\n",
      "ms_30 = math.factorial(n)/(math.factorial(n1_30)*math.factorial(n2_30));          #number of microstates in the macrostate (3,0)\n",
      "mis_30 = \"(xyz,0)\";                   #microstates in the macrostate (3,0)\n",
      "tms = N**n;            #total number of microstates\n",
      "mis = \"[(0,xxx),(x,xx),(xx,x),(xxx,0)]\";        #the microstates when particles are indistinguishable\n",
      "\n",
      "#Result\n",
      "print \"number of microstates in the macrostate (0,3) is\",ms_03,\"that is\",mis_03\n",
      "print \"number of microstates in the macrostate (1,2) is\",ms_12,\"that is\",mis_12\n",
      "print \"number of microstates in the macrostate (2,1) is\",ms_21,\"that is\",mis_21\n",
      "print \"number of microstates in the macrostate (3,0) is\",ms_30,\"that is\",mis_30\n",
      "print \"total number of microstates is\",tms\n",
      "print \"the microstates when particles are indistinguishable are\",mis"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "number of microstates in the macrostate (0,3) is 1.0 that is (0,xyz)\n",
        "number of microstates in the macrostate (1,2) is 3.0 that is [(x,yz),(y,zx),(z,xy)]\n",
        "number of microstates in the macrostate (2,1) is 3.0 that is [(xy,z),(yz,x),(zx,y)]\n",
        "number of microstates in the macrostate (3,0) is 1.0 that is (xyz,0)\n",
        "total number of microstates is 8\n",
        "the microstates when particles are indistinguishable are [(0,xxx),(x,xx),(xx,x),(xxx,0)]\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 15.3, Page number 343"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 4;       #1st group of particles\n",
      "n2 = 2;       #2nd group of particles  \n",
      "n3 = 8;       #3rd group of particles\n",
      "n4 = 6;       #4th group of particles \n",
      "n5 = 5;       #5th group of particles\n",
      "v1 = 1;       #speed of 1st group of particles\n",
      "v2 = 2;       #speed of 2nd group of particles\n",
      "v3 = 3;       #speed of 3rd group of particles\n",
      "v4 = 4;       #speed of 4th group of particles  \n",
      "v5 = 5;       #speed of 5th group of particles\n",
      "\n",
      "#Calculation\n",
      "vbar = ((n1*v1)+(n2*v2)+(n3*v3)+(n4*v4)+(n5*v5))/(n1+n2+n3+n4+n5);         #average speed(m/sec)\n",
      "vsquarebar = ((v1*(n1**2))+(v2*(n2**2))+(v3*(n3**2))+(v4*(n4**2))+(v5*(n5**2)))/(n1+n2+n3+n4+n5);        #mean square speed\n",
      "rms = math.sqrt(vsquarebar);                #root mean square speed(m/sec)\n",
      "rms = math.ceil(rms*10**3)/10**3;   #rounding off to 3 decimals\n",
      "\n",
      "#Result\n",
      "print \"average speed is\",vbar,\"m/sec\"\n",
      "print \"root mean square speed is\",rms,\"m/sec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "average speed is 3.24 m/sec\n",
        "root mean square speed is 4.405 m/sec\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 15.4, Page number 344"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "t = 27;         #temperature(C)\n",
      "M = 14;         #mass of nitrogen(gm)\n",
      "kb = 1.38*10**-23;     #boltzmann constant\n",
      "a = 6.02*10**23;       #avagadro number  \n",
      "\n",
      "#Calculation\n",
      "T = t+273;      #temperature(K) \n",
      "M = M*10**-3;       #mass of nitrogen(kg)\n",
      "vmp = math.sqrt(2*kb*T*a/M);             #most probable speed of nitrogen(m/sec)\n",
      "vmp = math.ceil(vmp*10)/10;   #rounding off to 1 decimal\n",
      "\n",
      "#Result\n",
      "print \"most probable speed of nitrogen is\",vmp,\"m/sec\"\n",
      "print \"answer given in the book is wrong\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "most probable speed of nitrogen is 596.7 m/sec\n",
        "answer given in the book is wrong\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 15.5, Page number 344"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "t = 37;       #normal temperature of human body(C)\n",
      "b = 2.898*10**-3;      #constant of proportionality(mK)\n",
      "\n",
      "#Calculation\n",
      "T = t+273;         #normal temperature of human body(K)\n",
      "lamda_m = b/T;      #wavelength for maximum energy radiation(m)\n",
      "lamda_m = lamda_m*10**10;         #wavelength for maximum energy radiation(angstrom)\n",
      "\n",
      "#Result\n",
      "print \"wavelength for maximum energy radiation is\",int(lamda_m),\"angstrom\"\n",
      "print \"answer given in the book is wrong\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength for maximum energy radiation is 93483 angstrom\n",
        "answer given in the book is wrong\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 15.6, Page number 344"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "kb = 1.38*10**-23;     #boltzmann constant\n",
      "thetaE = 230;        #einstein's temperature(K)\n",
      "h = 6.63*10**-34;          #planck's constant(m**2 kg/s)\n",
      "\n",
      "#Calculation\n",
      "newE = kb*thetaE/h;         #einstein's frequency(per sec)\n",
      "\n",
      "#Result\n",
      "print \"einstein's frequency is\",round(newE/1e+12,2),\"*10**12 per sec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "einstein's frequency is 4.79 *10**12 per sec\n"
       ]
      }
     ],
     "prompt_number": 47
    }
   ],
   "metadata": {}
  }
 ]
}