refactor(aocscf): replace Dz0SCF with average-occupation ROKS - #17
Merged
Merged
Conversation
wtpeter
force-pushed
the
refactor/dz0scf
branch
from
September 26, 2026 00:58
43ab0dd to
9a7b25c
Compare
Betty0621
approved these changes
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
dz0scfreference with an average-occupation ROKS interface while retaining the existing orbital optimization and high-spin gradient definition. This PR intentionally removes the oldDZ0SCFAPI.Changes relative to Dz0SCF
mol.ROKS(xc=...).average_occ()(also supported on plainSymAdaptedROKS) instead ofDZ0SCF(mol, xc=...). Importingnest.aocscfregisters the method. The oldnest.dz0scfmodule,DZ0SCFfactory, and direct gradient aliases are removed.get_veffon the total density and is supplied to ROHF as two identical spin blocks. The old implementation called UKSget_veffwith two equal spin densities.energy_tot()evaluates the average-occupation energy. After_finalize,mf.e_avg_occholds that energy andmf.e_totholds the high-spin energy evaluated with the converged orbitals. Previouslymf.e_totheld the average-occupation energy andmf.high_spin_energy()was a separate call. Consequently,mf.energy_tot()and the finalizedmf.e_tothave different meanings.nest.grad.aocscf. Its Z-vector equation, explicit high-spin derivative, and numerical reference tests are retained. The material implementation change is that the intermediate RKS/ROKS evaluators uselib.view(mf, ...)instead of constructing fresh objects and copying selected DFT settings. Bothmf.nuc_grad_method()andmf.Gradients()return this driver.examples/aocscfto the NTTDA example.Reviewer focus
Please check the RKS versus equal-spin UKS potential equivalence, the finalized
e_tot/energy_tot()contract, and whether thelib.viewchange preserves the intended high-spin gradient for other XC functionals and symmetry-adapted references. The gradient tests still cover NH2/PBE and triplet CH2/B3LYP; they do not cover the symmetry-adapted gradient.Verification
OMP_NUM_THREADS=2 python -m pytest src/nest/aocscf/tests/test_aocscf.py src/nest/grad/tests/test_aocscf_grad.py src/nest/nttda/tests/test_nttda_aocscf.py -q— 6 passed.mf.Gradients()andmf.nuc_grad_method()both returnnest.grad.aocscf.Gradients.python -m ruff check .andgit diff --check— passed.