#initiation of variable
from math import pi
b_m=9.27*10**-24 # Bohr Magneton in ampere*m^2
Na=6.023*10**23 #Avogadro's Number
d=8.9*10**6 # density in g/m^3
uo=4*pi*10**-7 #Permittivity of free space
A=58.71 # Atomic weight of Nickel g/mol
#calculation
N=d*Na/A #No. of atoms per cubic meter
M=0.6*b_m*N #0.6= Bohr Magneton/atom
#partA
#results
print" Saturation Magnetization is %.1e Ampere" %M
# Part B
M=0.6*b_m*N #0.6= Bohr Magneton/atom
B=uo*M
#results
print" Saturation Flux Density is %.2f Tesla" %B;
#initiation of variable
a=0.839*10**-9 #a is edge length in m
b_m=9.27*10**-24 # Bohr Magneton in ampere*m^2
n_b=8*4 #8 is no. of Fe++ ions per unit cell and 4 is Bohr magnetons per Fe++ ion
#calculation
M=n_b*b_m/a**3 #M is Saturation magnetisation
#result
print" Saturation Magnetization is %.1e Ampere" %M
#initiation of variable
from sympy import *
x = symbols('x')
from sympy import roots, solve_poly_system
Ms_Fe=5.25*10**5; #Required saturation Magnetisation in A/m
b_m=9.27*10**-24; #Bohr Magneton in ampere*m^2
a=0.839*10**-9; #a is edge length in m
M=5.0*10**5; #From previous question result
#result
nb=Ms_Fe*a**3/b_m;
# 'x' represent fraction of Mn++ that have substituted Fe++
n=solve(8*(5*x+4*(1-x))-nb,x); #5 is Bohr magnetons per Fe++ ion
#4 is Bohr magnetons per Mn++ ion
print" Replacing ", round((n[0]),3),"of Fe++ with Mn++ would produce the required saturation magnetisation of %.2e A" %Ms_Fe;