ffsim.optimize_orbitals

ffsim.optimize_orbitals(rdm, hamiltonian, *, initial_orbital_rotation=None, real=None, return_optimize_result=False, **optimize_kwargs)[source]

Find orbitals that minimize the energy of a pair of one- and two-RDMs.

Uses scipy.optimize.minimize() to find an orbital rotation that minimizes the energy of a pair of one- and two-RDMs with respect to a molecular Hamiltonian.

Real optimization stays in the determinant component of the initial rotation. If no initial rotation is given, it searches rotations with determinant +1. Optimization starts with zero generator parameters for an additional rotation applied after the initial rotation, which remains fixed throughout optimization.

The minimized energy can be computed from the returned orbital rotation as

rdm.rotated(orbital_rotation).expectation(mol_hamiltonian)

or

rdm.expectation(mol_hamiltonian.rotated(orbital_rotation.T.conj()))

See Optimize orbitals for a how-to guide.

Parameters:
  • rdm (ReducedDensityMatrix) – The reduced density matrices.

  • hamiltonian (MolecularHamiltonian) – The Hamiltonian.

  • initial_orbital_rotation (ndarray | None) – An initial guess for the orbital rotation. If not provided, the identity matrix will be used. Real optimization accepts either determinant sign, including complex-typed matrices whose imaginary entries are all zero.

  • real (bool | None) – Whether to restrict the optimization to real-valued orbital rotations. The default behavior is to restrict to real-valued orbital rotations if the reduced density matrices, Hamiltonian, and initial orbital rotation (if one was given) are all real-valued, and to allow complex orbital rotations if any of these are complex-valued.

  • return_optimize_result (bool) – Whether to also return the OptimizeResult returned by scipy.optimize.minimize().

  • optimize_kwargs – Keyword arguments to pass to scipy.optimize.minimize(). The default method is "L-BFGS-B". Bounds, constraints, and callbacks use the generator parameters of the additional rotation relative to the initial guess.

Return type:

ndarray | tuple[ndarray, OptimizeResult]

Returns:

The orbital rotation that minimizes the energy when applied to the reduced density matrix, or when its adjoint is applied to the Hamiltonian. If return_optimize_result is set to True, the OptimizeResult returned by scipy.optimize.minimize() is also returned. The parameters result.x describe the additional rotation exp(K), and the returned rotation is exp(K) U0, where U0 is the initial rotation. The generator K is real skew-symmetric for real optimization and anti-Hermitian for complex optimization.

Raises:

ValueError – The initial rotation has nonzero imaginary entries when real=True, or real optimization is requested for one orbital.