Skip to content

Commit

Permalink
deploy: f6108a0
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Apr 16, 2024
1 parent 42dde18 commit c938c75
Show file tree
Hide file tree
Showing 41 changed files with 1,190 additions and 1,120 deletions.
398 changes: 199 additions & 199 deletions build/index.html

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions core/allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,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="../python/examples.html#model-with-allocation-user-demand">here</a>:</p>
<div id="ae01cd87" class="cell" data-execution_count="1">
<div id="be1c1f4e" 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 @@ -590,49 +590,49 @@ <h2 data-number="4.4" class="anchored" data-anchor-id="example"><span class="hea
<span id="cb1-18"><a href="#cb1-18" 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_abs_user_demand[UserDemand #13] + F_abs_user_demand[UserDemand #3] + F_abs_user_demand[UserDemand #6] + F_abs_level_demand[Basin #2] + F_abs_level_demand[Basin #12] + F_abs_level_demand[Basin #5]
<pre><code>Min F_abs_user_demand[UserDemand #3] + F_abs_user_demand[UserDemand #13] + F_abs_user_demand[UserDemand #6] + F_abs_level_demand[Basin #5] + F_abs_level_demand[Basin #2] + F_abs_level_demand[Basin #12]
Subject to
abs_positive_user_demand[UserDemand #13] : -F[(Basin #12, UserDemand #13)] + F_abs_user_demand[UserDemand #13] ≥ 0
abs_positive_user_demand[UserDemand #3] : -F[(Basin #2, UserDemand #3)] + F_abs_user_demand[UserDemand #3] ≥ 0
abs_positive_user_demand[UserDemand #13] : -F[(Basin #12, UserDemand #13)] + F_abs_user_demand[UserDemand #13] ≥ 0
abs_positive_user_demand[UserDemand #6] : -F[(Basin #5, UserDemand #6)] + F_abs_user_demand[UserDemand #6] ≥ 0
abs_negative_user_demand[UserDemand #13] : F[(Basin #12, UserDemand #13)] + F_abs_user_demand[UserDemand #13] ≥ 0
abs_negative_user_demand[UserDemand #3] : F[(Basin #2, UserDemand #3)] + F_abs_user_demand[UserDemand #3] ≥ 0
abs_negative_user_demand[UserDemand #13] : F[(Basin #12, UserDemand #13)] + F_abs_user_demand[UserDemand #13] ≥ 0
abs_negative_user_demand[UserDemand #6] : F[(Basin #5, UserDemand #6)] + F_abs_user_demand[UserDemand #6] ≥ 0
abs_positive_basin[Basin #5] : -F_basin_in[Basin #5] + F_abs_level_demand[Basin #5] ≥ 0
abs_positive_basin[Basin #2] : -F_basin_in[Basin #2] + F_abs_level_demand[Basin #2] ≥ 0
abs_positive_basin[Basin #12] : -F_basin_in[Basin #12] + F_abs_level_demand[Basin #12] ≥ 0
abs_positive_basin[Basin #5] : -F_basin_in[Basin #5] + F_abs_level_demand[Basin #5] ≥ 0
abs_negative_basin[Basin #5] : F_basin_in[Basin #5] + F_abs_level_demand[Basin #5] ≥ 0
abs_negative_basin[Basin #2] : F_basin_in[Basin #2] + F_abs_level_demand[Basin #2] ≥ 0
abs_negative_basin[Basin #12] : F_basin_in[Basin #12] + F_abs_level_demand[Basin #12] ≥ 0
abs_negative_basin[Basin #5] : F_basin_in[Basin #5] + F_abs_level_demand[Basin #5] ≥ 0
F[(Basin #12, UserDemand #13)] ≥ 0
F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0
F[(Basin #5, Basin #2)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0
F[(Basin #2, Basin #5)] ≥ 0
F[(UserDemand #13, Terminal #10)] ≥ 0
F[(Basin #5, Basin #2)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(Basin #12, UserDemand #13)] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(Basin #2, Basin #5)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #10)] ≥ 0
F_basin_in[Basin #5] ≥ 0
F_basin_in[Basin #2] ≥ 0
F_basin_in[Basin #12] ≥ 0
F_basin_in[Basin #5] ≥ 0
F_basin_out[Basin #5] ≥ 0
F_basin_out[Basin #2] ≥ 0
F_basin_out[Basin #12] ≥ 0
F_basin_out[Basin #5] ≥ 0
source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 1
F[(UserDemand #13, Terminal #10)] ≤ 0
F[(UserDemand #3, Basin #2)] ≤ 0
F[(UserDemand #13, Terminal #10)] ≤ 0
F[(UserDemand #6, Basin #5)] ≤ 0
fractional_flow[(TabulatedRatingCurve #7, Basin #12)] : F[(TabulatedRatingCurve #7, Basin #12)] - 0.4 F[(Basin #5, TabulatedRatingCurve #7)] ≤ 0
basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0
basin_outflow[Basin #2] : F_basin_out[Basin #2] ≤ 0
basin_outflow[Basin #12] : F_basin_out[Basin #12] ≤ 0
basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0
flow_conservation_basin[Basin #2] : -F[(UserDemand #3, Basin #2)] - F[(Basin #5, Basin #2)] - F[(FlowBoundary #1, Basin #2)] + F[(Basin #2, Basin #5)] + F[(Basin #2, UserDemand #3)] + F_basin_in[Basin #2] - F_basin_out[Basin #2] = 0
flow_conservation_basin[Basin #12] : F[(Basin #12, UserDemand #13)] - F[(TabulatedRatingCurve #7, Basin #12)] + F_basin_in[Basin #12] - F_basin_out[Basin #12] = 0
flow_conservation_basin[Basin #5] : F[(Basin #5, Basin #2)] - F[(UserDemand #6, Basin #5)] + F[(Basin #5, TabulatedRatingCurve #7)] + F[(Basin #5, UserDemand #6)] - F[(Basin #2, Basin #5)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 0
flow_conservation_basin[Basin #5] : F[(Basin #5, Basin #2)] - F[(Basin #2, Basin #5)] - F[(UserDemand #6, Basin #5)] + F[(Basin #5, TabulatedRatingCurve #7)] + F[(Basin #5, UserDemand #6)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 0
flow_conservation_basin[Basin #2] : -F[(Basin #5, Basin #2)] + F[(Basin #2, UserDemand #3)] - F[(FlowBoundary #1, Basin #2)] - F[(UserDemand #3, Basin #2)] + F[(Basin #2, Basin #5)] + F_basin_in[Basin #2] - F_basin_out[Basin #2] = 0
flow_conservation_basin[Basin #12] : -F[(TabulatedRatingCurve #7, Basin #12)] + F[(Basin #12, UserDemand #13)] + F_basin_in[Basin #12] - F_basin_out[Basin #12] = 0
</code></pre>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions core/equations.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ <h2 data-number="2.1" class="anchored" data-anchor-id="sec-reduction_factor"><sp
\end{cases}
\end{align}\]</span></p>
<p>Here <span class="math inline">\(p &gt; 0\)</span> is the threshold value which determines the interval <span class="math inline">\([0,p]\)</span> of the smooth transition between <span class="math inline">\(0\)</span> and <span class="math inline">\(1\)</span>, see the plot below.</p>
<div id="9a887f81" class="cell" data-execution_count="1">
<div id="3df20009" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
Expand Down Expand Up @@ -475,7 +475,7 @@ <h2 data-number="2.1" class="anchored" data-anchor-id="sec-reduction_factor"><sp

invalid escape sequence '\p'

/tmp/ipykernel_5056/665069857.py:31: SyntaxWarning:
/tmp/ipykernel_5497/665069857.py:31: SyntaxWarning:

invalid escape sequence '\p'
</code></pre>
Expand Down
85 changes: 65 additions & 20 deletions core/usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ <h2 id="toc-title">On this page</h2>
<li><a href="#sec-terminal" id="toc-sec-terminal" class="nav-link" data-scroll-target="#sec-terminal"><span class="header-section-number">17</span> Terminal</a></li>
<li><a href="#sec-discrete-control" id="toc-sec-discrete-control" class="nav-link" data-scroll-target="#sec-discrete-control"><span class="header-section-number">18</span> DisceteControl</a>
<ul class="collapse">
<li><a href="#discretecontrol-condition" id="toc-discretecontrol-condition" class="nav-link" data-scroll-target="#discretecontrol-condition"><span class="header-section-number">18.1</span> DiscreteControl / condition</a></li>
<li><a href="#discretecontrol-logic" id="toc-discretecontrol-logic" class="nav-link" data-scroll-target="#discretecontrol-logic"><span class="header-section-number">18.2</span> DiscreteControl / logic</a></li>
<li><a href="#discretecontrol-variable" id="toc-discretecontrol-variable" class="nav-link" data-scroll-target="#discretecontrol-variable"><span class="header-section-number">18.1</span> DiscreteControl / variable</a></li>
<li><a href="#discretecontrol-condition" id="toc-discretecontrol-condition" class="nav-link" data-scroll-target="#discretecontrol-condition"><span class="header-section-number">18.2</span> DiscreteControl / condition</a></li>
<li><a href="#discretecontrol-logic" id="toc-discretecontrol-logic" class="nav-link" data-scroll-target="#discretecontrol-logic"><span class="header-section-number">18.3</span> DiscreteControl / logic</a></li>
</ul></li>
<li><a href="#sec-pid-control" id="toc-sec-pid-control" class="nav-link" data-scroll-target="#sec-pid-control"><span class="header-section-number">19</span> PidControl</a>
<ul class="collapse">
Expand Down Expand Up @@ -657,7 +658,8 @@ <h1 data-number="3"><span class="header-section-number">3</span> Node</h1>
</ul></li>
<li>DiscreteControl: Set parameters of other nodes based on model state conditions (e.g.&nbsp;basin level)
<ul>
<li><code>DisceteControl / condition</code>: Conditions of the form ‘the level in the basin with node id <code>n</code> is bigger than 2.0 m’</li>
<li><code>DiscreteControl / variable</code> : Linear combinations of variables, e.g.&nbsp;averages or differences of levels</li>
<li><code>DisceteControl / condition</code>: Conditions of the form ‘the compound variable with ID <code>n</code> is bigger than 2.0’</li>
<li><code>DisceteControl / logic</code>: Translates the truth value of a set of conditions to parameter values for a controlled node</li>
</ul></li>
<li>PidControl: Controls the level in a basin by continuously controlling the flow rate of a connected pump or outlet. See also <a href="https://en.wikipedia.org/wiki/PID_controller">Wikipedia</a> and <a href="../core/equations.html#sec-PID">PID controller in equations</a>.
Expand Down Expand Up @@ -1821,15 +1823,18 @@ <h1 data-number="17"><span class="header-section-number">17</span> Terminal</h1>
<section id="sec-discrete-control" class="level1" data-number="18">
<h1 data-number="18"><span class="header-section-number">18</span> DisceteControl</h1>
<p>DiscreteControl is implemented based on <a href="https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/#VectorContinuousCallback">VectorContinuousCallback</a>.</p>
<section id="discretecontrol-condition" class="level2" data-number="18.1">
<h2 data-number="18.1" class="anchored" data-anchor-id="discretecontrol-condition"><span class="header-section-number">18.1</span> DiscreteControl / condition</h2>
<p>The condition schema defines conditions of the form ‘the discrete_control node with this node id listens to whether the given variable of the node with the given listen feature id is grater than the given value’. If the condition variable comes from a time-series, a look ahead <span class="math inline">\(\Delta t\)</span> can be supplied.</p>
<section id="discretecontrol-variable" class="level2" data-number="18.1">
<h2 data-number="18.1" class="anchored" data-anchor-id="discretecontrol-variable"><span class="header-section-number">18.1</span> DiscreteControl / variable</h2>
<p>The compound variable schema defines linear combinations of variables which can be used in conditions. This means that this schema defines new variables with the given <code>compound_variable_id</code> that look like <span class="math display">\[
\text{weight}_1 * \text{variable}_1 + \text{weight}_2 * \text{variable}_2 + \ldots,
\]</span></p>
<p>which can be for instance an average or a difference of variables. If a variable comes from a time-series, a look ahead <span class="math inline">\(\Delta t\)</span> can be supplied.</p>
<table class="table">
<colgroup>
<col style="width: 39%">
<col style="width: 18%">
<col style="width: 16%">
<col style="width: 25%">
<col style="width: 43%">
<col style="width: 17%">
<col style="width: 15%">
<col style="width: 23%">
</colgroup>
<thead>
<tr class="header">
Expand All @@ -1847,40 +1852,80 @@ <h2 data-number="18.1" class="anchored" data-anchor-id="discretecontrol-conditio
<td>sorted</td>
</tr>
<tr class="even">
<td>compound_variable_id</td>
<td>Int32</td>
<td>-</td>
<td>sorted per node_id</td>
</tr>
<tr class="odd">
<td>listen_node_type</td>
<td>String</td>
<td>-</td>
<td>known node type</td>
</tr>
<tr class="odd">
<tr class="even">
<td>listen_node_id</td>
<td>Int32</td>
<td>-</td>
<td>sorted per node_id</td>
</tr>
<tr class="even">
<tr class="odd">
<td>variable</td>
<td>String</td>
<td>-</td>
<td>must be “level” or “flow_rate”, sorted per listen_node_id</td>
</tr>
<tr class="odd">
<td>greater_than</td>
<tr class="even">
<td>weight</td>
<td>Float64</td>
<td>various</td>
<td>sorted per variable</td>
<td>-</td>
<td>(optional, default 1.0)</td>
</tr>
<tr class="even">
<tr class="odd">
<td>look_ahead</td>
<td>Float64</td>
<td><span class="math inline">\(s\)</span></td>
<td>Only on transient boundary conditions, non-negative (optional, default 0)</td>
<td>Only on transient boundary conditions, non-negative (optional, default 0.0).</td>
</tr>
</tbody>
</table>
</section>
<section id="discretecontrol-condition" class="level2" data-number="18.2">
<h2 data-number="18.2" class="anchored" data-anchor-id="discretecontrol-condition"><span class="header-section-number">18.2</span> DiscreteControl / condition</h2>
<p>The condition schema defines conditions of the form ‘the <code>discrete_control</code> node with this <code>node_id</code>listens to whether the variable given by the <code>node_id</code> and <code>compound_variable_id</code> is greater than <code>greater_than</code>’. Multiple conditions with different <code>greater_than</code> values can be defined on the same compound_variable.</p>
<table class="table">
<thead>
<tr class="header">
<th>column</th>
<th>type</th>
<th>unit</th>
<th>restriction</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>node_id</td>
<td>Int32</td>
<td>-</td>
<td>sorted</td>
</tr>
<tr class="even">
<td>compound_variable_id</td>
<td>Int32</td>
<td>-</td>
<td>-</td>
</tr>
<tr class="odd">
<td>greater_than</td>
<td>Float64</td>
<td>various</td>
<td>sorted per variable</td>
</tr>
</tbody>
</table>
</section>
<section id="discretecontrol-logic" class="level2" data-number="18.2">
<h2 data-number="18.2" class="anchored" data-anchor-id="discretecontrol-logic"><span class="header-section-number">18.2</span> DiscreteControl / logic</h2>
<section id="discretecontrol-logic" class="level2" data-number="18.3">
<h2 data-number="18.3" class="anchored" data-anchor-id="discretecontrol-logic"><span class="header-section-number">18.3</span> DiscreteControl / logic</h2>
<p>The logic schema defines which control states are triggered based on the truth of the conditions a DiscreteControl node listens to. DiscreteControl is applied in the Julia core as follows:</p>
<ul>
<li>During the simulation it is checked whether the truth of any of the conditions changes.</li>
Expand Down
4 changes: 2 additions & 2 deletions core/validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ <h1 class="title">Validation</h1>
<section id="connectivity" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Connectivity</h1>
<p>In the table below, each column shows which node types are allowed to be downstream (or ‘down-control’) of the node type at the top of the column.</p>
<div id="2a0015e5" class="cell" data-execution_count="1">
<div id="13624b1e" 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 Down Expand Up @@ -546,7 +546,7 @@ <h1 data-number="1"><span class="header-section-number">1</span> Connectivity</h
<section id="neighbor-amounts" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Neighbor amounts</h1>
<p>The table below shows for each node type between which bounds the amount of in- and outneighbors must be, for both flow and control edges.</p>
<div id="169824f1" class="cell" data-execution_count="2">
<div id="5cb01779" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>flow_in_min <span class="op">=</span> <span class="fu">Vector</span><span class="dt">{String}</span>()</span>
Expand Down
Loading

0 comments on commit c938c75

Please sign in to comment.