Commit 33593b1
authored
fix(lmp): clear DPLR PPPM force cache (#5744)
## Summary
- add a small helper to resize and zero the DPLR PPPM fele cache
- clear fele before returning from PPPMDPLR::compute when qsqsum == 0
- reuse the same helper in init and fieldforce paths
This addresses #5647 as a defensive consistency fix. In normal DeePMD
DPLR usage, atom charges are fixed and are not changed from nonzero to
all-zero during a run, so this stale-cache path should not be triggered
by standard DeePMD workflows. It would only matter for unusual external
charge mutation or reinitialization paths where qsqsum is refreshed to
zero after a previous nonzero-charge PPPM/DPLR step.
## Tests
- git diff --check
- /tmp/deepmd-check-venv/bin/ruff check .
- /tmp/deepmd-check-venv/bin/ruff format --check .
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved consistency in per-atom field/force handling by clearing the
accumulator before early exits and during setup.
* Reduced the chance of stale values carrying over between calculations.
* **Refactor**
* Consolidated repeated zeroing and resizing steps into a shared
internal routine, simplifying the calculation flow and making the code
easier to maintain.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 7b0050f commit 33593b1
2 files changed
Lines changed: 13 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
60 | | - | |
61 | 68 | | |
62 | | - | |
63 | | - | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| 98 | + | |
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
| |||
296 | 303 | | |
297 | 304 | | |
298 | 305 | | |
299 | | - | |
300 | | - | |
| 306 | + | |
301 | 307 | | |
302 | 308 | | |
303 | 309 | | |
| |||
372 | 378 | | |
373 | 379 | | |
374 | 380 | | |
375 | | - | |
376 | | - | |
| 381 | + | |
377 | 382 | | |
378 | 383 | | |
379 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
0 commit comments