Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Apr 24, 2024
1 parent 675a0e4 commit 2dbf9cf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions core/src/allocation_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,8 @@ function add_constraints_conservation_node!(
end
end

# If the node is a Basin, add basin in- and outflow
if node_id.type == NodeType.Basin &&
has_external_demand(graph, node_id, :level_demand)[1]
# If the node is a Basin with a level demand, add basin in- and outflow
if has_external_demand(graph, node_id, :level_demand)[1]
push!(inflows_node, F_basin_out[node_id])
push!(outflows_node, F_basin_in[node_id])
end
Expand Down
3 changes: 1 addition & 2 deletions core/src/allocation_optim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,7 @@ function save_demands_and_allocations!(
#NOTE: instantaneous
realized = get_flow(graph, inflow_id(graph, node_id), node_id, 0)

elseif node_id.type == NodeType.Basin &&
has_external_demand(graph, node_id, :level_demand)[1]
elseif has_external_demand(graph, node_id, :level_demand)[1]
basin_priority_idx = get_external_priority_idx(p, node_id)

if priority_idx == 1 || basin_priority_idx == priority_idx
Expand Down
3 changes: 1 addition & 2 deletions core/src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,7 @@ function Allocation(db::DB, config::Config, graph::MetaGraph)::Allocation

# Find basins with a level demand
for node_id in values(graph.vertex_labels)
if node_id.type == NodeType.Basin &&
has_external_demand(graph, node_id, :level_demand)[1]
if has_external_demand(graph, node_id, :level_demand)[1]
mean_flows[(node_id, node_id)] = Ref(0.0)
end
end
Expand Down
14 changes: 9 additions & 5 deletions docs/core/allocation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ Sources are indicated by a set of edges in the subnetwork
$$
E_S^\text{source} \subset E.
$$
That is, if $(i,j) \in E_S^\text{source}$, then $Q_{ij}$ (see the [formal model description](equations.qmd#formal-model-description)) is treated as a source flow in the allocation problem. These edges are either coming from a boundary/source node (e.g. a level or flow boundary) or connect the main network to a subnetwork.
That is, if $(i,j) \in E_S^\text{source}$, then the average over the allocation interval $\Delta t_{\text{alloc}}$ of the of the flow over this edge
$$
\frac{1}{\Delta t_{\text{alloc}}}\int_{t - \Delta t_{\text{alloc}}}^tQ_{ij}(t') dt'
$$
is treated as a source flow in the allocation problem. These edges are either coming from a boundary/source node (e.g. a level or flow boundary) or connect the main network to a subnetwork. For the definition of $Q_{ij}$ see [the formal model description](equations.qmd#formal-model-description).

### User demands

Expand Down Expand Up @@ -71,12 +75,12 @@ 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 sum 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$. Firstly there is the average over the allocation interval $\Delta t_{\text{alloc}}$ of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each basin:
$$
\phi_i(t), \quad \forall i \in B_S.
\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.
$$

We consider fluxes into the basin to be positive and out of the basin to be negative.
We consider fluxes into the basin to be positive and out of the basin to be negative. For more information see [the natural water balance terms](equations.qmd#natural-water-balance-terms).

Secondly, there is either a supply or demand from the storage in the basin. Given a minimum level $\ell_{\min, i}$ and a maximum level $\ell_{\max, i}$ which correspond to a minimum storage $s_{\min, i}$ and maximum storage $s_{\max, i}$ respectively, we get a flow supply of
$$
Expand All @@ -88,7 +92,7 @@ $$
d^p_i = \max\left(0.0, \frac{s_{\min,i} - u_i(t)}{\Delta t_{\text{alloc}}} - \phi_i(t)\right),
$$

for all $i \in B_S$. Here $\Delta t_{\text{alloc}}$ is the simulated time between two consecutive allocation solves. Note that the basin demand has only a single priority, so for other priorities this demand is $0$.
for all $i \in B_S$. Note that the basin demand has only a single priority, so for other priorities this demand is $0$.

### Constraining factors

Expand Down
2 changes: 1 addition & 1 deletion docs/core/equations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ax.hlines([0,1],x_min,x_max, color = "k", ls = ":", zorder=-1)
ax.vlines([0,p], *y_lim, color = "k", ls = ":")
ax.set_xlim(x_min,x_max)
ax.set_xlabel("$x$", fontsize=fontsize)
ax.set_ylabel("$\phi(x;p)$", fontsize=fontsize)
ax.set_ylabel(r"$\phi(x;p)$", fontsize=fontsize)
ax.set_ylim(y_lim)
fig.tight_layout()
Expand Down

0 comments on commit 2dbf9cf

Please sign in to comment.