fixed an edge case error that can happens on damping ratio calculation

This commit is contained in:
Félix Boisselier committed 2024-04-24 15:28:33 +02:00
1 parent 178fa2ea3b
commit 19bc62a6b7
1 file changed
+4
+4
View File
@@ -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)
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