ffsim.ucj_energy_and_grad_func_spinless

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

Return a function that computes the spinless UCJ energy and gradient.

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

Parameters:
  • hamiltonian (MolecularHamiltonianSpinless) – The Hamiltonian.

  • nelec (int) – The number of electrons.

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

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

  • occupied_orbitals (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.