skip to main content
Rulebased Simulation
Max Outflow
Rulebased Simulation may now access the Max Outflow functions of Reservoir Objects used in Simulation. Three new functions have been added to Reservoirs which can be called from within Rulebased Simulation. These functions initialize a local data structure with current Reservoir data required for the Max Outflow calculations. The new functions are:
• C_getMaxOutflowGivenInflow reservoir inflow inflowScale
• inflowUnits poolSeed
• poolSeedScale poolSeedUnits
• outflowReturnScale
• outflowReturnUnits
The getMaxOutflowGivenInflow function takes the values for the Inflow, and an optional Pool Elevation seed value, and stores this information in a LocalInfo data structure. LocalInfo is then passed into the given Reservoir’s Simulation function, getMaxOutGivenIn, where the calculations for Max Outflow are actually performed. C_getMaxOutflowGivenInflow returns this Maximum Outflow value in the specified units and scale.
• C_getMaxOutflowGivenStorage reservoir stor storScale storUnits outflowReturnScale outflowReturnUnits
The getMaxOutflowGivenStorage function takes the value for the Storage, computes a corresponding Pool Elevation, and stores this information in a LocalInfo data structure. LocalInfo is then passed into the given Reservoir’s Simulation function, getMaxOutGivenStorage for SlopePowerReservoirs or getMaxOutGivenStorHW for all other Reservoirs, where the calculations for Max Outflow are actually performed. C_getMaxOutflowGivenStorage returns this Maximum Outflow value in the specified units and scale.
• C_getMaxOutflowGivenHW reservoir pool poolScale
• poolUnits outflowReturnScale
• outflowReturnUnits
The getMaxOutflowGivenHW function takes the value for the Pool Elevation, computes a corresponding Storage, and stores this information in a LocalInfo data structure. LocalInfo is then passed into the given Reservoir’s Simulation function, getMaxOutGivenHW for SlopePowerReservoirs or getMaxOutGivenStorHW for all other Reservoirs, where the calculations for Max Outflow are actually performed. C_getMaxOutflowGivenHW returns this Maximum Outflow value in the specified units and scale.
Precedence of Slots Directly Set by a Rule
Slots which are directly set by a rule are now marked by an R flag in the Edit Slot dialog. These slots are now given preference within a priority level when determining the dispatch method with which an Object will redispatch. The Rulebased Simulation Controller adds slots to the known set in the groups shown below. Slots are added to the known set one group at a time until the known set exactly matches one of the Object’s dispatch conditions. Slots are considered for dispatching in the following order:
1. All slots flagged as user Inputs (Priority 0).
2. All slots which were set by default in TIMESTEPBEGINRUN and TIMESTEPBEGINTIMESTEP (Priority -1).
3. For each rule priority, in descending order:
– If any known slots of the given priority contain the R flag, only those slots are added.
– If no slots contain the R flag, however, all known slots of the given priority are added.
4. For each rule priority, in descending order:
– Any known slots of the given priority which were not added in step 3 are added.
For example, the following list of known slots and priority levels would be added to the known set and checked against the Object’s dispatching criteria, in the sequence on the following page.
 
Slot
Priority
Hydrologic Inflow
-1
Inflow
1
Outflow
1R
Pool Elevation
2R
Diversion
2R
Return Flow
3
1. No slots are user Input, so none are added to the known set.
2. Hydrologic Inflow was set in TIMESTEPBEGINRUN; add it to the known set.
– Priority Level 1: Both Inflow and Outflow are known, but Outflow contains an R flag; add it to the known set.
– Priority Level 2: Both Pool Elevation and Diversion are known with R flags; add them both to the known set.
– Priority Level 3: Return Flow is known without any R flags; add it to the known set.
Note:  At this point, the known set contains slots which exactly match the required conditions of a dispatch method. The Object would be placed on the queue for this dispatch method, and no further slots would be added to the known set. If, for the sake of example, this dispatch method did not exist, the next known slot would be added to the set as follows:
– Priority Level 1: Inflow was not set in Step 3) due to an R flag on another slot; add it to the known set now.
– Priority Level 2: All known slots were already added in Step 3).
– Priority Level 3: All known slots were already added in Step 3).
The resulting known set would then be:
 
Known Set
Hydrologic Inflow
Outflow
Pool Elevation
Diversion
Return Flow
Inflow
In this scenario, the Object would redispatch with the solveMB_givenOutflowHW dispatch method, whose known slots are: Outflow, Pool Elevation, Hydrologic Inflow, Diversion, and Return Flow.
Overwriting Higher Priority Slots
Slot values computed during a lower priority redispatch will now overwrite any higher priority values already in the slots. This places the burden of enforcing rule priorities on the proper selection of which dispatch method to use. When an Object redispatches, any computed slot value will be set, regardless of the relative priority of the slot and the current dispatch. This change allows solution-independent parameters such as Tailwater Base Value to force a redispatch of Objects regardless of the priority of the last value.
Revised: 08/02/2021