Tutorial 5                 

Data Input & Output

Problem Statement

You are interested in testing your plant under more dynamic or stressful conditions such as varying input water flowrate.  Unfortunately, you do not have access to real data.  Therefore, you will generate a simulated flowrate loading data to your plant and then input this data as a driving function for the model.  You will investigate the effect of step feed during these conditions.

Interactive controllers provide an easy-to-use method for exploring the dynamic response of the model.  However, in most modeling projects, it is desirable if not essential to input real forcing functions to examine how the model behaves under real conditions.  The forcing functions can be flows or influent concentrations, or any other model parameter, but are always in the form of time dynamic data; that is, variable values over time.  A typical set of time dynamic data would be the influent flow rate to the plant over a period of time. GPS-X facilitates the input of this data so that the model will be tested against real conditions.

Objectives

This chapter covers two important and useful features of GPS-X:

·         Using a data file as an input to control simulations

·         Using a data file as outputs to calibrate your model

Setting Up Dynamic Input

1.       Openthe layout built in Tutorial 4 and save it as ‘tutorial-5’ using File > Save As...

 

2.       Switch to Simulation Mode if not already there.

 

3.       Create Input Controls. More information regarding input controls is presented inTutorial 2. Right-click on the River Water Influent and select Composition > Influent Characterization to bring up the Influent Advisor tool.

The Influent Advisor will take up most, if not all, of the room on the main window.  Click the little right arrow (see Figure 5‑1) between the “User Inputs” column and “State Variables” column to shrink the window and hide everything except the “User Inputs” column.

image

Figure 51- Shrink Influent Advisor

Now that you have room, drag the pH (see Figure 5‑2) item to the blank area to the right of the existing input control tabs. By dropping it there a new tab will automatically be generated with the new input control automatically created.

 

image

Figure 52- Dragging Variable to New Input Tab

On the same tab, create an input controller for Carbonic Acid found under the Weak Acid & Bases subheading.

 

Create an input Control for the Influent Flow by going to Flow > Flow Data. Note this is a duplicate of a controller on the Flow Controls input controller tab. GPS-X will only allow you to have one input controller for an input variable so adding influent flow to this input tab will remove it from the Flow Control input tab.

 

Rename the tab ‘Influent Control’.

 

image

Figure 53- New Input Controls

The next step is setting up the data in files to be read by GPS-X during a simulation.  There are two different ways that data files can be prepared for the file input controllers:

 

 

 

A.     Manually preparing spreadsheets outside of GPS-X (best used for preparing data for multiple variables) and adding the data file to the layout in Scenario > Configuration.

 

or

 

B.      Using the Data File… tool in the GPS-X to automatically prepare the file (best used for preparing data for a single variable).

 

This tutorial uses both methods to illustrate their use.

Method A: Manually Preparing a Spreadsheet Input File

image

4.       To open the Data File Organizer window, press the Data File button on the main toolbar in GPS-X

5.       Press the New button to open the Data File Creation Wizard.

 

6.       Ensure Input Variable is selected in the ‘Input or Output’ pane of the New Data File Creation Wizard. Press Next.

 

A screenshot of a social media post  Description automatically generated

Figure 54- Data File Creation Wizard

7.       Select the Variables. Every variable on an input control tab will be available to select from for addition to the data file in the New Data File Creation Wizard.

 

From the Influent Control heading, select [winf] pH, [winf] carbonic acid and [winf] influent flow. Press Next.

 

image

Figure 55- Input Variable Selection

8.       Save the File. By default, GPS-X will save the excel sheet in the active directory with the same name as the layout. Press Finish.

 

image

Figure 56- Save New Data File

9.       Open the file. You will be prompted to open the new file after saving it. Press Yes

 

A picture containing screenshot  Description automatically generated

Figure 57- Input Data File Generated by GPS-X

We have created a version of this data file that has already been populated with data to use for this portion of the tutorial.  Locate and open the tutorial-5-example-data.xls spreadsheet file in the following subdirectory of the GPS-X installation:

\layouts\08tutorials\

 

Save a copy of the file in the current working directory.

 

A screenshot of a cell phone  Description automatically generated

Figure 58  - Contents of "tutorial-5-exampledata.xls"

We will use the data found in this file as our dynamic dataset.  It is a typical set of influent input data that you might use to simulate a change in influent conditions over time.

 

The first column is labeled “t” for time and is in the unit of days “d”.

 

The remaining columns contain data for each of the parameters being read from the file.  The names at the head of each column are the “cryptic variable name” (which is the internal “short form” variable name used within GPS-X calculations) for each variable.  These names are specific to the layout you have created and are different for each variable and object within the layout. The units of the data reported in the column are then specified in the row after the cryptic name. The units can be different than the units used by the input controller, as long as the units are recognized by GPS-X. All of the units recognized for a given input variable can be viewed by opening the unit drop down menu next to the variable in the input control properties window.

A screenshot of a social media post  Description automatically generated

Figure 59- Available Influent Flow Units

Note that if any data was missing from the data file presented inFigure 5‑8, a question mark (?) can be entered in the cell corresponding to the missing data point and GPS-X will continue to use the last value assigned to that variable.

