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
|
{
"metadata": {
"name": "",
"signature": "sha256:07eafc200928a1fc85942d637323ac709731a49898cf69ec16ea9de55515ee47"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1>Chapter 7: Magnetostatic Fields<h1>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3>Example 7.1, Page number: 266<h3>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"import scipy\n",
"\n",
"#Variable Declaration\n",
"\n",
"p=5 #Distance from side 1 of loop to (0,0,5) in m\n",
"l=2 #Length of the side in m\n",
"I=10 #Current through loop in A\n",
"\n",
"#Calculation\n",
"\n",
"a1=scipy.arccos(l/(scipy.sqrt(l**2+p**2))) #Angle in radians\n",
"a2=scipy.pi/2 #Angle in radians\n",
"H=I*(scipy.cos(a1)-scipy.cos(a2))/(4*scipy.pi*p) #Field Intensity in A/m\n",
"\n",
"#Result\n",
"\n",
"print 'H=',round(H*1000,1),'mA/m in the negative y direction'"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"H= 59.1 mA/m in the negative y direction\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3>Example 7.2, Page number: 268<h3>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"import scipy\n",
"from numpy import *\n",
"\n",
"#Variable Declaration\n",
"\n",
"ax=array([1,0,0]) #Unit vector along x direction\n",
"ay=array([0,1,0]) #Unit vector along y direction\n",
"az=array([0,0,1]) #Unit vector along z direction\n",
"a1=scipy.arccos(0)\n",
"a2=scipy.arccos(1)\n",
"b1=scipy.arccos(0.6)\n",
"b2=scipy.arccos(1)\n",
"p1=5\n",
"p2=4\n",
"I1=3 #current in A\n",
"I2=3 #current in A\n",
"\n",
"#Calculations\n",
"\n",
"Hz=I1/(4*scipy.pi*p1)*(cos(a2)-cos(a1))*array([0.8,0.6,0])\n",
"Hx=I2/(4*scipy.pi*p2)*(cos(b2)-cos(b1))*array([0,0,1])\n",
"Hzcyl=-I1/(4*scipy.pi*p1)*array([0,1,0])\n",
"Hzx=round(dot(Hz,ax),4)\n",
"Hzy=round(dot(Hz,ay),5)\n",
"Hxz=round(dot(Hx,az),5)\n",
"Hxr=array([0,0,Hxz])\n",
"Hzr=array([Hzx,Hzy,0])\n",
"Hzcyly=round(dot(Hzcyl,ay),5)\n",
"Hzcylr=array([0,Hzcyly,0])\n",
"Hcart=(Hxr+Hzr)*10**3 #H in cartesian coordinates in mA \n",
"Hcyl=(Hxr+Hzcylr)*10**3 #H in cylindrical coordinates in mA\n",
"\n",
"#Result\n",
"\n",
"print 'H at (-3, 4, 0) in cartesian coordnates =',Hcart,'mA/m'\n",
"print 'H at (-3, 4, 0) in cylindrical coordnates =',Hcyl,'mA/m'"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"H at (-3, 4, 0) in cartesian coordnates = [ 38.2 28.65 23.87] mA/m\n",
"H at (-3, 4, 0) in cylindrical coordnates = [ 0. -47.75 23.87] mA/m\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3>Example 7.5, Page number: 279<h3>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"#Variable Declaration\n",
"\n",
"i0=-10 #current through plane z=0 in A/m\n",
"i4=10 #current through plane z=4 in A/m\n",
"\n",
"#Calculations\n",
"\n",
"H0a=0.5*i0*-1 #H in positive Y direction in A/m\n",
"H4a=0.5*i4*-1*-1 #H in positive Y direction in A/m\n",
"Ha=H0a+H4a #H at (1,1,1) in A/m \n",
"H0b=0.5*i0*-1 #H in positive Y direction in A/m\n",
"H4b=0.5*i4*-1 #H in negative Y direction in A/m\n",
"Hb=H0b+H4b #H at (0,-3,10) in A/m\n",
"\n",
"#Results\n",
"\n",
"print 'H at (1,1,1) =',Ha,'A/m'\n",
"print 'H at (0,-3,10) =',Hb,'A/m'"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"H at (1,1,1) = 10.0 A/m\n",
"H at (0,-3,10) = 0.0 A/m\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3>Example 7.7, Page number: 287<h3>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"import scipy.integrate\n",
"\n",
"#Calculation\n",
"\n",
"def B(z,p): \n",
" return 0.5*p\n",
"psy, err = scipy.integrate.dblquad(lambda p , z: B(z,p), \n",
" 0, 5, lambda p: 1, lambda p: 2)\n",
"\n",
"#Result\n",
"\n",
"print 'Total magnetic flux crossing the surface phi=pi/2 is',psy,'Wb'"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Total magnetic flux crossing the surface phi=pi/2 is 3.75 Wb\n"
]
}
],
"prompt_number": 4
}
],
"metadata": {}
}
]
}
|