mammos_mumag.materials#

Materials class.

Functions

read_krn(fname)

Read material krn file and return as list of dictionaries.

read_yaml(fname)

Read material yaml file.

Classes

MaterialDomain([theta, phi, K1, K2, Ms, A])

Uniform material domain.

Materials([domains, filepath])

This class stores, reads, and writes material parameters.

class mammos_mumag.materials.MaterialDomain(theta=0.0, phi=0.0, K1=<factory>, K2=<factory>, Ms=<factory>, A=<factory>)[source]#

Uniform material domain.

It collects material parameters, constant in a certain domain.

Parameters:
A: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=Entity)#

Exchange stiffness constant in \(\mathrm{J}/\mathrm{m}\).

K1: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=Entity)#

First magnetocrystalline anisotropy constant in \(\mathrm{J}/\mathrm{m}^3\).

K2: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=Entity)#

Second magnetocrystalline anisotropy constant in \(\mathrm{J}/\mathrm{m}^3\).

Ms: Entity = FieldInfo(annotation=NoneType, required=False, default_factory=Entity)#

Spontaneous magnetisation in \(\mathrm{A}/\mathrm{m}\).

phi: float = 0.0#

Angle of the magnetocrystalline anisotropy axis from the \(x\)-direction in radians.

theta: float = 0.0#

Angle of the magnetocrystalline anisotropy axis from the \(z\)-direction in radians.

class mammos_mumag.materials.Materials(domains=<factory>, filepath=None)[source]#

This class stores, reads, and writes material parameters.

Parameters:
add_domain(A, Ms, K1, K2, phi, theta)[source]#

Append domain with specified parameters.

Parameters:
  • A (float) – Exchange stiffness constant in \(\mathrm{J}/\mathrm{m}\).

  • Ms (float) – Spontaneous magnetisation in \(\mathrm{T}\).

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

  • K2 (float) – Second magnetocrystalline anisotropy constant in \(\mathrm{J}/\mathrm{m}^3\).

  • phi (float) – Angle of the magnetocrystalline anisotropy axis from the \(x\)-direction in radians.

  • theta (float) – Angle of the magnetocrystalline anisotropy axis from the \(z\)-direction in radians.

Return type:

None

Examples

>>> from mammos_mumag.materials import Materials
>>> mat = Materials()
>>> mat.add_domain(A=1, Ms=2, K1=3, K2=0, phi=0, theta=0)
>>> mat
Materials(domains=[MaterialDomain(theta=..., phi=..., K1=..., K2=..., Ms=..., A=...)])
domains: list[MaterialDomain] = FieldInfo(annotation=NoneType, required=False, default_factory=list)#

Each domain is a MaterialDomain class of material parameters, constant in each region.

filepath: Path | None = None#

Material file path.

read(fname)[source]#

Read materials file.

This function overwrites the current domains attribute.

Currently accepted formats: krn and yaml.

Parameters:

fname (str | Path) – File name.

Raises:

NotImplementedError – Wrong file format.

Return type:

None

write_krn(fname)[source]#

Write material krn file.

Each domain in domains is written on a single line with spaces as separators.

Parameters:

fname (str | Path) – File path

Return type:

None

write_yaml(fname)[source]#

Write material yaml file.

Parameters:

fname (str | Path) – File path

Return type:

None

mammos_mumag.materials.read_krn(fname)[source]#

Read material krn file and return as list of dictionaries.

Parameters:

fname (str | Path) – File path

Returns:

Domains as list of dictionaries, with each dictionary defining the material constant in a specific region.

Return type:

list[MaterialDomain]

mammos_mumag.materials.read_yaml(fname)[source]#

Read material yaml file.

Parameters:

fname (str | Path) – File path

Returns:

Domains as list of dictionaries, with each dictionary defining the material constant in a specific region.

Return type:

list[MaterialDomain]