Skip to content

Commit

Permalink
Merge branch 'degeneracy_hunter_bug' of https://github.com/andrewlee9…
Browse files Browse the repository at this point in the history
…4/idaes-pse into degeneracy_hunter_bug
  • Loading branch information
andrewlee94 committed Dec 6, 2023
2 parents 77a0cf8 + b6fb080 commit c41bab2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
14 changes: 5 additions & 9 deletions idaes/core/util/tests/test_model_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def model(self):
m.b.v2 = Var(units=units.m)
m.b.v3 = Var(bounds=(0, 5))
m.b.v4 = Var()
m.b.v5 = Var(bounds=(0, 1))
m.b.v5 = Var(bounds=(0, 5))
m.b.v6 = Var()
m.b.v7 = Var(
units=units.m, bounds=(0, 1)
Expand Down Expand Up @@ -550,7 +550,6 @@ def test_display_variables_at_or_outside_bounds(self, model):
The following variable(s) have values at or outside their bounds (tol=0.0E+00):
b.v3 (free): value=0.0 bounds=(0, 5)
b.v5 (fixed): value=2 bounds=(0, 1)
====================================================================================
"""
Expand Down Expand Up @@ -619,7 +618,6 @@ def test_display_variables_near_bounds(self, model):
The following variable(s) have values close to their bounds (abs=1.0E-04, rel=1.0E-04):
b.v3: value=0.0 bounds=(0, 5)
b.v5: value=2 bounds=(0, 1)
b.v7: value=1.0000939326524314e-07 bounds=(0, 1)
====================================================================================
Expand Down Expand Up @@ -1009,7 +1007,7 @@ def test_collect_numerical_warnings(self, model):

assert len(warnings) == 2
assert "WARNING: 1 Constraint with large residuals (>1.0E-05)" in warnings
assert "WARNING: 2 Variables at or outside bounds (tol=0.0E+00)" in warnings
assert "WARNING: 1 Variable at or outside bounds (tol=0.0E+00)" in warnings

assert len(next_steps) == 2
assert "display_constraints_with_large_residuals()" in next_steps
Expand Down Expand Up @@ -1070,10 +1068,9 @@ def test_collect_numerical_cautions(self, model):
dt = DiagnosticsToolbox(model=model.b)

cautions = dt._collect_numerical_cautions()

assert len(cautions) == 5
assert (
"Caution: 3 Variables with value close to their bounds (abs=1.0E-04, rel=1.0E-04)"
"Caution: 2 Variables with value close to their bounds (abs=1.0E-04, rel=1.0E-04)"
in cautions
)
assert "Caution: 2 Variables with value close to zero (tol=1.0E-08)" in cautions
Expand Down Expand Up @@ -1133,7 +1130,6 @@ def test_assert_no_numerical_warnings(self, model):

# Fix numerical issues
m.b.v3.setlb(-5)
m.b.v5.setub(10)

solver = get_solver()
solver.solve(m)
Expand Down Expand Up @@ -1198,12 +1194,12 @@ def test_report_numerical_issues(self, model):
2 WARNINGS
WARNING: 1 Constraint with large residuals (>1.0E-05)
WARNING: 2 Variables at or outside bounds (tol=0.0E+00)
WARNING: 1 Variable at or outside bounds (tol=0.0E+00)
------------------------------------------------------------------------------------
5 Cautions
Caution: 3 Variables with value close to their bounds (abs=1.0E-04, rel=1.0E-04)
Caution: 2 Variables with value close to their bounds (abs=1.0E-04, rel=1.0E-04)
Caution: 2 Variables with value close to zero (tol=1.0E-08)
Caution: 1 Variable with extreme value (<1.0E-04 or >1.0E+04)
Caution: 1 Variable with None value
Expand Down
2 changes: 1 addition & 1 deletion idaes/core/util/tests/test_utility_minimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def model(self):
"state_definition": FTPx,
"state_bounds": {
"flow_mol": (0, 100, 1000, pyunits.mol / pyunits.s),
"temperature": (273.15, 300, 450, pyunits.K),
"temperature": (100, 300, 450, pyunits.K),
"pressure": (5e4, 1e5, 1e6, pyunits.Pa),
},
"pressure_ref": (1e5, pyunits.Pa),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_T_sweep(self, m):
m.fs.obj = Objective(expr=(m.fs.state[1].temperature - 510) ** 2)
m.fs.state[1].temperature.setub(600)

for logP in range(8, 13, 1):
for logP in [9.5, 10, 10.5, 11, 11.5, 12]:
m.fs.obj.deactivate()

m.fs.state[1].flow_mol.fix(100)
Expand Down Expand Up @@ -115,11 +115,11 @@ def test_P_sweep(self, m):
assert check_optimal_termination(results)

while m.fs.state[1].pressure.value <= 1e6:
m.fs.state[1].pressure.value = m.fs.state[1].pressure.value + 1e5

results = solver.solve(m)
assert check_optimal_termination(results)
print(T, m.fs.state[1].pressure.value)

m.fs.state[1].pressure.value = m.fs.state[1].pressure.value + 1e5

@pytest.mark.component
def test_T350_P1_x5(self, m):
Expand Down
7 changes: 0 additions & 7 deletions idaes/models/unit_models/tests/test_equilibrium_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,6 @@ def test_get_performance_contents(self, sapon):
}
}

@pytest.mark.component
def test_initialization_error(self, sapon):
sapon.fs.unit.outlet.pressure[0].fix(1)

with pytest.raises(InitializationError):
sapon.fs.unit.initialize()


class TestInitializers:
@pytest.fixture
Expand Down
10 changes: 0 additions & 10 deletions idaes/models/unit_models/tests/test_hx_ntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,6 @@ def test_conservation(self, model):
<= 1e-6
)

@pytest.mark.component
def test_initialization_error(self, model):
model.fs.unit.hot_side_outlet.pressure[0].fix(1)

with pytest.raises(InitializationError):
model.fs.unit.initialize()

# Revert DoF change to avoid contaminating subsequent tests
model.fs.unit.hot_side_outlet.pressure[0].unfix()


class TestInitializers(object):
@pytest.fixture(scope="class")
Expand Down

0 comments on commit c41bab2

Please sign in to comment.