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.

Parameters:

out (Path | str) – Output directory containing temperature sweeps and 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:

RunData or TemperatureSweepData satisfying given filters.

Raises:
  • LookupError – No run has been found satisfying all filters.

  • LookupError – Too many results have been found.

Return type:

RunData | TemperatureSweepData

info(include_description=True, include_time_elapsed=True, include_parameters=True)[source]#

Return a Dataframe containing information about all available UppASD runs.

Parameters:
  • include_description (bool) – Whether to include the description in the dataframe columns.

  • include_time_elapsed (bool) – Whether to include elapsed time in the dataframe columns.

  • include_parameters (bool) – Whether to include the run parameters in the dataframe columns.

Returns:

Dataframe with relevant information.

Return type:

DataFrame

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 E: Entity#

Get energy.

Returns:

Entity Energy in Joule.

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.

property U_binder: float#

Get U_binder coefficient.

Returns:

Binder coefficient.

__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.*.out file.

Returns:

Path of file containing magnetic information.

Raises:
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:
  • include_description (bool) – Whether to include the description in the dataframe columns.

  • include_time_elapsed (bool) – Whether to include elapsed time in the dataframe columns.

  • include_parameters (bool) – Whether to include the run parameters in the dataframe columns.

Returns:

Dataframe with relevant information.

Return type:

DataFrame

property inpsd: Path#

Get path of inpsd.dat input 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:
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() or temperature_sweep(). A list of required parameters can be obtained from required_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() or Simulation.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.

Return type:

tuple[str, dict[str, Path]]

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>-run inside 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>-run and <some-index>-temperature_sweep directories 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 T is supported, which will be used to set both ip_temp and temp. Passing both T and (at least) one of ip_temp or temp is 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:

RunData

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_temp and temp.

  • out (str | Path) – Base directory for the output. A new directory <index>-temperature_sweep will be created inside, the logic is equivalent to Simulation.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 options ip_temp and temp cannot be used as instead T is required.

Returns:

An object to access UppASD outputs.

Return type:

TemperatureSweepData

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 E: Entity#

Get energy.

Returns:

1D array Entity Energy in Joule.

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.

__init__(out)[source]#

Initialize TemperatureSweepData given the directory path of a sweep run.

Parameters:

out (Path | str) – Output directory containing the sweep output.

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:

RunData satisfying given filters.

Raises:
  • LookupError – No run has been found satisfying all filters.

  • LookupError – Too many results have been found.

Return type:

RunData

info(include_description=True, include_time_elapsed=True, include_parameters=True)[source]#

Return a Dataframe containing information about the temperature sweep.

Parameters:
  • include_description (bool) – Whether to include the description in the dataframe columns.

  • include_time_elapsed (bool) – Whether to include elapsed time in the dataframe columns.

  • include_parameters (bool) – Whether to include the run parameters in the dataframe columns.

Returns:

Dataframe with relevant information.

Return type:

DataFrame

save_output(out)[source]#

Save output files M(T) and output.csv in directory out.

M(T) contains all information evaluated from the cumulant files. output.csv contains entities for information temperature, magnetization, Binder cumulant and heat capacity.

Parameters:

out (Path | str) – Directory location where to save output files.

Return type:

None

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:

out (Path | str) – Output directory to read.

Returns:

Relevant Data object based on the content of the given directory.

Return type:

MammosUppasdData | RunData | TemperatureSweepData