ffsim.ucj_energy_and_grad_func_spin_unbalanced¶
- ffsim.ucj_energy_and_grad_func_spin_unbalanced(hamiltonian, nelec, interaction_pairs=None, *, with_final_orbital_rotation=False, occupied_orbitals=None, chunk_size=None)[source]¶
Return a function that computes the spin-unbalanced UCJ energy and gradient.
The returned function takes a parameter vector for a spin-unbalanced UCJ operator with n_reps=1, as returned by
UCJOpSpinUnbalanced.to_parameters()and accepted byUCJOpSpinUnbalanced.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,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. IfNone, all two-body terms are evaluated in one batch.
- Return type:
- Returns:
A callable that takes a flattened parameter vector and returns the energy value and gradient.