File IO#

MOTEP has parsers for the file formats of the MLIP codes developed by Shapeev and co-workers.

  • .cfg: Atomic configurations

  • .mtp: MTP parameters

.cfg#

Module for MTP formats.

motep.io.mlip.cfg.read_cfg(fd: TextIO, index: int = -1, species: list[int] | list[str] | None = None) Atoms | list[Atoms]#

Read images from a MTP .cfg file.

Parameters:
  • fd (TextIO) – TextIO object.

  • index (int) – Index of images.

  • species (list[int] | list[str], optional) – List defining types of chemical symbols. For example, [46, 1] and [‘Pd’, ‘H’] assign Pd for type 0 and H for type 1. If None, dummy symbols ‘X’, ‘H’, ‘He’, etc. are assigned for types 0, 1, 2, etc.

Return type:

Atoms | list[Atoms]

motep.io.mlip.cfg.write_cfg(fd: TextIO, images: Atoms | list[Atoms], species: list[int] | list[str] | None = None, key_energy: str | None = None) None#

Write images into the MTP .cfg format.

Parameters:
  • fd (TextIO) – TextIO object.

  • images (Atoms | list[Atoms]) – _description_

  • species (list[int] | list[str], optional) – List that defines types of chemical symbols (e.g, [‘Pd’, ‘H’] means Pd is type 0 and H type 1), by default None. If None, this list is built by assigning each distinct species to an integer in the order of appearance in images.

  • key_energy (str | None, default: None) – Key for the energy (either “free_energy” or “energy”) to be printed. If None, “free_energy” is first considered, followed by “energy”.

.mtp#

Parsers of MLIP .mtp files.

motep.io.mlip.mtp.read_mtp(file: str | Path) MTPData#

Read an MLIP .mtp file.

Return type:

MTPData

motep.io.mlip.mtp.write_mtp(file: str | Path, data: MTPData) None#

Write an MLIP .mtp file.