About Reservoir Convergence Functions

The purpose of these functions is to solve for the variable of interest, which is dependent on a second changing variable. The functions must be solved simultaneously to determine the variable of interest. For example, the getMaxOutflow function returns the maximum allowable outflow based on the pool elevation. Two functions are used in this iterative process; the mass balance and maximum outflow functions. The reservoir inflows are known and the function searches for the solution for maximum outflow that satisfies both the maximum outflow tables (max outflow as a function of pool elevation) and the mass balance equation for the reservoir. As guesses for the maximum outflow change, the pool elevation fluctuates as a result of the changing storage as calculated by the mass balance equation. This pool elevation is then used to determine a new maximum outflow value.

Thus, an iterative search algorithm is needed to simultaneously solve the functions. Two types of search algorithms are employed to find the solution. The first algorithm iterates by updating the variable of interest based on the independent variable (usually pool elevation) in each iteration. For example, during each iteration in the getMaxOutflow function, outflow is calculated based on the mass balance pool elevation. At the end of each iteration, the outflow value is compared to that of the previous iteration and the algorithm is exited if these values are within convergence. The values are considered converged if

Note: If New Value is zero, the Old Value is used as the denominator. If Old and New Value are both zero, it has converged. Convergence Percentage is a general slot on the reservoir which defaults to 0.0001 if not input by the user.

Under certain circumstances, this simplistic iterative routine may fall into a loop that iterates around the solution and never converges. In this event, the bisection routine is invoked using the final values from the first routine as its initial conditions.

The bisection routine is an incremental search method in which the functions are reevaluated at the midpoint of the interval between the values of the previous guess to determine on which side of the midpoint the root lies. Depending on which side of the midpoint the root lies, the midpoint becomes either the upper or lower bound to the search interval. The interval is again divided in half and the functions are reevaluated at the midpoint. This procedure is repeated until the solution is obtained.

Revised: 01/11/2023