From 6581233c54e22ac174e2c2f9b995b4b02ce7ca03 Mon Sep 17 00:00:00 2001 From: keitaroyam Date: Mon, 11 Dec 2023 23:19:50 +0900 Subject: [PATCH] chiral_abs_volume: avoid nan Chiral volume may become NaN in come cases. An example is the current PRO's chir_2, which will be fixed by https://github.com/MonomerLibrary/monomers/pull/38 --- include/gemmi/chemcomp.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gemmi/chemcomp.hpp b/include/gemmi/chemcomp.hpp index f831666b..06c87656 100644 --- a/include/gemmi/chemcomp.hpp +++ b/include/gemmi/chemcomp.hpp @@ -311,7 +311,7 @@ inline double chiral_abs_volume(double bond1, double bond2, double bond3, x -= cosine * cosine; y *= cosine; } - return mult * std::sqrt(x + y); + return mult * std::sqrt(std::max(0., x + y)); } inline double Restraints::chiral_abs_volume(const Restraints::Chirality& ch) const {