summaryrefslogtreecommitdiff
path: root/Elements_of_Electromagnetics/chapter_5.ipynb
blob: db757859a983f72da56767cbd159124de10ee057 (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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
{
 "metadata": {
  "name": "",
  "signature": "sha256:08d693988f55ded7946a3910c4b750b4a1419d79f72e5b56719c0d924a66fd5a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 5: Electric Fields in Material Space<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.1, Page number: 167<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "import scipy.integrate\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "r1= 0.2                # radius of hemispherical shell in metres\n",
      "r2= 0.1                # radius of spherical shell in metres\n",
      "\n",
      "#Calculations\n",
      "\n",
      "#Calculation of current through hemispherical shell \n",
      "\n",
      "def J1(phi,theta):\n",
      "\ts1=(1/r1)*(2* scipy.cos(theta)* scipy.sin(theta))\n",
      "\treturn s1\n",
      "\n",
      "if __name__ == '__main__':\n",
      "\n",
      " I1, error = scipy.integrate.dblquad(lambda theta , phi: J1(phi,theta),    \n",
      "             0, 2*scipy.pi, lambda theta: 0, lambda theta: scipy.pi/2) \n",
      "\t                 \n",
      "#Calculation of current through spherical shell \n",
      "\n",
      "def J2(phi,theta):\n",
      "\ts2=(1/r2)*(2* scipy.cos(theta)* scipy.sin(theta))\n",
      "\treturn s2\n",
      "\n",
      "if __name__ == '__main__':\n",
      "\n",
      " I2, error = scipy.integrate.dblquad(lambda theta , phi: J1(phi,theta),    \n",
      "              0, 2*scipy.pi, lambda theta: 0, lambda theta: scipy.pi) \n",
      "\t                 \n",
      "#Results\n",
      "\n",
      "print 'Current through hemispherical shell=',round(I1,1),'A' \n",
      "print 'Current through spherical shell=',round(I2,0),'A'\n",
      "\t"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through hemispherical shell= 31.4 A\n",
        "Current through spherical shell= 0.0 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.2, Page number: 168<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Variable Declaration\n",
      "\n",
      "ps=10**-7     #Surface charge density of the belt in Couloumb/metre^2\n",
      "u=2           #Speed of the belt in metres/sec\n",
      "w=0.1         #Width of the belt in metres\n",
      "t=5           #Time taken in seconds \n",
      "\n",
      "#Calculations\n",
      "\n",
      "I=ps*u*w      #Current in amperes\n",
      "Q=I*t*10**9   #Charge collected in 5 seconds in nano Coloumbs\n",
      "\n",
      "#Result\n",
      "\n",
      "print \"The charge collected in 5 seconds is \",Q,\"nC\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The charge collected in 5 seconds is  100.0 nC\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.3, Page number: 169<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Variable Declaration\n",
      "\n",
      "n=10**29              #Number density of electrons in m^-3\n",
      "e=-1.6*10**-19        #Electronic charge in Coloumbs\n",
      "sigma=5*10**7         #Current density in S/m\n",
      "E=10**-2              #Electric Field in V/m\n",
      "S=(3.14*10**-6)/4     #Cross sectional area of the wire in m^2\n",
      "\n",
      "#Calculations\n",
      "\n",
      "pv=n*e                #Charge density of free electrons in C/m^3\n",
      "J=sigma*E*10**-3      #Current density in kA/m^2\n",
      "I=J*S*10**3           #Current in amperes\n",
      "u=J*10**3/pv          #Drift velocity in m/s\n",
      "\n",
      "#Results\n",
      "\n",
      "print \"The charge density is \",pv,\"C/m^3\" \n",
      "print \"The current density is \",J,\"kA/m^2\" \n",
      "print \"The current is \",round(I,3), \"A\"\n",
      "print \"The drift velocity is \",-u,\"m/s\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The charge density is  -16000000000.0 C/m^3\n",
        "The current density is  500.0 kA/m^2\n",
        "The current is  0.393 A\n",
        "The drift velocity is  3.125e-05 m/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.4, Page number: 170<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "l=4                            #Length of the lead bar in m\n",
      "d=3                            #Width of the lead bar in cm\n",
      "r=0.5                          #Radius of the hole drilled in cm\n",
      "sigma=5*10**6                  #Conductivity of the bar in S/m\n",
      "\n",
      "#Calculation\n",
      "\n",
      "S=(d**2-(scipy.pi*r**2))       #Cross sectional area in cm^2\n",
      "R=l/(S*sigma*10**-4)           #Resistance in ohms\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'The resistance between the square ends is',round(R*10**6),'micro ohms'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance between the square ends is 974.0 micro ohms\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.6, Page number: 177<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "e0=10**-9/(36*scipy.pi)         #permittivity of free space in Farad/m\n",
      "er=2.55                         #relative permittivity (dimensionless)\n",
      "E=10*10**3                      #Electric field in V/m\n",
      "chi=er-1.0                      #Electric susceptibility (dimensionless)\n",
      "d=1.5                           #Distance between plates in mm\n",
      "\n",
      "#Calculations\n",
      "\n",
      "D=e0*er*E*10**9                 #D in nC/m^2\n",
      "\n",
      "P=chi*e0*E*10**9                #P in nC/m^2\n",
      "\n",
      "ps=D                            #The surface charge density of \n",
      "                                #free charge in nC/m^2\n",
      "                                \n",
      "pps =P                          #The surface charge density of\n",
      "                                #polarization charge in nC/m^2\n",
      "                                \n",
      "V=E*d*10**-3                    #The potential difference between \n",
      "                                #the plates in volts\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'D =',round(D,2),'nC/m^2'\n",
      "print 'P =',round(P,0),'nC/m^2'\n",
      "print 'Surface charge density of free charge =',round(ps,2),'nC/m^2'\n",
      "print 'Surface charge density of polarization charge =',round(pps,0),'nC/m^2'\n",
      "print 'The potential difference between the plates =',V,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "D = 225.47 nC/m^2\n",
        "P = 137.0 nC/m^2\n",
        "Surface charge density of free charge = 225.47 nC/m^2\n",
        "Surface charge density of polarization charge = 137.0 nC/m^2\n",
        "The potential difference between the plates = 15.0 V\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.7, Page number: 178<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "e0=10**-9/(36*scipy.pi)                   #permittivity of free space\n",
      "                                          #in Farad/m\n",
      "                                          \n",
      "er=5.7                                    #relative permittivity\n",
      "                                          #(dimensionless)\n",
      "                                          \n",
      "chi=er-1                                  #Electric susceptibility\n",
      "                                          #(dimensionless)\n",
      "                                          \n",
      "r=0.1                                     #radius of sphere in m\n",
      "\n",
      "q1=2                                      #charge on sphere in pC\n",
      "\n",
      "q2=-4                                     #value of point charge in pC\n",
      "\n",
      "#Calculations\n",
      "\n",
      "E=q1/(4*scipy.pi*e0*er*r**2)              #Electric field on the\n",
      "                                          #sphere in pV/m\n",
      "                                          \n",
      "P=chi*e0*E                                #Polarisation in pC/m^2\n",
      "\n",
      "pps=P                                     #The surface density of polarization \n",
      "                                          #charge in pC/m^2\n",
      "                                          \n",
      "F=(q1*q2*10**-12)/(4*scipy.pi*e0*er*r**2) #Force exerted on point charge in pN\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'The surface density of polarization'\n",
      "print 'charge on the surface of the sphere =',round(pps,2),'pC/m^2'\n",
      "print 'Force exerted on -4 pC charge =',round(F,3),'pN in the radial direction'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The surface density of polarization\n",
        "charge on the surface of the sphere = 13.12 pC/m^2\n",
        "Force exerted on -4 pC charge = -1.263 pN in the radial direction\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.9, Page number: 188<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Variable Declarartion\n",
      "\n",
      "import scipy\n",
      "from numpy import *\n",
      "\n",
      "an=array([0,0,1])            #Unit vector normal to the interface\n",
      "E1=array([5,-2,3])           #Electric field for z >=0 in kV/m\n",
      "e_r1=4                       #Relative permittivity for z >=0 (dimensionless)\n",
      "e_r2=3                       #Relative permittivity for z <=0 (dimensionless)\n",
      "e0=(10**-9)/(36*scipy.pi)    #Permittivity of free space in Farad/m\n",
      "V=2*2*2                      #Volume of cube placed in region 2 in m^3\n",
      "\n",
      "#Calculations\n",
      "\n",
      "E1n=array([0,0,dot(E1,an)])   #The normal component of E1 in kV/m\n",
      "E1t=E1-E1n                    #Transverse component of E1 in kV/m\n",
      "E2t=E1t                       #Transverse component of E2 in kV/m\n",
      "E2n=e_r1*E1n/e_r2             #Normal Component of E2 in kV/m\n",
      "E2=E2n+E2t                    #The total field E2 in kV/m\n",
      "\n",
      "theta1= 90- 180*scipy.arccos(dot(E1,an)/        #Angle between E1 and \n",
      "             scipy.sqrt(dot(E1,E1)))/scipy.pi   #interface in degrees\n",
      "             \n",
      "theta2= 90- 180*scipy.arccos(dot(E2,an)/        #Angle between E2 and \n",
      "             scipy.sqrt(dot(E2,E2)))/scipy.pi   #interface in degrees\n",
      "\n",
      "\n",
      "We1= 0.5*e0*e_r1*dot(E1,E1)*10**6       # The energy density of E1 in J/m^3\n",
      "We2= 0.5*e0*e_r2*dot(E2,E2)*10**6       # The energy density of E2 in J/m^3\n",
      "W= We2*V                                # The energy within the cube in J\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'The electric field for the region z <=0 is',E2,'kV/m'\n",
      "print 'The angle E1 makes with the boundary is',round(theta1,1),'degrees'\n",
      "print 'The angle E2 makes with the boundary is',round(theta2,1),'degrees'\n",
      "print 'The energy density in dielectric 1 is',round(We1*10**6,0),'J/m^3'\n",
      "print 'The energy density in dielectric 2 is',round(We2*10**6,0),'J/m^3'\n",
      "print 'The energy within the cube is',round(W*1000,3),'mJ'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The electric field for the region z <=0 is [ 5 -2  4] kV/m\n",
        "The angle E1 makes with the boundary is 29.1 degrees\n",
        "The angle E2 makes with the boundary is 36.6 degrees\n",
        "The energy density in dielectric 1 is 672.0 J/m^3\n",
        "The energy density in dielectric 2 is 597.0 J/m^3\n",
        "The energy within the cube is 4.775 mJ\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5.10, Page number: 190<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "e=(10**-9)/(36*scipy.pi)     #Permittivity of free space in Farad/m\n",
      "er=2                         #Relative permittivity (dimensionless)\n",
      "ps=2                         #Surface charge in nC/m^2\n",
      "\n",
      "#Calculations\n",
      "\n",
      "#Point A is in the region y <=0. Hence E=D=0\n",
      "#For point B which is in the region y >=0,\n",
      "\n",
      "Dn=ps                        #Displacement current in nC/m^2\n",
      "En=Dn*10**-9/(e*er)          #Electric Field\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'E at point A= 0'\n",
      "print 'D at point A= 0'\n",
      "print 'E at point B=',round(En,2),'V/m along positive y direction'\n",
      "print 'D at point B=',Dn,'nC/m^2 along positive y direction'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "E at point A= 0\n",
        "D at point A= 0\n",
        "E at point B= 113.1 V/m along positive y direction\n",
        "D at point B= 2 nC/m^2 along positive y direction\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}