You are on page 1of 86

UNIT OF ENVIRONMENTAL ENGINEERING - INSTITUTE OF INFRASTRUCTURE

faculty of civil engineering - university of innsbruck

Authors: S. Achleitner and W. Rauch

Supported by the Fund for Scientific Research established by the state of Tyrol/Austria. (Wissenschaftsfond des Landes Tirol).

CITY DRAIN 2.0

IMPRINT CITY DRAIN 2.0 an open source Matlab/Simulink library for integrated simulation of urban drainage systems. (2007)
Software requirements: Availability: MATLAB Release 13 (or higher)+Simulink http://umwelttechnik.uibk.ac.at/ or contact developers

The software is a freeware and may be downloaded at http://umwelttechnik.uibk.ac.at/. A copy may as well be obtained by contacting the Institute of Environmental Engineering.

Authors:
Dipl.-Ing. Dr. techn. Stefan Achleitner Univ.-Prof. Dipl.-Ing. Dr. techn. Wolfgang Rauch

Development/Programming:
Dipl.-Ing. Dr. techn. Stefan Achleitner Dipl.-Inf. Heiko Kinzel Dipl.-Ing. Michael Mderl

IUT Unit of Environmental Engineering - Institute of Infrastructure Faculty of Civil Engineering, University of Innsbruck Technikerstrae 13, 6020 Innsbruck, Austria http://umwelttechnik.uibk.ac.at umwelttechnik@uibk.ac.at

Acknowledgements:
The authors gratefully acknowledge the support granted by the Fund for Scientific Research established by the state of Tyrol/Austria. (Wissenschaftsfond des Landes Tirol).

Disclaimer
CITY DRAIN 2.0 an open source Matlab/Simulink library for integrated simulation of urban drainage systems. Copyright (C) 2007 , Stefan Achleitner and Wolfgang Rauch Unit of Environmental Eng. Institute of Infrastructure, Univ. of Innsbruck
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

USER MANUAL

ii

CITY DRAIN 2.0

GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program

USER MANUAL

iii

CITY DRAIN 2.0

itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical

USER MANUAL

iv

CITY DRAIN 2.0

distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS

USER MANUAL

CITY DRAIN 2.0

CONTENT 1 Introduction.................................................................................................................1
1.1 1.2 General Purpose of Integrated Modelling....................................................................... 1 Dominant processes and complexity of models ............................................................. 1
1.2.1 1.2.2 1.2.3 Principals .......................................................................................................................... 1 Computational aspects for hydraulics............................................................................... 2 Computational aspects for transport and conversion of matter........................................ 2

1.3

Why realising CITY DRAIN in Matlab/Simulink .............................................................. 2 Installation of City Drain ................................................................................................. 3 The City Drain Library .................................................................................................... 4 Simulation parameters and Unit Conventions ................................................................ 5 Implement functions for substance handling .................................................................. 7
3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 Function get-sub............................................................................................................. 7 Function get_sub_no...................................................................................................... 7 Function get_substance ................................................................................................. 7 Function get_substance_count ...................................................................................... 7 Function get_substance_name ...................................................................................... 8 Function get_substances_count .................................................................................... 8 Function permute ........................................................................................................... 8 Function set_substance ................................................................................................. 8

First steps ...................................................................................................................3


2.1 2.2

Concepts and programming......................................................................................5


3.1 3.2

3.3

State space modelling and S-functions .......................................................................... 9 Flowread....................................................................................................................... 15 Rainread....................................................................................................................... 19 Raingenerator............................................................................................................... 22 QCM-Generator............................................................................................................ 24 Catchment CSS............................................................................................................ 27 Catchment SSS ............................................................................................................ 29 Retention Catchment (CSS and SSS).......................................................................... 31 Underlying Blocks in catchment models....................................................................... 34
5.4.1 5.4.2 5.4.3 Simplified Muskingum routing method............................................................................ 34 Catchment Loss Model ................................................................................................... 36 Catchment Flow Model - SW (storm water).................................................................... 37

Source blocks ...........................................................................................................15


4.1 4.2 4.3 4.4

Catchment/sewer Blocks .........................................................................................26


5.1 5.2 5.3 5.4

5.5 5.6 5.7 5.8

Sewer ........................................................................................................................... 38 Retention sewer ........................................................................................................... 39 CSO (Types A and B)................................................................................................... 41 Pumping station............................................................................................................ 46 WWTP (simple) ............................................................................................................ 51 ASM WWTP ................................................................................................................. 52 Muskingum oS - Q........................................................................................................ 60 Muskingum oM - Q ....................................................................................................... 62

Wastewater treatment ..............................................................................................51


6.1 6.2

River (Flood Routing) blocks...................................................................................60


7.1 7.2

USER MANUAL

vi

CITY DRAIN 2.0

7.3 7.4 7.5

Muskingum sS - QC ..................................................................................................... 64 Muskingum sM - QC..................................................................................................... 66 Hydropower .................................................................................................................. 68 Mixing QC..................................................................................................................... 69 Mixing QC-QD .............................................................................................................. 70 Splitter .......................................................................................................................... 72 Dynamic Splitter ........................................................................................................... 74 Switch........................................................................................................................... 75 Wrong Connect ............................................................................................................ 76 SetSubstance Q/C........................................................................................................ 77 Filter ............................................................................................................................. 78

Tools ..........................................................................................................................69
8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8

LITERATURE .............................................................................................................79

USER MANUAL

vii

CITY DRAIN 2.0

1 1.1

INTRODUCTION General Purpose of Integrated Modelling

The aspect of improving ambient water quality, based on the overall management of river basins gained importance during the last years (Blch, 1999). The emphasis is being put on the improvement of the receiving water quality as well as on the overall management of river basins as requested also by the European water framework directive (WFD). Both aspects require a change in the design procedures for urban drainage systems. Reason is that the application of design rules based on emission criteria does not necessarily lead to an improvement of the water quality at least they are limited to a certain extend (Lau et al., 2002; Lijklema, 1995). Thus a shift is recently experienced from end of pipe design criteria to ambient water quality approaches (Achleitner et al., 2005). For the application in practice software tools are required that are capable of modelling urban drainage systems (including the receiving water) in an integrated manner. Rainfall as the elementary input source is of irregular occurrence in intensity and duration, which leads to the need of long term simulations for being capable of a systems performance.

Fig. 1. Schematic on the main elements and information flow in an integrated model (redrawn from (Rauch et al., 2002)) The schematic in Fig. 1 illustrates the main elements and information flow occurring.

1.2
1.2.1

Dominant processes and complexity of models


Principals

A software for integrated modelling may incorporate a variety of models covering hydraulics, mass transport, processes for conversion of matter etc. within the subsystems. Main objective is the prediction of the system performance including the receiving water quality. For choosing the appropriate models it is therefore vital to characterise the impacts onto the receiving water with regard to their type (hydraulic, chemical, biochemical,) and duration (e.g. acute, delayed, accumulating). Regarding the time scale for modelling not only the dynamics of the relevant processes in the drainage system itself are to be considered but also the duration of the impacts (and associated processes) in the receiving waters. E.g. acute pollution occurs instantly and requires short term modelling whereas accumulative effects in the receiving water can only be covered within a long term simulation effort. But also the stochastic nature of rainfall as the source of impacts in an urban catchment needs to be considered. Single rain events are often source for acute effects in the receiving water such as hydraulic stress or pollutants entering the receiving water. The assessment of those is based on an evaluation of frequency, magnitude and duration of the impact (see. e.g. Harremos and Rauch (1996)) and thus requires a statistical interpretation. This again is possible only within the framework of long term simulation studies.

USER MANUAL

CITY DRAIN 2.0

Overall the computation in CITY DRAIN is based on an fixed discrete time steps approach where each subsystem uses the same time increments, usually being predetermined by the timely resolution of the rain data used. Models implement for hydraulics and mass transport are formulated for discrete time steps t. 1.2.2 Computational aspects for hydraulics

Flow of water in both sewers and rivers is described by the continuity and momentum equations. The latter is known as the Navier-Stokes or Reynolds equation. The actual form of a hydrodynamic model depends on assumptions made on characterizing turbulence but for water quality purposes mostly the well-known, crosssectionally integrated (1D) Saint Venant equations or approximations to these equations are used. Different levels of simplifications of the momentum equation are known for describing unsteady flow. Most simple approximation is the kinematic wave model being valid where backwater effects are negligible. All hydrodynamic equations have in common that they are demanding from a computational point of view. There for a variety of simpler conceptual models where developed (frequently denoted as hydrological models). These as well respect conservation of mass but use conceptual relations instead of momentum equations. The rapid simulation with conceptual models puts them in favour to hydrodynamic models regarding computational effort. Effects such as pressurized flow or backwater effects cannot be covered. For allowing long term simulations the blocks implemented in CITY DRAIN are based on purpose on simple conceptual models for hydraulics. 1.2.3 Computational aspects for transport and conversion of matter

For limiting the effort of modelling only relevant pollutants and processes need to be considered. Neglecting issues of secondary importance is required to avoid unnecessary complexity of models. Transport models describe in principle only the flow of soluble and conservative matter through the system. Effects such as physical or biological conversion processes (sedimentation, degradation, etc) are considered by extension of the transport equations.

1.3

Why realising CITY DRAIN in Matlab/Simulink

Basic idea was to create an open source toolbox for integrated modelling of urban drainage systems. For the use in the daily engineering work such software tools are required to be simple in handling and to provide a certain flexibility to be adjustable for different scenarios. Different subsystems should be freely arrangable and connectible to each for describing an integrated urban drainage system and the fluxes of water and matter (Achleitner, 2006). The principle of block-wise modelling of integrated systems in CITY DRAIN has been developed in a Matlab/Simulink environment. The platform is widely used for all different kinds of dynamic simulations and was found suitable as hosting environment for the CITY DRAIN software. On the one hand the platform is tailored for dynamic and time dependent simulations, on the other hand a graphical user interface is already provided. The user interface is block oriented for convenient usage and creation of coupled models. Blocks are connected to each other providing information flow between each other. Besides using pre-existing blocks provided by Simulink the creation of own blocks is supported. Creation of own routines is done by coding in either m-functions, s-function or C++. For simulation either continuous or sampled (discrete) time may be used. Results can be visualized directly in Simulink. Alternatively results may be stored in the Matlab workspace for visualisation or further analysis.

USER MANUAL

CITY DRAIN 2.0

2 2.1

FIRST STEPS Installation of City Drain

City Drain requires two simple steps prior being available within Matlab/Simulink environment. Following files are part of the City Drain software: CityDrain02.zip CD2_startup.m CD2_ UserManual.pdf The file (CityDrain02.zip) contains the software library and all associated. Data is to be unzipped and saved preferably in the operating systems programs directory. C:\Programme\CityDrain02\ for German operating system C:\Program Files\CityDrain02\ for English operating system For convenient use of City Drain 2.0 it is required to include the CityDrain02 directory (and all subdirectories) in the Matlab paths. Therefore the Matlab startup.m file is extended for automatic adding of City Drain directory to the Matlab path. File: C:\Programme\MATLAB6p5\work\startup.m In case there is no startup.m file created in your Matlab, please create a new startup-file. Following code to be added can be found in CD2_startup.m. The user may modify the path of City Drain included in the code (bold printed). % Path setting for CITY DRAIN 1.0 % IUT Institute of Environmental Engineering cd02path='C:\Program Files\CityDrain02'; cd02path_full=genpath(cd02path); k=strcmp(cd02path_full,''); disp('Matlab-path for CITY DRAIN 2.0:'); if k==1 disp('HAS NOT BEEN SET !!'); disp('Please check in startup.m if path is set correctly.'); disp(' ');disp(' '); else disp(cd02path); path(path,cd02path_full); disp(' ');disp(' ');

end

clear('cd02path');clear('cd02path_full');clear('k');

USER MANUAL

CITY DRAIN 2.0

2.2

The City Drain Library

To open the City Drain block library type > citydrain in the Matlab command window. Alternative, the Library can be opened via File/Open : C:\Programs\CityDrain02\CD2_Library.mdl

Fig. 2. City Drain 2.0 Block Library (CD2_Library.mdl) The library contains blocks in 5 sections. Core block required for every simulation is the CD Parameters blocks organizing global setting for each simulation. This manual as well as the Tutorial may be opened via double click on the Manual Blocks. The remaining blocks represent different parts of the urban drainage system and are described in detail in this manual. How to create a new scenario, perform simulations and cope with simulation results is shown in the Tutorial Manual.

USER MANUAL

CITY DRAIN 2.0

3 3.1

CONCEPTS AND PROGRAMMING Simulation parameters and Unit Conventions

CITY DRAIN and the library blocks implemented are designed to work within a discrete time scheme. Constant and discrete time steps are used within a simulation where simulation time and size of time steps are to be chosen by the used. Core element of every CITY DRAIN simulation is the block CD - Simulation Parameters

