-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add min_upstream_level
and max_downstream_level
to Pump and Outlet
#1792
Conversation
This seems like something a user might want to control. 2 centimeter is probably a reasonable default, but why not make this part of the structure? FWIW, mf6 uses |
Yeah we may need to support that at some point, but not in this PR. We could either set it as a global setting in the TOML, or per node in the database. |
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.
Some comments, but overall looking good
core/src/solve.jl
Outdated
|
||
set_flow!(graph, inflow_edge, q, du) | ||
_, src_level = get_level(p, inflow_id, t, du) |
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 like we don't ever use the first output of get_level
, might be worth a refactor. I'm also not sure why you compare src_level
to nothing
, as the second output of get_level
is always a number
.
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.
Also isnothing
looks a bit nicer to me
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.
Good call, I refactored get_level
to return only a number, which I set to -Inf for Terminal to avoid reduction factors based on downstream level checks.
core/src/solve.jl
Outdated
q *= reduction_factor(src_level - min_upstream_level, 0.02) | ||
end | ||
|
||
if dst_level !== nothing |
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.
Same here
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.
Ah I also see that comparing against nothing
this way was already in the code.
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.
We no longer need to check nothing
with the new get_level
.
- $Q$ is the realized Outlet flow rate. | ||
- $Q_\text{set}$ is the Outlet's target `flow_rate`. | ||
- $Q_{\min}$ and $Q_{\max}$ are the Outlet `min_flow_rate` and `max_flow_rate`. | ||
- $\phi$ is the reduction factor, which smoothly reduces flow based on all of these criteria: |
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'd still be in favor of writing say
and then
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.
In principle the text is precise and with links to the reduction factor curious users can determine the exact equations. Though perhaps we can make the mathematical notation more complete besides the text.
- $Q$ is the realized Pump flow rate. | ||
- $Q_\text{set}$ is the Pump's target `flow_rate`. | ||
- $Q_{\min}$ and $Q_{\max}$ are the Pump `min_flow_rate` and `max_flow_rate`. | ||
- $\phi$ is the reduction factor, which smoothly reduces flow based on all of these criteria: |
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.
Same here
Fixes #1771, the remaining part after #1788 was merged. I split out #1789 as a separate issue, though in this PR a lot of the preparatory work is already done (all changes related to TabulatedRatingCurve).
This is breaking due to #1791 because of adding new optional columns.
It is also breaking that TabulatedRatingCurve and Pump now only support one outflow edge. As far as I know this wasn't used anywhere though. We cannot easily support that anymore since we now look at downstream levels. Users should instead use separate Pumps or TabulatedRatingCurves, which can share the same upstream Basin, but go to different downstream nodes.
I decided to start the reduction factors for reaching these limits from 2 centimeters away. There was one existing level based reduction factor, the level difference in the Outlet, which I also adjusted from 10 to 2 centimeter. I feel like 10 centimeter would be too much in areas where the level is controlled up to centimeter accuracies.