"
]
},
{
"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": [
"
Example 7.2, Page number: 268
"
]
},
{
"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": [
"
Example 7.5, Page number: 279
"
]
},
{
"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": [
"