mammos_analysis quickstart#

mammos_analysis has a collection of post-processing tools:

  • mammos_analysis.hysteresis contains functions to extract macroscopic properties from a hysteresis loop

  • mammos_analysis.kuzmin contains fuctions to estimate micromagnetic properties from (atomistic) M(T) data using Kuz’min equations.

import mammos_analysis
import mammos_entity as me
import mammos_units as u
import numpy as np
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:

H = me.H([-1e6, -0.8e6, -0.6e6, -0.5e6, -0.2e6, 0, 0.5e6, 1e6])
M = me.M([-1e6, -1e6, 1e6, 1e6, 1e6, 1e6, 1e6, 1e6])
plt.plot(H.q, M.q, "o-", linewidth=1)
plt.xlabel(H.axis_label)
plt.ylabel(M.axis_label)
Text(0, 0.5, 'Magnetization (A / m)')
../../_images/d5177193795a36697a9b3b6fe591d41a7a2c2989bfd859045574912e1814f787.png
extrinsic_properties = mammos_analysis.hysteresis.extrinsic_properties(
    H=H,
    M=M,
    demagnetization_coefficient=1 / 3,  # assumption: we have a cube
)
extrinsic_properties.Mr
Remanence(value=1000000.0, unit=A / m)
extrinsic_properties.Hc
CoercivityHcExternal(value=700000.0, unit=A / m)
extrinsic_properties.BHmax  # only available if we pass a demagnetization_coefficient, otherwise NaN
MaximumEnergyProduct(value=312763.00212764443, unit=N / m2)
plt.plot(H.q, M.q, ".-", -H.q, -M.q, "x-", linewidth=1)
plt.plot(0, extrinsic_properties.Mr.q, "cs", label="Mr")
plt.plot(extrinsic_properties.Hc.q, 0, "rD", label="Hc")
plt.xlabel(H.axis_label)
plt.ylabel(M.axis_label)
plt.legend()
<matplotlib.legend.Legend at 0x7f9e86202d50>
../../_images/d51d13226643f166fe5727a9d08497bf94efa0d592782391a24d46eb7373409a.png

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:

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.q, M.q, "o-", linewidth=1)
plt.xlabel(H.axis_label)
plt.ylabel(M.axis_label)
Text(0, 0.5, 'Magnetization (A / m)')
../../_images/0d4e75d8932c3dff5ab64fdd5efc9eb774043c46a9d684ae211d1b837bf6a085.png
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)
linear_segment_properties.plot()
<Axes: xlabel='External Magnetic Field (A / m)', ylabel='Magnetization (A / m)'>
../../_images/b06f79df1c73fb76005177a7563131f39d6de6adc0041513146534b8ca0e59d9.png

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:

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_quant = Ms_val * u.A / u.m
Ms = me.Ms(Ms_quant.to("kA/m"))
plt.plot(T.q, Ms.q, "o")
plt.xlabel(T.axis_label)
plt.ylabel(Ms.axis_label)
Text(0, 0.5, 'Spontaneous Magnetization (kA / m)')
../../_images/54a82b0e105b94acd8bb6fbaead7b5a2853314dc219ebdba03d9edf4f1ee5c85.png
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:

kuzmin_result.plot()
array([<Axes: xlabel='Thermodynamic Temperature (K)', ylabel='Spontaneous Magnetization (kA / 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)
../../_images/b4b12c11f027d7ac5661b1a1659326830617302716d3d932913f2397a02d7d98.png
kuzmin_result.Ms.plot()
plt.plot(T.q, Ms.q, "o")
[<matplotlib.lines.Line2D at 0x7f9ebc4bc6d0>]
../../_images/294d1fd83dbf856068721e6751554a3fd9d29867a8a4987461cfe741a5463695.png

We can also generate these plots using temperature in degree Celsius by using the celsius argument:

kuzmin_result.plot(celsius=True);
../../_images/16f42ac9edaa4264123517bc3f8b536d14616c62d5d7f07d0a59acf44cfab61a.png

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.

kuzmin_result
KuzminResult(Ms=Ms(T), A=A(T), Tc=Entity(ontology_label='CurieTemperature', value=505.2631528213887, unit='K'), s=<Quantity 2.4534165>, 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:

kuzmin_result.Ms(me.T(0))
SpontaneousMagnetization(value=1118.0339887498951, unit=kA / m)
kuzmin_result.A(100 * u.K)
ExchangeStiffnessConstant(value=2.049375704183663e-12, unit=J / m)
kuzmin_result.K1(300)
UniaxialAnisotropyConstant(value=27234.489224682686, unit=J / m3)

We can also use an array to get data for multiple temperatures:

kuzmin_result.Ms(me.T([0, 100, 200, 300]))
SpontaneousMagnetization(value=[1118.03398875 1041.90028122  906.08222136  724.70526759], unit=kA / m)