Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IDAES requirement to 2.2.0.dev0.watertap.23.08.03 and other stability improvements #930

Merged
merged 68 commits into from
Aug 19, 2023

Conversation

bknueven
Copy link
Contributor

@bknueven bknueven commented Feb 17, 2023

Fixes #929, Fixes #1072

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Feb 23, 2023
Copy link
Contributor

@TimBartholomew TimBartholomew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adam-a-a
Copy link
Contributor

OK- I checked whether this PR would break anything in the BSM2 flowsheet by putting up a draft PR (#1108), and all checks pass! I'll review this and suspect it'll be ready to merge soon.

Comment on lines +73 to +78
WARNING: model contains export suffix 'fs.state_block[0].scaling_factor' that
contains 4 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.state_block[0].scaling_factor' that
contains 4 component keys that are not exported as part of the NL file.
Skipping.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something we wouldn't want showing up in the how-to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's just in the test -- so the reader won't see it.
  2. I talked with @andrewlee94 about this a few weeks ago and there is not a workaround nor is one planned (IDAES and Pyomo are implementing a new model scaling framework)

@@ -304,4 +300,4 @@ jobs:
pyomo build-extensions || python -c "from pyomo.contrib.pynumero.asl import AmplInterface; exit(0) if AmplInterface.available() else exit(1)"
- name: Run pytest
run: |
pytest --pyargs watertap -k 'not nf_dspmde.nf_ui'
pytest --pyargs watertap -k 'not (nf_dspmde.nf_ui or nf_dspmde.nf_with_bypass_ui)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the alternative GUI flowsheet code was also causing checks to fail, hence it's addition here. DOes that mean the UI code for these NF flowsheets still has issues to address?

Copy link
Contributor

@lbianchi-lbl lbianchi-lbl Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this is due to a limitation of the watertap.ui.fsapi layer for models that require the "good" (ma27-enabled) Ipopt to solve. If the model can be initialized without failures, specifying requires_idaes_solver=True kwarg is enough to skip the corresponding test without failures, but this doesn't work when the solve fails during initialization. Therefore, we have to exclude the entire test module using the -k not ... pytest flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note -- this only applies to the macOS tests

@@ -585,7 +619,8 @@ def test_initialize(self, model_initialize):

@pytest.fixture
def model_solve(self, model, solver):
results = solver.solve(model, tee=True)
model.write("bah.nl", io_options={"symbolic_solver_labels": True})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

@pytest.mark.component
def test_ideal_naocl_chlorination_full_block():
model = run_chlorination_block_example(fix_free_chlorine=True)
assert model.fs.ideal_naocl_mixer_unit.dosing_rate.value == pytest.approx(
0.9504457542440085e-6, rel=1e-3
1.7296113311683092e-09, rel=1e-3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 order of magnitude change--not sure if this is correct due to inaccuracies in the original values used that were corrected or if this is an error itself. Without a deep dive into verifying replaced values, my guess is that this result is due to the former.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dh_rxn_ref was also corrected by three orders of magnitude above.

There's also other changes to how the solubility equilibrium constraint is implemented in IDAES IDAES/idaes-pse#1197

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so due to the first reason I mentioned. Thanks for confirming.

Copy link
Contributor

@adam-a-a adam-a-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments, but overall, should be good to go.

Comment on lines +73 to +78
WARNING: model contains export suffix 'fs.state_block[0].scaling_factor' that
contains 4 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.state_block[0].scaling_factor' that
contains 4 component keys that are not exported as part of the NL file.
Skipping.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's just in the test -- so the reader won't see it.
  2. I talked with @andrewlee94 about this a few weeks ago and there is not a workaround nor is one planned (IDAES and Pyomo are implementing a new model scaling framework)

watertap/examples/chemistry/tests/test_pure_water_pH.py Outdated Show resolved Hide resolved
@@ -304,4 +300,4 @@ jobs:
pyomo build-extensions || python -c "from pyomo.contrib.pynumero.asl import AmplInterface; exit(0) if AmplInterface.available() else exit(1)"
- name: Run pytest
run: |
pytest --pyargs watertap -k 'not nf_dspmde.nf_ui'
pytest --pyargs watertap -k 'not (nf_dspmde.nf_ui or nf_dspmde.nf_with_bypass_ui)'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note -- this only applies to the macOS tests

@pytest.mark.component
def test_ideal_naocl_chlorination_full_block():
model = run_chlorination_block_example(fix_free_chlorine=True)
assert model.fs.ideal_naocl_mixer_unit.dosing_rate.value == pytest.approx(
0.9504457542440085e-6, rel=1e-3
1.7296113311683092e-09, rel=1e-3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dh_rxn_ref was also corrected by three orders of magnitude above.

There's also other changes to how the solubility equilibrium constraint is implemented in IDAES IDAES/idaes-pse#1197

@adam-a-a adam-a-a enabled auto-merge (squash) August 19, 2023 16:56
Copy link
Contributor

@adam-a-a adam-a-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adam-a-a adam-a-a merged commit 537279d into watertap-org:main Aug 19, 2023
23 checks passed
@bknueven bknueven deleted the issue929 branch September 22, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:High High Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix OS-specific solver issues for NF flowsheet Make WaterTAP compatible with NL_v2 writer
5 participants