Force Field Query

A trained sGDML model (see Force Field Reconstruction) is straightforward to use. The following example shows how to predict energy and forces using the pre-trained ethanol force field (Pre-trained Models) for a ethanol geometry file ethanol.xyz (Download) stored in XYZ format:

import numpy as np
from sgdml.predict import GDMLPredict
from sgdml.utils import io

model = np.load('ethanol.npz')
gdml = GDMLPredict(model)

r,_ = io.read_xyz('ethanol.xyz') # 9 atoms
e,f = gdml.predict(r)

print r.shape # (1,27)
print e.shape # (1,)
print f.shape # (1,27)

We instantiate the sGDML predictor with the model file ethanol.npz and query it using the ethanol geometry stored in ethanol.xyz. It returns the energy and all interatomic forces for this structure.

Note

The order of atoms in ethanol.xyz must be the same as in the dataset from which the model ethanol.npz emerged.

Note

The distance unit of the query geometry (here: Ångström) must match the unit in the dataset used for model reconstruction.