Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ void FixDPLR::pre_force(int vflag) {
// }
// cout << endl;
// }

// re-init dfele
dfele.resize(nlocal * 3);
for (int ii = 0; ii < nlocal * 3; ++ii) {
dfele[ii] = 0.0;
}
}

/* ---------------------------------------------------------------------- */
Expand All @@ -611,8 +617,7 @@ void FixDPLR::post_force(int vflag) {
int nlocal = atom->nlocal;
int nghost = atom->nghost;
int nall = nlocal + nghost;
vector<FLOAT_PREC> dcoord(nall * 3, 0.0), dbox(9, 0.0),
dfele(nlocal * 3, 0.0);
vector<FLOAT_PREC> dcoord(nall * 3, 0.0), dbox(9, 0.0);
vector<int> dtype(nall, 0);
// set values for dcoord, dbox, dfele
{
Expand Down
1 change: 1 addition & 0 deletions source/lmp/fix_dplr.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class FixDPLR : public Fix {
double compute_scalar(void) override;
double compute_vector(int) override;
double ener_unit_cvt_factor, dist_unit_cvt_factor, force_unit_cvt_factor;
std::vector<double> dfele;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add documentation for the new public interface.

The dfele vector is now part of the public interface and accessible to external modules. Consider adding documentation to clarify its purpose, lifecycle, and thread safety considerations.

+ // Public vector for external force modifications on local atoms
+ // Size: nlocal * 3, reset and initialized in pre_force()
+ // Note: External modifications are overwritten on each pre_force() call
  std::vector<double> dfele;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
std::vector<double> dfele;
// Public vector for external force modifications on local atoms
// Size: nlocal * 3, reset and initialized in pre_force()
// Note: External modifications are overwritten on each pre_force() call
std::vector<double> dfele;
🤖 Prompt for AI Agents
In source/lmp/fix_dplr.h at line 60, the newly added public member
std::vector<double> dfele lacks documentation. Add clear comments above its
declaration explaining its purpose, how and when it should be used, its
lifecycle, and any thread safety considerations to guide external module users.


private:
PairDeepMD *pair_deepmd;
Expand Down
Loading