Object-oriented Hydrological Modeling System
Y. Ichikawa, Y. Tachikawa, K. Takara
Disaster Prevention Research Institute, Kyoto University, Uji 611-0011, Japan

M. Shiiba
Department of Civil Engineering Systems, Kyoto University, Kyoto 606-8501, Japan

ABSTRACT: A new hydrological modeling system is developed on the basis of theobject–oriented analysis of hydrological systems. In this modeling system, hydrological systems are considered as a set of dynamic elements which communicate
one another. This modeling system provides the base element model which has thecommon functions required in hydrological simulations, such as initialization of statevariables, giving numerical values to parameter variables, setting computation time
steps. Also this system provides the port models for data transfer between element
models. The system user can easily create his own element models by using thebase element model and easily build the total system model for the hydrologicalsimulations by connecting a number of element models through the port models.

1 INTRODUCTION
Hydrological systems are generally considered as a set of unit processes such as
precipitation, evapotranspiration, waterﬂow on the slope systems, river network
ﬂow, water storage in the dam reservoirs.
Therefore hydrological simulation models are usually built using the following
method in which:
1. the element models for each processes are prepared, and2. the total system model for the hydrological simulations is built byconnecting the element models according to the basin structure.
This method has the advantage that the
total system model can be easily built
and modiﬁed (Figure 1).
In order to support this modelingmethod, we developed the computer

software system, termed Object-oriented
Hydrological Modeling System (OHyMoS) . OHyMoS is designed on the basisof the object-oriented programming concepts and it enables the user to easily
develop his own element models and easily build the total system model for thehydrological simulations by connecting a
number of element models.
2

EXISTING MODELING SYSTEMS

There are some hydrological modelingsystems which contain the libraries of
element models. The users can selectthe element models from the libraries according to their needs. HEC–HMS, developed by US Army Corps of Engineers
Hydrologic Engineering Center (1998),
is such kind of modeling system. Thissystem provides seven types of element:

Proc. of 4th International Conference Hydroinformatics 2000, Iowa, USA, 2000, CD-ROM, 8 pp.

replacing
element models

selecting and connecting
element models

elements models

building a total system model

modifying a total system model

Figure 1: Building and modifying a total system model

subbasin, routing reach, junction, reservoir, source, sink and diversion. The
user can construct a basin hydrologicalmodel by selecting and connecting theseelements. Also each element has several options for hydrological computation, and the user can choose an appropriate option for each element. This typeof modeling system has the advantagethat the user is free from the laborious
works of writing the codes of the element
models if he uses the element models provided in the modeling system.
However, let us suppose that a user
attempts to originally develop a new element model and connect it with othermodels provided in the modeling system.
What should he know for his purpose?
First, he has to know the structure of
the element model; i.e. he has to knowwhat variables and what functions to berequired. Second, he has to know themethod of data transfer between element
models. If he does not know it, his element model could not be connected toother models. Furthermore, he may haveto understand the speciﬁcations of thegraphical user interface used in the modeling system. It means that he shouldhave the detailed knowledge of the mod-eling system, which is usually a huge andcomplex software. It seems to be a very
strict requirement and it is practically
impossible for the user to develop his
own element model and to use his modelwith the provided ones. From similarreason, it seems to be diﬃcult to modify
the provided models.
3

BASIC REQUIREMENTS OF HYDROLOGICAL MODELING SYSTEM

By summarizing the previous section,
it can be said that the existing modeling systems are not ﬂexible enoughto be customized according to the userneeds, and a hydrological modeling system should be designed so that the user
can easily develop his own element modeland connect it to other element models.
We propose that the hydrological modeling system must satisfy the four following basic requirements:(a) All of the element models must havea common structure.
(b) The method of data transfer between element models must be standardized.

(c) The element model structure andthe data transfer method must be
open to the users.
(d) It must be easy for the user to develop his own element model according to the element model structure
and the data transfer method.
Requirements (a) and (b) are theminimum requirements of hydrologicalmodeling systems. Requirement (c) canbe satisﬁed if a detailed documentation
for the modeling system is provided.
However, to satisfy requirement (d) ispractically very diﬃcult. Most existinghydrological modeling systems have beencoded in the procedure–oriented computer languages, such as C or Fortran,
and have generally prepared the function
libraries for data transfer, model operation, graphical user interface, etc. Even
if the detailed documentations for thefunction libraries are provided to the system user, he must read the documentations and understand what functions to
be required and how to use them in order to write the codes of his own element
model. This is a hard task and makes it
diﬃcult for the user to develop element
models. To satisfy requirement (d) is the
key to development of a ﬂexible modeling system.
4 OBJECT – ORIENTED DESIGNFOR HYDROLOGICAL MODELING SYSTEM• hydrological elements are regarded
as “objects” and basin hydrologicalsystems as a hierarchy of objects of
the hydrological elements,• the functions for an element modelare divided into peculiar functions
and common functions; e.g. initializing the state variables, giving numerical values to the model parameters, setting computation time step
(Figure 2).
• the common functions are packed
into “the base element model” (Figure 2), and• the user can develop his own element model by combining its peculiar functions with the base element
model (Figure 3).
The most important point in this approach is the base element model. A
model developer can use the base element model as the “template” for his
model and add appropriate functions to
his model as he likes. Because his model
will automatically inherit all the common functions deﬁned in the base element models, he does not have to write
the codes for these functions and can devote himself to the part of hydrologicalcomputations. Moreover, all the element
models will have the common structure
because they are all derived from thebase element model. This fact implies
that all the element model can be operated through the same function calls.

