Skip to content

Commit 645578c

Browse files
Don't normalize equilibria if one rate is zero
This is to avoid a (rare but possible) division-by-zero error.
1 parent 92c7cb0 commit 645578c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

overreact/api.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,15 @@ def get_k(
570570
pair = k[i : i + 2]
571571
_K = pair[0] / pair[1]
572572

573-
k[i : i + 2] = pair / pair.min()
573+
denom = pair.min()
574+
if denom == 0.0:
575+
logger.warning(
576+
"found half-equilibrium reaction with zero rate constant: "
577+
"skipping equilibrium normalization"
578+
)
579+
denom = 1.0
580+
581+
k[i : i + 2] = pair / denom
574582
assert np.isclose(_K, k[i] / k[i + 1]), (
575583
f"reaction rate constants {k[i]} and {k[i + 1]} for "
576584
"equilibria could not be made to match the expected "

0 commit comments

Comments
 (0)