-
Notifications
You must be signed in to change notification settings - Fork 247
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
Enable derived costing package to define a flow cost #983
Conversation
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.
LGTM
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 think there is an edge case that we need to address, plus we should probably note something about this in the docs (docs/reference_guides/core/costing/costing_framework.rst).
current_component = self.component(name) | ||
if current_component is not None and current_component is cost: | ||
pass | ||
else: |
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 think I see an edge case here that needs to be caught - what happens if a component name
already exists but is not cost
? I think this would implicitly replace the existing component, so I think we need to catch this and raise an Exception
.
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 agree -- I was just making a minimal change to existing behavior. Happy to add an Exception
here though.
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 think an Exception
is the best approach - it is easy to add in here, and I generally never try to second guess the user. I.e. if they do something wrong it is best to tell them to fix it rather than make assumptions.
Codecov ReportBase: 69.93% // Head: 69.93% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #983 +/- ##
==========================================
- Coverage 69.93% 69.93% -0.01%
==========================================
Files 397 397
Lines 64922 64927 +5
Branches 11849 11851 +2
==========================================
+ Hits 45406 45408 +2
- Misses 17259 17263 +4
+ Partials 2257 2256 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I've added a For the documentation, I've opted to extend the docstring for this function. The costing framework documentation doesn't seem to mention flow costing. |
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.
Looks good.
Fixes N/A
Summary/Motivation:
In the WaterTAP costing package, we have names like
electricity_base_cost
for predefining flow costs. It would be less brittle and error-prone if the WaterTAP costing package could just use the nameelectricity_cost
directly:https://github.com/watertap-org/watertap/blob/c71b898cf490b7dc6f7a0115e95b8dbb6a771adf/watertap/costing/watertap_costing_package.py#L122-L128. Here, changing this mutable Param doesn't actually do anything, because its value is extracted when the
electricity_cost
Var
is created.Changes proposed in this PR:
{flow_type}_cost
is already on the global costing block, just use it instead of creating a newVar
.Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: