mammos_spindynamics.uppasd#
Module for interfacing with UppASD.
- class mammos_spindynamics.uppasd.MammosUppasdData[source]#
Collection of UppASD Result instances.
This class collects all temperature sweeps and runs executed in the output directory specified by the path attribute.
- out#
Output directory containing temperature sweeps and runs.
- __init__(out)[source]#
Initialize MammosUppasdData given the directory containing all runs.
Examples
>>> from mammos_spindynamics.uppasd import MammosUppasdData >>> MammosUppasdData("Fe3Y") MammosUppasdData('Fe3Y')
- get(**kwargs)[source]#
Select run based on different filters specified as keyword arguments.
Exceptions are raised if the filters give no match or too many matches.
- Parameters:
**kwargs – Keys are the names to filter on, values must match exactly.
- Returns:
RunDataorTemperatureSweepDatasatisfying given filters.- Raises:
LookupError – No run has been found satisfying all filters.
LookupError – Too many results have been found.
- Return type:
- class mammos_spindynamics.uppasd.RunData[source]#
UppASD Data parser class for a single run.
- out#
Output directory containing the run output.
- metadata#
Dictionary of the run metadata.
- parameters#
Dictionary of the run parameters.
- property Cv: Entity#
Get specific heat capacity at constant volume.
- Returns:
Entity IsochoricHeatCapacity in Joule per Kelvin.
- property Ms: Entity#
Get spontaneous magnetization of the run.
- Returns:
Entity Spontaneous Magnetization in Ampere per meter.
- property T: Entity#
Get temperature of the run.
- Returns:
Entity Thermodynamic Temperature in Kelvin.
- __init__(out)[source]#
Initialize RunData given the directory path of a single run.
- Parameters:
out (Path) – Output directory containing the run output.
- property cumulants: Path#
Get
cumulants.*.outfile.- Returns:
Path of file containing magnetic information.
- Raises:
RuntimeError – Could not find the cumulants file.
RuntimeError – More than one cumulants file were found.
- property exchange: Path#
Get path of file containing exchange interactions.
- Returns:
Path of file defining exchange interactions.
- info(include_description=True, include_time_elapsed=True, include_parameters=True)[source]#
Return a Dataframe containing information about the UppASD run.
- Parameters:
- Returns:
Dataframe with relevant information.
- Return type:
- property inpsd: Path#
Get path of
inpsd.datinput file.- Returns:
Path of input file defining simulation parameters.
- property momfile: Path#
Get path of file containing magnetic moments.
- Returns:
Path of file defining magnetic moments.
- property n_magnetic_atoms: int#
Get number of magnetic atoms.
- Returns:
Number of magnetic atoms as defined in the
momfile.
- property posfile: Path#
Get path of file containing atomic positions.
- Returns:
Path of file defining atomic positions.
- property restartfile: Path#
Get path of restart file.
- Returns:
Path of restart file for consecutive runs.
- Raises:
RuntimeError – Could not find the restart file.
RuntimeError – More than one restart file were found.
- class mammos_spindynamics.uppasd.Simulation[source]#
Class to perform UppASD simulations.
Simulations can be performed without or with existing inpsd.dat file:
If no inpsd.dat file is passed the simulation object will use an internal template to create a new inpsd.dat file. This template requires a number of parameters, which have to be passed by the user either when creating the simulation object, or when calling
run()ortemperature_sweep(). A list of required parameters can be obtained fromrequired_parameters().If an inpsd.dat file is passed most of its lines can be modified by passing a new value for a parameters as keyword argument. It is not possible to overwrite
ip_mcanneal.
- __init__(inpsd=None, **kwargs)[source]#
Create a new simulation object with an inpsd.dat file and/or parameters.
- Parameters:
inpsd (Path | str | None) – Optional path to an existing inpsd.dat file. If not passed a default template defined in the Simulation class is used.
kwargs – Parameters to use (or overwrite when passing inpsd) in inpsd.dat. Parameters can also be passed when calling
Simulation.run()orSimulation.temperature_sweep().
- property allowed_parameters#
UppASD inpsd parameters that can be passed without a custom inpsd file.
- create_input_files(**kwargs)[source]#
Create input files required for UppASD: inpsd.dat and auxilary files.
This method creates the content for inpsd.dat and collects auxiliary files posfile, momfile, exchange, and optionally restartfile. Other external files are not supported.
If no custom inpsd.dat file is used, a predefined template will be used. The user has to pass all required template arguments either at object creation time or when calling this method. A list of required arguments can be obtained from
Simulation.required_parameters().If a custom inpsd.dat file is used, the user has the option to overwrite lines in that input files by passing the respective keys and new values. Not all options in inpsd.dat are currently supported, in particular ip_mcanneal cannot be used.
The auxiliary files have hard-coded names in inpsd.dat, when passing a custom inpsd.dat the corresponding lines will be modified (trailing comments are lost). The dict returned as second object maps names used in the inpsd.dat file to original file paths.
- property required_parameters#
UppASD inpsd parameters that must be passed without a custom inpsd file.
- run(out, description='', uppasd_executable='uppasd', verbosity=1, **kwargs)[source]#
Run a single UppASD simulation.
This method creates inputs required for UppASD in a new directory, runs UppASD in that directory and returns an object that allows accessing the resulting data.
- Parameters:
out (str | Path) – Base directory in which the output is stored. The method will create a subdirectory
<index>-runinside that directory. The value of<index>depends on the existing directory content. For empty directories<index>=0. Otherwise, the method will search for all existing<some-index>-runand<some-index>-temperature_sweepdirectories and use the next index.description (str) – Human-readable description of this simulation run, stored as metadata.
uppasd_executable (str | Path) – Name or path to UppASD executable. If provided a name the method will search for the executable on PATH.
verbosity (int) –
Verbosity of the run:
0: no output
1: summary line with status information (output directory, runtime)
kwargs –
UppASD arguments to use in the inpsd.dat file, including paths to files for momfile, posfile, and exchange. Further details are explained in
Simulation.create_input_files().In addition a special argument
Tis supported, which will be used to set bothip_tempandtemp. Passing bothTand (at least) one ofip_temportempis not supported.Parameters passed to run instead of at object creation time are recorded as separate metadata and can be used later on to conveniently retrieve simulation results.
- Returns:
An object to access UppASD outputs.
- Return type:
- temperature_sweep(T, out, restart_with_previous=True, description='', uppasd_executable='uppasd', verbosity=2, **kwargs)[source]#
Run temperature sweep.
This method runs consecutive simulations for multiple temperatures. For each temperature it will call
Simulation.run()internally. The method does not sort the temperatures, so make sure you pass the desired order, in particular when using restart_with_previous=True.After finishing all simulations two additional files M(T) and output.csv with aggregated simulation results are created.
- Parameters:
T (Iterable[Real]) – Temperatures in Kelvin to run the simulation for. The value will be used for both
ip_tempandtemp.out (str | Path) – Base directory for the output. A new directory
<index>-temperature_sweepwill be created inside, the logic is equivalent toSimulation.run().restart_with_previous (bool) – If set to True use the restart file from the previous run as initial configuration for all but the first run in the sweep.
description (str) – Human-readable description of the sweep, the individual runs do not have a description.
uppasd_executable (str | Path) – Name or path to UppASD executable, like in
Simulation.run().verbosity (int) –
Verbosity of the sweep:
0: no output
1: only summary output for the whole sweep (number and list of temperatures)
2: summary for the sweep and summary for each run (verbosity 1 for each run)
kwargs – UppASD arguments in inpsd.dat as in
Simulation.run(). The two optionsip_tempandtempcannot be used as insteadTis required.
- Returns:
An object to access UppASD outputs.
- Return type:
- class mammos_spindynamics.uppasd.TemperatureSweepData[source]#
UppASD Data parser for a temperature sweep.
A temperature sweep is a sequence of runs with changing temperature and possibly other simulation parameters.
- out#
Output directory containing the sweep output.
- metadata#
Dictionary of the sweep metadata.
- parameters#
Dictionary of the sweep parameters.
- property Cv: Entity#
Get specific heat capacity at constant volume.
For a temperature sweep the heat capacity Cv is evaluated as the derivative of the energy as a function of temperature.
- Returns:
1D array Entity IsochoricHeatCapacity in Joule per Kelvin.
- property Ms: Entity#
Get array of spontaneous magnetization of the sweep.
- Returns:
1D array Entity SpontaneousMagnetization in Kelvin.
- property T: Entity#
Get array of temperatures of the sweep.
- Returns:
1D array Entity ThermodynamicTemperature in Kelvin.
- property U_binder: ndarray#
Get array of Binder coefficients.
- Returns:
Array of Binder coefficients.
- get(**kwargs)[source]#
Select run based on different filters specified as keyword arguments.
Exceptions are raised if the filters give no match or too many matches.
- Parameters:
**kwargs – Keys are the names to filter on, values must match exactly.
- Returns:
RunDatasatisfying given filters.- Raises:
LookupError – No run has been found satisfying all filters.
LookupError – Too many results have been found.
- Return type:
- info(include_description=True, include_time_elapsed=True, include_parameters=True)[source]#
Return a Dataframe containing information about the temperature sweep.
- Parameters:
- Returns:
Dataframe with relevant information.
- Return type:
- mammos_spindynamics.uppasd.read(out)[source]#
Read UppASD calculations results directory.
This function returns different classes based on the content of the mammos_spindynamics.yaml generated from the execution of UppASD via the mammos_spindynamics Python library.
- Parameters:
- Returns:
Relevant Data object based on the content of the given directory.
- Return type: