Skip to content

SDFT/MDFT: dump plane-wave wavefunctions via out_wfc_pw - #8381

Open
LiYuqiii wants to merge 2 commits into
deepmodeling:developfrom
LiYuqiii:sdft-wfc-dump
Open

LiYuqiii wants to merge 2 commits into
deepmodeling:developfrom
LiYuqiii:sdft-wfc-dump

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

Part 1/3 of the SDFT work reported in #8379 and #8380. This part is a standalone feature (it makes
the SDFT/MDFT wavefunctions visible) and does not fix those two issues; the DOS and entropy fixes
are in part 2/3 (#8382).

Unit Tests and/or Case Tests for my changes

  • Commands run:
    • abacus -h out_wfc_pw
    • mpirun -np 4 abacus on tests/06_SDFT/01_PW_SDFT_10S_M (Al, esolver_type sdft) with
      out_wfc_pw 1
    • the same cell with esolver_type ksdft, nbands 12, out_wfc_pw 1, then
      diff of the headers of wfk1_pw.txt and wfc_sto_k1_pw.txt
    • tests/06_SDFT through tests/integrate/Autotest.sh (24 cases, 116 checks)
    • cmake --build --target abacus_pw_para on top of the current develop
  • Result summary:
    • -h out_wfc_pw reports the new availability
      (basis_type==pw and (esolver_type==ksdft or esolver_type==sdft))
    • the SDFT run writes wfc_sto_k1_pw.txt and wfc_shchi_k1_pw.txt; every coefficient of the raw
      stochastic orbital has |c| = 1/sqrt(nbands_sto) = 0.316228
    • header, <Reciprocal Lattice Vector>, <G vectors> and < Band N > layout of our files is
      identical to the wfk1_pw.txt that the KSDFT solver writes for the same cell
    • tests/06_SDFT: 116/116 checks pass
  • Checks not run, with reason: no unit test is added for the writer itself; it is a pure text
    serialiser whose only meaningful verification is the byte layout compared against the KSDFT output
    of the same cell, which the case test above checks.

What's changed?

out_wfc_pw is accepted for esolver_type=sdft but produced nothing: ESolver_SDFT_PW overrides
iter_finish() and never reaches ModuleIO::write_wfc_pw, so SDFT/MDFT runs could not be inspected
in real space at all.

ESolver_SDFT_PW::after_scf() now dumps, when out_wfc_pw != 0, four sets of orbitals with the
existing wfk{k}_pw.txt text layout (so the same post-processing works unchanged):

  • deterministic (Kohn-Sham) orbitals -> OUT.*/wfc_ks_k*_pw.txt
  • raw stochastic orbitals |chi> -> OUT.*/wfc_sto_k*_pw.txt
  • ones orthogonalized against the KS space -> OUT.*/wfc_chiortho_k*_pw.txt
  • occupation-filtered ones sqrt(f(H))|chi~> that enter the charge density
    -> OUT.*/wfc_shchi_k*_pw.txt

With bndpar > 1 every band group writes its own files (bg<i>_ suffix) and a warning is printed.
No new INPUT keyword is introduced.

Governance Notes

  • INPUT/docs changes: only the availability and the description of the existing out_wfc_pw
    parameter are updated in source_io/module_parameter/read_inp_out.cpp. docs/parameters.yaml and
    docs/advanced/input_files/input-main.md are generated from those Input_Item registrations, so
    there is no documentation update required here.
  • Core module impact: new opt-in step in ESolver_SDFT_PW::after_scf(); the KSDFT path is untouched.
    The writer lives in a new module (module_stodft/sto_wfc_out.{h,cpp}) that takes everything through
    ModuleIO::WfcDumpContext / WfcDumpSpec and has no global-state dependency.
  • Exceptions requested: Global dependency budget (+4 references in output_wfc_sdft()), see below.

Governance Exception

  • Rule: Global dependency budget
  • Reason: building the dump context needs the output directory and the pool / band-group indices,
    and the band-parallel warning goes to the running log. In this version ESolver_SDFT_PW has no
    accessor for them, so the new function reads GlobalV::ofs_running, GlobalV::MY_POOL,
    GlobalV::MY_BNDGROUP and PARAM.globalv.global_out_dir once per run (net +4).
  • Scope: source/source_esolver/esolver_sdft_pw.cpp, function output_wfc_sdft() only.
    module_stodft/sto_wfc_out.* adds no global reference.
  • User or maintenance risk: low. The values are read once, and the whole function returns
    immediately unless out_wfc_pw != 0 and istep == 0.
  • Why the normal rule cannot be followed now: passing them down would change the
    ESolver::after_scf() / ModuleIO interfaces, a much larger cross-layer change than the feature.
  • Follow-up cleanup plan: bundle these values into a small context struct created at the Driver
    level, pass it through after_scf(), and delete the global reads.
  • Requested approver: ABACUS maintainer

3.11 only writes wfk*_pw.txt for esolver_type=ksdft: ESolver_SDFT_PW overrides
iter_finish() and never reaches ModuleIO::write_wfc_pw, so SDFT/MDFT runs cannot
be inspected in real space at all.

Reuse out_wfc_pw as the switch and dump, from after_scf(), the deterministic
(Kohn-Sham) orbitals, the raw stochastic orbitals, the ones orthogonalized
against the KS subspace, and the occupation-filtered ones sqrt(f(H))|chi> that
enter the charge density. The writer reuses the wfk{k}_pw.txt text layout, so
the existing post-processing (FFT to real space) works unchanged.
The Makefile-based build (source/Makefile.Objects) lists its objects explicitly,
so the new writer has to be registered there as well; otherwise
`make -f ../Makefile` fails with an undefined reference to
ModuleIO::write_wfc_pw_txt_selected().

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

Development

Successfully merging this pull request may close these issues.

1 participant