Skip to content

Modular Properties Scaler Object#1652

Merged
dallan-keylogic merged 113 commits intoIDAES:scaling_toolboxfrom
dallan-keylogic:modular_properties_scaler
Sep 30, 2025
Merged

Modular Properties Scaler Object#1652
dallan-keylogic merged 113 commits intoIDAES:scaling_toolboxfrom
dallan-keylogic:modular_properties_scaler

Conversation

@dallan-keylogic
Copy link
Contributor

Summary/Motivation:

I've begun implementing scaling for the modular property framework.

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.

Copy link
Contributor

@Ryan-Hughes-8 Ryan-Hughes-8 left a comment

Choose a reason for hiding this comment

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

Overall, I think this looks good. I tested this branch locally using an air/flue gas generic parameter block and the ethylene glycol production generic properties and reactions in the examples, and it worked well.

My main recommendation is improving the error message for when a required default scaling factor is omitted. I also left a couple other comments and suggestions.

log_con_obj[idx], sf, overwrite=overwrite
)

def _bubble_dew_scaling(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function, along with some others throughout this PR, could use some more comments to help explain what is being done.

)
# Phase equilibrium
# Right now (7/24/25) phase equilibrium methods don't create
# additional variables, so this method does nothing.
Copy link
Contributor

Choose a reason for hiding this comment

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

remove "this method does nothing"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not the wording a user should read. Leave the comment just change the wording

for vardata in log_var_obj.values():
self.set_component_scaling_factor(vardata, 1, overwrite=overwrite)

# Not porting these from the old scaler, we'll see if
Copy link
Contributor

Choose a reason for hiding this comment

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

improve wording

assert get_scaling_factor(model.rblock[1].dh_rxn["r1"]) == pytest.approx(
1 / (300 * 8.3144), rel=1e-3
)
assert get_scaling_factor(model.rblock[1].k_eq["e1"]) == 0.01
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Why are we changing some tests to have "1e^" form and some to decimals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I copy and pasted the test, then began changing the wrong version, only to imperfectly revert it. I restored the changes in this file

Scaler for constraints associated with FcTP state variables
"""

# Safe to inherit variable_scaling_routine from FTPx
Copy link
Contributor

Choose a reason for hiding this comment

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

Standarize this comments through state definitions. FpcTP does not include "safe".

@dallan-keylogic dallan-keylogic merged commit 42e8728 into IDAES:scaling_toolbox Sep 30, 2025
39 checks passed
@dallan-keylogic dallan-keylogic deleted the modular_properties_scaler branch September 30, 2025 20:35
dallan-keylogic added a commit that referenced this pull request Nov 6, 2025
* rescue files from overloaded git branch

* fix due to api tweaks

* run black

* forgot to add a file

* fix test errors

* pin coolprop version

* update version, disable superancillaries

* run black

* respond to Marcus's feedback

* getting close

* address Will's comments

* tests for set_scaling_factor

* support for unions in python 3.9

* testing the scaling profiler is way too fragile

* modify test to be less fragile

* remove pdb

* rescue files from branch

* towards scaling cv

* preliminary testing

* scaling by defn constraint

* scale constraint by definition constraint

* Disable obsolete tests for now

* run black

* actually add tests

* inh

* tests for methods rescued from old scaling tools

* pylint

* test to make sure that value is reverted

* Apply suggestions from code review

spelling fixes

Co-authored-by: Brandon Paul <[email protected]>

* additional clarity

* more files rescued from branch

* rescue files from other branch

* first tests

* tests

* additional scaling

* more tests

* fixes

* run black

* black on forgotten file

* fix failing tests

* fix issues when initializing FpcTP

* begin scaling for cubic complementarity vle

* error for unnamed expressions

* pylint

* enthalpy of formation test

* default is warning=False

* make sure expression walker doesn't emit warnings

* Cubic complementarity VLE test

* avoid auto-construction and run black

* new scaling for test_BTIdeal_FcTP

* BT ideal test

* regularly scheduled scaling has been interrupted by a bug in scaling core

* fix get_default_scaling_factor

* tests for one more example ported

* delegate scaling for solubility product forms

* test FcPh

* test FcTP

* test_FpcTP

* test FTPx

* FPhx

* no build on demand

* not every component has lock attribute creation context

* no more enth_mol_phase

* run black

* move to scaler object get scaling factor for future extension

* get rid of remaing gsf and pylint changes

* Actually scale cubic complementarity VLE and pylint

* rescue files from different branch

* tests for scaler base get_scaling_factor

* remove dependency on fix_gdsf

* pylint

* maybe pylint will like this better

* Is this acceptable to both pylint and black?

* stash

* fix failing test

* black

* pylint

* minor tweaks

* increase test coverage

* avoid generation of properties

* more test coverage for IdealBubbleDew

* Renaming and comments

* fix wrong constraint scaling method

* reply to review comments

* revert legacy test

* failing test

* improve error message

* update authors

* forgot to save file

* fix exception match

* Let's see if three solves is enough

* less strict complementarity

* xfail

---------

Co-authored-by: Brandon Paul <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:Normal Normal Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants