fix dplr: correct type check in get_valid_pairs#2580
Merged
wanghan-iapcm merged 17 commits intodeepmodeling:develfrom Jun 5, 2023
Merged
fix dplr: correct type check in get_valid_pairs#2580wanghan-iapcm merged 17 commits intodeepmodeling:develfrom
wanghan-iapcm merged 17 commits intodeepmodeling:develfrom
Conversation
for more information, see https://pre-commit.ci
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## devel #2580 +/- ##
==========================================
- Coverage 76.67% 76.66% -0.02%
==========================================
Files 233 233
Lines 24158 24175 +17
Branches 1710 1697 -13
==========================================
+ Hits 18524 18533 +9
- Misses 4507 4519 +12
+ Partials 1127 1123 -4
☔ View full report in Codecov by Sentry. |
njzjz
requested changes
Jun 2, 2023
njzjz
approved these changes
Jun 2, 2023
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…to fix_dplr_dpl_type
for more information, see https://pre-commit.ci
wanghan-iapcm
approved these changes
Jun 5, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The binary_search method in C++ is only valid for sorted vectors.
The following case in "type_associate" of "fix dplr" will raise error: 4 5 3 6. 4 and 3 are real atom types and stored in sel_type. The vector sel_type is sorted. 5 and 6 are associated with 4 and 3, respectively. The resulting sel_type vector is 3 4, and the resulting dpl_type vector is 6 5. If a pair 4 5 is searched, then this line
deepmd-kit/source/lmp/fix_dplr.cpp
Lines 195 to 196 in e7d68c1
will do binary search for 4 in 3 4, which results in True; and will search for 5 in 6 5, which results in False.
Therefore, I am copying dpl_type vector to the dpl_type_sorted vector and sort it. The binary search should be used on the sorted vector.
The above solution is abandoned.
In stead, do not use binary_search in the type check of get_valid_pairs.
The current method is: first find the type of the real atom, and check if the type of its bonded atom is consistent with that defined by type_associate.