Ribasim icon indicating copy to clipboard operation
Ribasim copied to clipboard

`ManningResistance` causes unexpected oscillations

Open SouthEndMusic opened this issue 1 year ago • 7 comments

In the basic model, the levels of the basins around the ManningResistance look like this with saveat = 0:

plot

These oscillations are damped by setting k = 100.0 in formulate_flow! for the ManningResistance:

plot

@Huite do you think that's a valid change? It relaxes the approximation of the absolute value function.

SouthEndMusic avatar Aug 20 '24 17:08 SouthEndMusic

Oh nice find. To add some context, the basic model has only static parameters, so we expect just smoothly going to a dynamic equilibrium like in the lower figure. There is a constant inflow on the upstream side, so that level should be slightly higher the whole time.

visr avatar Aug 20 '24 18:08 visr

It would be nice if we had a more structural solution than parameter fiddling, though. I think the problem (still) is that the flow is too sensitive to head difference changes around a head difference of 0.

SouthEndMusic avatar Aug 20 '24 18:08 SouthEndMusic

@Huite do you think that's a valid change? It relaxes the approximation of the absolute value function

It's currently k=1000.0 right? I haven't looked at atan enough to know in at which $\Delta h$ it starts to make a difference.

Don't we use a quadratic sigmoid somewhere else? That has the upside of being cheaper to compute and is more explicit in when it's "turned" on.

Huite avatar Aug 20 '24 19:08 Huite

Not sure what a quadratic signmoid is or what this means:

... and is more explicit in when it's "turned" on.

What we want is to limit $\frac{\text{d}Q}{\text{d}\Delta h}$ which is essentially the inverse of the resistance used in LinearResistance. So we could make that an optional parameter which we enforce in the ManningResistance formulation (I would have to look into what's the best way to do that).

SouthEndMusic avatar Aug 21 '24 08:08 SouthEndMusic

I don't think it's a proper term, I mean something like this, more in general for reduction factors:

image

In our case, the Sf isn't naturally bounded (0, 1), so you specify when the (linear reduction) starts. But to get smooth gradients you adjust the function a bit, $\Omega$ control when you start adjusting. For linear relationship you'd only use $\Omega$.

And what I mean with "turning on/off", basically this (for arctan):

image

Huite avatar Aug 21 '24 09:08 Huite

I see, but our problem here is of a different nature (I think). We're not looking at smooth transitions to 0, we're looking at bounding a derivative. The manning resistance behaves like $\text{sign}(\Delta h)\sqrt{|\Delta h|}$:

image

which is bad around $0$.

SouthEndMusic avatar Aug 21 '24 12:08 SouthEndMusic

Suggestion:

https://www.desmos.com/calculator/g6xogkegp5

Here you can set a threshold below which the curve is modified to prevent the derivative going to $\infty$.

SouthEndMusic avatar Aug 21 '24 13:08 SouthEndMusic