Models¶
Most of the code in metatensor.torch.atomistic
is here to define and export
models and to store model metadata. The corresponding classes are documented
below:
We also provide a couple of functions to work with the models:
- metatensor.torch.atomistic.load_atomistic_model(path, extensions_directory=None) MetatensorAtomisticModel [source]¶
Check and then load the metatensor atomistic model at the given path.
This function calls
metatensor.torch.atomistic.check_atomistic_model()
andmetatensor.torch.atomistic.load_model_extensions()
before attempting to load the model.- Parameters:
path – path to an exported metatensor model
extensions_directory – path to a directory containing all extensions required by the exported model
- Return type:
- metatensor.torch.atomistic.check_atomistic_model(path: str)[source]¶
Check that the file at
path
contains an exported metatensor atomistic model, and that this model can be loaded in the current process.This function should be called before
torch.jit.load()
when loading an existing model.- Parameters:
path (str) – path to the exported model file
- metatensor.torch.atomistic.load_model_extensions(path: str, extensions_directory: str | None = None)[source]¶
Load the TorchScript extensions (and their dependencies) that the model at
path
uses.If
extensions_directory
is provided, we look for the extensions and their dependencies in there first. If this function fails to load some library, it will produce a warning using Torch’s warnings infrastructure. Users can set theMETATENSOR_DEBUG_EXTENSIONS_LOADING
environment variable to get more informations about a failure in the standard error output.- Parameters:
path (str) – path to the exported model file
extensions_directory (str | None) – path to a directory containing the extensions. This directory will typically be created by calling
MetatensorAtomisticModel.export()
withcollect_extensions=extensions_directory
.
- metatensor.torch.atomistic.unit_conversion_factor(quantity: str, from_unit: str, to_unit: str)[source]¶
Get the multiplicative conversion factor from
from_unit
toto_unit
. Both units must be valid and known for the given physicalquantity
. The set of valid quantities and units is available here.
Known quantities and units¶
The following quantities and units can be used with metatensor models. Adding
new units and quantities is very easy, please contact us if you need something
else! In the mean time, you can create
metatensor.torch.atomistic.ModelOutput
with quantities that are not
in this table. A warning will be issued and no unit conversion will be
performed.
When working with one of the quantity in this table, the unit you use must be one of the registered unit.
quantity |
units |
---|---|
length |
angstrom (A), Bohr, meter, centimeter (cm), millimeter (mm), micrometer (um, µm), nanometer (nm) |
energy |
eV, meV, Hartree, kcal/mol, kJ/mol, Joule (J), Rydberg (Ry) |