Vous êtes sur la page 1sur 123

GPS-X Tutorial Guide

A Step-By-Step Guide For Learning


And Getting Familiar With GPS-X

GPS-X Version 4.1


ii Table of Contents

Copyright 1992-2003 Hydromantis, Inc. All rights reserved.

No part of this work covered by copyright may be reproduced in any form or by any means - graphic,
electronic or mechanical, including photocopying, recording, taping, or storage in an information retrieval
system - without the prior written permission of the copyright owner.
The information contained within this document is subject to change without notice. Hydromantis, Inc.
makes no warranty of any kind with regard to this material, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose. Hydromantis, Inc., shall not be liable
for errors contained herein or for incidental consequential damages in connection with the furnishing,
performance, or use of this material.

Trademarks
GPS-X, GMI and all other Hydromantis trademarks and logos mentioned and/or displayed are trademarks
or registered trademarks of Hydromantis, Inc. in Canada and in other countries
ACSL is a registered trademark of AEgis Research Corporation
Adobe and Acrobat are trademarks of Adobe Systems Incorporated
MATLAB is a registered trademark of The MathWorks, Inc.
JAVA is a trademark of Sun Microsystems, Inc.
Microsoft, Windows, Windows NT, Windows 95, Windows 98, Windows 2000 and Windows ME are
trademarks of Microsoft Corporation.

Printing Date: June, 2003


Table of Contents iii

TABLE OF CONTENTS

Preface..................................................................................................................... vii
Introduction............................................................................................................... vii
Intended Audience ........................................................................................... vii
How This Guide is Organized.................................................................................. viii
Modules and Libraries................................................................................... ix
Companion Documents ................................................................................. ix
Conventions ...........................................................................................................x
Resources and Support .................................................................................. xi
TUTORIAL 1...................................................................................................................... 1
Building a Plant Model ................................................................................ 1
Introduction .......................................................................................................... 1
Objectives .............................................................................................................. 2
Building a Simple Plant Layout ................................................................. 2
Selecting Object Models ................................................................................ 9
Generating Source Code and Binary Executable ........................... 13
Defining & Displaying Interactive Control Windows .................. 14
Defining a Control Window ................................................................... 14
Displaying a Control Window .............................................................. 18
Defining & Displaying Output Windows............................................. 18
Defining an Output Window .................................................................. 19
Displaying an Output Window ............................................................. 22
Organizing the Display ................................................................................ 22
Running a Simulation .................................................................................... 23
Analyzing the Plant ........................................................................................ 25
What's Next? ...................................................................................................... 27
TUTORIAL 2.................................................................................................................... 29
Editing Layouts and Using Scenarios ............................................. 29
Problem Statement .......................................................................................... 29
Objectives ............................................................................................................ 30
Expanding the Plant....................................................................................... 30
Using Scenarios ............................................................................................... 34
Generating a Static Report ......................................................................... 36
What's Next ......................................................................................................... 38
TUTORIAL 3.................................................................................................................... 39
iv Table of Contents

Influent Data & Influent Advisor ....................................................... 39


Problem Statement .......................................................................................... 39
Objectives ............................................................................................................ 39
Influent Data ...................................................................................................... 39
Using Influent Advisor .................................................................................. 41
Model Dependency ..................................................................................... 46
What's Next? ...................................................................................................... 47
TUTORIAL 4.................................................................................................................... 49
Data Input and Output ................................................................................. 49
Problem Statement .......................................................................................... 49
Objectives ............................................................................................................ 49
Saving the Dynamic Response of a Simulation ................................ 50
Using a Data File as an Input................................................................... 52
What's Next? ...................................................................................................... 55
TUTORIAL 5.................................................................................................................... 57
Using Automatic Controllers ................................................................. 57
Problem Statement .......................................................................................... 57
Objectives ............................................................................................................ 57
Setting up an Automatic MLSS Controller ......................................... 58
Tuning the Automatic MLSS Controller .............................................. 60
Using an Automatic DO Controller ....................................................... 64
What's Next? ...................................................................................................... 68
Reference ............................................................................................................. 68
TUTORIAL 6.................................................................................................................... 69
The Define Function..................................................................................... 69
Problem Statement .......................................................................................... 69
Objectives ............................................................................................................ 69
Setting up the Layout ..................................................................................... 69
Defining Mass Flows ..................................................................................... 72
Defining an SRT ............................................................................................... 74
Defining Averages........................................................................................... 76
Controlling SRT with Waste Pump Rate.............................................. 77
What's Next? ...................................................................................................... 78
TUTORIAL 7.................................................................................................................... 79
Sensitivity Analysis ...................................................................................... 79
Table of Contents v

Problem Statement .......................................................................................... 79


Objectives ............................................................................................................ 79
Setting Up the Layout .................................................................................... 80
Setting Up the Parameters for Analysis ............................................... 80
Steady-State Analysis .................................................................................... 81
Time Dynamic Analysis ................................................................................ 84
Phase Dynamic Analysis ............................................................................. 85
What's Next? ...................................................................................................... 86
TUTORIAL 8.................................................................................................................... 87
Parameter Optimization ............................................................................. 87
Problem Statement .......................................................................................... 87
Objectives ............................................................................................................ 87
Initial Manual Calibration ......................................................................... 88
Automatic Calibration Using the Optimizer ...................................... 89
What's Next? ...................................................................................................... 94
TUTORIAL 9.................................................................................................................... 95
Basic Customization..................................................................................... 95
Problem Statement .......................................................................................... 95
Objectives ............................................................................................................ 95
Setting Up and Customizing a Layout .................................................. 96
Running Simulations .................................................................................... 103
What's Next ....................................................................................................... 103
TUTORIAL 10................................................................................................................ 105
Dynamic Parameter Estimator (DPE) ........................................... 105
Problem Statement ........................................................................................ 105
Objectives .......................................................................................................... 105
Setting Up the Layout .................................................................................. 106
Setting Up the DPE ...................................................................................... 108
Running the DPE ........................................................................................... 110
The End............................................................................................................... 111
vi Table of Contents
Preface vii

Preface

Introduction
GPS-X is a modular, multi-purpose modeling environment for the simulation
of municipal and industrial wastewater treatment plants. It is the world's
premier wastewater treatment plant simulator. GPS-X uses an advanced
graphical user interface to facilitate dynamic modelling and simulation. No
other software for modeling and simulation of wastewater treatment
processes provides the power and flexibility available with GPS-X. It is
state-of-the-art technology, using the most recent advances in process
modeling, simulation technology, graphics and a host of productivity tools
that simplify model construction, simulation and interpretation of results.
This allows you to examine the complex interactions between various unit
processes in your plant, interactively and dynamically. Understanding these
relationships is critical for effective design, operation and control of
wastewater treatment plants.

Intended Audience
The GPS-X Tutorial Guide is primarily intended for first-time users of GPS-
X but is also useful for experienced users who need information on a specific
feature. To understand the material in this tutorial best, you should have a
background in the fundamentals of wastewater treatment including the unit
processes in a typical wastewater treatment facility and the operation of these
processes. It is helpful if you have some knowledge of modeling and
simulation but this is not required.
viii Preface

How This Guide is Organized


The GPS-X Tutorial Guide is divided into ten tutorials. An effort has been
made to include realistic examples in these tutorials in order to improve
understanding and show the many practical applications for GPS-X. It is
assumed that you have properly installed GPS-X and that you can start the
program on your workstation. Technical information regarding modeling,
simulation and analysis features are contained in the GPS-X Technical
Reference manual. For detailed descriptions of each GPS-X feature
including step-by-step instructions, please refer to the GPS-X User's Guide.

The following is a brief introduction to the material covered in each chapter.

Tutorial 1, Building a Plant Model, covers the basic information needed to


create layouts, specify unit-process-object attributes, build a model, set up
interactive controllers and display graphical results.

Tutorial 2, Editing Layouts and Using Scenarios, contains information on the


GPS-X layout editing features. In addition, the steps needed to set up
simulation scenarios are explained.

Tutorial 3, Influent Data & Influent Advisor, examines the procedure for
entering influent data and using Influent Advisor to help debug potential
problems with influent data.

Tutorial 4, Data Input and Output, examines the procedure for saving
simulation data and reading data from an input file when you run a
simulation. The report generation feature is also examined in this chapter.

Tutorial 5, Using Automatic Controllers, explains how standard automatic


control algorithms (P, PI, PID) can be specified in the GPS-X models.
Selection of control variable, manipulated variable, set-point and tuning
constants is explained by example.

Tutorial 6, The Define Function, explains features of GPS-X which allows


you to define global variables, such as solids retention time and loading rate,
that depend on the layout or configuration of unit processes in the plant
model.

Tutorial 7, Sensitivity Analysis, describes how to use a GPS-X model to


analyze the effects of model inputs (independent variables) on model outputs
(dependent variables). Instructions are given for setting up both steady-state
and dynamic sensitivity analyses.

Tutorial 8, Parameter Optimization, explains how GPS-X optimization


routines can be used to automatically fit your models to real data. The
tutorial examines the methodology for specifying the model parameters to be
optimized as well as the form of the objective functions used in the
optimization routine.
Preface ix

Tutorial 9, Basic Customization, describes ways to add your own model


equations and new variables to a GPS-X layout.

Tutorial 10, Dynamic Parameter Estimator (DPE), explains how the DPE
module can be used to estimate time-varying parameters using on-line or
historical data.

Modules and Libraries


GPS-X is distributed as a number of program modules and model libraries.
The modules and libraries you purchased are listed on the invoice. You
should transfer this information to the inside cover of this manual for future
reference. Modules available in GPS-X are:

Simulator
Builder
Analyzer
Optimizer
Advanced Tools
Multi-Instance Licenses
The Simulator module is delivered with all copies of GPS-X and most users
will have ordered the Builder module option as well. The other modules are
options available to you at the time of order or at any time in the future
should you decide to upgrade your system.

Chapters 1 through 5 are useful for all users and require only the GPS-X
Simulator module. GPS-X users without the Builder module can skip the
development section of the tutorial, and simply open in the pre-built model
from the Windows `Start' menu. The remaining chapters require additional
modules as outlined below.

Chapters 6, 7, 8, 9, and 10 require the Builder module, while Chapter 6


requires the Analyzer module. Chapter 7 requires the Optimizer module, and
Chapter 10 requires the Advanced Tools module.

The tutorials can be carried out using any GPS-X library.

Companion Documents
This document is part of the GPS-X software manual set which includes:

GPS-X User's Guide. Takes a procedural look at GPS-X and


describes the steps needed to complete specific tasks.
GPS-X Tutorial Guide (This manual).
x Preface

GPS-X Technical Reference. Provides technical information on


the process models and other routines used in GPS-X (available
in electronic format on the CD and through the GPS-X Help
menu).
GPS-X Entry Level Manual. Provides basic information on running
GPS-X, defining outputs controls, and outlines the use of
scenarios (available in electronic format on the CD and through
the GPS-X Help menu).
GPS-X Advanced Control Module Manual. Explains how you can
use the Advanced Control Module to design advanced
multivariable controllers for use in GPS-X (available in
electronic format on the CD and through the GPS-X Help menu).

Conventions
This manual uses the following typeface conventions:

Terms introduced for the first time, variables, and references to


other documents are in italics.
Names of buttons, menu items, and settings are shown in Helvetica
Bold font, for example: "Choose Open from the File menu".

Courier New is used for text that appears in text-based windows


such as the Log window or in a data entry field. It is also used for
directory and file names.
Preface xi

Resources and Support


All users are entitled to 90 days of free technical support. In addition, as part
of the annual maintenance contract (optional), registered users have access to
unlimited free technical support on the features of GPS-X for one year.
Telephone, FAX and e-mail support are available.

Telephone and FAX Support. Telephone and FAX support is available


at the following numbers;

Telephone: +1 (905) 522-0012


FAX: +1 (905) 522-0031

E-mail Support. Support is also available to users with access to electronic


mail services. For e-mail support send mail to the following address:

support@hydromantis.com

Hydromantis has a presence on the World Wide Web. Its web site address is:

http://www.hydromantis.com

There, you will find information on the company and details about our
software, upcoming events, etc.
Building a Plant Model 1

TUTORIAL 1

Building a Plant Model

Introduction
Dynamic process models have great potential for assisting operators,
engineers and managers. However, in the past dynamic models were not
used very often because the cost of building models, running simulations and
interpreting the results were too expensive. In order to simplify the
modelling process and therefore reduce costs, you need tools to aid you with
the steps in any modelling exercise.

A tool like GPS-X is invaluable as its easy-to-use interface connected to a


powerful library of simulation models will greatly reduce the expense of
carrying out simulation studies.

There are five major steps in any modelling study:

1. model construction
2. model calibration
3. scenario development
4. simulation
5. interpretation of results
In this chapter you will develop a simple dynamic model of an activated
sludge system.
2 GPS-X Tutorial Guide

Objectives
This tutorial covers the following topics:

1. Building a simple plant layout


2. Preparing the source and binary code
3. Setting up graphics and interactive controls
4. Running interactive simulations
When you have finished this tutorial, you will be able to build and run full-
scale dynamic treatment process models. You will learn how GPS-X
automatically generates error-free code when a model is built, the procedures
for creating time series graphics and interactive controls, and how to run the
model you have prepared. These essential features provide a foundation on
which other advanced features are built; therefore, it is important to
understand the material in this chapter first before going on to more
complicated tasks.

Users who do not have the GPS-X Builder module should open the
tutorial1 layout located in the GPS-X tutorial directory. This file can
also be accessed from the `Start' menu. After doing this, these users should
proceed to the Defining & Displaying Interactive Control Windows (Page 14)
section and continue with the rest of the tutorial.

This chapter assumes you have installed GPS-X and supporting files on your
workstation. Refer to your workstation documentation and the GPS-X User's
Guide for information on these initial set-up procedures.

Building a Simple Plant Layout


After starting GPS-X:

1. Select the Carbon-Nitrogen-Phosphorus Library (cnplib) from the


Options > Preferences submenu of the Options menu (Figure 1-1).
Building a Plant Model 3

Figure 1 - 1 Selecting a GPS-X library.

Note: If a white drawing board is not displayed, start a new file by clicking
on the New button on the tool bar.

2. Locate the Process Table on the left-hand side of the GPS-X window.
These icons are used to build a plant layout. Icons represent the unit
processes and control points in a layout. The icons are separated into groups
of like objects, such as Preliminary Treatment, Clarification and Settling,
and Biosolids Treatment.

