Skip to content

refactor(dfpt): move the ASR family to dfpt_phon_asr.cpp - #8260

Merged
mohanchen merged 5 commits into
deepmodeling:developfrom
Zanthoxylum:refactor-dfpt-phon-asr
Nov 2, 2026
Merged

mohanchen merged 5 commits into
deepmodeling:developfrom
Zanthoxylum:refactor-dfpt-phon-asr

Conversation

@Zanthoxylum

Copy link
Copy Markdown
Collaborator

Summary

audit_asr and apply_asr (the per-direction physical residual audit
and the simple/crystal enforcement with the mass-weighted symmetric
projection and the Born-charge sum rule) move verbatim from
dfpt_phon.cpp (689 → 380 lines) to the new dfpt_phon_asr.cpp,
restoring one-file-one-concern mapping; the sibling splits already in
the tree are dfpt_phon_ewald.cpp (ion-ion) and dfpt_phon_elec.cpp
(electronic 2n+1), so the ASR family completes the set.

  • Class declaration and call sites unchanged (pure implementation-file
    move); the file-header comment of dfpt_phon.cpp updated to point at
    the three companion files.
  • Build surfaces updated per the file-move checklist:
    source/Makefile.Objects, source/source_pw/module_dfpt/CMakeLists.txt
    (pyabacus does not list DFPT sources).

What did NOT change

No behavior change: the moved bodies are verbatim.

Verification

cmake --build build-gcc13 --target abacus_basic_para MODULE_DFPT_phon_serial -j 20
ctest --test-dir build-gcc13 -R "MODULE_DFPT"      # 10/10 targets Passed
  • Anchors against the pre-change baseline (branch binary): si_G and
    bn_hex_G full DFPT reruns — phonon frequencies and the QE-format
    dyn.q0 output bit-identical to the pre-move results.

Documentation

No docs change needed: internal file organization only, no INPUT,
interface, or behavior change.

audit_asr and apply_asr (the per-direction physical residual audit and
the simple/crystal enforcement with the mass-weighted symmetric
projection and the Born-charge sum rule) move verbatim from
dfpt_phon.cpp (689 -> 380 lines) to the new dfpt_phon_asr.cpp, matching
the Phase-1 test file test_dfpt_phon_asr.cpp. Class declaration and
call sites unchanged; build surfaces updated (Makefile.Objects,
module_dfpt CMakeLists; pyabacus does not list DFPT sources).
MODULE_DFPT 10/10; si_G/bn_hex_G anchor reruns verified bit-identical
frequencies and dyn files against the E5 baseline.
@Zanthoxylum Zanthoxylum added Refactor Refactor ABACUS codes DFPT Density Functional Perturbation Theory labels Nov 2, 2026
… dfpt_phon.cpp

The MODULE_DFPT_phon_serial and MODULE_DFPT_pw_run_test targets compile
the DFPT sources directly, so the moved apply_asr/audit_asr definitions
must be added to their SOURCES (only the main library lists were
updated). Rebuild from a deleted binary + full MODULE_DFPT ctest: 10/10.
@Zanthoxylum
Zanthoxylum force-pushed the refactor-dfpt-phon-asr branch from 94a6a3f to a6f3e96 Compare November 2, 2026 07:28

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No split-induced correctness regression found. Static review covered the moved method bodies, affected callers and build source lists; no build or runtime tests were run.

… file; include <algorithm>

The header comment referenced test_dfpt_phon_asr.cpp, which does not
exist yet; point at the current dfpt_phon_serial_test.cpp. Include
<algorithm> directly for std::max instead of relying on transitive
standard-library includes. Rebuild from deleted binaries + full
MODULE_DFPT ctest: 10/10.

@mohanchen mohanchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…-asr

# Conflicts:
#	source/source_pw/module_dfpt/test/CMakeLists.txt
#	source/source_pw/module_dfpt/test_serial/CMakeLists.txt
@Zanthoxylum
Zanthoxylum requested a review from mohanchen November 2, 2026 14:03
@mohanchen
mohanchen merged commit aef2795 into deepmodeling:develop Nov 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DFPT Density Functional Perturbation Theory Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants