pywr / pywr-next

An experimental repository exploring ideas for a major revision to Pywr using Rust as a backend.
6 stars 4 forks source link

Turbine node and parameter #144

Closed s-simoncelli closed 2 months ago

s-simoncelli commented 4 months ago

I moved the implementation of the turbine components in a new branch because both the parameter and node have the same dependencies.

jetuk commented 4 months ago

I've not thorough read this yet. Is it still draft, or is it ready for review?

I moved the implementation of the turbine components in a new branch because both the parameter and node have the same dependencies.

Great!

The HydropowerTargetParameter is now initialised with a dedicated struct to reduce the number of inputs to new()

Sounds like a good idea.

The TurbineNode accepts target which sets the max_flow using the inverse hydropower equation. Do we want to let the user set the max_flow and min_flow fields if the target is not set? These are private now.

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.

I need to add a boolean field to let the user set the target as min_flow instead of max_flow.

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)
}

The TurbineNode::create_metric() function is still a WIP. The derived metric uses TurbineData to get the data it needs to calculate the power. However, because water_elevation (L163) is a DynamicFloatValue, I need to load it as Metric but I don't have access to the schema, domain, tables, etc. Have I implemented it correctly or does the create_metric signature needs to be changed?

I'll take a look at this. I was expecting some complication here as this is a not quite like anything currently implemented.

jetuk commented 4 months ago

@s-simoncelli are you still working on this as a draft or do you want me to review it?

s-simoncelli commented 4 months ago

It’s ready except for the power metric calculation. You can review it :)

jetuk commented 3 months ago

@s-simoncelli I've had a look at this. I think it is good. In order to solve the issue in the create_metric method I've wanted to refactor a few things first. Most of those are done now (e.g. #148 ). The only other one is simplifying metrics in the schema. I am going to work on that next. Once done we can fix this branch and see if it fits together better.

s-simoncelli commented 3 months ago

I merged the new changes from the main branche and I pass now &LoadArgs to the metric functions so that I can use it in the turbuine node.

jetuk commented 2 months ago

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?

Batch21 commented 2 months ago

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