qdk_chemistry.algorithms.scf_solver module

Public entry point for the SCF solver algorithms.

This module re-exports the core ScfSolver so that consumers can import it directly from qdk_chemistry.algorithms without depending on internal package paths.

class qdk_chemistry.algorithms.scf_solver.QdkScfSolver

Bases: ScfSolver

QDK implementation of the SCF solver.

This class provides a concrete implementation of the SCF (Self-Consistent Field) solver using the internal backend. It inherits from the base ScfSolver class and implements the solve method to perform self-consistent field calculations on molecular structures.

Typical usage:

import qdk_chemistry.algorithms as alg
import qdk_chemistry.data as data

# Create a molecular structure
water = data.Structure(
    positions=[[0.0, 0.0, 0.0], [0.0, 0.76, 0.59], [0.0, -0.76, 0.59]],
    elements=[data.Element.O, data.Element.H, data.Element.H]
)

# Create an SCF solver instance
scf_solver = alg.QdkScfSolver()

# Configure settings if needed
scf_solver.settings().set("basis_set", "sto-3g")

# Perform SCF calculation
energy, wavefunction = scf_solver.run(water, 0, 1)
__init__(self: qdk_chemistry.algorithms.QdkScfSolver) None

Default constructor.

Initializes an SCF solver with default settings.

class qdk_chemistry.algorithms.scf_solver.ScfSolver

Bases: pybind11_object

Abstract base class for Self-Consistent Field (SCF) solvers.

This class defines the interface for SCF calculations that compute molecular orbitals from a molecular structure. Concrete implementations should inherit from this class and implement the solve method.

Examples

>>> # To create a custom SCF solver, inherit from this class:
>>> import qdk_chemistry.algorithms as alg
>>> import qdk_chemistry.data as data
>>> class MyScfSolver(alg.ScfSolver):
...     def __init__(self):
...         super().__init__()  # Call the base class constructor
...     # Implement the _run_impl method
...     def _run_impl(self, structure: data.Structure, charge: int, spin_multiplicity: int, initial_guess=None) -> tuple[float, data.Wavefunction]:
...         # Custom SCF implementation
...         return energy, wavefunction
__init__(self: qdk_chemistry.algorithms.ScfSolver) None

Create an ScfSolver instance.

Initializes a new Self-Consistent Field (SCF) solver with default settings. Configuration options can be modified through the settings() method.

Examples

>>> scf = alg.ScfSolver()
>>> scf.settings().set("max_iterations", 100)
>>> scf.settings().set("convergence_threshold", 1e-8)
name(self: qdk_chemistry.algorithms.ScfSolver) str

The algorithm’s name.

Returns:

The name of the algorithm

Return type:

str

run(self: qdk_chemistry.algorithms.ScfSolver, structure: qdk_chemistry.data.Structure, charge: SupportsInt, spin_multiplicity: SupportsInt, basis_or_guess: qdk_chemistry.data.Orbitals | qdk_chemistry.data.BasisSet | str) tuple[float, qdk_chemistry.data.Wavefunction]

Perform SCF calculation on the given molecular structure.

This method automatically locks settings before execution.

Parameters:
  • structure (qdk_chemistry.data.Structure) – The molecular structure to solve

  • charge (int) – The molecular charge

  • spin_multiplicity (int) – The spin multiplicity of the molecular system

  • basis_or_guess (Union[qdk_chemistry.data.Orbitals, qdk_chemistry.data.BasisSet, str]) –

    Basis set information, which can be provided as:

    • A qdk_chemistry.data.BasisSet object

    • A string specifying the name of a standard basis set (e.g., “sto-3g”)

    • A qdk_chemistry.data.Orbitals object to be used as an initial guess

Returns:

Converged total energy (nuclear + electronic) and the resulting wavefunction.

Return type:

tuple[float, qdk_chemistry.data.Wavefunction]

settings(self: qdk_chemistry.algorithms.ScfSolver) qdk_chemistry.data.Settings

Access the solver’s configuration settings.

Returns:

Reference to the settings object for configuring the solver

Return type:

qdk_chemistry.data.Settings

type_name(self: qdk_chemistry.algorithms.ScfSolver) str

The algorithm’s type name.

Returns:

The type name of the algorithm

Return type:

str