Skip to content

Commit

Permalink
REport residuals on unconverged constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Lee committed Oct 3, 2023
1 parent 5d4ffa1 commit 2ab12f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions idaes/core/util/model_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,19 @@ def display_constraints_with_large_residuals(self, stream=stdout):
None
"""
lrdict = large_residuals_set(
self._model,
tol=self.config.constraint_residual_tolerance,
return_residual_values=True,
)

lrs = []
for k, v in lrdict.items():
lrs.append(f"{k.name}: {v:.5E}")

_write_report_section(
stream=stream,
lines_list=large_residuals_set(
self._model, tol=self.config.constraint_residual_tolerance
),
lines_list=lrs,
title=f"The following constraint(s) have large residuals "
f"(>{self.config.constraint_residual_tolerance:.1E}):",
header="=",
Expand Down
4 changes: 2 additions & 2 deletions idaes/core/util/tests/test_model_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,11 @@ def test_display_constraints_with_large_residuals(self, model):
expected = """====================================================================================
The following constraint(s) have large residuals (>1.0E-05):
b.c2
b.c2: 6.66667E-01
====================================================================================
"""

print(stream.getvalue())
assert stream.getvalue() == expected

@pytest.mark.component
Expand Down

0 comments on commit 2ab12f4

Please sign in to comment.