Skip to content

SDFT: fix the high-temperature DOS blow-up and the Ne/TS precision asymmetry - #8382

Open
LiYuqiii wants to merge 1 commit into
deepmodeling:developfrom
LiYuqiii:sdft-dos-ts-fix
Open

LiYuqiii wants to merge 1 commit into
deepmodeling:developfrom
LiYuqiii:sdft-dos-ts-fix

Conversation

@LiYuqiii

@LiYuqiii LiYuqiii commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the exact verification commands run and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver / HSolver / ElecState / Hamilt / Operator / Psi.
  • I have requested any needed governance exception below.

Linked Issue

Fixes #8379.
Fixes #8380.

Part 2/3 of the series; part 3/3 is #8383.

Unit Tests and/or Case Tests for my changes

What's changed?

Four defects made SDFT/DOS unusable at high temperature:

  • Math_Chebyshev::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 integral of the
    density of states.
  • 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.

Governance Notes

  • INPUT/docs changes: no new keyword; the behaviour of dos_scale, dos_nche, emin_sto and
    emax_sto is unchanged for healthy input (the window is repaired only when it is out of range).
    No default or interface changes, so there is no documentation update required.
  • Core module impact: module_stodft only (Sto_DOS, Sto_Tool, Sto_Func, Stochastic_Iter,
    Stochastic_WF); no change in the KSDFT solver.
  • Exceptions requested: Global dependency budget (+11 references, all in warning/reporting paths of
    the SDFT range checks), see below.

Governance Exception

  • Rule: Global dependency budget
  • Reason: the repaired range and the new consistency diagnostics are reported through
    GlobalV::ofs_running, the same channel the existing SDFT warnings use. The added reads happen at
    most once per run (or once per SCF step in the range check).
  • Scope: source/source_pw/module_stodft/sto_dos.cpp, sto_iter.cpp, sto_tool.cpp.
  • User or maintenance risk: low. No behavioural change for healthy runs; the messages are what makes
    a silent DOS/entropy failure visible.
  • Why the normal rule cannot be followed now: Sto_DOS / Sto_Tool are not given an output stream,
    and threading one through would change the ESolver <-> module_stodft interface.
  • Follow-up cleanup plan: pass an std::ostream& (or a small logging context) down from the esolver
    and remove the GlobalV::ofs_running reads, together with the same cleanup as part 1/3.
  • Requested approver: ABACUS maintainer

…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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant