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()

-