qdk_chemistry.plugins.pyscf.scf_solver module
PySCF-based Self-Consistent Field (SCF) solver implementation for qdk_chemistry.
This module provides integration between QDK/Chemistry and PySCF for performing Self-Consistent Field calculations supporting both Hartree-Fock (HF) and Density Functional Theory (DFT) methods. It implements solvers that can be used within the QDK/Chemistry framework for electronic structure calculations.
The module contains:
PyscfScfSettings: Configuration class for SCF calculation parametersPyscfScfSolver: Main solver class that performs HF and DFT calculationsRegistration utilities to integrate the solver with QDK/Chemistry’s plugin system
The solver handles automatic conversion between QDK/Chemistry molecular structures and PySCF format, performs the SCF calculation using the specified method (HF or DFT functional), and returns results (energy and orbitals) in QDK/Chemistry-compatible format. It supports various basis sets and exchange-correlation functionals through the settings interface.
Upon import, this module automatically registers the PySCF solver with QDK/Chemistry’s SCF solver registry under the name “pyscf”.
>>> from qdk_chemistry.plugins.pyscf.scf_solver import PyscfScfSolver
>>> solver = PyscfScfSolver()
>>> solver.settings()["method"] = "b3lyp" # Use B3LYP DFT
>>> energy, orbitals = solver.run(molecule, 0, 1, "sto-3g")
This module requires both QDK/Chemistry and PySCF to be installed. The solver supports both restricted and unrestricted variants for both HF and DFT calculations.
- class qdk_chemistry.plugins.pyscf.scf_solver.PyscfScfSettings[source]
Bases:
ElectronicStructureSettingsSettings configuration for the PySCF SCF solver.
This class manages the configuration parameters for the PySCF Self-Consistent Field (SCF) solver, inheriting common electronic structure defaults from ElectronicStructureSettings and adding PySCF-specific customizations.
Inherits from ElectronicStructureSettings: - method (str, default=”hf”): The electronic structure method (Hartree-Fock). - basis_set (str, default=”def2-svp”): The basis set used for quantum chemistry calculations. Common options include “def2-svp”, “def2-tzvp”, “cc-pvdz”, etc. - convergence_threshold (float, default=1e-7): Convergence tolerance for orbital gradient norm. - max_iterations (int, default=50): Maximum number of iterations. - scf_type (str, default=”auto”): Type of SCF calculation. Can be: “auto”: Automatically detect based on spin (RHF for singlet, UHF for open-shell) “restricted”: Force restricted calculation (RHF/ROHF for HF, RKS/ROKS for DFT) “unrestricted”: Force unrestricted calculation (UHF for HF, UKS for DFT)
PySCF specific setting: - xc_grid: Integer DFT integration grid density level passed to PySCF (0=coarse, 9=very fine).
Examples
>>> settings = PyscfScfSettings() >>> settings.get("max_iterations") 50 >>> settings.set("max_iterations", 100) >>> settings.get("max_iterations") 100
Notes
The PySCF SCF solver is used for performing self-consistent field calculations in quantum chemistry, which are fundamental for determining electronic structure and molecular properties.
- class qdk_chemistry.plugins.pyscf.scf_solver.PyscfScfSolver[source]
Bases:
ScfSolverPySCF-based Self-Consistent Field (SCF) solver for quantum chemistry calculations.
This class provides an interface between QDK/Chemistry and PySCF for performing both Hartree-Fock (HF) and Density Functional Theory (DFT) calculations on molecular systems. It handles the conversion between QDK/Chemistry structuresand PySCF molecular representations, performs the SCF calculation, and returns the results in QDK/Chemistry-compatible format.
The solver supports:
Hartree-Fock (HF): method=”hf” uses RHF/UHF/ROHF
DFT methods: any other method string is treated as an XC functional (e.g., “b3lyp”, “pbe”, “m06”)
The solver automatically selects restricted/unrestricted variants based on spin and the scf setting, returning electronic energy (excluding nuclear repulsion) along with molecular orbitals information.
Examples
>>> solver = PyscfScfSolver() >>> solver.settings()["method"] = "b3lyp" # Use B3LYP DFT >>> energy, orbitals = solver.run(molecule_structure, charge=0, spin_multiplicity=1, "6-31G*") >>> print(f"Electronic energy: {energy} Hartree")
See also
ScfSolver : Base class for SCF solvers PyscfScfSettings : Settings configuration for PySCF calculations