From 32d4884fd7d72d7c0998e3454ea74fe03ead6b2a Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Mon, 11 Nov 2024 14:51:32 +0100 Subject: [PATCH] Some docs updates --- docs/concept/allocation.qmd | 11 +++++------ docs/dev/allocation.qmd | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/concept/allocation.qmd b/docs/concept/allocation.qmd index 9f138fbfb..37783191f 100644 --- a/docs/concept/allocation.qmd +++ b/docs/concept/allocation.qmd @@ -36,7 +36,7 @@ The following data of the parameters and state of a Ribasim model are relevant f ### The subnetwork -The allocation problem is solved per subnetwork, which is given by a subset $S \subset V$ of node ids. Different subnetworks are disjoint from eachother. +The allocation problem is solved per subnetwork, which is given by a subset $S \subset V$ of node IDs. Different subnetworks are disjoint from eachother. ### Source flows @@ -77,7 +77,7 @@ for all $i \in FD_S$. Here $d^{p_{\text{df}}}$ is given by the original flow dem ### Vertical fluxes and local storage -Apart from the source flows denoted by edges, there are other sources of water in the subnetwork, associated with the basins in the subnetwork $B_S = B \cap S$. Firstly there is the average over the last allocation interval $\Delta t_{\text{alloc}}$ of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each basin: +Apart from the source flows denoted by edges, there are other sources of water in the subnetwork, associated with the basins in the subnetwork $B_S = B \cap S$. First, there is the average over the last allocation interval $\Delta t_{\text{alloc}}$ of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each basin: $$ \phi_i(t) = \frac{1}{\Delta t_{\text{alloc}}}\int_{t - \Delta t_{\text{alloc}}}^t \left[Q_{P,i}(t') - Q_{E,i}(t') + Q_{\text{drn},i}(t') - Q_{\text{inf},i}(t') \right] dt', \quad \forall i \in B_S. $$ @@ -102,7 +102,7 @@ for all $i \in B_S$. Note that the basin demand has only a single priority, so f Nodes in the Ribasim model that have a `max_flow_rate`, i.e. 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. #### UserDemand return flows -UserDemand nodes dictate proportional relationships between flows over edges in the subnetwork. The return factor is given by $0 \le r_i \le 1, i \in U_S$. +UserDemand nodes dictate proportional relationships between flows over edges in the subnetwork. The return factor is given by $0 \le r_i(t) \le 1, i \in U_S$. ## The subnetwork The subnetwork consists of a set of nodes $S \subset V$ and edges @@ -123,7 +123,6 @@ The capacities are determined in different ways: - If an edge does not exist in the allocation network, i.e. $(i,j) \notin E_S$ for certain $1 \le i,j\le n'$, then $(C_S)_{i,j} = 0$; - The capacity of the edge $e \in E_S$ is given by the smallest `max_flow_rate` of the nodes along the equivalent edges in the subnetwork. If there are no nodes with a `max_flow_rate`, the edge capacity is infinite; - If the edge is a source, the capacity of the edge is given by the flow rate of that source; -- If an edge comes from a node with a flow demand, it has infinite capacity at priorities other than this of this flow demand, and zero capacity otherwise. There are also capacities for special edges: @@ -133,7 +132,7 @@ There are also capacities for special edges: # The optimization problem -The optimization problem for a subnetwork is a linear optimization problem consisting of an objective function with associated constraints on a set of variables, all of which are introduced below. +The optimization problem for a subnetwork consists of a quadratic objective function with associated linear constraints on a set of variables, all of which are introduced below. ## The optimization variables @@ -145,7 +144,7 @@ There are several types of variable whose value has to be determined to solve th ## The optimization objective -The goal of allocation is to get the flow to nodes with demands as close as possible to these demands. To achieve this, a sum error of terms is minimized. +The goal of allocation is to get the flow to nodes with demands as close as possible to these demands. To achieve this, a sum of error terms is minimized. $$ \min E_{\text{user demand}} + E_{\text{level demand}} + E_{\text{flow demand}} diff --git a/docs/dev/allocation.qmd b/docs/dev/allocation.qmd index 44800e7d9..82d916160 100644 --- a/docs/dev/allocation.qmd +++ b/docs/dev/allocation.qmd @@ -28,10 +28,10 @@ More details on how allocation interacts with `JuMP.jl` is explained [here](#sec After initialization, as the simulation starts, the allocation problem is solved and updated after every allocation timestep (which is specified in the TOML). With every allocation timestep a new optimization problem is formulated and solved, using the latest available (simulation) model conditions and forcing and demand predictions. -The update of allocation (`update_allocation`) is repeating and spread into three parts: +The update of allocation (`update_allocation!`) is repeating and spread into three parts: -- Updating the mean flows. The mean flow data is only used only for output, not used by any internal functions. -- ["Collect demand"](/concept/allocation.qmd#sec-high-level-algorithm). This step initialize and solve the optimization problems that collects the demand from the subnetworks. +- Updating the mean flows. The mean flow data is used for output and to act a determine the capacity of sources in the allocation model. +- ["Collect demand"](/concept/allocation.qmd#sec-high-level-algorithm). This step initializes and solves the optimization problems that collects the demand from the subnetworks. - ["Allocate"](/concept/allocation.qmd#sec-high-level-algorithm). This step solves the optimization problems that allocates the demand. For the main network this step allocates to the subnetworks and demand nodes that are in the main network. For the subnetwork this step allocates to the demand nodes. The steps "collect demand" and "allocate" correspond to the function `collect_demand` and `allocate_demand` in the code.