Initialization and Main Tab in State Variables in HEC-ResSim

This post will demonstrate the use of the Initialization tab for state variables in HEC-ResSim.

For state variables, the code that resides in the Main tab is run at each time step.  The code that resides in the Initialization tab is run only at the beginning of the simulation.  For computational efficiency and clean organization of the code, it may be desirable to store constants and functions in the Initialization tab.

To demonstrate this, I developed a simple model consisting of two reservoirs.  There are no rules in the downstream reservoir.  The upstream reservoir has a single rule that is based on the value of the state variable.

Below is the reservoir network.



The image below shows the maximum release rule at the upstream reservoir being dependent on the value of the state variable "upstreammaxrel".




In this example, we use a dictionary to correlate the maximum allowable release with the pool elevation.  For example, a maximum release of 500 cfs is used for pool elevations up to and including 75 feet, a maximum release of 1,500 cfs is used for pools elevation greater than 75 feet and less than or equal to 77 feet, etc.  This code is shown below.  Note that all of the code is entered into the main tab for this example.

 

It may be desirable to move the dictionary values to the Initialization tab.  The coding for the Initialization tab and the Main tab is shown below:

Initialization tab:



Main tab:



Note that sending the dictionary from the Initialization tab to the Main tab is accomplished through the use of the varPut and varGet commands.

The point of this post was to show the use of the initialization and main tab, however, this example also provides us with an opportunity to examine the behavior of HEC-ResSim and the caution that needs to be exercised when developing realistic rules.  The output at the upstream reservoir from this simulation is shown below.  Note that the green line (reservoir outflow) is very bouncy.  This is due to the maximum release being strictly defined at discrete elevations.




Tabulating the result provides a more comprehensive evaluation of the behavior (note that the last three columns in the table below are pool elevation, inflow, and outflow).  In the state variable, we are using the previous value of the pool elevation to determine the maximum release.  On 07Jan2016 at 12:00, the pool elevation is 75.046 ft.  Since the reservoir is in its flood pool, HEC-ResSim releases the maximum of 1,500 cfs (from the state variable computation) to bring the pool elevation down to 75.021 at the next time step.  It again releases 1,500 cfs to bring the pool down to 75.004 ft.  At this time, HEC-ResSim only releases 1,300 cfs to bring the pool down to the top of conservation level of 75.0 feet.  Once at this level, the maximum release becomes 500 cfs for that time step.  Since the inflow is greater than 500 cfs (set to a constant 1,200 cfs), the pool rises back into the flood pool at the next time step and the cycle starts over.



Since HEC-ResSim interprets our commands very literally, the behavior is what should be expected.








Comments