Pages

Showing posts with label Speed. Show all posts
Showing posts with label Speed. Show all posts

Monday, May 14, 2018

Closing the wormhole with the new features in HEC-RAS 5.0.4!

Written by Krey Price  |  Surface Water Solutions
Copyright © The RAS Solution 2018.  All rights reserved





The Great Hobbiton Flood


For those who have used wormhole culverts or mega-cell culverts in previous versions of HEC-RAS, you'll be relieved to hear that they have officially been retired with the May 2 release of the new Version 5.0.4.


It sounds like the new features are already getting lots of use, and online and face-to-face training courses are popping up all over the world. Given the surge in interest, we thought we'd post a quick overview of the new features and compare some model results between versions. We've found, for example, that the new coordinate-based culvert features in Version 5.0.4 give identical results to wormhole culverts in Version 5.0.3, with both methods drawing flow from the 2D cells that cover the actual inlet location:




[Left-click to play, then right-click on the video to loop the particle tracing - a handy trick to keep file sizes small while providing a continuous animation in a presentation!]


This article highlights the new culvert capabilities along with the following features, each of which is also covered in an accompanying instructional video here:
  • Culverts. We’ll see how the new culvert editor gets rid of the need for wormhole culverts (RIP!) by allowing the inlet and outlet of each barrel to be defined by its own set of coordinates.
  • Mesh Polygons. We’ll then add a “Refinement Region” to a 2D Flow Area using the new RAS Mapper tool that allows you to assign customized computational grid spacing with polygon features.
  • Internal Boundary Conditions. Next we’ll add inflow hydrographs inside of the 2D Flow Area as internal boundary conditions.
  • Adjustable Time Steps. We’ll set Courant Number criteria to allow variable time steps to be selected based on computed velocities.
  • Rating Curves. We’ll then run the model and generate rating curves in a single step (rather than having to extract flow and stage time series hydrographs separately and combine them in Excel).
  • Speed Enhancements. Finally we’ll compare run times to see how the speed improvements stack up.
This demonstration model uses terrain data covering the Hobbit movie set in New Zealand. You can download the terrain for free if you want to follow along (instructions for setting up the project with saved views and static aerial imagery are available here.)

Culverts
If a HEC-RAS model contained wormhole culverts in Version 5.0.3, they will be ignored when the project is opened in Version 5.0.4, so we’ll need to convert any wormhole culverts to “coordi-culverts”, with coordinates assigned to each barrel’s inlet and outlet either manually or with a great new feature to import culvert centerlines from a shape file:

Here’s the schematic plan view for four culvert methods available in Version 5.0.4, with the new “coordivert” in our demonstration model shown in the canal on the far right:
A description of each method is included here. (A fifth method, entering the bridge piers or culvert walls as 2D terrain only, wasn't included here since it is only appropriate for open channel flow.)

Mesh Polygons
To take advantage of the new capability to define a finer mesh within a polygon, we'll use a "Refinement Region" in RAS Mapper. After delineating a polygon under the refinement regions layer, the next step is to right-click on the shape and select “Edit Refinement Region Properties” and enter a cell spacing (in this case 1 meter by 1 meter):
With the higher resolution area defined, if you zoom in on the refinement region, you’ll see a more detailed computational mesh inside the 2D Flow Area:
In this case, I've defined a tighter mesh spacing around the roadway and culvert and left a lower-resolution mesh in the open channel areas. This feature can save a substantial amount of computation time and prevents the need to create multiple 2D areas to reflect varying resolution requirements – or the menial task of creating an excessive number of snaking breaklines with red-dot errors that need fixing!
Internal Boundary Conditions
In Version 5.0.4, BC lines can now be entered as internal boundary conditions inside the 2D Flow Area. Keep in mind that flow will be able to travel in both directions from an internal BC Line, and any BC line in 5.0.3 that crossed the external boundary of the 2D Flow Area will need to be edited to be either all in or all out. At this point flow can only be positive (can’t subtract flow to represent infiltration or a stormwater pit) but with Version 5.0.4 there isn’t any need to use the wormhole culvert hack to move flow around your 2D area anymore. To test it out, we’ve moved the BC lines inside of the upstream boundary, and the model behaved just fine:

Adjustable Time Step
The window with the new option to use the Courant Number criterion is shown below. With the adjusted time step selected, the model will increase or decrease the computational time step automatically based on the computed velocity. This can give you significant speed improvements if you were already conservative with your time step. If you had an unstable model, however, the use of this feature will slow it down as it slices the time step to stabilize it. In this case, our 0.5-second time step can be doubled four times or halved four times, giving it a potential range from 0.03 to 8 seconds:

Rating Curves
One last feature we’ll illustrate is the ability to plot rating curves directly along any saved profile line with a single command. Just right-click on your saved profile line name and select “Rating Curve” as a new option under Time Series (but watch out for the potential pitfalls mentioned in the article here!). Here’s where to find the rating curve function in RAS Mapper:

Speed Comparison
Using the same grid size and time step, this particular model runs twice as fast in 5.0.4 as it did in Version 5.0.3. Taking advantage of the refinement areas and variable time steps, it runs even faster - in less than a quarter of the 5.0.3 time without any significant loss of accuracy. We’ve seen similar speed enhancements with our other models as well.
Comparing results
In this particular demonstration model, the water surface elevation profile results in 5.0.4 look nearly identical to the results from 5.0.3. Here is the particle tracing with the coordi-culvert in 5.0.4 shown at the right-hand side of the image. This one matches the particle tracing in Version 5.0.3 using a wormhole culvert in place of the coordi-vert:
Here are the water surface profiles comparing the coordi-culvert to the wormhole culvert for open channel flow, pressure flow, and overtopping flow conditions:
As you can see, in the vicinity of the culvert, the results are effectively identical for all three flow conditions, which brings us to the bottom line: the wormhole has closed with the release of Version 5.0.4, and wormhole culverts have officially been retired – not just for long culverts, but for internal boundary conditions as well. Mega-cell culverts have also become obsolete now. From what we’ve seen so far, the new culverts provide equivalent results with much more functionality - particularly the fact that they work perfectly fine with the roadway/bridge deck represented as terrain or removed from the terrain and replaced with a weir embankment - so good riddance to both the worms and the Cells Of Unusual Size!
And finally just for fun, let’s ramp up the flow and see if an Orc-dam can flood out Hobbiton; if you want to see how the Hobbits fare in the flood, further details, animations, and comparisons of the new features are available here, or feel free to follow along with the instructional videos covering each of these new features separately.


In this case, our particle tracing shows that this one may catch Frodo in a whirlpool - and suck him right through the Orc-pipe that we can now move anywhere in our model thanks to the new coordiverts in Version 5.0.4!
[Again, right-click to loop]


We'd love to have you join us in an upcoming comprehensive training course, but in the meantime, we hope this has been a helpful overview of some of the new features in 5.0.4! We look forward to hearing how you are using the new features in your own projects.
Krey Price
Surface Water Solutions

Friday, August 5, 2016

Optimizing Your Computer for Fast HEC-RAS Modeling

Written by Christopher Goodell, P.E., D.WRE
and Gary Brunner, P.E., D.WRE  |  Hydrologic Engineering Center
Copyright © The RAS Solution 2016.  All rights reserved. 

Now that 2D modeling is becoming widespread in the HEC-RAS community, a lot of HEC-RAS users are wanting to know what kind of computer to build to maximize computation speed when running those large 2D datasets.  I had an opportunity to interview Gary Brunner about this and he had some valuable insight I’d like to pass along.


Before moving into suggestions for 2D modeling, let me first state that in 1D modeling, multiple processing cores are NOT used.  If you plan to only do 1D modeling, having extra cores will not help you with speed.  In this case, the processor speed is everything.  So get the fastest processor you can (e.g. 3.4 Ghz or higher).

For the rest of this post, I’ll assume you want to optimize your computer for 2D HEC-RAS modeling, since those are the models that typically will take longest to run.
  •  More processing cores is not always better.  In fact, it has been found that for smaller 2D areas (e.g. less than 10,000 cells or so), 8 cores may indeed run slower than 4 or 6 cores.  The reason behind this is that there is a level of computing overhead used just to transfer data between cores.  Fortunately, HEC-RAS has an option to change the number of cores you wish to use in the Computation Options and Tolerances window (from the unsteady flow analysis window…Options…Calculation Options and Tolerances…2D Flow Options tab).  For smaller datasets, I suggest experimenting with this to optimize computation speed.  “All Available” may not necessarily be the fastest.  But for large numbers of cells, you’re going to want as many cores as you can get your hands on.  Get as many cores as you can afford, but not at the expense of processor speed.  Try to get at least 3.2 to 3.4 Ghz or higher processors, no matter how many cores you get.
  • Processor speed is still paramount.  Do NOT think you will have fast HEC-RAS model run times just because you have a computer with 16 processing cores or more.  If all of your cores have slow processor speeds, you’ll get some benefit out of the number of cores, but you will be disappointed in the overall speed for a wide range of model types (1D/2D) and sizes.  So make sure even if you get a large number of cores, you are not doing so at the expense of fast processor clock speeds.  Again, 3.2 to 3.4 GHz or higher is a good clock speed for fast running models. 
  • Your hard drive is important.  Especially if you are producing a lot of output.   Small detailed output intervals, small mapping output intervals, writing computation level output, etc.  All of these settings affect how much and how often output is written to the hard drive during run time.  Solid state hard drives (SSD) are typically going to be better than the traditional spinning hard drive (HDD).
  • RAM is important, but not as much as you might think.  While RAM is definitely important, it is not as important for 2D modeling as number of cores and processor speed.  You do want enough RAM to run your operating system and have your entire HEC-RAS model in memory, without the operating system having to swap things in and out of memory.  That being said, if you plan to do multiple HEC-RAS models at the same time, or you have a habit of keeping lots of programs open and running in the background of your computer, you may want to get a computer with a lot of RAM.    I would venture to guess that if you are buying a computer with a lot of cores with fast clock speeds, your computer will have enough RAM.  But RAM is cheap, so you might as well load up on it while you’re building the HEC-RAS computer of your dreams. 
  • Graphics card does not matter.  While some of your other programs run best on a super-charged graphics card, HEC-RAS does not.  For HEC-RAS modeling, don’t waste your money on an expensive graphics card.  However, you may seem some noticeable improvement in the snappiness of image rendering or particle tracing with a better graphics card.  If money is no object, get a top-of-the-line graphics card, but this is one area you can sacrifice if you need to save some dough. 
To sum up, my recommendation for building a computer to optimize 2D runs in HEC-RAS is as follows:
  • Get as many processing cores as you can, but do not do so in expense of processor speed. 
  • Make sure your computer has processors that are 3.2 to 3.4 Ghz or even higher (the faster the better).  
  • Get an SSD hard drive
  • Max out your RAM.  
Pretty simple really.  And by the way, 24-inch (or larger) dual monitors really helps with viewing all those HEC-RAS windows you have open.  But if you have the means, why stop at two monitors?  


Starting on page 4-11 in the HEC-RAS 2D Manual, there is an interesting discussion on the effect of number of processing cores in computations.  I suggest giving it a read.  There will be a new chapter in the RAS 2D manual due out soon (for version 5.0.2) that will discuss this topic.  

Mr. Brunner has some follow-up advice when buying a computer that has an Intel chip that uses Hyper-threading:

"Hyper-threading is an Intel technology that attempts to keep CPU resources as busy as possible.  Each real CPU core has what appears to be two cores.  However, there is really only one true core.  For example, the typical Intel I7 chip has four real CPU cores, but if you open Task Manager and go to the Performance Tab, you will see four across the top, and what appears to be four more below it.  These are virtual cores.  Each real CPU core has only one true math processing unit, but with Hyper-threading it has two instruction feeders.  Hyper-threading tries to eliminate stalls by always having another thread at the ready in a second virtual core.  If one thread stalls (not requiring the math unit) on virtual core A, virtual core B will instantly start picking up the slack, so the execution units keep working at 100%.

The RAS 2D compute engine is extremely math heavy.  So for each core it utilizes, it is almost always using 100% of the math unit.  So the second virtual core (Hyper-thread) is never used.   So back to our Intel I7 chip example.  An Intel I7 has 4 real cores, but appears to have 8 cores (4 virtual cores).  RAS will only use the four real cores, and it will keep them almost 100% busy.  However, Task Manager reports this as only 50% utilization of the CPU.  However, this is truly 100% utilization of the four real cores math units."

What has been your experience with running fast HEC-RAS simulations on your computer?  Please leave a comment and share with us what you’ve learned about how your computer performs.  In fact, if you have a good picture of your suped up machine running HEC-RAS, please share!