diff --git a/source/lib/include/SimulationRegion_Impl.h b/source/lib/include/SimulationRegion_Impl.h index 528402b7d6..341ae8f1dd 100644 --- a/source/lib/include/SimulationRegion_Impl.h +++ b/source/lib/include/SimulationRegion_Impl.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "errors.h" // using namespace std; @@ -501,10 +502,8 @@ computeVolume() boxt[0*3+0] * (boxt[1*3+1]*boxt[2*3+2] - boxt[2*3+1]*boxt[1*3+2]) - boxt[0*3+1] * (boxt[1*3+0]*boxt[2*3+2] - boxt[2*3+0]*boxt[1*3+2]) + boxt[0*3+2] * (boxt[1*3+0]*boxt[2*3+1] - boxt[2*3+0]*boxt[1*3+1]); - volumei = static_cast(1.)/volume; - if (volume < 0) { - throw deepmd::deepmd_exception("Negative volume detected. Please make sure the simulation cell obeys the right-hand rule."); - } + volume = std::abs(volume); + volumei = static_cast(1.)/volume; } template diff --git a/source/lib/src/region.cc b/source/lib/src/region.cc index d8333e4929..8ce37c0584 100644 --- a/source/lib/src/region.cc +++ b/source/lib/src/region.cc @@ -1,5 +1,6 @@ #include #include +#include #include "region.h" #include "errors.h" #define BOXT_DIM 9 @@ -33,9 +34,7 @@ compute_volume(const FPTYPE * boxt) boxt[0*3+0] * (boxt[1*3+1]*boxt[2*3+2] - boxt[2*3+1]*boxt[1*3+2]) - boxt[0*3+1] * (boxt[1*3+0]*boxt[2*3+2] - boxt[2*3+0]*boxt[1*3+2]) + boxt[0*3+2] * (boxt[1*3+0]*boxt[2*3+1] - boxt[2*3+0]*boxt[1*3+1]); - if (volume < 0) { - throw deepmd::deepmd_exception("Negative volume detected. Please make sure the simulation cell obeys the right-hand rule."); - } + volume = std::abs(volume); return volume; }