This block ensures that simulation parameters in the Matlab/Simulink are defined correctly. User input is required for the sampling time t, start time t0 and stop time tE.

of the simulation. In addition to version 1.0 of CITY DRAIN, a global list of substances is to be set in the parameters block. This list is available for all other blocks and can be addressed by using different provided Matlab functions. Utilisation of functions can be done within the mask or as well inside underlying s-function codes of the different blocks. The available functions are described below. The sampling time defined is utilized within all CITY DRAIN blocks provided, thus is being globally used. Hidden settings (without required user input) are made for 'Solver' .......................'FixedStepDiscrete' 'TimeSaveName'........'cd_time' 'Decimation' ..............'1' 'LimitDataPoints' .......'off'

THE BLOCK CD SIMULATION PARAMETERS IS TO BE INCLUDED WITHIN EACH SIMULATION TO ENSURE CORRECT SETTING OF VARIABLES.

USER MANUAL

CITY DRAIN 2.0

Convention regarding units in City Drain are as followed: Q [m/s]....... Flow [cubic meter per second] V [m] ........... Volume [cubic meter per second] L [m] ........... Length [meters] t, t [s] ........ Time [seconds] C [g/m] ...... Concentrations [gram per cubic meter] M [g] ........... Mass [grams] One mayor improvement of City Drain 2.0 compared to City Drain 1.0 is the substances transportation system. As in City Drain 1.0, data on flow and substance concentration is to be transferred between blocks in each time step. This is done within the Simulink-system on which City Drain is built on. The data is to be transferred as vector from one block to another in a downstream manner. The general concept of the vector to have the flow entry at first followed by substance concentrations has been kept. Q = [q, c1, c2 cn] In Version 1.0, the user was required to know which entry of concentration represents what substance, having no possibility to link a substance name to the numerical entry given. The new, respectively improved concept in this version, allows to link names helping to avoid mistaken build up of the model with respect to definition of the concentration vector. Secondly it allows an efficient and more visible administration of the substance flows. Each transfer of data from one block to another is then done using this specific format. The definition of the order of substances is done within the mask of the parameters block using the field model substances. Example: Ntot COD BOD5 Cu is treated as Q = [q, C1, C2, C3, C4]= [q, CNtot, CCOD, CBOD5, CCu] The substance names are to be entered as string and are to be separated by blanks from each other. Names given are case sensitive (e.g. Ntot is not equal to NTOT). This list of names is the available to be used in the blocks. The contrasting alternative to this scheme would be to have a system allowing to have a differing order of substances in each link, requiring a more attention in the maintenance of the blocks. Especially when adding a substance to the system, each block would require to get the information that a substance is added separately. This would, in the extreme case, require to edit all blocks in a modelled scenario. Using the functions described below, information about the substance list (such as the number of substances included) can be obtained and transferred to each block in an automated manner. Secondly, assessing a substance concentration for performing calculations can as well be done by a using the substances name and using one of the below described functions. Advantage is, that the calculation is still done with the correct substance although the number and order of substances is changed. As long as the name given is kept, the correct numerical value of the concentration is used. Thus, this scheme is to be seen as an highly recommended option but not as a must to be used. Depending on the case, the advanced user may decide to exclude single blocks from the overall scheme simply by not applying the below described functions in that specific block. Secondly, this allows to reused already set up models with version 1.0 of CITYDRAIN. The global variable substances stores the list of all substance in the model as a string. For the below given example to usage of the functions provide the before given example is used.

USER MANUAL

CITY DRAIN 2.0

3.2
3.2.1

Implement functions for substance handling


Function get-sub Function: c=CD2_get_sub(elec, u) Inputs: elec u Output: c Vector of the wanted concentrations in given order according to elec c = [.CNtot CBOD5 ] String containing the names of the wanted substances (e.g. Ntot BOD5) Data vector organized according to global naming scheme

3.2.2

Function get_sub_no Function: [s,r] = CD2_get_sub_no(elec) Returns for a given string of substance names a vector s and r containing the concentrations and positions within the global substance vector respectively. Input: elec Output: s r Concentrations of substance in the order as given in elec s= [CNtot CBOD5] Position of substances in the global order substances r= [1 3] String of substance names (e.g. Ntot BOD5).

3.2.3

Function get_substance Function: concentration=CD2_get_substance(substances_vector,substance) Grabs from a vector with substance concentrations the correct entries according to the substance names stated. The concentrations are addressed according to the order given in the global substance name Input: substances_vector substance Output: concentration Vector of wanted substance concnetrations. vector with concentrations string of the wanted substances name

3.2.4

