Skip to content

Commit

Permalink
Some docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 11, 2024
1 parent 4efb30d commit 32d4884
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions docs/concept/allocation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
$$
Expand All @@ -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
Expand All @@ -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:

Expand All @@ -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

Expand All @@ -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}}
Expand Down
6 changes: 3 additions & 3 deletions docs/dev/allocation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 32d4884

Please sign in to comment.