The Rules capability in HEC-RAS unsteady flow modeling is extremely powerful.  This tutorial will walk the user through using the Rules capability within the 2D modeling framework.

Project Files

2D Rules Example.zip

Overview

This example will demonstrate the use of the Rules capability to adjust gate settings for a 2D model that has a tidal boundary condition. The river used for the example has flow going from north to south - an inflow hydrograph is used for the Upstream boundary and a tidal stage boundary for the Downstream boundary condition.  Gates are used to represent the culvert opening under the road crossing (Street) and is modeled using a 2D Connection.  For the simple 2D model shown below, a 2D Flow Area has already been created with the road crossing.

The road crossing is modeled with a 2D Connection with the weir elevation set to the top of road elevation and three sluice gates (5' x 5') used to model the culverts.

The objective of the rule set described below is to hinder the intrusion of brackish water inland. Therefore, for the gates are closed if the downstream water surface elevation is too high and to be open the water surface upstream must be higher than the downstream water level.  The (relatively simple) specific Gate Rules are defined below.

Gate Rules

  • Gates OPEN when the Headwater elevation is greater than Tailwater by 0.7ft for more than 2min
  • Gates CLOSE when the Tailwater elevation is greater than 3.5ft for more than 5min.

Reference Locations can be used in RAS to monitor Headwater and Tailwater water surface elevations.

This example will begin will a running model and take you through the process listed below.

  • Adding Reference Points
  • Entering Rule Operations
  • Visualizing Output
  • Evaluating Results

Getting Started

  1. Open the HEC-RAS project "2DRulesExample"
  2. Open the Unsteady Flow Analysis Dialog
  3. Compute the NoRules plan.  Note that the Tailwater Stage is higher than the headwater on the rising and falling limbs of the flow hydrograph.

Add Reference Points

  1. Open RAS Mapper - you need to add Reference Locations
  2. Zoom into the bridge
  3. Start Editing the geometry
  4. Select the Reference Points layer
    1. Add a Reference Point at the Headwater (HW) of the bridge
    2. Add a Reference Point as the Tailwater (TW) of the bridge
  5. Stop Editing and Save Edits
  6. Close RAS Mapper