Function get_substance_count Function: n=CD2_get_substance_count(vect) Returns the number of substances that are given in a string. Input: vect Output: n number of substances string with substance names (usually used with the global variable substances

USER MANUAL

CITY DRAIN 2.0

3.2.5

Function get_substance_name Function: name=CD2_get_substance_name(vect, pos) Returns the name of the substance located at the position pos in the string vect which contains substance names. Input: vect pos Output: name String of the substance name wanted String of substance names position of the wanted substance

3.2.6

Function get_substances_count Function: n=CD2_get_substances_count() Input: none Output: Number of substance given in the global substance list

3.2.7

Function permute Function: y=CD2_permute(x,r) Permutation of values in vector x according to the (new) order given in vector r. The resulting permutation vector is stored in y. Input: x r Output: y Vector of substance concentrations in new order Example: x=[ 7 23 40 ]; r= [ 2 1 3 ]; y= [ 23 7 40] ; Vector of substance concentrations Vector of new positions for permutation

3.2.8

Function set_substance Function: subs_out =CD2_set_substance(s_name, s_name_set, concentration) Generates a zero value vector and sets the concentration of matters given in s_name_set. Input: s_name s_name_set conc Output: subs_out Generated vector of substance concentrations String with substance names given for the target vector (the one to be modified) String with substance names to be set Vector of concentrations of substance to be set (order according to string s_name_set)

USER MANUAL

CITY DRAIN 2.0

3.3

State space modelling and S-functions

For general issues on creating and modification on blocks, the user is asked to stick to the very detailed manuals provided by the Mathworks Company. Still, as this software is open source and it is wanted to have users that extend the library with new and groundbreaking blocks, we would like to give some guidance on how state space modelling works, how numerics are implemented and what most important issued are to known when starting to modify or to create s-functions. Realisation of a block wise representation of parts of the urban drainage system as in Rauch et al. (2002) is based on the state-space approach as shown by (Schreider et al., 2001). The principles of state-space modelling have been formulated by (Kalman, 1960) and it is since then widely used. The Matlab/Simulink environment is using the same principles embedded in a graphical user interface to arrange blocks (The Mathworks, 2003). In principle input (u) is fed to a state-space model that is variable in time. A dynamic output is generated, based on both, the dynamic input (u) and the models state (x).

Fig. 3: State-space model The state (x) of the system is defined as the values of state variables at any instant point of time. When modelling urban drainage systems this may be the current volume V or the current substance concentration C. The utilization of states is the core element, where the change of the states is defined via mathematical equations. This can be either differential equations or as used in CITY DRAIN discrete formulations of the differential equations. As an additional information, the state-space model accepts parameters which are constant in time. A linear state-space model is described by the following equations

dx = Ax + Bu dt y = Cx + Du
The set of differential equations describing the output as function of states and input are to be solved for each time step. Different numerical methods for solving the differential equations are available. The time steps for which the equations are solved relate to the accuracy of the solution. Depending on the software, the time steps can be implemented as variable or as in CITY DRAIN as fixed time steps. Usually when implementing a dynamic system, the time management is to be organised by the programmer. Within the Simulink environment, a defined scheme is already provided that takes care of the time management. Thus, discretised equations are to be formulated for a single time step and to be embedded in the provided scheme. The scheme is realized in so called s-functions that are available for different software languages (Matlab, C++ or MEX functions). Within the graphical environment each block addresses a certain s-function. The following figure shows the temporal workflow of initialization, output and update procedures (Achleitner, 2006).

USER MANUAL

CITY DRAIN 2.0

Fig. 4: Simulink workflow for Initialization, Update and Output When the model is started, the defined state variables are to be set within the initialization stage. This initial setting of the state variable is used within the first output calculations at t = 0. Thus, one can virtually attribute the initial states to the time step t = -1. Subsequently, output and update procedures are redone for each time step. This calling of different routines is described within the Matlab/Simulink help as a set of S-function callback methods. The Simulink environment is thereby calling the appropriate methods automatically while running a simulation. The S-function methods included are Initialization of the S-function to create SimStruct, which contains the information about the S-function. The main tasks are to set the number and dimensions of inputs, a outputs and states. Further the sampling time is to be sets. Next sample hit calculation To calculate the next sampling time step which is only required for variable sample time blocks. This option is not used withing CITY DRAIN. Output calculation generating the outputs at the major time step. Update of states to store the current state at the major time step for having it available at the next time step as calculation basis. In the following only the most important issues of s-function using discrete time steps and Matlab m-file language are discussed. For getting to know the full spectra of possibilities in coding Simulink s-functions the user may refer to the respective manuals on s-function provided by Mathworks. To get to know s-functions linewise, guidance is made using the the s-function USER MANUAL 10

CITY DRAIN 2.0

CD1_sfun_Muskingum_sM_QC.m as an example. The function contains all relevant sections that are required for an s-function. In general s-functions are nothing mysterious compared to usual m-functions. In fact they are just mfunctions that are to be set up in specific way so they can be used by the Simulink environment in a standardized manner. Main difference to regular programming is, that Simulink takes over the time management and coordinates thereby the dynamic behaviour of blocks operated simultaneous. As known from Matlab m-function, the function declaration is to be the first entry. [sys,x0,str,ts] = CD1_sfun_Muskingum_sM_QC(t,x,u,flag,tstep,K,X,CA,CB,n_comp,N) The left hand side arguments returned are standardized and shall not be changed. In the same way, the first arguments (t,x,u,flag) passed to the function are not be modified as they are the minimum requirement to properly run the s-function. The remaining ones are additional parameters that are specific for this function. The parameters passed on represent partly dynamic and partly static parameters. t,x,u,flag are generated and passed automatically by Simulink environment, thus they are variable over time. t x u flag current time the current state of the block the input to the block is mode at which the s-function is currently called

Within the states (x) the actual condition(s) such as the currently stored volume or currently given concentrations etc. are stored. Parameter u contains the dynamic input fed to the block/s-function at the current time step. Unfortunately the s-functions accepts only one dynamic input being a row vector. Therefore, if blocks are required to be subjected to two or more dynamic inputs, these streams are to be merged to one row vector (see Mux and Dmux blocks in Simulink) prior fed to the s-function block. Once u is passed over, the row vector may be taken apart for convenience in performing calculations. As additional information the number of components (n_comp) and the number of inflows expected(N) are passed to the function. The both allow to extract the correct part of the vector for further calculations. In the following example 2 streams are expected with n_comp component each. u=[qA CA,1 CA,2 CA,n_comp qB CB,1 CB,2 CB,n_comp] u(1 , n_comp+1)= [qA CA,1 CA,2 CA,n_comp] u(n_comp+2 , 2*(n_comp+1))= [qB CB,1 CB,2 CB,n_comp] Per definition, CITY DRAIN deals with q being the mean flow entering or leaving a block during the last time step (similar conventions are used in recording rain series). This means, when the s-function is called at t=1800sec and the timestep is tstep=300s, the flow is the mean inflow between 1500sec and 1800sec. Analogous this convention is applied for dealing with concentrations. In contrast states (x) are attributed to a discrete point in time. Thus, a stored volume or concentration is the state at t=1800s at the end of the past time step. Having this convention in mind, derivation of discrete formulations from differential equations are made accordingly. This scheme led for the applications implemented so far to more simple and numerically stable numerics.

USER MANUAL

11

CITY DRAIN 2.0

The last parameter required by Simulink is "flag". The s-function is called at each time step automatically. Thereby the flag defines the mode at which the s-function is currently run. The implemented switch leads to either one of the functions mdlInitializeSizes mdlOutput mdlUpdate

where other functions than these may be implemented when dealing with continuous models. ============================= switch flag, case 0, [sys,x0,str,ts] = mdlInitializeSizes(n_comp,N,tstep); case 2, sys = mdlUpdate(t,x,u); case 3, sys = mdlOutputs(t,x,u,tstep,K,X,CA,CB,n_comp,N); case 9, sys = []; % do nothing otherwise error(['unhandled flag = ',num2str(flag)]); end ============================= In this example, flags other than 0, 2 or 3 are not defined and dealt as unhandled flags. "flag=0" - mdlInitializeSizes When it is called first time, no states for the function are set yet. When the model is started, the defined state variables are to be set within the initialization step. This initial setting of the state variable is then used within the first output calculations at t = 0. Thus, one can virtually attribute the initial states to the time step t = -1 as outlined before. Additionally general conditions such as vector sizes used for input (u), states (x)etc. are to be set as well as the timestep size. As the same s-function scheme is used for continuous modelling, a lot more variables can be defined compared to the minimum needed for discrete modelling. The variables of interest are: % Volumes and concentrations only sizes.NumDiscStates = N*(n_comp+1); % Volumes and Flows including corresponding concentrations sizes.NumOutputs = 2*(n_comp+1); % Inflow and concentrations sizes.NumInputs = n_comp+1; Passed on information on the number of components (n_comp) and the number of compartments used (N) allow to keep the s-function flexible with regard to the number of substances and subreaches used. The information on n_comp and N are input made by the user within the mask and is pass don via the s-function block. The actual numerical values for the initial states are set in x0 = zeros(sizes.NumDiscStates,1);

which is in this example set to zero. If one requires any other starting conditions, modifications may be made at this point. In general, starting with other initial conditions than zero without a good reason is not

USER MANUAL

12

CITY DRAIN 2.0

recommended. Information on the start conditions are then hidden in the code and may lead to confusion e.g. for mass balancing. ================== str = []; sys(7)=1; ts = [tstep 0]; % driven by global timesteps defined ================== The above are not to be changed as they make CITY DRAIN running with fixed discrete tie steps of size tstep. =================== % Initial setting of values for previous time steps u_dat.volume=zeros(N*(n_comp+1)); set_param(gcb,'UserData',u_dat); =================== These lines define a global variable u_dat on the blocks level. The gcb returns the handle for the current block (GetCurrentBlock). The u_dat variable is used for exchanging calculation results between sections mdlOutput and mdlUpdate. Subsequently after initialization is finished, the s-function is called twice repeatedly at each time step, first calling the mdlOutput function (flag=3) and secondly calling the mdlUpdate function (flag=2). As outlined, any other parameters other than t,x,u and flag can be passed to the s-functions and consequently to mdlOutput or mdlUpdate as they may be required to perform the calculations. The mdlOutput section is designed to generate the dynamic outputs that finally leave the block, where the update section is designed to set the new states (e.g. volumes, concentrations, etc.) obtained in this step. A shortcoming is that the exchange of information between the output section and the update section is limited to be done via a global variable such here used u_dat. When considering mathematics as given here the calculations of outputs and new states are merged such that one cannot calculate an output without calculating the states as well. Still, stated are not automatically available in the update section as the mdlUpdate function is run when the s-function is second time called in this time step. To have the states available in the update section as well (in order to store them properly) two options are available: Doing the calculations a second time or transferring the values from mdlOutput to mdlUpdate via a temporal storage in a global variable such a u_dat.

Neither one of the two option is strictly recommended. It depends more on the number of calculations performed. In this example the first option was used, perfoming first all the calculations in the output section and storing the states calculated in the global variable u_dat at the end of the function. ====================== % renewing the storage vector u_dat for next step usage u_dat.volume=xnew; set_param(gcb,'UserData',u_dat); ====================== Finally calculated outputs are passed to the Simulink environment at the end of the mdlOutput function via the return variable sys:

USER MANUAL

13

CITY DRAIN 2.0

============================ % Generating output for block out=[QE, V]; sys = out; ============================ In contrast to the mdlOutput function the mdlUpdate function is kept puristic. ====================== function sys = mdlUpdate(t,x,u) u_dat=get_param(gcb,'UserData'); VC=u_dat.volume; sys = [VC]; ====================== No additional parameters other than (t,x,u) are passed and the function is limited to read the global variable and pass it to the Simulink environment via the return variable sys. In some s-functions one will find the mdlUpdate function missing (e.g. mixing blocks). This is simply due to flow enters and is instantly passed on. As no storage is required, no states and consequently no mdlUpdate section is needed.

USER MANUAL

14

CITY DRAIN 2.0

4 4.1

SOURCE BLOCKS Flowread

Function: Reads flow data from ASCII files containing time t, flow Q and concentrations C as input. Data is to be provided column wise. First row in the file allows to hold an alpha-numeric descriptor for column data. The time is to be provided in [sec] starting with t=0. Sampling time tCITYDRAIN in the simulation must not necessarily be same as the sampling time given in the raw data. An automatic interpolation of data is provided. In case the data set ends before the end of simulation, values are set to zero. Cyclic repetition of data is optionally provided which may be used for e.g. the repetition of daily flow dynamics within long term simulations. Requirement for cyclic repetition is that the first data set Q(t=0), C(t=0) and the last data set Q(t=tmax), C(t=tmax) are equal. Data provided may either represent grab samples (measurement at specific point of time) or composite samples (values representing the mean concentration / flow over time). Input: none Output: Q Ci Flow [m/s]. Pollutant concentrations [g/m] The number of pollutant concentrations is automatically inherited from the ASCII file storing the raw data.

Parameters: Source file containing the hydrograph Q(t) and pollutograph C(t) (optional). Data type Grab sample.Flows Q and concentrations C given are measured values corresponding to the specific point of time. Composite sample.Flows Q and concentrations C given represent mean values corresponding to the past sampling period. Initial Conditions: No initial condition required

USER MANUAL

15

CITY DRAIN 2.0

Format / Example Usage: n the following the output generated by flow read is shown having an example input file containing 15 min values (T= 900 s) of flow and pollutant concentration. Tabulators are used as delimiters. Example input file (Input_Flowread_Example.txt):
t 0 900 1800 2700 3600 4500 5400 6300 7200 q 0.40 0.45 0.50 0.60 1.00 2.00 0.50 0.30 0.40 C1 0.16 0.20 0.25 0.36 1.00 4.00 0.25 0.09 0.16

The example input is prepared for usage with the cyclic repetition option. There for the first and last entry have to be equal.

Fig. 5. Data read with cyclic repetition having equal sampling time in data (T) and simulation t. Fig. 5 (a) shows a plot of the raw input data having a sampling time of T=900 [s]. Due to cyclic repetition being applied, the last entry of data is substituted as default by the first data

USER MANUAL

16

CITY DRAIN 2.0

entry. The user is requested to provide data used for cyclic repetition having equal data at the first and last entry. Interpretation of raw data The raw data read may be interpreted as grab samples (Fig. 5(b)) or as composite samples (Fig. 5(c))

For grab sample data, the distribution of flow and concentrations is assumed to be linear over T between data points. In the case of composite samples the data read represents mean flows / concentration over the past time step T. Transfer from raw data to City Drain output data The output generated from this block is always of type composite sample regardless what type of raw data was used. The values represent the mean flow / mean concentration over the last time step tCITYDRAIN.

Fig. 6. Interpolation of data when sampling time given in the raw data T and simulation t are not equal. In Fig. 6 (a) a plot of the raw data are shown having time steps T. The example output generated is for sampling times tCITYDRAIN > T. An internal algorithm is used to account for transferring raw data to output data. Differences in interpolated output is given for raw data being interpreted as either grab sample Fig. 6 (b) or as composite sample Fig. 6 (c) (grey shaded areas).

USER MANUAL

17

CITY DRAIN 2.0

The algorithm is based on the principle of conservation of mass. Volume (V) and mass flux (F) over each time step are integrated and are maintained when transferred to sampling steps used in the simulation (tCITYDRAIN).

V = const. = qRAW (t )dt = q tCITYDRAIN F = const. = qRAW (t ) CRAW (t ) dt = q C tCITYDRAIN

USER MANUAL

18

CITY DRAIN 2.0

4.2

Rainread

Function: Reads rain data from ASCII files having a predefined format. As output rain data is provided following the sampling time of the simulation environment. The dates read are transferred into numerical values of time, where counting of time is started with t=0 at the earliest date/time obtained. See the formats section for the data types supported. Input: none Output: rR tout Parameters: Inp.File Name of ASCII file (e.g. filename.ixx ) storing the rain data to be read. Format For the type of format no additional user input is required. The appropriate format is defined by the file extension. Following extensions are supported: ixx km2 mse Volume of rain per time step in [mm/T]. Run time is virtually transferred to the Simulink environment

See section Formats for details on the type of rain data formats supported. Initial Conditions: No initial condition required Formats: Supported formats in CD1_sfun_rainread.m IXX Format used by the Austrian Hydrographic Service. The format uses a line of file for one data entry every 5-minute interval. VR of time interval t1 to t2 is numerically attributed to time t1 . The format of a line is written as: DD.MM.YYYY_hh:mm:ss_rR

USER MANUAL

19

CITY DRAIN 2.0

with DD (day), MM (month), YYYY (year) hh (hour), mm (minute), ss (second) rR (Volume of rain [mm]) Example input file: 01.01.1991 00:00:00 01.01.1991 00:05:00 01.01.1991 00:10:00 01.01.1991 00:15:00 01.01.1991 00:20:00 KM2 0.1 0.1 0.1 0.1 0.1

This format is used as well within the software MOUSE from DHI (Danish Hydraulic Institute). In contrast to the ixx format, where dry rain periods are stored as well, this format produces rather small file sizes. Rain data is stored as well for discrete time steps but splitted into different rain events. Rain events are defined by the dry (rainless) period in between. By default the dry period separating two rain events is taken as 1 hour which is roughly the time for a drainage system to empty. Thus, two consecutive events do not interact hydraulically in the system. Each rain event is always introduced by a header and then followed by the rain data itself. Syntax of the header: 3 YYYYMMDD hhmm 0 N t V.V 3 YYYYMMDD hhmm 0 N t V.V Internal Code Date Starting time in hours and minutes Internal code Number of intervals recorded in the event [-] Timestep of one interval [min] Total rain volume cumulated in the rain event [mm]

Rain data: The rain data is stored row wise carrying 10 entries in a row. One line is started by two space. Rain data R is written with one integer digit and three decimal digits stored as rain rate having the unit [10-3mm/s]. Conversion from rain rate R to rain volume r per time step is done by

r[mm / t ] = R[10 3 mm / s ] 0.001 t[ s ] .


Example input file: 3 19900425 0820 0 1 5 0.1 0.333 3 19900426 0955 0 18 5 0.4 0.250 0.000 0.000 0.000 0.000 0.250 0.000 0.000 0.150 0.100 3 19900426 1320 0 8 5 0.2 0.150 0.100 0.000 0.000 0.000 3 19900426 1915 0 2 5 0.1 0.228 0.022 3 19900427 0925 0 11 5 0.6 0.293 0.002 0.000 0.000 0.293 0.295

0.000 0.000 0.000 0.250 0.000 0.000 0.248 0.002 0.000 0.000 0.250

0.272 0.319 0.298 0.293 0.002

USER MANUAL

20

CITY DRAIN 2.0

Since the output generated from the block is a continuous stream of rain data, timely gaps in between the rain events are filled with zeros for the rain volume. MSE MSE formatted rain data only stores rain events, neglecting dry periods. When reading the data timely gaps are filled by zero values for dry the periods. The format uses a line per data entry having either 5 or 10 minute intervals. rR of time interval t1 to t2 is numerically attributed to time t1 . The format of a line is written as: YY_MM_DD_hh_mm_ss_rR with DD (day), MM (month), YY (year) hh (hour), mm (minute), ss (second) rR (Volume of rain [mm]) Example input file: 81 1 1 22 40 0 0.0000 81 1 1 22 50 0 0.0000 81 1 1 23 0 0 0.1670 81 1 2 4 30 0 0.1670 81 1 2 4 40 0 0.0000 81 1 2 4 50 0 0.0000 81 1 2 5 0 0 0.0000

USER MANUAL

21

CITY DRAIN 2.0

4.3

Raingenerator

Function: Generates rain data by means of a simple stochastic algorithm. Input: none Output: rR tout Parameters: a, b, c, d Parameters used for calibration of stochastic processes Initial Conditions: No initial conditions required Theory: The rain series produced is based on a simple stochastic algorithm for generating the main parameters describing a rain series: TDRY TRAIN rM Duration of next dry period Duration of next rain event Mean rain volume for the next rain event [mm/t] Volume of rain per time step in [mm]. Run time is virtually transferred to the Simulink environment

Within a discrete formulation, the durations TDRY and TRAIN are for sake of simplicity given as the number of time steps. At the end of the last rain event (t0) the durations and the mean rain volume is calculated as:

1 86400 TDRY = log( a ) a t 1 86400 TRAIN = log( b ) b t


1 1 rM = log( c ) c TRAIN

USER MANUAL

22

CITY DRAIN 2.0

The parameters a, b and c are used for linear scaling of random numbers generated, thus may be used for calibrating the scheme to local real rain series. The log scaled parameters a, b and c are random numbers being uniformly distributed in the interval (0,1).

Fig. 7. Schematic for stochastic rain generator Magnitudes of consecutive rain intensities ri within a rain event are as well based on a stochastic process. A single rain event is evaluated as deviation ri from the mean rain intensity rM.

ri = rM ri
The deviation ri is generated randomly, but using the last deviation ri-1 generated as an additive term. This is done for including tendencies of increase or decrease and to avoid unnatural jumps in consecutive rain intensities generated.

ri =

ri1 + d rM 2

The parameter used is a random number being normally distributed with mean 0, variance 2=1, and standard deviation =1. The constant d is used for linear scaling and required as user input.

USER MANUAL

23

CITY DRAIN 2.0

4.4

QCM-Generator

Function: Generates a dynamic output (either for flow Q, concentration C or mass M) on a weekly basis. The block is primarily designed to generated dynamic fluxes representing flow of concentration of DWF. Input: none Output: Q/C/M tout Parameters: The parameters Q/C/M, time and daily mean value are to be inserted for workdays and weekends respectively. Dynamic vector scaled to unity (mean value=1); Depending on the user the dynamics represent either flow Q, concentration C or mass M. time time vector associated to Q/C/M vector daily mean Represents the mean daily flow, concentration or mass discharged for workdays or weekends. Interpolation type: linear, spline Theory: The parameters Q/C/M, time and daily mean value are to be inserted for workdays and weekends respectively. From these given time series (typically hourly values), time a time USER MANUAL 24 Q/C/M Dynamic vector alternating after one week; Depending on the user the dynamics represent either flow Q, concentration C or mass M. Run time is virtually transferred to the Simulink environment

CITY DRAIN 2.0

series for a full week is generated (5 workdays and 2 weekend days) and are repeatedly sent as output. Temporal scales are adjusted to the time steps used in the current simulation where values are interpolated respectively. The type of interpolation made is either linear or spline.

USER MANUAL

25

CITY DRAIN 2.0

CATCHMENT/SEWER BLOCKS
In comparison to CITY DRAIN 1.0, the catchment blocks have been significantly enhanced with regard to dynamics of flow and pollutant transport, Where the former blocks transport mechanisms was based on pure translation, these blocks mimic transport processes by the Muskingum method. Again, blocks are differentiated for Combined sewer system (CSS) and Separate sewer system (SSS). For both types, a classic version using Muskingum exclusively and a Retention version that introduced additional storage volume, are provided. The retentiontype catchments may be especially used in flat urban catchment where the Muskingum routing method (and its retention/storage ability) may not be sufficient. The Muskingum with multiple subcatchments is used in the catchment blocks as well as in Sewer and River block presented in chapter 5.4.1 Simplified Muskingum .

USER MANUAL

26

CITY DRAIN 2.0

5.1

Catchment CSS

Function: Catchment CSS block is designed to simulate a combined sewer system on catchment level. The block copes the major drainage-related processes in an urban area and returns for each time step both the current amount and pollutant concentration of the aggregated outflow from the catchment. Storm water runoff and water quality aspects are computed here with a set of consistently simple conceptual models. The main processes that appear on an urban area in this context are Runoff generation Overland flow USER MANUAL 27

CITY DRAIN 2.0

Dry weather flow generation Runoff and wasteflow pollution

The associated dynamic inputs can be distinguished for inputs that (a) originate from the catchment and (b) inputs which originate from upstream and are to be routed through the catchment. The modified scheme allows both, feeding of the uppermost block (QI,U) as well a distributed feeding of blocks (QI,L). Thus, inputs provided such as the rain intensities (rl) acting on the catchment, the dry weather flows generated in the catchment (DWFL) and parasite water infiltrating into the sewer system (Qpl) are distributed homogeneously within the catchment. Flows from upstream of the catchment are all the way routed through and thus are fed to the uppermost sub-block. In case of the CSS block an upstream wastewater stream Qe may be provided as dynamic input. Input: rL QDWF,L QP,L Qe Output: Qe Parameters: A hi hp nTA nP CRAIN K X Catchment Area A [ha] Runoff coefficient [-]. In the range of = 0...1. Initial loss [mm] Permanent loss [mm/ day] Number of sub areas/subreaches nTA [-] Number of pollutants nP [-] Vector of pollutant concentrations of storm water flow [g/m] Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. K applies to one subreach and does not cover travelling time for all sub reaches. Dimensionless weighting factor that relates to the amount of wedge storage [-] in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Combined sewer (out) flow at the catchment outlet [q [m/s] C1[g/m] C2[g/m] .]. Rain volume per time step [mm/ t]. Dynamic dry weather flow [q [m/s] C1[g/m] C2[g/m] Dynamic flow parasite water [q [m/s] C1[g/m] C2[g/m] Wastewater/stormwater flow introduced from an upstream catchment [q [m/s] C1[g/m] C2[g/m] ]

Initial Conditions: No initial conditions applied Theory: For details of the utilized blocks/s-functions see chapters 5.4.1 5.4.2 5.4.3 8.1 Simplified Muskingum . Catchment Loss Model Catchment Flow Model - SW (storm water) Mixing

USER MANUAL

28

CITY DRAIN 2.0

5.2

Catchment SSS

Function: Catchment SSS block is designed to simulate a separate sewer system on catchment level. Equivalent to the CSS block, it copes with the major drainage-related processes in an urban USER MANUAL 29

CITY DRAIN 2.0

area and returns for each time step both the current amount and pollutant concentration of the aggregated outflow from the catchment. In contrast to the CSS block, streams of Storm water runoff and wastewater are treated in separate stream, leading to two dynamic block output (R and DWF). Identically to the CSS block, associated dynamic inputs can be distinguished for inputs that (a) originate from the catchment and (b) inputs which originate from upstream and are to be routed through the catchment. The modified scheme allows both, feeding of the uppermost block (QI,U) as well a distributed feeding of blocks (QI,L). Thus, inputs provided such as the rain intensities (rl) acting on the catchment, the dry weather flows generated in the catchment (DWFL) and parasite water infiltrating into the sewer system (Qpl) are distributed homogeneously within the catchment. Flows from upstream of the catchment are all the way routed through and thus are fed to the uppermost sub-block. For the SSS block two ports allow the dynamic inputs to the storm and wastewater sewer (R and DWFu respectively). Input: rL Ru QDWF,L QP,L QDWF,U Output: QR QDWF Parameters: A hi hp nTA nP CRAIN K X Catchment Area A [ha] Runoff coefficient [-]. In the range of = 0...1. Initial loss [mm] Permanent loss [mm/ day] Number of sub areas/subreaches nTA [-] Number of pollutants nP [-] Vector of pollutant concentrations of storm water flow [g/m] Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. K applies to one subreach and does not cover travelling time for all sub reaches. Dimensionless weighting factor that relates to the amount of wedge storage [-] in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Stormwater (out) flow at the catchment outlet [q [m/s] C1[g/m] C2[g/m] Dry Weather (out) flow at the catchment outlet [q [m/s] C1[g/m] C2[g/m] Rain volume per time step [mm/ t]. Provided by source block CD1_rainread. Dynamic dry weather flow from an upstream catchment [q [m/s] C1[g/m] C2[g/m] Dynamic dry weather flow [q [m/s] C1[g/m] C2[g/m]; Dynamic flow parasite water [q [m/s] C1[g/m] C2[g/m] Dynamic dry weather flow from an upstream catchment [q [m/s] C1[g/m] C2[g/m]

With regard to flow dynamics, stormwater and dry weather flow is routed using equivalent catchment/model parameters nTA, K and X respectively. Initial Conditions: No initial conditions applied Theory: For details of the utilized blocks/s-functions see chapters 5.4.1 5.4.2 5.4.3 8.1 Simplified Muskingum . Catchment Loss Model Catchment Flow Model - SW (storm water) Mixing

USER MANUAL

30

CITY DRAIN 2.0

5.3

Retention Catchment (CSS and SSS)

Function: The Retention Catchments (CSS and SSS) apply in principal the same underlying models as the classical catchments CSS and SSS. As the Muskingum method may not work sufficiently with regard to storage when it is applied for flat urban catchment, these advanced block types where generated. In order to provide an additional storage ability within the block to mimic backpressure effects, a classical catchment is put in series with a CSO structure inside the blocks.

USER MANUAL

31

CITY DRAIN 2.0

Fig. 8: Internal flow scheme of the retention type catchment CSS

Fig. 9: Internal flow scheme of the retention type catchment SSS The storage volume introduced by the storage volume of the virtual CSO structure is with respect to real conditions interpretable as part of the storage volume included in the sewer/catchment system. The throttled flow leaving the virt. CSO and consequently the catchment system is as well definable by the user. As backpressure conditions occur usually with a filled sewer system, the maximum throttled flow is interpretable as maximum flow obtainable from the sewer system under filled/pressure conditions. All flows exceeding that value are usually stored in the system, either in the sewer or worst case as overflow at manholes. In any case, the volume needs to be stored in the system. To mimic the behaviour numerically, flows are fed back from Qr(outflow) to Qr (inflow). The ports can be connected directly where a discrete state space block is included in the block after the flow Qw to avoid a numerical loop. Thus, storage of water and matter is numerically delayed by one time step. For the case of the CSS, the full stormwater/DWF stream is recycled and introduced as additional (distributed) DWF to the catchment system. For the case of the SSS the DWF stream exclusively is recycled. Stormwater is not subjected to an additional retention. In case fluxes occurring within the stormwater stream of a SSS are of special concern, a recycle feature can be included similarly. Block Types: Input: see blocks - Catchment CSS - Catchment SSS - CSO Type B USER MANUAL 32 Catchment CSS Catchment SSS CSO Type B

CITY DRAIN 2.0

Additional input: QRi Output: CSS Qe VCI SSS QR QDWF VCI Parameters: As required for blocks Catchment CSS Catchment SSS CSO Type B Combined (out) flow at the catchment outlet [q [m/s] C1[g/m] C2[g/m] Currently stored volume and concentration [V [m] C1[g/m] C2[g/m] Stormwater (out) flow at the catchment outlet [q [m/s] C1[g/m] C2[g/m] Dry Weather (out) flow at the catchment outlet [q [m/s] C1[g/m] C2[g/m] Currently stored volume and concentration of DWF stream [V [m] C1[g/m] C2[g/m] Recycled stream for additional retention.

Initial Conditions: No initial conditions applied

USER MANUAL

33

CITY DRAIN 2.0

5.4
5.4.1

Underlying Blocks in catchment models


Simplified Muskingum routing method Rainfall measurements are likely given as rain volumes, accumulated during a certain period of time (usually in the range of 5 10 min intervals). The rain ri [mm] is the volume of rain fallen between ti-1 and ti time. Consequently the derived flow does not describe the actual flow at time ti but the mean flow between ti-1 and ti anyway. Therefore the Muskingum equation (Roberson et al., 1995b) is newly derived using a simplified numerical scheme (Achleitner et al., 2006; Motiee et al., 1997).

V =

Vi + Vi 1 = K QE ,i + K X (QI ,i QE ,i ) 2 V Vi Vi 1 = = Q I ,i Q E ,i t t

Eliminating the stored volume Vi leads to

2 K [X QI ,i + (1 X ) QE ,i ] Vi 1 = (QI ,i QE ,i ) t + Vi 1
Consequently the mean outflow QE,i is

QE ,i = C X QI ,i + CY Vi1
with

CX =

t + K (1 X ) 2

t KX 2

and

CY =

1 t + K (1 X ) 2

In contrast to the original discrete scheme used, only two instead of three parameters are required. The volume stored at time ti is

Vi = (QI ,i QE ,i ) t + Vi 1
For numerical stability, different requirements are to be fulfilled. For assessing the wave travelling through the reach, the sampling time t is to be smaller than the flow time K.

t K ; 1

K Requirement (1) t

Further, the coefficients CX and CY are required to be positive for a positive contribution of the inflow and the stored volume to the outflow.

C X 0; CY 0 Requirement (2)
Derived from these requirements the ratio of K/t is to be in the range of USER MANUAL 34

CITY DRAIN 2.0

K 1 t 2 X

for obtaining numerical stability and avoiding negative values in the coefficients:

Fig. 10: Valid range for numerical stability in the simplified discrete Muskingum scheme. Consequently the range for X values is defined as well from this equation, where X is in the range of 0 < X < 0.5. Only for this range the above stated relation of

1 ....

1 2X

holds true. For dealing with n subreaches, the formulas are rearranged and the nomenclature is taken as followed to include the numbering of subreaches j (1...n).

Fig. 11: Schematic on nomenclature for multiple subreaches The Muskingum parameter K applies to the total reach. For simplicity a reach is always split for n equal subreaches, each having an associated Muskingum parameter K:

K'= K n
The overall wave travelling time K is substituted by K being the travelling time for each subreach ( K ' = K n ). The outflow of the reach j is: USER MANUAL 35

CITY DRAIN 2.0

Qi j +1 = C X Qi j + CY Vij1
The storage volume at time ti in reach j is

Vi j = Qi j Qi j +1 t + Vi j1
So far, the model only considers flow entering the most upstream compartment. This is feasible, as long as the method is used for only transport pipes without any lateral flow. For applications such as river or catchment routing, flow entering along the pathways is necessary. This is the case for dry weather flow that is generated all over the catchment but also for rainfall that is spatially distributed. A general scheme including compartment-wise inflows is illustrated in the following.

Fig. 12: Muskingum routing with multiple sub-reaches having upstream and compartment-wise inflows. The total flow introduced locally QI,L is according to the area and subreaches - evenly distributed over n sub-reaches (QI,L / n). The formulas do not have to be changed as the total local inflow comprises both, the upstream flow and the locally generated flow.

j QI ,L j Qi j +1 = Qi j C X + Vi j1 CY = Qi + n C X + Vi1 CY
described function itself has been as well extended 5.4.2 Catchment Loss Model

Function: Applies initial and permanent loss to a given precipitation, responsible for the generation of effective runoff height. Input: rR Output: he Parameters: S function parameters [ hi , hp , ] hi hp Initial loss [mm] Permanent loss [mm/ t] Runoff coefficient [-]. In the range of = 0...1. USER MANUAL 36 Rain volume per time step [mm/ t]. Provided by e.g. source block CD1_rainread. Effective runoff per time step [mm/ t].

CITY DRAIN 2.0

Initial Conditions: No initial conditions to be applied Theory: The underlying model is a virtual basin having the volume (height) of hI. The initial loss is therefore represented by a filling of the basin, where the effective runoff he is computed as spilled volume per time step t .

he = (rR hI ) 0
Permanent loss per time step hP is taken into account only during dry weather periods, used for emptying the virtual basin. 5.4.3 Catchment Flow Model - SW (storm water)

Function: Block for generating outflow Qe from a given effective runoff height he [mm / t]. Pollutant concentrations given as constant parameters - are added to the flow. Input: he Output: Qe Stormwater runoff in [m/s] at the catchment outlet, including concentrations of substances carried. Concentrations applied are introduced as constant parameter CRAIN. Effective runoff height per time step [mm/ t] at the catchment outlet.

Parameters: S function parameters [A, nP', CRAIN, tSAMP] A nP CRAIN t Theory: The S-function is responsible for creating a flow vector representing the storm water flow at the catchment outlet only. The function covers the transfer from dynamic rain height he in terms of [mm/t] to flow rate qe [m/s] using the catchment area A. The resulting outflow rate from the catchment is calculated as Catchment Area [m]. Number of pollutants carried nP [-] Vector of pollutant concentrations of storm water flow [g/m] Sampling rate (time steps) in [s]. t is inherited from the global setting of sampling times.

qe [m / s ] =

he [mm / t ] A[m] 1000 t[ s ]

The number of substances carried nP must meet the length of the vector holding the pollutant concentrations (CRAIN ). The resulting output vector Q e has the form of

Qe = qe

CRAIN ,1 L CRAIN ,K

L CRAIN ,nP

]
37

USER MANUAL

CITY DRAIN 2.0

5.5

Sewer

Function: Block for flow / pollutant routing in a sewer by means of the Muskingum routing method applied for water and matter. The block may be used for sewer stretches not subjected to additional surface runoff or DWF along ist flow path. Upstream inflow is required as dynamic input Qi. Input: Qi Output: Qe VCi Parameters: K X nP nT Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. K applies to one subreach and does not cover travelling time for all sub reaches. Dimensionless weighting factor that relates to the amount of wedge storage [-] in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Number of pollutants nP [-] Transport time defined as number of time steps/sub-reaches. Effluent flow at the sewer outlet. Current volume and concentrations stored in the block. Inflow to be routed in the sewer.

Initial Conditions: No initial conditions to be applied. Theory: See chapter 5.4.1 Simplified Muskingum routing method

USER MANUAL

38

CITY DRAIN 2.0

5.6

Retention sewer

Function: The Retention Sewer block utilizes as well the Muskingum routing model as the regular Sewer block. As the Muskingum method may not work sufficiently with regard to storage when it is applied for flat stretches, this advanced block type was generated. In order to provide a an additional storage ability within the block to mimic backpressure effects, a classical sewer block is put in series with a CSO structure inside this new block.

Fig. 13: Internal flow scheme of the retention type sewer block Analoguous to the scheme applied in the catchment blocks, an additional storage volume is introduced. The virtual CSO structure is with respect to real conditions interpretable as part of the storage volume included in the sewer system. The throttled flow leaving the virtual CSO and consequently the catchment system is as well definable by the user. As backpressure conditions occur usually with a filled sewer system, the maximum throttled flow is interpretable as maximum flow obtainable from the sewer under filled/pressure conditions. All flows exceeding that value are usually stored in the system, either in the sewer or worst USER MANUAL 39

CITY DRAIN 2.0

case as overflow at manholes. In any case, the volume needs to be stored in the system, thus is in this model fed back using a recycle flow. To avoid a numerical loop, a discrete state space block is included after the flow QW. Block Type: Input: Qri Qei Output: Qe Qr VCi Parameters: See blocks - Sewer - CSO Type B Initial Conditions: No initial conditions to be applied. Theory: See chapters of underlying blocks 5.4.1 Simplified Muskingum routing method 5.7 CSO (Types A and B) Effluent flow at the sewer outlet. Recycled storage flow. Current volume and concentrations stored in the block. Inflow to be routed in the sewer. Inflow from upstream system. Sewer CSO Type B

USER MANUAL

40

CITY DRAIN 2.0

5.7

CSO (Types A and B)

Function: Simulation of an overflow structure for either combined or separate sewer. Inflow is routed downstream via the effluent outlet (QE) which is limited by a maximum effluent flow rate QE,MAX [m/s]. Flow exceeding the structures storage capacity (VMAX) is routed via the CSO overflow (QW [m/s]). With the model implemented hydraulic and pollutants routing is based on instant and ideal mixing in the CSO structure. CSO Type B contains, in contrast to Type A, a simplified modelling option of sedimentation. Using a linear sedimentation coefficient sed in CSO type B allows modelling of lower pollutant concentrations present in the overflow (QW) than in the effluent flow (QW). Input: Qi Output: Qe Qw Parameters: CSO Type A CSO Type B VMAX QE,MAX nP sed [VMAX, Qe,MAX, nP', t] [VMAX, Qe,MAX, nP', sed, t] Effluent flow at the CSO structure. Overflow generated when CSO storage volume is exceeded. Inflow to CSO structure.

Basin volume (storage volume) [m] Maximum Effluent flow [m/s] Number of pollutants carried [-]. Sedimentation coefficient USER MANUAL 41

CITY DRAIN 2.0

Sampling rate t [s] is inherited from global setting of simulation parameters.

Initial Conditions: No initial conditions to be applied. The structure is considered being empty at the beginning of the simulations. Theory: Hydraulics of the CSO structure: The basic differential equation of the hydraulic mass balance for the CSO structure is written as

V = QI (t ) QE (t ) QW (t ) t

Fig. 14: Variable definitions of discrete CSO model The flows QI , QE and QW are considered as mean flows occurring during the discrete timely period. Herein the volume is related to discrete points of time. The mass balance equation therefore is

Vi Vi 1 = QI ,i QE ,i QW ,i t
where i denotes the time step considered. Restrictions are usually given by the maximum Volume of the CSO structure (VMAX) and the maximum outflow from the structure QE,MAX. Depending on the magnitude of inflow QI,i and the previous Volume stored (Vi-1), three different cases apply. The cases can be differentiated considering the hydraulic mass balance with no overflow QW = 0 and fully developed outflow QE = QE,MAX. The virtual volume Vi from this mass balance denotes

Vi ' = (QI ,i QE ,MAX ) t + Vi1 .


Three cases can be distinguished: Case No. 1 2 3 Vi < 0 Vi > VMAX 0 < Vi < VMAX Qw = 0 No overflow QE < QE,MAX Outflow QE not fully developed QW > 0 QE = QE,MAX Overflow QW developed Outflow QE fully developed

Qw = 0 No overflow QE = QE,MAX Outflow QE fully developed

USER MANUAL

42

CITY DRAIN 2.0

In case Vi falls below zero (case 1), the maximum outflow QE,MAX from CSO structure did not develop throughout the whole time and the structure falls dry. In order to keep the hydraulic mass balance, the outflow rate is adjusted (reduced). In case of a positive Vi (cases 2 and 3) the maximum flow rate QE,MAX develops. An overflow occurs when having a virtual volume large than the maximum (Vi > VMAX). For calculating the unknowns Vi , QI,i and QW,i the following equations apply for the respective case: Case 1

Vi = 0
Q E ,i =
Case 2

Vi 1 + QI ,i QE , MAX t ;

QW ,i = 0

Vi = VMAX QE ,i = QE , MAX
Case 3 ;

QW ,i = QI ,i QE , MAX

VMAX Vi 1 t

Vi = (QI ,i QE , MAX ) t + Vi 1 QE ,i = QE , MAX


;

QW ,i = 0

Mixing and Settling The here presented scheme builds on the simplified hydraulic scheme for CSO storage. Flows are taken into account that represent mean flows occurring during a time step t. Similar, the concentrations entering or leaving the chamber are mean concentrations over a time step. Flow entering the basin is assumed to be fully mixed with the volume in the structure. The new concentrations being present in the chamber are then taken for the effluent and overflow concentrations. This is done for (a) simplification of calculations and (b) in order to avoid numerical shortcomings (e.g. negative concentrations). Hydraulic parameters/variables QI,i Inflow for timestep i Vi-1 Volume stored for the previous time step VQI,i Volume added to the storage by inflow QI,i during time step t Vi Vi QW,i QE,i Volume stored for the current time step (including overflow volume) Volume stored for the current time step Overflow for timestep i Outflow for timestep i

Substance parameters/variables CQIi Concentration in the inflow CV,i-1 Concentration of stored volume in previous time step i-1 CV,i Concentration of stored volume in current time step i related to the total volume Vi CV, i Concentration of stored volume in current time step i related to the stored volume Vi CQW,i CQE, i Concentration of overflow volume in current time step i Concentration of outflow volume in current time step i USER MANUAL 43

CITY DRAIN 2.0

Mass balancing is done by first mixing the inflow QI with the stored volume of the previous time step.

Fig. 15: Scheme for flow and pollutant mass balance

V 'i = QI ,i t + Vi 1
The concentration in this volume is

C 'Vi =

C QI ,i QI ,i t + CV ,i 1 Vi 1 V 'i

for

V 'i > 0

In order to account for settling of matter, the concentrations in the overflow volume are reduced using a settling coefficient SED to virtually account for the sedimentation. The concentrations present in the overflow are reduced by:

CQW ,i = C 'V ,i (1 SED )


The mass balance for the substance matter present in the volume Vi leads to an increased concentration in the remaining volume Vi . Considering the effluent concentration CQE,i being the same as the chamber concentration CV,i leads to

CV ,i =

CQI ,i QI ,i t + CV ,i1 Vi1 QW ,i t 1 ( 1 ) SED Q t + V QE ,i t + Vi I ,i i 1 CQE ,i = CV ,i

The concentration in the overflow is therefore

CQW ,i =

CQI ,i QI ,i t + CV ,i1 Vi1 QI ,i t + Vi1

(1 SED ) .

For numerical stability, following terms are required to be > 0:

QI ,i t + Vi1 > 0 and QE ,i t + Vi > 0


Physical interpretation of the first term would be that no inflow occurs ( QI,i = 0 ) and the basin was empty in the last time step ( Vi-1 = 0 ). Therefore, the concentration in the chamber and the effluent concentration are set to zero ( CE,I = CV,I = 0 ). Setting the concentration to zero is done for the overflow quality as well ( CQW,i = = 0 ) , since hydraulically no overflow is given. The second boundary condition fails when no outflow occurs (QE,i = 0) and if the basin is USER MANUAL 44

CITY DRAIN 2.0

empty at the present time step (Vi = 0). Again the concentrations are set to zero ( CQW,i = CQE,i = CV,i = 0), due to having an empty basin at the present time step, having not outflow and overflow.

USER MANUAL

45

CITY DRAIN 2.0

5.8

Pumping station

Function: The implemented concept of a simplified discrete formulation of a pumping station, is equivalent to other models used - based on mean flows from and to the storage structure. The central idea is to describe a pumping station with a number of pumps, each with its fixed pumping rate (QP,k) and its set points (water levels) for turning pump either on (hP,kON) or off (hP,kOFF). The number of installed pumps including their characteristics is up to the user and adaptable. Input: Qi Output: Qp Qw Vi Parameters: Vp NP Qp VON VOFF nP Pumped flow as a sum of all pumps installed [q [m/s] C1[g/m] C2[g/m]. Overflow generated in excess of the pumped flow [q [m/s] C1[g/m] C2[g/m]. Current volume and concentrations stored in the pumping station [V[m] C1[g/m] C2[g/m]. Maximum storage volume of pumping station [m3]. Number of installed pumps [-]. Vector of pumping rates for all pumps installed [m3/s]. Vector of volume representing the ON-set points for the pumps [m3]. Vector of volume representing the OFF-set points for the pumps [m3]. Number of pollutants [-] Inflow to CSO structure.

Initial Conditions: No initial conditions to be applied. The structure is considered being empty at the beginning of the simulations.

USER MANUAL

46

CITY DRAIN 2.0

Theory: The storage volume is defined by the basin volume VMAX of the structure.

Fig. 16: Schematic of pumping station with multiple (here 3) pumps By definition the pumping rates are defined as

QP = [ QP ,1 .... QP ,k
Set points (water levels) are
ON ON hP = [ hP ,1 OFF OFF hP = [ hP ,1 ON .... hP ,k OFF .... hP ,k

.... QP , NP

ON .... hP , NP OFF .... hP , NP

] ]

Alternatively these may be written in terms of volume using the base area A of the structure
ON 0 VPON = A hP VMAX OFF 0 VPOFF = A hP VMAX

where set points are to be within the range of the structure storage capacity VMAX. Requirement for the set points is that the ON points are more elevated than the corresponding OFF points.
OFF ON hP ,k hP ,k

Further the set points are to be monotonically increasing in elevation.


ON hP ,1 OFF hP ,1 ON hP ,k OFF hP ,k ON hP , NP OFF hP , NP

The scheme assumes the inflow and outflows as mean values over the last time step. The inflow QI,i+1 is further fully mixed with the structures content from the last time step Vi resulting in a virtual content Vi+1.

V 'i+1 = Vi + QI ,i+1 t
This virtual content represents the volume which would have been accumulated without pumping. Operation of pumps is driven by the water level (or by the stored volume respectively) where the order in which pumps are operating is according to the ON/OFF set USER MANUAL 47

CITY DRAIN 2.0

points in increasing sequence. Pump 1 is operating in case the virtual volume Vi+1 tops the ON set point of the pump.
ON V 'i+1 = Vi1 +1 VP ,1

For homogeneous notation for all pumps, the virtual volume Vi+1 is termed V1i+1 since it is compared with the set point volume of the first pump. In case there is no operation of the pump the pumping rate for considered time step (QP,1) is set to zero.

Q'P ,1 = 0
For the case that the pump is operating it must be checked whether the volume available is sufficient for operating the pump throughout the whole time span t. Secondly, the remaining volume must be larger than the OFF set point of the pump (VOFFP,1).
OFF Vi1 0 +1 QP ,1 t VP ,1

Since the OFF set point is required to be greater than zero, both requirements are fulfilled simultaneously. For the case that sufficient volume is available for full operation, the pumping rate for the considered time step is set to the given pumping rate.

Q'P ,1 = QP ,1
If operation is not possible for the full period t, the pumping rate QP,1 is reduce instead of partial operation with the original pumping rate QP,1.
OFF Q'P ,1 = Vi1 / t +1 VP ,1

This does not reflect the real operation but is necessary for fitting in the discrete time scheme (time steps t) used. Finally the mass balance, respectively the volume withdrawn (V1i+1 - VOFFP,1) remains the same. This procedure is redone for each of the remaining pumps starting at a reduced volume.
2 1 Vi+ 1 = Vi +1 Q ' P ,1 t

The procedure using a generalized formulation for processing all available pumps is shown in the following figure, wherein the procedure is looped for the number of pumps (NP) used.

USER MANUAL

48

CITY DRAIN 2.0

Fig. 17: Numerical scheme for a pumping station based on discrete formulation The resulting vector of pumping rates defines the total volume withdrawn

Q'P = [ Q'P ,1 ... Q'P ,k


NP k =1

... Q'P , NP

V 'P = Q'P ,k t
The remaining volume in the storage tank denotes therefore as

Vi+1 = V 'i+1 V 'P = Vi + QI ,i+1 t V 'P


Still this volume possibly exceeds the storage volume VMAX. of the structure.

Vi+1 VMAX
If this is the case, the exceeding volume is withdrawn via an overflow weir.

QW = (Vi+1 VMAX ) / t
Consequently the remaining volume in the tank equals the maximum storage capacity.

Vi+1 = VMAX
Fig. 18 shows an example for two pumps operating in parallel. No overflow is generated in the presented example.

USER MANUAL

49

CITY DRAIN 2.0

Fig. 18: Example pumping period with 2 pumps operating; (top) volume stored and (bottom) in- and outflows from the pumping station

USER MANUAL

50

CITY DRAIN 2.0

6 6.1

WASTEWATER TREATMENT WWTP (simple)

Function: Models a WWTP that is consideration to fulfill predefined requirements of removal efficiencies RE,MIN [-] and maximum effluent concentrations CE,MAX [g/m].

Thus emission standards are considered to be fulfilled, regardless the hydraulic or pollutant load associated. In the model no process are considered. Input: Qi Output: Qw Parameters: S function parameters: [nP', CE,MAX, RE,MIN] RE,MIN CE,MAX nP Theory: Based on user defined removal efficiencies RE,MIN [-] and maximum effluent concentrations CE,MAX [g/m], concentrations of the inflow are reduced and assigned to the effluent flow. For each substance the more stringent of the defined prerequisites is applied. Required removal efficiencies [-] Maximum effluent concentration [g/m] Number of pollutants carried [-]. Outflow from the WWTP. Inflow to WWTP.

CW ,i = min[CE ,i ,MAX

; C I ,i RE ,MIN ]

Thus, it is assumed that the WWTP meets the prerequisites defined, regardless the magnitude of either hydraulic or pollutant loading applied.

USER MANUAL

51

CITY DRAIN 2.0

6.2

ASM WWTP

Function: The ASM-WWTP is designed to consider biological treatment as well as primary and secondary clarification. In contrast to other blocks, specific substances are required for usage of this model, as a modified ASM1 (Activated sludge model) is used. Input: Qi Flow vector with [Q C1 C2Cn] in the order of the global substance naming (CD_Parameters)

For the blocks input, the flow vectors is required to contain the following five substances/information as a minimum requirement to be run properly. Temp CODsol CODpar Ntot Ptot Inflow temperatur to the treatment plant[C] COD soluble [mg/l] COD particulate [mg/l] total Nitrogen [mg/l] total Phosphorus [mg/l]

The respective ASM1 components are derived from these by inflow conversion of substances. Names used in the global CD_parameter setting must include these substance names as written here (case sensitive). The respective numerical values from the inflow are then used automatically within the treatment processes. Output: Qe Treated outflow from the WWTP providing the flow q and substances according to the inflow to the treatment plant. ASM1+P This output port is specific for the WWTP, returning a vector representing Qe using internal used ASM1 type substances. The vector contains the flow q [m/s] followed by the components of the WWTPs biokinetic model in the order as shown in Tab. 2. Thus, the vector is of 11 components and does not match the global naming system used. It is rather an additional information for the user, not ment to fed to any other block.

USER MANUAL

52

CITY DRAIN 2.0

Parameters: WWTPfile TWWTP FSOL nP Definition file of the treatment plant (file name) Internal (constant) time step used for calculation of hydraulic and biochemical processes in the WWTP. [s] Fraction of soluable part of the [-] Number of pollutants [-]

Substances other than required by the WWTP are as well accepted by the block but treated without a biological conversion. Commonly substances that are surplus of the minimum required ones are bypassed and not used in the process. As a consequence this may lead to temporal differences in substance flow and mass balances between bypassed and nonbypassed matter. Thus, it was decided to avoid bypass substance and subject all substances to flow, mixing and settling processes within the treatment plant but exclude the biological conversion for the surplus of substances. The parameter Fsol defines the soluable fraction of surplus substances. The fractions in the vector are to be entered in the order of the appearance of the surplus substances in the global substance list defined in CD_parameters. Example: Global substance list: and Flow vector: Vect. of wwtp subst.: Vect. of surplus subst.: Sol. fractions Treatment plant file: Although the treatment plant is realized in a single block as a unit process, flexibility in the arrangement of compartments is still given. The treatment plant outline is load via a definition file that is stated in the blocks mask. Next to compartemt specific parameters such as compartment type, volume etc.., flow quantities and source are defined for each compartment. The file is ASCII code and can be opened and with every text editor. As an example, a conventional treatment plant having a primary clarifier, anaerob and aerob reactor and a secondary settler is outlined below. The coding of the plant design is as followed W P R R S E r=4 V=50 0=1 V=300 1=1 4R=1 3=2 O2=0.0 V=500 2=4 O2=2.0 A=100 h=3.5 n=10 3=2 4E=1 Temp CODsol Cu CODpar Cd Ntot Ptot Bp Q = [q CTemp CCODsol CCu CCODpar CCd CNtot CPtot CBp] Q = [q CTemp CCODsol CCODpar CNtot CPtot] Q= [CCu CCd CBp] Fsol= [FCuSOL FCdSOL FBpSOL]

where the different compartments are outlined together with the coded lines:

USER MANUAL

53

CITY DRAIN 2.0

Fig. 19: Example plant layout including code explanations

USER MANUAL

54

CITY DRAIN 2.0

The letter in each line marks the type of information followed by a blank and the parameter list. Following the above given example, the first line (marked with W) defines the number of reactors given in the plant (e.g. r=4). As virtual compartments the inflow is termed as compartment 0 and the effluent is termed compartment E. The following lines start with the respective identifier for the different types of compartments. P R S Primary clarifier Reactor (with or without aeration) Secondary clarifier (Takacs settler)

followed by flow inputs to the compartment and compartment specific parameters. The flow quantity between the compartments is thereby defined as a multiple of the inflow. The internal numbering of compartments used to define the source of flow is made in the order of appearance of entries in the text file. Thus, for each compartment the flow(s) entering are described by the following syntax: COMP#SOURCE =n COMP#SOURCE n Example: 4=1 Flow Q=1xQIN originating from compartment #4 Number of the source compartment Flow quantity relative to the inflow quantity QIN

Within the last row, flow from the treatment plant is defined. Effluent is thereby described by the key E as a virtual effluent compartment. The parameters required at each type of compartment are given below: W - WWTP P - Primary Clarifier R - Reactor S - Settler (Tacacs) r=total number of reactors in the WWTP V=Volume [m] V = Volume [m] O2 = Oxygen Concentration [mg/l] A=Surface area of the settler [m] h=Height of the settler [m] n=Number of settling layer (according to Takacs) Flow from the WWTP

E - Effluent

In the above given example the compartment 2 has inflow from 3 source. The first one originates from the compartment 1 at a rate of 1xQIN. Settler have in contrast to the other types of compartment two effluent stream. The actual effluent stream (E) is carrying the treat water and where the return sludge stream (R) is carrying activated sludge. Thus, when specifying a settler compartment as source it is required to provide the compartment number followed by the effluent type (E or R). The respective entry in the example given is 4R=1, specifying that a return sludge flow of one time the inflow QIN is diverted from the settler to the compartment 2. For the reactors R, which are assumed to be fully mixed, the effluent stream are separated according to quantities and no distinction regarding concentration is the case. For the primary USER MANUAL 55

CITY DRAIN 2.0

clarifier only fluxes withdrawn from the top zone are available to be further used. Settling of matter is made, where the settled material is not proved as a separate stream. Withdrawn quantities from the different compartment are generated automatically according to the inflow defined. Theory: A process description for the wastewater treatment process incorporating an ASM 1 type process model was developed. Continuous simulation of wastewater treatment plant behaviour under both dry and wet weather conditions, is based on the assumptions of the IAWQ Activated sludge model (Henze et al., 1987). Further various other sub-models are included that allow simulating a complete treatment plant. The implementation follows closely the model/software denoted RUMBA. The software was developed by Rauch (1997) and is used as sub-element for other works (Harremos and Rauch, 1996; Rauch and Harremos, 1996, 1997). The used model is based the assumptions of the IAWQ model of Henze et al. (1987). Main features of the implemented model are described in the following. The basic concept implemented is that of a recirculation plant with a primary clarifier in front followed by 2 biological reactors and a final clarifier. The oxygen set points in the two biological reactors can be determined in the setup program, so nitrification - denitrification schemes can be simulated easily. Note that the O2 set points are not dynamic values but fixed for the simulation. Furthermore there is both an internal recycle and a recycle from the settler to the first reactor. The effluent from the primary clarifier can be directed to both reactors, i.e. the first one can be partially bypassed to model step feeding. The following 4 quality descriptors characterize the influent to the treatment plant: COD soluble COD particulate total Nitrogen total Phosphorus

These quality descriptors are defined in the sewer system model. However, the values must be in the usual range for municipal wastewater and rain runoff. In the following an overview on the conversion parameters (including default values) used to transfer inflow quality descriptors to ASM fractions: Tab. 1: Conversion model parameters Symbol fsSI fsSS fsXS fpXS fpXH fpXI iX iXi iP Description Fraction of SI in CODsol Fraction of SS in CODsol Fraction of XS in CODsol Fraction of XS in CODpar Fraction of XH in CODpar Fraction of XI in CODpar Fraction of N in org. matter Fraction of N in inert m. Fraction of P in X Default value 0.125 0.375 0.500 0.420 0.330 0.250 0.070 0.020 0.01 Sum 1.0

1.0

In the conversion model the COD components are determined more or less directly from the organic matter fraction parameters f. The amount of XA in the influent is set to zero. Primary Clarifier model Primary clarifiers are widely used in activated sludge systems for the purpose of sedimentation and removal of suspended particulate matter in the wastewater. USER MANUAL 56

CITY DRAIN 2.0

The model implemented here assumes the primary clarifier to be a fully mixed tank without any conversion processes taking place but with settling and removal of particulate components. The settling and removal model implemented is based on an empirical relationship for the removal of particulate components as a function of the hydraulic retention time (Rauch and Harremos, 1996; Schilling and Hartwig, 1988). The fraction of particulate matter that is not settled (XIN) is written as
' X IN = X IN (1 )

with the removal efficiency for particulate matter written as


' X IN = max (max min ) e c V / QIN

V QIN XIN XIN

max min C

with

Removal efficiency for particulate matter [-] maximum minimum Coefficient for taking the hydraulic retention time into account [T-1],[1/s] Primary clarifier volume [m3] plant influent [m3/s] particulate matter in the plant inflow [g/m3] reduced particulate matter after settling (non-settled fraction) [g/m3]

The removed amount of suspended solids is calculated directly as a fraction of the inflow. This method for describing the settling process has the advantage to take the limited amount of settable matter into account directly. Biokinetic model During the last three decades a large number of models of the biological processes in activated sludge treatment plants have been developed. A modified version of the IAWQ model No.1 is used for modelling biodegradation of organic material as well as biological nitrogen removal. The components implemented are shown in Tab. 2. Tab. 2: Components used in the WWTPs biokinetic model 1 2 3 4 5 6 7 8 9 10 T SI SS SNO SNH SP XH XA XS XI Temperature Inert soluble organic matter readily biodegradable organic matter nitrate (NO3-) ammonia (NH4+ + NH3) Inorganic soluble phosphorus (PO4) heterotrophic biomass autotrophic biomass slowly biodegradable organic matter Inert particulate organic matter Celsius gCOD/m3 gCOD/m3 gN/m3 gN/m3 gP/m3 gCOD/m3 gCOD/m3 gCOD/m3 gCOD/m3

Dissolved oxygen not introduced as component One of the main differences to the full ASM1 model is that dissolved oxygen in the water phase is not treated as a component (i.e. state variable of the model) but as a boundary condition. The dissolved oxygen concentration SO of both biological reactors is therefore specified in the plant outline and is not assumed to change during the simulation. Still, the given SO values influence the process rates thus allowing to distinguish between aerobic and anaerobic conditions. Stoichiometry and process rates implemented are shown in Tab. 3 and Tab. 4 respectively.

USER MANUAL

57

CITY DRAIN 2.0

Tab. 3: Stoichiometry
1 Process 1 2 3 4 5 6 7 Aerobic het. growth Anoxic het. growth Aerobic aut. growth Decay het. Decay aut. Hydrolysis P. precipitation 1 ix iP -1 T 2 SI 3 SS -1/YH -1/YH -(1-YH)/2.86/YH 1/YA 4 SNO 5 SNH -ix -ix -1/YA - ix 6 SP -iP -iP -iP -1 -1 7 XH 1 1 1 1-fp 1-fp -1 fp fp 8 XA 9 XS 10 XI

Tab. 4: Process rates


Process 1 2 3 4 5 6 7 Aerobic het. growth Anoxic het. growth Aerobic aut. growth Decay het. Decay aut. Hydrolysis P. precipitation Process rates H * SS/(KS+SS) * SO/(KOH+SO)* SNH/(0.01+SNH) * SP/(0.01+SP)* XH H * SS/(KS+SS)* KOH /(KOH+SO) * SNO/(KNO+SNO) * SNH/(0.01+SNH) * SP/(0.01+SP)*g*XH A * SNH/(KNH+SNH) * SO/(KOA+SO) * SP/(0.01+SP) * XA bH * XH bA * XA kh * XS/XH/(KX+XS/XH) * XH kP*SP

Main differences to the original ASM1 are: Switching functions of Monod type growth processes: All growth processes (of Monod type) contain switching functions for nitrogen and phosphorus. That is, in the absence of those the growth processes are stopped. This is in accordance with ASM3. The K values of the Monod type switching functions are set to 0.01 directly in the software code and not subject to variation. Ammonification process : The ammonification process is neglected here and all soluble organic ammonia (nitrogen fraction in SS) is assumed to be directly converted to SNH. Due to the coupling of nitrogen fractions to the organic matter the hydrolysis of particulate organic nitrogen (XND in ASM1) is modelled indirectly in the hydrolysis process of XS. Hydrolysis : The hydrolysis process rate was taken as is from ASM3 (Henze et al., 2000). Phosphorus precipitation: A very simple phosphorus precipitation process was included. The rate expression is a 1.order removal function without any effect by other components. This should reflect in a crude manner the precipitation process. Biological P removal is not included. Secondary clarifier Covering the relevant physical processes in the secondary clarifier under unsteady flow conditions is an essential part of a WWTP-model when used in integrated urban drainage simulations. A one-dimensional settler model is implemented based on solid flux theory. The model background is described in (Takacs et al., 1991) and with respect to details the reader is referred to this publication.

USER MANUAL

58

CITY DRAIN 2.0

Waste sludge removal Sewage treatment plants convert a substantial part of the influent waste into bacterial biomass that has to be removed subsequently in order to keep an appropriate concentration level in the reactors. The implementation of waste sludge removal is based on the concept of imposing a certain sludge age as described in ASM 1 (Henze et al., 1987).

USER MANUAL

59

CITY DRAIN 2.0

7 7.1

RIVER (FLOOD ROUTING) BLOCKS Muskingum oS - Q

Function: Muskingum oS-Q describes the flood routing by the Muskingum Method (Roberson et al., 1995a) for a single stretch. The block considers hydraulics only, where contaminant transport is not included. Input: qI Output: qE v Parameters: K X Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. Dimensionless weighting factor that relates to the amount of wedge storage [-]. Usually in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Downstream outflow from the stretch in [m/s]. Current Volume stored in the reach [m]. Upstream inflow in the stretch in [m/s].

S-function parameters: [t, K, X, C0,C1,C2] C0,C1,C2 Muskingum constants calculated within the block mask (no user input required). See theory section below. t Sampling rate t [s] is inherited from global setting of simulation parameters. Initial Conditions: QE = 0; V = 0; QI = 0; Theory: The outflow from a reach is calculated as a function of QE,I, QI,i and QE,I+1. Index i denotes the time step.

QE ,i +1 = C 0 QI ,i +1 + C1 QI ,i + C 2 QE ,i
Muskingum constants C0,C1 and C2 are constant over time and calculated as followed: USER MANUAL 60

CITY DRAIN 2.0

C0 =

0,5 t K X K (1 X ) 0,5 t 0,5 t + K X C1 = C2 = K (1 X ) + 0,5 t ; K (1 X ) + 0,5 t ; K (1 X ) + 0,5 t Vi +1 = K [X QI ,i +1 + (1 X ) QE ,i +1 )]

The actual volume stored in the river reach denotes as:

The numerical stability of the Muskingum equation is given when fulfilling the following relation of K, X and t:

1 K 1 2 (1 X ) t 2 X

USER MANUAL

61

CITY DRAIN 2.0

7.2

Muskingum oM - Q

Function: Muskingum oM-Q describes the flood routing by the Muskingum Method (Roberson et al., 1995a) for a river stretch comprised holding multiple subreaches. The block considers hydraulics only, where contaminant transport is not included. Input: qI Output: qE v Upstream inflow in the stretch in [m/s]. Downstream outflow from the stretch in [m/s]. Outflow from the last (Nth) sub reach. Vector of current volumes stored in sub reaches [m]. The length of the Vector depends on the number of sub reaches (N) considered. [V1, V2, VN-1, VN] Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. K applies to one subreach and does not cover travelling time for all sub reaches. Dimensionless weighting factor that relates to the amount of wedge storage [-]. Usually in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Number of subreaches

Parameters: K X N

S-function parameters: [t, N, K, X, C0,C1,C2] C0,C1,C2 Muskingum constants calculated within the block mask (no user input required). Constants apply to one subreach !! See theory section below. t Sampling rate t [s] is inherited from global setting of simulation parameters. Initial Conditions: Volumes in and flows rate between subreaches are considered to be zero for the initial conditions.

USER MANUAL

62

CITY DRAIN 2.0

Theory: Flows from a sub reaches (j) are driven by the outflow from their upstream sub reach (j-1) where j denotes the reach number and i denotes the time step.

Fig. 20. Schematic on nomenclature for multiple subreaches


1 j j j +1 Qi j++ 1 = C 0 Qi +1 + C1 Qi + C 2 Qi

C0 =

0,5 t K X K (1 X ) 0,5 t 0,5 t + K X C1 = C2 = K (1 X ) + 0,5 t ; K (1 X ) + 0,5 t ; K (1 X ) + 0,5 t

Current Volume stored for a sub reach j is calculated as:


j j +1 Vi +j1 = K X Qi + 1 + (1 X ) Qi +1 )

Again, for numerical stability the following relation between K, X and the discrete sampling time t must be fulfilled:

1 K 1 2 (1 X ) t 2 X

USER MANUAL

63

CITY DRAIN 2.0

7.3

Muskingum sS - QC

Function: Muskingum sS-QC describes the flood routing by the Muskingum Method. Formulation is based on a simplified discrete scheme compared to the original scheme. Instead of considering the discharges Q at instant times they are considered as mean discharges over the last discrete period of time. This is feasible when recalling that the measured precipitation represents cumulated (mean) quantities of rainfall for discrete time periods. The block provides hydraulic routing as well as routing of pollutants. Input: QI Output: QE V Parameters: K X nP Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. Dimensionless weighting factor that relates to the amount of wedge storage [-]. Usually in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Number of pollutants carried Downstream outflow from the stretch. [qE, CE,1, CE,2, .,CE,np]. Vector of current volumes and pollutant concentrations stored in the reach. [V, C1, C2,, Cnp] Upstream inflow in the stretch in [m/s].

S-function parameters: [t, K, X, CA,CB,nP] CA,CB Muskingum constants calculated within the block mask (no user input required). See theory section below. Sampling rate t [s] is inherited from global setting of simulation parameters.

Initial Conditions: Flows and concentrations in the reach are initially considered being zero.

USER MANUAL

64

CITY DRAIN 2.0

Theory: The outflow from a reach is calculated as a function of QI,i and Vi-1. Index i denotes the corresponding time step, where flow rates Qi represent mean values of flow of the past time step ti = ti - ti-1 .

QE ,i =

QI ,i C A + Vi 1 CB
with

CA = CB =

t + K (1 X ) 2

t KX 2

The actual volume stored in the river reach denotes as:

Vi = (QI ,i QE ,i ) t + Vi 1
Again, for numerical stability criteria defining the relation between K, X and the discrete sampling time t must be fulfilled:

K 1 t 2 X

USER MANUAL

65

CITY DRAIN 2.0

7.4

Muskingum sM - QC

Function: Muskingum sM-QC describes the flood routing by the Muskingum Method. Formulation is based on a simplified discrete scheme equivalent to the formulation used in Muskingum sS-QC. Instead of considering the discharges Q at instant times they are considered as mean discharges over the last discrete period of time. The block provides hydraulic routing as well as routing of pollutants using a user defined number of multiple sub reaches. Input: QI Output: QE V Upstream inflow in the river stretch being the flow into the first sub reach. [qI, CI,1, CI,2, .,CI,np] Downstream outflow from the river stretch [qE, CE,1, CE,2, .,CE,np]. Vector of current volumes and pollutant concentrations stored in each of the N sub reaches of the river stretch. [V1, C11, C21,, Cnp1, ,V j, C1 j, C2 j,, Cnp j, ,V N, C1 N, C2 N,, Cnp N] Number of subreaches Muskingum parameter describing the time required for a discharge wave travelling through the reach [s]. K applies to one subreach and does not cover travelling time for all sub reaches. Dimensionless weighting factor that relates to the amount of wedge storage [-] in the range of 0 (linear reservoir storage) and 0.5. (Typical value = 0,2). Number of pollutants carried

Parameters: N K X nP

S-function parameters: [t, K, X, CA,CB,nP, N] CA,CB t Muskingum constants calculated within the block mask (no user input required). See theory section below. Sampling rate t [s] is inherited from global setting of simulation parameters.

USER MANUAL

66

CITY DRAIN 2.0

Initial Conditions: Flows and concentrations in the reach are initially considered being zero.

Theory:

The outflow from a sub reach Qj+1 is calculated as a function of the inflow Qji and stored volume Vji-1. Index i denotes the corresponding time step, where flow rates Qi represent mean values of flow of the past time step ti = ti - ti-1 . Index j denotes the number of the sub reach.

Qi j +1 =

Qi j C A + Vi j1 CB
with

t CA = KX 2 t CB = + K (1 X ) 2
The actual volume stored in a sub reach denotes as

Vi j = Qi j Qi j +1 t + Vi j1
Again, for numerical stability criteria defining the relation between K, X and the discrete sampling time t must be fulfilled:

K 1 t 2 X

USER MANUAL

67

CITY DRAIN 2.0

7.5

Hydropower

Function: The block simulates river discharges from retaining structure such as hydropower intakes. The flow discharged downstream comprises of flow rates for baseflow qo and additional discharge qa. Background concentrations associated are introduced as constants in the block mask. Input: qo qa Output: QE Parameters: nP Number of pollutants carried CSTREAM Constant pollutant background concetration [C1, C2, .,Cnp]. S-function parameters: [nP, CSTREAM , t] t Sampling rate t [s] is inherited from global setting of simulation parameters. Outflow from the Hydropower block [qE, CE,1, CE,2, .,CE,np]. Flowrate of baseflow [m/s] Flowrate of additional flow [m/s]

Initial Conditions: No initial conditions required.

USER MANUAL

68

CITY DRAIN 2.0

8 8.1

TOOLS Mixing QC

Function: The block is designed to combine flows from two sources by means of simple mixing. Input: Q1 Q2 Output: QE Parameters: nP Number of pollutants carried S-function parameters: [nP, t] Dynamic input of flow and pollutant concentrations associated [q1, C1,1, C1,2, .,C1,np] Dynamic input of flow and pollutant concentrations associated [q2, C2,1, C2,2, .,C2,np] Outflow from the block [qE, CE,1, CE,2, .,CE,np].

Sampling rate t [s] is inherited from global setting of simulation parameters.

Initial Conditions: No initial conditions required. Theory: Equation for mixing of substances

CE =

C1 q1 + C2 q2 qE
with

qE = q1 + q2

USER MANUAL

69

CITY DRAIN 2.0

8.2

Mixing QC-QD

Function: The block is designed to combine flows from two sources by means of simple mixing. Two inflows Q0 and QW are considered where Q0 is considered being the less polluted flow. In extend to the block Mixing-QC the block evaluates the additional flow rates qD required to meet user defined maximum concentration limits CMCL. A standard application of the block is to combine upstream base flow in a river (Q0) and combined sewer overflow (QW) entering the river. Block Type: Discrete Block utilizing S-function: CD1_sfun_mixing_QC_QD.m Input: Qw Q0 Output: QE QD Dynamic input of flow and pollutant concentrations associated [qW, CW,1, CW,2, .,CW,np] Dynamic input of flow and pollutant concentrations associated [q0, C0,1, C0,2, .,C0,np] Outflow from the block [qE, CE,1, CE,2, .,CE,np]. Vector of flow rate demands for each pollutant concentration respectively. [qD1, qD2, qD3, qD4, qD,np, qD,MAX]. The maximum flow rate demand out of all is stored in the vectors last entry. Number of pollutants carried Maximum concentrations limits defined by the user [CMCL,1, CMCL,2, ,CMCL,np]

Parameters: nP CMCL

S-function parameters: [nP, t, CMCL]

Sampling rate t [s] is inherited from global setting of simulation parameters.

Initial Conditions: No initial conditions required. Theory: Mixing of substances is done equivalent as in the block Mixing-QC.

USER MANUAL

70

CITY DRAIN 2.0

CE =

C1 q1 + C2 q2 qE
with

qE = q1 + q2
Outflow concentrations are checked for compliance with user defined maximum concentration limits (CMCL). In case of non-compliance the additional upstream flow (q0) for sufficient dilution is returned. Based on the extended mixing formula

C 'E =

qW CW + (q0 + qD ) C0 CMCL qW + q0 + qD

the additional upstream demand of flow rate denotes as

qD

qW (CMCL CW ) + q0 (CMCL C0 ) (C0 CMCL )

For having different substances considered, the minimum demanding flow rate is returned for each substance as well as the maximum out of these: QD= [qD1, qD2, qD3, qD4, qD,np, qD,MAX]. with

USER MANUAL

71

CITY DRAIN 2.0

8.3

Splitter

Function: The block is designed to split flows according to a fixed flows rate of factor. Thus, the block may be used to model a pump operating with a fixed flow rate using the splitting mode { m/s } Alternative structures that divert the inflow into two flows at a specific ration may be modelled using either the splitting mode { Percent (0-100) } or { Fraction (0-1) }. Input: QI Output: Q1 Q2 Parameters: nP f mode Number of pollutants carried Fraction / amounted directed to Q1 Splitting mode to be used { m/s } Fixed flow rate diverted to output port Q1 { Percent (0-100) } Fixed percentage of flow diverted to output port Q1 { Fraction (0-1) } Fixed fraction of flow diverted to output port Q1 Outflow from the block; Fraction according to user input defined in the mask [q1, CI,1, CI,2, .,CI,np]. Outflow from the block; Remaining fraction qI = qI - q1 [q2, CI,1, CI,2, .,CI,np]. Dynamic input of flow and pollutant concentrations associated [qI, CI,1, CI,2, .,CI,np]

S-function parameters: [nP, f, mode, t] t Sampling rate t [s] is inherited from global setting of simulation parameters. Theory: Splitting of flows is done according to the splitting mode selected where the flow q1 is calculated as: Mode { m/s }

f qI f qI
Mode { Percent (0-100) }

q1 = f and q2 = qI q1 q1 = qI and q2 = 0

q1 =

f f qI and q2 = 1 qI 100 100


72

USER MANUAL

CITY DRAIN 2.0

Mode { Fraction (0-1) }

q1 = f qI and q2 = (1 f ) qI

USER MANUAL

73

CITY DRAIN 2.0

8.4

Dynamic Splitter

Function: The block is in its ability to split fluxes equivalent to the original Splitter Block. As the numerical value of the fraction diverted to Q1 is introduced as dynamic input to the DYN port, the magnitude of the fraction can be modified during the simulation run. Thus, the block is utilizable for real time control actions. See Splitter Block for details on the splitting modes and units used.

USER MANUAL

74

CITY DRAIN 2.0

8.5

Switch

Function: The block is designed to selective forward either Q1 or Q2 to the output port. Input: Q1 Q2 Output: Qe Outflow from the block; Switch=0 Qe= Q1 Switch=1 Qe= Q2 0/1 defined wether Q1 of Q2 is forwarded. Dynamic input of flow and pollutant concentrations associated [qI, CI,1, CI,2, .,CI,np] Dynamic input of flow and pollutant concentrations associated [qI, CI,1, CI,2, .,CI,np]

Parameters: Switch

Initial Conditions: No initial conditions required.

USER MANUAL

75

CITY DRAIN 2.0

8.6

Wrong Connect

Function: The block is designed to model wrong connections that may occur in a separate sewer system. Thereby single households may be wrongly connected to the storm water sewer. On the other hand, storm water inlets may be connected to the waster water sewer. Modelling of such wrong connections is done on a catchment level. It is not the number of wrong connections being of interest, but the overall fraction or quantity of flow in the catchment that is diverted from the storm to the waste sewer (and vice versa). Input: Qr Qdwf Output: Qr Qdwf Parameters: nP fr-dwf mr-dwf fdwf-r mdwf-r Number of pollutants carried Fraction / Amounted directed from the storm to the waste water pipe Splitting mode to be used (see block Splitter for details) Fraction / Amounted directed from the waste to the storm water pipe Splitting mode to be used (see block Splitter for details) Dynamic input of flow and pollutant concentrations representing storm water flow in the catchment. [qr, Cr,1, Cr,2, .,Cr,np] Dynamic input of flow and pollutant concentrations representing dry weather flow in the catchment. [qdwf, Cdwf,1, Cdwf,2, .,Cdwf,np] Flow and pollutant concentrations in the storm water pipe including wrong connections. [qr, Cr,1, Cr,2, .,Cr,np] Flow and pollutant concentrations in the waste water pipe including wrong connections. [qdwf, Cdwf,1, Cdwf,2, .,Cdwf,np]

Initial Conditions: No initial conditions required. Theory: See blocks Splitter: CD1_sfun_splitter.m Mixer-QC: CD1_sfun_mixing_QC.m for details.

USER MANUAL

76

CITY DRAIN 2.0

8.7

SetSubstance Q/C

Function: The block is designed to filter a flow Qi for one or more substances. As the dynamic input Qi to the block does not contain a substance specification, the respective names of substances to filter are to be given as mask input (subs). In the above example, the flow is filtered for substances COD COD T. Input: QI Output: S Parameters: subs nP String specifying the substances to be filtered Number of pollutants carried Outflow from the block; Dynamic input of flow and pollutant concentrations associated [qI, CI,1, CI,2, .,CI,np]

Initial Conditions: No initial conditions required.

USER MANUAL

77

CITY DRAIN 2.0

8.8

Filter

Function: The block is designed to accept a flow Qi and set one or more substances to a specific value. The vector of values is given as dynamic input Q/C. As the dynamic input to the block does not contain a substance specification, the respective names of substances to be substituted are to be given as mask input (subs). In the above example, the temperature T is substituted from 2 7. Input: QI Output: Qe Parameters: subs nP String specifying the substances to be substituted Number of pollutants carried Outflow from the block; Fraction according to user input defined in the mask [q1, CI,1, CI,2, .,CI,np]. Dynamic input of flow and pollutant concentrations associated [qI, CI,1, CI,2, .,CI,np]

Initial Conditions: No initial conditions required.

USER MANUAL

78

CITY DRAIN 2.0

LITERATURE

Achleitner S., DeToffol S., Engelhard C. and Rauch W. (2005). The European Water Framework Directive: Water Quality Classification and Implications to Engineering Planning. Environmental Management, 35 (4),517-525. Achleitner S. (2006). Modular conceptual modelling in urban drainage - development and application of CITY DRAIN. PhD thesis, Unit of Environmental Engineering, Institute of Infrastructure, University of Innsbruck, Faculty of Civil Engineering Science. Achleitner S., Mderl M. and Rauch W. (2006). CITY DRAIN - an open source approach for simulation of integrated urban drainage systems. Environmental Modelling & Software, (accepted) Blch H. (1999). The European Water Framework Directive: Taking European water policy into the next millennium. Water Science and Technology, 40 (10),67-71. Harremos P. and Rauch W. (1996). Integrated design and analysis of drainage systems, including sewers, treatment plant and receiving waters. Journal of Hydraulic Research, 34 (6) Henze M., Grady Jr. C. P. L., Gujer W., Marais G. v. R. and Matsuo T. (1987). Activated Sludge Model No. 1. - Scientific and Technical Report. IAWQPRC, London. Henze M., Gujer W., Mino T. and van Loosdrecht M. (2000). Activated Sludge Models ASM1, ASM2, ASM2d and ASM3. IWA Scientific and Technical Report No. 9. IAWQPRC, London, UK. Kalman R. E. (1960). A new approach to linear filtering and prediction problem. Journal of Basic Engineering, 81D,35-45. Lau J., Butler D. and Schtze M. (2002). Is combined sewer overflow spill frequency/volume a good indicator of receiving water quality impact? Urban Water, 4,181189. Lijklema L. (1995). Water Quality Standards: Sense and Nonsense. Water Science and Technology, 31 (8),321-327. Motiee H., Chocat B. and Blanpain O. (1997). A storage model for the simulation of the hydraulic behaviour of drainage networks. Water Science and Technology, 36 (8-9),57-63. Rauch W. and Harremos P. (1996). The importance of the treatment plant performance during rain to acute water pollution. Water Science and Technology, 34 (3-4),18. Rauch W. (1997). RUMBA - waste water treamtment plant modelling (User Manual). Institute of Environmental Science and Engineering, Technical University of Denmark, Lyngby Denmark. Rauch W. and Harremos P. (1997). Acute pollution of recipients in urban areas. Water Science and Technology, 36 (8-9),179184. Rauch W., Bertrand-Krajewski J. L., Krebs P., Mark O., Schilling W., Schtze M. and Vanrolleghem P. A. (2002). Deterministic modelling of integrated urban drainage systems. Water Science and Technology, 45 (3),81-94. Roberson J. A., Cassidy J. and Chaudhry M. H. (1995a). Hydraulic Engineering. John Wiley Sons, Inc., New York. Roberson J. A., Cassidy J. J. and Chaudhry M. H. (1995b). Hydraulic Engineering. John Wiley Sons, Inc., New York. Schilling W. and Hartwig P. (1988). Simulation von Reinigungsprozessen in Belebungsanlagen mit Mischwasserzuflu. gwf wasser-abwasser, 129 (8) Schreider S. Y., Young P. C. and Jakeman A. J. (2001). An Application of the Kalman Filtering Technique for Streamflow Forecasting in the Upper Murray Basin. Mathematical and Computer Modelling, 33,733-743. Takacs I., Patry G. G. and Nolasco D. (1991). A dynamic model of the clarification-thickening process. Water Research, 25 (10),1263-1271. The Mathworks (2003). Simulink - Writing S-Functions. Model-Based and System-Based Design, The Mathworks,
USER MANUAL 79