sci_solvers.energy_solvers.general_algebra_solvers.pyscf_davidson¶
PySCF fixed-space Davidson selected-CI solver (native spin projection).
PyscfDavidsonSolver
[source]
¶
PyscfDavidsonSolver(*, spin_sq: float | None = None, davidson_block_size: int | None = None, **kwargs: Any)
Bases: GeneralAlgebraSolverBase
PySCF fixed-space Davidson solver — reads raw integrals, projects spin natively.
Does NOT mix in :class:~sci_solvers.energy_solvers.spin_filter_mixin.SpinFilterMixin:
it targets a spin sector directly via PySCF's fix_spin_ penalty
(spin_sq). It bypasses the matrix-free operator (and thus the packed sector
view), always solving the full space.
It cannot represent a non-product determinant basis — kernel_fixed_space
builds a PySCF SCIvector over the Cartesian product of strs_a x strs_b —
so mode="gdb" is rejected (supports_gdb = False). For the same reason
hamiltonian_backend="fulqrum" is rejected (supports_fulqrum_backend = False):
it would build an operator this solver never reads.
spin_sq: target total spin squared, projected via PySCF fix_spin_.
davidson_block_size: Davidson subspace size, the number of vectors kept
before a restart -- same meaning as on PySCFSolver, converted to PySCF's
max_space by :func:davidson_block_size_to_max_space. None (default)
leaves max_space unset, i.e. PySCF's own default, as before this
parameter existed.
compute_energy
¶
compute_energy(ci_strs_batches: List[Tuple[ndarray, ndarray]] | None = None, bitstring_matrix_batches: List[ndarray] | None = None, sort_ci_strs: bool = True, **solver_call_kwargs: Any) -> List[SCIResult]
Compute energies for each batch of CI strs.
Note - to get from bitstrings into ci_strs you can use:
from qiskit_addon_sqd.fermion import bitstring_matrix_to_ci_strs
ci_strs = bitstring_matrix_to_ci_strs(bitstrings_to_use, open_shell=False) #or open_shell==True, depending on your case
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ci_strs_batches
|
List[Tuple[ndarray, ndarray]] | None
|
List of |
None
|
bitstring_matrix_batches
|
List[ndarray] | None
|
List of boolean NumPy matrices, one per batch.
Provide exactly one of this argument or |
None
|
sort_ci_strs
|
bool
|
Sort and deduplicate each batch's alpha/beta CI strings with
|
True
|
**solver_call_kwargs
|
Any
|
Additional kwargs forwarded to |
{}
|
sci_solver_callable_eigen_states
¶
sci_solver_callable_eigen_states(ci_strs_batches: 'List[Tuple[np.ndarray, np.ndarray]] | List[np.ndarray]', hcore: ndarray, eri: ndarray, norb: int, nelec: 'Tuple[int, int] | int', *, nroots: int | None = None, **kwargs: Any) -> List[EigenStates]
Diagonalize each batch's CI subspace via :meth:_diagonalize.
Three reduction paths are dispatched on the integral dtype and nelec:
- real spatial — real integrals,
(n_a, n_b)tuple: build an :class:~sci_solvers.eigen_problem.EigenProblemper(strs_a, strs_b). - complex spatial — complex Hermitian integrals,
(n_a, n_b)tuple: build a :class:~sci_solvers.eigen_problem.HermitianOperatorvia :func:~sci_solvers.complex_ci_problem.build_selected_complex_ci_problem. - complex spinless — a scalar
nelec(totalN): each batch is a flatstrsarray; see :meth:_solve_spinless_batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ci_strs_batches
|
'List[Tuple[np.ndarray, np.ndarray]] | List[np.ndarray]'
|
|
required |
hcore
|
ndarray
|
One-electron integrals, shape |
required |
eri
|
ndarray
|
Two-electron integrals, full 4-index chemists' notation (may be complex). |
required |
norb
|
int
|
Number of spatial orbitals (spin-orbitals |
required |
nelec
|
'Tuple[int, int] | int'
|
|
required |
nroots
|
int | None
|
Solve-time override of the constructor |
None
|
**kwargs
|
Any
|
Accepted for API parity; forwarded to the base guard.
|
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
List[EigenStates]
|
class: |
List[EigenStates]
|
order, each holding the lowest |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If, in |
sci_solver_callable
¶
sci_solver_callable(ci_strs_batches: 'List[Tuple[np.ndarray, np.ndarray]] | List[np.ndarray]', hcore: ndarray, eri: ndarray, norb: int, nelec: 'Tuple[int, int] | int', **kwargs: Any) -> List[SCIResult]
Diagonalize each batch's CI-string subspace, returning ground states.
The qiskit-addon-sqd entry point: matches the sci_solver signature
expected by qiskit_addon_sqd.fermion.diagonalize_fermionic_hamiltonian.
Thin wrapper over :meth:sci_solver_callable_eigen_states that keeps
each batch's ground state (root 0) and discards the excited states,
since the SQD recovery loop consumes only the ground state. To access
excited states, call :meth:sci_solver_callable_eigen_states directly.
Note - to get from bitstrings into ci_strs you can use:
from qiskit_addon_sqd.fermion import bitstring_matrix_to_ci_strs
ci_strs = bitstring_matrix_to_ci_strs(bitstrings_to_use, open_shell=False) #or open_shell==True, depending on your case
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ci_strs_batches
|
'List[Tuple[np.ndarray, np.ndarray]] | List[np.ndarray]'
|
List of |
required |
hcore
|
ndarray
|
One-electron integrals, shape |
required |
eri
|
ndarray
|
Two-electron repulsion integrals. Either full 4-D
|
required |
norb
|
int
|
Number of spatial orbitals. |
required |
nelec
|
'Tuple[int, int] | int'
|
|
required |
**kwargs
|
Any
|
Solver-specific optional arguments. See each concrete solver for the accepted set. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
List[SCIResult]
|
class: |
List[SCIResult]
|
order. |
|
List[SCIResult]
|
themselves to obtain chemical totals. |