-
Notifications
You must be signed in to change notification settings - Fork 62
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
CSTR Re-Scaling #1542
base: main
Are you sure you want to change the base?
CSTR Re-Scaling #1542
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1542 +/- ##
=======================================
Coverage 93.67% 93.68%
=======================================
Files 278 278
Lines 30262 30297 +35
=======================================
+ Hits 28348 28383 +35
Misses 1914 1914 ☔ View full report in Codecov by Sentry. |
@TimBartholomew @adam-a-a @dallan-keylogic Based on the scaling discussion yesterday, the latest commit added some preliminary testing using the Scaling Profiler for these three unit models using the new scaling tools (Scaler objects) and the old scaling tools (iscale). I think it might make the most sense for this and similar PRs of mine to get all the Scalers and tests in place while subsequent PRs can refine the tests and scaler objects as necessary (e.g. adjusting unit model variable/constraint_scaling_routine, adjusting property model variable/constraint_scaling_routine, solution pertubation when using the ScalingProfiler, etc.) Any advice/comments on this and does it still make sense to keep tests making the overly simplistic comparison between the Jacobian condition numbers for the old and new scaling tools? If you all are still planning on meeting to discuss this topic "soon", I'd be happy to tag along as well. |
Great job on putting those changes so quickly! I agree with your thought on refining as needed in subsequent PRs. As for the comparison of condition numbers, I don't see any harm in keeping them for now since they give us some sort of benchmark. |
submodel_scalers=submodel_scalers, | ||
overwrite=overwrite, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is injection
another variable that should be covered here? I was thinking this Scaler looks almost the same (if not the same) as that of the CSTR, but injection is what sets this model apart from the regular cstr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this to work, I would need to add something like the following code into the CSTR_InjectionScaler class, but I'm not sure how to get this working (how to get it to read the has_aeration config option and whether or not S_O or S_O2 exist)
if self.config.has_aeration:
# Assuming that the supplied property package doesn't have both S_O and SO2 to represent oxygen.
if "S_O" in self.config.property_package.component_list:
self.scale_variable_by_default(
model.control_volume.mass_transfer_term[0, "Liq", "S_O"], overwrite=overwrite
)
elif "S_O2" in self.config.property_package.component_list:
self.scale_variable_by_default(
model.control_volume.mass_transfer_term[0, "Liq", "S_O2"], overwrite=overwrite
)
else:
pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a theoretical perspective, I've only been adding default scaling for variables that don't usually vary by orders of magnitude. For instance, volume for these units will usually be on the order of 1e3 (based on historical usage). However, I'm not as confident with injection. Should we expect this variable to consistently be on the order of 1e-2 or will it vary depending on the application. If the latter, we should probably avoid applying a default scaling factor here.
Summary/Motivation:
Adds the new IDAES scaling routine (scaler objects) to the CSTR & CSTR w/Injection unit models.
Changes proposed in this PR:
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: