Pre and post processing virtual reservoirs
The virtual reservoir representation in the market clearing problem requires some pre-calculation at the beginning of the run, as well as at the beginning and end of each period. These calculations can use input data and results from optimizing the market clearing subproblem of a previous period, and are utilized to fill and update parameters used in the subproblem.
Curveguide points
If the depletion curve is set to uniform, the curveguide points are defined to deplete each reservoir proportionally. This means that the same percentage of each reservoir's volume will be released over time. Since the curveguide is defined as a convex combination of the points, it is sufficient to define the first point of each reservoir as 1 and the second and last points as 0. This ensures that, by the end of the period, each reservoir will have released its water at the same proportion.
For each virtual reservoir $r$, and hydro unit $h \in J^H_{VR}(r)$, we define the waveguide points as follows:
\[v^{WG}_{r, h, 1} = 1 \quad \text{and} \quad v^{WG}_{r, h, 2} = 0\]
Water-to-Energy Factors
For a hydro unit $h$ at a virtual reservoir $r$, the water-to-energy factor $\zeta_{r,h}$ represents the amount of energy (MWh) that can be generated by each $hm^3$ of volume at $h$ within the hydro units of reservoir $r$. To calculate this factor, we analyze the topology of the cascade to identify which hydro units within $r$ lie downstream of $h$. Specifically, we look for hydro units $g \in J^H_VR(r)$ such that there exists a path from $h$ to $g$ through intermediate units. This path is defined by a sequence of units $h, g_1, g_2, \dots, g_n, g$, where each $g_i \in J^H_VR(r)$ for all $i \in [n]$, with each unit in the sequence receiving water from the previous one: $h$ turbines water to $g_1$, $g_i$ turbines water to $g_{i+1}$, and $g_n$ turbines water to $g$.
Let $G$ be the set of possible downstream units $g$. Thus, the water-to-energy factor is given by:
\[\zeta_{r,h} = \sum_{g \in G} \rho_g \cdot C_{hm^3/h \rightarrow m^3/s}\]
where $\rho_g$ is the production factor of hydro unit $g$.
Additional energy from inflows
At the beginning of each period, for each scenario, we calculate the additional energy that is stored in the virtual reservoirs due to inflows. This is done by analyzing the inflow series and the current volume of each hydro unit. The calculation begins at the top of the cascade and proceeds downstream. At each hydro unit $j$, the inflow volume for the period is:
\[a^{vol}_j = \sum_{\tau \in B(t)} a_{j, \tau} \cdot C_{m^3/s \rightarrow hm^3/h} \cdot d(\tau)\]
The maximum volume of water that can be turbined from hydro unit $j$ during the period is:
\[U_j^{vol} = U_j \cdot C_{m^3/s \rightarrow hm^3/h} \cdot \sum_{\tau \in B(t)} d(\tau)\]
The inflow volume that unavoidably spills from hydro unit $j$ is:
\[z^{vol}_j = \max(a^{vol}_j + v^{S_{in}}_j - (V_j + U_j^{vol}), 0)\]
The additional energy that can be generated by the inflow at hydro unit $j$ is:
\[e^{inflow}_r = (a^{vol}_j - z^{vol}_j) \cdot \zeta_{r,j}\]
where $\zeta_{r,j}$ is the water-to-energy factor for hydro unit $j$ at virtual reservoir $r$.
The excess inflow $z^{vol}_j$ is added to the downstream hydro unit $g$ that receives water from $j$, if it exists, and the process continues downstream until all hydro units in the virtual reservoir have been processed.
Post processing energy account
At the end of each period, we want to guarantee that the sum of the energy accounts of the asset owners at a virtual reservoir is equal to the stored energy of the hydro units of this virtual reservoir. For that, we adjust the energy accounts, if necessary. The raw energy accounts can be obtained from the optimization solution: ${E^{out}_{r,i}}^*$. The stored energy of each hydro unit $h$ can be calculated based on the final volume at the optimization solution ${v^{S_{out}}_h}^*$ and the water-to-energy factors $\zeta_{r,h}$.
Stored energy of virtual reservoir $r$: $A=\sum_{h \in J^H_{VR}(r)} {v^{S_{out}}_h}^* \cdot \zeta_{r,h}$
Sum of energy accounts of virtual reservoir $r$: $B =\sum_{i \in I^{VR}(r)} {E^{out}_{r,i}}^*$
For each asset owner $i$ at virtual reservoir $r$, we define the post-processed energy account $E'_{r,i}$:
\[E'_{r,i} = {E^{out}_{r,i}}^* \cdot \frac{A}{B}\]
This way, $\sum_{i \in I^{VR}(r)} E'_{r,i} = A$, and the proportions of energy accounts at $r$ are kept.
For the next period, $E^{in}_{r,i} = E'_{r,i}$.