import math
#to calculate permeability and susceptibility of the bar
phi=2.4*10**-5 #magnetic flux in weber
A=0.2*10**-4 #cross sectional area in m**2
B=phi/A #magnetic induction in N/Am
H=1200 #magnetising field in A/m
mu=B/H
print "permeability is mu=","{:.3e}".format(mu),"N/A**2"
muo=4*math.pi*10**-7
chim=(mu/muo)-1
print "susceptibility is chim=",round(chim,3),"unitless"
#the answer is given wrong in the book (round off error) chim=737
import math
#to calculate current should be sent through the solenoid
l=.10 #length in m
N=50 #number of turns
H=5*10**3 #magnetising field in A/m
i=H*l/N
print "current is i=",i,"A"
import math
#to calculate magnetic moment of the rod
#formula is B=muo*(H+I)
#where H=ni
n=500.0 #number of turns in turns/m
i=0.5 #current passed through the solenoid in A
mur=1200.0 #relative permeability
I=(mur-1)*n*i #intensity of magnetisation in A/m
V=10**-3 #volume in m**3
M=I*V
print "the magnetic moment of the rod is M=",round(M),"A-m**2"
import math
#to calculate flux density,magnetic intensity,permeability of iron
phi=2.0*10**-6 #flux in the ring in weber
A=10**-4 #cross-sectional area in m**2
B=phi/A
print "flux density is B=","{:.3e}".format(B),"weber/m**2"
N=200.0 #number of turns
i=0.30 #current flows in the windings in A
l=0.2 #length in m
H=N*i/l
print "magnetic intensity is H=",H,"A-turn/m"
mu=B/H
print "permeability is mu=",round(mu,8),"weber/A-m"
muo=4*math.pi*10**-7
mur=mu/muo
print "relative permeability is mur=",round(mur,3),"unitless"
#the answer for H in the book is wrong
#the answer for mu in book is wrong due to wrong H
#the answer in book for mur is wrong
import math
#to calculate number of ampere turns
l=0.5 #length in m
mu=6.5*10**-3 #permeability of iron in henry/m
A=2*10**-4 #area of cross-section in m**-4
R=l/(mu*A) #reluctance in A-turns/weber
flux=4*10**-4 #in weber
mmf=flux*R
print "the number of ampere turns is mmf=",round(mmf,3),"ampere-turns"
import math
#to calculate relative permeability of the medium
phi=1.5*10**-3 #magnetic flux in weber
l=math.pi*50*10**-2 #length in m
A=10*10**-4 #area of cross-section
N=1000 #number of turns
i=5 #current in A
muo=4*math.pi*10**-7
#phi(magnetic flux)=m.m.f/reluctance
#phi=N*i*muo*mur*A/l
#we get,
mur=phi*l/(N*i*A*muo)
print "relative permeability of the medium is mur=",mur,"unitless"
import math
#to calculate magnetising current
#formula is phi(magnetic flux)=m.m.f/reluctance
#phi=N*i*mu*A/l--------eq(1)
#phi=BA------------eq(2)
B=0.20 #magnetic flux density in weber/m**2
l=1 #average length of the circuit in m
N=100 #number of turns
mu=7.3*10**-3 #in h.m
#from eq(1)and eq(2),we get
i=B*l/(N*mu)
print "magnetising current is i=",round(i,3),"A"