Skip to content

Commit

Permalink
Force absolute difference mode for target values equal to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Dec 3, 2023
1 parent 5ebb583 commit 3dff30a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tespy/tools/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def newton(func, deriv, params, y, **kwargs):
logger.debug(msg)

break
if tol_mode == 'abs':
if tol_mode == 'abs' or y == 0:
expr = abs(res) >= tol_abs
elif tol_mode == 'rel':
expr = abs(res / y) >= tol_rel
Expand Down Expand Up @@ -680,7 +680,7 @@ def newton_with_kwargs(
logger.debug(msg)

break
if tol_mode == 'abs':
if tol_mode == 'abs' or target_value == 0:
expr = abs(residual) >= tol_abs
elif tol_mode == 'rel':
expr = abs(residual / target_value) >= tol_rel
Expand Down

0 comments on commit 3dff30a

Please sign in to comment.