Repository navigation
Conversation
7 tasks done
This was referenced Nov 24, 2026
Four defects made SDFT/DOS unreliable at high electronic temperature: * Math_Chebyshev::checkconverge() treats tmin == 0 as its "uninitialized" sentinel, so a positive trial Rayleigh quotient can leave Emin > 0 and exclude every bound state; the upper bound is underestimated in the same path. * the DOS stage re-derived the range from the input defaults instead of keeping the converged SCF range, and Stochastic_WF::nchi was never initialized, so the range probe always used random vectors even for MDFT. * dos_scale widened the reported window by 0.5% per side without any relation to the Chebyshev interval, so a grid point could sit outside the spectral range. * the entropy density formed 1 - f by subtraction and returned 0 for |x| > 36, which lifted the sqrt(g) coefficient tail from ~1e-19 to ~1e-12, and Stochastic_Iter::dot() ignored the arrays it was given, so the printed Chebyshev "precision" of the stochastic trace was not the quantity it claimed. Fixes: keep the converged SCF range in the DOS stage, initialize nchi, repair a positive automatic lower bound and an underestimated upper bound at the call sites (an explicitly given emin_sto is preserved, since a positive spectrum is valid), clip the requested output window to the spectral interval instead of widening the interval, evaluate the entropy density with s = min(f, 1-f) and log1p(-s), and make dot() contract the arrays that the caller passes. The range probe now also carries one independent random vector next to the real stochastic orbitals: with `nbands_sto all` those orbitals are coordinate vectors, so a handful of them can miss a diagonal state of another invariant subspace. The new unit test for the entropy kernels fails on the unpatched sto_func.cpp and passes here; dos_nche >= 2 is documented in its INPUT metadata.
Move the Chebyshev-window repair and the DOS diagnostics of the SDFT solver into one small, global-state-free module (`module_stodft/sto_dos_quality`) and cover it with unit tests: * `sanitize_che_range()` repairs the window so that it covers the known deterministic eigenvalues and the plane-wave spectrum top (`1.05*ecutwfc`), replaces a pathological positive lower bound and enforces a minimum width. Healthy input is returned bit for bit unchanged and the function is idempotent. It replaces the two inline copies of the heuristic in `Sto_Tool::check_che_op` and `Sto_DOS::decide_param` and takes the cutoff and the eigenvalues as arguments instead of reading them from the caller's globals. The interval is deliberately *not* widened to fit a requested DOS output grid: at a fixed Chebyshev order that lowers the resolution, so the output window is clipped to the spectrum instead (part 2/3). * `check_dos_parameters()` reports `dos_edelta_ev` vs `dos_sigma` mismatches and a `dos_nche` that cannot resolve `range/dos_sigma` (with the estimated order); `check_dos_result()` reports a curve that goes visibly negative or an output energy outside the interval. Both only return messages: the caller logs them as `WARNING: DOS: ...` and never aborts a long run. Adds `unittests/test_sto_dos_quality.cpp` (13 cases).
LiYuqiii
force-pushed
the
sdft-dos-quality
branch
from
November 25, 2026 09:05
a5a9bf5 to
44737d3
Compare
This branch has not been deployed
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.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.Linked Issue
Addresses #8379 (part 3/3). Depends on #8382; this branch is based on it and will be rebased
onto
developonce #8382 is merged.Unit Tests and/or Case Tests for my changes
ctest -R "MODULE_PW_STO|MODULE_PW_Sto_Tool" --output-on-failure(three targets, 17TESTcases)tests/06_SDFTthroughtests/integrate/Autotest.sh(24 cases, 116 checks)mpirun -np 4 abacuson the 1-atom 348 eV DOS case of SDFT: DOS values of 1e52 at high electronic temperature #8379 with healthy and with deliberately badDOS parameters
cmake --build --target abacus_pw_paraon top of SDFT: fix the high-temperature DOS blow-up and the Ne/TS precision asymmetry #8382MODULE_PW_STO_DOS_QUALITY_UTs(13 cases) passes, as do the existingMODULE_PW_STO_FUNC_UTsandMODULE_PW_Sto_Tool_UTsdos_sigma 20 eV,dos_edelta_ev 0.5,dos_nche 600): 0 warnings and∫ DOS dE = 12806.6, i.e. the curve does not changedos_sigma 0.07 eV,dos_edelta_ev 0.05,dos_nche 100): twoWARNING: DOS: ...lines (order needed ~1e4, range/sigma prohibitive) and the run completes;max |DOS| = 34.0 eV^-1instead of the historical1e52tests/; both behaviour groups arepure functions covered by the unit test and the end-to-end effect is covered by
tests/06_SDFT.What's changed?
New module
ModuleIO::sto_dos_quality(pure functions, noPARAM/GlobalV):sanitize_che_range(emin, emax, ecutwfc, det_eigs)repairs the Chebyshev window so that it coversthe known deterministic eigenvalues and the plane-wave spectrum top (
1.05*ecutwfc), replaces apathological positive lower bound and enforces a minimum width. Healthy input is returned bit for
bit unchanged and the function is idempotent. It replaces the two inline copies of the heuristic in
Sto_Tool::check_che_opandSto_DOS::decide_paramand takes the cutoff and the eigenvalues asarguments. The interval is not widened to fit a requested output window: at a fixed order that
lowers the resolution and can hide a resolved peak, so the window is clipped to the spectrum
instead (part 2/3).
check_dos_parameters(range, sigma, de, nche)reportsdos_edelta_evvsdos_sigmamismatches anda
dos_nchethat cannot resolverange/dos_sigma(with the estimated order);check_dos_result(min_dos, max_abs_t)reports a curve that goes visibly negative or an outputenergy outside the interval. Both only return messages, so the caller logs them as
WARNING: DOS: ...and never aborts a long run.Files: new
module_stodft/sto_dos_quality.{h,cpp}andmodule_stodft/unittests/test_sto_dos_quality.cpp,plus the wiring in
sto_dos.cpp,sto_tool.cpp,module_stodft/CMakeLists.txt,module_stodft/test/CMakeLists.txt,module_stodft/unittests/CMakeLists.txtand the Makefile objectlist.
Governance Notes
There is no documentation update required for this change.
module_stodftonly. The new module has no global-state dependency, which isalso what makes it unit-testable.
Global dependency budget, see below.Governance Exception
GlobalV::ofs_running, the channel the SDFT stagealready uses, and the sanitiser has to know the plane-wave cutoff (
PARAM.inp.ecutwfc). Both areread once per call; the cutoff is part of the repair arithmetic and stays after the logging cleanup.
source/source_pw/module_stodft/sto_dos.cppandsto_tool.cpp;sto_dos_quality.*adds noglobal reference.
module_stodft; threading them through would change theESolver<->module_stodftinterface.esolver, then drop the
GlobalV::ofs_running/PARAM.inp.ecutwfcreads here.