From a9ef2466803951ed157afd3b89d935c4ee86dfc6 Mon Sep 17 00:00:00 2001 From: evetion Date: Wed, 16 Oct 2024 18:54:23 +0000 Subject: [PATCH] deploy: d3a2b37e283a4cbd5af0f1fa05fcdd783a221540 --- concept/allocation.html | 22 +-- concept/core.html | 13 ++ guide/delwaq.html | 166 +++++++++--------- reference/node/basin.html | 14 +- reference/node/discrete-control.html | 2 +- reference/node/manning-resistance.html | 2 +- reference/node/tabulated-rating-curve.html | 2 +- reference/node/user-demand.html | 47 +++++ reference/test-models.html | 71 ++++---- .../figure-html/cell-2-output-10.png | Bin 71220 -> 65309 bytes .../figure-html/cell-2-output-11.png | Bin 61999 -> 71220 bytes .../figure-html/cell-2-output-12.png | Bin 34000 -> 61999 bytes .../figure-html/cell-2-output-13.png | Bin 57329 -> 34000 bytes .../figure-html/cell-2-output-14.png | Bin 59483 -> 57329 bytes .../figure-html/cell-2-output-15.png | Bin 28213 -> 59483 bytes .../figure-html/cell-2-output-16.png | Bin 64017 -> 28213 bytes .../figure-html/cell-2-output-17.png | Bin 49977 -> 64017 bytes .../figure-html/cell-2-output-18.png | Bin 94014 -> 49977 bytes .../figure-html/cell-2-output-19.png | Bin 52872 -> 94014 bytes .../figure-html/cell-2-output-20.png | Bin 39276 -> 52872 bytes .../figure-html/cell-2-output-21.png | Bin 68484 -> 39276 bytes .../figure-html/cell-2-output-22.png | Bin 99126 -> 68484 bytes .../figure-html/cell-2-output-23.png | Bin 126618 -> 99126 bytes .../figure-html/cell-2-output-24.png | Bin 36557 -> 126618 bytes .../figure-html/cell-2-output-25.png | Bin 52419 -> 36557 bytes .../figure-html/cell-2-output-26.png | Bin 36174 -> 52419 bytes .../figure-html/cell-2-output-27.png | Bin 68237 -> 36174 bytes .../figure-html/cell-2-output-28.png | Bin 36430 -> 68237 bytes .../figure-html/cell-2-output-29.png | Bin 51867 -> 36430 bytes .../figure-html/cell-2-output-30.png | Bin 69080 -> 51867 bytes .../figure-html/cell-2-output-31.png | Bin 74529 -> 69080 bytes .../figure-html/cell-2-output-32.png | Bin 37135 -> 74529 bytes .../figure-html/cell-2-output-33.png | Bin 72169 -> 37135 bytes .../figure-html/cell-2-output-34.png | Bin 123757 -> 72169 bytes .../figure-html/cell-2-output-35.png | Bin 87899 -> 123757 bytes .../figure-html/cell-2-output-36.png | Bin 81813 -> 87899 bytes .../figure-html/cell-2-output-37.png | Bin 39174 -> 81813 bytes .../figure-html/cell-2-output-38.png | Bin 93720 -> 39174 bytes .../figure-html/cell-2-output-39.png | Bin 42763 -> 93720 bytes .../figure-html/cell-2-output-40.png | Bin 0 -> 42763 bytes .../figure-html/cell-2-output-9.png | Bin 65309 -> 101370 bytes reference/usage.html | 20 ++- reference/validation.html | 4 +- search.json | 22 ++- tutorial/irrigation-demand.html | 4 +- tutorial/reservoir.html | 4 +- 46 files changed, 237 insertions(+), 156 deletions(-) create mode 100644 reference/test-models_files/figure-html/cell-2-output-40.png diff --git a/concept/allocation.html b/concept/allocation.html index 0a56fdb06..83dc17dea 100644 --- a/concept/allocation.html +++ b/concept/allocation.html @@ -578,7 +578,7 @@

4.4 Example

The following is an example of an optimization problem for the example shown here:

-
+
Code
using Ribasim
@@ -600,27 +600,27 @@ 

println(p.allocation.allocation_models[1].problem)

