Hydrograph Load importer is developed with two aspects. First, to ease the input of hydrograph loads to the manhole and catch basins, and second, to demonstrate how a collection field can be manipulated using WaterObjects.NET.
Importing hydrograph loads via the ModelBuilder, if doable, will be a pain as it will involve multiple steps and heavy formatting of the data source like Excel. With the use if this tool, importing will be little bit simpler. The tool supports two types of data sources, CSV and Excel. The source data structure is illustrated later on the article.
Under the hood there are two major steps. It first reads the data from the source and then stores it to some custom classes and then starts writing the data to the database. The actual entry of hydrograph curve is little bit trickery as it falls in a collection of a collection field.
The actual import process from a UI level is three basic steps, first select the model database file (the swg.mdb file), second, provide the data source like Excel or CSV and then import. When an Excel data source is selected, a new window will appear where we need to specify the data structure used in Excel spreadsheet.
Source Data Structure
I will define the Structure in terms of Excel file as it is commonly used and it allows one to save in CSV format too. The tool basically needs four types of information to bring the hydrograph load data. First, we need to provide the hydrograph curve data. The time field must be in a minute unit and the flow field must be in cubic feet per second. As we know a hydrograph curve needs more than one data set of time and flow. So we will include all the time data in a time column and flow data in a flow column. The tool only gives the A through Z column names.
Then we need to specify the Hydrograph ID column. Since one modeling node (manhole or catch basin) can take multiple hydrograph loads, we need to separate the hydrograph data by its ID. Each hydrograph must have a unique ID in a modeling node which can repeat in an individual curve point. A hydrograph ID used in one modeling node can be reused in another modeling node, as shown in image.
Finally, we need a column with the key label, such as a manhole or catch basin label that the tool will use to create hydrograph loads on. This column will contain the label of either Manhole or a Catch Basin. The label will repeat on every single data row that pertain the hydrograph load to that modeling node.
The data column can be in any order and not required to be in adjacent of a data column as long as it’s in Excel format. However, this is not true for the CSV file format. In CSV file the data should be in first four columns starting with Label, Hydrograph ID, Time and Flow. Column names are not important but the order of the column is.
Using the Tool
Before running (double clicking), make sure the tool is saved in the directory where SewerGEMS is installed. Once the tool is copied over to the installation directory, typically, C:\Program Files (x86)\Bentley\SewerGEMS\, double-click to run it.
Click on the Browse Model button to select and to open a SewerGEMS model. Note SewerGEMS database (.swg.mdb) file can only be selected. Select the model and click Open in the model selection window. If model is valid, the tool will open the SewerGEMS database internally. Second, click on the Browse Data button to select either the CSV file or the Excel file. When a CSV file is selected, the tool will start working on the data when Import Data button is clicked, however, when an Excel file is selected, a new window will show up where one has to provide the Sheet name where the hydrograph loads are and, the columns where data are stored. If everything goes as expected, the progress bar will report the progress of the import.
The progress bar will show the progress of data read from the source file and then the progress of data write into the SewerGEMS database. So, it will display the both read and write progresses.
When import is complete, simply close the Hydrograph Load Importer window and open the SewerGEMS model in SewerGEMS and check the corresponding nodes. The hydrograph loads should be created!
Under the Hood
Besides opening op the hydraulic database, there are two major steps, reading the data into memory and then writing the data into the hydraulic model. Let’s look each of these steps…
Open a SewerGEMS Database
A HydraulicModel class has been created which basically opens or closes a model and provides access to DomainDataSet and DataSource properties. The primary snippet to open a database is as;
m_dataSource = dataSource;
Read Data and Store in Memory
There are three classes created to store the data in memory.
The HydrographItem class basically provides two properties, FlowInCfs and TimeInMin. A new instance of this class is created to store a hydrograph curve point. All the collection of these HydrographItem points is stored in a Hydrograph class which is another simple ICollection inherited class. The Hydrograph class contains a field called Index which basically serves as an ID of a hydrograph. The third and final class, HydrographCollector is also ICollection inherited class which facilitates to store the hydrographs in an IList along with a node label.
Write Data to Hydraulic Model
The heart of the program is in writing the data to database. In the very beginning, a corresponding ID is obtained from the given label by casting the DomainDataSet to IDomainDataSetSerach and then by calling a method called GetDomainElementIDsForLabel and passing the label of the element. From the ID, we get the corresponding DomianElementManager. The FiedName of the Inflow (Wet) Collection field is InflowList. When we get this field, we cast it as IInflowListCollectionField. Now, calling the GetValue and passing the nodeID will give us IInflowListCollectionFieldListManager. The IInflowListCollectionField also provides a function called GetHydrographFieldFor which return IInflowHydrographListCollectionFieldListManager. Now rest is just some work out with these fields.
What If the Tool is Not Working
- Make sure the tool is placed in SewerGEMS installation directory.
- The tool is written against the SewerGEMS SS2 assemblies so make sure you are on SewerGEMS SS2 (08.11.02.75)
- Make sure that the mode database file can be opened (or imported) in SewerGEMS software.
- Make sure the Manhole Label or Catch Basin Label exist in the provided database.
- Make sure the data structure matches as provided in the sample excel spreadsheet.
- Leave comments here