mammos_mumag.parameters#

Parameters class.

Classes

Parameters([size, scale, state, h_mag_on, ...])

Class storing simulation parameters.

class mammos_mumag.parameters.Parameters(size=1e-09, scale=0.0, state=<factory>, h_mag_on=True, h_start=<factory>, h_final=<factory>, h_step=<factory>, h_vect=<factory>, m_step=<factory>, m_final=<factory>, m_vect=<factory>, precond_iter=10, tol_fun=1e-10, tol_h_mag_factor=1.0, filepath=None)[source]#

Class storing simulation parameters.

Parameters:
  • size (float) – Size of the mesh. This factor usually indicates the magnitude of the geometry, i.e., 1e-9 for nanometer meshes, 1e-9 for micrometer, etc.

  • scale (float) – Scale of the mesh. This factor can include other scaling, so that the total scale of the mesh is size * scale.

  • state (str) – Name of the initial magnetization state. Scripts recognize the strings flower, vortex, twisted, and random. Other strings are interpreted as the default case. The default case is a uniformly magnetized state.

  • h_mag_on (bool) – Whether the external field is on (True) or off (False).

  • h_start (Entity) – Strength of the external field that the hysteresis loop starts from.

  • h_final (Entity) – Strength of the external field that the hysteresis loop finishes at.

  • h_step (Entity) – Difference in field strength between two hysteresis loop measurements.

  • h_vect (Entity) – External field vector \(\mathbf{h}\) as a list of floats or a Vector entity. This vector is not necessarily normal. The property h will be the normalized field. If not defined, the external field is zero.

  • m_step (Entity) – Threshold at which the magnetization is saved. If in the hysteresis calculation the difference between two consecutive values of magnetization along the external field vector is bigger than this value, a new configuration index will appear on the output csv table. Different configurations mean that the magnetization is behaving differently, possibly changing states.

  • m_final (Entity) – Value of magnetization (along the external field direction) at which the hysteresis calculation will stop.

  • m_vect (Entity) – Magnetization field \(\mathbf{m}\) as a list of floats or a Vector entity.

  • precond_iter (int) – Conjugate gradient iterations for inverse Hessian approximation.

  • tol_fun (float) – Total energy tolerance to obtain the equilibrium configuration.

  • tol_h_mag_factor (float) – Factor defining the tolerance for the magnetostatic scalar potential according to the formula tol_u = tol_fun * tol_h_mag_factor.

  • filepath (Path | None) – Path of parameter file to read at initialization. In this case all other parameters will be overwritten (if specified in the parameter file).

filepath: Path | None = None#
property h: list[float]#

Direction of the external field.

h_final: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
h_mag_on: bool = True#
h_start: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
h_step: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
h_vect: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
property m: list[float]#

Normalized magnetization.

m_final: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
m_step: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
m_vect: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
precond_iter: int = 10#
read(fname)[source]#

Read parameter file.

Parameters:

fname (str | Path) – File path

Raises:

NotImplementedError – Wrong file format.

Return type:

None

read_p2(fpath)[source]#

Read parameter file in p2 format.

The speciality of this file format is that magnetization values are stored in Tesla for readability. Hence, they need to be converted to A/m first. Furthermore, in this format some of the names have a special formatting.

Parameters:

fpath (str | Path) – Parameter file path.

Return type:

None

read_yaml(fpath)[source]#

Read parameter file in yaml format.

We expect the parameters to be saved using the module mammos_entity.io and use the function mammos_entity.io.entities_from_file().

Parameters:

fpath (str | Path) – Parameter file path.

Return type:

None

scale: float = 0.0#
size: float = 1e-09#
state: str = FieldInfo(annotation=NoneType, required=False, default_factory=<lambda>)#
tol_fun: float = 1e-10#
tol_h_mag_factor: float = 1.0#
write_p2(fname)[source]#

Write parameter p2 file.

Parameters:

fname (str | Path) – File path

Return type:

None

Examples

>>> from mammos_mumag.parameters import Parameters
>>> par = Parameters()
>>> par.write_p2("parameters.p2")
write_yaml(fname)[source]#

Write parameter yaml file.

Parameters:

fname (str | Path) – File path

Return type:

None

Examples

>>> from mammos_mumag.parameters import Parameters
>>> par = Parameters()
>>> par.write_yaml("parameters.yaml")