-
Min F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²
+
Min F[(Basin #2, UserDemand #3)]² + F[(Basin #5, UserDemand #6)]²
 Subject to
- flow_conservation[TabulatedRatingCurve #7] : -F[(TabulatedRatingCurve #7, Terminal #8)] + F[(Basin #5, TabulatedRatingCurve #7)] = 0
- flow_conservation[Basin #2] : F[(FlowBoundary #1, Basin #2)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] - F[(Basin #2, UserDemand #3)] + F[(UserDemand #3, Basin #2)] = 0
- flow_conservation[LinearResistance #4] : -F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] + F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] = 0
  flow_conservation[Terminal #8] : F[(TabulatedRatingCurve #7, Terminal #8)] = 0
- flow_conservation[Basin #5] : F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] + F[(UserDemand #6, Basin #5)] - F[(Basin #5, UserDemand #6)] - F[(Basin #5, TabulatedRatingCurve #7)] = 0
+ flow_conservation[Basin #5] : F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] - F[(Basin #5, TabulatedRatingCurve #7)] - F[(Basin #5, UserDemand #6)] + F[(UserDemand #6, Basin #5)] = 0
+ flow_conservation[LinearResistance #4] : -F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] + F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] = 0
+ flow_conservation[TabulatedRatingCurve #7] : -F[(TabulatedRatingCurve #7, Terminal #8)] + F[(Basin #5, TabulatedRatingCurve #7)] = 0
+ flow_conservation[Basin #2] : -F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] - F[(Basin #2, UserDemand #3)] + F[(UserDemand #3, Basin #2)] + F[(FlowBoundary #1, Basin #2)] = 0
  source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 172800
  source_user[UserDemand #3] : F[(UserDemand #3, Basin #2)] ≤ 0
  source_user[UserDemand #6] : F[(UserDemand #6, Basin #5)] ≤ 0
- F[(FlowBoundary #1, Basin #2)] ≥ 0
  F[(LinearResistance #4, Basin #5)] ≥ 0
  F[(Basin #5, LinearResistance #4)] ≥ 0
- F[(TabulatedRatingCurve #7, Terminal #8)] ≥ 0
- F[(UserDemand #6, Basin #5)] ≥ 0
  F[(Basin #2, LinearResistance #4)] ≥ 0
  F[(LinearResistance #4, Basin #2)] ≥ 0
- F[(Basin #5, UserDemand #6)] ≥ 0
+ F[(TabulatedRatingCurve #7, Terminal #8)] ≥ 0
+ F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
  F[(Basin #2, UserDemand #3)] ≥ 0
  F[(UserDemand #3, Basin #2)] ≥ 0
- F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
+ F[(Basin #5, UserDemand #6)] ≥ 0
+ F[(FlowBoundary #1, Basin #2)] ≥ 0
+ F[(UserDemand #6, Basin #5)] ≥ 0
 
diff --git a/concept/core.html b/concept/core.html index 05e7cafab..2b6ffb458 100644 --- a/concept/core.html +++ b/concept/core.html @@ -220,6 +220,7 @@

On this page

@@ -366,6 +367,18 @@

2 Nested allocati + +
+

3 Substance (tracer) concentration calculations

+

Ribasim can calculate concentrations of conservative tracers (i.e. substances that are non-reactive). It does so by calculating the mass transports by flows for each timestep, in the update_cumulative_flows! callback. Specifically, for each basin at each timestep we calculate:

+
    +
  • all mass inflows (flow * source_concentration) given the edge inflows
  • +
  • update the concentrations in the basin based on the added storage (previous storage + inflows)
  • +
  • all mass outflows (flow * basin_concentration_state) give the edge outflows
  • +
  • update the concentrations in the basin based on the current storage
  • +
+

We thus keep track of both mass and concentration of substances for each basin. Note that we have not added the substance mass to the states, and we assume that concentrations of flows are piecewise constant over a timestep.

+

By default we calculate concentrations for the following source tracers. - Continuity (mass balance, fraction of all water sources, sum of all other source tracers) - Initial (fraction of initial storages) - LevelBoundary, FlowBoundary, UserDemand, Drainage, Precipitation (fraction of different boundaries)

diff --git a/guide/delwaq.html b/guide/delwaq.html index 6eecdaa31..92662d7dc 100644 --- a/guide/delwaq.html +++ b/guide/delwaq.html @@ -879,14 +879,14 @@

2020-01-01 00:00:00 1 0.0 -Cl +Foo 1464 2020-01-01 00:00:00 1 -0.0 -FlowBoundary +1.0 +Initial 2928 @@ -899,8 +899,8 @@

4392 2020-01-01 00:00:00 1 -1.0 -Continuity +0.0 +Drainage 5856 @@ -920,22 +920,22 @@

11711 2020-12-31 00:00:00 9 -0.509381 -Bar +1.008239 +Cl 13175 2020-12-31 00:00:00 9 -0.000108 -Initial +0.0 +UserDemand 14639 2020-12-31 00:00:00 9 -0.970239 -Tracer +0.999999 +Continuity 16103 @@ -948,8 +948,8 @@

17567 2020-12-31 00:00:00 9 -0.0 -UserDemand +0.640103 +FlowBoundary @@ -958,7 +958,7 @@

-
{'Cl', 'FlowBoundary', 'Terminal', 'Continuity', 'LevelBoundary', 'Drainage', 'Foo', 'Bar', 'Initial', 'Tracer', 'Precipitation', 'UserDemand'}
+
{'Foo', 'Initial', 'Terminal', 'Drainage', 'LevelBoundary', 'Bar', 'Tracer', 'Cl', 'UserDemand', 'Continuity', 'Precipitation', 'FlowBoundary'}
@@ -986,15 +986,15 @@

8 2020-01-03 00:00:00 1 -1.164538 -Cl +0.034251 +Foo 1472 2020-01-03 00:00:00 1 -0.744403 -FlowBoundary +0.044259 +Initial 2936 @@ -1007,8 +1007,8 @@

4400 2020-01-03 00:00:00 1 -1.0 -Continuity +0.0 +Drainage 5864 @@ -1022,35 +1022,35 @@

2020-01-03 00:00:00 1 0.0 -Drainage +Bar 8792 2020-01-03 00:00:00 1 -0.034251 -Foo +0.92149 +Tracer 10256 2020-01-03 00:00:00 1 -0.0 -Bar +1.164538 +Cl 11720 2020-01-03 00:00:00 1 -0.044259 -Initial +0.0 +UserDemand 13184 2020-01-03 00:00:00 1 -0.92149 -Tracer +1.0 +Continuity 14648 @@ -1063,22 +1063,22 @@

16112 2020-01-03 00:00:00 1 -0.0 -UserDemand +0.744403 +FlowBoundary 9 2020-01-03 00:00:00 3 -28.936922 -Cl +0.851086 +Foo 1473 2020-01-03 00:00:00 3 -0.0 -FlowBoundary +0.029275 +Initial 2937 @@ -1091,8 +1091,8 @@

4401 2020-01-03 00:00:00 3 -1.0 -Continuity +0.0 +Drainage 5865 @@ -1106,35 +1106,35 @@

2020-01-03 00:00:00 3 0.0 -Drainage +Bar 8793 2020-01-03 00:00:00 3 -0.851086 -Foo +0.119639 +Tracer 10257 2020-01-03 00:00:00 3 -0.0 -Bar +28.936922 +Cl 11721 2020-01-03 00:00:00 3 -0.029275 -Initial +0.0 +UserDemand 13185 2020-01-03 00:00:00 3 -0.119639 -Tracer +1.0 +Continuity 14649 @@ -1148,21 +1148,21 @@

2020-01-03 00:00:00 3 0.0 -UserDemand +FlowBoundary 10 2020-01-03 00:00:00 6 -1.357952 -Cl +0.03994 +Foo 1474 2020-01-03 00:00:00 6 -0.748699 -FlowBoundary +0.032499 +Initial 2938 @@ -1175,8 +1175,8 @@

4402 2020-01-03 00:00:00 6 -1.0 -Continuity +0.0 +Drainage 5866 @@ -1189,36 +1189,36 @@

7330 2020-01-03 00:00:00 6 -0.0 -Drainage +0.748699 +Bar 8794 2020-01-03 00:00:00 6 -0.03994 -Foo +0.927561 +Tracer 10258 2020-01-03 00:00:00 6 -0.748699 -Bar +1.357952 +Cl 11722 2020-01-03 00:00:00 6 -0.032499 -Initial +0.0 +UserDemand 13186 2020-01-03 00:00:00 6 -0.927561 -Tracer +1.0 +Continuity 14650 @@ -1231,22 +1231,22 @@

16114 2020-01-03 00:00:00 6 -0.0 -UserDemand +0.748699 +FlowBoundary 11 2020-01-03 00:00:00 9 -31.049776 -Cl +0.002296 +Foo 1475 2020-01-03 00:00:00 9 -0.04955 -FlowBoundary +0.0078 +Initial 2939 @@ -1259,8 +1259,8 @@

4403 2020-01-03 00:00:00 9 -1.0 -Continuity +0.0 +Drainage 5867 @@ -1273,36 +1273,36 @@

7331 2020-01-03 00:00:00 9 -0.0 -Drainage +0.04955 +Bar 8795 2020-01-03 00:00:00 9 -0.002296 -Foo +0.078971 +Tracer 10259 2020-01-03 00:00:00 9 -0.04955 -Bar +31.049776 +Cl 11723 2020-01-03 00:00:00 9 -0.0078 -Initial +0.0 +UserDemand 13187 2020-01-03 00:00:00 9 -0.078971 -Tracer +1.0 +Continuity 14651 @@ -1315,8 +1315,8 @@

16115 2020-01-03 00:00:00 9 -0.0 -UserDemand +0.04955 +FlowBoundary diff --git a/reference/node/basin.html b/reference/node/basin.html index 1a05b6f51..265a9b021 100644 --- a/reference/node/basin.html +++ b/reference/node/basin.html @@ -476,7 +476,7 @@

1.2.1 Interpolation

At the given timestamps the values are set in the simulation, such that the timeseries can be seen as forward filled.

-
+
Code
import numpy as np
@@ -675,7 +675,7 @@ 

1.4.1.1 Level to area

The level to area relationship is defined with the Basin / profile data using linear interpolation. An example of such a relationship is shown below.

-
+
Code
fig, ax = plt.subplots()
@@ -758,7 +758,7 @@ 

\[ S(h) = \int_{h_0}^h A(h')\text{d}h'. \]

-
+
Code
storage = np.diff(level) * area[:-1] + 0.5 * np.diff(area) * np.diff(level)
@@ -803,7 +803,7 @@ 

1.4.1.3 Interactive basin example

The profile data is not detailed enough to create a full 3D picture of the basin. However, if we assume the profile data is for a stretch of canal of given length, the following plot shows a cross section of the basin.

-
+
Code
import plotly.graph_objects as go
@@ -918,9 +918,9 @@ 

fig.show()

-