4.1 Basic concepts

4.2

Methodology

In order to satisfy the basic requirements proposed in the previous section,
especially requirement (d), we adopt theobject-oriented approach to develop ahydrological modeling system. In thisapproach,

We code the hydrological modeling system in the object-oriented computer
language, C++, which has the threeobject-oriented programming concepts:
1. class, 2. inheritance, and 3. polymorphism.

the base element model

peculiarfunctionsfunctions ofan element
model
commonfunctionspeculiarfunctionspeculiarfunctionspeculiarfunctionsa newelement modela newelement modela newelement model

splitting the functions

the base element model
initializing state variables
giving parameter values
setting computaion time step

Figure 3: Developing a new element model

Figure 2: Base element model
derived classbase class

4.2.1 ClassA class is a package that contains several data variables and several functions
to operate data variables. The data variables are called data members and thefunctions member functions.
Because an element model executes
hydrological computations by operatingstate variables and parameters in the hydrological equations, it can be expressed
as a class by regarding the state variables
and the parameters as the data members
and the equations as the member functions.
4.2.2 Inheritance
By using inheritance, new classes can becreated on the basis of existing classes.
For example, suppose that we want tocreate a new class which will have thedata members and the member functions deﬁned in an existing class withfurther data members and member functions (Figure 4). In this case, by deriving
the new class from the existing one, we
do not have to write the common partof these classes in the implementation of
the new class. The new class will auto-

data
members
a1, a2,
memberfunctions
A1, A2,

data
members
a1, a2,
memberfunctions
A1, A2,

data
members
b1, b2,
memberfunctions
B1, B2,class derivation
using inheritance

Figure 4: Inheritancematically inherit the data members andthe member functions deﬁned in the existing class. Of course, we can add further data members and member functions to the new class. The new classis called a derived class and the existing
one a base class.
In the modeling system, we provide
the base element model as a base classand then an user will be able to derive
his own element model from the base element model by using inheritance. His element model will automatically have thecommon functions provided in the baseelement model.

4.2.3 Polymorphism
Inheritance is used when a new classwill have the same member functions as
an existing class. However they may
have the same member functions withthe diﬀerent implementations, i.e. themember functions whose purposes aresame but whose methods are diﬀerent.
C++ allows this situation by using polymorphism. Polymorphism enables us to
implement the inherited member functions diﬀerently from those of the existing class.
For example, all the element models
must have the member function to calculate hydrological phenomena. It is therefore quite natural that this member function should be deﬁned in the base element model and all the element model
should have this function by using inheritance from the base element model.
However it is evident that each element
models must implement this function
uniquely. To solve this dilemma, we use
polymorphism. By using polymorphism,
the element models can have each variants of the function inherited from thebase element model.
5 OBJECT – ORIENTED HYDROLOGICAL MODELING SYSTEM
5.1 Element model, subsystem model,
total System model
In the previous section we described theconcept of an element model. We should
explain the concept of a subsystem modeland a total system model too. A subsystem model is a set of element models and a total system model is a set ofsubsystem models and element models.
Suppose, for example, the study basin
consists of three subbasins and each subbasin consists of a slope area and a

total basin
slope
area

river network

subbasin

Figure 5: Basin structure

river network (Figure 5). In OHyMoS,
ﬁrst, the slope area and the river network are modeled as the element models. These element models are derived
from the base element model. Second,
the subbasins are modeled as subsystemmodels by connecting the slope area element model and the river network element model. Finally, the study basin
is modeled as the total system model by
connecting three subsystem models (Figure 6). Note that the user must build thetotal system model for his study basinfor himself. How to build a total systemmodel will be given in 5.4. Unlike a total
system model the user dose not need touse the subsystem models; i.e. the model
structure shown in Figure 7 is possible.
An element model does actual hydrological computations according to thehydrological characteristics and a subsystem model and a total system model
work as managers of the element models and/or the subsystem models; theyissue several commands to operate thesubordinate models. Also, a total systemmodel works for communicating with auser interactively through command line
and dealing with data ﬁles.

element
model

subsystem
model

total system
model

input 1send port

relay port
input port

output port

outputreceive port

input 2

input 3Figure 6: Model structure using OHyMoS
element model total system model

input 1

receive port
send port
outputinput 2

output port
input port

input 3Figure 7: Another model structure

5.2 Data transfer
OHyMoS also provides the model forcommunicating (sending and receiving
data) between the element models. Using this model, a model developer does
not need to write the codes to transfer the data from his element model toother element models. He has only to
add this model to his own element modeland write the codes to deﬁne the relationships between the element models.

