Exercise 5: Setting up and running on
OpenMI system
CE 394K.2
Hydrology
17 April 2007
Prepared by
Jon Goodall (
Table of Contents
Computer
and Data Requirements
DailyStreamflow
Data: A WaterOneFlow component
Water
Balance: A simple water balance model component
Open
the OmiEd application and add the WaterOneFlow linkable component.
Add
the Simple Water Balance Model to OmiEd.
Add
a connection between the WaterOneFlow component and the Water Balance
component.
The goals of this exercise are to 1) introduce students to the OmiEd application, and 2) perform a water balance using OmiEd and WaterOneFlow web services, coupled with a simple water balance model.
For this exercise you will need:
In this exercise, you will use the OmiEd application to link a water balance model with a component that obtains streamflow data from WaterOneFlow web services. You will then execute the composition to perform the simple water balance. In this example, the WaterOneFlow component is not actually a model, but rather a connection to a remote data source. But the water balance model doesn’t care, as long as the WaterOneFlow component is OpenMI compliant.
This component returns a time series of daily streamflow, retrieved from the USGS National Water Information System (NWIS) via CUAHSI’s WaterOneFlow web service. The time series are retrieved for USGS stream gage locations, as defined in a local database file that sits alongside this component. The following files are associated with this component:
The time horizon for this component is for the year 1999, as defined in Catalog.mdb.
This component is a
simple water balance model created by Jon Goodall at
St = (It-∆t
+ Ot-∆t) * ∆t
+ St-∆t
Where:
St = storage for a given watershed at time t (m3)
St-∆t = storage for a given watershed at
time t-∆t (m3)
It-∆t = inflow to a given watershed at time t-∆t (m3/s)
Ot-∆t = outflow from a given watershed at time t-∆t (m3/s)
∆t = 86400 (the number of seconds in a day) (s)
Note that by convention, flows into a
watershed are positive, and flows out of a watershed are negative.
Of course, this model performs a very
simplified water balance. A more proper
water balance model would also take into account evaporation, precipitation,
and groundwater fluxes.
The following files are associated with this component:
The time horizon for this model is for the year 1999, as defined in model_parameters.txt.
For this composition, you will use the DailyStreamflow Data component to provide the inflows and outflows to a watershed in the Water Balance component. The inflow occurs at a stream gage at the upstream end of a watershed, while the outflow occurs at the outlet of a watershed. With inflow and outflow determined, the Water Balance component can then compute storage for a watershed.
Download data for the exercise at http://www.ce.utexas.edu/prof/maidment/GradHydro2007/Ex5/Ex5.zip. Unzip the OpenMI_ExFiles folder and save the folder to your computer in a location such as c:\temp\. The location does not matter, as long as you have write access to the folder.
Note that it’s
best to save the files to your computer locally. If you try to run the models from a remote
location such as a server, you may encounter errors when trying to access the
component which uses web services.
OmiEd is an application used to build and run OpenMI compositions by linking together OpenMI compliant models or components.
Open the OmiEd application by clicking Start à All Programs à OpenMI 1.2.0 à OmiEd.
Next you will add the WaterOneFlow model to OmiEd.
Click Composition à Add Model.
Browse to the NWISDV.omi file and open it (this file is in the OpenMI_ExFiles folder.) An omi file is a text file that contains the information needed to locate a given OpenMI compliant model on disk, as well as other parameters or data files required by the model.
The tool appears with the name “DailyStreamflow Data”. This OpenMI linkable component is designed to retrieve daily streamflow values from NWIS and then provide the data for a given time step when a GetValues request is made to the component. Because this component is OpenMI compliant, OmiEd can add it to the composition. Otherwise, OmiEd would have alerted you that this is not an OpenMI compliant component.
View the properties of the component by right clicking on the yellow rectangle and choosing Model properties…. This opens the Model properties window. In the Output Exchange Items list, click the plus sign to expand the output exchange items, and then browse through the various items.
From this dialog we see the list of time series that can be obtained from WaterOneFlow. These are defined as output exchange items, and include the elements at which the time series apply, which are stream gages in this case. Also included is information about the quantity measured (daily streamflow in this case), such as units of measure for the quantity. These time series are documented in the local database file Catalog.mdb, included in the OpenMI_ExFiles folder. If a study required different time series from WaterOneFlow, changing this local database file to store the metadata for the additional stations will allow those additional stations to appear as Output Exchange Items within OpenMI.
Close the Model properties window.
Click Composition à Add Model.
Browse to the WaterBalanceModel.omi file and open it (this file is in the OpenMI_ExFiles folder.) The water balance model appears with the name “Water Balance”.
View the properties of the Water Balance model component (Right-click on component and then click Model properties…).
From this dialog we see that the water balance component can accept input exchange items of InFlow and OutFlow, and provides Storage as an output exchange item.
We will use the DailyStreamflow Data component to provide the input data to the Water Balance component.
Click Composition à Add Connection.
Left-click on the DailyStreamflow Data component and then left-click on the Water Balance component. You should then see a blue line linking the two components with the arrow pointing from DailyStreamflow Data (the data source) to the Water Balance component.
Here we are telling OmiEd that the Water Balance component is dependent on input values from DailyStreamflow Data.
Now you need to edit the properties of the connection that you just created.
Right-click on the connection (it’s best to click on the triangle in the middle of the connection) and then click Connection properties…. This opens the Connection properties window.
From the output exchange item list, choose the Trent River near Trenton, NC as the inflow for watershed 2, and click Apply. This adds a link between an output exchange item from the DailyStreamflow Data component and an input exchange item from the Water Balance component. Repeat the procedure to create another link for the Trent River at Pollocksville, NC as outflow for watershed 2. We have now defined the surface water that goes in and comes out of a given watershed. From this, the water balance model can compute the storage in the watershed.
It is also possible to see the geometries for the watershed and a gage location by highlighting one of the link items and clicking ElementSet viewer. The vertices for the watershed are stored in a text file named watershed.txt located in the OpenMI_ExFiles folder.
In the viewer, you see the boundary of the watershed, and a red dot indicating the location of the streamflow gage at the outlet of the watershed.
Close the ElementSetViewer and the Connection properties dialog.
A trigger is used to initiate calculations and tell the model which quantities should be calculated.
Click Composition à Add Trigger.
Click Composition à Add Connection.
Left-click on the Water Balance component and then left-click on the Trigger component.
Right-click on the connection from the Water Balance model to the Trigger and click Connection properties….
Under Output Exchange Items, click watershed 2 and under Input Exchange Items choose TriggerElementID. Click Apply and then Close.
You’ve just told OpenMI what it should calculate. The model will run until the trigger value (storage for watershed 2) is known. Because the trigger is requesting to know the storage, the Water Balance component will be called. Because the Water Balance component needs inflows and outflows, the DailyStreamflow Data component will be called. Thus, by triggering computation of the most downstream model component, all components in the chain will be called.
Ok, it’s almost time to run the model. But first…SAVE THE MODEL (click File à Save.) Give the model the name of your choosing.
Click Composition à Run. This opens the Run properties dialog.
Choose the message you’d like to view as the model runs. For this exercise, click Set all. Next click the Latest overlapping button to make the model run for the latest time that overlaps both components in the model, and then click Run. The water balance model runs at a daily time step, which is the same time step as the daily streamflow values.
When the model runs, the trigger tells the model that it needs to know the storage for Watershed 2 at 12/31/1999 12:00:00 AM. Each component then communicates which data items are needed in order to compute the storage at that time. In this simple example, the components basically say, “To calculate the storage you requested, I need to begin by computing storage from 1/1/1999 12:00:00 AM.” This is how the composition knows over what time period to run, which is basically for the year 1999 in this case.
As the model runs, you will see the simulation progress and a record of the events that occurred, based on the events that you checked earlier. First, the model will download the daily streamflow values from NWIS that are required for the model run. Then the model will perform each time step to compute storage in the watershed. Note that the download of streamflow occurs before the main model loop, and so the simulation progress may appear to be frozen until the data download is complete.
Close the messages dialog and you’ll get a warning like what’s shown below. Choosing Yes will allow you to run the model again, choosing no will let you view the results. Choose no this time so we can see the results file.
Open and view the results files in the OpenMI_ExFiles folder.
Note: If you decide to run the model again, make sure you delete these
text files before running the model.
You have just created a simple simulation model that gains access to the
federal archival of streamflow through the WaterOneFlow system. Because we used OpenMI as the mediator
between the data source and the model, it is easier to separate these two components
and use them as part of other models.
This modularity is the advantage of OpenMI.
There are a number of ways that you can see if the model is computing its results correctly. One way is to set up a spreadsheet that includes the inflow, outflow, and storage results from the text files mentioned above, as well as streamflow data obtained independently from the model. You can then compare the model’s inflows and outflows to the streamflow data to see if the numbers match up. You can also compute storage from the independently obtained streamflow data, and see if it matches storage as computed by the model.
In Exercise 1 of this class, you learned how to obtain daily streamflow data using NWIS Analyst. Review that exercise if you need help obtaining streamflows. The site codes for the gages used in this exercise are:
Please turn in the following items:
(1) A graph of storage in watershed 2 vs. time.
(2) Do the numbers for storage make sense to
you? Explain why or why not. What other components could be added to this
model composition in order to compute a more accurate water balance?
(3) Verify the results of the model by computing
the storage in a spreadsheet, as described in the Verify results section
above. Submit the results of the
verification in a manner that you deem appropriate. Hint:
A spreadsheet called verify_results.xls is included in the zip file for
this exercise. That spreadsheet can help
you get started with your verification.
This concludes the exercise.