Skip to content
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(tf): throw errors when loc_cellnum is 0 #4180

Merged
merged 1 commit into from
Oct 7, 2024
Merged
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
7 changes: 7 additions & 0 deletions source/lib/src/coord.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <vector>

#include "SimulationRegion.h"
#include "errors.h"
#include "neighbor_list.h"

using namespace deepmd;
Expand Down Expand Up @@ -95,6 +96,12 @@
}
cell_info[21] = (cell_info[3 + 0]) * (cell_info[3 + 1]) *
(cell_info[3 + 2]); // loc_cellnum
if (cell_info[21] <= 0) {
throw deepmd::deepmd_exception(

Check warning on line 100 in source/lib/src/coord.cc

View check run for this annotation

Codecov / codecov/patch

source/lib/src/coord.cc#L100

Added line #L100 was not covered by tests
"loc_cellnum should be positive but is " +
std::to_string(cell_info[21]) +

Check warning on line 102 in source/lib/src/coord.cc

View check run for this annotation

Codecov / codecov/patch

source/lib/src/coord.cc#L102

Added line #L102 was not covered by tests
". You may give a PBC box with zero volume.");
}
cell_info[22] = (2 * cell_info[12 + 0] + cell_info[3 + 0]) *
(2 * cell_info[12 + 1] + cell_info[3 + 1]) *
(2 * cell_info[12 + 2] + cell_info[3 + 2]); // total_cellnum
Expand Down