The model for sending data from an element model is called a send port and themodel for receiving data from another element model is called a receive port. A
subsystem model has relay ports for datatransfer with the outside. A total system model has input ports to read dataﬁles (rainfall, temperature, etc) and output ports to write the calculation results(discharge, water depth, etc) to ﬁles.
The data transferred through the ports
is modeled as a data pack, which contains
the time and the numerical value(s).
The port models and the data packmodel also have the object-oriented hierarchies whose roots are the base port
model and the base data pack model, respectively.
5.3 How to develop an element model
It is the strongest point of OHyMoS thatthe user can easily develop his own element model. The procedure for developing an element model is as follows:
1. derive an element model from thebase element model,
2. deﬁne parameter variables and statevariables as the data members,
3. deﬁne send/receive ports as the data
members,
4. implement the member functions
which register send/receive ports,
5. implement the member functions
which give initial values to the statevariables and give numerical values
to the parameter variables,
6. implement the member function
which sends data at the beginningof the simulation,
7. implement the member function
which determines the time step forthe next computation,
8. implement the member function
which judges whether or not to exe-

cute the next computation,
9. implement the member function
which does hydrological computations and sends the result data, and
10. implement the member function
which drives a series of computational work until the simulationends.
5.4 How to build a total system model
OHyMoS provides the base total systemmodel (and the base subsystem model) sothat the user can easily build the total
system model for his study basin. The
procedure for building the total systemmodel is as follows:
1. derive an total system model fromthe base total system model,
2. deﬁne the subordinate element /subsystem models as the data members,
3. implement the member function
which registers the subordinate
models,
4. deﬁne the input/output ports as thedata members,
5. implement the member functions
which register the input/output
ports,
6. implement the member function
which connects data ﬁles to the input/output ports, and7. implement the member function
which connects the input/output
ports and the send/receive ports between the subordinate models.
5.5 Main program for a simulation
The main program for a simulation consists of a set of commands to operate thetotal system model. When receiving thecommands from the main program, thetotal system model will issue the messages to drive the subordinate models.

6

APPLICATION

OHyMoS was applied to Huaihe Riverbasin in China (145,000 km2 ) in order tosimulate rainfall-runoﬀ processes. Figure 8 shows Huaihe River basin. Thisbasin was divided into 1478 subbasinsby 10’ × 10’ grid boxes. Each subbasin was modeled as a subsystem model
which consisted of the xinanjiang model(Zhao et al., 1980) representing runoﬀ
processes from the slope area and the
lumped kinematic stream network model(Shiiba et al., 1996) representing ﬂood
wave in the river network (Figure 9).
The whole basin was modeled by connecting the subsystem models (Figure10). For detail of these models, you canalso refer to Tachikawa et al.(2000). Figure 11 shows the simulation result.
7

CONCLUSION

A hydrological modeling system has
been presented on the basis of the objectoriented approach and design. In thismodeling system, hydrological elements
are regarded as objects and basin hydrological systems as a hierarchy of objectsof hydrological elements. This modelingsystem provides the base element modelfrom which the user can derive his own
element model and the port models fordata transfer between element models.
The user can easily create his own element models by using the base element
model and easily build the total systemmodel by connecting a number of element models through the port models.
We distribute this modeling system at
http://rdp.dpri.kyoto-u.ac.jp/lab/ohymos.html and ftp://rdp.dpri.
kyoto-u.ac.jp/pub/. If you use oursystem and have some comments on thissystem, please let us know.

rainfall evapotranspiration

35N

xinanjiang
element model

33N

32N

31N
111E

lateral inflow

discharge fromupstream subbasinsdischarge into
downstream subbasins

34N

lumped stream network
element model
subbasin model

112E

113E

114E

115E

116E

117E

118E

Figure 9: Element models and subsystem model

Figure 8: Huaihe River basindischarge (mm/hour)

rainfall
1.5

5

1

10

rainfall (mm/hour)02simulateddischarge

0.5
00Figure 10: Total system model

REFERENCES
US Army Corps of Engineers Hydrologic Engineering Center, “HEC–HMS Hydrologic Modeling System
User’s Manual,” version 1.0, 1998.
Zhao, R.J., Y.L. Zhang, L.R. Fang, X.R.
Liu and Q.S. Zhang, “The Xinanjiang
model,” Proc. of the Oxford Symposium on Hydrological Forecasting,
IAHS Publ. no. 129., pp. 351 – 356,
1980.
Michiharu Shiiba, Yutaka Ichikawa,
Shuichi Ikebuchi, Yasuto Tachikawa

10

20
30
time (day)40

50

Figure 11: Simulation result

and Takuma Takasao, “Scale-up of arunoﬀ model using GIS and an objectoriented hydrological modeling system,” HydroGIS 96, IAHS Publ. no.
235, pp. 63 – 70, 1996.
Yasuto Tachikawa, Yutaka Ichikawa,
Kaoru Takara and Michiharu Shiiba, “Development of a macro scale
distributed hydrological model using
an object-oriented hydrological modeling system,” Submitted to Hydroinformatics 2000, 2000.