Commit 12ecc79
Refactor DFT+U codes (deepmodeling#7852)
* refactor(dftu): phase 1 - scaffold dftu_base.h/.cpp skeleton
- Add empty Plus_U_Base class in source_pw/module_pwdft/
- Wire into CMakeLists.txt and Makefile.Objects
- No functional change; dftu.h untouched
* refactor(dftu): phase 2 - duplicate base members and implementations to dftu_base
Copy all base-class members (static members, Yukawa members, locale/eff_pot_pw
data structures) and non-inline method implementations from dftu.cpp,
dftu_io.cpp, dftu_occup.cpp, dftu_pw.cpp into dftu_base.h/.cpp under
source_pw/module_pwdft/.
The Plus_U_Base class is a standalone duplicate of Plus_U's base portion.
Plus_U is not yet modified; both classes coexist independently.
init_base has an empty stub body (full implementation deferred to Phase 4).
cal_slater_UJ and other Yukawa calculation methods remain in dftu_yukawa.cpp
as Plus_U methods for now.
Build verified: make -j 30 in build_max_para_test passes with no errors.
* refactor(dftu): phase 3 - Plus_U inherits Plus_U_Base, remove duplicate members
- dftu.h: Plus_U now inherits from Plus_U_Base; LCAO-specific members kept
- dftu.cpp: remove duplicate static member definitions and method
implementations (uramping_update, u_converged) already in dftu_base
- dftu_io.cpp: remove duplicate implementations (output, write_occup_m,
read_occup_m, local_occup_bcast); keep inline JacobiRotate/
CalculateEigenvalues helpers
- dftu_occup.cpp: remove duplicate locale methods (copy_locale,
zero_locale, mix_locale, set_locale, get_locale_flat,
set_locale_flat); keep LCAO-specific cal_occup_m_k/gamma
- dftu_pw.cpp: cal_occ_pw reimplemented as Plus_U_Base::cal_occ_pw
(keeps PW-side OnsiteProjector/Charge_Mixing deps out of dftu_base.cpp)
- dftu_base.h: change private to protected for accessors used by
derived Plus_U; energy_u moved to protected
- test_dftu.cpp: remove duplicate static member definitions; rely on
dftu_base.cpp for Plus_U_Base symbols
- test CMakeLists.txt: add dftu_base.cpp to SOURCES for
MODULE_LCAO_operator_dftu_test
Verified: make -j 30 in build_max_para_test succeeds; all dftu unit
tests pass (dftu_core_test: 10, dftu_pw_test: 11, dftu_operator_test:
15, MODULE_LCAO_operator_dftu_test: 2).
* refactor(dftu): phase 4 - split init() into init_base + LCAO-specific setup
- dftu_base.cpp: implement Plus_U_Base::init_base() containing all
base-only initialization (static members, locale/eff_pot_pw/uom_array
allocation, Yukawa Fk/U_Yukawa/J_Yukawa setup, dm_onsite file reading)
- dftu.cpp: Plus_U::init() now calls init_base() and only retains
LCAO-specific setup (paraV, ptr_orb_, orb_cutoff_, ucell pointer,
parallel orbital dimension checks)
Verified: make -j 30 in build_max_para_test succeeds; all dftu unit
tests pass (dftu_core_test: 10, dftu_pw_test: 11, dftu_operator_test:
15, MODULE_LCAO_operator_dftu_test: 2).
* refactor(dftu): phase 5 - move dftu_pw.cpp to source_pw/module_pwdft
- git mv source_lcao/module_dftu/dftu_pw.cpp -> source_pw/module_pwdft/dftu_pw.cpp
- dftu_pw.cpp: include dftu_base.h instead of dftu.h (cal_occ_pw is now
a Plus_U_Base method, no LCAO types needed)
- source_lcao/module_dftu/CMakeLists.txt: remove dftu_pw.cpp from dftu
OBJECT library
- source_pw/module_pwdft/CMakeLists.txt: add dftu_pw.cpp to module_pwdft
OBJECT library
- Makefile.Objects: add dftu_pw.o to OBJS_SRCPW (was missing entirely
from OBJS_DFTU before)
Verified: make -j 30 in build_max_para_test succeeds; all dftu unit
tests pass (dftu_core_test: 10, dftu_pw_test: 11, dftu_operator_test:
15, MODULE_LCAO_operator_dftu_test: 2).
* refactor(dftu): phase 6 - remove redundant dftu_io.cpp
dftu_io.cpp only contained inline JacobiRotate/CalculateEigenvalues
helpers, which are already duplicated as inline functions in
dftu_base.cpp (where write_occup_m uses them). The file had no
non-inline symbols, so deleting it is safe.
- git rm source_lcao/module_dftu/dftu_io.cpp
- source_lcao/module_dftu/CMakeLists.txt: remove dftu_io.cpp from dftu
OBJECT library
- Makefile.Objects: remove dftu_io.o from OBJS_DFTU
Verified: make -j 30 in build_max_para_test succeeds; all dftu unit
tests pass (dftu_core_test: 10, dftu_pw_test: 11, dftu_operator_test:
15, MODULE_LCAO_operator_dftu_test: 2).
* Phase 7: switch setup_pot/setup_dftu_pw to Plus_U_Base interface
- setup_pot.h/cpp: include dftu_base.h instead of dftu.h
- setup_pot.cpp: parameter type Plus_U& -> Plus_U_Base&
- setup_pot.cpp: call dftu.init_base() instead of dftu.init() with nullptr pv
- setup_dftu_pw.h/cpp: forward declare Plus_U_Base, parameter type updated
- Callers (esolver_ks_pw.cpp) pass this->dftu (Plus_U), bound to Plus_U_Base&
After this phase, the PW path no longer needs LCAO-specific Plus_U headers.
* Phase A: extract output/write_occup_m as free functions in dftu_io namespace
- New files: source_pw/module_pwdft/dftu_output.h, dftu_output.cpp
- declare and implement dftu_io::output and dftu_io::write_occup_m
- first parameter is const Plus_U_Base&, accesses state via public getters
- JacobiRotate and CalculateEigenvalues inline helpers migrated here
- dftu_base.h: added public getters get_U_Yukawa / get_J_Yukawa;
removed output/write_occup_m member declarations
- dftu_base.cpp: removed output/write_occup_m implementations and the
two Jacobi inline helpers (no longer referenced here)
- Callers updated:
- setup_dftu_pw.cpp: dftu.output(...) -> dftu_io::output(dftu, ...)
- setup_dftu_lcao.cpp: dftu_ptr->output(...) -> dftu_io::output(*dftu_ptr, ...)
- CMakeLists.txt and Makefile.Objects: added dftu_output.cpp/dftu_output.o
All 4 dftu unit tests pass.
---------
Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>1 parent f7209c8 commit 12ecc79
19 files changed
Lines changed: 1461 additions & 1352 deletions
File tree
- source
- source_lcao
- module_dftu
- module_operator_lcao/test
- source_pw/module_pwdft
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
741 | 741 | | |
742 | 742 | | |
743 | 743 | | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
744 | 747 | | |
745 | 748 | | |
746 | 749 | | |
| |||
809 | 812 | | |
810 | 813 | | |
811 | 814 | | |
812 | | - | |
813 | 815 | | |
814 | 816 | | |
815 | 817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 24 | + | |
| 25 | + | |
40 | 26 | | |
41 | 27 | | |
42 | 28 | | |
| |||
68 | 54 | | |
69 | 55 | | |
70 | 56 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 57 | | |
77 | 58 | | |
78 | | - | |
| 59 | + | |
79 | 60 | | |
80 | 61 | | |
81 | 62 | | |
| |||
84 | 65 | | |
85 | 66 | | |
86 | 67 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 68 | | |
98 | 69 | | |
99 | 70 | | |
| |||
107 | 78 | | |
108 | 79 | | |
109 | 80 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | 81 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
308 | 98 | | |
309 | 99 | | |
310 | 100 | | |
| |||
465 | 255 | | |
466 | 256 | | |
467 | 257 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
| 258 | + | |
| 259 | + | |
507 | 260 | | |
508 | 261 | | |
509 | 262 | | |
| |||
0 commit comments