Skip to content

Commit

Permalink
fix(tf): throw errors when loc_cellnum is 0
Browse files Browse the repository at this point in the history
Fix #4122.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz committed Oct 2, 2024
1 parent ad8bebe commit 9f40295
Showing 1 changed file with 7 additions and 0 deletions.
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 @@ void deepmd::compute_cell_info(
}
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

0 comments on commit 9f40295

Please sign in to comment.