Repository navigation
Conversation
…ymmetry Four defects made SDFT/DOS unusable at high temperature: * checkconverge() uses tmin == 0 as its "uninitialized" sentinel, so a positive trial Rayleigh quotient leaves Emin > 0 and excludes every bound state; the upper bound is underestimated in the same path. * the DOS stage re-derived the range from (0, 0) instead of inheriting the converged SCF range, and Stochastic_WF::nchi was never initialized, so the range probe always used random vectors. * dos_scale widened the reported window by 0.5% per side without widening the Chebyshev interval, so T_n(|x| > 1) grew exponentially: DOS values of 1e26--1e64 instead of the 2*N_pw integral. * the entropy density computed 1 - f by subtraction, and returned 0 for |x| > 36: the sqrt(g) coefficient tail was lifted from ~1e-19 to ~1e-12, which made E_entropy(-TS) two orders of magnitude too large while Ne stayed exact. Stochastic_Iter::dot() also ignored its arguments, so the reported precision was meaningless. Fixes: repair the range at the call sites, inherit the SCF range in the DOS stage, initialize nchi, expand the Chebyshev interval to contain the output grid, evaluate the entropy density with s = min(f, 1-f) and log1p(-s), and make dot() use the passed arrays. Adds a unit test for the entropy kernels.
…tests Add ModuleIO::sto_dos_quality with two groups of pure (global-state free, unit-tested) helpers: * sanitize_che_range(): repairs the Chebyshev window so that it covers the known deterministic eigenvalues, the plane-wave spectrum top (1.05*ecutwfc) and the requested DOS output grid. Healthy input is returned bit for bit unchanged. Used by both the SCF range check (Sto_Tool::check_che_op) and the DOS stage (Sto_DOS::decide_param), replacing two copies of an inline heuristic that read PARAM directly. * check_dos_parameters() / check_dos_result(): warn (never abort) when dos_edelta_ev and dos_sigma are mismatched, dos_nche cannot resolve range/sigma (reporting the estimated order), the range/sigma ratio is prohibitive, the DOS integral does not reproduce 2*sum_k npwk, the curve goes visibly negative, or an output energy left the Chebyshev interval. The integral check is skipped when the window truncates the spectrum on purpose. Adds unittests/test_sto_dos_quality.cpp (14 cases).
7 tasks done
Sto_Tool::check_che_op() now calls ModuleIO::sanitize_che_range(), so the pre-existing MODULE_PW_Sto_Tool_UTs target (which compiles ../sto_tool.cpp) needs ../sto_dos_quality.cpp as well; otherwise the target fails to link in the BUILD_TESTING configuration.
The Makefile-based build (source/Makefile.Objects) lists its objects explicitly, so the new quality-guard translation unit has to be registered there too; otherwise `make -f ../Makefile` fails with an undefined reference to ModuleIO::sanitize_che_range().
This was referenced Nov 24, 2026
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 currently contains part 2 as well; after
#8382 is merged the diff of this PR reduces to the 4 files listed below).
Unit Tests and/or Case Tests for my changes
ctest -R MODULE_PW_STO --output-on-failure(two targets, 18TESTcases:test_sto_func.cppand the newtest_sto_dos_quality.cppwith 14 cases)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 deliberatelybad DOS parameters
cmake --build --target abacus_pw_paraon top of the currentdevelopctest -R MODULE_PW_STO: 2/2 targets, 18/18 cases passtests/06_SDFT: 116/116 checks pass; the two existing DOS cases emit no new warnings(
dos_sigma 0.05 eV,dos_edelta_ev 5,dos_nche 50): 4 warnings, the run still completestests/; the two behaviour groups arepure functions covered by the new unit test, and the end-to-end effect is covered by
tests/06_SDFT.What's changed?
New module
ModuleIO::sto_dos_qualitywith pure (global-state free, unit-tested) helpers:sanitize_che_range()repairs the Chebyshev window so that it covers the known deterministiceigenvalues, the plane-wave spectrum top (
1.05*ecutwfc) and the requested DOS output grid(
|t| <= 1by construction). Healthy input is returned bit for bit unchanged and the function isidempotent. It replaces two copies of an inline heuristic (
Sto_Tool::check_che_op,Sto_DOS::decide_param) and takesecutwfc, the eigenvalues and the output window as argumentsinstead of reading
PARAM.check_dos_parameters()/check_dos_result()emit warnings only (never abort):dos_edelta_evvsdos_sigmamismatch,dos_ncheinsufficient forrange/sigma(with theestimated order), prohibitive
range/sigma, DOS integral not reproducing the number of states,visibly negative DOS, and an output energy that left the Chebyshev interval. The integral check is
skipped when the window truncates the spectrum on purpose and for spin-polarized runs.
Files: new
module_stodft/sto_dos_quality.{h,cpp}andmodule_stodft/unittests/test_sto_dos_quality.cpp,plus the wiring in
sto_dos.{h,cpp},sto_tool.cpp,module_stodft/CMakeLists.txtandmodule_stodft/unittests/CMakeLists.txt.Governance Notes
There is no documentation update required for this change.
module_stodftonly. The new module is dependency-free (noPARAM, noGlobalV), which is also what makes it unit-testable.Global dependency budget(+3 references on top of SDFT: fix the high-temperature DOS blow-up and the Ne/TS precision asymmetry #8382, in the reportingpath), see below.
Governance Exception
GlobalV::ofs_running, the channel the SDFT stagealready uses. The guarded calls run once per DOS calculation.
source/source_pw/module_stodft/sto_dos.cpponly;sto_dos_quality.*adds no globalreference.
healthy parameter sets.
is passed into
module_stodft.esolver).