ffsim.ucj_energy_and_grad_func_spin_balanced

ffsim.ucj_energy_and_grad_func_spin_balanced(hamiltonian, nelec, interaction_pairs=None, *, with_final_orbital_rotation=False, occupied_orbitals=None, chunk_size=None)[source]

Return a function that computes the spin-balanced UCJ energy and gradient.

The returned function takes a parameter vector for a spin-balanced UCJ operator with n_reps=1, as returned by UCJOpSpinBalanced.to_parameters() and accepted by UCJOpSpinBalanced.from_parameters(), and returns the energy and its gradient with respect to the parameters.

Parameters:
  • hamiltonian (MolecularHamiltonian) – The Hamiltonian.

  • nelec (tuple[int, int]) – The number of alpha and beta electrons.

  • interaction_pairs (tuple[list[tuple[int, int]] | None, list[tuple[int, int]] | None] | None) – The interaction pairs used to parameterize the Jastrow matrices. If None, all pairs are considered.

  • with_final_orbital_rotation (bool) – Whether the parameter vector includes a final orbital rotation.

  • occupied_orbitals (tuple[Sequence[int], Sequence[int]] | None) – The occupied orbitals for the reference state. Defaults to the Hartree-Fock state.

  • chunk_size (int | None) – The maximum number of two-body Hamiltonian terms to evaluate at a time. Smaller values use less memory but take longer to run. If None, all two-body terms are evaluated in one batch.

Return type:

Callable[[ndarray], tuple[float, ndarray]]

Returns:

A callable that takes a flattened parameter vector and returns the energy value and gradient.