mattertune.wrappers.ase_calculator

Classes

MatterTuneCalculator(property_predictor)

class mattertune.wrappers.ase_calculator.MatterTuneCalculator(property_predictor)[source]
Parameters:

property_predictor (MatterTunePropertyPredictor)

__init__(property_predictor)[source]

Basic calculator implementation.

restart: str

Prefix for restart file. May contain a directory. Default is None: don’t restart.

ignore_bad_restart_file: bool

Deprecated, please do not use. Passing more than one positional argument to Calculator() is deprecated and will stop working in the future. Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.

directory: str or PurePath

Working directory in which to read and write files and perform calculations.

label: str

Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.

atoms: Atoms object

Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.

Parameters:

property_predictor (MatterTunePropertyPredictor)

calculate(atoms=None, properties=None, system_changes=None)[source]

Calculate properties for the given atoms object using the MatterTune property predictor. This method implements the calculation of properties like energy, forces, etc. for an ASE Atoms object using the underlying MatterTune property predictor. It converts between ASE and MatterTune property names and handles proper type conversions of the predicted values.

Parameters:
  • atoms (Atoms | None, optional) – ASE Atoms object to calculate properties for. If None, uses previously set atoms. Defaults to None.

  • properties (list[str] | None, optional) – List of properties to calculate. If None, calculates all implemented properties. Defaults to None.

  • system_changes (list[str] | None, optional) – List of changes made to the system since last calculation. Used by ASE for caching. Defaults to None.

Notes

  • The method first ensures atoms and property names are properly set

  • Makes predictions using the MatterTune property predictor

  • Converts predictions from PyTorch tensors to appropriate numpy types

  • Maps MatterTune property names to ASE calculator property names

  • Stores results in the calculator’s results dictionary

Raises:

AssertionError – If atoms is not set properly or if predictions are not in expected format

Parameters:
  • atoms (Atoms | None)

  • properties (list[str] | None)

  • system_changes (list[str] | None)