Create an Orbital Optimizer
Goal
Build and configure an orbital optimizer using the fluent builder API. Choose between Newton and simple optimizers. Optionally, set estimators, minimizers, gradient calculators, and number of shots for sampling.
Prerequisites
A basic understanding of orbital optimization (rotating molecular orbitals to lower the system’s energy)
Overview
Start the builder with:
import qrunch as qc
opt = qc.orbital_optimizer_creator()
Then narrow to a specific algorithm and call .create():
optimizer = (
qc.orbital_optimizer_creator()
.newton() # or .simple()
# .<configure>(...)
.create()
)
Available Optimizers
A Newton-style optimizer that uses a gradient calculator. Supports finite-difference or local (RDM-based) gradients.
import qrunch as qc
optimizer = (
qc.orbital_optimizer_creator()
.newton()
.choose_gradient_calculator()
.local_gradient( # analytical (RDM-based) gradients
estimator=qc.estimator_creator().excitation_gate().create()
)
.with_shots(None) # None = exact estimator for gradients
.with_options( # optional Newton options
options=qc.options.NewtonMinimizerOptions(...)
)
.create()
)
The Newton-style optimizer with a local gradient calculator is a
strong default choice for orbital optimization. It leverages analytical gradients
via reduced density matrices (RDMs), leading to efficient and accurate updates. Options can be set using a NewtonMinimizerOptions instance.
A lightweight optimizer that uses an estimator and a classical minimizer.
import qrunch as qc
optimizer = (
qc.orbital_optimizer_creator()
.simple()
.with_estimator( # optional: set custom estimator
estimator=qc.estimator_creator().excitation_gate().create()
)
.choose_minimizer() # optional: choose custom minimizer
.scipy(
name="L-BFGS-B",
options=qc.options.ScipyMinimizerOptions(...)
)
.with_shots(None) # None = exact estimator; or an int for finite shots
.create()
)
See Choose a Minimizer for a guide to choosing a minimizer.
Next Step
Use the orbital optimizer within VQE calculator variants that support orbital rotations (e.g., OO-BEAST-VQE, OO-FAST-VQE).