February 4, 2015

Using Period-Based Results in Model Calculations

Posted by Ryan Roper

We've had a number of support inquiries where users need some way of calculating period-based summary data (such as monthly or annual averages or cumulative amounts) for use in other calculations within the same model (e.g. post-processing). GoldSim's reporting periods feature is great for generating this sort of summary data with little effort on the part of the user, but these results are only intended to be viewed and not used for other subsequent calculations. If you do need to use these results for other calculations in the same model, our model library contains a number of examples that illustrate how to calculate such results manually. This blog post briefly describes some of these examples and points you to where you can find them in our library to see them in more detail.

All of the examples mentioned in this post make use of a feature of GoldSim known as array constructors. This is a simple but powerful feature of GoldSim that, once you understand how to use, can make your life a bit easier when implementing fairly complex logic with arrays (i.e. vectors and matrices). Refer to the following simple example for a description of how to use a vector constructor to calculate monthly cumulative amounts from rate data such as volume flow rates: Monthly Cumulative Flows. This is a good model to look at if you’re not already familiar with array constructors. Below is a screenshot from the model showing the calculated cumulative flow of water into a reservoir in the month of June (red dashed line).



More advanced examples of how to calculate period-based results are briefly described below:

Monthly and Annual Totals:  In this example, a scalar input signal is integrated over the simulation duration to generate monthly and annual sums. The results are stored in a matrix in which the rows correspond to years and the columns correspond to months. In this format, it is a simple matter to calculate statistics on the rows or columns using GoldSim's built-in array functions (e.g. meanr(), meanc(), sumr(), etc).

Annual Totals:  This model shows two examples of how a daily signal can be integrated to obtain annual sums stored in a vector or matrix format. In one example, a scalar daily signal is integrated (accumulated) over the simulation period to generate annual sums in a vector format. In the other example, a vector input signal is similarly integrated over this same period to generate annual sums in a matrix format.

Time Series Data Preprocessing:  In this example, a SubModel is used to generate monthly mean precipitation amounts from a Time Series element containing rainfall rate data. The mean values are exported from the SubModel and used as the means in a Stochastic element that generates daily rainfall.

As always, you can learn more by referring to the GoldSim documentation. In GoldSim, go to Help|Help Topics. In the ‘Search’ tab of the GoldSim Help, search for ‘Using Array Constructor Functions’. In the search results, look at the article called ‘Defining Arrays in an Input Field Using Array Constructor Functions’.

No comments:

Post a Comment