21.2. Geometry optimization with RHF and ROOpCCD wave functions
Before proceeding, please read the Quick Guide on geometry optimization here.
The geometry optimization module uses geomeTRIC as the optimization backend. At every optimization step, geomeTRIC proposes a new molecular geometry and PyBEST evaluates the corresponding electronic energy and analytic nuclear gradient.
21.2.1. RHF geometry optimization
RHF geometry optimizations are performed with
RHFGeometryOptimizer.
The optimizer recomputes the RHF energy at every geometry and evaluates the analytic RHF nuclear gradient. The one-particle density matrix required for the gradient is generated from the converged RHF wave function.
A typical RHF geometry optimization has the following structure:
optimizer = RHFGeometryOptimizer(
lf,
occ_model,
maxiter=100,
)
result = optimizer(
hf_kwargs={
"threshold": 1.0e-10,
}
)
The returned IOData container contains the optimized coordinates in the
coordinates attribute.
21.2.2. ROOpCCD geometry optimization
ROOpCCD geometry optimizations are performed with
ROOpCCDGeometryOptimizer.
At each geometry, PyBEST first performs an RHF calculation to generate initial orbitals. By default, the occupied and virtual orbitals are localized using the Pipek–Mezey localization procedure before the ROOpCCD calculation is started. The ROOpCCD energy and analytic gradient are then evaluated and passed to geomeTRIC.
A typical ROOpCCD geometry optimization has the following structure:
optimizer = ROOpCCDGeometryOptimizer(
lf,
occ_model,
maxiter=100,
)
result = optimizer(
hf_kwargs={
"threshold": 1.0e-10,
},
pccd_kwargs={
"threshold": 1.0e-10,
"localize": True,
},
)
To switch off Pipek–Mezey localization, set localize to False in
pccd_kwargs.
21.2.3. Summary of keyword arguments
The geometry optimization classes accept the following geometry-related keyword arguments during initialization:
- coordsys:
(str) Coordinate system passed to geomeTRIC. The default is
"tric".- name:
(str) Optional name used for output files and labels.
- maxiter:
(int) Maximum number of geometry optimization steps. The default is
200.- constraints:
Optional geomeTRIC constraint specification. This can be
Noneor a path to a geomeTRIC constraints file.- hessian:
(str) Hessian handling strategy passed to geomeTRIC. The default is
"never".- transition:
(boolean) If set to
True, geomeTRIC performs a transition-state search. The default isFalse.- check_interval:
(int) Interval reserved for additional checks during the optimization. The default is
0.- verbose:
(boolean) If set to
True, more detailed optimization output is printed. The default isFalse.
Additional keyword arguments passed when calling the optimizer are separated into geometry-optimization options and wave-function options. Geometry options are forwarded to geomeTRIC, while wave-function options are forwarded to the energy calculation at each optimization step.
21.2.4. Wave-function keyword arguments
For RHF geometry optimization, SCF options can be passed through hf_kwargs:
result = optimizer(
hf_kwargs={
"threshold": 1.0e-10,
"maxiter": 128,
}
)
For ROOpCCD geometry optimization, options for the initial RHF calculation are
passed through hf_kwargs and options for the ROOpCCD calculation are passed
through pccd_kwargs:
result = optimizer(
hf_kwargs={
"threshold": 1.0e-10,
},
pccd_kwargs={
"threshold": 1.0e-10,
"localize": True,
},
)
21.2.5. Constrained optimizations
Constraints can be provided through the constraints keyword. In typical
applications, this keyword points to a geomeTRIC constraints file.
optimizer = RHFGeometryOptimizer(
lf,
occ_model,
constraints="constraints.txt",
)
The exact syntax of the constraints file follows the geomeTRIC constraints format.
21.2.6. Transition-state searches
Transition-state searches can be requested with the transition keyword:
optimizer = RHFGeometryOptimizer(
lf,
occ_model,
transition=True,
hessian="first+last",
)
For transition-state optimizations, an appropriate initial structure and Hessian strategy are important for convergence.
21.2.7. Output data
The result of a geometry optimization is returned as a
IOData container. The optimized Cartesian
coordinates are available as
result.coordinates
During the optimization, PyBEST prints the energy and gradient norm for each geometry step. After convergence, the final molecular geometry and internal coordinates are printed.