From 6ba97799d387354ccf9231916fc18d90c8a78644 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Thu, 23 Jul 2020 08:27:31 +0800 Subject: [PATCH] raise exception when det(cell) < 0 --- source/lib/include/SimulationRegion_Impl.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/lib/include/SimulationRegion_Impl.h b/source/lib/include/SimulationRegion_Impl.h index 2b4ed1a72b..5b3aa2ef02 100644 --- a/source/lib/include/SimulationRegion_Impl.h +++ b/source/lib/include/SimulationRegion_Impl.h @@ -500,6 +500,9 @@ computeVolume() 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 std::runtime_error("Negative volume detected. Please make sure the simulation cell obeys the right-hand rule."); + } } template