sci_solvers.energy_solvers.factory¶
Construct an energy calculator instance by name, and query its capabilities.
This is the entry point external tools (e.g. sweep launchers) use to pick a solver
from a string-valued config.
:func:supports_multiroot / :func:is_general_algebra answer capability questions by
name without constructing the solver.
Add a solver by
adding one _SOLVER_LOADERS entry (and the matching SolverType literal).
Another installed package can add one without editing this file, by declaring an entry point
in the sci_solvers.solvers group (see :data:SOLVER_ENTRY_POINT_GROUP).
AVAILABLE_SOLVERS
module-attribute
¶
AVAILABLE_SOLVERS: tuple[str, ...] = tuple(sorted(_SOLVER_LOADERS))
create_solver
¶
create_solver(solver_type: SolverType | str, **kwargs: Any) -> EnergyCalculatorBase
Construct an energy calculator instance by name.
The unified entry point for sweep launchers and other tools that pick a solver from a config value (e.g. CLI arg, YAML key) and pass it whatever solver-specific kwargs the user supplied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solver_type
|
SolverType | str
|
One of |
required |
**kwargs
|
Any
|
Solver-specific keyword arguments forwarded verbatim
to the chosen solver's
|
{}
|
Returns:
| Type | Description |
|---|---|
EnergyCalculatorBase
|
Initialised energy calculator instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
Examples:
>>> solver = create_solver("pyscf", verbose=True)
>>> result = solver.compute_energy(hamiltonian, configurations)
>>>
>>> solver = create_solver("dice", mpirun_options="-n 4")
>>> result = solver.compute_energy(hamiltonian, configurations, spin_sq=0.0)
>>>
>>> solver = create_solver("sbd", mode="gdb", device="gpu")
>>> result = solver.compute_energy(hamiltonian, configurations)
solver_class
¶
solver_class(solver_type: SolverType | str) -> type[EnergyCalculatorBase]
Return the solver class for solver_type (imported, not constructed).
is_complex_capable
¶
is_complex_capable(solver_type: SolverType | str) -> bool
Whether solver_type can diagonalize a complex Hermitian operator.
supports_multiroot
¶
supports_multiroot(solver_type: SolverType | str) -> bool
Whether solver_type returns more than one root per batch when asked.
is_general_algebra
¶
is_general_algebra(solver_type: SolverType | str) -> bool
Whether solver_type diagonalizes via the general-algebra EigenProblem reduction.
supports_spinless
¶
supports_spinless(solver_type: SolverType | str) -> bool
Whether solver_type accepts a scalar nelec (the flat spin-orbital,
no-alpha/beta-split path -- GHF / SOC / generalized-spinor Hamiltonians).
Not the same set as :func:is_complex_capable: every spinless-capable solver is
also complex-capable (the spinless operator is complex Hermitian by
construction), but the converse does not hold -- a solver can diagonalize a
complex-spatial (n_a, n_b) Hamiltonian without implementing the spinless
(scalar-nelec) reduction at all.
supports_init_vectors
¶
supports_init_vectors(solver_type: SolverType | str) -> bool
Whether solver_type honors a per-call init_vectors (Davidson start vectors).
Lets a caller (e.g. an SQD loop warm-starting each iteration from the previous
one) decide before the call whether to build the vectors at all; the other
solvers raise NotImplementedError when one is passed.