mammos_mumag.hysteresis#

Functions for evaluating and processin the hysteresis loop.

Functions

read_result(outdir[, name])

Read hysteresis loop output from directory.

run(Ms, A, K1, mesh, hstart, hfinal[, ...])

Run hysteresis loop.

Classes

Result(H, M, Mx, My, Mz[, energy_density, ...])

Hysteresis loop Result.

class mammos_mumag.hysteresis.Result(H, M, Mx, My, Mz, energy_density=None, configuration_type=None, configurations=None)[source]#

Hysteresis loop Result.

Parameters:
H: Entity#

Array of external field strengths.

M: Entity#

Array of spontaneous magnetization values for the field strengths in the direction of H.

Mx: Entity#

Component x of the spontaneous magnetization.

My: Entity#

Component y of the spontaneous magnetization.

Mz: Entity#

Component z of the spontaneous magnetization.

configuration_type: ndarray | None = None#

Array of indices of representative configurations for the field strengths.

configurations: dict[int, Path] | None = None#

Mapping of configuration indices to file paths.

property dataframe: DataFrame#

Dataframe containing the result data of the hysteresis loop.

energy_density: Entity | None = None#

Array of energy densities for the field strengths.

plot(duplicate=True, duplicate_change_color=True, configuration_marks=False, ax=None, label=None, **kwargs)[source]#

Plot hysteresis loop.

Parameters:
  • duplicate (bool) – Also plot loop with -M and -H to simulate full hysteresis.

  • duplicate_change_color (bool) – If set to false use the same color for both branches of the hysteresis plot.

  • configuration_marks (bool) – Show markers where a configuration has been saved.

  • ax (matplotlib.axes.Axes | None) – Matplotlib axes object to which the plot is added. A new one is create if not passed.

  • label (str | None) – Label shown in the legend. A legend is automatically added to the plot if this argument is not None.

  • kwargs – Additional keyword arguments passed to ax.plot when plotting the hysteresis lines.

Returns:

The matplotlib.axes.Axes object which was used to plot the hysteresis loop

Return type:

matplotlib.axes.Axes

plot_configuration(idx, jupyter_backend='trame', plotter=None)[source]#

Plot configuration with index idx.

This method does only directly show the plot if no plotter is passed in. Otherwise, the caller must call plotter.show() separately. This behavior is based on the assumption that the user will want to further modify the plot before displaying/saving it when passing a plotter.

Parameters:
  • idx (int) – Index of the configuration.

  • jupyter_backend (str) – Plotting backend.

  • plotter (pyvista.Plotter | None) – Pyvista plotter to which glyphs will be added. A new plotter is created if no plotter is passed.

Return type:

None

mammos_mumag.hysteresis.read_result(outdir, name='out')[source]#

Read hysteresis loop output from directory.

Parameters:
  • outdir (str | pathlib.Path) – Path of output directory where the results of the hysteresis loop are stored.

  • name (str) – System name with which the loop output files are stored.

Returns:

Result object.

Raises:

FileNotFoundError – hysteresis loop .dat file not found.

Return type:

mammos_mumag.hysteresis.Result

mammos_mumag.hysteresis.run(Ms, A, K1, mesh, hstart, hfinal, hstep=None, hnsteps=20, outdir='hystloop')[source]#

Run hysteresis loop.

Parameters:
  • Ms (float | u.Quantity | me.Entity) – Spontaneous magnetisation in \(\mathrm{A}/\mathrm{m}\).

  • A (float | u.Quantity | me.Entity) – Exchange stiffness constant in \(\mathrm{J}/\mathrm{m}\).

  • K1 (float | u.Quantity | me.Entity) – First magnetocrystalline anisotropy constant in \(\mathrm{J}/\mathrm{m}^3\).

  • mesh (mammos_mumag.mesh.Mesh | pathlib.Path | str) – The mesh can either be given as a Mesh instance (for meshes available through mammos_mumag) or its path can be specified. The only possible mesh format is .fly.

  • hstart (float | u.Quantity) – Initial strength of the external field.

  • hfinal (float | u.Quantity) – Final strength of the external field.

  • hstep (float | u.Quantity | None) – Step size.

  • hnsteps (int) – Number of steps in the field sweep.

  • outdir (str | pathlib.Path) – Directory where simulation results are written to.

Returns:

Result object.

Return type:

mammos_mumag.hysteresis.Result