QCANT.qkud#

QCANT.qkud(symbols: Sequence[str], geometry, *, n_steps: int, epsilon: float, active_electrons: int, active_orbitals: int, basis: str = 'sto-3g', charge: int = 0, spin: int = 0, method: str = 'pyscf', device_name: str | None = None, initial_state: object | None = None, overlap_tol: float = 1e-10, normalize_basis: bool = True, basis_threshold: float = 0.0, use_sparse: bool = False, return_min_energy_history: bool = False) Tuple[object, object] | Tuple[object, object, object][source]#

Generate a QKUD Krylov basis and diagonalize the Hamiltonian in that basis.

The basis is built using the recurrence in Eq. (3) of the QKUD formulation: |psi_n> = (X + X^†) / (2 * epsilon) |psi_{n-1}| with X = i * exp(-i * epsilon * H).

Parameters:
  • symbols – Atomic symbols.

  • geometry – Nuclear coordinates, array-like with shape (n_atoms, 3) in Angstrom.

  • n_steps – Number of QKUD steps. The returned basis contains n_steps + 1 vectors (including the initial state).

  • epsilon – Error parameter used in the QKUD recurrence (must be > 0).

  • active_electrons – Number of active electrons.

  • active_orbitals – Number of active orbitals.

  • basis – Basis set name understood by PennyLane/PySCF (e.g. "sto-3g").

  • charge – Total molecular charge.

  • spin – Spin parameter used by PySCF as 2S (e.g. 0 for singlet).

  • method – Backend used by PennyLane quantum chemistry tooling (default: "pyscf").

  • device_name – Unused; present for API compatibility with other algorithms.

  • initial_state – Optional statevector to seed the Krylov basis. If not provided, the Hartree–Fock state is used.

  • overlap_tol – Threshold for discarding near-linearly dependent basis vectors when orthonormalizing the basis via the overlap matrix eigen-decomposition.

  • normalize_basis – If True, normalize each Krylov vector to avoid numerical overflow.

  • basis_threshold – Drop amplitudes with absolute value below this threshold after each basis update. The thresholded state is re-normalized. Use 0.0 to disable thresholding.

  • use_sparse – If True, use a sparse Hamiltonian representation for state updates.

  • return_min_energy_history – If True, also return the minimum energy after each QKUD step.

Notes

This implementation enforces a real-valued Hamiltonian by dropping tiny imaginary parts in the coefficients. This keeps simulator backends like lightning.qubit stable when numerical noise introduces complex terms.

Returns:

(energies, basis_states) where:

  • energies is a real-valued array of eigenvalues obtained by diagonalizing the Hamiltonian projected into the generated basis.

  • basis_states is a complex-valued array with shape (n_steps+1, 2**n_qubits).

If return_min_energy_history=True, the function returns (energies, basis_states, min_energy_history) where min_energy_history has shape (n_steps,) and contains the minimum energy after each step (using the basis with k+1 vectors).

Return type:

tuple