The Process Table contains 43 unit process icons. Each object is identified
by process name (see Figure 1-2). The process name is also displayed if you
hold the cursor over any object in your drawing board layout.
4 GPS-X Tutorial Guide

Figure 1 - 2 Process Table

We will start by building a simple wastewater treatment plant consisting of 3


objects:

an influent
an aeration tank
a secondary clarifier

3. Place the influent object on the drawing board. If the Influent group
is not selected in the process table, click on the Influent process group to
display the influent process objects. Place the cursor over the grey arrow
influent object. Click on the left mouse button and with the button pressed,
drag the cursor to the centre of the drawing board and drop the object by
releasing the mouse button. The influent object now appears in the drawing
board. You can drop as many of these objects as desired by repeating this
procedure. For now, drop only one influent object.

4. Select the plug flow tank icon (Suspended Growth Processes group) and
drop it on the drawing board to the right of the influent object.

5. Select the circular secondary clarifier icon (Clarification and Settling


process group) and drop a circular secondary clarifier object to the right of
the plug flow reactor. Close the Process Table by clicking on the Process
Table button (left-hand side of the lower toolbar).
Building a Plant Model 5

Figure 1 - 3 Building the layout.

The drawing board should now look similar to Figure 1-3.

6. Zoom in by using the Locator feature. This is a simple plant and there is
a lot of white space on the drawing board. We can zoom in to get a better
view of the layout using the Locator feature of GPS-X.

To use the Locator, click the Locator button on the tool bar. The Locator
window will be displayed as shown in Figure 1-4.

Figure 1-4 GPS-X locator window.


6 GPS-X Tutorial Guide

7. Zoom in or out by selecting a region in the Locator window (click, drag


and release). Try selecting an area much larger than the rectangle currently
displayed in the Locator window. When you release the mouse button the
GPS-X drawing board is refreshed and the icons in the drawing board appear
smaller. Try dragging-out a smaller rectangle and note the effect in the main
drawing board area. You should see an enlarged view like that shown in
Figure 1-5.

NOTE: The area in the Locator window represents the total available
drawing area. When you drag out a region in the Locator window and
release the mouse button the region within the drag rectangle is displayed in
the drawing board area, scaled as necessary.

8. Specify the connectivity between the objects. This is critical in the


specification of a flow sheet as all material balances - and therefore the
equations which result - are based on the connectivity in the layout. When
you specify these connections, remember that the flow lines are directional,
i.e., materials flow from the initial point to the terminal point of the flow
connection.

Figure 1 5 Enlarged view of the layout.


Building a Plant Model 7

To specify the connectivity between objects, in the drawing board, move the
pointer over the influent object connection point. You will know that you are
over the connection point when the mouse pointer changes from the default
`Windows' arrow to a connecting arrow. When the connecting arrow
appears, click to anchor the flow line at this initial point.

Next, drag the pointer from the influent object to the influent connection
point of the plug flow tank (top left hand corner of the icon, NOT the return
flow connection point just below on the left hand side of the icon). When the
connecting arrow re-appears, release the mouse button. A connecting pipe
will be drawn between the influent object and the plug flow tank. In a similar
manner, connect the effluent point from the plug flow tank (top right hand
corner of the icon) to the secondary clarifier. Finally, connect the underflow
from the secondary clarifier (bottom of the secondary clarifier icon) to the
return flow point of the aeration tank (lower left hand corner of the aeration
tank icon). In this example excess sludge will be wasted from the bottom of
the secondary clarifier (lower right hand corner of the clarifier icon). As this
model does not consider any downstream processing of the excess sludge, it
is not necessary to specify a flow connection from this point (Figure 1-6).

Figure 1-6 Completed Layout


8 GPS-X Tutorial Guide

NOTE: When flow connections are being specified, GPS-X interprets


mouse button clicks in a certain way. The first mouse button click within the
drawing board is assumed to be a flow stream initiating point and the mouse
release event signals the terminal point. You must be on a valid connection
point for these assignments to be made correctly. GPS-X does not allow
invalid flow connections. For example, flows which initiate at the influent of
an object and terminate at the effluent of a second object are not allowed.
GPS-X will disallow an incorrect connection by displaying an invalid sign.
If you experience some difficulty in specifying flow connections, you can
delete the flow lines by placing the cursor at the flow initiation point and
dragging the flow line to an empty cell on the drawing board. As soon as the
cursor button is released the flow line will be deleted.

9. Show or re-name the stream labels. In the completed layout shown in


Figure 1-6 there are numbers associated with each of the flow streams. To
display these stream labels click on the Labels button on the tool bar. A
drop-down menu will appear as shown in Figure 1-7. Check the Streams
checkbox.

Figure 1-7 Selecting to show the stream labels.

To change a stream label, right-click on an object icon and the process data
menu will be displayed. Select the Labels item from this menu. New label
names can be input on the form that is displayed. Save these changes by
choosing Accept. If there is a conflict between your label assignments and
Building a Plant Model 9

existing labels, a message will be displayed. An example of a labels window


is shown in Figure 1-8.

Figure 1-8 Changing the labels of the process units and streams.

NOTE: Variable names in GPS-X models use the connection labels to


identify a particular stream (e.g. qinf for the influent flowrate, and qfe1
for effluent flowrate in this case). These variable names are displayed on
some of the forms you will see as you progress through the tutorial chapters.

The plant layout is now ready! If you experienced some difficulty in


selecting or placing the objects in this layout, you can delete objects from the
drawing table by selecting the object (a dotted red square appears around the
object) and then pressing the Delete button. Alternatively, you can close the
current drawing board and click on the New button. See Chapter 3 of the
GPS-X User's Guide for step-by-step instructions on using all the editing
features in GPS-X.

Selecting Object Models


In the previous section we selected the basic objects to be modelled in our
plant. These objects are the major unit processes and control points only.
No mathematical models were assigned to the various objects in the layout.
10 GPS-X Tutorial Guide

Each object in the layout has a number of attributes or properties, and each
attribute has a certain value. One of the most important attributes for GPS-X
objects is the set of equations (or model) that define the dynamic behavior of
that object. Remember to distinguish between an object type and the model
for that object as some objects have more than one possible model. Before
you can build the plant model, a model must be specified for each object in
the layout.

10. Specify the influent model. Right-click on the influent icon. An


influent object-specific data menu appears as shown below (Figure 1-9). The
first item in the menu is Models. Click on this item to activate the sub-menu,
and select the bodbased item.

Figure 1-9 Model selection for the influent.

11. Specify the plug flow tank model by repeating this procedure, but for
this object select the asm1 item.

12. Specify the secondary clarifier object model by selecting the simple1D
(non-reactive 1-dimensional clarification model) item1.

13. Save the layout. Go to the File menu, and select the Save As menu
item. When you make this selection the Save dialog box is displayed. A list
of directories and files in the current directory is shown in the list box.
Navigate through your directories to an appropriate directory and type a
filename in the File name: text box, as shown in Figure 1-10.

1
See GPS-X Technical Reference for more information on these Models.
Building a Plant Model 11

Figure 1-10 GPS-X: Save As dialogue box.

When you have specified a directory and file name, click on the Save button.
A message is displayed if a file having the same name is in the listed
directory. Choose Yes to save over the old file (overwriting the previous file)
or No to select a different file name. Note that you must have write
privileges for that directory.

You may have noticed that an object's process menu contains a number of
items for specifying other attributes of an object, for example, parameters
and initialization properties (Figure 1-11). In this tutorial we will use the
default properties for the objects you have selected with three exceptions; the
influent soluble substrate fraction, the influent biological model and the
excess sludge wastage rate from the final clarifier.

14. Change the secondary clarifier wastage rate by right-clicking on the


secondary clarifier object, move to the Parameters sub-menu and select the
Operational menu-item as shown in Figure 1-11. A data entry form will
appear on the screen as shown in Figure 1-12. Change the pumped flow entry
from 0.0 m 3 /d to 40 m 3 /d as shown in Figure 1-12. This value is 2% of the
default influent flow (2000 m 3 /d). Once you have changed this flow, click
on the Accept button.
12 GPS-X Tutorial Guide

Figure 1-11 Secondary clarifier Operational menu item.

Figure 1-12 Changing the pumped flow.


Building a Plant Model 13

15. Change the influent soluble substrate fraction by right clicking on the
influent object, move to the Composition sub-menu and select the Influent
Stoichiometry menu-item. A data entry form will appear on the screen as
shown in Figure 1-13. Change the soluble substrate/BODultimate entry from
0.3 to 0.4 as shown in Figure 1-13 and select ASM1 from the local model
selection drop-down menu [note that changing the local model selection
ensures that the influent calculations are consistent with the down-stream
biological model in the plug-flow tank]. Click on the Accept button.

16. Save the layout again by clicking the SAVE button on the tool bar.
Selecting Save rather than Save As saves the layout with the current name
(shown on the GPS-X main window title bar) overwriting any previous files
with the same name.

The layout is now fully-specified and you can build the plant model.

Figure 1-13 Changing the influent stoichiometry.

Generating Source Code and Binary Executable


The next step is to translate the plant layout and the model parameters, first
into source code, and then into a binary file, which will be executed by GPS-
X. The translation and compilation process involves several steps; however,
GPS-X has been designed in such a way that these steps are executed without
user input. This enables you to concentrate your efforts on process
understanding rather than the mechanics of model construction.
14 GPS-X Tutorial Guide

17. Generate the model source and binary code by clicking on the Build
button. This starts the process of compilation and linking, resulting in the
creation of an executable model. The time required to complete this process
depends on the speed of your workstation, and the complexity of the model.
Upon completion of the build step, the message Completed will be displayed
in the Build window as shown in Figure 1-14. Click on the Accept button
when this message is displayed.

Figure 1-14 Compilation completed message.

Defining & Displaying Interactive Control Windows


GPS-X is an interactive simulation program, or simulator, which can run
both pre-defined (batch) simulations and interactive sessions. We will now
set up an interactive session that allows us to investigate the effects of
changes in the influent flow rate on the plant effluent quality.

Defining a Control Window


Our first task is to define a control window. A control window is a window
containing one or more interactive controls, which can be used to change the
value of model variables during the course of a simulation run. You can
define as many control windows as desired. Here, we will define a single
control window with one interactive control that sets the value for the plant
influent flow.
Building a Plant Model 15

Figure 1-15 Flow data menu.

Before defining an interactive control for the influent flow, the variable must
be tagged, i.e., it must be identified as a controllable variable. This is done
by marking that variable as a control variable in its data entry form.

18. Tag the influent flow as a control variable by right-clicking on the


influent object and select the Flow Data item from the Flow sub-menu as
shown in Figure 1-15.

A data entry form will open displaying the current influent flow value. Click
on the checkbox to the left of the influent flow variable. A check mark (9)
will appear in the box as shown in Figure 1-16. The influent flow has now
been tagged as a variable that can be controlled during the course of a
simulation run. Remember to accept the changes made in the data entry form
by clicking the Accept button on the bottom right-hand corner of the form.

Figure 1-16 Tagging the flowrate.


16 GPS-X Tutorial Guide

19. Define the control window by clicking on the arrow on the right hand
side of the Controls buttons. A drop-down menu is displayed containing the
following items:

The first menu item is used to define control windows. Select this item and a
form will be displayed entitled Controls Define. Click on the Add button and
this will insert a blank item in the bottom position of the list box. Each listed
item represents a control window. You create control windows by inserting
new items in this list. The text you enter for the item is the name that will be
displayed in the title bar of that control window.

Next, click in the text field to the right of the word Title: type in an
appropriate title for the control window (Figure 1-17). The text will appear
in the title list box.

Note the numerical value indicated in the small box next to the word Title: in
the lower left hand corner of the control window definition form. This
number uniquely identifies the control window and is referenced when
specifying the control window on which to place a control. Control windows
are always numbered sequentially, so if you have 5 control windows defined,
these will be numbered 1 to 5.

When you have finished defining the control windows, click the Accept
button. Your entries will be saved and the form will close.

Figure 1 - 17 Control Window Definition


Building a Plant Model 17

20. Select the Setup... item from the Controls drop-down menu to activate
the Controls Setup form (Figure 1-18 and Figure 1-19). The Control Setup
form is used to specify the type and placement for controls linked to each of
the model independent variables you have tagged. The first 3 entries (rows)
on this form are reserved for system variable controls, which are placed on
the simulation control window. You can use this form to set minimum (Min),
maximum (Max) and control increment (Delta) values for simulation delay,
stopping time and communication interval.

The fourth line displays the previously tagged variable, which in this case is
influent flow. Click on the inverted triangle in the #: window box and a drop-
down menu will appear with the title and number of all defined control
windows. Select 1 for the control window number, 0 for minimum flow and
10000 for maximum flow (Figure 1-19). It is not necessary to enter a value
in the Delta column, as we will use a slider-type control, which does not
require a value for this attribute. Note the small menu mark (inverted
triangle) on the right-hand side of each entry below the Type column
heading. If you click on this menu mark, a list of control types is displayed.
These types are discussed in more detail in a subsequent tutorial. For now,
note that the Up/Down type is used for the first three items and that Slider is

Figure 1-18 Controls set-up.

used for the influent flow item. Make sure that these types are set correctly
before proceeding. Remember to save your entries by clicking on the Accept
button.
18 GPS-X Tutorial Guide

Figure 1 - 19 Controls Setup window.

Displaying a Control Window


The control window and a single influent flow control have now been
defined and can be displayed.

21. Display the control window by clicking on the Controls icon. The
window shown in Figure 1-20 appears containing a slider that allows you to
change the influent flow from 0 to 10000 m 3 /d. You can move the control
window to any convenient position on the screen. You can test the slider
control by dragging the small slider button, but note that if you move the
slider bar, the influent flow value will change to the value displayed on the
control. Before proceeding, move the slider back to a position corresponding
to 2000 m 3 /d, or alternatively you may enter the value into the control with
the keyboard.

Figure 1 - 20 Interactive Controller

Defining & Displaying Output Windows


At this point the plant model has been prepared and an interactive control has
been defined but we have no way to observe the results of a simulation.
GPS-X provides six different types of graphic display for output of
simulation results. In this tutorial, we will set up a single time series graphic
window and plot two important model variables, the influent flow and the
effluent suspended solids concentration.

The graphic setup procedure is similar to the interactive control setup


procedure. First, variables to be displayed must be tagged, next, a graphic
window is defined and the variables to plot in the window are specified.
Finally, the graphic window is displayed.
Building a Plant Model 19

Defining an Output Window


22. Tag the variables to be displayed during the simulation run by right
clicking on the influent object to display its process data menu. Select Flow
from the Display Variables sub-menu (Figure 1-21).

NOTE: There is a difference between data entry forms and display variable
forms even though both have a similar appearance and may contain the same
variable name entries. Data entry forms contain a field on the right-hand
side for entering data. Display variable forms do not contain this field. To
review: variables tagged on a data entry form can be placed on a control
form, whereas variables tagged on a display variable form can be placed on
graphs or saved to data files. For more information on the display and data
entry form see the GPS-X User's Guide.

A display variable form will appear as shown in Figure1-22. Tag the flow
variable by clicking in the checkbox to the left of flow. A small check mark
(9) will appear in the box as shown in Figure 1-22.

Click Accept to save the variable tagging information and close the display
variable form.

Figure 1-21 Display Variables menu item.


20 GPS-X Tutorial Guide

Figure 1-22 Tagging the influent flow.

Next, move the pointer over the effluent point of the final clarifier
(overflow). When the pointer is positioned correctly, the cursor will change
to a connecting arrow to indicate that you have located a connection point1.
Right-click and select the Composite Variables item from the Display
Variables sub-menu (Figure 1-23). Tag the total suspended solids variable by
clicking on the checkbox to the left of the variable name as shown in Figure
1-23. Close the form by choosing Accept.

Figure 1 - 23 Tagging the final effluent.

23. Define the display graphs by clicking on the inverted triangle on the
right hand side of the Outputs button on the tool bar. Select the Define... item
from the drop-down menu. A form will appear entitled Output Define (Figure
1-24). Select the Add button and this will insert a blank item in the bottom
position of the list box under the heading Title. Next, click in the text field to
the right of the word Title: Type in an appropriate title for the graphic

1
Display variables are defined within each object and at each of the objects connection points.
Building a Plant Model 21

window such as that shown in Figure 1-24. The text will appear in the list
box.

A numerical value is assigned to each graphic window just as with control


windows, and this value is shown in the box next to the word Title: in the
lower left-hand corner of the graphic window definition form (Figure 1-24).
Graphic windows are also numbered sequentially, so if you have 5 graphic
windows defined, these will be numbered 1 to 5.

Unlike control windows which can contain more than one type of control,
graphics windows can contain only one type of graph. Because of this, the
graphic type specification is made in the graphic windows definition form.
By default, the graph type is X-Y (time series) but this can be changed by
making a selection from the Type: drop-down menu. To make a different
selection, click on the menu mark next to the Type: label, and select the
desired graph type. Before continuing, re-select the X-Y type so that the
results you get match the figures shown in this tutorial.

Figure 1 - 24 Naming the graph.

You can also use the Delete button to delete items from the list. When you
have finished defining the output windows, click on the Accept button. Your
entries will be saved and the form will close.

24. Select the Setup... item from the Outputs drop-down menu. The
previously tagged variables should appear on the Output Setup form which is
displayed. The Output Setup form, like the Controls Setup, form is used to
specify plotting attributes including the output window in which to plot the
22 GPS-X Tutorial Guide

variable, the minimum y-axis value (Min), maximum y-axis value (Max) and
whether you want to save the data which are generated during simulation
(Save).

For this tutorial, we want to plot both variables on the same graph so click on
the inverted triangle in the #: Window box and a drop-down menu with the
title and number of all defined output windows will appear. Select 1 for each
variable. Enter a minimum and maximum value for each variable, i.e., 0 and
10000 m3/d for flow, and 0 and 150 g/m3 for suspended solids (see Figure 1-
25). Accept the changes.

Figure 1 - 25 Setting up a graph.

Displaying an Output Window


25. Display the output graphs by clicking on the Outputs button on the tool
bar.

When you make this selection, the defined output windows will be displayed
(Figure 1-26). These windows can be moved to a convenient position.
Output windows can also be re-sized and the graphic will re-scale.

Organizing the Display


Once the controller and output windows are displayed, they can be manually
resized and moved using the mouse. However; the Autoarrange button can
be used to quickly move all the windows into a standard setting, with the
control windows in the upper left corner, the layout moved to the centre left,
the simulation control panel in the bottom left corner, and the outputs "tiled"
on the right.
Building a Plant Model 23

Figure 1 - 26 Output Window.

Running a Simulation
You are now ready to run the model. Before you do this, make sure the
interactive controls and output windows are displayed. The next step is to
load the model.

26. Display the Simulation Control window by clicking on the Simulation


button on the tool bar.

27. Load the model by clicking on the Load button in the Simulation Control
window.

28. Specify a simulation duration time of 1 day by clicking on the arrow


button adjacent to the Stop label in the Simulation Control window. (Stop
should increment by 1 day).

29. Start the simulation by clicking on the Start button in the Simulation
Control window. The flow and effluent suspended solids will be displayed in
the output window.

You can now change the flow with the control window slider bar, and assess
the effect of changes in influent flow on the effluent suspended solids of the
plant. If the flow is high enough (say 6000 m3/d) you will see a significant
increase in the effluent suspended solids due to clarifier overload. An
example run is depicted in Figure 1-27. If the simulation proceeds too
24 GPS-X Tutorial Guide

quickly, you can artificially slow down the simulation by inserting a delay.
Add a delay by putting 0.5 (or any other number, the magnitude of the
number dictates the degree of delay) into the Delay entry field on the
Simulation Control window.

Figure 1-27 Example run.

30. Run the simulation again, but this time adjust the influent flow by
dragging the influent flow slider away from 2000 m3/d.

NOTE: If the simulation time exceeds the stop time (Stop) the model
will halt. At that time, you have three choices:
restart the simulation by clicking on the Start button in
the Simulation Control window; or
increase the length of the simulation by increasing the
value of Stop and clicking Continue to continue the
simulation; or
unload the model by clicking Unload .

If you Continue, GPS-X will begin simulating from where it previously


stopped and continue until the new stop time is reached. If you click on
Start, GPS-X reruns the previous simulation. Unloading the model will
terminate the simulation.
Building a Plant Model 25

Analyzing the Plant


We will now take a more detailed look at our plant's performance by
investigating the effect of increased flow on the secondary clarifier. We will
first set-up an output graph displaying the solids profile inside the final
clarifier. We will then simulate steady-state conditions with the design flow
of 2000 m3/d and investigate the change in the solids profile inside the final
clarifier by running the model at a higher flow rate (i.e. simulating a storm
condition).

To investigate the effect of increased flow on final effluent quality, set up a


graphical output of the solids profile inside the final clarifier.

31. Display the secondary clarifier solids profile by clicking on the


secondary clarifier object and selecting from the Display Variables sub-menu
item, Suspended Solids. Tag the suspended solids (Figure 1-28) item and
Accept the form.

Figure 1-28 Tagging the suspended solids inside the clarifier.

Next, click on the Outputs button and select Define from the drop-down
menu. Select the Add button and insert a blank item underneath the existing
label. Click in the text field box to the right of the word Title: and type in a
title for the output window (see previous example in Figure 1-24). Click on
the inverted arrow in the box entitled Type: and from the drop-down menu
select Bar Chart.

Select the Setup... item from the Outputs drop-down menu, and specify the
#: Window, minimum and maximum for the new graphic display. Set the
minimum to 0 g/m 3 and the maximum to 10000 g/m 3 (Figure 1-29). Accept
the form.
26 GPS-X Tutorial Guide

Figure 1-29 Setting up the solids profile inside the final clarifier as an output variable.

Show the outputs and the controls, and Autoarrange them using the
autoarrange button. From the Simulation Control window, Load the model.

32. Select the Steady-State option and Start the simulation setting Stop to
one day. Figure 1-30 shows a bar chart profiling the solids distribution
inside the final clarifier.

33. Increase the influent flowrate to a higher value (for example 6500 m 3
/d) with the controller. Adjust Stop to two days and Continue the simulation.
The bar chart profiling the solids distribution inside the final clarifier will
change to reflect the build-up of solids due to higher flows. Following this,
save the layout by clicking on the Save button on the tool bar.

Figure 1-30 Solids profile across the final clarifier. The top of the clarifier is represented by the
bars on the left, and the bottom of the clarifier is on the right.
Building a Plant Model 27

What's Next?
This tutorial covered the basic features of GPS-X. There are many additional
features which make GPS-X more powerful and flexible. The next tutorial
will expand on the layout prepared in this tutorial. GPS-X scenarios will be
introduced as a method of storing simulation setup data.

1. See the GPS-X Technical Reference for more information on these models.
2. Display variables are defined within each object and at each of the object's connection points.
28 GPS-X Tutorial Guide
Editing Layouts and Scenarios 29

TUTORIAL 2

Editing Layouts and Using Scenarios

Problem Statement
The previous tutorial examined the five major steps in a modeling study. A
special note was made of the iterative nature of modeling and simulation.
Making and running a model is rarely, if ever, a linear step-by-step process.
Model construction, calibration and refinement are part of the development
cycle. Once you see the results of a simulation, you will likely think of new
ways to alter or add to the model to improve its predictive power.

In designing and operating wastewater treatment facilities, it is often


necessary to assess the effects of changes or additions to a plant. The
conventional approach is to perform steady-state calculations, run laboratory
or prototype tests and even conduct plant audits or performance analyses.
This involves a major commitment of time and resources including staff,
external consultants and plant hardware. Sometimes it is impossible to
physically test the changes because to do so would endanger the plant
operation and/or result in permit or consent violations. In some cases the
assessment must be based to a large extent on experience.

For this tutorial, consider a situation where the plant you developed in the
first tutorial is expected to treat increased flow due, for example, to extra
sewer connections. Assume that the plant has adequate aeration capacity but
requires an extra clarifier.
30 GPS-X Tutorial Guide

Objectives
GPS-X makes it easy to build models to help you examine changes in plant
design and operation. This tutorial will show you how to use the layout
editing tools such as Copy and Paste to make additions to the layout. Once
the new model is built, the scenario features of GPS-X will be introduced.
Using scenarios, you can set up specialized data sets for comparing the
performance of the clarifiers in the event of uneven flow distribution under
both steady state and dynamic conditions. After running each scenario, it
may be desirable to record the model parameters and variables that were
used. The report feature of GPS-X is introduced to facilitate this task.

When you are finished with this tutorial, you will have developed the ability
to create and edit plant layouts and will have developed a better
understanding of static1 data input and output in GPS-X. You will be able to
prepare simulation scenarios to test different hypothetical situations and be
able to run the scenarios to test alternative plant designs or examine
operational changes. You will also be able to produce a record of model
dependent and independent variables.

Users who do not have the GPS-X Builder module can simply open in the
tutorial2 layout located in the GPS-X tutorial directory. This file can
also be accessed from the `Start' menu. Users that wish to use this pre-
compiled layout should proceed to the section Using Scenarios on Page 33.