10.   Verify that the cryptic names in the data file are the same as the variables for the input controllers.  The simplest way to do this is to look at the tooltip that pops up when you hover the mouse cursor over the controller’s label as shown in Figure 5‑10.

 

image

Figure 510- Viewing the Cryptic Name via Tooltip

The cryptic variable names for the three variables used in this tutorial are:

phconwinf pH

sticwinf Carbonic Acid

qconwinf Influent Flow

If the variables you are interested in are not currently on an input controller, you can quickly find the cryptic variable name by using the GPS-X find functionality. You can access the find function by going to Edit > Find on the main tool bar or using CTRL-F.

This will open the Find pop-up window. In the ‘Find Input/Output Variable’ pane of the find window there is an input box with a toggle for Keyword and Cryptic beneath it.

If you need to find a cryptic variable name and you know part of its plain English variable name, type it in the entry field, for example ‘carbonic acid’. Ensure the keyword option is selected and press find. This will find and display every variable in the layout that contains the keywords ‘carbonic acid’. The matching variables will be grouped by the object they are associated with. The stream associated with the variable will be given in square brackets in front of the variable name.

 

image

Figure 511- Finding all Instances of Carbonic Acid in the Model

If a variable is related to a stream number/name that you do not recognize, use the “Select label to highlight the process” drop down menu in the “Find Stream Label” pane to select the stream. This will highlight the object that the stream initiates from on the layout. For example, selecting the “of” stream from the drop-down menu will highlight the Neutralization Tank because the Neutralization tank’s overflow stream was labelled “of”.

 Diagram  Description automatically generated

Figure 512- Using the Find Stream Label Functionality to Identify Where the “of” Stream Originates

image

 

After identifying the variable of interest under the River Water > Input Variables headings you can click on the Go to location button to the right of the variable to be taken to the window where this variable is defined. Hovering the cursor over the variable name will cause a tooltip containing the cryptic variable name to appear.

 

Alternatively, if you are given a cryptic variable name by a GPS-X output, the corresponding plain English variable name can be identified using the find functionality. For example, after opening the find window, select the cryptic option and enter the cryptic variable name sticwinf in the find field. Pressing the Find button will present you with input and output variables, which have a cryptic variable name containing sticwinf.

11.   Access the Configuration/Data Files window.  Click on the Scenario menu on the Simulation Toolbar and select Scenario > Configuration/Data Files…

  

image

Figure 513- Accessing Scenario > Configuration/ Data Files…

Access the list of current data files.  The configuration window will show all the scenarios available (in this case the Base Model and Surge Flow scenarios should be available). Data files can be added to a specific scenario if desired by selecting it before pressing the Data Files button.  Make sure Base Model is selected and press the Data Files button.

 

image

Figure 514- Scenario Configuration Showing Data Files Button

12.   Remove the empty data file.  The Data Files window shows all the files that this scenario is currently using.  At this point, only the unpopulated file made by the New Data File Wizard will be available.  Remove this file by clicking on it and pressing the Remove button.

 

13.   Add the populated data file.  To add the Excel file prepared above, press the Add button and browse to the appropriate location and select the “tutorial-5-example-data.xls” file.

 

image

Figure 515– Adding a File to a Scenario

14.   Accept the changes and close the Scenario Configuration window. Notice that the interactive slider for the inputs have automatically changed to file input controls that cannot be directly edited.  The values are now being read in from the file.

 

A screenshot of a cell phone  Description automatically generated

Figure 516- Controllers Changed to File Input

15.   Create A New Graph Tab. Press the New Graph tab button on the Outputs toolbar to create a new graph tab.

 

16.   Create New Output Graphs. Create the following Output Graphs on the new Output Tab:

·         Right click on the Treated Water object and select Output Variables > Water Chemistry Variables. Drag the Total Alkalinity variable, found under the Alkalinity subheading to the new graph tab.

·         Right click on the Treated Water object and select Output Variables > Water Chemistry Variables. Drag the Carbonate Hardness variable, found under the Hardness subheading to the new graph tab.

Give each of these output plots an appropriate title. Set the maximum y-axis values to 250.0 mgCaCO3/L and 200.0 mgCaCO3/L for the Total Alkalinity and Carbonate Hardness graphs, respectively.

Rename the output tab “Alkalinity and Hardness”.

17.   Run a 6-day simulation with Steady-State clicked ON. As the simulation proceeds, the values of the influent flow, pH and Carbonic Acid concentration will change in the input controller. The model responds dynamically to the changing input, as shown by the increasing effluent pH.

image

Figure 517- Results of the Data Driven Simulation

Method B: Using the GPS-X Data File Tool

The above methodology is useful for simulations where data for many parameters are being read in simultaneously, and it is easy to assemble that data externally in a spreadsheet. 

There is another option that is useful for simple simulations where just one or two parameters are being read from a file, and you want to input those values directly into GPS-X.  For this situation, you can use the GPS-X Data File Tool.

18.   Create a new Input Control. Right-click on the River Water object and select Composition > Influent Characterization. Drag soluble calcium variable found under the Strong Anion & Cation subheading to a new input tab (i.e. drop it in a blank area beside the Influent Control tab’s label).

 

