Skip to content

Commit

Permalink
Merge pull request #456 from oemof/fix/newton-helpers-convergence
Browse files Browse the repository at this point in the history
Force absolute difference mode for target values equal to zero
  • Loading branch information
fwitte authored Dec 7, 2023
2 parents a7f2de7 + 3dff30a commit eb6d1c5
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 eb6d1c5

Please sign in to comment.