fix(lmp): clear DPLR PPPM force cache#5744
Conversation
📝 WalkthroughWalkthroughIntroduces a private Changesfele Clearing Refactor
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant Compute as PPPMDPLR::compute
participant Init as PPPMDPLR::init
participant FieldforceIK as PPPMDPLR::fieldforce_ik
participant FieldforceAD as PPPMDPLR::fieldforce_ad
participant ClearFele as PPPMDPLR::clear_fele
Init->>ClearFele: reset fele buffer
Compute->>ClearFele: reset fele on qsqsum == 0.0
FieldforceIK->>ClearFele: reset fele buffer
FieldforceAD->>ClearFele: reset fele buffer
ClearFele->>ClearFele: resize fele to nlocal*3 and fill with 0.0
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
source/lmp/pppm_dplr.cpp (1)
51-55: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: use
assigninstead ofresize+fill.
fele.assign(static_cast<size_t>(nlocal) * 3, 0.0);achieves the same result in one call.♻️ Optional simplification
void PPPMDPLR::clear_fele() { int nlocal = atom->nlocal; - fele.resize(static_cast<size_t>(nlocal) * 3); - fill(fele.begin(), fele.end(), 0.0); + fele.assign(static_cast<size_t>(nlocal) * 3, 0.0); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@source/lmp/pppm_dplr.cpp` around lines 51 - 55, The clear_fele() method in PPPMDPLR currently resizes fele and then fills it with zeros in two steps; simplify this by using fele.assign(static_cast<size_t>(nlocal) * 3, 0.0) to initialize the buffer in one call. Keep the behavior the same and update only the fele initialization logic inside PPPMDPLR::clear_fele().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@source/lmp/pppm_dplr.cpp`:
- Around line 51-55: The clear_fele() method in PPPMDPLR currently resizes fele
and then fills it with zeros in two steps; simplify this by using
fele.assign(static_cast<size_t>(nlocal) * 3, 0.0) to initialize the buffer in
one call. Keep the behavior the same and update only the fele initialization
logic inside PPPMDPLR::clear_fele().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 585df065-3b96-4ee5-ba19-0facf93c76a9
📒 Files selected for processing (2)
source/lmp/pppm_dplr.cppsource/lmp/pppm_dplr.h
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5744 +/- ##
==========================================
- Coverage 81.36% 81.22% -0.14%
==========================================
Files 991 991
Lines 111198 111200 +2
Branches 4235 4234 -1
==========================================
- Hits 90474 90324 -150
- Misses 19199 19349 +150
- Partials 1525 1527 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
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
Summary by CodeRabbit
Bug Fixes
Refactor