summaryrefslogtreecommitdiff
path: root/Modern_Physics_for_Scientists_and_Engineers/ch7.ipynb
blob: 05b43549dcc2ceb0c988346cafdffc74081376c7 (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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
{
 "metadata": {
  "name": "",
  "signature": "sha256:ac0a66c98f2095bc3ebf2778dcd991b562e3ba004b2f051bfaa777d8205d2aed"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7: The Hydrogen Atom"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2, Page 248"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import scipy\n",
      "import math\n",
      "from scipy.integrate import quad\n",
      "\n",
      "#Variable declaration\n",
      "a0 = 1;    # For simplicity assume Bohr radius to be unity, m\n",
      "\n",
      "#Calculations&Results\n",
      "x = lambda r:r**4*math.exp(-r/a0)\n",
      "int1,err = scipy.integrate.quad(x,0,15)\n",
      "y = lambda t:math.sin(t)**3\n",
      "int2,err = scipy.integrate.quad(y,0,math.pi)\n",
      "z = lambda p:p**0\n",
      "int3,err = scipy.integrate.quad(z,0,2*math.pi)\n",
      "NE = 1./(64*math.pi*a0**5)*int1*int2*int3;\n",
      "print \"NE = %.f\"%NE\n",
      "if round(NE) == 1:\n",
      "    print \"The hydrogen wave function is normalized\"\n",
      "else:\n",
      "    print \"The hydrogen wave function is not normalized\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "NE = 1\n",
        "The hydrogen wave function is normalized\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4, Page 252"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n = 3;    # Principal quantum number\n",
      "\n",
      "#Calculations&Results\n",
      "Total = 0;\n",
      "print (\"\\nn    l    m_l               2(l + 1)\");\n",
      "print (\"\\n------------------------------------\");\n",
      "for l in range(0,n):\n",
      "    print (\"\\n%d\"% n),\n",
      "    print (\"    %d    \"% l),\n",
      "    if l > 0:\n",
      "        count = 0;\n",
      "        for m_l in range(-l,l+1):\n",
      "            print (\"%2d \"% m_l),\n",
      "            count = count + 1;\n",
      "\n",
      "        if  l == 1:\n",
      "            print(\"      \"),\n",
      "        else:\n",
      "            print(\"\"),\n",
      "\n",
      "    else :\n",
      "        m_l = 0;\n",
      "        count = 0;\n",
      "        print(\"%2d             \"% m_l),\n",
      "        count = count + 1;\n",
      "\n",
      "    print(\"      %d\"% count),\n",
      "    Total = Total + count;\n",
      "\n",
      "print(\"\\n                                 Total = %d\"% Total);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "n    l    m_l               2(l + 1)\n",
        "\n",
        "------------------------------------\n",
        "\n",
        "3     0      0                    1 \n",
        "3     1     -1   0   1               3 \n",
        "3     2     -2  -1   0   1   2         5 \n",
        "                                 Total = 9\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7, Page 256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "e = 1.602e-019;    # Charge on an electron, C\n",
      "h = 6.62e-034;    # Planck's constant, Js\n",
      "h_bar = h/(2*math.pi);    # Reduced Planck's constant, Js\n",
      "m = 9.11e-031;    # Electron mass, kg\n",
      "B = 2.00;    # External magnetic field, T\n",
      "m_l1 = 0;    # Lower orbital magnetic quantum number\n",
      "m_l2 = 1;    # Upper orbital magnetic quantum number\n",
      "\n",
      "#Calculations\n",
      "delta_m_l = m_l2 - m_l1;    # Change in m_l\n",
      "mu_B = e*h_bar/(2*m);    # Bohr's magneton, J/T\n",
      "delta_E = mu_B*B*delta_m_l/e;    # Energy difference between components of p states of atomic hydrogen placed in the external field, eV\n",
      "\n",
      "#Results\n",
      "print \"The value of Bohr magneton = %4.2e J/T\"%mu_B\n",
      "print \"The energy difference between components of p states of atomic hydrogen placed in the external field = %4.2e eV\"%delta_E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Bohr magneton = 9.26e-24 J/T\n",
        "The energy difference between components of p states of atomic hydrogen placed in the external field = 1.16e-04 eV\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8, Page 257"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "m = 1.67e-027;    # Mass of the proton, kg\n",
      "k = 1.38e-023;    # Boltzmann constant, J/K\n",
      "T = 663;    # Temperature of the discharge tube, K\n",
      "\n",
      "#Calculations\n",
      "v_x = math.sqrt(3*k*T/m);    # Average speed of the hydrogen atom\n",
      "mu_z = 9.27e-024;    # Bohr's magneton, J/T\n",
      "B_grad = 1240;    # Magnetic field gradient, T/m\n",
      "delta_x = 0.03;    # Length of the homogeneous magnetic field, m\n",
      "d = 1/(2*m)*(mu_z*B_grad)*(delta_x/v_x)**2;    # Separation of the atomic beam, m\n",
      "\n",
      "#Result\n",
      "print \"The separation of the atomic beam = %4.2f mm\"%(d/1e-003)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The separation of the atomic beam = 0.19 mm\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9, Page 259"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n = 4;    # Principal quantum number\n",
      "l = 2;    # For 4d-state\n",
      "\n",
      "#Calculations&Results\n",
      "print \"\\nn    l         m_l             m_s\"\n",
      "print \"\\n------------------------------------------\"\n",
      "count = 0;\n",
      "for m_l in range(-l,3):\n",
      "    if (m_l == 0):\n",
      "        print \"%d\\t\"%n,\n",
      "        print \" %d\"%l,\n",
      "        print \"     %d       \"%m_l,\n",
      "        print \"     +1./2, -1./2\"\n",
      "    else:    \n",
      "        print \"               %2d\"%m_l,\n",
      "        print \"            +1./2, -1./2\"\n",
      "    count = count + 2;\n",
      "     \n",
      "print \"Total No. of different states for 4d level of atomic hydrogen = %d\"%count\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "n    l         m_l             m_s\n",
        "\n",
        "------------------------------------------\n",
        "               -2             +1./2, -1./2\n",
        "               -1             +1./2, -1./2\n",
        "4\t 2      0             +1./2, -1./2\n",
        "                1             +1./2, -1./2\n",
        "                2             +1./2, -1./2\n",
        "Total No. of different states for 4d level of atomic hydrogen = 10\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10, Page 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "def check_allowance(dn, dl, dml, dms):\n",
      "    if (dl == -1 or dl == 1 or dml == -1 or dml == 0 or dml == 1 or dms == -1 or dms == 0 or dms == 1) and dl != 0:\n",
      "        return 1;\n",
      "    else:\n",
      "        return 0;\n",
      "\n",
      "\n",
      "state = [[2, 0, 0, 1./2],[ 3, 1, 1, 1./2],[ 2, 0, 0, 1./2],[ 3, 0, 0, 1./2],[ 4, 2, -1, -1./2],[ 2, 1, 0, 1./2]];\n",
      "for i in range(0,5,2):\n",
      "    flag = 0; \n",
      "    d_n = state[i][0] - state[i+1][0];\n",
      "    d_l = state[i][1] - state[i+1][1];\n",
      "    d_m_l = state[i][2] - state[i+1][2];\n",
      "    d_m_s = state[i][3] - state[i+1][3];\n",
      "    flag = check_allowance(d_n, d_l, d_m_l, d_m_s);\n",
      "    if flag == 1:\n",
      "        print(\"\\n\\nThe transition (%d,%d,%d,1/%d) --> (%d,%d,%d,1/%d) is allowed\"%( state[i][0], state[i][1], state[i][2], state[i][3]*4, state[i+1][0], state[i+1][1], state[i+1][2], state[i+1][3]*4))\n",
      "        delta_E = -13.6*(1./state[i+1][0]**2-1./state[i][0]**2);\n",
      "        print(\"The energy of this transition is %4.2f eV\"% delta_E);\n",
      "    else:\n",
      "        print(\"\\n\\nThe transition (%d,%d,%d, %d)--> (%d,%d,%d,%d) is not allowed\"%(state[i][0], state[i][1], state[i][2], state[i][3], state[i+1][0], state[i+1][1], state[i+1][2], state[i+1][3]))\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "The transition (2,0,0,1/2) --> (3,1,1,1/2) is allowed\n",
        "The energy of this transition is 1.89 eV\n",
        "\n",
        "\n",
        "The transition (2,0,0, 0)--> (3,0,0,0) is not allowed\n",
        "\n",
        "\n",
        "The transition (4,2,-1,1/-2) --> (2,1,0,1/2) is allowed\n",
        "The energy of this transition is -2.55 eV\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.13, Page 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import scipy\n",
      "from scipy.integrate import quad\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "a0 = 1;    # For simplicity assume bohr radius to be unity\n",
      "\n",
      "#Calculations\n",
      "p = lambda r: 4/a0**3*math.exp(-2*r/a0)*r**2\n",
      "P,err = scipy.integrate.quad(p, a0, 10);\n",
      "\n",
      "#Result\n",
      "print \"The probability of the electron in the 1s state of the hydrogen atom = %4.2f\"%P"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The probability of the electron in the 1s state of the hydrogen atom = 0.68\n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}