Skip to content

Geometry optimization


Geometry optimization calculations are represented by the Python object OptimizationInput. The initial geometry is specified through the initial_molecule argument, and the underlying energy method through method.

Energy minimization

A first example

A short script to optimize the geometry of water using GFN1-xTB is shown below.

import sierra
from sierra.inputs import *

water = Molecule(pubchem="water")
inp = OptimizationInput(
result =
for i, e in enumerate(result.energies):
    print(f"  {i+1} {e:15.9f}")

This example also prints out the table of energies computed during the optimization. The optimized molecular structure is found in result.final_molecule, along with a host of other data.

Energy minimization with OrbNet

In this second example, we will use OrbNet to determine the O-H bond length in phenol.

import sierra
from sierra.inputs import *

inp = OptimizationInput(
result =
phenol = result.final_molecule
# find index of the oxygen atom in the structure
o_index = list(phenol.symbols).index('O')
# find the distances between oxygen and each hydrogen, and take the smallest
rOH = min([phenol.measure([o_index,i]) for i, s in enumerate(phenol.symbols) if s == 'H'])
print(f"OH bond length = {rOH *'bohr', 'pm'):.2f} pm")

This should print out the OrbNet-optimized bond-length as:

OH bond length = 95.94 pm