Skip to content

Commit

Permalink
deploy: d3a2b37
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Oct 16, 2024
1 parent 72ff625 commit a9ef246
Show file tree
Hide file tree
Showing 46 changed files with 237 additions and 156 deletions.
22 changes: 11 additions & 11 deletions concept/allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ <h2 data-number="4.3" class="anchored" data-anchor-id="the-optimization-constrai
<section id="example" class="level2" data-number="4.4">
<h2 data-number="4.4" class="anchored" data-anchor-id="example"><span class="header-section-number">4.4</span> Example</h2>
<p>The following is an example of an optimization problem for the example shown <a href="../guide/examples.html#model-with-allocation-user-demand">here</a>:</p>
<div id="3c4c4314" class="cell" data-execution_count="1">
<div id="1736ed1b" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">Ribasim</span></span>
Expand All @@ -600,27 +600,27 @@ <h2 data-number="4.4" class="anchored" data-anchor-id="example"><span class="hea
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(p.allocation.allocation_models[<span class="fl">1</span>].problem)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>Min F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²
<pre><code>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
</code></pre>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions concept/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ <h2 id="toc-title">On this page</h2>
<ul>
<li><a href="#sec-simulationloop" id="toc-sec-simulationloop" class="nav-link active" data-scroll-target="#sec-simulationloop"><span class="header-section-number">1</span> The simulation loop</a></li>
<li><a href="#sec-nested-allocation" id="toc-sec-nested-allocation" class="nav-link" data-scroll-target="#sec-nested-allocation"><span class="header-section-number">2</span> Nested allocation</a></li>
<li><a href="#substance-tracer-concentration-calculations" id="toc-substance-tracer-concentration-calculations" class="nav-link" data-scroll-target="#substance-tracer-concentration-calculations"><span class="header-section-number">3</span> Substance (tracer) concentration calculations</a></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -366,6 +367,18 @@ <h1 data-number="2"><span class="header-section-number">2</span> Nested allocati
</div>
</div>
</div>
</section>
<section id="substance-tracer-concentration-calculations" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Substance (tracer) concentration calculations</h1>
<p>Ribasim can calculate concentrations of conservative tracers (i.e.&nbsp;substances that are non-reactive). It does so by calculating the mass transports by flows for each timestep, in the <code>update_cumulative_flows!</code> callback. Specifically, for each basin at each timestep we calculate:</p>
<ul>
<li>all mass inflows (flow * source_concentration) given the edge inflows</li>
<li>update the concentrations in the basin based on the added storage (previous storage + inflows)</li>
<li>all mass outflows (flow * basin_concentration_state) give the edge outflows</li>
<li>update the concentrations in the basin based on the current storage</li>
</ul>
<p>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.</p>
<p>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)</p>


</section>
Expand Down
Loading

0 comments on commit a9ef246

Please sign in to comment.