Skip to main content

Overview

MLIPCalculator combines MLIP (the PyTorch model wrapper) with ASE’s Calculator base class to produce a drop-in ASE calculator that can compute energies, forces, and stress for any Atoms object.

Inheritance

Implemented properties


Constructor

torch.nn.Module
required
The underlying PyTorch MLIP model. The model is moved to device during construction.
torch.device | None
default:"None"
Target compute device. When None, the device is selected automatically by get_freer_device() — see device selection below.
float
default:"6.0"
Neighbor-list cutoff radius in Angstroms. Passed to collate_fn when building the graph for each calculate call.
str | None
default:"None"
Path to a restart file. Forwarded to ase.calculators.calculator.Calculator.__init__.
ase.Atoms | None
default:"None"
Optional Atoms object to attach on construction. Forwarded to the ASE Calculator.
str | Path
default:"."
Working directory for file I/O. Forwarded to the ASE Calculator.
dict
default:"{}"
Extra keyword arguments forwarded verbatim to ase.calculators.calculator.Calculator.__init__.

calculate

Computes the requested properties for atoms and stores the results in self.results. Execution flow:
  1. Calls super().calculate(atoms, properties, system_changes) (ASE bookkeeping).
  2. Builds a batched graph via collate_fn([atoms], cutoff=self.cutoff) and moves it to self.device.
  3. Runs self.forward(data) to get model outputs.
  4. Extracts and stores results:
ase.Atoms
required
The atomic structure to evaluate.
list[string]
required
Subset of implemented_properties to compute. Accepted values: "energy", "forces", "stress".
list
default:"all_changes"
List of changes since the last calculation. Forwarded to the ASE base class to decide whether to recompute. Defaults to ase.calculators.calculator.all_changes.

Results stored in self.results

float
Total potential energy of the system in eV. Populated when "energy" is in properties.
numpy.ndarray, shape (N, 3)
Atomic forces in eV/Å. Populated when "forces" is in properties. Moved to CPU and detached before storing.
numpy.ndarray, shape (6,) or (3, 3)
Virial stress tensor in eV/ų (Voigt notation). Populated when "stress" is in properties. Moved to CPU and detached before storing.

Device selection

When device=None (the default), MLIPCalculator calls get_freer_device() from mlip_arena.models.utils to pick the best available device: You can always override this by passing an explicit device argument:

MLIPCalculator vs. external calculators

Some models in the registry wrap third-party calculator classes directly rather than subclassing MLIPCalculator. Use the following guidance:

Code example: using a calculator with ASE

Running a geometry optimisation