Expanding the Plant


1. Recreate the layout used in tutorial 1 or open the layout that you
previously created.

NOTE: Before proceeding with the layout alterations make sure that
the model is not loaded

2. Save the layout under a different name (`tutorial2, for example).

3. Display the drawing board grid by selecting the Grid button from the
tool bar. In order to facilitate expansion to the layout, more space is required
on the drawing board. Open the Locator window and outline a larger
working area. This will allow you to place more objects on the drawing
board.

1
The term static is used to describe the process of data input and output in this case in order to differentiate
it from the case of input and output involving time series data which is described in Chapter 4.
Editing Layouts and Scenarios 31

4. Move the influent and plug-flow tank objects by clicking and dragging
out a box around the influent and plug-flow objects. Then, with the mouse
button pressed on one of the selected objects, drag the selected area to its
new location on the drawing board (Figure 2-1).

1. Select area of interest.

2. Click and drag area to new location.

3. Release mouse button.

Figure 2-1 Moving a group of objects.

5. Copy the final clarifier by selecting the existing secondary clarifier


located on the drawing board. A red outline around the clarifier grid cell will
appear. Click on the copy button and select a destination cell by dragging
out a small box inside the destination cell. The destination cell will get a red
outline. Next, click on the paste button. This will paste a copy of the
clarifier and all its attributes to the new location. Your layout should now
look like Figure 2-2.
32 GPS-X Tutorial Guide

Figure 2-2 Copying the final clarifier

6. Follow the procedure outlined in Tutorial 1 and complete the layout


by adding:
a two-way splitter to divide the mixed liquor from the aeration
tank to the two clarifiers
a two-way combiner to join the recycled sludge from the two
clarifiers with the raw sewage as feed to the tank.
a two-way combiner to mix the final effluent from the two final
tanks
Prior to connecting the new objects you must delete some old connections
(see Note: box below Step 8 of Tutorial 1 for this procedure). Delete the
connection from the plug flow reactor to the final tank as well as the
connection between the clarifier underflow and the plug flow reactor. Next,
select a two-way splitter from the Flow Control group of icons in the Process
Table and place it downstream of the plug-flow tank on the drawing board.
Then, position a two-way combiner underneath the plug-flow tank and
another downstream of the two clarifiers. If necessary, reposition the objects
so that your layout now resembles Figure 2-3.

7. Connect all objects. The last step of the plant expansion is to connect all
the objects. You may find it helpful to reorganize your layout and/or rotate
the combiner object located underneath the plug flow reactor. This is done
by selecting the combiner grid cell and clicking on the Rotate button until the
desirable orientation is achieved. The layout should resemble Figure 2-4.
Editing Layouts and Scenarios 33

Figure 2-3 Adding objects.

8. Recompile the model by clicking on the Build button on the tool bar.

Figure 2-4 Connecting the new units


34 GPS-X Tutorial Guide

Using Scenarios
Having built the modified layout, you can proceed with the plant
performance investigation. To do this, change the following model
parameters:

influent flow, to simulate the additional sewer connections


influent type, to simulate a dynamic fluctuation of the
influent wastewater
To change a model parameter (in this case change from a constant influent
flow to a sinusoidal influent flow), without recompilation, you must become
familiar with the scenarios function. Each user-defined scenario can have a
different set of model parameters so that the same model can quickly be
simulated using different operating conditions.

9. Display the Simulation Control window and Load the model from the
Simulation Control window.

10. Define a new scenario by selecting the New option from the Scenario
drop-down menu in the Simulation Control window. Type in a name for your
new scenario and Accept the form (see Figure 2-5).

Figure 2-5 Defining a new scenario.

11. Change the influent flow type and rate by selecting Flow Data from the
Flow menu of the influent object. This will open a form entitled Flow Data -
SIMULATION IS LOADED. The latter part of the title is a reminder that the
model is loaded and that changes made in this form will be saved in the
current scenario. Click on the inverted triangle and select Sinusoidal.
Editing Layouts and Scenarios 35

Change the influent flow in the Data sub-section of the same form to 5000
m3/d. Accept the form. You can display the items saved with a particular
scenario by selecting Scenario > Show... from the Simulation Control menu
bar. Similarly, you can revert back to the layout parameters (i.e. reset the
parameters to those used during the model build) by selecting the Default
scenario from the Simulation Control window (click on the inverted triangle
to the right of the Scenario: text box located at the bottom of the Simulation
Control window and select Default).

12. Define and set-up an interactive controller (slider type) for the flow
split fraction (in the "MLSS Splitter") as described in the Defining &
Displaying Control Windows section of Tutorial 1 (Steps 18-21).
Alternatively, you can use the Quick Help function by selecting Help > Quick
Help and clicking the Controls icon to display the steps to define and set-up
an interactive controller.

13. Define and set-up output graphs for the solids profiles in the new
(copied) clarifier as described in the Defining & Displaying Output
Windows section of Tutorial 1 (Steps 22-25). Alternatively, you can use the
Quick Help function by selecting Help > Quick Help and clicking the Outputs
icon to display the steps to define and set-up an output graph.

14. Define and set-up an output graph for the effluent SS for each
clarifier, and the combined effluent as described in the Defining &
Displaying Output Windows section of Tutorial 1. In each case, the total
suspended solids variable can be found in the Display Variables > Composite
Variables menu of each object's outflow stream. Display all three
concentrations on one graph.

15. Display the controls and graphs.

16. Run a steady-state simulation followed by a one-day dynamic


simulation.

17. Change the split fraction to 0.35 using the interactive controller and
increase the stop time to 2 days. Click Continue on the Simulation Control
window and let the simulation proceed until it stops.

18. Increase the flow to the plant to 6000 m3/d, increase the stop time to 3
days and Continue the simulation. A set of typical results are shown in
Figure 2-6. These graphs show the effect of the imbalanced flow split on
final clarifier performance and combined final effluent SS.

If you encounter difficulties, examine the procedure for creating the


`Expansion' scenario.
36 GPS-X Tutorial Guide

Generating a Static Report


You may wish to create a file with a list of all the parameter values, as well
as the model results for a particular run. GPS-X has a feature which will
allow you to do just that.

19. Select the Report... item from the File menu. This will open a new,
blank window. If you select Generate from the Report drop-down menu in
this window, a text file will be displayed in the window. Click `save' to save
an ASCII copy of the window contents to the current working directory. The
name of this file includes the layout name with an extension `.rpt . The
values of all the variables in the report correspond to the values in the model
when the report was generated. Therefore, if you wish to save the
concentrations corresponding to a steady-state simulation, the report should
be generated immediately after bringing the model to steady-state. If you
wish to save the concentrations corresponding to a particular point in time
(remember that the report produces a static picture of the plant) then, run the
simulation to that time and then generate the report (Figure 2-7). By default,
all the model parameters (including physical, operational, stoichiometric,
kinetic and settling parameters, and composite and state variable
concentrations) are selected to be included in the generated report. Note that
if you wish to generate several reports for the same layout, you must rename
the report file before generating another or else you will overwrite the
previous report.
Editing Layouts and Scenarios 37

Figure 2-6 Typical results.


38 GPS-X Tutorial Guide

Figure 2-7 Report window.

What's Next
This tutorial covered some of the GPS-X editing features as well as the
scenario and report generation features within the context of a plant
expansion analysis.

The next tutorial will examine influent data entry and the use of Influent
Advisor as a tool to help understand the interactions and dependencies in
influent data.

1. The term static is used to describe the process of data input and output in this case in order to
differentiate it from the case of input and output involving time series data which is described in
Chapter 4.
Influent Data and Influent Advisor 39

TUTORIAL 3

Influent Data & Influent Advisor

Problem Statement
You have some historical data related to the influent wastewater for your
plant and it does not resemble the default data presented in the GPS-X
influent object forms. Unfortunately, a full characterization of your influent
wastewater has not been performed. Nevertheless, you need to estimate the
influent wastewater characterization so that the model can be used with an
influent that approximates your influent data. In this tutorial, you will
investigate the influent models, the impact of the local biological model on
the influent calculations and the use of Influent Advisor as a tool to help
characterize influent data.

Objectives
This chapter covers two important features of GPS-X:

influent data entry


use of Influent Advisor as a characterization tool
All GPS-X users can complete this tutorial, as it only requires the GPS-X
Simulator module.

Influent Data
The following historical data have been gathered at your plant and represent
typical average values for your influent.
40 GPS-X Tutorial Guide

Table 3-1: Typical Average Historical Data

Measured Parameter Value Units


carbonaceous BOD5 210 mg/l
soluble COD 36 mg COD/l
total COD 390 mg COD/l
total suspended solids 205 mg/l
volatile suspended solids 197 mg/l
ammonia 26 mgN/l

1. Open the layout built in Tutorial 1 and save it as `tutorial3 using


the Save As... command from the File menu. After saving, rebuild the layout.
Alternatively, you can open the tutorial3 layout located in the GPS-X
tutorial directory. This file can also be accessed from the `Start' menu.

2. Display the Simulation Control window, Load the model and display the
Log window by checking the Log checkbox in the View menu of the
Simulation Control window.

3. Set up a new scenario for an influent case study. Create a new scenario
named influent as described in Tutorial 2 (Step 10).

4. Access the continuous influent object process menu and choose


Composition > Influent Composition.

5. Enter the total carbonaceous BOD5 and total suspended solids data from
the table above into the form and click Accept.

Figure 3-1 Influent Composition form of the BODbased influent model.

6. Check the influent data by clicking Start with the Steady State checkbox
unchecked, and Stop: set to 0. This checks for influent state variable
calculation errors. If an influent state variable error has occurred, then a
warning message will be printed to the Log window. No error should occur
Influent Data and Influent Advisor 41

with this layout. If one is printed, refer to Tutorial 1, Step 15 and ensure the
influent is set up as described.

7. Check the entered data and the resulting calculations by accessing the
influent object's process menu, selecting the Display Variables > Composite
Variables sub-menu.

8. Move the cursor over the total COD menu item and left-click. A quick
display pop-up window will be displayed showing the current value of the
influent total COD (Figure 3-2). Compare this value to the value for the total
COD given in the table above. Clearly, the influent model calculations are
inconsistent with the data for your plant indicating that one or more of the
default settings (i.e. composition data or stoichiometric fraction) are
inconsistent with your wastewater. A similar check can be done for
ammonia, by accessing the ammonia quick display in the Influent > Display
Variables > State Variables sub-menu.

Figure 3-2 Quick display pop-up window.

Using Influent Advisor


One method to rectify this inconsistency is to manually change the fractions
and repeat steps 7 & 8 until you achieve agreement. However, this is a
tedious task that could potentially take a significant amount of time. So, to
help uses with their influent models and entering influent data, Hydromantis
has developed a new Microsoft Excel based utility tool: Influent Advisor.

Note: Microsoft Excel 97/2000 must be installed for you to take


advantage of Influent Advisor.
42 GPS-X Tutorial Guide

Figure 3-3 Accessing Influent Advisor from the Start menu.

9. Start Influent Advisor from the Start menu as shown in Figure 3-3. For
this program to work properly, you must Enable Macros at start-up. The
Influent Advisor introductory screen will be displayed (Figure 3-4). Please
ensure that the macro security setting in Excel is set to Medium (located in
the Tools>Macro>Security menu).

Figure 3-4 Influent Advisor introductory screen.

10. Select the appropriate options in the three selection boxes. As you
are using the CNP library, and ASM1 as the biological model, select CNP in
the Library box, ASM1 in the Biological Model box and click on the
BODbased button. This will display the CNP/ASM1/BODbased Influent
Advisor sheet (Figure 3-5).
Influent Data and Influent Advisor 43

Figure 3-5 CNP, ASM1, BODbased Influent Advisor worksheet.

11. Click on the Reset Input to Default Values button at the top of the sheet
to ensure that the sheet is displaying the GPS-X default values in all input
cells.

12. Enter 210 next to total carbonaceous BOD5, 205 next to total suspended
solids, and 0.4 next to soluble substrate/BODultimate in the User Inputs table
on the left-hand side of the sheet. Note that the values calculated for total
COD (right-hand table, third from the top) and ammonia (middle table) are in
agreement with the values calculated in GPS-X.

13. Click on the total COD value. You will notice that a formula has been
displayed in the formula box at the top of the sheet. This formula
corresponds to the formula used in GPS-X to calculate the value clicked on.
Click on other cells to see other formulas.

From the data listed in Figure 3-1, several important relationships can be
calculated. For instance:

VSS: TSS ratio (ivt) = 197/205 = 0.96


particulate COD: VSS ratio (icv) = (390-36)/197= 1.80

14. Enter these values into the User Inputs table under the Stoichiometric
Coefficients sub-heading. Note that doing this seemingly results in values
further away from what you are looking for.

15. Click on total COD to display the calculation formula. By continuing to


click on the cells in the formula, you should be able to determine that cod is a
function of xcod and scod. Clicking on xcod reveals that xcod is a function
of x, ivt and icv. These have been calculated from your data, so these are
likely not the problem.

16. Decipher what input variables are important for the calculation of
scod. The calculated scod is much larger than the measured value so, to
decrease this calculated value it is important to know what input values to
adjust. Clicking on subsequent cells will reveal that scod is dependent on ss,
44 GPS-X Tutorial Guide

which is dependent on fss and the BOD5/BODultimate ratio in the User Inputs
table.

17. Adjust the fss value and see how the dependent values change. By
adjusting the fss value to 0.02, you will see that it is possible to achieve
reasonably close agreement between the calculated and measured scod and
cod. However, it is important to realize that this value results in a very small
ss value being calculated. This may be correct, though it is probably
unrealistically low given the BOD of 210 mg/l. As an alternative, try
adjusting the fss up to 0.1, which is in a typical range for this parameter.

18. Adjust the fbod value and see how the dependent values change. As
you adjust fbod up, you will notice that the scod value decreases. Again a
reasonable assumption will have to be made, such that the fbod is not too
high. For this case, a value of 0.8 can be used.

Note: In reality you will characterize your influent and adjust these
unknown parameters based on the model behavior and how that model
behavior relates to what has been observed or measured at the plant. Each
wastewater is different and each will require some adjustment of these
parameters to get a characterization that results in model behavior that is
consistent with your plant behavior.

19. Adjust si down to get an approximate agreement between the calculated


scod and the measured scod.

After adjusting these values you will notice that the xnd cell is now shaded
red to indicate that xnd has gone negative. In this case you have several
options. You can, adjust total TKN, fnh, fxn or you can adjust the nitrogen
fractions of the particulate state variables. In this case (using ASM1) it is
best to stick to total TKN, fnh and fxn, unless you have a measure of these
nitrogen fractions. Note that the calculated ammonia concentration is much
lower than the measured value.

20. Adjust the total TKN up until you get an approximate agreement
between the calculated and measured ammonia. In doing so, you will have to
substantially increase the TKN to a values which for this wastewater may be
too high.

21. Increase fnh to 0.75 and adjust total TKN to get an approximate
agreement. Note that this TKN may be more in keeping with a wastewater of
this strength.

22. Return to the GPS-X influent object forms and adjust the
parameters on those forms to the values determined using Influent Advisor.
ALL PARAMETERS NOT SHOWN ON THE INFLUENT ADVISOR SHEET
SHOULD BE SET TO ZERO. Figure 3-6 and Figure 3-7 show the completed
forms.
Influent Data and Influent Advisor 45

Figure 3-6 Influent composition for a determined by Influent Advisor


and entered into the GPS-X forms.
46 GPS-X Tutorial Guide

Figure 3-7 Influent Stoichiometry as determined by Influent Advisor


and entered into the GPS-X forms.

23. Check the influent data by clicking Start with the Steady State
checkbox unchecked, and Stop: set to 0. If a warning is printed, refer to the
Influent Advisor sheet and make sure that the data has been entered correctly
into the GPS-X data forms.

24. Check the entered data and the resulting calculations by accessing
the influent object's process menu, selecting the Display Variables >
Composite Variables sub-menu. Move the cursor over the total COD menu
item and left-click. A quick display pop-up window will be displayed
showing the current value of the influent total COD. This value should agree
with the value calculated in Influent Advisor.

Model Dependency
Strictly as an exercise to demonstrate a point, you will now examine the
impact of changing the local biological model.

25. Access the influent object's process data menu and select the
Composition > Influent Stoichiometry sub-menu.

26. Change the local biological model to Mantis and Accept this form.
Influent Data and Influent Advisor 47

27. Check the influent data by clicking Start with the Steady State
checkbox unchecked, and Stop: set to 0. A warning will be printed in the Log
window.

At time= 0.00 xndinf concentration negative (-0.15)

28. Return to Influent Advisor, click on the Introduction Sheet button at the
top of the sheet.

29. Select the CNP library, the Mantis biological model and click on the
BODbased button. The appropriate sheet will be displayed. Click on the
Reset Input to Default Values button.

30. Enter the input data into this sheet as it appears on the GPS-X influent
object forms. Note that indeed as you do this xnd is negative and shaded red.

31. Attempt to rectify the problem by investigating how this parameter is


calculated in this model.

One way to fix this particular problem is to increase fxn to 0.95 from 0.9.
This redistributes the organic nitrogen from snd to xnd, and clears the
negative problem.

The reason for this difference between the Mantis and ASM1 models is the
nitrogen fractions. In ASM1, the default values are 0.086 & 0.06. In the
Mantis model, the defaults are 0.068 & 0.068. You should match the local
biological model to the biological models used downstream where possible.
This will ensure that similar defaults are used as the nitrogen fractions of
these components are not often changed from the defaults. However, if
information about these fractions is available and that information indicates
something different from the defaults, then the user should adjust the
fractions used in the reactor as well as the fractions used in the influent to
maintain consistency.

This simple exercise demonstrates how the local biological model choice is
an important component of the influent data entry.

What's Next?
You have briefly examined the procedure for entering influent data and
examining that data for possible consistencies using Influent Advisor.

Further investigation of the plant under stress conditions can be carried out.
In order to do so, the next tutorial will introduce the aspects of inputting and
outputting time series data.
48 GPS-X Tutorial Guide
Data Input and Output 49

TUTORIAL 4

Data Input and Output

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

Interactive controllers provide an easy-to-use method for exploring the


dynamic response of the model. However, in most modelling 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 flowrate to the plant over a period
of time. GPS-X facilitates the input of this data so that the model will be
used under real conditions.

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

Saving dynamic simulation results to a text data file


Using a data file as an input to control simulations
All GPS-X users can complete this tutorial as it only requires the GPS-X
Simulator module.
50 GPS-X Tutorial Guide

Saving the Dynamic Response of a Simulation

1. Open the layout built in Tutorial 1 and save it as `tutorial4 using


the Save As... command from the File menu. After saving, rebuild the layout.
Alternatively, you can open the tutorial4 layout located in the GPS-X
tutorial directory. This file can also be accessed from the `Start' menu.

2. Display the Simulation Control window and Load the model.

3. Set up a new scenario for a step_feed case study. Create a new scenario
named step feed as described in Tutorial 2 (Step 10).

4. Alter the influent distribution to the plug-flow tank by selecting the


plug-flow tank's Parameters > Operational sub-menu from the plug-flow
tanks' process data menu. Scroll to the bottom of the form to view the
Internal Flow Distribution sub-section (Figure 4-1). Click on the array button
[(...)] to the right of influent fractions. This will open a form showing the
four influent distribution fractions for the plug-flow tank. Change the first
fraction to 0 and set the third fraction to 1.0 (Figure 4-2). This means that
influent flow will be directed to the third tank rather that the first tank.
Accept this form and Accept the Operational form. The changes made to the
model for this scenario can be seen by selecting Show... from the Scenarios
menu in the Simulation Control window (Figure 4-3).

Figure 4-1 Selecting the influent fractions.


Data Input and Output 51

Figure 4-2 Specifying the influent fractions.

Figure 4-3 List of changes for the step-feed scenario.

5. Next we will create a data file containing a storm that can be re-used in
order to test the plant under the step_feed scenario that was just created. In
the Output Setup window, there is a box under the column heading Save
adjacent to every item to be displayed. Tag the box next to the flow item and
Accept the window. This will save the influent flow data from any
subsequent simulation to a text-based (ASCII) data file (the file will have the
naming convention of: <layout name>_<scenario name>_<time stamp>.out,
where, <timestamp> = yyyy_mm_dd).

Figure 4-4 shows the completed Output Setup form. When you vary the
influent flow rate using the interactive controller, this flow data will be saved
to the output file and can be used as an input for future simulations.

6. Show and Autoarrange the Controls and Outputs.

7. Perform a two-day simulation (with Steady State enabled), but after


approximately half a day, simulate a storm event by increasing the influent
flowrate using the interactive controller. Bring the flowrate back to normal
before the end of the two-day simulation. If the simulation is too quick for
52 GPS-X Tutorial Guide

you to develop a realistic storm, try increasing the Delay time on the
Simulation Control window to 0.5 seconds and rerun the simulation.

Figure 4-4 Saving output data.

8. Unload the model to properly close the newly created data file. If you
look in the directory that contains your layout you will see a new file with the
name:

tutorial4_step_feed_1994_11_01.out

where tutorial4 is the name of your layout, step_feed is the name of


the scenario, and 1994_11_01 is the default simulation date at time = 0.
(This default date can be changed under Options > General Data > System >
Parameters > Simulation Setup.)

Using a Data File as an Input


9. You should now open the output file in order to see what it looks like.
WordPad (or Notepad) is recommended for this step, though any text editor
will work. The file contains a header line which is space delimited. The
label t represents time, while qinf represents the influent flowrate. You
now need to change the qinf label in the header line to read qconinf
which represents the model variable that controls the influent flowrate. Your
header line should now read:

t qconinf

10. Save this file under the same name, but with a new file extension of
.dat rather than the original .out. If using WordPad, make sure the `Save
as type' field on the Save As window is set to `Text Document'. Figure 4-5
illustrates an example of a completed storm data file. You now have a data
file containing the same storm flows that you just simulated. Close the text
editor.
Data Input and Output 53

Figure 4-5 Editing the .out file and saving it as a .dat file.

11. Load the model.

12. Change the type of flow controller from Slider to File Input in the
Controls Setup window. Accept the Controls Setup window (Figure 4-6).
Show the Controls and Outputs, and Autoarrange the windows.

Figure 4-6 Setting the controller type to File Input.

13. Load the model (if not already loaded), and select your step_feed
scenario from the Scenario: drop-down menu. Check the Steady State
checkbox and Start a two-day simulation. You will notice that the influent
flowrate slider has changed to an indicator which displays the flow values as
they are read from the data file. This is also reflected on the graph window
where the storm is reproduced exactly as it was generated (Figure 4-7).
54 GPS-X Tutorial Guide

It would now be interesting to investigate the effects of the storm on the


sludge blanket height, effluent suspended solids and MLSS concentrations.

14. Create an output window for the MLSS (found through the plug-flow
tank's effluent stream - Display Variables > Composite Variables menu),
effluent suspended solids (clarifier effluent stream - Display Variables >
Composite Variables menu) and sludge blanket height. Sludge blanket height
can be tagged in the Display Variables > Clarifier Variables menu accessed
through the final clarifier effluent stream. The outputs can all be put on the
same graph by using the same number in the Outputs Setup window. Try
running simulations with different step feed combinations.

Figure 4-7 Controller and graph showing the storm event and its impact.
Data Input and Output 55

What's Next?
You have briefly examined the procedure for using data files as input to your
simulations, as well as saving the time dynamic response (or "output") of the
model in the context of investigating plant performance under storm
conditions. Although you saved only the influent flowrate, the procedure is
identical for saving other variables such as effluent TSS, DO, etc. These
files can then be opened with other software packages for post processing or
presentation.

The next tutorial will introduce the procedure for setting up automatic
process control algorithms to simulate their implementation at a plant for
process improvements.
56 GPS-X Tutorial Guide
Using Automatic Controllers 57

TUTORIAL 5

Using Automatic Controllers

Problem Statement
Automatic process control is well established in many applications ranging
from large refineries using multivariate model-based control to climate
control of buildings using simple on/off control. Wastewater treatment
plants are no exception. The implementation of even basic automatic control
should improve performance and save money. In GPS-X, the user can
simulate the effects of automatic process control1.

To improve and stabilize operation, as well as realize energy savings, you


decide to implement MLSS and dissolved oxygen control. You will do this
by incorporating MLSS and DO controllers into your system.

Objectives
This tutorial will show you how to setup an MLSS controller to
automatically adjust the bio-solids wastage rate in order to meet the specified
MLSS set point. This tutorial also will show you how to setup a dissolved
oxygen controller that automatically changes the aeration rate in order to
meet the dissolved oxygen set point.

Implementation of the controllers requires the GPS-X Builder module. Users


who do not have the GPS-X Builder module should open the tutorial5
layout located in the GPS-X tutorial directory. This file can also be accessed

1
For more detailed controller design, an additional GPS-X module, which uses MATLABs Control
System Toolbox, is available.
58 GPS-X Tutorial Guide

from the `Start' menu. After doing this, these users can proceed to Step 8, or
skip the section on MLSS control and proceed directly to the section on DO
control.

Setting up an Automatic MLSS Controller

1. Open the layout completed in Tutorial 1 and save it as `tutorial5


using the Save As... command from the File menu. If you no longer have a
copy of this layout you can find it in the GPS-X tutorial directory. As we
will be defining new variables for MLSS control, make sure that you DO
NOT load the executable model into memory (i.e. don't use the Load button
in the Simulation Control window). If the model is already loaded, simply
unload it by clicking on the Unload button located in the Simulation Control
window.

Figure 5-1 Setting up the MLSS Control (a).

2. Identify the manipulated variable for the MLSS controller. The most
logical variable for this is the wastage flowrate, which in this case, is the
pumped flow from the clarifier. Some of the pumped flow control
parameters are found in the secondary clarifier Parameters > Operational
form. Turn the Pumped Flow controller ON. Additional pumped flow control
parameters are found on a subsequent form displayed using the More... button
found at the bottom of the Pumped Flow sub-section. Initially your forms
Using Automatic Controllers 59

will appear slightly different than the ones shown in Figure 5-1and Figure 5-
2; however, you are going to modify your forms to resemble those shown.

Figure 5-2 Setting up the MLSS Control (b).

3. Define the control variable for the MLSS controller. In the secondary
clarifier Parameter > Operational > More... form, type xmlss, (the variable
which corresponds to the MLSS in the aeration basin effluent stream) in the
text field next to the control variable label. If this stream is not labelled as
mlss in your layout then the variable name you will need to type is
x<stream label> where <stream label> is the plug-flow tank
effluent stream label.

4. Set the controller tuning constants by entering 0.05 days as the


controller sampling time (this represents the frequency with which the
controller samples the control variable, or MLSS in this case). The controller
effect on control variable - direct should be turned OFF. This means that the
manipulated variable, the wastage flow rate, is increased in order to reduce
the control variable, MLSS. (A different control loop such as air flow and
DO concentration would require the controller effect on control variable -
direct switch to be turned on as an increase in the manipulated variable, air,
would result in an increase in the control variable, DO.)
60 GPS-X Tutorial Guide

5. Tag the tuning constants (proportional gain, integral time and derivative
time), so that they can be set-up on an interactive controller (Figure 5-1 and
Figure 5-2).

6. Set the maximum pumped flow rate to 200 m 3 /d and Accept this form
(Figure 5-2).

7. Set the setpoint for the control variable (in the Parameters > Operational
form, Figure 5-1) to 2000 mg/l. Tag the setpoint for control variable and the
controller ON-OFF switch so that they can be set up on an interactive
controller. Accept this form, Save your layout and Build the model.

Tuning the Automatic MLSS Controller


8. Define a new interactive control window as described in Tutorial 1 and
set-up the window with the controller constants (proportional gain, integral
time and derivative time), the MLSS setpoint and the controller switch
(Figure 5-3). Set the minimum and maximum for setpoint for control
variable, proportional gain, integral time and derivative time to 0-4000 g/m3,
0-50, 0-10 d and 0-10 d, respectively.

9. Define a new output graph as described in Tutorial 1 and set-up the


MLSS, the influent flowrate and the wastage flowrate on the same output
graph. The output variable (MLSS) can be tagged in the Display Variables >
Composite Variables form of the plug-flow tank effluent stream. Set the
minimum and maximum for MLSS concentration, influent flow and wastage
flow to 0-5000 g/m3, 0-5000 m3/d and 0-500 m3/d, respectively.

Figure 5-3 MLSS interactive controls.

10. Run a 10-day dynamic simulation with a sinusoidal influent flow


pattern (see Tutorial 2 if you have forgotten how to do this) and the
controller turned ON.
Using Automatic Controllers 61

Initially, you will find that the manipulated variable oscillates wildly between
its minimum and maximum values. This is a controller tuning problem. It is
usually possible to obtain reasonable controller performance by trial and
error. In this example, one may conclude that the controller gain is too large.
One option for tuning this controller by trial-and-error is as follows:

Start with a low proportional gain (0.001), high integral time, (10
days), and low derivative time (0 days). This creates a sluggish
but stable controller.
Watch how the wastage rate changes to counteract the effect of a
disturbance (e.g. influent flow rate). If it does not react quickly
enough, try increasing the proportional gain. Continue to
increase the proportional gain until you get a reasonably
responsive control effect, but still a stable response.
If the wastage rate becomes unstable (wild oscillations) decrease
the proportional gain.
With the proportional effect stable, try decreasing the integral
time to increase the performance of your controller.
If there is too much overshoot, try increasing the derivative time.
A simplified understanding of the three elements of a PID controller is: fast,
persistent and predictive for the P, I and D terms respectively. Remember
that automatic process control is not a simple subject and it may not be
possible to achieve the level of control that you desire. Consider the process
time constant of the MLSS in the aeration basin. It takes several days for a
plant to reach a new steady-state given a change in wastage rate, while the
plant upsets (changes in the influent flow rate) that can have a dramatic effect
on the MLSS can occur in a matter of hours or even minutes.

There are several published approaches for finding good initial tuning
constants for PID controllers. One approach is to use the Ciancone
correlations (Marlin, 1995) which are included in GPS-X's PID tuning tool.
The Ciancone correlations provide the tuning constants given the gain, time
constant, and dead time of the process, under the assumption that the process
dynamics may be represented with reasonable accuracy by a first-order plus
dead time model. In GPS-X's PID tuning tool, the process response to a step
change in the manipulated variable is fit to a first-order plus dead time model
using least squares (in tuning mode). The Ciancone correlations are then
used to determine the appropriate values for the tuning constants.

11. Activate the pumped flow control tuning mode, by creating a new
scenario in the Simulation Control window as described in Tutorial 2. In
the final clarifier Parameters > Operational form (under the Pumped Flow
more... button, under Pumped Flow Control Tuning) turn the tuning
switch ON. The fractional step size can be specified on that form and can
be a positive or negative value. In this case, set the pumped flow value of
80 m 3 /d and a fractional step size to 0.5. This fractional step size
corresponds to a step in pumped flow rate from 80 m 3 /d to 120 m 3 /d.
Accept all the operational forms.
62 GPS-X Tutorial Guide

12. Start a 0-day steady state simulation with the newly created scenario
and turn the MLSS controller turned ON. Once this is complete, turn the
MLSS controller off using the ON-OFF control switch1 and run a 10-
day dynamic simulation.

The simulation performed in tuning mode is shown in Figure 5-4. The


essential characteristics of a successful tuning mode simulation are:

(i) it must be started under steady-state, with values of the manipulated


(pumped flow) and control (MLSS) variables representative of normal
operating conditions,

(ii) the simulation should last long enough to capture most of the process
dynamics (i.e. the simulation should end at steady-state, or be
approaching steady-state), and

(iii) the step in the manipulated variable should be large enough to


dominate other "noise" that affects the controlled variable (in this case
the sinusoidal influent flow pattern).

Figure 5-4 Tuning mode simulation.

At the end of the simulation, PID tuning constants will be calculated (this
may take several seconds), and will appear in the log window. A notification
will appear on screen when the calculation is complete (Figure 5-5). The log
window can be opened by checking the Log checkbox in the View menu of
the Simulation Control window.

1
For the tuning mode to operate properly, the controller sampling time must be set to a reasonable value,
e.g. the execution time of the controller to be implemented. This is why the controller sampling time was
left as 0.05 days.
Using Automatic Controllers 63

Figure 5-5 Calculated PID tuning constant.

13. After setting the controller tuning constants to these values, (under
Parameters > Operational) turn the tuning mode OFF and turn the MLSS
controller ON. The simulation shown in Figure 5-6 was performed using
these tuning parameters for the MLSS controller. The MLSS setpoint was
2000 mg/l and a decrease in the average level of the influent flow rate was
introduced to test the performance of the controller under these conditions.
64 GPS-X Tutorial Guide

Figure 5-6 Simulation with MLSS controller.

Using an Automatic DO Controller


14. Open the Tutorial (Start) layout from the Tutorials5 directory by
selecting Hydromantis GPS-X 4.1 > Tutorials > Tutorial5 > Tutorial
(Start) from the Start Menu. Display the Simulation Control window and
Load the model. The model by default uses the oxygen mass transfer
coefficient (KLa) as the aeration driving function, so that the KLa is the
manipulated variable in the case of DO control. In order to turn the DO
controller on, a Scenario should be defined.

15. Create a new Scenario as described in Tutorial 2.

16. Turn ON the plug-flow tank's DO controller by opening the


Parameters > Operational form of the plug flow tank. The DO control switch
is the first item in this form (Figure 5-7). The default is OFF and so this
switch must be switched ON before the controller will operate. Switch it on
and tag the DO controller so that it will be controllable during a simulation.
Using Automatic Controllers 65

Figure 5-7 Setting up a DO controller.

The other important item in this form is the DO setpoint array button [(...)].
By clicking on the array button, another form will appear showing the
setpoints. The default setpoints are all set to 2.0. At this point you should
tag the first and last setpoints (see Figure 5-8) so that they can be put on an
interactive control window. Accept all forms.

17. Set the controller sampling time (found on the plug-flow tank's
Parameters > Operational > Aeration Control More... form) to a shorter time
(say 0.001 days, which is approximately 1.5 minutes). Accept all forms.
66 GPS-X Tutorial Guide

Figure 5-8 DO setpoints.

18. Define a new interactive control window as described in Tutorial 1 and


set-up the window with the DO controller ON-OFF switch and the two DO
setpoints. Set the minimum and maximum values of the DO setpoints to 0
and 5 gO2/m3, respectively.

19. Define a new output graph as described in Tutorial 1 and set-up the
graph to display the dissolved oxygen concentration in the first and fourth
tanks of the plug-flow tank and the effluent free and ionized ammonia. The
dissolved oxygen variables can be tagged in the Display Variables > State
Variables > dissolved oxygen > [(...)] form (Figure 5-9 and Figure 5-10) of the
plug-flow tank (ensure that you do not click on a connection point to or from
the tank as in this case we want variables internal to the object). Accept both
forms. Tag the free and ionized ammonia variable in the Display Variables >
State Variables form of the plug-flow tank effluent stream. Use similar
min/max ranges as above for the setpoints.

20. Show both the Controls and Outputs and Autoarrange the windows.
Ensure that both the MLSS and DO controllers are turned ON.

21. Run a simulation, varying the influent flowrate and the DO setpoints.
The automatic controller behaves quite well with the default tuning
constants.
Using Automatic Controllers 67

Figure 5-9 DO display variables.

Figure 5-10 Tagging DO for display.


68 GPS-X Tutorial Guide

What's Next?
You have finished a brief explanation of the automatic process control
features within GPS-X. Although we have only looked at two control loops,
you can setup many more using the built-in control forms for any of the
object pumped flows. This essentially means that any user specified pumped
flowrate can be setup as a manipulated variable in order to maintain a control
variable at its set point.

The next tutorial examines the use of the GPS-X Define feature for creating
special variables which are plant layout dependent. This tutorial will require
the GPS-X Builder module.

Reference
Marlin T.E., Process Control: Designing Processes and Control Systems for
Dynamic Performance, McGraw-Hill, 1995.

1. For more detailed controller design, an additional GPS-X module which uses MATLAB's
Control System Toolbox is available.
2. For the tuning mode to operate properly, the controller sampling time must be set to a
reasonable value, e.g. the execution time of the controller to be implemented. This is why the
controller sampling time was left as 0.05 days.
The Define Function 69

TUTORIAL 6

The Define Function

Problem Statement
Some important operational variables in a wastewater treatment plant are site
specific and difficult to generalize. These variables include sludge residence
time (SRT) and food-to-microorganism ratio (F/M). In addition, other
calculations, such as daily averages, moving averages, and mass flows are
applied to most water quality parameters throughout the plant.
Consequently, it is desirable for any wastewater treatment plant model to
contain these traditional process variables, and GPS-X provides you with this
capability.

Objectives
This tutorial will show you how to define operational variables such as SRT.
In addition, mathematical operations such as averaging and flux calculations
will be demonstrated. These operations are centered around the Define
function (Tools > Define menu or the Define button located on the GPS-X
toolbar). This tutorial requires the GPS-X Builder module.

Setting up the Layout


1. Develop a new layout consisting of an influent object, control-splitter,
plug flow basin, rectangular secondary clarifier and a combiner. Use CN
library. The completed layout with the stream labels is shown in Figure 6-1
(if you are not licensed for the full library set of objects, you do not have
70 GPS-X Tutorial Guide

access to the control-splitter object, so you will have to open the pre-built
layout from the GPS-X tutorials directory). You should edit the stream
labels of your unit process so that they are the same as those in Figure 6-1.
Labels can be edited via the Labels... item of the object's process menus. The
control-splitter unit process will be used to simulate a bypass weir.

Figure 6-1 The Define Function layout.

2. Assign appropriate models to the objects and use the bodbased influent
model, the mantis plug flow tank model and the simple1d rectangular clarifier
model.

3. Set the clarifier operational parameters by setting the recycle fraction


as 80% of the influent flow rate. This is done through the clarifier's
Parameters > Operational menu. Switch `on' the proportional recycle switch
and in the space next to location to which recycle is proportional replace
`blank with the name of the influent stream to the aeration tank. In
Figure 6-1 this is labelled `inf. The default value for the recycle fraction
is already 0.8 so it is not necessary for you to change it. These changes to the
operational parameters are depicted in Figure 6-2.
The Define Function 71

Figure 6-2 Proportional recycle set-up

4. Specify a value for the pumped flow (which will be used as the wastage
rate) by changing the default pumped flow value from 0 to 100. Accept this
form.
72 GPS-X Tutorial Guide

Defining Mass Flows


5. Specify a mass flow on the effluent solids using the Define feature. This
mass flow is defined as the effluent suspended solids multiplied by the
effluent flow rate. Click on the Define button to display Define drop-down
menu. Select Mass Flow from the list, and the Status Bar at the bottom of the
main window will indicate Mode: Define - Mass Flow (Figure 6-3).

Figure 6-3 Defining a Mass Flow.

Right-click the plant effluent stream leaving the final clarifier (eff label)
and choose the Defined Variables > Composite Variables menu item. Tag total
suspended solids and Accept this form. Repeat this procedure for the total
suspended solids in the plant bypass stream, and for suspended solids in
the stream labeled discharge.

6. Exit Define Mode by clicking on the Define button again to uncheck the
Define Mode checkbox. The Status Bar message should revert to Mode: Edit.

7. Define a new output graph as described in Tutorial 1 and set-up the


three mass flows on a graph. Right-click on the clarifier eff stream and
The Define Function 73

select the Display Variables > Defined Variables > Mass Flow menu item. Tag
the Mass Flow.total suspended solids variable and Accept this form. Repeat
this procedure for the bypass and the discharge streams. Set the
minimum and maximum mass flows on that graph to 0 and 1,000,000
respectively (Figure 6-4).

Figure 6-4 Mass Flow output graph set-up.

8. Define a new interactive control window as described in Tutorial 1 and


set-up the window with the influent flow rate on an interactive controller
(slider type) with a maximum of 10 000 m3/d.

9. You should now Save the model and Build the layout.

10. Load the model and set the Stop time to 2 days. Show the Controls and
Outputs and Start the simulation.

11. Increase the influent flow rate and notice that when the influent flow
rate is above 2000 m 3 /d (the default pump flow rate for the CONTROL
SPLITTER object), some flow will begin to bypass the plant and show up in
the bypass stream. You can try changing the bypass flow limit by increasing
the pumped flow rate in the CONTROL SPLITTER object. To prevent having
to re-build the model, this must be done either by defining a scenario or by
placing the bypass pump flow on an interactive controller.

12. Re-run the simulation and try to reduce the total mass flow of solids
discharged to the receiving water.
74 GPS-X Tutorial Guide

Defining an SRT
In this section you will learn how to calculate and display SRT, the solids
residence time in the system.

13. Unload the model and click on the Define button.

14. Define the SRT calculation by choosing SRT from the define list as
described above. Point to the aeration basin and click on it. An SRT
equation will appear in the Status Bar (bottom left hand side of the drawing
board) as shown in Figure 6-5.

Figure 6-5 Defining the SRT equation.

There are two parts to the equation. The numerator is the mass section of the
equation, and it includes the mass of solids held in each tank. Typically SRT
calculations only include the mass of solids held in the aeration basin, but it
is also possible to calculate SRT by summing the mass in the aeration basin
and the final clarifier. While the SRT equation is shown, every time you
click on a tank the mass of solids in that tank will be included in the SRT
The Define Function 75

calculation. As you first pointed at the aeration basin, the mass of solids in
the aeration basin is already included in the calculation. If you click on the
clarifier, its label (eff) is added to the numerator of the equation indicating
that the mass of solids contained in the clarifier is now part of the SRT
calculation.

You also need to define the denominator part of the equation, the excess
solids mass flow lines that are used to calculate SRT. This is done by
pointing to the flow lines which convey solids out of the system. Typically
this will only include the waste flow. If you point to the waste flow line (the
cursor will change to the block connector arrow), you will see a label
representing the waste flow line, was, appearing in the denominator of the
SRT equation. For this example, we will also include the solids flux in the
effluent line by clicking on the clarifier effluent stream (labeled eff). The
SRT equation should now look like this:

Solids Residence Time mlss=mass(mlss,eff)/Mass Flow(was,eff)

15. Click on the aeration basin to accept the equation. A window will
appear with the defined equation. Accept this window if the equation is
correct or Discard this equation if you have made a mistake. Unselect the
Define checkbox.

16. Set up SRT as an output parameter and display it on a graph. Do this


by right-clicking on the mlss stream (the block arrow should appear) and
choose Display Variables > Defined Variables > Solids Retention Time menu
item. Tag the Solids Retention Time variable. Figure 6-6 shows the tagged
SRT variable.

17. Define a new output graph as described in Tutorial 1 and set-up the
SRT variable on it with appropriate limits (e.g. 0 to 50 days).

Figure 6-6 Tagging SRT as an output variable.

18. Define a new interactive control window as described in Tutorial 1 and


set-up the window with the wastage flow rate on an interactive
controller. It is located in the clarifier's Parameters > Operational form.
You can assign it to the existing control window (i.e. Influent Flow).

19. BUILD the model.

20. Try running a few simulations, observing the SRT as you change the
amount of solids being wasted out of the system. After you are finished,
UNLOAD the model.
76 GPS-X Tutorial Guide

Defining Averages
The procedure for defining averages is similar to setting up mass flow
calculations. In addition, averaging calculations can also be applied to a
defined mass flow, SRT, or F/M ratio. Here, you will apply averaging
calculations to the Mass Flow in the discharge stream defined above.

21. Click on the Define button and select Daily Average. Now right-click
on the discharge stream and select the Defined Variables > Defined
Variables > Mass Flow menu item. Tag the mass flow variable and Accept the
form. You have now set up a daily average calculation for the mass flow of
suspended solids in the discharge stream.

22. Use the same procedure and define a moving average for the mass
flow of suspended solids in the discharge stream. Click on the Define
button and select Moving Average. Now right-click on the discharge
stream and select the Defined Variables > Defined Variables > Mass Flow menu
item. Tag the mass flow variable and Accept the form. Turn `off' Define
Mode.

23. Select the moving average and daily average for display. You will
notice in the display menu for the moving average (from the discharge
stream, Display Variables > Defined Variables > Moving Average) that a number
will appear to the right of the variable name (see Figure 6-7). This number
represents the number of communication intervals (Communication in the
Simulation Control window) that are used in each moving average calculation.
For example, if the number in the Moving Average window is 100, and the
Communication interval is 0.05 days, then the moving average calculation
will use data from the previous 5 days (100 x 0.05 days).

Figure 6-7 Moving average.

24. Define a new output graph as described in Tutorial 1 and set-up the
moving average and daily average for display using a maximum limit of
1,000,000 for both variables.

25. BUILD the model.

26. Run the model and change the influent and wastage flow rates to
observe the moving and daily averages.
The Define Function 77

Controlling SRT with Waste Pump Rate


In Tutorial 5, you learned how to create a PID controller for MLSS control.
This controller was based on maintaining a constant MLSS in the aeration
basin. As an optional exercise, you can set up the waste pump rate to control
SRT. This is done by opening the clarifier's Parameters > Operational form.
In the Pumped Flow sub-section, turn the controller to On and set the setpoint
for control variable to 5 days. Set the pumped flow control variable (select
More... at the bottom of the Pumped Flow sub-section) to `srtmlss as
shown in Figure 6-8. Note also that the Controller effect on control var - direct
should be set to Off and the other parameter values should be set to the values
shown in Figure 6-8. By setting the controller effect to Off, the controller
gain will be taken as negative. This will cause the SRT to decrease as the
wastage rate is increased. You now need to Save and Build the layout. When
running this model, you may find you need to adjust the control constants to
ensure stable operation in a similar manner as suggested in Tutorial 5. Setup
the SRT and wastage flow rate on an output graph in the same way you did
earlier in this chapter.

Figure 6-8 Setting up SRT as a control variable.


78 GPS-X Tutorial Guide

What's Next?
You have now navigated through the use of the Define function. Although all
the possibilities for its use have not been demonstrated, you should have a
basic understanding of its function. The next tutorial examines the
sensitivity analysis tool which requires the GPS-X Analyze module.
Sensitivity Analysis 79

TUTORIAL 7

Sensitivity Analysis

Problem Statement
With any model, one of the first exercises to carry out is a sensitivity analysis
of the model parameters. There are two reasons for doing so: 1) to validate
the model results and 2) to identify parameters to be adjusted during
calibration. The former reason should allow the modeler to develop some
confidence in the model so that it behaves in an expected manner. For
example, lowering the air flow rate to the aeration basin should result in a
lower dissolved oxygen concentration. The latter reason for performing a
sensitivity analysis, parameter identification, is useful because it helps
determine the parameters that have the most impact on the model response.
We do not want to adjust parameters during a calibration run that have little
effect on the model behavior.

After the model is calibrated and verified, sensitivity analyses are useful for
other reasons. Mathematical models can be revealing, sometimes allowing
us to explore operational strategies that might never have been contemplated
otherwise. In this chapter, you will explore the steady-state and dynamic
sensitivity of a basic model.

Objectives
The purpose of this tutorial is to see how we can extract as much information
as possible from a GPS-X model. By the end of this tutorial you should have
developed a working knowledge of the Analyze functions. This includes
setting up and running steady state, phase dynamic, and time dynamic
80 GPS-X Tutorial Guide

sensitivity analyses. By completing this tutorial, you will also learn how to
interpret the results from these simulations.

Users who wish to complete this tutorial must have the GPS-X Analyzer
module. The Builder module is not necessary.

Setting Up the Layout


Because this GPS-X feature requires multiple simulations, for demonstration
purposes the work will be carried out on a simple model consisting of an
influent, a two-way combiner, a CSTR, and a circular final clarifier.

If you do not have the GPS-X Builder module, open the layout by selecting
Hydromantis GPS-X 4.1 > Tutorials > Tutorial7 > Tutorial (Start) from
the Windows Start menu and proceed to the next section below. If you have
the GPS-X Builder module you may prefer to reconstruct the layout yourself
(use the CN library). The layout should resemble that shown in Figure 7-1,
with a bodbased influent model, mantis CSTR model and simple1d clarifier
model. Remember to define a wastage flow, say 40 m 3 /d, in the secondary
clarifier (the pumped flow under the Operational parameters). Save and Build
this new layout.

Setting Up the Parameters for Analysis


1. Create a new scenario and set up a sinusoidal influent flow and load
pattern by specifying Sinusoidal for both the influent Flow > Flow Data > flow
type parameter and the influent Composition > Load Type Options > loadtype
parameter.
Sensitivity Analysis 81

Figure 7-1 Layout for the tutorial.

2. Place the influent flow and the oxygen mass transfer coefficient (KLa)
on an interactive control window. The influent flow variable can be tagged
from the influent object Flow > Flow Data form, and the oxygen mass transfer
coefficient can be tagged on the CSTR object Parameters > Operational form.
Assign both parameters to a new control window, with limits of 0-10,000
m3/d for the influent flow and 20-120 d-1 for the KLa.

3. Set-up for display the effluent ammonia and BOD concentrations, as


well as the DO and KLa in the aeration tank. The effluent free and
ionized ammonia variable is found on the clarifier effluent stream's Display
Variables > State Variables form. Similarly, the total carbonaceous BOD5
concentration is found in the clarifier effluent stream's Display Variables >
Composite Variables form. The dissolved oxygen in the aeration basin can be
tagged from the CSTR's Display Variables > State Variables form, while the
oxygen mass transfer coefficient can be tagged from the CSTR's Display
Variables > Parameters > Operational form. Place these outputs on four
separate graphs. Use limits of 0-10 gO2/m3 for DO, 0-150 d-1 for KLa, 0-50
gO2/m3 for CBOD5, and 0-20 gN/m3 for NH3. Run a one day simulation
(with Steady State checked) to verify that the model is working.

Steady-State Analysis
You will now carry out a steady state sensitivity analysis of the oxygen
transfer coefficient on the dependent variables that you have selected for
display (DO, CBOD5, NH3).
82 GPS-X Tutorial Guide

4. In order to carry out the analysis, set the mass transfer coefficient as an
Analyze type in the Controls Setup form, ensuring that there is a delta value
of 20 which sets the variable increment for the analysis (see Figure 7-2).

Figure 7-2 Setting up the independent variable.

5. If the model is not Unloaded, do so now. Now re- Load the model and
select your sinusoidal scenario.

6. Now click on the Controls icon to display the controls and then click
on the Outputs icon to display the output graphs.

7. Arrange the windows by clicking on the Autoarrange icon.

8. Select Steady State from the Analyze drop-down menu (see Figure 7-3)
and then click on the Analyze icon (in the GPS-X toolbar) to switch to
analyze mode.

9. Start a 0-day simulation (the steady state option will be checked


automatically by the software).

The analysis will not work if you show the outputs before showing the
controls. Observe the effect of an increase in KLa on DO and the effluent
CBOD5 and NH3. Typical results are shown in Figure 7-4. Note that a value
of 58 d -1 for the oxygen mass transfer coefficient results in a DO level of 2.0
gO2/m3. Try the analysis using different influent flows.
Sensitivity Analysis 83

Figure 7-3 Select steady-state analysis.

Figure 7-4 Analysis results.


84 GPS-X Tutorial Guide

Time Dynamic Analysis

You will now carry out a time dynamic sensitivity analysis of the oxygen
transfer coefficient on the dependent variables that you have selected for
display (DO, CBOD5, NH3).

10. Unload the model in order to turn off the analyze mode. Load the
model again and select your scenario containing the sinusoidal influent.

11. Select Options > Preferences > Run and change the Number of runs
displayed to 10.

12. Show first the control windows, and then the output graphs (again,
the order is important).

13. Arrange the windows by clicking on the Autoarrange icon.

14. Select Time Dynamic from the Analyze menu and then click on the
Analyze icon to switch to analyze mode.

15. Start a one-day simulation with steady state checked. The results of
this simulation are shown in Figure 7-5.

Each successive curve on the various graphs is the result of a dynamic


simulation using a specific KLa. Notice in Figure 7-5 that for increasing
values of KLa, the DO concentration in the aeration tank increases - it also
fluctuates over time because of the sinusoidal influent flow and load patterns.
Sensitivity Analysis 85

Figure 7-5 Typical results from a time dynamic analysis. Six dynamic runs
for kLa values ranging between 20 and 120 d-1 in increments of 20 d-1.

Phase Dynamic Analysis


You will now carry out a phase dynamic sensitivity analysis of the oxygen
transfer coefficient on the dependent variables that you have selected for
display (DO, CBOD5, NH3).

15. Again Unload the model to turn off the time dynamic analyze mode.
Re- Load the model and select your sinusoidal scenario.

16. Show the control windows and output graphs.

17. Arrange the windows by clicking on the Autoarrange icon.

18. Select Phase Dynamic from the Analyze drop-down menu and click on
the Analyze icon to switch to analyze mode.

19. Set the simulation time to 1.0 day (with Steady State checked so that
the initial conditions are at steady state) and Start the simulation.

This type of analysis allows you to run the same dynamic simulation as in the
previous step. The only difference is in the graphical display. Here the
results will be plotted against the analyze variable and not against time. The
length of the simulations will set the phase. Typical results are shown in
86 GPS-X Tutorial Guide

Figure 7-6 for a sinusoidal influent. In this case, the results are very similar
to the Steady State analysis type since the simulation was not very dynamic.
The graph shows the DO concentration after 1.0 day for a KLa of 20.0 to
120.0 d -1 (as opposed to showing the steady-state value when carrying out
the Steady State analysis).

Figure 7-6 Typical results from a phase dynamic analysis.

What's Next?
This tutorial has concentrated on the procedure for setting up the three
different types of sensitivity analysis. You should now feel comfortable to
do this and may wish to take some time to carry out further analyses on
different model parameters. The next tutorial examines the use of the GPS-X
Optimize module. This includes selecting the parameters to be optimized, the
objective function, and the control of the optimizing routine.
Parameter Optimization 87

TUTORIAL 8

Parameter Optimization

Problem Statement
Model calibration and verification is one of the most important components
of any modeling project. Model calibration, also known as parameter
estimation, is defined as the process of adjusting model parameters such that
the difference between observed and simulated results is minimized. For
example, if the difference between observed and simulated effluent
suspended solids is too large, it is likely that you will want to adjust some of
the model parameters.

GPS-X provides a very convenient way of adjusting the model parameters,


based on a non-linear dynamic multi-parameter optimization algorithm
(Nelder-Mead simplex method).

In this example, the estimation of two kinetic parameters (heterotrophic


growth rate and half saturation constant) is carried out in order to fit the
model-predicted soluble substrate concentration with the measured data.
Although this is a simple example, using only a CSTR unit process, the
procedure outlined below is the important subject.

Objectives
The purpose of this tutorial is to develop a basic understanding of parameter
estimation using GPS-X. After this tutorial you will be able to target
variables that you are interested in fitting to the data, select the model
variables to be adjusted and specify the form of the objective function. Other
88 GPS-X Tutorial Guide

optimizer variables such as termination criteria and number of data points


will be explained in this tutorial.

This tutorial requires the GPS-X Builder and Optimizer modules.

Initial Manual Calibration


1. Develop a simple layout (in the CN library) consisting of a single
CSTR using the mantis process model.

2. Set the initial readily biodegradable substrate concentration to 200


gCOD/m3 from the first page of the initial concentrations form (Initialization
> Initial Concentrations, see Figure 8-1).

Figure 8-1 Initial concentrations.

3. Change the Date & Time at t = 0 by selecting the Options > General Data
> System > Parameters > Simulation Setup form. Click on the date and time at
t=0 array [(...)] and change the year to 1997, the month to 6, and the day to 15.

4. Save the model with the name tutorial8, and Build it.

5. Set the effluent readily biodegradable substrate on a graph by tagging it


on the CSTR effluent stream's Display Variables > State Variables form,
and defining and setting up the output as usual. Use limits of 0-200
gCOD/m3 for the output graph.
Parameter Optimization 89

6. Run a 0.25 day simulation with a Communication interval of 0.01 days


(make sure Steady State is not checked).

You will now optimize two kinetic parameters in order to obtain the best fit
between effluent soluble substrate data and simulation results.

7. Place the heterotrophic maximum specific growth rate and the readily
biodegradable substrate half saturation coefficient on an interactive control
window with limits of 0.5-5 d-1 for the growth rate, and 0.5-10 gCOD/m3
for the half saturation coefficient. These parameters can be found in the
CSTR's Parameters > Kinetic form.

The observed data from the plant is saved in a file called


tutorial8_optimize_1997_6_15.dat. Make sure you have this
file in the directory where you are saving your layout. You can copy it from
the \gps-x41\layouts\tutorials\tutorial8\completed
directory.

8. Try re-running the simulation, manually changing the growth rate


and half saturation parameters with the goal of minimizing the
difference between the simulated and measured data.

Automatic Calibration Using the Optimizer


After manually calibrating the model in the previous section (i.e. adjusting
the heterotrophic maximum specific growth rate and readily biodegradable
substrate half saturation coefficient parameters using the sliders and re-
running the simulation), you will now automate the calibration process of
fine-tuning these parameters. (Note that it is always advisable to carry out a
manual calibration first in order to determine the effects of parameters on the
simulated response before carrying out an optimization.).

9. Unload the model, then select the Time Series menu item from the Type
menu found in the Optimize drop-down menu (Figure 8-2).
90 GPS-X Tutorial Guide

Figure 8-2 Choosing time-series optimization.

10. Select the Maximum Likelihood option in the Objective Function sub-
menu of the Optimize drop-down menu. See the GPS-X Technical
Reference for details on the maximum likelihood objective function.

11. Switch to optimize mode by clicking on the Optimize icon or by


clicking on Optimize Mode in the Optimize drop-down menu.

12. The Target Variables must now be identified by tagging them in the
Target Variables forms. The menu items which were labeled Display
Variables previously (when in edit mode) are now labeled Target Variables.
In this example we will use the effluent readily biodegradable substrate
concentration as the target variable. This variable is located on the CSTR
effluent's Target Variables > State Variables form. After tagging this target
variable you can display it and any other target variables by selecting the
Target Variables... menu item from the Optimize drop-down menu (in this case
you should see the form shown in Figure 8-3).

Figure 8-3 Selected target variables.

Note: While in optimize mode you cannot define Display Variables for
outputs. To do so, first turn off the optimize mode by clicking on the
Optimize icon or by clicking on Optimize Mode from the Optimize drop-down
menu.
Parameter Optimization 91

13. Now you must set up the independent variables (the two kinetic
parameters) in the Controls Setup form as Optimize types (see Figure 8-4).
The Min and Max values are used as bounds on the independent variable.

Figure 8-4 Independent variables setup.

You should now set some of the optimizer parameters in the Options >
General Data > System > Parameters > Optimizer form. You can also access
this form by right-clicking anywhere on the drawing board where there are
no objects, as shown in Figure 8-5.

14. In this form, you must specify the number of optimized parameters, in
this case 2, followed by the number of data points that you wish to use
(typically you would enter the number of rows in the data file). In this
case, enter 26 for the number of data points.

Four different optimizer termination criteria can also be set. For this
example, the default termination criteria are sufficient. For an explanation of
the termination criteria see the GPS-X Technical Reference.

15. In the Optimizer form switch the detailed statistical report parameter
ON so that a statistical analysis is printed to the Log window.

16. In the Maximum Likelihood sub-section of the Optimizer form, switch


the heteroscedasticity model to ON. The heteroscedasticity model is a
power-law variance model that accounts for non-constant measurement
variance. Click on the heteroscedasticity parameters (...) button and enter a
value of 2 for the heteroscedasticity parameter. This value signifies that we
are assuming that the measurements have a constant relative error. The
heteroscedasticity parameter is the exponent used in the power law.
92 GPS-X Tutorial Guide

Figure 8-5 Choosing optimizer system parameters.

17. In the Confidence Limits sub-section of the Optimizer form, switch the
printing of confidence limits parameter to ON. When this switch is ON,
confidence limits are provided for the parameter estimates in the Log window
at the end of the optimization. The confidence level for the confidence limits
is set by the confidence level for confidence limits parameter. By default it is
set to 0.95 which corresponds to 95% confidence limits. Note that when the
printing of confidence limits is switched ON, the variance-covariance and
correlation matrices are also reported in the Log window. The correlation
matrix shows the correlation between the estimated parameters.

18. In the Portmanteau sub-section of the Optimizer form, switch the


Portmanteau test on weighted residuals parameter to ON. The Portmanteau
test checks for serial correlation (i.e. trends) in the residuals. The residuals
are the differences between the measured values and the model predictions at
each data point. If there are trends in the residuals, then the fitted model does
not account for all the non-random variability in the data. The Portmanteau
test is a type of model adequacy test.

Remember to Accept the changes in the Optimizer form.

Note: The lack of fit test is not used in this example because we do not have
replicate measurements.

19. The show process warnings parameter should be switched OFF. You
can find it in the Options > General Data > System > Parameters > Simulation
Setup form.

20. Save and Build the model and Load it in the Simulation Control
window.
Parameter Optimization 93

21. Switch to optimize mode by clicking on the Optimize icon in the GPS-
X toolbar.

22. Display first the control windows, then the output graphs.

23. You can display the Log window at this point if desired but keep in
mind that it will slow down the optimization. You may prefer to display
the Log window at the end of the optimization. To view the Log window
select View and then Log in the Simulation Control window.

24. Set the Stop time to 0.25 days, the Communication interval to 0.01 days,
and Start the simulation (Steady State should not be checked).

At each optimization iteration, GPS-X plots the simulation results (i.e.


predicted values) that correspond to the current parameter values. It retains
the 10 most recent simulations on the graph. The simulation results are
shown by a black line and the data are shown by red markers.

Note that the initial parameter values used in the optimization are the default
values found in GPS-X.

The optimization is complete when the Simulation Time counter stops


changing and the Solution Report is printed to the Log window. The solution
report includes the final parameter values and the results of the statistical
tests.

A plot of the fitted model and the measured data is shown in Figure 8-6.

Figure 8-6 Results of the optimization.


94 GPS-X Tutorial Guide

What's Next?
This tutorial has shown you how to setup and use the optimizer. Although
emphasis was placed on using the optimizer for calibration, it can also be
used for process optimization. For example, if a target value of effluent TSS
and TKN are in a data file, the optimizer could be used to determine the best
(minimum) volume to do so. The next tutorial examines the basic
customization features of GPS-X. This includes adding your own code to a
specific model layout.
Basic Customization 95

TUTORIAL 9

Basic Customization

Problem Statement
No wastewater treatment plant modeling/simulation tool can be general
enough to automatically handle ALL conceivable plant layouts or desired
variables. So, GPS-X facilitates model layout customization. This is an
advanced feature of GPS- X and requires a basic understanding of ACSL, the
simulation language upon which GPS-X is based. The potential of the tool
will be demonstrated using the following simple example.

In this tutorial you will add two equations to calculate the specific oxygen
uptake rate (SOUR) for the first stage of the plug-flow tank. One of the
equations will assume an ideal oxygen uptake rate (OUR) measurement and
the second will simulate measurement noise on the oxygen uptake rate
measurement. This variable is often used for toxicity detection and in
process control strategies.

Objectives
This tutorial is designed to introduce you to the steps required to input your
own code for a specific plant layout. You will learn how to setup the GPS-X
interface, allowing you to input and output these customized variables as if
they were part of the original layout.

The GPS-X Builder module is required for this tutorial.


96 GPS-X Tutorial Guide

Setting Up and Customizing a Layout

1. Open the layout completed in Tutorial 1 and save it as `tutorial9


using the Save As... command from the File menu. If you no longer have a
copy of this layout you can find it in the GPS-X tutorial directory. The
layout for this tutorial includes an influent object, a plug-flow tank and a
circular secondary clarifier (If not already done, construct this layout and
connect the objects as shown in Figure 9-1. Assign the influent object the
bodbased model, the plug-flow tank should be assigned the asm1 model and
the secondary clarifier should be assigned the simple1d model. As in
Tutorial 1, make sure you have changed the influent soluble
substrate/BODultimate ratio to 0.4 and influent local biological model to
ASM1. Further, make sure you have defined a wastage flow rate for the
secondary clarifier. A pumped flow rate of 40 m3 /d should be used. Also,
label the overflow stream of the plug-flow tank: mlss - see Tutorial 1, for
instructions on how to do these steps, if required).

Figure 9-1 Layout.

2. Define a new output graph as described in Tutorial 1 and set-up the


influent flow rate and plug-flow tank oxygen uptake rate on the same graph.
The influent flow can be tagged in the Display Variables > Flow form of the
influent object and the oxygen uptake rate can be tagged in the Display
Variables > Internal Variables > actual oxygen uptake rate > [(...)] form of the
plug-flow tank (Figure 9-2). In the Output Setup window, set the minimum
OUR to 15 and the maximum OUR to 25 g/m3/h. Set the minimum flow to 0
and the maximum flow to 10000 m3/d.
Basic Customization 97

Figure 9-2 Tagging the oxygen uptake rate.

3. Change the influent flow type by selecting Flow Data from the Flow
menu of the influent object. This will open a form entitled Flow Data. Click
on the inverted triangle and select Sinusoidal. Accept the form.

4. Save and Build the layout.

5. Run a steady-state simulation followed by a 10-day dynamic


simulation to ensure that the model is correctly set-up. You should be
able to produce a graph similar to Figure 9-3.
98 GPS-X Tutorial Guide

Figure 9-3 Example dynamic simulation.

You will now customize the layout code.

6. Open the tutorial9.usr file by choosing the Options > General


Data > User Files > Macros... menu item (see Figure 9-4).

Figure 9-4 Macros menu item.


Basic Customization 99

In this file, which is generated when you save the layout for the first time,
there are a number of sections separated by asterisks. They correspond to the
different sections of the ACSL program structure. In this example, you will
add new code to the DERIVATIVE SECTION as shown in Figure 9-5.

Figure 9-5 The tutorial9.usr file.


100 GPS-X Tutorial Guide

In the DERIVATIVE SECTION, four new variables are calculated,


noise, ourwithnoise, sourone and sourtwo, from the actual
oxygen uptake rate and the VSS in the first stage of the plug-flow tank. The
cryptic variable name for the actual oxygen uptake rate can be found in the
Display Variables > Internal Variables > actual oxygen uptake rate > [(...)] form
of the plug-flow tank (Figure 9-2). Moving the mouse pointer over the
variable name will display a tooltip with the variable description and the
variable's cryptic variable (Figure 9-6). The cryptic variable name for the
volatile suspended solids can be found in the Display Variables > Composite
Variables > volatile suspended solids > [(...)] form of the plug-flow tank.

Figure 9-6 Displaying the cryptic variable name.

The variable noise makes use of an ACSL command, GAUSS, to simulate


measurement noise.

The method by which user-defined constants are setup for input into GPS-X
requires the use of another file, named tutorial9.con.

7. Open the tutorial9.con file by choosing the Options > General Data
> User Files > Constants... menu item. This file allows you to setup the input
variables on the same type of controllers as the other GPS-X variables. For
this example, the tutorial9.con file is shown below in Figure 9-7.

Edit the tutorial9.con file, adding the code shown in Figure 9-7. In
this file Noise Variables is the text string that will appear under
Options > General Data > User > Parameters, as shown in Figure 9-8. The
other important additions to the file are the keyword constant, signifying
that this variable is an ACSL constant; the cryptic variable names mean and
stdev, equal to assigned default values; a descriptive variable name for
each within exclamation marks before and after the name; and the units (if
any) for the variables.
Basic Customization 101

Figure 9-7 The tutorial9.con file.

Figure 9-8 User menu.

8. Open the tutorial9.var file by choosing the Options > General Data
> User Files > Display Variables... menu item. This file allows you to make
the new variables available for output. As shown below in Figure 9-9, and
similar to the tutorial9.con file, a MENU ITEM followed by a list of
variables is included. The difference between this file and the
tutorial9.con file is that here, the keyword display is used instead
of the keyword constant, and the variable is not assigned any default
value as it will be calculated by GPS-X.
102 GPS-X Tutorial Guide

Figure 9-9 The tutorial9.var file.

9. After modifying these three files, Save the layout. You will then need
to close the tutorial9 layout (use File > Close) and reopen the layout (use File
> Open...). This process re-reads the custom code you've entered. Now you
can re- Build the layout.

10. Define a new interactive control window as described in Tutorial 1 and


set-up the window with the average measurement noise and measurement
noise standard deviation in the same window. These variables can be tagged
in the Options > General Data > User > Parameters > Noise Variables form. In
the Controls Setup window, set the minimum average noise to -2 and the
3
maximum average measurement noise to 2 gO2/m /h and the minimum
measurement noise standard deviation to 0 and the maximum measurement
noise standard deviation to 10 gO2/m3/h.

11. Define a new output graph as described in Tutorial 1 and set-up the
two new SOUR variables on this graph. The SOUR variables can be tagged
in the Options > General Data > User > Display Variables > Uptake Variables
form. In the Output Setup window, set the minimum SOUR to 5 and the
maximum SOUR to 10 mgO2/gVSS/h. Set-up the OUR with noise variable
(ourwithnoise) on the graph created in Step 2 of this tutorial. The OUR
with noise variable can be tagged in the Options > General Data > User >
Display Variables > Uptake Variables form. In the Output Setup window, set
the minimum OUR to 15 and the maximum OUR to 25 gO2/m3/h for this
variable.

12. Display the Simulation Control window, the Outputs, and the Controls.

13. Load the model.


Basic Customization 103

Running Simulations
14. Run a steady-state simulation followed by a 10-day dynamic
simulation. You should produce an output similar to Figure 9-10.

15. Vary the noise parameters with the interactive controllers and
observe the impact on the output. Try running several simulations using
different settings.

Figure 9-10 Running the simulation.

What's Next
This tutorial presented an example on how to make basic customizations to a
GPS-X layout through the modifications of the .usr, .con, and .var
auxiliary files. The next tutorial covers Dynamic Parameter Estimation.
104 GPS-X Tutorial Guide
Dynamic Parameter Estimator (DPE) 105

TUTORIAL 10

Dynamic Parameter Estimator (DPE)

Problem Statement
With many of the dynamic models used in GPS-X most of the model
parameters are assumed to be constant over the entire calibration period. For
example, the clarifier's flocculent zone settling parameter is normally set to
one specific value for the entire simulation. One reason for doing so is that it
is difficult to determine or identify the changes in this parameter over time
since it is difficult to measure on-line. The best the modeler can do is
assume that the parameter doesn't change over the simulation period, and
therefore use only one value to fit the target or measured data.

A more rigorous approach, however, might be to try to fit the measured data
by varying the parameter over the simulation period. This has two
advantages: a better agreement between the model and data, and an indicator
of the dynamic response of the parameter. Of course this technique assumes
that the measured data is relatively free of error.

Objectives
After completing this chapter you should be able to setup and run the
dynamic parameter estimator (DPE). The GPS-X Advanced Tools and
Builder modules are required to complete this tutorial.

Users who do not have the GPS-X Builder Module can simply open in the
tutorial10 layout located in the GPS-X tutorial directory. This file can
also be accessed from the Start Menu. Users that wish to use this pre-
compiled layout should proceed to the step 16.
106 GPS-X Tutorial Guide

Setting Up the Layout


1. Open the realplant layout from the GPS-X layouts\examples
directory.

2. You will modify this layout, deleting everything downstream of the


combiner after the primary clarifier. The layout should look like the one
shown in Figure 10-1. Use the Locator as necessary to adjust the layout
view.

Figure 10-1 Layout for DPE.

3. Build the layout.

4. Open the Outputs Setup form, and change the Max value for the
primary effluent [pe] suspended solids from 1000 to 300 g/m3. Also
remove the primary effluent ammonia variable from this graph by selecting
the asterisk option for the graph name (using the drop-down menu), as shown
in Figure 10-2. Remember to Accept the form when finished.
Dynamic Parameter Estimator (DPE) 107

Figure 10-2 Output setup.

5. Load the model. Select scenario5 and check Steady State in the
Simulation Control window.

6. Display the controls and outputs, and Start a 4 day simulation.

The graph of the primary effluent TSS shows a reasonable fit with the real
measured data but there is considerable room for improvement. These
results are shown in Figure 10-3.
108 GPS-X Tutorial Guide

Figure 10-3 Primary Effluent TSS.

Setting Up the DPE


At this point, it is desirable to improve the fit between the primary effluent
TSS and the data by optimizing the flocculent zone settling parameter as it
varies with time.

7. Unload the model and select the Optimize > Type > DPE mode. Then
click on the Optimize icon to switch to optimize mode. The status bar at the
bottom of the GPS-X window should display Optimize - DPE on its right-hand
side.

8. In the primary tank Parameters > Settling form, tag the flocculent zone
settling parameter.

9. Select the Optimize type of control for the flocculent zone settling
parameter in the Controls Setup form. Also, place this item in window "3:
Pump Controls" with a Min of 0.0001 and a Max of 0.001 m3/gTSS.

10. Next specify the primary effluent TSS concentration as the target
variable for the optimization. To do this, simply tag the appropriate
variable on the upper influent connection point of the combiner Target
Variables > Composite Variables form. Note that while the Optimize mode is
on, the menu item that was formerly labeled Display Variables has changed to
Target Variables (see Figure 10-4).
Dynamic Parameter Estimator (DPE) 109

Figure 10-4 Tagging the target variable.

11. Finally, under the General Data > System > Parameters sub-menu
Optimizer, set a DPE timewindow of 0.4 days and make this variable
available for control. In addition set the parameter tolerance to 0.001.

12. In the Controls Setup form put the DPE timewindow in control window
"3: Pump Controls" and set the Min to 0 and the Max to 4.

13. Save the layout and Build the model.

14. While the model is building, switch to edit mode by clicking on the
Optimize icon. In doing so you will now be able to setup the flocculent zone
settling parameter for display.

15. On the overflow stream from the primary clarifier, select Display
Variables > Parameters > Settling and tag the flocculent zone settling
parameter. In the Output Setup form, locate the newly tagged variable and
select window "3: Primary Eff - BOD5 & COD", the Min value (0.0001
m3/gTSS) and the Max value (0.001 m3/gTSS). Also, select the asterisk
option for all other variables currently displayed on the "3: Primary Eff -
BOD5 & COD" output graph. Accept this form. It is recommended to also
change the title of the graph in the Outputs > Define form. Change the third
title to PE - Settling Parameter.
110 GPS-X Tutorial Guide

Running the DPE


16. After the compilation is complete, Load the model, select the same
scenario (scenario5), and click on Steady State.

17. Select Optimize > Type > DPE and then click on the Optimize icon to
switch to optimize mode.

18. Display the control windows and the output graphs.

19. Set the simulation time to 4 days and Start the optimization.

The results are shown in Figure 10-5 and Figure 10-6 below. Try repeating
the simulation with a shorter time window or tighter convergence criteria
(found in the General Data > System > Parameters > Optimizer form).

Figure 10-5 DPE Results.


Dynamic Parameter Estimator (DPE) 111

Figure 10-6 Flocculant parameter.

The End
You have finished all the tutorials and should now be comfortable in
developing model layouts, running simulations and displaying outputs.
Additional details on particular GPS-X features can be found in the GPS-X
User's Guide, while details about the models are included in the GPS-X
Technical Reference.

Vous aimerez peut-être aussi