Skip to content

Refactor DFT+U compact occupation writer - #8196

Merged
mohanchen merged 7 commits into
deepmodeling:developfrom
lanshuyue:codex/refactor-dftu-io-writer-pr
Oct 23, 2026
Merged

mohanchen merged 7 commits into
deepmodeling:developfrom
lanshuyue:codex/refactor-dftu-io-writer-pr

Conversation

@lanshuyue

Copy link
Copy Markdown
Collaborator

Summary

  • remove the legacy DFT+U occupation-matrix text writer and retain the compact format
  • split compact matrix serialization into dftu_base_io_write.cpp and update Makefile/CMake source lists
  • preserve the existing collinear and SOC eigenvalue helper implementations for a follow-up eigensystem-output PR
  • simplify occupation-output interfaces and snapshot orchestration
  • add compact writer/reader roundtrip coverage for collinear, SOC Pauli, and real spin-basis layouts

Validation

  • built abacus_basic_para successfully
  • MODULE_PW_dftu_base_test: 26/26 passed
  • MODULE_DFTU_base_io: 6/6 passed
  • code quality score: dftu_base_io.cpp 85, dftu_base_io_write.cpp 98

Scope

This PR intentionally does not add occupation eigenvector output. That numerical and output-format change will be handled in a separate follow-up PR.

@lanshuyue lanshuyue added DFT+U Issues related to DFT plus U function Refactor Refactor ABACUS codes labels Oct 21, 2026
Resolve CMake conflicts with latest develop formatting:
- source/source_pw/module_pwdft/CMakeLists.txt
- source/source_pw/module_pwdft/test/CMakeLists.txt
- source/source_lcao/module_dftu/unittests/CMakeLists.txt

Keep dftu_base_io_write.cpp entries added by this PR while adopting
develop's unified CMake formatting.

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

Static review of a612a74 found no new correctness defect in the inspected paths. git diff --check passed; the pinned governance check completed with warnings. No builds or runtime tests were run; CI was unavailable.

Non-blocking: Please add the exact configure/build/CTest/quality commands and relevant configuration behind the reported results, and state why no documentation update is required: the production compact format and INPUT behavior are unchanged.

Comment thread source/source_pw/module_pwdft/test/dftu_base_test.cpp
Comment thread source/source_pw/module_pwdft/setup_dftu_pw.cpp Outdated
- Remove the trailing first_scf_step return and its output-cadence
  comment from iter_init_dftu_pw; output() was removed earlier, so
  the guard no longer controls anything.
- Extend the compact writer roundtrip tests to assert the serialized
  mag and nelec header values against values computed from the source
  occupation matrix, including the nonzero y magnetization in the
  SOC Pauli case. read_occup_m only checks these fields for finiteness,
  so matrix-only comparisons could not detect an incorrect diagnostic.
@lanshuyue

Copy link
Copy Markdown
Collaborator Author

@ABACUS-PR-BOT Review comments addressed in 98cd900.

Verification commands and results (Intel oneAPI 2024.0, build/ configured with default CMake options, LCAO on):

cmake -S . -B build
make -C build -j$(nproc) abacus_basic_para          # passed
./build/source/source_pw/module_pwdft/test/MODULE_PW_dftu_base_test --gtest_filter="*CompactWriter*"  # 3/3 passed
ctest --test-dir build -R "MODULE_DFTU_|MODULE_PW_dftu|MODULE_PW_test_dftu"  # 15/15 passed

(LD_LIBRARY_PATH extended with intel/oneapi/mkl/2024.0/lib and intel/oneapi/compiler/2024.0/lib for local runtime only.)

No documentation update required: this PR only splits the occupation-matrix writer into dftu_base_io_write.cpp and adds unit tests; the production compact file format and all INPUT behavior are unchanged, so no user-facing documentation is affected.

@lanshuyue
lanshuyue requested a review from mohanchen October 22, 2026 02:03
Comment thread source/source_pw/module_pwdft/setup_dftu_pw.cpp
Comment thread source/source_pw/module_pwdft/setup_dftu_pw.cpp
@lanshuyue lanshuyue mentioned this pull request Oct 22, 2026
7 tasks done
@mohanchen
mohanchen merged commit 370ba68 into deepmodeling:develop Oct 23, 2026
18 checks passed
@mohanchen

Copy link
Copy Markdown
Collaborator

LGTM.

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

Labels

DFT+U Issues related to DFT plus U function Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants