From f982750b1f349e79199f3d86cc1115b76abcf464 Mon Sep 17 00:00:00 2001 From: Morten Kapusta Date: Tue, 7 Apr 2026 15:37:24 +0200 Subject: [PATCH] HOTFIX: NEB tangent estimation: fix division by zero error for flat energy landscapes --- pele/transition_states/_NEB.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pele/transition_states/_NEB.py b/pele/transition_states/_NEB.py index 944870dc6..4cfecb9db 100644 --- a/pele/transition_states/_NEB.py +++ b/pele/transition_states/_NEB.py @@ -316,7 +316,7 @@ def tangent(self, central, left, right, gleft, gright): tright = -gright # special interpolation treatment for maxima/minima - if (central >= left and central >= right) or (central <= left and central <= right): + if (central > left and central > right) or (central < left and central < right): if left > right: t = vmax * tleft + vmin * tright else: @@ -324,9 +324,12 @@ def tangent(self, central, left, right, gleft, gright): # left is higher, take this one elif left > right: t = tleft - # otherwise take right - else: + # right is higher, take this one + elif left < right: t = tright + # flat section (i.e. all energy levels equal) -> fallback to original NEB tangent + else: + t = tleft / norm(tleft) + tright / norm(tright) return t / norm(t)