Skip to content

Commit

Permalink
deploy: 935aeed
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Jul 16, 2024
1 parent 025c010 commit 6886905
Show file tree
Hide file tree
Showing 78 changed files with 1,202 additions and 2,280 deletions.
49 changes: 15 additions & 34 deletions concept/allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ <h3 data-number="3.2.2" class="anchored" data-anchor-id="constraining-factors"><
<h4 data-number="3.2.2.1" class="anchored" data-anchor-id="flow-magnitude-and-direction-constraints"><span class="header-section-number">3.2.2.1</span> Flow magnitude and direction constraints</h4>
<p>Nodes in the Ribasim model that have a <code>max_flow_rate</code>, i.e.&nbsp;Pump, Outlet and LinearResistance, put a constraint on the flow through that node. Some nodes only allow flow in one direction, like Pump, Outlet and TabulatedRatingCurve.</p>
</section>
<section id="fractionalflow-and-userdemand-return-flows" class="level4" data-number="3.2.2.2">
<h4 data-number="3.2.2.2" class="anchored" data-anchor-id="fractionalflow-and-userdemand-return-flows"><span class="header-section-number">3.2.2.2</span> FractionalFlow and UserDemand return flows</h4>
<p>Both FractionalFlow and UserDemand nodes dictate proportional relationships between flows over edges in the subnetwork. UserDemands have a return factor <span class="math inline">\(0 \le r_i \le 1, i \in U_S\)</span>, and FractionalFlow nodes have an associated fraction <span class="math inline">\(f_j\)</span> which can be updated by DiscreteControl.</p>
<section id="userdemand-return-flows" class="level4" data-number="3.2.2.2">
<h4 data-number="3.2.2.2" class="anchored" data-anchor-id="userdemand-return-flows"><span class="header-section-number">3.2.2.2</span> UserDemand return flows</h4>
<p>UserDemand nodes dictate proportional relationships between flows over edges in the subnetwork. The return factor is given by <span class="math inline">\(0 \le r_i \le 1, i \in U_S\)</span>.</p>
</section>
</section>
</section>
Expand Down Expand Up @@ -480,7 +480,7 @@ <h2 data-number="4.1" class="anchored" data-anchor-id="the-optimization-variable
<ul>
<li>The flows <span class="math inline">\(F \in \mathbb{R}_{\ge 0}^{n\times n}\)</span> over the edges in the allocation network;</li>
<li>The flows <span class="math inline">\(F^\text{basin out}_{i}, F^\text{basin in}_{i} \geq 0\)</span> for all <span class="math inline">\(i \in B_S\)</span> supplied and consumed by the basins with a level demand respectively;</li>
<li>The flows <span class="math inline">\(F^\text{buffer out}_{i}, F^\text{buffer in}_{i} \ge 0\)</span> for all <span class="math inline">\(i \in FD_S \cup FF_S\)</span> supplied and consumed by the flow buffers of nodes with a flow demand or fractional flow outneighbors.</li>
<li>The flows <span class="math inline">\(F^\text{buffer out}_{i}, F^\text{buffer in}_{i} \ge 0\)</span> for all <span class="math inline">\(i \in FD_S \cup FF_S\)</span> supplied and consumed by the flow buffers of nodes with a flow demand.</li>
</ul>
</section>
<section id="the-optimization-objective" class="level2" data-number="4.2">
Expand Down Expand Up @@ -577,18 +577,13 @@ <h2 data-number="4.3" class="anchored" data-anchor-id="the-optimization-constrai
r_i \cdot F_{ki}, \quad V_S^{\text{in}}(i) = \{k\}.
\]</span></p>
<ul>
<li><p>Fractional flow: Let <span class="math inline">\(L_S \subset V_S\)</span> be the set of nodes in the max flow graph with fractional flow outneighbors, and <span class="math inline">\(f_j\)</span> the flow fraction associated with fractional flow node <span class="math inline">\(j \in V_S\)</span>. Then <span id="eq-fractionalflowconstraint"><span class="math display">\[
F_{ij} \le f_j \sum_{k\in V^\text{in}_S(i)} F_{ki} \qquad
\forall i \in L_S, \;
j \in V_S^\text{out}(i).
\tag{3}\]</span></span></p></li>
<li><p>Flow sign: Furthermore there are the non-negativity constraints for the flows and allocations, see <a href="../concept/allocation.html#the-optimization-variables">The optimization variables</a>.</p></li>
<li>Flow sign: Furthermore there are the non-negativity constraints for the flows and allocations, see <a href="../concept/allocation.html#the-optimization-variables">The optimization variables</a>.</li>
</ul>
</section>
<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="ff8c1934" class="cell" data-execution_count="1">
<div id="a55a8c2a" 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 @@ -611,41 +606,27 @@ <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[(Basin #2, UserDemand #3)]² + F[(Basin #5, UserDemand #6)]² + F[(Basin #12, UserDemand #13)]²
<pre><code>Min F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²
Subject to
source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 172800
source_user[UserDemand #13] : F[(UserDemand #13, Terminal #10)] ≤ 0
source_user[UserDemand #3] : F[(UserDemand #3, Basin #2)] ≤ 0
source_user[UserDemand #6] : F[(UserDemand #6, Basin #5)] ≤ 0
fractional_flow[(TabulatedRatingCurve #7, FractionalFlow #8)] : F[(TabulatedRatingCurve #7, FractionalFlow #8)] - 0.6 F[(Basin #5, TabulatedRatingCurve #7)] ≤ 0
fractional_flow[(TabulatedRatingCurve #7, FractionalFlow #9)] : F[(TabulatedRatingCurve #7, FractionalFlow #9)] - 0.4 F[(Basin #5, TabulatedRatingCurve #7)] ≤ 0
flow_buffer_outflow[TabulatedRatingCurve #7] : F_flow_buffer_out[TabulatedRatingCurve #7] ≤ 0
flow_conservation[FractionalFlow #9] : F[(TabulatedRatingCurve #7, FractionalFlow #9)] - F[(FractionalFlow #9, Basin #12)] = 0
flow_conservation[FractionalFlow #8] : -F[(FractionalFlow #8, Terminal #10)] + F[(TabulatedRatingCurve #7, FractionalFlow #8)] = 0
flow_conservation[Basin #2] : F[(FlowBoundary #1, Basin #2)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] + F[(UserDemand #3, Basin #2)] - F[(Basin #2, UserDemand #3)] = 0
flow_conservation[Terminal #1] : F[(TabulatedRatingCurve #7, Terminal #1)] = 0
flow_conservation[TabulatedRatingCurve #7] : -F[(TabulatedRatingCurve #7, Terminal #1)] + F[(Basin #5, TabulatedRatingCurve #7)] = 0
flow_conservation[Basin #5] : -F[(Basin #5, TabulatedRatingCurve #7)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] - F[(Basin #5, UserDemand #6)] + F[(UserDemand #6, Basin #5)] = 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[TabulatedRatingCurve #7] : -F[(TabulatedRatingCurve #7, FractionalFlow #8)] - F[(TabulatedRatingCurve #7, FractionalFlow #9)] + F[(Basin #5, TabulatedRatingCurve #7)] - F_flow_buffer_in[TabulatedRatingCurve #7] + F_flow_buffer_out[TabulatedRatingCurve #7] = 0
flow_conservation[Basin #5] : F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] - F[(Basin #5, UserDemand #6)] + F[(UserDemand #6, Basin #5)] - F[(Basin #5, TabulatedRatingCurve #7)] = 0
flow_conservation[Basin #2] : -F[(Basin #2, UserDemand #3)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] + F[(FlowBoundary #1, Basin #2)] + F[(UserDemand #3, Basin #2)] = 0
flow_conservation[Basin #12] : F[(FractionalFlow #9, Basin #12)] - F[(Basin #12, UserDemand #13)] = 0
flow_conservation[Terminal #10] : F[(FractionalFlow #8, Terminal #10)] + F[(UserDemand #13, Terminal #10)] = 0
F[(FractionalFlow #8, Terminal #10)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #1)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(Basin #2, LinearResistance #4)] ≥ 0
F[(LinearResistance #4, Basin #2)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(LinearResistance #4, Basin #5)] ≥ 0
F[(Basin #5, LinearResistance #4)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(TabulatedRatingCurve #7, FractionalFlow #8)] ≥ 0
F[(TabulatedRatingCurve #7, FractionalFlow #9)] ≥ 0
F[(FractionalFlow #9, Basin #12)] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(UserDemand #13, Terminal #10)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(Basin #12, UserDemand #13)] ≥ 0
F_flow_buffer_in[TabulatedRatingCurve #7] ≥ 0
F_flow_buffer_out[TabulatedRatingCurve #7] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
</code></pre>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions concept/modelconcept.html
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,8 @@ <h2 data-number="1.4" class="anchored" data-anchor-id="structures-in-a-water-sys
<li><a href="../reference/node/manning-resistance.html">ManningResistance</a>: bi-directional flow based on head difference and resistance using Manning-Gauckler formula. Same usage as LinearResistance, providing a better hydrological meaning to the resistance parameterization.</li>
<li><a href="../reference/node/pump.html">Pump</a>: one-directional structure with a set flow rate. Node type typically used in combination with control to force water over the edge.</li>
<li><a href="../reference/node/outlet.html">Outlet</a>: one-directional gravity structure with a set flow rate. Node type typically used in combination with control to force water over the edge, even if their is a mismatch in actual hydraulic capacity. The node type has an automated mechanism to stop the flow when the head difference is zero.</li>
<li><a href="../reference/node/fractional-flow.html">FractionalFlow</a>: to split an outflow over multiple edges based on a flow fraction. Node type is typically used for diversions or bifurcations with a known and fixed ratio.</li>
</ul>
<p>The control layer can activate or deactivate nodes, set flow rates for the Pump and Outlet, or choose different parameterizations for TabulatedRatingCurve, LinearResistance, ManningResistance or FractionalFlow.</p>
<p>The control layer can activate or deactivate nodes, set flow rates for the Pump and Outlet, or choose different parameterizations for TabulatedRatingCurve, LinearResistance or ManningResistance.</p>
<p>Connector nodes are required within a Ribasim network to determine the flow exchange between basins.</p>


Expand Down
2 changes: 1 addition & 1 deletion dev/addnode.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ <h2 data-number="1.4" class="anchored" data-anchor-id="the-jacobian"><span class
<p>We divide the various node types in groups based on what type of state dependencies they yield, and these groups are discussed below. Each group has its own method <code>update_jac_prototype!</code> in <code>utils.jl</code> for the sparsity structure induced by nodes of that group. <code>NewNodeType</code> should be added to the signature of one these methods, or to the list of node types that do not contribute to the Jacobian in the method of <code>update_jac_prototype!</code> whose signature contains <code>node::AbstractParameterNode</code>. Of course it is also possible that a new method of <code>update_jac_prototype!</code> has to be introduced.</p>
<p>The current dependency groups are:</p>
<ul>
<li>Out-neighbor dependencies: examples are <code>TabulatedRatingCurve</code>, <code>Pump</code> (the latter only in the reduction factor regime and not PID controlled). If the in-neighbor of a node of this group is a basin, then the storage of this basin affects itself and the storage of the outneighbor (or the basin one node further if it is connected with a <code>FractionalFlow</code> in between) if that is also a basin;</li>
<li>Out-neighbor dependencies: examples are <code>TabulatedRatingCurve</code>, <code>Pump</code> (the latter only in the reduction factor regime and not PID controlled). If the in-neighbor of a node of this group is a basin, then the storage of this basin affects itself and the storage of the outneighbor if that is also a basin;</li>
<li>Either-neighbor dependencies: examples are <code>LinearResistance</code>, <code>ManningResistance</code>. If either the in-neighbor or out-neighbor of a node of this group is a basin, the storage of this basin depends on itself. If both the in-neighbor and the out-neighbor are basins, their storages also depend on eachother.</li>
<li>The <code>PidControl</code> node is a special case which is discussed in <a href="../reference/node/pid-control.html#equations">the PID equations</a>.</li>
</ul>
Expand Down
Loading

0 comments on commit 6886905

Please sign in to comment.