Serialization

metatensor.torch.atomistic.save(file: str | Path | BytesIO, system: System) None[source]

Save a System object to a file.

The provided System must contain float64 data and be on the CPU device.

The saved file will be a zip archive containing the following files:

  • types.npy, containing the atomic types in numpy’s NPY format;

  • positions.npy, containing the systems’ positions in numpy’s NPY format;

  • cell.npy, containing the systems’ cell in numpy’s NPY format;

  • pbc.npy, containing the periodic boundary conditions in numpy’s NPY format;

For each neighbor list in the System object, the following files will be saved (where {nl_idx} is the index of the neighbor list):

  • pairs/{nl_idx}/options.json: the NeighborListOptions object converted to a JSON string.

  • pairs/{nl_idx}/data.mts: the neighbor list TensorBlock object

For each extra data in the System object, the following file will be saved (where {name} is the name of the extra data):

  • data/{name}.mts: The extra data TensorMap

Parameters:
  • file (str | Path | BytesIO) – The path (or file-like object) to save the System to.

  • system (System) – The System object to save.

Return type:

None

metatensor.torch.atomistic.load_system(file: str | Path | BytesIO) System[source]

Load a System object from a file.

The loaded System object will be on the CPU device and contain float64 data.

Parameters:

file (str | Path | BytesIO) – The path (or file-like object) to load the System object from.

Returns:

The System object.

Return type:

System