import math
# Variable declaration
r   = 0.53*10**-10;          # orbit radius m
n   = 6.6*10**15;            # frequency of revolution of electronHz
e   = 1.6*10**-19            # charge of electron in coulombs
h   = 6.63*10**-34;          # plancks constant in J.s
m   = 9.1*10**-31;           # mass of electron in kg
# Calculations
i   = e*n                              # current produced due to electron
A   = math.pi*r*r                      # Area in m^2
u   = i*A;                             # magnetic moment A*m^2
ub  = (e*h)/float(4*math.pi*m);        # Bohr magneton in J/T
#result
print'Magnetic moment = %3.3e'%u,'Am**2';
print'Bohr magneton = %3.2e'%ub,'J/T';
import math
#Variable declaration
ur  = 1150;           # relative permeability
n   = 500;            # turns per m
V   = 10**-3;         # volume of iron rod in m**3
i   = 0.5;            # current in amp
#Calculations
#B = uo(H+M)
# B = uH, u/uo = ur
# M = (ur - 1)H
#if current is flowing through a solenoid having n turns/l then H = ni
M = (ur - 1)*n*i      # magnetisation
m = M*V;              # magnetic moment
 
#Output
print'Magnetic moment = %3.2e'%m,' A-m**2';
print'\n Note: Instead of 2.87*10**2, 2.87*10**-2 is printed in textbook';
import math
# Variable declaration
ur  = 90;             #relative permeability
n   = 300;            # turns per m
i   = 0.5;            # current in amp
d   = 10*10**-3;      # diameter of iron rod
l   = 2;              # length of iron rod
#Calculations
V   = math.pi*(d/float(2))**2 * l;      #volume of rod
M   = (ur - 1)*n*i;         # magnetisation
m   = M*V;                  # magnetic moment
# Output
print'Magnetic Moment of the rod = %3.3g'%m,'A-m**2';
print'Note: In textbook length of iron rod given as 2m whereas in calculation it is wrongly taken as 0.2m';
import math
#Variable declaration
Bo  = 2;                    # magnetic field in tesla
r   = 5.29*10**-11           # radius in m
m   = 9.1*10**-31;           # mass of electron in kg
e   = 1.6*10**-19            # charge of electron
# calculations
du  = (e**2 * Bo * r**2)/float(4*m);        # change in magnetic moment(indicating oth in -ve and +ve values)
#result
print'Change in magnetic moment = %3.1e'%du,'J/T';
import math
# Variable declaration
u1  = 3.3;                    # magnetic dipole moment
u   = 9.24*10**-24;
B   = 5.2;                    # magnetic field in tesla
k   = 1.38*10**-23;           # boltzmann constant
# calculations
T   = (u*u1*B)/float(1.5*k);     # Temperature in Kelvin
#result
print'Temperature to which substance to be cooled = %3.1f'%T,'K';
print'Note:Values given in question B = 52, u = 924*10**-24.Values substituted in calculation B = 5.2, u = 9.24*10**-24';
import math
#Variable declaration
xm      = -4.2*10**-6;           # magnetic susceptibility in A.m**-1
H       = 1.15*10**5;            # magnetic field in A.m**-1
#Calculations
uo      = 4*math.pi*10**-7;          # magnetic permeability  N·A**-2
M       = xm*H;                      # magnetisation in A.m**-1
B       = uo*(H + M);                # flux density in T
ur      = 1+(M/float(H));            # relative permeability 
# result
print'Magnetisation = %3.2f'%M,'A/m';
print'flux density = %3.2f'%B,'Tesla'; 
print'relative permeability = %f'%ur;
import math
# Variable declaration
xm      = 1.4*10**-5;        # magnetic susceptibility
# B    = uoH
# B'   = uruoH
# ur   = 1+xm
# from above equations
#B'    = (1+xm)B
# percentage increase in magnetic induction = ((B'-B)/B)*100
# y     = (((1+xm)B - B)/B)*100
PI    = xm*100;       # percentage increase
# Output
print'Percentage increase = %3.4f'%PI,'%';
import math
# Variable declaration
xm      = -0.2*10**-5;       # magnetic susceptability in A.m**-1
H       = 10**4;             # magnetic field in A/m
# Calculations
uo      = 4*math.pi*10**-7;          # magnetic permeability
M       = xm*H              # magnetisation in A/m
B       = uo*(H+M);         # magnetic flux density in T
# Output
print'magnetisation = %3.2f'%M,'A/m';
print'Note:magnetisation sign is printed wrong in textbook';
print'Magnetic flux density = %3.4f'%B,'T';
import math
#variable declaration
sighem        = 2.1*10**-5;             #magnetic susceptability
u1             = 10**-7;
#calculation
u0            = 4*math.pi*u1;
ur             = 1+(sighem);      #permeability
u              = u0*ur;           #relative permeability in N/A**2
#result
print'permeability =%3.6f'%ur;
print'relative permeability =%3.4e'%u,'N/A**2';
 
