Skip to content

Commit

Permalink
deploy: 799a2d5
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Apr 15, 2024
1 parent efc6731 commit 332a391
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 214 deletions.
378 changes: 189 additions & 189 deletions build/index.html

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions core/allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,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 model shown <a href="../python/examples.html#model-with-allocation-user-demand">here</a>:</p>
<div id="ac9e84e8" class="cell" data-execution_count="1">
<div id="c512f488" 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 @@ -589,37 +589,37 @@ <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 #12, UserDemand #13)]² + F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]² + F_basin_in[Basin #2]² + F_basin_in[Basin #5]² + F_basin_in[Basin #12
<pre><code>Min F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]² + F[(Basin #12, UserDemand #13)]² + F_basin_in[Basin #12]² + F_basin_in[Basin #5]² + F_basin_in[Basin #2
Subject to
F[(Basin #12, UserDemand #13)] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #10)] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(Basin #5, Basin #2)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(UserDemand #13, Terminal #10)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(Basin #2, Basin #5)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(UserDemand #13, Terminal #10)] ≥ 0
F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F_basin_in[Basin #2] ≥ 0
F_basin_in[Basin #5] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #10)] ≥ 0
F[(Basin #12, UserDemand #13)] ≥ 0
F_basin_in[Basin #12] ≥ 0
F_basin_out[Basin #2] ≥ 0
F_basin_out[Basin #5] ≥ 0
F_basin_in[Basin #5] ≥ 0
F_basin_in[Basin #2] ≥ 0
F_basin_out[Basin #12] ≥ 0
F_basin_out[Basin #5] ≥ 0
F_basin_out[Basin #2] ≥ 0
source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 1
F[(UserDemand #6, Basin #5)] ≤ 0
F[(UserDemand #3, Basin #2)] ≤ 0
F[(UserDemand #13, Terminal #10)] ≤ 0
fractional_flow[(TabulatedRatingCurve #7, Basin #12)] : -0.4 F[(Basin #5, TabulatedRatingCurve #7)] + F[(TabulatedRatingCurve #7, Basin #12)] ≤ 0
basin_outflow[Basin #2] : F_basin_out[Basin #2] ≤ 0
basin_outflow[Basin #5] : F_basin_out[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 #12] : F_basin_out[Basin #12] ≤ 0
basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0
basin_outflow[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
flow_conservation_basin[Basin #5] : F[(Basin #5, TabulatedRatingCurve #7)] + F[(Basin #5, Basin #2)] - F[(UserDemand #6, Basin #5)] - F[(Basin #2, Basin #5)] + 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[(UserDemand #3, 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 #5] : F[(Basin #5, UserDemand #6)] + F[(Basin #5, Basin #2)] + F[(Basin #5, TabulatedRatingCurve #7)] - F[(Basin #2, Basin #5)] - F[(UserDemand #6, Basin #5)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 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
</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="c631e217" class="cell" data-execution_count="1">
<div id="af4c141e" 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_5297/665069857.py:31: SyntaxWarning:
/tmp/ipykernel_4977/665069857.py:31: SyntaxWarning:

invalid escape sequence '\p'
</code></pre>
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="1840fd64" class="cell" data-execution_count="1">
<div id="133d7632" 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="1c942b3b" class="cell" data-execution_count="2">
<div id="b64479ef" 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
2 changes: 1 addition & 1 deletion python/test-models.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ <h1 class="title">Test models</h1>


<p>Ribasim developers use the following models in their testbench and in order to test new features.</p>
<div id="74132ce5" class="cell" data-execution_count="1">
<div id="afbabb2b" 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> ribasim_testmodels</span>
Expand Down
4 changes: 2 additions & 2 deletions search.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
"href": "core/equations.html#sec-reduction_factor",
"title": "Equations",
"section": "2.1 The reduction factor",
"text": "2.1 The reduction factor\nAt several points in the equations below a reduction factor is used. This is a term that makes certain transitions more smooth, for instance when a pump stops providing water when its source basin dries up. The reduction factor is given by\n\\[\\begin{align}\n \\phi(x; p) =\n \\begin{cases}\n 0 &\\text{if}\\quad x &lt; 0 \\\\\n -2 \\left(\\frac{x}{p}\\right)^3 + 3\\left(\\frac{x}{p}\\right)^2 &\\text{if}\\quad 0 \\le x \\le p \\\\\n 1 &\\text{if}\\quad x &gt; p\n \\end{cases}\n\\end{align}\\]\nHere \\(p &gt; 0\\) is the threshold value which determines the interval \\([0,p]\\) of the smooth transition between \\(0\\) and \\(1\\), see the plot below.\n\n\nCode\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef f(x, p = 3):\n x_scaled = x / p\n phi = (-2 * x_scaled + 3) * x_scaled**2\n phi = np.where(x &lt; 0, 0, phi)\n phi = np.where(x &gt; p, 1, phi)\n\n return phi\n\nfontsize = 15\np = 3\nN = 100\nx_min = -1\nx_max = 4\nx = np.linspace(x_min,x_max,N)\nphi = f(x,p)\n\nfig,ax = plt.subplots(dpi=80)\nax.plot(x,phi)\n\ny_lim = ax.get_ylim()\n\nax.set_xticks([0,p], [0,\"$p$\"], fontsize=fontsize)\nax.set_yticks([0,1], [0,1], fontsize=fontsize)\nax.hlines([0,1],x_min,x_max, color = \"k\", ls = \":\", zorder=-1)\nax.vlines([0,p], *y_lim, color = \"k\", ls = \":\")\nax.set_xlim(x_min,x_max)\nax.set_xlabel(\"$x$\", fontsize=fontsize)\nax.set_ylabel(\"$\\phi(x;p)$\", fontsize=fontsize)\nax.set_ylim(y_lim)\n\nfig.tight_layout()\nplt.show()\n\n\n&lt;&gt;:31: SyntaxWarning:\n\ninvalid escape sequence '\\p'\n\n&lt;&gt;:31: SyntaxWarning:\n\ninvalid escape sequence '\\p'\n\n/tmp/ipykernel_5297/665069857.py:31: SyntaxWarning:\n\ninvalid escape sequence '\\p'",
"text": "2.1 The reduction factor\nAt several points in the equations below a reduction factor is used. This is a term that makes certain transitions more smooth, for instance when a pump stops providing water when its source basin dries up. The reduction factor is given by\n\\[\\begin{align}\n \\phi(x; p) =\n \\begin{cases}\n 0 &\\text{if}\\quad x &lt; 0 \\\\\n -2 \\left(\\frac{x}{p}\\right)^3 + 3\\left(\\frac{x}{p}\\right)^2 &\\text{if}\\quad 0 \\le x \\le p \\\\\n 1 &\\text{if}\\quad x &gt; p\n \\end{cases}\n\\end{align}\\]\nHere \\(p &gt; 0\\) is the threshold value which determines the interval \\([0,p]\\) of the smooth transition between \\(0\\) and \\(1\\), see the plot below.\n\n\nCode\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef f(x, p = 3):\n x_scaled = x / p\n phi = (-2 * x_scaled + 3) * x_scaled**2\n phi = np.where(x &lt; 0, 0, phi)\n phi = np.where(x &gt; p, 1, phi)\n\n return phi\n\nfontsize = 15\np = 3\nN = 100\nx_min = -1\nx_max = 4\nx = np.linspace(x_min,x_max,N)\nphi = f(x,p)\n\nfig,ax = plt.subplots(dpi=80)\nax.plot(x,phi)\n\ny_lim = ax.get_ylim()\n\nax.set_xticks([0,p], [0,\"$p$\"], fontsize=fontsize)\nax.set_yticks([0,1], [0,1], fontsize=fontsize)\nax.hlines([0,1],x_min,x_max, color = \"k\", ls = \":\", zorder=-1)\nax.vlines([0,p], *y_lim, color = \"k\", ls = \":\")\nax.set_xlim(x_min,x_max)\nax.set_xlabel(\"$x$\", fontsize=fontsize)\nax.set_ylabel(\"$\\phi(x;p)$\", fontsize=fontsize)\nax.set_ylim(y_lim)\n\nfig.tight_layout()\nplt.show()\n\n\n&lt;&gt;:31: SyntaxWarning:\n\ninvalid escape sequence '\\p'\n\n&lt;&gt;:31: SyntaxWarning:\n\ninvalid escape sequence '\\p'\n\n/tmp/ipykernel_4977/665069857.py:31: SyntaxWarning:\n\ninvalid escape sequence '\\p'",
"crumbs": [
"Julia core",
"Equations"
Expand Down Expand Up @@ -973,7 +973,7 @@
"href": "core/allocation.html#example",
"title": "Allocation",
"section": "4.4 Example",
"text": "4.4 Example\nThe following is an example of an optimization problem for the example model shown here:\n\n\nCode\nusing Ribasim\nusing Ribasim: NodeID\nusing SQLite\nusing ComponentArrays: ComponentVector\n\ntoml_path = normpath(@__DIR__, \"../../generated_testmodels/allocation_example/ribasim.toml\")\np = Ribasim.Model(toml_path).integrator.p\nu = ComponentVector(; storage = zeros(length(p.basin.node_id)))\n\nallocation_model = p.allocation.allocation_models[1]\nt = 0.0\npriority_idx = 1\n\nRibasim.set_flow!(p.graph, NodeID(:FlowBoundary, 1), NodeID(:Basin, 2), 1.0)\nRibasim.set_objective_priority!(allocation_model, p, u, t, priority_idx)\nRibasim.set_initial_values!(allocation_model, p, u, t)\n\nprintln(p.allocation.allocation_models[1].problem)\n\n\nMin F[(Basin #12, UserDemand #13)]² + F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]² + F_basin_in[Basin #2]² + F_basin_in[Basin #5]² + F_basin_in[Basin #12]²\nSubject to\n F[(Basin #12, UserDemand #13)] ≥ 0\n F[(TabulatedRatingCurve #7, Terminal #10)] ≥ 0\n F[(Basin #5, UserDemand #6)] ≥ 0\n F[(Basin #5, Basin #2)] ≥ 0\n F[(UserDemand #3, Basin #2)] ≥ 0\n F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0\n F[(FlowBoundary #1, Basin #2)] ≥ 0\n F[(Basin #2, Basin #5)] ≥ 0\n F[(UserDemand #6, Basin #5)] ≥ 0\n F[(UserDemand #13, Terminal #10)] ≥ 0\n F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0\n F[(Basin #2, UserDemand #3)] ≥ 0\n F_basin_in[Basin #2] ≥ 0\n F_basin_in[Basin #5] ≥ 0\n F_basin_in[Basin #12] ≥ 0\n F_basin_out[Basin #2] ≥ 0\n F_basin_out[Basin #5] ≥ 0\n F_basin_out[Basin #12] ≥ 0\n source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 1\n F[(UserDemand #6, Basin #5)] ≤ 0\n F[(UserDemand #3, Basin #2)] ≤ 0\n F[(UserDemand #13, Terminal #10)] ≤ 0\n fractional_flow[(TabulatedRatingCurve #7, Basin #12)] : -0.4 F[(Basin #5, TabulatedRatingCurve #7)] + F[(TabulatedRatingCurve #7, Basin #12)] ≤ 0\n basin_outflow[Basin #2] : F_basin_out[Basin #2] ≤ 0\n basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0\n basin_outflow[Basin #12] : F_basin_out[Basin #12] ≤ 0\n flow_conservation_basin[Basin #2] : -F[(Basin #5, Basin #2)] - F[(UserDemand #3, 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\n flow_conservation_basin[Basin #5] : F[(Basin #5, UserDemand #6)] + F[(Basin #5, Basin #2)] + F[(Basin #5, TabulatedRatingCurve #7)] - F[(Basin #2, Basin #5)] - F[(UserDemand #6, Basin #5)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 0\n 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",
"text": "4.4 Example\nThe following is an example of an optimization problem for the example model shown here:\n\n\nCode\nusing Ribasim\nusing Ribasim: NodeID\nusing SQLite\nusing ComponentArrays: ComponentVector\n\ntoml_path = normpath(@__DIR__, \"../../generated_testmodels/allocation_example/ribasim.toml\")\np = Ribasim.Model(toml_path).integrator.p\nu = ComponentVector(; storage = zeros(length(p.basin.node_id)))\n\nallocation_model = p.allocation.allocation_models[1]\nt = 0.0\npriority_idx = 1\n\nRibasim.set_flow!(p.graph, NodeID(:FlowBoundary, 1), NodeID(:Basin, 2), 1.0)\nRibasim.set_objective_priority!(allocation_model, p, u, t, priority_idx)\nRibasim.set_initial_values!(allocation_model, p, u, t)\n\nprintln(p.allocation.allocation_models[1].problem)\n\n\nMin F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]² + F[(Basin #12, UserDemand #13)]² + F_basin_in[Basin #12]² + F_basin_in[Basin #5]² + F_basin_in[Basin #2]²\nSubject to\n F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0\n F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0\n F[(Basin #5, Basin #2)] ≥ 0\n F[(UserDemand #3, Basin #2)] ≥ 0\n F[(UserDemand #13, Terminal #10)] ≥ 0\n F[(UserDemand #6, Basin #5)] ≥ 0\n F[(FlowBoundary #1, Basin #2)] ≥ 0\n F[(Basin #2, Basin #5)] ≥ 0\n F[(Basin #5, UserDemand #6)] ≥ 0\n F[(Basin #2, UserDemand #3)] ≥ 0\n F[(TabulatedRatingCurve #7, Terminal #10)] ≥ 0\n F[(Basin #12, UserDemand #13)] ≥ 0\n F_basin_in[Basin #12] ≥ 0\n F_basin_in[Basin #5] ≥ 0\n F_basin_in[Basin #2] ≥ 0\n F_basin_out[Basin #12] ≥ 0\n F_basin_out[Basin #5] ≥ 0\n F_basin_out[Basin #2] ≥ 0\n source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 1\n F[(UserDemand #6, Basin #5)] ≤ 0\n F[(UserDemand #3, Basin #2)] ≤ 0\n F[(UserDemand #13, Terminal #10)] ≤ 0\n fractional_flow[(TabulatedRatingCurve #7, Basin #12)] : F[(TabulatedRatingCurve #7, Basin #12)] - 0.4 F[(Basin #5, TabulatedRatingCurve #7)] ≤ 0\n basin_outflow[Basin #12] : F_basin_out[Basin #12] ≤ 0\n basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0\n basin_outflow[Basin #2] : F_basin_out[Basin #2] ≤ 0\n 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\n flow_conservation_basin[Basin #5] : F[(Basin #5, TabulatedRatingCurve #7)] + F[(Basin #5, Basin #2)] - F[(UserDemand #6, Basin #5)] - F[(Basin #2, Basin #5)] + F[(Basin #5, UserDemand #6)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 0\n flow_conservation_basin[Basin #2] : -F[(Basin #5, Basin #2)] - F[(UserDemand #3, 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",
"crumbs": [
"Julia core",
"Allocation"
Expand Down

0 comments on commit 332a391

Please sign in to comment.