Skip to content

ControlVolume0D Scaler#1651

Merged
dallan-keylogic merged 35 commits intoIDAES:scaling_toolboxfrom
dallan-keylogic:CV0D_scaler
Aug 22, 2025
Merged

ControlVolume0D Scaler#1651
dallan-keylogic merged 35 commits intoIDAES:scaling_toolboxfrom
dallan-keylogic:CV0D_scaler

Conversation

@dallan-keylogic
Copy link
Contributor

@dallan-keylogic dallan-keylogic commented Aug 19, 2025

Summary/Motivation:

Adds a scaler for the ControlVolume0D in addition to another scaling helper method

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.

@codecov
Copy link

codecov bot commented Aug 19, 2025

Codecov Report

❌ Patch coverage is 82.28782% with 48 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (scaling_toolbox@ff5c700). Learn more about missing BASE report.

Files with missing lines Patch % Lines
idaes/core/base/control_volume_base.py 81.48% 14 Missing and 16 partials ⚠️
idaes/core/scaling/custom_scaler_base.py 84.61% 4 Missing and 2 partials ⚠️
idaes/models/unit_models/equilibrium_reactor.py 54.54% 5 Missing ⚠️
idaes/core/util/testing.py 82.60% 2 Missing and 2 partials ⚠️
idaes/core/scaling/util.py 85.71% 1 Missing and 1 partial ⚠️
idaes/core/base/control_volume0d.py 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             scaling_toolbox    #1651   +/-   ##
==================================================
  Coverage                   ?   77.03%           
==================================================
  Files                      ?      395           
  Lines                      ?    63957           
  Branches                   ?    10501           
==================================================
  Hits                       ?    49269           
  Misses                     ?    12211           
  Partials                   ?     2477           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dallan-keylogic dallan-keylogic marked this pull request as ready for review August 19, 2025 18:09
Copy link
Contributor

@bpaul4 bpaul4 left a comment

Choose a reason for hiding this comment

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

@dallan-keylogic this is largely good to me, just a couple typos and a question. I encountered a bunch of merge conflicts when I created a dummy branch to test against my in-progress CSTR scaling, so I'll come back with more comments or an approval one I've sorted that out.

def test_scale_variable_by_definition_constraint_indexed(self, model):
sb = CustomScalerBase()

# The fact that this constraint overdetermines the mode is
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because an exception is thrown before the model can even be solved.

@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Aug 21, 2025
Comment on lines +324 to +325
# Set scaling factors for element balance variables
# TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these TODOs going to be completed in this PR or a subsequent PR?

for idx in model.material_balances:
self.scale_constraint_by_nominal_value(
model.material_balances[idx],
scheme=ConstraintScalingScheme.inverseMaximum,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it true that we'll just use inverseMaximum in most cases?

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'm using it here because I already had set scaling factors for all the variables/expressions that appear in the constraint. The real thing dictating the scale here is the scaling of get_material_flow_terms, which is inherited by the rest of the mass transfer terms.

Copy link
Contributor

@MarcusHolly MarcusHolly left a comment

Choose a reason for hiding this comment

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

LGTM

@dallan-keylogic dallan-keylogic merged commit f9cf6d1 into IDAES:scaling_toolbox Aug 22, 2025
60 checks passed
@dallan-keylogic dallan-keylogic deleted the CV0D_scaler branch August 22, 2025 16:00
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

---------

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.

4 participants