Chapter 7: Magnetostatic Fields

Example 7.1, Page number: 266

In [1]:
 
import scipy

#Variable Declaration

p=5                    #Distance from side 1 of loop to (0,0,5) in m
l=2                    #Length of the side in m
I=10                   #Current through loop in A

#Calculation

a1=scipy.arccos(l/(scipy.sqrt(l**2+p**2)))        #Angle in radians
a2=scipy.pi/2                                     #Angle in radians
H=I*(scipy.cos(a1)-scipy.cos(a2))/(4*scipy.pi*p)  #Field Intensity in A/m

#Result

print 'H=',round(H*1000,1),'mA/m in the negative y direction'
H= 59.1 mA/m in the negative y direction

Example 7.2, Page number: 268

In [2]:
 
import scipy
from numpy import *

#Variable Declaration

ax=array([1,0,0])           #Unit vector along x direction
ay=array([0,1,0])           #Unit vector along y direction
az=array([0,0,1])           #Unit vector along z direction
a1=scipy.arccos(0)
a2=scipy.arccos(1)
b1=scipy.arccos(0.6)
b2=scipy.arccos(1)
p1=5
p2=4
I1=3                        #current in A
I2=3                        #current in A

#Calculations

Hz=I1/(4*scipy.pi*p1)*(cos(a2)-cos(a1))*array([0.8,0.6,0])
Hx=I2/(4*scipy.pi*p2)*(cos(b2)-cos(b1))*array([0,0,1])
Hzcyl=-I1/(4*scipy.pi*p1)*array([0,1,0])
Hzx=round(dot(Hz,ax),4)
Hzy=round(dot(Hz,ay),5)
Hxz=round(dot(Hx,az),5)
Hxr=array([0,0,Hxz])
Hzr=array([Hzx,Hzy,0])
Hzcyly=round(dot(Hzcyl,ay),5)
Hzcylr=array([0,Hzcyly,0])
Hcart=(Hxr+Hzr)*10**3               #H in cartesian coordinates in mA  
Hcyl=(Hxr+Hzcylr)*10**3             #H in cylindrical coordinates in mA

#Result

print 'H at (-3, 4, 0) in cartesian coordnates =',Hcart,'mA/m'
print 'H at (-3, 4, 0) in cylindrical coordnates =',Hcyl,'mA/m'
H at (-3, 4, 0) in cartesian coordnates = [ 38.2   28.65  23.87] mA/m
H at (-3, 4, 0) in cylindrical coordnates = [  0.   -47.75  23.87] mA/m

Example 7.5, Page number: 279

In [3]:
 
#Variable Declaration

i0=-10                #current through plane z=0 in A/m
i4=10                 #current through plane z=4 in A/m

#Calculations

H0a=0.5*i0*-1         #H in positive Y direction in A/m
H4a=0.5*i4*-1*-1      #H in positive Y direction in A/m
Ha=H0a+H4a            #H at (1,1,1) in A/m 
H0b=0.5*i0*-1         #H in positive Y direction in A/m
H4b=0.5*i4*-1         #H in negative Y direction in A/m
Hb=H0b+H4b            #H at (0,-3,10) in A/m

#Results

print 'H at (1,1,1) =',Ha,'A/m'
print 'H at (0,-3,10) =',Hb,'A/m'
H at (1,1,1) = 10.0 A/m
H at (0,-3,10) = 0.0 A/m

Example 7.7, Page number: 287

In [4]:
 

import scipy.integrate

#Calculation

def B(z,p): 
 return 0.5*p
psy, err = scipy.integrate.dblquad(lambda p , z: B(z,p),    
             0, 5, lambda p: 1, lambda p: 2)

#Result

print 'Total magnetic flux crossing the surface phi=pi/2 is',psy,'Wb'
Total magnetic flux crossing the surface phi=pi/2 is 3.75 Wb