sci_solvers.energy_solvers.general_algebra_solvers.primme¶
PRIMME selected-CI solver (needs the primme extra).
PrimmeSolver
[source]
¶
PrimmeSolver(*, max_restarts: int | None = None, a_norm: float | None = 1.0, **kwargs: Any)
Bases: SpinFilterMixin, GeneralAlgebraSolverBase
PRIMME (eigsh) solver with a Jacobi preconditioner (needs the primme extra).
max_restarts: forwarded to primme.eigsh's maxiter directly (no n scaling).
None (default) preserves the prior behavior -- self.maxiter * n in
:meth:_diagonalize -- so existing callers see no change. Set this explicitly for a
flat, size-independent iteration budget, mirroring :class:ArpackSolver's identical
max_restarts knob (added there for the same maxiter * n scaling issue).
a_norm: forwarded to primme.eigsh as aNorm. PRIMME's default stopping test is
||A v - lambda v|| < tol * ||A|| with ||A|| an internal running estimate of the
spectral norm, so tol is relative and its absolute meaning varies per molecule. When
a_norm is set, PRIMME uses it verbatim as ||A|| in that test, so the default
a_norm=1.0 makes tol an absolute residual bound, the same quantity the
Davidson-family solvers use. Pass None to keep PRIMME's own ||A|| estimate (the
relative behavior this solver had before a_norm 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, spin_filter: bool | None = None, **kwargs: Any) -> List[EigenStates]
Oversolve (when possible), then keep the roots whose <S^2> matches spin_sq.
A pure passthrough when spin_sq is None or not active (the
common case) -- nelec and ci_strs_batches flow through
unexamined to the wrapped solver, so this works on the spinless path
(a scalar nelec) exactly as far as the wrapped solver itself
does. The classification step below (_keep_target_spin /
_spin_square) is spatial-only (<S^2> has no meaning without
an alpha/beta split, and it reads SCIState.ci_strs_a/ci_strs_b,
which a spinless SpinlessSCIState does not carry), so an active
filter on a scalar nelec is rejected outright rather than left to
fail with an unrelated-looking AttributeError deep in
_spin_square.
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. |