Skip to content

Energy evaluation

Introduction

It is possible to call individual energy methods through the Python API for integration in other workflows. In addition to single-point energies, gradients can be computed, as well as hessian for some methods. For geometry optimization, see the separate tutorial on that topic.

The Python object that describes an energy calculation at a single molecular geometry is EnergyInput. We can try a simple example by constructing then evaluating a EnergyInput for a B97-3c energy calculation on the water molecule as follows:

import sierra
from sierra.inputs import *

water = Molecule(pubchem="water")
inp = EnergyInput(molecule=water, method=DFTMethod(xc="b97-3c"))
result = sierra.run(inp)
print(result.energy)
Other energy methods can be inserted as required, and a small case study for using OrbNet is presented below.

Evaluating gradients and hessians

A similar API is used for a single gradient or hessian evaluation. For example the gradients of the energy with respect to geometrical coordinates for the above example can be computed through:

import sierra
from sierra.inputs import *

water = Molecule(pubchem="water")
inp = GradientInput(molecule=water, method=DFTMethod(xc="b97-3c"))
result = sierra.run(inp)
print(result.gradient)

In the same way, the hessian can be evaluated (HessianInput) where available, and printed as print(result.hessian). Lower derivatives are always computed, so for example the result object is populated by the energy and gradient in a hessian calculation.

Using EnergyInput for OrbNet energy evaluations

Here we will compute the reaction energy for conversion of ethyne to benzene using both OrbNet and the (much more computationally expensive) DFT method on which the OrbNet Fuji model was trained.

The reaction_energy function below calculates the (0K) reaction energy for a given Sierra method.

import sierra
from sierra.inputs import *

benzene = Molecule(pubchem="benzene")
ethyne = Molecule(pubchem="ethyne")

def reaction_energy(method):
    e_benzene = sierra.run(EnergyInput(molecule=benzene, method=method)).energy
    e_ethyne = sierra.run(EnergyInput(molecule=ethyne, method=method)).energy
    delta_e = e_benzene - 3 * e_ethyne 
    return delta_e * sierra.constants.cf("hartree", "kJ / mol")

reference_dft = DFTMethod(xc="wb97xd3", ao="def2-tzvp")
orbnet = OrbNetMethod(model="fuji")
for method in [reference_dft, orbnet]:
    delta_e = reaction_energy(method)
    print(f"{str(method):48} {delta_e:10.3f} kJ / mol")

Running the script produces the table

DFTMethod(xc='WB97XD3', ao='def2-tzvp')            -689.166 kJ / mol
OrbNetMethod(model='fuji', version='3.1')          -692.228 kJ / mol
and it is seen that the reaction energies from OrbNet and the underlying DFT method agree to within chemical accuracy.