Skip to content

Commit

Permalink
deploy: 5021c6e
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Oct 10, 2024
1 parent b272004 commit b10e786
Show file tree
Hide file tree
Showing 25 changed files with 159 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="eee760ce" class="cell" data-execution_count="1">
<div id="8cced682" 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 @@ -602,25 +602,25 @@ <h2 data-number="4.4" class="anchored" data-anchor-id="example"><span class="hea
<div class="cell-output cell-output-stdout">
<pre><code>Min F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²
Subject to
flow_conservation[Terminal #8] : F[(TabulatedRatingCurve #7, Terminal #8)] = 0
flow_conservation[Basin #5] : -F[(Basin #5, TabulatedRatingCurve #7)] + F[(UserDemand #6, Basin #5)] - F[(Basin #5, UserDemand #6)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] = 0
flow_conservation[LinearResistance #4] : F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] - F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] = 0
flow_conservation[Basin #2] : F[(UserDemand #3, Basin #2)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] + F[(FlowBoundary #1, Basin #2)] - F[(Basin #2, UserDemand #3)] = 0
flow_conservation[Basin #5] : -F[(Basin #5, UserDemand #6)] - F[(Basin #5, TabulatedRatingCurve #7)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] + F[(UserDemand #6, Basin #5)] = 0
flow_conservation[TabulatedRatingCurve #7] : F[(Basin #5, TabulatedRatingCurve #7)] - F[(TabulatedRatingCurve #7, Terminal #8)] = 0
flow_conservation[LinearResistance #4] : F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] - F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] = 0
flow_conservation[Terminal #8] : F[(TabulatedRatingCurve #7, Terminal #8)] = 0
flow_conservation[Basin #2] : -F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] + F[(FlowBoundary #1, Basin #2)] + F[(UserDemand #3, Basin #2)] - F[(Basin #2, UserDemand #3)] = 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[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(Basin #2, LinearResistance #4)] ≥ 0
F[(LinearResistance #4, Basin #2)] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #8)] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(LinearResistance #4, Basin #5)] ≥ 0
F[(Basin #5, LinearResistance #4)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #8)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F[(LinearResistance #4, Basin #5)] ≥ 0
F[(Basin #5, LinearResistance #4)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
</code></pre>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions concept/equations.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,21 @@ <h2 data-number="1.4" class="anchored" data-anchor-id="the-water-balance-error">
<p>The water balance error quantifies how well the water volume in the model is conserved for each Basin over an output save period, i.e.&nbsp;whether no water erroneously appears or disappears. It looks at the storage rate <span class="math display">\[
\text{storage rate} = \frac{\Delta S_b}{\Delta t}
\]</span></p>
<p>in a Basin over a time period <span class="math inline">\(\Delta t = t_1 - t_0\)</span> and compares that to the total inflows and outflows of that Basin over that period. More precisely, we first compute the total inflow and outflow, where:</p>
<p>in a Basin over a time period <span class="math inline">\(\Delta t\)</span> and compares that to the total inflows and outflows of that Basin over that period. More precisely, we first compute the total inflow and outflow, where:</p>
<ul>
<li><span class="math inline">\(\text{total inflow}\)</span>: the precipitation, drainage and horizontal flows into the Basin;</li>
<li><span class="math inline">\(\text{total outflow}\)</span>: the evaporation, infiltration and horizontal flows out of the Basin.</li>
</ul>
<p>Whether a flow is an inflow or an outflow depends on whether the flow contributes to or takes from the Basin storage, and thus this is independent of the edge direction. This is determined for each solver timestep individually.</p>
<p>Whether a flow is an inflow or an outflow depends on whether the flow contributes to or takes from the Basin storage, which means that this is independent of the edge direction. This is determined for each solver timestep individually.</p>
<p>Then from this we compute the errors:</p>
<p><span class="math display">\[
\begin{align}
\text{balance error} =&amp;&amp; \text{storage rate} - (\text{total inflow} - \text{total outflow}) \\
\text{relative error}=&amp;&amp; \frac{\text{absolute error}}{0.5(\text{total inflow} + \text{total outflow})}
\end{align}
\]</span> Hence the reference used for computing the relative error is the average of the total inflow and total outflow of the Basin (which are both non-negative).</p>
<p>The default tolerances are <span class="math inline">\(0.001 \text{ m}^3\)</span> for the balance error and <span class="math inline">\(0.01\)</span> for the absolute error, which should not be exceeded for realistic models.</p>
<p>In extreme cases where storage rate is many orders of magnitude smaller than the storage itself, these computations can have floating point truncation errors which can lead to large relative errors. This is however only when the storage is roughly <span class="math inline">\(10^{15}\)</span> or more times bigger than the storage rate.</p>
<p>The default tolerances are <span class="math inline">\(0.001 \text{ m}^3\)</span> for the balance error and <span class="math inline">\(0.01\)</span> for the relative error, which should not be exceeded for realistic models.</p>
<p>In extreme cases where the storage rate is many orders of magnitude smaller than the storage itself, these computations can have floating point truncation errors which can lead to large relative errors. This is however only when the storage is roughly $ ^{15}$ times bigger than the storage rate.</p>
<section id="example-calculation" class="level3" data-number="1.4.1">
<h3 data-number="1.4.1" class="anchored" data-anchor-id="example-calculation"><span class="header-section-number">1.4.1</span> Example calculation</h3>
<p>Say we have the following model:</p>
Expand Down
Loading

0 comments on commit b10e786

Please sign in to comment.