-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lmp): add pair_deepmd_index arg to fix dplr for multiple deepmd pairs #4274
Conversation
…airs Fix deepmodeling#4273. Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
📝 WalkthroughWalkthroughThe pull request introduces enhancements to the documentation and implementation of the Deep Potential Long Range (DPLR) model in LAMMPS. Key updates include the addition of an optional Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
source/lmp/fix_dplr.h (1)
83-85
: Enhance documentation for pair_deepmd_index
The implementation looks good, but the documentation could be more comprehensive to help users avoid potential issues.
Consider expanding the comment to clarify:
/* The index of deepmd pair index, which starts from 1. By default 0, which
- * works only when there is one deepmd pair. */
+ * works only when there is one deepmd pair. When using hybrid/scaled pair_style
+ * with multiple deepmd pairs, specify the index (1-based) of the desired pair. */
doc/model/dplr.md (2)
Line range hint 201-212
: Consider adding a usage example with multiple pair_style deepmd.
The documentation for the new pair_deepmd_index
parameter is clear and follows LAMMPS conventions. To make it more user-friendly, consider adding a practical example demonstrating its usage with multiple pair_style deepmd
commands, as this is the primary use case for this parameter.
Example suggestion:
pair_style hybrid/scaled deepmd model1.pb deepmd model2.pb
pair_coeff 1 1 1
pair_coeff 2 2 2
fix 0 all dplr model ener.pb type_associate 1 3 bond_type 1 pair_deepmd_index 2
🧰 Tools
🪛 Markdownlint
215-215: null
Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
228-229
: Consider adding error handling information.
The documentation clearly states when pair_deepmd_index
must be used. To improve user experience, consider adding information about what error message users might encounter if they don't set the index when using multiple pair_style deepmd commands.
Suggested addition:
"If multiple pair_style deepmd are used without specifying pair_deepmd_index, an error will be raised indicating that the index is required for disambiguation."
source/lmp/fix_dplr.cpp (1)
129-134
: Enhance error handling for pair_deepmd_index argument.
While the basic error checking is present, consider these improvements:
- Add bounds checking for the index value
- Provide more descriptive error messages that include the expected format
Consider this enhancement:
} else if (string(arg[iarg]) == string("pair_deepmd_index")) {
if (iarg + 1 >= narg) {
- error->all(FLERR, "Illegal pair_deepmd_index, not provided");
+ error->all(FLERR, "Illegal pair_deepmd_index: expected a non-negative integer argument");
}
pair_deepmd_index = atoi(arg[iarg + 1]);
+ if (pair_deepmd_index < 0) {
+ error->all(FLERR, "pair_deepmd_index must be non-negative");
+ }
iarg += 2;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- doc/model/dplr.md (3 hunks)
- source/lmp/fix_dplr.cpp (3 hunks)
- source/lmp/fix_dplr.h (1 hunks)
🔇 Additional comments (3)
source/lmp/fix_dplr.h (1)
83-85
: Verify initialization and usage of pair_deepmd_index
The member variable addition looks correct, but let's ensure proper integration.
Let's verify the initialization and usage:
✅ Verification successful
Let me analyze the constructor and argument parsing to verify the initialization of this new member.
Member variable is properly initialized and integrated
The verification shows proper integration of pair_deepmd_index
:
- Default initialization to 0 in constructor
- Command-line argument parsing with error handling via
pair_deepmd_index
keyword - Correct usage in
pair_match
for DeepMD pair style lookup - Appropriate error handling if pair style is not found
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check initialization in constructor and usage in pair matching
echo "Checking constructor initialization:"
rg -A 5 "FixDPLR::FixDPLR.*LAMMPS"
echo -e "\nChecking pair matching usage:"
rg "pair_match.*pair_deepmd_index"
echo -e "\nChecking for potential hybrid pair style handling:"
rg "hybrid.*scaled.*deepmd"
Length of output: 791
Script:
#!/bin/bash
# Check initialization and usage of pair_deepmd_index
echo "Checking pair_deepmd_index initialization:"
rg -B 5 -A 2 "pair_deepmd_index" source/lmp/fix_dplr.cpp
echo -e "\nChecking constructor and parse_args for initialization:"
rg -A 10 "parse_args" source/lmp/fix_dplr.cpp
echo -e "\nChecking all usages of pair_deepmd_index:"
rg "pair_deepmd_index" source/lmp/fix_dplr.cpp
Length of output: 1651
source/lmp/fix_dplr.cpp (2)
65-65
: LGTM: Proper initialization of pair_deepmd_index.
The default value of 0 maintains backward compatibility for single pair usage.
151-154
: LGTM: Proper implementation of indexed pair matching.
The modification correctly implements support for multiple deepmd pairs while maintaining clear error messaging.
Let's verify the pair_style configuration:
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #4274 +/- ##
==========================================
- Coverage 84.37% 84.36% -0.01%
==========================================
Files 551 551
Lines 51585 51591 +6
Branches 3052 3054 +2
==========================================
+ Hits 43524 43525 +1
- Misses 7100 7105 +5
Partials 961 961 ☔ View full report in Codecov by Sentry. |
Fix #4273.
Summary by CodeRabbit
New Features
pair_deepmd_index
in thefix dplr
command for enhanced control in simulations.Bug Fixes
pair_deepmd_index
parameter to ensure proper usage.Documentation