Target data Readers

Parsers for obtaining target informations from target files. All readers return a metatensor.torch.TensorBlock. Currently we support the following target properties

The mapping which reader is used for which file type is stored in a dictionary.

Energy

metatensor.models.utils.data.readers.targets.ENERGY_READERS = {'.extxyz': <function read_energy_ase>, '.xyz': <function read_energy_ase>}

dict: dictionary mapping file suffixes to a target energy reader

Implemented Readers

metatensor.models.utils.data.readers.targets.read_energy_ase(filename: str, key: str, dtype: dtype = torch.float32) List[TensorBlock][source]

Store energy information in a List of metatensor.TensorBlock.

Parameters:
  • filename (str) – name of the file to read

  • key (str) – target value key name to be parsed from the file.

  • dtype (dtype) – desired data type of returned tensor

Returns:

TensorMap containing the given information

Return type:

List[TensorBlock]

Forces

metatensor.models.utils.data.readers.targets.FORCES_READERS = {'.extxyz': <function read_forces_ase>, '.xyz': <function read_forces_ase>}

dict: dictionary mapping file suffixes to a target forces reader

Implemented Readers

metatensor.models.utils.data.readers.targets.read_forces_ase(filename: str, key: str = 'energy', dtype: dtype = torch.float32) List[TensorBlock][source]

Store force information in a List of metatensor.TensorBlock which can be used as position gradients.

Parameters:
  • filename (str) – name of the file to read

  • key (str) – target value key name to be parsed from the file.

  • dtype (dtype) – desired data type of returned tensor

Returns:

TensorMap containing the given information

Return type:

List[TensorBlock]

Stress

metatensor.models.utils.data.readers.targets.STRESS_READERS = {'.extxyz': <function read_stress_ase>, '.xyz': <function read_stress_ase>}

dict: dictionary mapping file suffixes to a target stress reader

Implemented Readers

metatensor.models.utils.data.readers.targets.read_stress_ase(filename: str, key: str = 'stress', dtype: dtype = torch.float32) List[TensorBlock][source]

Store stress information in a List of metatensor.TensorBlock which can be used as strain gradients.

Parameters:
  • filename (str) – name of the file to read

  • key (str) – target value key name to be parsed from the file

  • dtype (dtype) – desired data type of returned tensor

Returns:

TensorMap containing the given information

Return type:

List[TensorBlock]

Virial

metatensor.models.utils.data.readers.targets.VIRIAL_READERS = {'.extxyz': <function read_virial_ase>, '.xyz': <function read_virial_ase>}

dict: dictionary mapping file suffixes to a target virial reader

Implemented Readers

metatensor.models.utils.data.readers.targets.read_virial_ase(filename: str, key: str = 'virial', dtype: dtype = torch.float32) List[TensorBlock][source]

Store virial information in a List of metatensor.TensorBlock which can be used as strain gradients.

Parameters:
  • filename (str) – name of the file to read

  • key (str) – target value key name to be parsed from the file

  • dtype (dtype) – desired data type of returned tensor

Returns:

TensorMap containing the given information

Return type:

List[TensorBlock]