import math
#variable declaration
sighem        = 0.084;             #magnetic susceptability
u1             = 10**-7;
#calculation
u0            = 4*math.pi*u1;
ur             = 1+(sighem);        #permeability
u              = u0*ur;            #relative permeability in N/A**2
#result
print'permeability =%3.6f'%ur;
print'relative permeability =%3.3e'%u,'N/A**2';
import math
#variable declarationn
u            = 0.126;              #permiability in N/A**2
u1             = 10**-7;
#calculation
u0            = 4*math.pi*u1;
ur             = u/float(u0);
sighe         = ur-1;                #magnetic susceptability
#result
print'relative permiability =%3.5e'%sighe;
print' Note:Calculation mistake in textbook in calculating sighe by taking ur as 10**5 instead of 100318.4';
import math
#variable declaration
#diamagnetic susceptability of He
R         = 0.6*10**-10;                #mean radius of atom in m
N         = 28*10**26;                  #avagadro number in per m**3
e         = 1.6*10**-19;                 #charge of electron in coulombs
m         = 9.1*10**-31;                 #mass of electron in kilograms
Z         = 2;                           #atomic number
 
#calculation
u0        = 4*math.pi*10**-7;                        #atomic number
si        = -(u0*Z*(e**2)*N*(R**2))/float(6*m);       #susceptability of diamagnetic material 
 
#result
print'susceptability of diamagnetic material = %3.4e'%si;
 
import math
#variable declaration
phi         = 2*10**-5;          #magnetic flux in Wb/m**2
H          = 2*10**3;              #in A/m
A          = 0.2*10**-4;        #area  in m**2
 
 
#calculation
u0        = 4*math.pi*10**-7;
B         = phi/float(A);                #magnetic flux density in Wb/m**2
u         = B/float(H);                  #permiability in A**-2
sighem    = (u/float(u0))-1;
          
#result
print'permiability =%3.2e'%u,'N/A**2';
print'susceptability =%4f'%sighem;
print'Note:answer of permiability is wrong in textbook';
print'Note: calcuation mistake in textbook in sighem';
# import math
#variable declaration
N         = 6.5*10**25;             #number of atoms in atoms per m**3
e         = 1.6*10**-19;            #charge of electron in coulombs
m         = 9.1*10**-31;            #mass of electron inilograms
h         = 6.6*10**-34;            #planck's constant in J.s
T         = 300;                    #temperature in K
k         = 1.38*10**-23;           #boltzman constant in J*(K**-1)
n         = 1;                      #constant
 
 
#calculation
u0        =  4*math.pi*10**-7;
M         = n*((e*h)/float(4*math.pi*m));                 #magnetic moment in A*m**2
sighe     = (u0*N*(M**2))/float(3*k*T);                   #susceptability of diamagnetic material
 
#result
print'susceptability of diamagnetic material = %3.2e'%sighe;
import math
#variable declaration
L       = 2.0;                    #length in m
A       = 4*10**-4;               #cross section sq.m
u       = 50*10**-4;              #permiability in H*m**-1
phi       = 4*10**-4;             #magnetic flux in Wb
#calculation
B      =  phi/float(A);               #magnetic flux density in Wb/m**2
NI     = B/float(u);                  #ampere turn in A/m
 
#result
print'ampere turn =%3.0f'%NI,'A/m';
 
import math
#variable declaration
H          = 5*10**3;               #corecivity in A/m
l          = 10**-1;                #length in m
n          = 500;                   #number of turns
#calculation
N      = n/float(l);                   #number of turns per m
i      = H/float(N);                   #current in A
 
#result
print'current =%1d'%i,'A';
 
import math
#variable declaration
A          = 6*10**-4;               #area in m**2
l          = 0.5;                    #length in m
u          = 65*10**-4;             #permiability in H/m
phi        = 4*10**-5;              #magnetic flux in Wb
#calculation
B          = phi/float(A);
H          = B/float(u);
N          = H*l;                                  #number of turns
 
#result
print'number of turns =%1f'%N;
print' Note: calculation mistake in textbook in calculattig H by taking B value as 0.06 instead of 0.0666';
 
import math
#variable declaration
A          = 0.2*10**-4;               #area in m**2
H          = 500;                      #magnetising field in A.m**-1
phi         = 2.4*10**-5;              # magnetic flux in Wb
#calculation
u0      = 4*math.pi*10**-7;
B      = phi/float(A);                        #magnetic flux density in N*A**-1 *m**-1
u      = B/float(H);                          #permiability in N/m
fm     = (u/float(u0))-1;                     #susceptability 
 
#result
print'susceptability =%3.2d'%fm;
 
import math
#variable declaration
f      = 50;                  #number of reversals/s in Hz
W      = 50;                  #weight in kg
d      = 7500;                #density in kg/m^3
A      = 200;                 #area in  joules /m^3
 
#calculation
 
V      = 1/float(d);           #volume of 1 kg iron
E      = A*V;                  #loss of energy per kg
L      = f*E;                  #hysteresisloss/s in Joule/second
Lh     = L*60*60;               #loss per hour
 
#calculation
print'loss of energy per hour =%3.2f'%Lh;
print'Note:calculation mistake in textbook in calculating Lh';
import math
#variable declaration
f       = 50;                   #frequency in Hz
Bm      = 1.1;                  #magnetic flux in Wb/m**2
t       = 0.0005;               #thickness of sheet 
p       = 30*10**-8*7800;        #resistivity in ohms m
d       = 7800;                 #density in kg/m**3
Hl      = 380;                  #hysteresis loss per cycle in W-S/m**2
#calculation
Pl     = ((math.pi**2)*(f**2)*(Bm**2)*(t**2))/float(6*p);    #eddy current loss
Hel     = (Hl*f)/float(d);                                   #hysteresis loss
Tl      = Pl+Hel;                                            #total iron loss watt/kg
 
#result
print'total iron loss =%3.2f'%Tl,'watt/kg';