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

Smoothing the Q(h) relation #1919

Open
SouthEndMusic opened this issue Oct 28, 2024 · 1 comment · May be fixed by #1932
Open

Smoothing the Q(h) relation #1919

SouthEndMusic opened this issue Oct 28, 2024 · 1 comment · May be fixed by #1932
Labels
core Issues related to the computational core in Julia performance Relates to runtime performance or convergence

Comments

@SouthEndMusic
Copy link
Collaborator

In the grand scheme of boosting performance by making the whole RHS of the Ribasim ODE problem C1 smooth, doing this for TabulatedRatingCurve is one of the steps. Currently the $Q(h)$ relation is given by piecewise linear interpolation of the input data. To make this more smooth, we can use a cubic polynomial that rounds out the corners. As proposed by @Huite, this is easiest to understand by hydrologist by taking some fixed small interval centered around each data point where the linear interpolation is replaced by a polynomial (some care must be taken half this interval is bigger than the distance between points in the $x$ direction).

For the nicest integration this could be incorporated into DataInterpolations.jl. For some inspiration see here, which uses an interval around the data points whose size is relative to the distance between points instead of absolute as proposed here.

@github-project-automation github-project-automation bot moved this to To do in Ribasim Oct 28, 2024
@SouthEndMusic SouthEndMusic added performance Relates to runtime performance or convergence core Issues related to the computational core in Julia labels Oct 28, 2024
@SouthEndMusic SouthEndMusic changed the title Smoothing the $Q(h)$ relation Smoothing the Q(h) relation Oct 28, 2024
@Huite
Copy link
Contributor

Huite commented Oct 28, 2024

Commenting this for completeness, this paper

Model smoothing strategies to remove microscale discontinuities and spurious secondary optima in objective functions in hydrological calibration
Dmitri Kavetski, George Kuczera
First published: 08 March 2007 https://doi.org/10.1029/2006WR005195

primarily suggest using logistic smoothing. This has the upside of being better than C2, but I'd say with a significant cost since our Qh tables contain quite a lot of rows.

Basically, you need a logistic function for each jump of dQ/dh. For integration, to keep it continous, you need to sum as many integrals (a softplus) as there are jumps (because the function is only 0 or 1 in the limit as x to ±infinity). For e.g. 20 points, that means 20 softplus evaluations.

Image

@SouthEndMusic SouthEndMusic linked a pull request Nov 13, 2024 that will close this issue
@SouthEndMusic SouthEndMusic moved this from To do to 🏗 In progress in Ribasim Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues related to the computational core in Julia performance Relates to runtime performance or convergence
Projects
Status: 🏗 In progress
Development

Successfully merging a pull request may close this issue.

2 participants