Skip to content

refactor(dfpt): split the DFPT_PW_Data response-field slots to dfpt_pw_data_resp.cpp - #8261

Merged
mohanchen merged 5 commits into
deepmodeling:developfrom
Zanthoxylum:refactor-dfpt-pw-data-io
Nov 2, 2026
Merged

mohanchen merged 5 commits into
deepmodeling:developfrom
Zanthoxylum:refactor-dfpt-pw-data-io

Conversation

@Zanthoxylum

Copy link
Copy Markdown
Collaborator

Summary

The largest DFPT module file, dfpt_pw_data.cpp (791 lines), is split
by subsystem. The bound-safe getters/setters of the per-direction /
per-q response fields (u_active, docc, v_sc, the displacement /
E-field response stashes drho_disp / dpsi_disp / pos_resp /
dpsi_efield, and the drho_r / drho_g / dv_r / dv_recip_c /
dv_rc slot family) move verbatim to the new
dfpt_pw_data_resp.cpp (413 lines). The driver state stays behind in
dfpt_pw_data.cpp (402 lines): lifecycle (init/clean/allocate), the
q-list delegation and validate_q_ordering, the dpsi / convergence /
residual ledger, and the dynmat / phonon-frequency / dielectric / Born
tensors.

  • Class declaration and call sites unchanged (pure implementation-file
    move).
  • 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_write_dyn_serial \
  MODULE_DFPT_rho_serial MODULE_DFPT_phon_serial -j 20
ctest --test-dir build-gcc13 -R "MODULE_DFPT"      # 10/10 targets Passed
  • Anchor against the pre-change baseline (branch binary): si_G full
    DFPT rerun — 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.

…w_data_resp.cpp

The bound-safe getters/setters of the per-direction / per-q response
fields (u_active, docc, v_sc, the displacement / E-field response
stashes and the drho / dv slot family) move verbatim from
dfpt_pw_data.cpp (791 -> 402 lines) to the new dfpt_pw_data_resp.cpp
(413 lines); the driver state (lifecycle, q delegation, validate_q_
ordering, the dpsi / convergence ledger, dynmat / phonon tensors,
drhoc) stays behind. Class declaration and call sites unchanged; build
surfaces updated (Makefile.Objects, module_dfpt CMakeLists). MODULE_DFPT
10/10; si_G anchor rerun verified bit-identical frequencies and dyn file
against the E5 baseline.
@Zanthoxylum Zanthoxylum added Refactor Refactor ABACUS codes DFPT Density Functional Perturbation Theory labels Nov 2, 2026
…e test targets

dfpt_pw_data_resp.cpp dereferences the Plus_U_Base reservation in
u_active, which is only forward-declared in dfpt_pw_data.h -- include
dftu_base.h for the complete type (the main build surfaces list only
made the link error invisible in the test targets). The test targets
that compile dfpt_pw_data.cpp directly also need the new
dfpt_pw_data_resp.cpp in their SOURCES. Rebuild from deleted binaries +
full MODULE_DFPT ctest: 10/10.
@Zanthoxylum
Zanthoxylum force-pushed the refactor-dfpt-pw-data-io branch from ffee306 to 114bbce Compare November 2, 2026 07:33

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

After the response-field split, dfpt_pw_data.cpp only passes and stores
a Plus_U_Base pointer; the forward declaration in dfpt_pw_data.h is
sufficient and the complete type is needed only by u_active() in
dfpt_pw_data_resp.cpp. All DFPT test binaries rebuilt from deleted
binaries (make rc=0); full MODULE_DFPT ctest: 10/10.
…ata-io

# Conflicts:
#	source/source_pw/module_dfpt/test/CMakeLists.txt
#	source/source_pw/module_dfpt/test_serial/CMakeLists.txt
@mohanchen
mohanchen merged commit 405c6d1 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