Using Python Dictionary Script in ResSim

This post shows how to use the Python dictionary script created in the 29 April 2016 post within HEC-ResSim.

The model used to show this example is a simple one reservoir model with 1,500 cfs entering the model at its upstream end (CP1).

The top of conservation is at 50 ft.




This model utilizes a scripted rule that is applied to both the Flood Control zone and the Conservation zone.






When you create a scripted rule, the script editor appears.  Your code will be entered after the "# add your code here" comment.

The code looks very similar to the Python script shown in the earlier post.  However, in the earlier post, I showed pool_elev as a constant since it was not connected to the ResSim model.  Now that the script is in the ResSim model, I can access the pool elevation at each time step of the simulation.  It is performed with two lines of code explained in more detail below.  The pool elevation and release are related in the rating dictionary.  So, for instance, a release of 1,000 cfs is related to elevation 50 ft while a release of 1,200 cfs is related to elevation 60 ft.



To get the pool elevation at each time step, I first need to access the pool elevation time series.  This is done by double-clicking "Pool Elev" for the reservoir of interest in the interface found to the left of the code.  





 The following appears in the code after double clicking "Pool Elev".


This is indicating that I want to access the pool elevation time series for "reservoir one".  I then make it an object by assigning that statement to pool_ts (this can be any name that you decide).

 

I then obtain the value at the previous time step of that object.  I prefer to extract the previous value on computed values such as the pool elevation since the current value may not have been computed.



Other than the two lines of code shown above, the code should look very similar to what I developed in the 29 April 2016 posting.  With it already having been tested outside of ResSim, the incorporation into ResSim was relatively easy.

The value of the rule at each time step and the type of rule are then sent to ResSim via the line of code shown below.  It is already present in ResSim when you initially create a scripted rule.  You simply need to indicate if it is a minimum release rule (RULETYPE_MIN), maximum release rule (RULETYPE_MAX), or specified release rule (RULETYPE_SPEC).  Additionally, the value of the rule is also indicated.  For this script, the value of "project_rel" is used as the value of the scripted rule.


The results of the simulation are shown below.  After the lookback period, the release drops to zero since the pool is in the conservation zone and no minimum release is required.  Once it rises into the flood pool (above 50 ft), ResSim wants to release as much as possible, however, the script limits this release.  Since the maximum release is interpolated based on the pool values provided in the dictionary, the release increases with increasing pool elevation.




Comments

  1. Kevin,

    Where can I find more information regarding scripting in ResSim? I have not been able to find any references beyond the ResSim manual (and, now, your blog!) I would like to enter some relatively complex operation rules and I believe scripting may be the only way.

    Thanks!

    Guillermo

    ReplyDelete
  2. Guillermo,

    The references are somewhat scarce for scripting in ResSim. I started by learning Python and using the interface on the left hand side for scripts and state variables. There is also the javadocs which you should be able to find in the directory for the installation of ResSim. As I have time, I plan to put some additional examples demonstrating some of the scripting.

    ReplyDelete
    Replies
    1. Meant to say that I plan to put some additional examples on the blog.

      Delete
  3. Kevin,

    Really appreciate the effort you've been putting up in this blog. I have a question related to scripting in HEC-ResSim. I am intermediate Python user and have been using it for quite a long time now. However, I don't have a lot of experience using HEC-ResSim. I am wondering if it is possible to define reservoirs iteratively HEC-ResSim using scripting? I have multiple scenarios for alternative reservoir locations and dam heights, I was wondering if there is any way to automate this kind of a task using scripting?

    Thank you!

    Abdul Moiz

    ReplyDelete
  4. Abdul,

    I am not sure if that is possible. If it is, it would require scripting that is beyond my capabilities.

    You may already know how to develop your scenarios in ResSim, but I will provide an explanation. If you are looking to add, remove, or change locations of a reservoir, you would develop that as a new configuration in the Watershed Setup. If you are looking to alter the dam height or outlets, you can do that by having multiple reservoir networks since you are altering the physical components. If you are testing alternate operational zones or rules, you do that by developing a new operations set.

    Thanks for the question. It would make for a good post. If you figure out how to script that, feel free to share.

    Kevin

    ReplyDelete
  5. Kevin,
    Thank you for all the information present in your blog. I've have a question and maybe you can help me. I have to run a HEC-RESSIM simulation from command line. I know it's possible to do that, but I can't find information on how to do it. Can you give me any direction on this matter?
    Thank you in advance.

    ReplyDelete
    Replies
    1. Matias,
      Did you find a way to run Hec-ResSim from a command line?

      Thank you in advance,

      Estelle.

      Delete
  6. Pretty article! I found some useful information in your blog....

    so here we provide,

    We provide you with flexible services and complete hybrid network solutions. It can provide your organisation with exceptional data speeds, advanced external security protection, and high-resilience by leveraging the latest SD-WAN and networking technologies to monitor, manage and strengthening your organisation’s existing network devices.

    https://www.quadsel.in/networking/>
    https://twitter.com/quadsel/
    https://www.linkedin.com/company/quadsel-systems-private-limited/
    https://www.facebook.com/quadselsystems/

    #quadsel #network #security #technologies #managedservices #Infrastructure #Networking #OnsiteResources #ServiceDeskSupport #StorageServices #WarrantyAMCServices #datacentersolutions #DataCenterBuild #EWaste #InfraConsolidation #DisasterRecovery #NetworkingServices #ImagingServices #MPS #Consulting #WANOptimisation #enduserservices

    ReplyDelete

Post a Comment