From 19bc62a6b760f530f7eee4a0f582718e13288414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Wed, 24 Apr 2024 15:28:33 +0200 Subject: [PATCH] fixed an edge case error that can happens on damping ratio calculation --- src/helpers/common_func.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/common_func.py b/src/helpers/common_func.py index e0b24eb..14b9a24 100644 --- a/src/helpers/common_func.py +++ b/src/helpers/common_func.py @@ -120,7 +120,11 @@ def compute_mechanical_parameters(psd, freqs, min_freq=None): bw1 = math.pow(bandwidth / fr, 2) bw2 = math.pow(bandwidth / fr, 4) - zeta = math.sqrt(0.5 - math.sqrt(1 / (4 + 4 * bw1 - bw2))) + try: + zeta = math.sqrt(0.5 - math.sqrt(1 / (4 + 4 * bw1 - bw2))) + except ValueError: + # If a math problem arise such as a negative sqrt term, we also return None instead for damping ratio + return fr, None, max_power_index, max_under_min_freq return fr, zeta, max_power_index, max_under_min_freq