IDAES / idaes-pse

The IDAES Process Systems Engineering Framework
https://idaes-pse.readthedocs.io/
Other
206 stars 228 forks source link

Negative flow rates in BTX and demo flowsheet ill-conditioning #1439

Open dallan-keylogic opened 2 weeks ago

dallan-keylogic commented 2 weeks ago

While working on #1395, I found that changes I made to the BTX scaling caused test failures for the demo flowsheet on Linux while tests succeeded on Windows. Trying to dig into the problem I discovered two issues: 1) The problem Jacobian had a condition number on the order of 10^15 2) There were negative values for flow_mol_phase in model.fs.M01.inlet_2_state.

I dealt with the second issue by adding bounds for it (and other similar variables) in #1395, but that caused the initialization to fail. Because it was clear that something was fundamentally wrong with the flowsheet that scaling could not fix, I didn't want #1395 to be dragged even further off-topic and so xfailed two tests involving the demo flowsheet.

Somebody needs to go back and either fix the issues with the demo flowsheet or replace the BTX property package with some suitable variation of the modular properties.

There appears to be an issue where the heater in the flowsheet has very little to do, because the feed comes in at 377 K and the heater outlet is set to 380 K. However, lowering the feed temperature didn't fix the underlying singularity.

dallan-keylogic commented 2 weeks ago

From the developer call on 6/20/24. This is a significant issue, negative flow rates call results into question in many tests. Naively adding lower bounds of 0 to flow_mol_phase and flow_mol_phase_comp causes seven tests to fail:

FAILED idaes/core/solvers/tests/test_homotopy.py::test_ideal_prop - AssertionError
FAILED idaes/core/solvers/tests/test_homotopy.py::test_ideal_prop_max_iter - AssertionError
FAILED idaes/models/unit_models/tests/test_gibbs.py::TestInitializers::test_block_triangularization - idaes.core.util.exceptions.InitializationError: fs.unit failed to initialize successfully: uninitialized variables or unconverged equality constraints detected. Please check postcheck summary for more information (largest residual above tolerance = 229.82787418188317).
FAILED idaes/models_extra/column_models/tests/test_reboiler.py::TestBTXIdeal::test_initialize - idaes.core.util.exceptions.InitializationError: fs.unit failed to initialize successfully. Please check the output logs for more information.
FAILED idaes/models_extra/column_models/tests/test_reboiler.py::TestBTXIdeal::test_solve - AssertionError
FAILED idaes/models_extra/column_models/tests/test_reboiler.py::TestBTXIdeal::test_solution - AssertionError
FAILED idaes/models_extra/column_models/tests/test_tray_column.py::TestBTXIdealFcTP::test_initialize - idaes.core.util.exceptions.InitializationError: fs.unit.reboiler failed to initialize successfully. Please check the output logs for more information.
FAILED idaes/models_extra/column_models/tests/test_tray_column.py::TestBTXIdealFcTP::test_solve - AssertionError
FAILED idaes/models_extra/column_models/tests/test_tray_column.py::TestBTXIdealFcTP::test_solution - AssertionError

We should probably wait to solve this issue until the new scaling tools are implemented, and it's not clear who's going to fix this issue.