Configurations

The MFF package uses training and testing data extracted from .xyz files. The mff.configurations module contains the function carve_confs which is used to save .npy files containing local atomic environments, the forces acting on the central atoms of these local atomic environments and, if present, the energy associated with the snapshot the local environment has been extracted from. To extract local atomic environments, forces, energies and a list of all the elements contained in an ase atoms object:

from ase.io import read
from mff.configurations import carve_confs
traj = read(filename, format='extxyz')
elements, confs, forces, energies = carve_confs(traj, r_cut, n_data)

where r_cut specifies the cutoff radius that will be applied to extract local atomic environments containing all atomis within r_cut from the central one, and n_data specifies the total number of local atomic environments to extract.

class mff.configurations.Configurations(confs=None)

Configurations can represent a list of configurations

class mff.configurations.ConfsTwoBodySingleForces(r_cut)
class mff.configurations.ConfsTwoForces(r_cut)
class mff.configurations.Energies(confs=None, energy=None)
class mff.configurations.Forces(confs=None, forces=None)
exception mff.configurations.MissingData
mff.configurations.carve_2body_confs(atoms, r_cut, nbins=100, forces_label=None, energy_label=None)

Extract atomic configurations, the forces acting on the central atoms os said configurations, and the local energy values associeated. This function is optimised to get configurations that contain a diverse set of interatomic distances.

Parameters:
  • atoms (ase atoms object) – Ase trajectory file, opened with ase.io.read
  • r_cut (float) – Cutoff to use when carving out atomic environments
  • nbins (int) – number of bins used to sample the distance values. An atomic configuration is selected only if it contains at least a bond which length falls in an unoccupied bin, so that the final database will contain the most diverse set of bond lengths possible.
  • forces_label (str) – Name of the force label in the trajectory file, if None default is “forces”
  • energy_label (str) – Name of the energy label in the trajectory file, if None default is “energy”
Returns:

Array of atomic numbers in increasing order confs (list of arrays): List of M by 5 numpy arrays, where M is the number of atoms within

r_cut from the central one. The first 3 components are positions w.r.t the central atom in Angstroms, the fourth is the atomic number of the central atom, the fifth the atomic number of each atom.

forces (array): x,y,z components of the force acting on the central atom in eV/Angstrom energies (array): value of the local atomic energy in eV

Return type:

elements (array)

mff.configurations.carve_3body_confs(atoms, r_cut, nbins=50, forces_label=None, energy_label=None)

Extract atomic configurations, the forces acting on the central atoms os said configurations, and the local energy values associeated. This function is optimised to get configurations that contain a diverse set of interatomic distances and angles.

Parameters:
  • atoms (ase atoms object) – Ase trajectory file, opened with ase.io.read
  • r_cut (float) – Cutoff to use when carving out atomic environments
  • nbins (int) – number of bins used to sample the distance values. An atomic configuration is selected only if it contains at least a triplet three distances fall in an unoccupied bin, so that the final database will contain the most diverse set of triplets possible.
  • forces_label (str) – Name of the force label in the trajectory file, if None default is “forces”
  • energy_label (str) – Name of the energy label in the trajectory file, if None default is “energy”
Returns:

Array of atomic numbers in increasing order confs (list of arrays): List of M by 5 numpy arrays, where M is the number of atoms within

r_cut from the central one. The first 3 components are positions w.r.t the central atom in Angstroms, the fourth is the atomic number of the central atom, the fifth the atomic number of each atom.

forces (array): x,y,z components of the force acting on the central atom in eV/Angstrom energies (array): value of the local atomic energy in eV

Return type:

elements (array)

mff.configurations.carve_confs(atoms, r_cut, n_data, forces_label=None, energy_label=None, boundaries=None)

Extract atomic configurations, the forces acting on the central atoms os said configurations, and the local energy values associeated.

Parameters:
  • atoms (ase atoms object) – Ase trajectory file, opened with ase.io.read
  • r_cut (float) – Cutoff to use when carving out atomic environments
  • n_data (int) – Total number of atomic configurations to extract from the trajectory
  • forces_label (str) – Name of the force label in the trajectory file, if None default is “forces”
  • energy_label (str) – Name of the energy label in the trajectory file, if None default is “energy”
  • boundaries (list) – List containing three lists for the three cartesian coordinates. Each of them contains a list of tuples indicating every interval that must be used to sample central atoms from. Example: boundaries = [[], [], [[-10.0, +5.3]]] Default is None, and all of the snapshot is used.
Returns:

Array of atomic numbers in increasing order confs (list of arrays): List of M by 5 numpy arrays, where M is the number of atoms within

r_cut from the central one. The first 3 components are positions w.r.t the central atom in Angstroms, the fourth is the atomic number of the central atom, the fifth the atomic number of each atom.

forces (array): x,y,z components of the force acting on the central atom in eV/Angstrom energies (array): value of the local atomic energy in eV

Return type:

elements (array)

mff.configurations.carve_from_snapshot(atoms, atoms_ind, r_cut, forces_label=None, energy_label=None)

Extract atomic configurations, the forces acting on the central atoms os said configurations, and the local energy values associated to a single atoms object.

Parameters:
  • atoms (ase atoms object) – Ase atoms file, opened with ase.io.read
  • atoms_ind (list) – indexes of the atoms for which a conf is created
  • r_cut (float) – Cutoff to use when carving out atomic environments
  • forces_label (str) – Name of the force label in the trajectory file, if None default is “forces”
  • energy_label (str) – Name of the energy label in the trajectory file, if None default is “energy”
Returns:

List of M by 5 numpy arrays, where M is the number of atoms within

r_cut from the central one. The first 3 components are positions w.r.t the central atom in Angstroms, the fourth is the atomic number of the central atom, the fifth the atomic number of each atom.

forces (array): x,y,z components of the force acting on the central atom in eV/Angstrom energies (array): value of the local atomic energy in eV

Return type:

confs (list of arrays)