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 (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('') # 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 It returns the energy and all interatomic forces for this structure.


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


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