llg3d.parameters

Parameters for the simulation.

The RunParameters dataclass defines all the parameters for the simulation, along with their types, default values, and help text.

The arg_parameters dictionary is generated from the dataclass fields and is used to create the command-line interface for the simulation.

Adding a new parameter is as simple as adding a new field to the RunParameters class with appropriate metadata:

  • this field will be accessible as attribute to all llg3d.solvers classes

  • the arg_parameters will be automatically updated to include the new parameter in the CLI.

Module Attributes

arg_parameters

simulation CLI parameters

Functions

lit_to_list(lit)

Convert a Literal type to a list of its possible values.

Classes

ArgParameter

Metadata for a simulation parameter.

RunParameters([element, N, dt, Jx, Jy, Jz, ...])

Store simulation parameters.

class RunParameters(element='Cobalt', N=5000, dt=1e-14, Jx=300, Jy=21, Jz=21, dx=1e-09, T=0.0, H_ext=0.0, init_type='0', result_file='run.npz', start_averaging=4000, n_mean=1, n_profile=0, solver=<factory>, precision='double', blocking=False, seed=12345, device='auto', profiling=False, verbosity='INFO', np=<factory>, geometry='periodic_wire')[source]

Bases: object

Store simulation parameters.

Example

>>> params = RunParameters(element="Cobalt", N=1000)
>>> print(params)
element         : Cobalt
N               = 1000
dt              = 1e-14
Jx              = 300
Jy              = 21
Jz              = 21
dx              = 1e-09
T               = 1100
H_ext           = 0.0
init_type       : 0
result_file     : run.npz
start_averaging = 2000
n_mean          = 1
n_profile       = 0
solver          : numpy
precision       : double
blocking        = False
seed            = 12345
device          : auto
profiling       = False
verbosity       : INFO
np              = 1
Parameters:
  • element (Literal['Cobalt', 'Iron', 'Nickel'])

  • N (int)

  • dt (float)

  • Jx (int)

  • Jy (int)

  • Jz (int)

  • dx (float)

  • T (float)

  • H_ext (float)

  • init_type (Literal['0', 'dw', 'double_dw'])

  • result_file (str)

  • start_averaging (int)

  • n_mean (int)

  • n_profile (int)

  • solver (Literal['opencl', 'mpi', 'numpy', 'jax'])

  • precision (Literal['single', 'double'])

  • blocking (bool)

  • seed (int)

  • device (Literal['cpu', 'gpu', 'auto'])

  • profiling (bool)

  • verbosity (Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'])

  • np (int)

  • geometry (Literal['finite_box', 'periodic_wire', 'periodic_layer', 'periodic_box'])

element: Literal['Cobalt', 'Iron', 'Nickel'] = 'Cobalt'

Chemical element of the sample

N: int = 5000

Number of iterations

dt: float = 1e-14

Time step

Jx: int = 300

Number of points in x

Jy: int = 21

Number of points in y

Jz: int = 21

Number of points in z

dx: float = 1e-09

Step in x

T: float = 0.0

Temperature (K)

H_ext: float = 0.0

External field (A/m)

init_type: Literal['0', 'dw', 'double_dw'] = '0'

Initialization type

result_file: str = 'run.npz'

Result file name

start_averaging: int = 4000

Start index of time average

n_mean: int = 1

Spatial average frequency (number of iterations)

n_profile: int = 0

x-profile save frequency (number of iterations)

solver: Literal['opencl', 'mpi', 'numpy', 'jax']

Solver to use

precision: Literal['single', 'double'] = 'double'

Precision of the simulation

blocking: bool = False

Use blocking communications

seed: int = 12345

Random seed for temperature fluctuations

device: Literal['cpu', 'gpu', 'auto'] = 'auto'

Device to use

profiling: bool = False

Enable profiling output

verbosity: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] = 'INFO'

Logging verbosity level

np: int

Number of processes (for MPI solver)

geometry: Literal['finite_box', 'periodic_wire', 'periodic_layer', 'periodic_box'] = 'periodic_wire'

Sample geometry (determines PBC directions)

as_dict()[source]

Convert RunParameters to a dictionary.

Returns:

Dictionary representation of the parameters

Return type:

dict[str, Any]

class ArgParameter[source]

Bases: TypedDict

Metadata for a simulation parameter.

lit_to_list(lit)[source]

Convert a Literal type to a list of its possible values.

Parameters:

lit (Any) – Literal type

Returns:

List of possible values

Return type:

list[Any]

_generate_arg_parameters()[source]

Generate arg_parameters from RunParameters fields metadata.

Returns:

Dictionary of argument parameters for CLI

Return type:

dict[str, ArgParameter]

arg_parameters: dict[str, ArgParameter] = {'H_ext': {'default': 0.0, 'help': 'External field (A/m)'}, 'Jx': {'default': 300, 'help': 'Number of points in x'}, 'Jy': {'default': 21, 'help': 'Number of points in y'}, 'Jz': {'default': 21, 'help': 'Number of points in z'}, 'N': {'default': 5000, 'help': 'Number of time iterations'}, 'T': {'default': 0.0, 'help': 'Temperature (K)'}, 'blocking': {'action': 'store_true', 'default': False, 'help': 'Use blocking communications (MPI solver only)'}, 'device': {'choices': ['cpu', 'gpu', 'auto'], 'default': 'auto', 'help': 'Device to use by the OpenCL solver'}, 'dt': {'default': 1e-14, 'help': 'Time step'}, 'dx': {'default': 1e-09, 'help': 'Step in x'}, 'element': {'choices': ['Cobalt', 'Iron', 'Nickel'], 'default': 'Cobalt', 'help': 'Chemical element of the sample'}, 'geometry': {'choices': ['finite_box', 'periodic_wire', 'periodic_layer', 'periodic_box'], 'default': 'periodic_wire', 'help': "Sample geometry: 'finite_box' (Neumann x/y/z), 'periodic_wire' (PBC x, Neumann y/z), 'periodic_layer' (PBC x/y, Neumann z), 'periodic_box' (PBC x/y/z)"}, 'init_type': {'choices': ['0', 'dw', 'double_dw'], 'default': '0', 'help': "Type of initialization ('0' for uniform, 'dw' for domain wall)"}, 'n_mean': {'default': 1, 'help': 'Spatial average frequency (number of iterations)'}, 'n_profile': {'default': 0, 'help': 'x-profile save frequency (number of iterations)'}, 'np': {'default': 1, 'help': 'Number of processes (for MPI solver)'}, 'precision': {'choices': ['single', 'double'], 'default': 'double', 'help': 'Precision of the floating point (single or double)'}, 'profiling': {'action': 'store_true', 'default': False, 'help': 'Enable profiling output (internal profiler)'}, 'result_file': {'default': 'run.npz', 'help': 'Name of the npz result file'}, 'seed': {'default': 12345, 'help': 'Random seed for temperature fluctuations', 'type': <class 'int'>}, 'solver': {'choices': ['opencl', 'mpi', 'numpy', 'jax'], 'default': 'numpy', 'help': 'Solver to use for the simulation'}, 'start_averaging': {'default': 4000, 'help': 'Start index of time average'}, 'verbosity': {'choices': ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], 'default': 'INFO', 'help': 'Logging verbosity level'}}

simulation CLI parameters