Rule Operations for Gates

  1. Open the Unsteady Flow Data dialog
    1. Save the flow data using the File | Save Unsteady Flow Data As... menu item.
    2. Provide a new name for the flow file (Flow - Simple Rules)
  2. Change the Boundary Condition for the Bridge (Street) by clicking on the TS Gate Openings and then clicking on the Rules button.
  3. Choose Yes for the dialog asking if you would like to change the boundary condition.
  4. The Rule Operations dialog will be displayed.
  5. Type in a general narrative the Description field.
  6. Provide base Gate Parameter information for how the gates will operate.  These gates will Open and Close at a rate of 1ft/min and will open to a maximum height of 3ft.  The simulation will begin with the gates closed.
  7. Click on the Enter/Edit Rule Operations button to edit rules
    The Operation available are listed near the bottom of the editor
  8. Press the Comment button to add a comment the rules set.  Comments are helpful to remembering what you have done and to share information to other users.
    After pressing the comment button, a row will be added the Operations list.  Type in your comment in the text box near the bottom of the Editor.


    • New operations are added ABOVE the selected line. 
    • Click the line below to continue.
    • Delete will delete the selected line.
    • Copy/paste can be used to move/duplicate lines.
  9. Set up variables to monitor the simulation values. A summary of variables is provided below.
    Variable NameDescription
    HW_StageStage of Headwater
    TW_StageStage of Tailwater
    TimestepCurrent Timestep
    Time_TW_gt_3.5ft

    Time that the Tailwater is greater than 3.5ft

    Time_HWDiff_gt_0.7ft

    Time that the Headwater - Tailwater is greater than 0.7ft

    DoneVariable to monitor whether we have satisfied a rule (Done=1 is True)
  10. Add the HW_Stage Simulation Variable by pressing the Get Sim Value.
    1. Enter the New Variable name
    2. Select the Reference Points | WS Elevation
    3. Set variable to the Reference Point named HW
  11. Click the next row in the list
  12. Repeat for the TW_Stage
  13. Provide Comments!
  14. Add add the Timestep variable by pressing the Get Sim Value
    1. Set the variable to the Solution | Timestep
  15. Convert the Timestep to seconds using the Math operation - HEC-RAS keeps track of simulation time in HOURS

  16. Add the Time_TW_gt_3.5ft to monitor the Tailwater stage using the New Variable operation
  17. Add the Time_HWDiff_gt_0.7ft to monitor the Headwater/Tailwater difference using the New Variable operation
  18. Provide Comments for the variables
  19. Create the Done Integer variable to keep track of the simulation - to know whether we have set a gate instruction and to stop evaluating the remainder of the rules for the current timestep - and
    1. Set it to 0 using the Math operation
  20. Create the OPEN GATE operation
    1. Create the first part of the rule to see if Done is True

      • Click on the Branch (If/Else) operation
      • Select the If () Then option
        • Set the expression to Done = 0
      • Click the next row
      • Click the Branch (If/Else) operation
        • Select the End If option
    2. Evaluate the Headwater/Tailwater difference and set the time counter accordingly

      • Select the last End If row
      • Click on the Branch (If/Else) operation
        • Set the expression to HW_Stage > TW_Stage + 0.7
      • Click the Math operation
        • Set the expression to Time_HWDiff_gt_0.7ft = Time_HWDiff_gt_0.7ft + Timestep
      • Click the next row
      • Click the Branch (If/Else) operation
        • Select the Else option
      • Click the next row
      • Click the Math operation
        • Set the expression to Time_HWDiff_gt_0.7ft = 0
      • Click the next row
      • Click the Branch (If/Else) operation
        • Select the End If option
    3. Add the Gate Opening rule based on the Headwater Difference time counter previously evaluated

      • Select the last End If row
      • Click on the Branch (If/Else) operation
        • Set the expression to Time_HWDiff_gt_0.7ft > 120
      • Click the Set Operational Parameter operation
        • Set the Gate Group 
        • Set the expression to Gate.Opening = 3
      • Click the next row
      • Click the Math operation
        • Set the expression to Time_TW_gt_3.5ft = 0
      • Click the next row
      • Click the Math operation
        • Set the expression to Done = 1
      • Click the next row
      • Click the Branch (If/Else) operation
        • Select the End If option
  21. Create the CLOSE GATE operation (repeat previous steps but evaluating the Tailwater condition)
  22. Provide Comments in the Rule Operations where needed
  23. Press the Check Rule Set button to evaluate the Rules.  Hopefully, you there are no syntax error.
  24. Press OK on the Operation Rules editor
  25. Save the Unsteady Flow Data

View Output

  1. Go to the Unsteady Flow Analysis dialog
  2. Save the Plan, providing a name (Simple Rules).  Provide a ShortID for the new plan.
  3. Compute the Simple Rules plan
  4. Evaluate the simulation results using the Hydrograph Plot

    Note that the Tailwater no longer gets higher than the headwater
  5. If you turn on Flow, you can see flow mostly "positive" in the downstream direction.  Without the rules there was significant negative flows (flows going upstream based on the high tide).
  6. To see the Gate Operations, choose the Options | Variables menu item
  7. Select the "Group #1 Opening" variable
  8. You can follow along and see how the gates are operating

Evaluate Results

  1. Go to the Unsteady Flow Analysis dialog
  2. Choose the Options | Output Options menu item
  3.  Turn on the Computation Level Output
  4. Re-compute the simulation
  5. Choose the Options | View Computation Log File menu item
  6. Evaluate the Rule Operations.  You can find where the Rules were evaluated by searching the text file for "Rule Set"

    Each line of the Rule Operation is enumerated in the left column.  The result of each evaluation is shown in the next column, follow by the evaluation.  For the timestep evaluated in the figure above, the Gate evaluation resulted in the decision to set the gate opening to 3ft.  The Log File in concert with the Hydrograph Plots allow you visualize how HEC-RAS evaluated the operation during the simulation.


Final Project Files

2D Rules Example Final.zip