-
Notifications
You must be signed in to change notification settings - Fork 4
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
Turbine node and parameter #144
Turbine node and parameter #144
Conversation
I've not thorough read this yet. Is it still draft, or is it ready for review?
Great!
Sounds like a good idea.
What happens if the user specifies "target" and "max_flow" in the schema? Is this allowed? Does it take the minimum? Same for a "min_flow". I would say these fields should be removed from the schema if they are not used.
Another option would be an enum (I'm not sure about the names): enum TargetType {
MaxFlow // Applies target as a max_flow
MinFlow // Applies target as a min_flow
Fixed // Applies target as both (like a catchment)
}
I'll take a look at this. I was expecting some complication here as this is a not quite like anything currently implemented. |
Use TargetType to set flow constraint type on TurbineNode
@s-simoncelli are you still working on this as a draft or do you want me to review it? |
It’s ready except for the power metric calculation. You can review it :) |
@s-simoncelli I've had a look at this. I think it is good. In order to solve the issue in the |
I merged the new changes from the main branche and I pass now |
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've merged main into here again. It was a bit fiddly but is working.
There's a couple of improvements to make before merge.
It would be nice to have a test model with the turbine node / parameter included to verify some of the values.
pywr-core/src/utils.rs
Outdated
energy_unit_conversion: f64, | ||
density: f64, | ||
) -> f64 { | ||
let mut head = water_elevation - turbine_elevation; |
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 would simplify this function to just accept head: f64
. It's only use already calculates the head value and sets turbine_elevation
to zero.
pywr-core/src/utils.rs
Outdated
/// Calculate the produced power from the flow using the hydropower equation | ||
pub fn hydropower_calculation( | ||
flow: f64, | ||
water_elevation: f64, |
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.
The same for this function.
// Bound the flow if required | ||
if let Some(max_flow) = &self.max_flow { | ||
q = q.min(max_flow.get_value(model, state)?); | ||
} else if let Some(min_flow) = &self.min_flow { |
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.
// Bound the flow if required
if let Some(max_flow) = &self.max_flow {
q = q.min(max_flow.get_value(model, state)?);
}
if let Some(min_flow) = &self.min_flow {
q = q.max(min_flow.get_value(model, state)?);
}
I think this should be two independent if blocks, not an if-else-if.
I've applied the changes I suggestion as they were only minor. I'm tempted to merge this now, and fix-up any issues, examples, etc later. @Batch21 do you agree? |
yeah, I agree |
I moved the implementation of the turbine components in a new branch because both the parameter and node have the same dependencies.
HydropowerTargetParameter
is now initialised with a dedicatedstruct
to reduce the number of inputs tonew()
TurbineNode
acceptstarget
which sets themax_flow
using the inverse hydropower equation. Do we want to let the user set themax_flow
andmin_flow
fields if the target is not set? These are private now.target
asmin_flow
instead ofmax_flow
.TurbineNode::create_metric()
function is still a WIP. The derived metric usesTurbineData
to get the data it needs to calculate the power. However, becausewater_elevation
(L163) is aDynamicFloatValue
, I need to load it asMetric
but I don't have access to theschema
,domain
,tables
, etc. Have I implemented it correctly or does thecreate_metric
signature needs to be changed?