mammos_spindynamics.uppasd#

Module for interfacing with UppASD.

class mammos_spindynamics.uppasd.MammosUppasdData(out)[source]#

Collection of UppASD Result instances.

Initialize MammosUppasdData given the directory containing all runs.

Parameters:

out (pathlib.Path | str)

get(**kwargs)[source]#

Extract run based on different filters.

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

Dataframe containing information about all available UppASD runs.

Parameters:
  • include_description (bool)

  • include_time_elapsed (bool)

  • include_parameters (bool)

Return type:

pandas.DataFrame

class mammos_spindynamics.uppasd.RunData(out)[source]#

UppASD Data parser class for a single run.

Initialize Data given the output directory of a single run.

Parameters:

out (pathlib.Path)

property Cv: mammos_entity.Entity#

Get specific heat capacity.

property E: mammos_entity.Entity#

Get energy.

property Ms: mammos_entity.Entity#

Get Spontaneous Magnetization.

property T: float#

Get Thermodynamics Temperature.

property U_binder: float#

Get U_binder value.

property cumulants: Path#

Get cumulants.*.out file.

property exchange: Path#

Get path of file containing exchange interactions.

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

Return information about the UppASD run.

Parameters:
  • include_description (bool)

  • include_time_elapsed (bool)

  • include_parameters (bool)

Return type:

pandas.DataFrame

property inpsd: Path#

Get path of inpsd.dat input file.

property momfile: Path#

Get path of file containing magnetic moments.

property n_magnetic_atoms: int#

Get number of magnetic atoms.

property posfile: Path#

Get path of file containing atomic positions.

property restartfile: Path#

Get path of restart file.

class mammos_spindynamics.uppasd.Simulation(inpsd=None, **kwargs)[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.

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(out)[source]#

Class for the result of the temperature_array runner.

Initialize TemperatureSweepData given the output directory of a sweep run.

Parameters:

out (pathlib.Path | str)

property Cv: mammos_entity.Entity#

Get Isochoric Heat Capacity.

The isochorich (at constant volume) heat capacity Cv is evaluated as the derivative of the energy as a function of temperature.

property E: mammos_entity.Entity#

Get Energy.

property Ms: mammos_entity.Entity#

Get Spontaneous Magnetization.

property T: mammos_entity.Entity#

Get Thermodynamics Temperature.

property U_binder: numpy.ndarray#

Get Binder coefficient.

get(**kwargs)[source]#

Select run satisfying certain filters defined in the keyword arguments.

If there are multiple matches, it returns the first one.

Return type:

RunData

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

Dataframe containing information about all available UppASD runs.

Parameters:
  • include_description (bool)

  • include_time_elapsed (bool)

  • include_parameters (bool)

Return type:

pandas.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)

Return type:

None

mammos_spindynamics.uppasd.read(out)[source]#

Read UppASD calculations results directory.

Parameters:

out (Path | str)

Return type:

MammosUppasdData | RunData | TemperatureSweepData