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 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. Soon, this will be the case with the default Niflheim installation.

Adding new OpenKIM models to Asap

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

kim-api-v1-collections-management list

You can add a specific model with the command:

kim-api-v1-collections-management install user Three_Body_Stillinger_Weber_Balamane_Si__MO_113686039439_002

or you can install them all with:

kim-api-v1-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_118428466217_002'))

In this case the standard Asap EMT potential is imported as an OpenKIM model (we are contributing this potential to the OpenKIM project). 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 10% for the EMT potential.

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

The OpenKIMcalculator

OpenKIMcalculator(name, atoms=None, allowed=None, allow_mi_opbc=True, access=None, stress=True, stresses=True, verbose=False):

A calculator interfacing to the OpenKIM models.

name:
The long name of the KIM Model.
atoms:
If set, set_atoms is called immediately. Default: no atoms set.
allowed:
List of OpenKIM neighbor list keywords, only these will be considered when matching the model. Default: All neighbor list modes are allowed.
allow_mi_opbc:
If set to False, minimum-image orthogonal periodic boundary condition methods are not considered when mathcing the neighbor lists. Useful if the cell is expected to become skewed during the simulation.
access:
Set to "iter" or "loca" to restrict the neigbor list access method to iterator mode or locator mode, respectively. Default: not restricted.
stress:
Set to False to refrain from calculate the global virial, even if the model supports it. Default: True (calculate global virial / stress).
stresses:
As above, but for atomic virials / stresses.
verbose:
Set to True to print additional info during neigborlist matching.

Not specifying allowed is equivalent to setting it to ["NEIGH_RVEC_H", "NEIGH_PURE_H", "NEIGH_RVEC_F", "NEIGH_PURE_F", "MI_OPBC_H", "MI_OPBC_F", "CLUSTER"] and the OpenKIM API will try to match with the model using the first of these neighbor list modes that the model supports. For some models there may be a significan difference in performance depending on which mode is used, and it may be worth the effort to experiment with this before a demanding simulation. In general, you should only specify the allowed keyword if you have a good reason for doing so.

Setting allow_mi_opbc=False prevents the MI_OPBC_H and MI_OPBC_F (Minimum Image Orthogonal Periodic Boundary Conditions Half/Full neighbor list) modes from being used. Normally, these may be chosen if the simulation cell is orthogonal and there are periodic boundary condition. If later the simulation cell is deformed, and error may be produced if the OpenKIM API chose the MI_OPBC_H or MI_OPBC_F neighbor list methods. This variable can prevent that from occurring.

Setting the access variable is not expected to be useful except when debugging OpenKIM models.

Setting model parameters

OpenKIM models may have parameters that can be read and modified. The interface for doing this is described here. Both the model's fixed and free parameters may be accessed, but of course only the free parameters may be modified. In the OpenKIM specification, all parameter names begin with PARAM_FREE_ or PARAM_FIXED_, these prefixes are removed by this interface.

WARNING: Currently, the interface only support floating-point parameters. No known OpenKIM models have free parameters of other types, but the fixed parameters may be integers or even pointers. Accessing these variables could cause memory access errors (i.e. crashes). For this reason, please only access the free parameters.

calculator.get_parameters(kind='free'):
Get a dictionary with all the parameters. Per default, only free parameters are returned. If kind is set to 'fixed' or 'all', fixed parameters or all parameters are returned (see warning above). Changing the dictionary or the arrays returned does not change the parameters as seen by the model.
calculator.set_parameters(param1=value, ...):

Set one or more free parameters. The parameters are given as keyword arguments with the parameter name as the keyword, and the desired value as the value. Limited type checking is done: a scalar parameter can only be set to a floating-point number; a indexed parameter can be set to a numpy array of the right size. Only the total number of elements is checked, the detailed shape is not.

After calling this function, the OpenKIM model is automatically reinitialized by calling its reinit method. Note that if this function fails to set one or more parameters (due to incorrect names or data types) this reinitialization is not done, and the OpenKIM model may be left in an undefined state. Call this function again to fix it.

calculator.get_fixed_parameter_names() and calculator.get_fixed_parameter_names():
Low-level access functions. They return a tuple of parameter names. The PARAM_FREE_/PARAM_FIXED_ prefix is not removed.

Asap: OpenKIM support (last edited 2017-12-06 12:39:39 by JakobSchiøtz)