QCANT.exact_krylov#
- QCANT.exact_krylov(symbols: Sequence[str], geometry, *, n_steps: int, 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, krylov_method: str = 'exact', use_sparse: bool = False, return_min_energy_history: bool = False) Tuple[object, object] | Tuple[object, object, object][source]#
Generate a Krylov basis and diagonalize the Hamiltonian in that basis.
The basis is built as
{|psi>, H|psi>, H^2|psi>, ...}up ton_steps. Energies are obtained by diagonalizing the Hamiltonian projected into the generated basis after overlap-based orthonormalization.- Parameters:
symbols – Atomic symbols.
geometry – Nuclear coordinates, array-like with shape
(n_atoms, 3)in Angstrom.n_steps – Number of Krylov steps. The returned basis contains
n_steps + 1vectors (including the initial state).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 – PennyLane device name used only to prepare the HF state if
initial_stateis not provided.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. This applies to
krylov_method="exact".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.
krylov_method – Krylov construction method. Use
"exact"for raw powers ofH, or"lanczos"to build an orthonormal Krylov basis.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 Krylov 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:energiesis a real-valued array of eigenvalues obtained by diagonalizing the Hamiltonian projected into the generated basis.basis_statesis 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)wheremin_energy_historyhas shape(n_steps,)and contains the minimum energy after each step (using the basis withk+1vectors).- Return type:
tuple