Introduction

Global variables are a convenient way of storing information related to the operation of a reservoir system because they are stored in a single location but can be referenced many different times throughout a ResSim model. This page walks through several simple examples of using global variables in a model for Baldhill Dam near Valley City, North Dakota. Only examples of Time Series and Scalar global variables are included, but similar concepts apply to String, Table, and Plugin global variables.

Time Series Global Variable

Operation of Baldhill Dam includes an annual, winter drawdown between October 1st and March 1st each year. If the snow water equivalent (SWE) is greater than 1 inch on March 1st, the reservoir is drawn down further to create flood storage for spring runoff. The drawdown can be modeled in ResSim using a Conservation zone elevation (guide curve) that is a function of Date and SWE. In this case, SWE was input into the model as a Time Series Global Variable. This was done by creating a time series global variable in the Global Variable Editor, as shown below. Since the value of the global variable will be set in the Alternative Editor, the Usage Type was set to Input.

Screenshot showing setup of the Mar1_SWE global variable in the Global Variable Editor

The value of the Mar1_SWE global variable was set in the Alternative Editor. Since the global variable is a time series, it appears on the Time-Series tab of the Alternative Editor. Its value was set by navigating to a local DSS file, just like the other local flow time series used in the model. When extracted to a simulation, the time series will be pulled into the simulation.dss file along with the other time series in the Alternative Editor.

Screenshot showing linking the value of the Mar1_SWE global variable to a timeseries dss record on the Time-Series tab of the Alternative Editor

In the Reservoir Editor, the Conservation Zone at Baldhill Dam was set to be a function of Date and the Mar1_SWE global variable. Four different drawdown scenarios were defined, one for 0 to 1 inch of SWE, one for 1 to 2 inches of SWE, and one for 2 to 3+ inches of SWE. The screenshots below show the Conservation zone elevation function, as well as a plot showing the value of the Mar1_SWE global variable and the computed Conservation zone elevation.

Screenshot showing the Conservation zone elevation function

Plot of the Mar1_SWE global variable and the computed Conservation zone elevation

Since the March 1st SWE total is stored within a global variable, it can also be used to define operating rules. In the example below, the downstream control rule "Valley City Control" was based on the the March 1st SWE value. Higher SWE values allow for higher flows at the downstream location during the months of April and May.

Screenshot showing the seasonal downstream control rule as a function of the Mar1_SWE global variable

Scalar Global Variable

The previous example used a time series for the March 1st SWE total because the SWE needed to vary from year to year. If you only need to store a single value, you can use a Scalar global variable. This is particularly useful when multiple rules, state variables, etc. rely on the same constant, but you want to be able to change the value of that constant in the alternative editor. An example where this might be useful is a spillway study. You've set up a scripted rule to compute the discharge over the spillway, but you want to set up different alternatives that vary the spillway width and sill elevation. Instead of creating multiple networks or operations sets, each with different width and sill elevations hard-coded into the scripted rule, you can create a global variable for the spillway width and a global variable for the sill elevation. If the scripted rules reference the global variables, their values can be changed in the Alternative Editor, and all of the analysis can be done with a single network. The screenshots below show the setup for the scripted rule and two example alternatives, each with different values set for the Spillway_Width and Spillway_Sill on the Global Variables tab of the Alternative Editor.

Screenshot showing how to read the value of a global variable in a scripted rule

The Alternative Editor for an alternative with Spillway_Width set to 30 and Spillway_Sill to 1263

The Alternative Editor for an alternative with Spillway_Width set to 40 and Spillway_Sill to 1263.5