OpenKIM support

The OpenKIM.org project aims at sharing potentials between molecular dynamics codes such as Asap. The potentials (called “Models” in the OpenKIM project) can be downloaded and compiled, without any adaptation to Asap (which acts as a “Simulator” in the OpenKIM sense).

The OpenKIM project is designed to support Parallel simulations on clusters using Message Passing using the same parallelization model as Asap. Thus the OpenKIM Models can directly be used in parallel simulations (barring bugs, of course).

Prerequisites

The OpenKIM API must be installed and compiled. Asap must have been built with OpenKIM support. This is the case with the default Niflheim installation.

From version 3.11, Asap uses OpenKIM version 2.X. This gives simpler memory management, and the issues seen with some version 1 OpenKIM models in parallel simulations are now solved.

Adding new OpenKIM models to Asap

Newer versions of OpenKIM include a utility for managing models. You list the installed models with:

kim-api-v2-collections-management list

You can add a specific model with the command:

kim-api-v2-collections-management install user SW_StillingerWeber_1985_Si__MO_405512056662_005

or you can install them all with:

kim-api-v2-collections-management install user OpenKIM

Using OpenKIM models

An OpenKIM model is used by creating an OpenKIM_Calculator object with the full KIM model name as the argument. Example:

atoms.set_calculator(OpenKIMcalculator('EMT_Asap_Standard_Jacobsen_Stoltze_Norskov_AlAgAuCuNiPdPt__MO_XXXXXXXXXXXX'))

In this case the standard Asap EMT potential is imported as an OpenKIM model (we are contributing this potential to the OpenKIM project - to appear soonish). Of course this is kind of pointless, as using the EMT potential avoids the overhead of going through the OpenKIM API. Currently, that overhead is of the order of XXX% for the EMT potential.

All correctly implemented OpenKIM models can be used with Parallel simulations on clusters using Message Passing using message passing; but they do not support Multi-threaded parallelization.

The OpenKIMcalculator

class asap3.OpenKIMcalculator(name, atoms=None, stress=True, stresses=True, verbose=False)[source]

A calculator interfacing to the OpenKIM models.

Parameters:
  • name (str) – The long name of the KIM Model.

  • atoms (ase.Atoms, optional) – If given, set_atoms is called immediately. By default no atoms are set.

  • stress (bool, optional) – Set to False to refrain from calculating the global virial, even if the model supports it. The default is True.

  • stresses (bool, optional) – As stress, but for atomic virials / stresses. The default is True.

  • verbose (bool, optional) – Set to True to print additional information during neighbor list matching. The default is False.

get_supported_elements(user=True)[source]

Get a list of supported elements, as chemical symbols.

Parameters:

user (bool, optional) – If True (the default), elements with the names 'user01' to 'user20' may also be reported as supported.

Returns:

list of str – The chemical symbols of the supported elements.

property parameters

Published parameters of the OpenKIM model as a dict-like object

Accessing model parameters

The published parameters of the OpenKIM model can be accessed through the .parameters attribute, which is a read/write dictionary-like object.

class asap3.Internal.OpenKIMcalculator.OpenKIMparameters(model)[source]

Published parameters of the OpenKIM model.

A dictionary-like object containing the parameters of a OpenKIM model. Model parameters can be read and set. If the parameter is a multidimensional array then a flattened version of the array is used when accessing the parameters through normal dictionary indexing (params['paramname']).

This object also has two helper functions that can be used to get and set multidimensional arrays, .getparameter(name, shape=None) and .setparameter(name, value, shape=None). They both take an optional argument specifying how an array of values should be interpreted. The following values are supported for the shape parameter:

a tuple

Explicitly gives the shape of the array.

'square'

The array is a square array.

'ut'

The array is an upper-triangular square matrix.

'lt'

The array is a lower-triangular square matrix.

None

The value is a scalar or a 1D array.

get_parameter(key, shape=None)[source]

Get a model parameter

Parameters:
  • key (str) – Name of the parameter.

  • shape (str or tuple, optional) – How to interpret the shape of the array - see class documentation.

set_parameter(key, value, shape=None)[source]

Set a model parameter

Parameters:
  • key (str) – Name of the parameter.

  • value (int or float or numpy.ndarray) – The new value of the parameter.

  • shape (str or tuple, optional) – How to interpret the shape of the array - see class documentation.