-
Notifications
You must be signed in to change notification settings - Fork 235
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
Fixing trying to access metadata via config block #1252
Conversation
# Check for default property package | ||
self._get_property_package() | ||
|
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.
Shouldn't this be added to ProcessBlock.build
instead of putting it in each of these blocks?
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.
No, as this changes the config block which we generally avoid doing. Hence, I only used this where necessary (and even then I probably could have found another way to do it, but didn't want to work throguh that mess).
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1252 +/- ##
==========================================
- Coverage 76.72% 76.72% -0.01%
==========================================
Files 382 382
Lines 61212 61219 +7
Branches 11291 11291
==========================================
+ Hits 46967 46971 +4
- Misses 11813 11817 +4
+ Partials 2432 2431 -1
☔ View full report in Codecov by Sentry. |
@andrewlee94 is this something that we test for? If not, do we need to add some so this doesn't occur again? |
@bpaul4 Unfortunately, this is very hard to test for as it is an integration issue. The only way to test is to force developers to add a test for their model to ensure it works with a default property package. |
If i try an execute the following code using the hx_bug branch i get an error:
I get the following traceback:
|
@vova292 Why are you trying to use the Now, it looks like that unit model has some issues. It shouldn't be looking to the flowsheet flag for dynamics, but the unit level flag, and it should be able to create the holdup terms by supplying the argument |
@vova292 @dallan-keylogic In this case, the issue is that the unit model allows the |
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.
I guess the configs here make sense given that the original heat exchanger (which this model subclasses) gets the dynamic flag for the control volumes from the unit level dynamic flag, but in the bigger picture it gets things backwards. IIRC, for a liquid/liquid heat exchanger over 80% of the holdup comes from metal, and for a gas/gas heat exchanger almost 100% of it comes from the metal.
There's nothing wrong with the code here in question, though.
@dallan-keylogic That might actually be a better solution, but would need us to overload some base methods. |
This reverts commit 5a751db.
Fixes #1249
Summary/Motivation:
@vova292 reported a bug where an error was being raised by the HX unit model when using a default property package defined at the flowsheet level. Investigation revealed that this was due to the model trying to access the properties metadata via the config block which was pointing to
useDefault
, and that this was a widespread issue across the code base.The fix is to access the metadata either via a StateBlock or a ControlVolume (which checks for
useDefault
and replaces it with the correct reference), or to use the_get_property_block
method to update the config block if a control volume is not used. This PR addresses many (hopefully most) of these issues.Changes proposed in this PR:
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: