In [1]:

```
#Variable declaration
H = 5e+3; # Coercivity of a bar magnet, A/m
L = 0.1; # Length of the solenoid, m
N = 50; # Turns in solenoid
n = 500; # Turns/m
#Calculations
# Using the relation
I = H/n; # where I is the current through the solenoid
#Result
print "The current through the solenoid is = %2d A"%I
```

In [2]:

```
#Variable declaration
n = 500; # Number of turns wound per metre on the solenoid
i = 0.5; # Current through the solenoid, A
V = 1e-03; # Volume of iron rod, per metre cube
mu_r = 1200; # Relative permeability of the iron
#Calculations&Results
H = n*i; # Magnetic intensity inside solenoid, ampere-turn per metre
# As B = mu_o * (H + I) => I = B/mu_o - H
# But B = mu_o * mu_r * H and solving for I
I = (mu_r - 1) * H;
print "The Intensity of magnetisation inside the solenoid, I = %5.3e A/m"%I
M = I * V; # Magnetic moment of the rod, ampere metre square
print "The magnetic moment of the rod, M = %3d ampere metre square"%M
```

In [4]:

```
#Variable declaration
n = 300; # Number of turns wound per metre on the solenoid
i = 0.5; # Current through the solenoid, A
V = 1e-03; # Volume of iron rod, per metre cube
mu_r = 100; # Relative permeability of the iron
#Calculations&Results
H = n*i; # Magnetic intensity inside solenoid, ampere-turn per metre
# As, I = (B-mu_o* H)/mu_o
#But, B= mu * H = mu_r * mu_o * H and I = (mu_r-1)* H
I = (mu_r-1)*n*i;
print "The Intensity of magnetisation inside the solenoid, I = %5.3e A/m"%I
l = 0.2; #length of the rod,m
r = 5e-3; #radius of the rod,m
V = 1.57e-5; #V=%pi*r^2*l where the volume of the rod having radius r and length,m
M = I * V ; # Magnetic moment of the rod, ampere metre square
print "The magnetic moment of the rod, M = %5.3f ampere metre square"%M
```

In [5]:

```
from math import *
#Variable declaration
B = 0.0044; # Magnetic flux density, weber/meter square
mu_o = 4*pi*1e-07; # Relative permeability of the material, henery/m
I = 3300; # Magnetization of a magnetic material, A/m
#Calculations&Results
#B = mu_o*(I+H), solving for H
H = (B/mu_o)- I; # Magnetizing force ,A/m
print "The magnetic intensity,H = %3d A/m"%H
# Relation between intensity of magnetization and relative permeability
mu_r = (I/H)+1; #substitute the value of I and H
print "The relative permeability, mu_r = %5.2f"%mu_r
#Incorrect answers in the textbook
```

In [16]:

```
from math import *
#Variable declaration
mu_o = 4*pi*1e-07; # Magnetic permeability of the free space, henery/m
mu_r = 600;
mu = mu_o*mu_r; # Magnetic permeability of the medium, henery/m
n = 500; # Turns in a wire
i = 0.3; # Current flows through a ring,amp
r = 12e-02/2; # Mean radius of a ring, m
#Calculations&Results
B = mu_o*mu_r*n*i/(2*pi*r);
print "The magnetic flux density = %2.1f weber/meter-square"%B
H = B/mu; # Magnetic intensity, ampere-turns/m
print "The magnetic intensity = %5.1f ampere-turns/m"%H
mui = B -mu_o
per = mui/i*100
print "The percentage magnetic flux density due to electronic loop currents = ",per,"%"
```

In [17]:

```
#Variable declaration
M_i = 4.5; # Intial value of total dipole moment of the sample
H_i = 0.84; # External magnetic field, tesla
T_i = 4.2; # Cooling temerature of the sample, K
H_f = 0.98; # External magnetic field, tesla
T_f = 2.8; # Cooling temerature of the sample, K
#Calculations
# According to the curie's law, Mf/Mi = (Hf/Hi)*(Ti/Tf)
M_f = M_i*H_f/H_i*T_i/T_f;
#Result
print "The total dipole moment of the sample = %5.3f joule/tesla"%M_f
```

In [18]:

```
from math import *
#Variable declaration
mu_o = 4*pi*1e-07; # Magnetic permeability of free space, henry/m
n = 1e+29; # Number density of atoms of iron, per metre cube
p_m = 1.8e-23; # Magnetic moment of each atom, ampere-metre square
k_B = 1.38e-23; # Boltzmann constant, J/K
B = 0.1; # Magnetic flux density, weber per metre square
T = 300; # Absolute room temperature, K
l = 10e-02; # Length of the iron bar, m
a = 1e-04; # Area of cross-section of the iron bar, metre square
#Calculations&Results
V = l*a; # Voluem of the iron bar, metre cube
chi = n*p_m**2*mu_o/(3*k_B*T);
print "The paramagnetic susceptibility of a material = %5.3e"%chi
pm_mean = p_m**2*B/(3*k_B*T); # Mean dipole moment of an iron atom, ampere metre-square
P_m = n*pm_mean; # Dipole moment of the bar, ampere metre-square
I = n*p_m; # Magnetization of the bar in one domain, ampere/metre
M = I*V; # Magnetic moment of the bar, ampere metre-square
print "The dipole moment of the bar = %5.3e ampere metre-square"%P_m
print "The magnetization of the bar in one domain = %3.1e ampere/metre"%I
print "The magnetic moment of the bar = %2d ampere metre-square"%M
```

In [19]:

```
#Variable declaration
A = 500; # Area of the B-H loop, joule per metre cube
n = 50; # Total number of cycles, Hz
m = 9; # Mass of the core, kg
d = 7.5e+3; # Density of the core, kg/metre cube
t = 3600; # Time during which the energy loss takes place, s
#Calculations
V = m/d; # Volume of the core, metre cube
E = n*V*A*t; # Hystersis loss of energy per hour, joule
#Result
print "The hystersis loss per hour = %5.2eJ"%E
```

In [20]:

```
#Variable declaration
n = 50; # Total number of cycles per sec, Hz
V = 1e-03; # Volume of the specimen, metre cube
t = 1; # Time during which the loss occurs, s
A = 0.25e+03; # Area of B-H loop, joule per metre cube
#Calculations
E = n*V*A*t; # Energy loss due to hysteresis, J/s
#Result
print "The hystersis loss = %4.1f J/s"%E
#incorrect answer in the textbook
```

In [21]:

```
#Variable declaration
e = 1.6e-19; # Charge on anlectron, C
m = 9.1e-31; # Mass of the electron, kg
r = 5.1e-11; # Radius of the electronic orbit, m
B = 2.0; # Applied magnetic field, weber per metre-square
#Calculations
delta_pm = e**2*r**2*B/(4*m);
#Result
print "The change in the magnetic dipole moment of the electron = %3.1e A-metre square"%delta_pm
```