mammos_analysis
quickstart#
mammos_analysis
has a collection of post-processing tools:
mammos_analysis.hysteresis
contains functions to extract macroscopic properties from a hysteresis loopmammos_analysis.kuzmin
contains fuctions to estimate micromagnetic properties from (atomistic) M(T) data using Kuz’min equations.
[1]:
import mammos_analysis
import mammos_entity as me
import mammos_units as u
import numpy as np
[2]:
import matplotlib.pyplot as plt
mammos_analysis.hysteresis
#
Extrinsic properties Hc, Mr, BHmax#
We can compute coercive field Hc
, remanent magnetization Mr
and the maximum energy product BHmax
from a hysteresis loop.
We need to provide the external field H
and the magnetization M
. These could come from a simulation or experiment. Here, we create some artificial data:
[3]:
H = me.H([-1e6, -0.5e6, -0.2e6, 0, 0.5e6, 1e6])
M = me.M([-1e5, -1e5, 1e5, 1e5, 1e5, 1e5])
plt.plot(H, M, "o-", linewidth=1)
[3]:
[<matplotlib.lines.Line2D at 0x7f2690bb3a50>]

[4]:
extrinsic_properties = mammos_analysis.hysteresis.extrinsic_properties(
H=H,
M=M,
demagnetization_coefficient=1 / 3, # assumption: we have a cube
)
[5]:
extrinsic_properties.Mr
[5]:
Remanence(value=100000.0, unit=A / m)
[6]:
extrinsic_properties.Hc
[6]:
CoercivityHcExternal(value=350000.0, unit=A / m)
[7]:
extrinsic_properties.BHmax # only available if we pass a demagnetization_coefficient, otherwise NaN
[7]:
MaximumEnergyProduct(value=0.0, unit=J / m3)
[8]:
plt.plot(H, M, ".-", -H, -M, "x-", linewidth=1)
plt.plot(0, extrinsic_properties.Mr, "cs", label="Mr")
plt.plot(extrinsic_properties.Hc, 0, "rD", label="Hc")
plt.legend()
[8]:
<matplotlib.legend.Legend at 0x7f268fa9f590>

Linear segment of a hysteresis loop#
We can compute properties the linear segment (starting at H=0) of a hysteresis loop.
We need to provide the external field H
and the magnetization M
. These could come from a simulation or experiment. Here, we create some artificial data:
[9]:
H = me.H(np.linspace(0, 1.1e6, 12))
M = me.M([0, 0.11e5, 0.22e5, 0.33e5, 0.44e5, 0.55e5, 0.66e5, 0.75e5, 0.83e5, 0.90e5, 0.95e5, 0.95e5])
plt.plot(H, M, "o-", linewidth=1)
[9]:
[<matplotlib.lines.Line2D at 0x7f2687744d10>]

[10]:
margin = 0.03 * 0.95e5 # allow 3% maximum deviation from assumed Ms=0.95e5
linear_segment_properties = mammos_analysis.hysteresis.find_linear_segment(H=H, M=M, margin=margin, min_points=3)
[11]:
linear_segment_properties.plot()
[11]:
<Axes: xlabel='External Magnetic Field (A / m)', ylabel='Spontaneous Magnetization (A / m)'>

mammos_analysis.kuzmin
#
Functionality to extract estimated micromagnetic properties from Ms(T) data, which could e.g. come from spin dynamics simulations.
We use Kuz’min equations to compute Ms(T), A(T), K1(T)
Kuz’min, M.D., Skokov, K.P., Diop, L.B. et al. Exchange stiffness of ferromagnets. Eur. Phys. J. Plus 135, 301 (2020). https://doi.org/10.1140/epjp/s13360-020-00294-y
Additional details about inputs and outputs are available in the API reference
In this notebook we will use artificial data:
[12]:
T = me.T(np.linspace(0, 600, 20))
Ms_val = np.sqrt(500 - T.value, where=T.value < 500, out=np.zeros_like(T.value)) * 0.5e5
Ms = me.Ms(Ms_val)
plt.plot(T, Ms, "o")
[12]:
[<matplotlib.lines.Line2D at 0x7f268764e090>]

[13]:
kuzmin_result = mammos_analysis.kuzmin.kuzmin_properties(T=T, Ms=Ms, K1_0=1e5) # K1_0 is optional
We can visualize the resulting functions and compare against our input data:
[14]:
kuzmin_result.plot()
[14]:
array([<Axes: xlabel='Thermodynamic Temperature (K)', ylabel='Spontaneous Magnetization (A / m)'>,
<Axes: xlabel='Thermodynamic Temperature (K)', ylabel='Exchange Stiffness Constant (J / m)'>,
<Axes: xlabel='Thermodynamic Temperature (K)', ylabel='Uniaxial Anisotropy Constant (J / m3)'>],
dtype=object)

[15]:
kuzmin_result.Ms.plot()
plt.plot(T, Ms, "o")
[15]:
[<matplotlib.lines.Line2D at 0x7f268772a0d0>]

The result object contains three functions for Ms, A, and K1. K1 is only available if we pass K1_0
to the kuzmin_properties
function. Furthermore, we get an estimated Curie temperature and the fit parameter s.
[16]:
kuzmin_result
[16]:
KuzminResult(Ms=Ms(T), A=A(T), Tc=CurieTemperature(value=505.2631562505781, unit=K), s=<Quantity 2.45341654>, K1=K1(T))
We can call the functions at different temperatures to get parameters. We can pass a mammos_entity.Entity
, an astropy.units.Quantity
or a number:
[17]:
kuzmin_result.Ms(me.T(0))
[17]:
SpontaneousMagnetization(value=1118033.988749895, unit=A / m)
[18]:
kuzmin_result.A(100 * u.K)
[18]:
ExchangeStiffnessConstant(value=2.0493756919248373e-12, unit=J / m)
[19]:
kuzmin_result.K1(300)
[19]:
UniaxialAnisotropyConstant(value=27234.488896009963, unit=J / m3)
We can also use an array to get data for multiple temperatures:
[20]:
kuzmin_result.Ms(me.T([0, 100, 200, 300]))
[20]:
SpontaneousMagnetization(value=[1118033.9887499 1041900.28067709 906082.21982412 724705.26467561], unit=A / m)