Atomic Simulation Environment (ASE) integration#
- class metatensor.torch.atomistic.ase_calculator.MetatensorCalculator(model: str | bytes | PurePath | MetatensorAtomisticModel, check_consistency=False)[source]#
Bases:
Calculator
The
MetatensorCalculator
class implements ASE’sase.calculators.calculator.Calculator
API using metatensor atomistic models to compute energy, forces and any other supported property.This class can be initialized with any
MetatensorAtomisticModel
, and used to run simulations using ASE’s MD facilities.- Parameters:
model (str | bytes | PurePath | MetatensorAtomisticModel) – model to use for the calculation. This can be a file path, a Python instance of
MetatensorAtomisticModel
, or the output oftorch.jit.script()
onMetatensorAtomisticModel
.check_consistency – should we check the model for consistency when running, defaults to False.
- run_model(atoms: Atoms, outputs: Dict[str, ModelOutput], selected_atoms: Labels | None = None) Dict[str, TensorBlock] [source]#
Run the model on the given
atoms
, computing properties according to theoutputs
andselected_atoms
options.The output of the model is returned directly, and as such the blocks’
values
will betorch.Tensor
.This is intended as an easy way to run metatensor models on
ase.Atoms
when the model can predict properties not supported by the usual ASE’s calculator interface.- Parameters:
atoms (Atoms) –
outputs (Dict[str, ModelOutput]) –
selected_atoms (Labels | None) –
- Return type:
- calculate(atoms: Atoms, properties: List[str], system_changes: List[str]) Dict[str, ndarray] [source]#
Compute some
properties
with this calculator, and return them in the format expected by ASE.This is not intended to be called directly by users, but to be an implementation detail of
atoms.get_energy()
and related functions. Seease.calculators.calculator.Calculator.calculate()
for more information.