Skip to content
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

Deceptive crossings of condition thresholds #454

Closed
SouthEndMusic opened this issue Jul 25, 2023 · 1 comment · Fixed by #492
Closed

Deceptive crossings of condition thresholds #454

SouthEndMusic opened this issue Jul 25, 2023 · 1 comment · Fixed by #492
Labels
control Rule based control of physical layer

Comments

@SouthEndMusic
Copy link
Collaborator

SouthEndMusic commented Jul 25, 2023

The problem described here can be summarized as "what starts as an up-crossing does not have to end as an up-crossing".

Example

In the example below we look at the level of a basin trough time.

control_problem

As the level crosses the upper threshold, a Pump flow rate is changed to bring the level to the setpoint (middle threshold). The VectorContinuousCallback detects the crossing of the upper threshold as an up-crossing, and so it is assumed that the condition

level > upper_threshold

is true just after the time when level = upper_threshold:

function discrete_control_affect_upcrossing!(integrator, condition_idx)
    discrete_control = integrator.p.discrete_control
    discrete_control.condition_value[condition_idx] = true

    discrete_control_affect!(integrator, condition_idx)
end

However, due to the change induced by control, this turns out not to be an up-crossing at al, but merely a 'touch' of the threshold.

This is a non-trivial problem, because only after the control change and a call of water_balance! is the direction of this crossing really clear, by the sign of the du of this basin.

Potential solution

At the moment it is quite expensive to get the du of a single basin (or the flow over a single edge for that matter, needed for flow conditions), because the implementation only supports computing all of them in one function call. It would be nice to have a way to only calculate the du of a single basin after a control state change (or the flow of a single edge), to have a relatively cheap way to infer the crossing type.

@SouthEndMusic SouthEndMusic added control Rule based control of physical layer needs-refinement Issues that are too large and need refinement bug labels Jul 25, 2023
@github-project-automation github-project-automation bot moved this to To do in Ribasim Jul 25, 2023
@SouthEndMusic
Copy link
Collaborator Author

Using DiscreteCallback does not have this problem but is less precise on the time of the control change, dependent on dt.

@SouthEndMusic SouthEndMusic changed the title Deceptive crossings Deceptive crossings of condition thresholds Jul 25, 2023
@SnippenE SnippenE removed the needs-refinement Issues that are too large and need refinement label Aug 15, 2023
SouthEndMusic added a commit that referenced this issue Aug 15, 2023
Fixes #447, fixes
#454.

---------

Co-authored-by: Bart de Koning <[email protected]>
@github-project-automation github-project-automation bot moved this from To do to ✅ Done in Ribasim Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control Rule based control of physical layer
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants