Calculators

A mapped potential is a tabulated 2- or 3-body interatomic potential created from a Gaussian process using a 2- or 3-body kernel. To use a mapped potential created with this python package within the ASE environment, it is necessary to setup a calculator using the mff.calculators class.

Theory/Introduction

Example

Running the Calculator

Configurations

Module used to create ase calculators using interpolators constructed with the models module of the mff package. These calculators can yield forces and energies for atoms objects at a very low computational cost.

WARNING: The atoms object must be such that the atoms are ordered with increasing atomic number for the two species calculator to work.

Example

>>> calc = calculators.CombinedTwoSpecies(
        r_cut, element0, element1,  grid_2b, grid_3b, rep_alpha=1.4)
>>> atoms = atoms[np.argsort(atoms.get_atomic_numbers())]
>>> atoms.set_calculator(calc)
class mff.calculators.CombinedSingleSpecies(r_cut, grid_2b, grid_3b, rep_alpha=0.0, **kwargs)
class mff.calculators.CombinedTwoSpecies(r_cut, element0, element1, grids_2b, grids_3b, rep_alpha=0.0, **kwargs)
class mff.calculators.MappedPotential(r_cut, **kwargs)
calculate(atoms=None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])

Do the calculation.

properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.

Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:

self.results = {'energy': 0.0,
                'forces': np.zeros((len(atoms), 3)),
                'stress': np.zeros(6),
                'dipole': np.zeros(3),
                'charges': np.zeros(len(atoms)),
                'magmom': 0.0,
                'magmoms': np.zeros(len(atoms))}

The subclass implementation should first call this implementation to set the atoms attribute.

set(**kwargs)

Set parameters like set(key1=value1, key2=value2, …).

A dictionary containing the parameters that have been changed is returned.

Subclasses must implement a set() method that will look at the chaneged parameters and decide if a call to reset() is needed. If the changed parameters are harmless, like a change in verbosity, then there is no need to call reset().

The special keyword ‘parameters’ can be used to read parameters from a file.

exception mff.calculators.SingleSpecies
class mff.calculators.ThreeBodySingleSpecies(r_cut, grid_3b, **kwargs)

A mapped 3-body calculator for ase

grid_3b

object – 3D Spline interpolator for the 3-body mapped grid

results

dict – energy and forces calculated on the atoms object

calculate(atoms=None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])

Do the calculation.

find_triplets()

Function that efficiently finds all of the valid triplets of atoms in the atoms object.

Returns:
array containing the indices of atoms belonging to any valid triplet.
Has shape T by 3 where T is the number of valid triplets in the atoms object
distances (array): array containing the relative distances of every triplet of atoms.
Has shape T by 3 where T is the number of valid triplets in the atoms object
positions (dictionary): versor of position w.r.t. the central atom of every atom indexed in indices.
Has shape T by 3 where T is the number of valid triplets in the atoms object
Return type:indices (array)
class mff.calculators.ThreeBodyTwoSpecies(r_cut, element0, element1, grids_3b, **kwargs)

A mapped 3-body 2-species calculator for ase

elements

list – List of ordered atomic numbers of the mapped two species system.

grids_3b

dict – contains the four 3D Spline interpolators relative to the 3-body mapped grids for element0-element0-element0, element0-element0-element1, element0-element1-element1 and element1-element1-element1 interactions.

results

dict – energy and forces calculated on the atoms object

calculate(atoms=None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])

Do the calculation.

find_triplets(atoms)

Function that efficiently finds all of the valid triplets of atoms in the atoms object.

Returns:
array containing the indices of atoms belonging to any valid triplet.
Has shape T by 3 where T is the number of valid triplets in the atoms object
distances (array): array containing the relative distances of every triplet of atoms.
Has shape T by 3 where T is the number of valid triplets in the atoms object
positions (dictionary): versor of position w.r.t. the central atom of every atom indexed in indices.
Has shape T by 3 where T is the number of valid triplets in the atoms object
Return type:indices (array)
class mff.calculators.TwoBodySingleSpecies(r_cut, grid_2b, rep_alpha=0.0, **kwargs)

A mapped 2-body calculator for ase

grid_2b

object – 1D Spline interpolator for the 2-body mapped grid

rep_alpha

float – Repulsion parameter, used when no data for very close atoms are available in order to avoid collisions during MD. The parameter governs a repulsion force added to the computed one.

results

dict – energy and forces calculated on the atoms object

calculate(atoms=None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])

Do the calculation.

class mff.calculators.TwoBodyTwoSpecies(r_cut, element0, element1, grids_2b, rep_alpha=0.0, **kwargs)

A mapped 2-body 2-species calculator for ase

elements

list – List of ordered atomic numbers of the mapped two species system.

grids_2b

dict – contains the three 1D Spline interpolators relative to the 2-body mapped grids for element0-element0, element0-element1 and element1-element1 interactions

rep_alpha

float – Repulsion parameter, used when no data for very close atoms are available in order to avoid collisions during MD. The parameter governs a repulsion force added to the computed one.

results

dict – energy and forces calculated on the atoms object

calculate(atoms=None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])

Do the calculation.

class mff.calculators.TwoSpeciesMappedPotential(r_cut, element0, element1, **kwargs)
calculate(atoms=None, properties=('energy', 'forces'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])

Do the calculation.

properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.

Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:

self.results = {'energy': 0.0,
                'forces': np.zeros((len(atoms), 3)),
                'stress': np.zeros(6),
                'dipole': np.zeros(3),
                'charges': np.zeros(len(atoms)),
                'magmom': 0.0,
                'magmoms': np.zeros(len(atoms))}

The subclass implementation should first call this implementation to set the atoms attribute.

set(**kwargs)

Set parameters like set(key1=value1, key2=value2, …).

A dictionary containing the parameters that have been changed is returned.

Subclasses must implement a set() method that will look at the chaneged parameters and decide if a call to reset() is needed. If the changed parameters are harmless, like a change in verbosity, then there is no need to call reset().

The special keyword ‘parameters’ can be used to read parameters from a file.