Skip to content

Conversation

@dallan-keylogic
Copy link
Contributor

@dallan-keylogic dallan-keylogic commented Nov 21, 2025

Fixes/Resolves:

Changes in IDAES caused some test failures in WaterTap (mostly involving scaling). This PR fixes those failures.

This requires IDAES/idaes-pse#1711 from idaes-pse.

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:High High Priority Issue or PR label Nov 24, 2025
Comment on lines 560 to 561
# TODO is it intentional that we're setting scaling factors for some constraints
# but doing constraint scaling transforms for others?
Copy link
Contributor

Choose a reason for hiding this comment

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

It was intentional, but it was long enough ago where I forget the rationale behind it. Likely because I tried constraint scaling transform first and I couldn't get it to solve

Copy link
Contributor

Choose a reason for hiding this comment

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

should this comment be removed?

Comment on lines +321 to +322
@linux_platform_only
def test_condition_number_on_linux(self, system_frame):
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this was the "fix" for the condition numbers not matching between Windows and Linux. I think this is fine as we've done similar things in other scaling/condition number tests already

Comment on lines +341 to +344
# Python 3.9-3.11
cond == pytest.approx(4.3021828e15, rel=1e-2)
# Python 3.12
or cond == pytest.approx(2.987651e15, rel=1e-2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully future improvements to scaling will bring these more in line?

"""

assert stream.getvalue() == expected
# TODO Replace these scaling profiler tests with more detailed convergence analysis
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps make an issue on this if you haven't already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in #1701.

Comment on lines -2957 to 2975
] == pytest.approx(2617, rel=1e-3)
] == pytest.approx(1e4, rel=1e-3)
assert m.fs.stream[0].scaling_factor[
m.fs.stream[0].eq_mass_frac_phase_comp["Liq", "SO4_2-"]
] == pytest.approx(468.1, rel=1e-3)
] == pytest.approx(1e3, rel=1e-3)
assert m.fs.stream[0].scaling_factor[
m.fs.stream[0].eq_mass_frac_phase_comp["Liq", "Na_+"]
] == pytest.approx(89.89, rel=1e-3)
] == pytest.approx(1e2, rel=1e-3)
assert m.fs.stream[0].scaling_factor[
m.fs.stream[0].eq_mass_frac_phase_comp["Liq", "Cl_-"]
] == pytest.approx(49.74, rel=1e-3)
] == pytest.approx(1e2, rel=1e-3)
assert m.fs.stream[0].scaling_factor[
m.fs.stream[0].eq_mass_frac_phase_comp["Liq", "Mg_2+"]
] == pytest.approx(717.2, rel=1e-3)
] == pytest.approx(1e3, rel=1e-3)
assert m.fs.stream[0].scaling_factor[
m.fs.stream[0].eq_dens_mass_solvent
] == pytest.approx(0.001, 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.

@dallan-keylogic notes that these changes are attributed to "how the nominal value expression walker works. Previously it used 1/value(var) if var was fixed, but now it uses 1/scaling_factor[var] regardless of whether or not var is fixed."

Copy link
Contributor

Choose a reason for hiding this comment

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

"One slight correction: it now uses 1/scaling_factor[var] if var has a scaling factor set, but falls back on 1/value(var) if no scaling factor is set, regardless of whether or not var is fixed"

# primary requirements for unit and property models
# allow X.Y.Z stable release(s) and X.Y+1.dev0 (i.e. the main branch after X.Y.Z)
# disallow X.Y+1.0rc0 (i.e. forcing a manual update to this requirement)
"idaes-pse >=2.9.0,<2.10.0rc0",
Copy link
Contributor

@sufikaur sufikaur Nov 26, 2025

Choose a reason for hiding this comment

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

changing this to new rc0

@sufikaur sufikaur merged commit bf8932b into watertap-org:main Dec 10, 2025
18 checks passed
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.

7 participants