19.   Rename the tab to “Influent Calcium”.

 

20.   Access the data file tool for the input. Right-click on the input control label, “[winf] soluble calcium”, and select the Data File… option. A new window will be displayed.

image

Figure 518- Accessing Data File Tool

21.   Enter the data from Table 5‑1. Select a cell in the table and type the value. Using the tab key, you can move to the next cell.

Table 51  - Data for Influent Soluble Calcium Concentration

t [d]

scawinf [gCa/m3]

1

50

2

75

3

85

4

60

5

35

 

 

image

Figure 519- Data File Tool with Values

22.   Save the data by pressing Accept. You will be prompted to save the file.  The default location is the same directory as the layout file and the default name is the layout’s name with the cryptic name of the variable concatenated to it. These defaults are usually appropriate, so click Save to save the file

 

Notice that the interactive slider for the removal efficiency input has automatically changed into a file input control bar and is no longer able to be manually adjusted.

 

23.   Create a New Output Plot. We will create a new output plot to emphasize the changes this new data file makes. Right-click on the Treated Water object and select Output Variables > Water Chemistry Variables. Drag the Total Ca, Mg Hardness variable under the Hardness subheading to a new output graph tab (i.e. drop it in a blank area beside the current tab’s label).

 

Open the Output Graph Properties window and set the y-axis minimum and maximum values to 0 and 250 mgCaCO3/L respectively. Rename the graph ‘Effluent Ca, Mg Hardness.

 

Rename the output tab “Ca, Mg Hardness”.

 

24.   Run a 6-day simulation with Steady-State clicked ON.  As the model is simulated, the value of the influent flowrate, the influent pH, the influent carbonic acid concentration, and the influent calcium concentration will be read in from the data files.

Chart, line chart  Description automatically generated

Figure 520- Data Driven Effluent Ca, Mg Hardness

Plotting Measured Data Along With Simulated Results

The previous section described the method for importing input data to the simulation file. In this section, the method for importing and displaying measured output data on a graph alongside the simulated results will be introduced. This is convenient for comparing the measured value from a plant with the simulated results given in GPS-X. It also makes it easier to calibrate and optimize the process.

25.   Create a spreadsheet file with the example measured data. The table below is an example of the observed effluent Ca, Mg Hardness data from the plant. Create a data file with this information and save it in the same directory as the layout file.

Table 52- Measured Data

t

totalhardnessweff

d

mgCaCO3/L

0

119

1

110

2

145

3

194

4

235

5

159

6

114

The cryptic variable name for the effluent Ca, Mg Hardness (totalhardnessweff) can be found by right-clicking on the output graph created in the previous section and selecting Output Graph Properties… from the drop-down menu. Hold the mouse cursor over the variable label and a tooltip will appear with the label/cryptic information as shown in Figure 5‑21.  This should correspond to the name on the first row of the spreadsheet file.

image

Figure 521  - Tooltip Showing Cryptic Variable Name

26.   Add the data file.  Following the same procedure outlined in the previous section, where an input data file was added to the layout, access Scenario > Configuration/ Data Files… > Data Files and add the output data file to the Base Model Scenario.

 

27.   Run a 6-day simulation with Steady-State clicked ON. The data points from the measured data file are shown as diamond-shaped points on the graph, as shown in Figure 5‑22.

image

Figure 522- Graph Showing Measured Data Points

Statistical Analysis of the Model Performance

A statistical analysis can then be conducted within GPS-X to test the model’s ability to reproduce the observed data. Statistical Analysis can only be preformed on X-Y timeseries output plots that have data points displayed on the plot.

26.   Run a 6-day simulation with Steady-State clicked ON.

 

27.   Open the Statistics menu. Right click anywhere on the graph and select the statistics > [weff] total Ca, Mg Hardness option.

 Diagram  Description automatically generated

Figure 523- Accessing the Statistics Menu for the Ca, Mg Hardness

28.   Select the type of Statistical Analysis. The statistics menu will provide you with a variety of Model Fit and Residual Analysis that can be conducted.

From the Model Fit Evaluation section of the menu, select:

·         Plot of simulated vs measured

·         Table of goodness-of-fit statistics

From the Residual Analysis section, under the plot against measured values sub-heading, select:

·         Residuals

Note: The Measured Data Type section of the statistical analysis allows you to specify the method in which the data has been collected. The grab sample option assumes that the data represented on the plot was collected at that specific point in time. For more details on the calculations performed in each statistical analysis and the measured data types available, refer to the Technical Reference manual.

image

Figure 524- Selecting the Statistical Analysis to be Preformed on the Model Output

29.   Press Accept. GPS-X will automatically produce the selected plots on the current output tab. Press the Auto Arrange button on the Output toolbar to view all the plots simultaneously.

Using the data presented in the output plots, you can judge the ability of your model to represent the collected data. A poor statistical analysis here may suggest that further model calibration is required to fit the model to measured data. You can use input controllers to fine tune your model within Simulation Mode.

 Chart  Description automatically generated

Figure 525- Results of the effluent Ca, Mg Hardness Statistical Analysis