Commit 0484e5b
Refactor DFT+U step 2 (deepmodeling#7858)
* refactor(dftu): rename member locale/locale_save -> occ_mat/occ_mat_save (Step 1/5)
- Rename Plus_U_Base data members: locale -> occ_mat, locale_save -> occ_mat_save
- Update all direct member access sites in:
* dftu_base.h inline get_locale/set_locale bodies and doc examples
* dftu_base.cpp (init allocation, copy/zero/mix/set internal, flat conv,
read_occup_m, local_occup_bcast MPI, Memory::record tag)
* dftu_pw.cpp (cal_occ_pw: becp accumulation, k-pool reduce, VU & energy)
* dftu.cpp (cal_energy_correction trace & double-counting terms)
* dftu_occup.cpp (LCAO cal_occup_m_k/_gamma S*DM accumulation, MPI
Allreduce, symmetrization via transpose)
* dftu_tools.cpp (get_onebody_eff_pot new/saved branches)
* test_dftu.cpp (setup resize/create, EXPECT assertions on values)
- Public API names (get_locale, set_locale, copy_locale, zero_locale,
mix_locale, set_locale_flat, is_locale_initialized, etc.) are kept
unchanged in this step to keep the change surface minimal.
7 files changed, 133 insertions(+), 133 deletions(-).
* refactor(dftu): rename get_locale/set_locale -> get_occ_mat/set_occ_mat (Step 2/5)
Rename the public single-element accessors of Plus_U_Base:
get_locale(iat,l,n,spin,m1,m2) -> get_occ_mat(...)
set_locale(iat,l,n,spin,m1,m2,val) -> set_occ_mat(...)
Update all 5 direct call sites:
* dftu_output.cpp (4 calls in dftu_io::write_occup_m for output)
* dftu_lcao.cpp (1 call in DFTU cal_occ fallback branch)
The protected batch overload set_locale(const UnitCell&) and the other
state/flat helpers (copy_locale, zero_locale, mix_locale, get_locale_flat,
set_locale_flat, is_locale_initialized, mark_*) are intentionally kept
unchanged and will be renamed in the following steps.
3 files changed, 7 insertions(+), 7 deletions(-).
* refactor(dftu): rename flat/state funcs + fix initialed_locale spelling (Step 3/5)
Rename Plus_U_Base flat-conversion and state-management APIs:
get_locale_flat -> get_occ_mat_flat
set_locale_flat -> set_occ_mat_flat
is_locale_initialized -> is_occ_mat_initialized
mark_locale_initialized-> mark_occ_mat_initialized
mark_locale_dirty -> mark_occ_mat_dirty
Also fix a long-standing spelling bug: the member variable
bool initialed_locale
was renamed to
bool occ_mat_initialized
(initialed -> initialized + naming aligned with occ_mat_* convention).
Header declarations updated in dftu_base.h, plus definitions and all
call sites updated across:
* dftu_base.cpp (defs + mark_locale_initialized calls in init_base)
* dftu_lcao.cpp (~16 call sites + doc comments)
* dftu_fs.cpp (1 get_occ_mat_flat call)
* dftu_hamilt.cpp (2 is_occ_mat_initialized calls)
* setup_dftu_lcao.cpp (1 mark_occ_mat_initialized call)
* dftu_occup.cpp (is/mark calls in cal_occup_m_*)
* dftu.cpp (1 is_occ_mat_initialized call in cal_energy_correction)
8 files changed, 36 insertions(+), 36 deletions(-).
* refactor(dftu): rename protected copy/zero/mix/set_locale -> *_occ_mat (Step 4/5)
Rename the four protected internal helpers of Plus_U_Base and their
ModuleBase::TITLE / timer tag strings for consistency:
copy_locale(ucell) -> copy_occ_mat(ucell)
zero_locale(ucell) -> zero_occ_mat(ucell)
mix_locale(ucell, mixing_beta) -> mix_occ_mat(ucell, mixing_beta)
set_locale(ucell) -> set_occ_mat(ucell)
The single-argument batch setter set_occ_mat(const UnitCell&) now
overloads the public element-wise setter set_occ_mat(iat,l,n,spin,m1,m2,val)
with a different signature — no ambiguity, no change to callers.
Declarations (dftu_base.h), definitions + internal call sites in
dftu_base.cpp (init_base flow, also all TITLE/timer labels), and
call sites in cal_occ_pw (dftu_pw.cpp) and cal_occup_m_{k,gamma}
(dftu_occup.cpp) are all updated together.
4 files changed, 32 insertions(+), 32 deletions(-).
* refactor(dftu): cleanup comments, tests, parameter names (Step 5/5)
Final cleanup pass to align naming after the locale -> occ_mat rename:
* dftu_lcao.cpp (~40 lines):
- Replace identifier-style 'locale' / 'Locale' references in the
contributeHR() doc block and inline comments with 'occ_mat' /
'Occ_mat', including stale 'via get_locale()' / 'get_locale uses'
mentions that no longer match the API.
- Rename local bool flag locale_not_init -> occ_mat_not_init.
* dftu_pw.cpp (4 lines): Fix the 4 remaining comments that still
referred to 'locale matrix' / 'reduce locale' / 'locale reduced'
in the cal_occ_pw implementation notes.
* dftu_occup.cpp (2 lines): Update the top-of-file function inventory
comment: set_locale(ucell) -> set_occ_mat(ucell); get/set_locale_flat
-> get/set_occ_mat_flat.
* dftu_tools.cpp (12 lines): Rename bool parameter 'newlocale' ->
'new_occ_mat' and its 3 internal uses in cal_VU_pot_mat_{complex,real}
and get_onebody_eff_pot signatures/bodies, so the parameter name
matches the occ_mat naming convention.
* dftu_core_test.cpp (28 lines):
- copy_locale_to_flat -> copy_occ_mat_to_flat (def + 3 call sites)
- set_locale_from_flat -> set_occ_mat_from_flat (def + 3 call sites)
- LocaleRoundtripTest -> OccMatRoundtripTest (test fixture + 2 TEST_F)
- Related header comments: 'copy_locale <-> set_locale roundtrip',
'nested locale matrix' updated accordingly.
* dftu_pw_test.cpp (6 lines):
- 'Locale accumulation from becp' -> 'Occupation matrix accumulation
from becp' in the test description;
- 'set_locale is tested via integration tests.' -> 'set_occ_mat is
tested via integration tests.'
Not touched: pure semantic/mathematical local variable names inside
the test helpers (locale_up, locale_dn, locale_c, compute_vu(locale_val),
compute_energy(locale_flat), etc.) - these are local symbolic
placeholders independent of the Plus_U_Base member naming.
6 files changed, 49 insertions(+), 49 deletions(-).
* refactor(dftu): move DFT+U operator from module_operator_lcao to module_dftu
Move DFTU/OperatorDFTU<OperatorLCAO> operator implementation files
(dftu.hpp, dftu_lcao.h/cpp, dftu_fs.cpp, op_dftu_lcao.h/cpp) and the
related unit test (test_dftu.cpp -> dftu_lcao_test.cpp) from
module_operator_lcao to module_dftu. This is a step toward removing
module_operator_lcao and grouping DFT+U code by physical domain.
CMake changes:
- module_dftu CMakeLists adds the 3 cpp files guarded by ENABLE_LCAO,
since module_dftu is unconditionally added by source_lcao while
these files depend on operator_lcao.h
- module_operator_lcao CMakeLists drops the 3 cpp files
- source_lcao CMakeLists drops the 3 cpp entries from the hamilt_lcao
OBJECT library (now provided by the dftu OBJECT library)
- New dftu_lcao_test target guarded by ENABLE_LCAO AND ENABLE_MPI
matches the original MODULE_LCAO_operator_dftu_test build condition
Include path updates in 5 external call sites plus op_dftu_lcao.h
internal operator_lcao.h path (changed from same-directory relative
to full path since the file is no longer co-located).
Verified: cmake configure, make abacus_max_para + dftu_lcao_test,
and ctest dftu_pw_test/dftu_core_test/dftu_operator_test/dftu_lcao_test
all pass; agent_governance_check reports only include-path change
warnings with no errors.
---------
Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>1 parent c9bae03 commit 0484e5b
27 files changed
Lines changed: 281 additions & 272 deletions
File tree
- source
- source_io/module_hs
- source_lcao
- module_dftu
- test
- module_operator_lcao
- test
- source_pw/module_pwdft
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | | - | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
| 197 | + | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| |||
File renamed without changes.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
0 commit comments