Skip to content

Grid Optimization

Grid optimizations perform geometry optimizations on a grid of chosen coordinates, or in other words give relaxed scans of the potential energy surface. They can be useful for:

  • Exploring a relevant region of a potential energy surface (PES)
  • Helping to find a particular transition state
  • Developing force field parameters, e.g. dihedral force constants

A grid optimization is specified via the GridOptimizationInput object, which requires an initial_molecule, an optimization_method for the energy method used in the optimizations, and a scans field that specifies both the set of coordinates for the scan, as well as the initial and final values.

There are two optional fields: energy_method and constraints.

The energy_method field can be specified to evaluate the final energy at the optimized geometries at each grid point. If it is not specified, the optimization_method is used for final energy evaluation.

The constraints field can be specified to add geometrical constraints to the remaining coordinates (e.g. for freezing the rotation of the -CH3 groups while performing relaxed scan on a C-C bond).

The results of a grid optimization are stored in the GridOptimizationResult object.

Example

The following example demonstrates how to perform grid optimizations:

import sierra
from sierra.inputs import *

import numpy as np

# Geometry of an HOOH molecule
# note the coordinates are in Angstrom
HOOH = Molecule(
    data="""
H 0 -0.3 1
O 0 0 0
O 0 1.2 0
H 0 1.5 1
"""
)

# Perform a grid optimization along the dihedral angle
# at GFN1-xTB level of theory
# Note: the angles are in degrees
inp = GridOptimizationInput(
    molecule=HOOH,
    scans=[
        {
            "indices": [0, 1, 2, 3],
            "span": {"start": -20, "stop": 20, "nsteps": 3},
        }
    ],
    optimization_method=XTBMethod(model="GFN1"),
)

result = sierra.run(inp)

final_relative_energies = {
    k: v - min(result.energies.values()) for k, v in result.energies.items()
}

print("Final relative energies (in Hartree) at each grid point:")
#> Final relative energies (in Hartree) at each grid point:
print(final_relative_energies)
"""
{
    (1,): 0.0008328854665649033,
    (0,): 0.0,
    (2,): 1.7763568394002505e-15,
}
"""

GridOptimizationInput

Fields

constraints
energy_method

The method for final energy evaluation. If None the final energies are computed using the level of theory specified by optimization_method.

initial_molecule
optimization_method

The method with which to optimize the molecule at each grid point.

scans
workflow
  • Type: WorkflowIdentifier
  • Default: WorkflowIdentifier(name='grid_optimization', image=None)

GridOptimizationResult

Fields

All the fields in GridOptimizationInput and the following:

energies_list

The energies of the optimized molecules at each grid point.

  • Type: Array
keys
  • Type: List[Tuple[int, ...]]
optimizations_list

A record of each optimization evaluation that the GridOptimization workflow completed.

optimized_molecules_list

The optimized molecules at each grid point.

energies

Key/value pairs of the zipped elements from keys and energies_list.

  • Type: Mapping[Tuple[int, ...], float]
optimizations

Key/value pairs of the zipped elements from keys and optimizations_list.

optimized_molecules

Key/value pairs of the zipped elements from keys and optimized_molecules_list.

  • Type: Mapping[Tuple[int, ...], Molecule]

Functions

GridOptimizationResult.visualize

visualize((str) units) -> None:

The results of a grid optimization can be displayed by using this function. CAVEAT: This function can only be used inside a jupyter notebook.

Arguments

units

The units in which energy values are displayed.

  • Type: str
  • Default: "kcal / mol"

Returns

None