HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) A MATLAB IMPLEMENTATION OF TOPMODEL RENATA ROMANOWICZ Westlakes Research Institute, Moor Row, Cumbria, CA2U 3LN, UK ABSTRACT The MATLAB SIMULINK programming language is applied to the TOPMODEL rainfall±runo model. SIMULINK requires a good recognition of model dynamics, which has been achieved here in a version based on the ®rst TOPMODEL (Beven and Kirkby, 1979). Introducing the topographic index distribution in a vector form allows the generalization and simpli®cation of the SIMULINK structure. The SIMULINK version of TOPMODEL has a very easy to understand graphical representation, which shows, in a straightforward way, all the physical interactions that take place in the model. Moreover, owing to its modular structure it is easy to add new and/or develop old submodels, depending on the available data and the goal of the modelling. In the example given here TOPMODEL was extended by two submodels representing the soil moisture and evaporation distribution in the catchment. Preparation of the data and presentation of the results is done in MATLAB. Discharge predictions and spatial patterns of hydrological response are demonstrated for a separate validation period. # 1997 by John Wiley & Sons, Ltd. Hydrol. Process., Vol. 11, 1115±1129 (1997). (No. of Figures: 9 KEY WORDS No. of Tables: 2 No. of Refs: 16) TOPMODEL; MATLAB SIMULINK; rainfall±runo modelling; soil moisture modelling; spatial predictions DESCRIPTION OF HYDROLOGICAL MODEL The model used in this study is a simpli®ed version of the semi-distributed model TOPMODEL (Beven and Kirkby, 1979; Beven, 1984, 1986; Romanowicz et al., 1993, 1994; Beven et al., 1995). It requires digitized elevation data and a sequence of rainfall and potential evapotranspiration data, and predicts the resulting stream discharges. In TOPMODEL the predicted hydrological responses depend upon the distribution of an index of hydrological similarity ln a=tan b (see Beven, 1997). This is derived from an analysis of the topography, as described by the digital elevation data of the particular catchment being studied. Simple steady-state theory is used to develop a relationship between the topographic index and the local saturation of the soil as the catchment wets and dries. This relationship can be used to predict runo contributing areas in a non-linear way. The model also describes the subsurface drainage to the stream (Beven et al., 1995) through: Qb t T 0 e ÿ l e ÿ S t=m 1 drainage, T 0 is the average eective transmissivity of the soil when the pro®le is where Qb (t) is the subsurface R just saturated, l 1=A li dA is the catchment average of the topographic index li ln ai =tan bi , where i represents the discrete increment of l, ai is the area of the hillslope per unit contour length that drains through the location corresponding to this value of topographic index, and tan bi is the local surface slope. S t is the catchment average storage de®cit and m is a parameter that can be derived from an analysis of the recession curves for the catchment when it can be assumed that all the ¯ow is derived from subsurface Contract grant sponsor: NERC. Contract grant number: GST/02/491. CCC 0885±6087/97/091115±15$17.50 # 1997 by John Wiley & Sons, Ltd. Received 20 June 1996 Accepted 6 December 1996 1116 R. ROMANOWICZ drainage. Equation (1) can be inverted, given an initial ¯ow at the start of the prediction, to give an initial value of storage de®cit S t0 . Then, S t is updated at each time step by a mass balance calculation involving vertical recharge to the unsaturated zone and the subsurface drainage Qb t. The parameter m also enters as a scaling parameter in the calculation of the runo production areas in the catchment, through the relationship: DS i S i ÿ S t ml ÿ li 2 where DSi is the dierence between local and catchment average storage de®cits, and li is the local value of the topographic index. Equation (2) assumes that the eective transmissivity at soil saturation is homogeneous in the catchment. Surface runo contributing areas are predicted in locations where the local storage de®cit is zero. This occurs ®rst at points with high values of li , and as the catchment wets up the contributing area will spread to lower values of the index. The index can be calculated using digital terrain maps of a catchment (Quinn et al., 1991, 1995). In the simplest version of the hydrological model, Equations (1) and (2) represent the most important functions in the model, with parameters m and T 0 . Under relatively wet conditions TOPMODEL has proven to be generally successful in predicting stream discharges in catchments of relatively shallow soils and moderate to steep slopes (see Beven et al., 1995; Beven, 1997). As reported in the literature, TOPMODEL is most sensitive to the changes in the recession parameter m, while the transmissivity is in¯uencing the resulting eciencies in a limited way, i.e. it should be bigger than some threshold value, depending on the conditions in the catchment. SIMULINK TOPMODEL STRUCTURE For the purpose of the SIMULINK implementation, an extension of the dynamic structure of TOPMODEL presented in the work of Beven and Kirkby (1979) seemed to be the most suitable. According to this work TOPMODEL consists of three basic dynamic components: (a) Root zone storage, S1 , with maximum storage, SRmax , which must be ®lled, before in®ltration, Q, from it can take place. Evaporation is allowed at the potential rate until the store is empty. When this zone is saturated, it contributes to the surface runo. This formulation of root zone storage does not allow any interaction with saturated storage to take place and was changed as described in the following section. However, in the new formulation the concept of the root zone storage was maintained and therefore it is left in this description. (b) A gravity drainage store S 2 , with a constant through time increment leakage rate Qv SAi Qvi , to the third non-linear storage S3 in the area which is not saturated (Ai denotes contributing area weighted by the topographic index distribution). It is assumed that the rain falling on the saturated contributing area, Ac , will immediately become overland ¯ow. Also, any area that saturates during the time step owing to rainfall± evaporation conditions in the catchment provides some overland ¯ow. Evaporation from the store S2 is assumed at the potential rate. (c) A non-linear saturated subsurface storage with storage de®cit S3 t S t and subsurface drainage Qb de®ned by Equation (1) followed by the steady-state distribution of soil moisture de®cits in the catchment according to the topographic index distribution [Equation (2)]. The scheme of those three storages and their interconnection can be presented as shown in Figure 1. The dynamics of these three conceptual stores are described by the set of the ordinary non-linear dierential equations. Now, taking the TOPMODEL scheme given in Figure 1 as a basis, the complete SIMULINK± TOPMODEL structure is built, as shown in Figure 2. SIMULINK is a program for simulating dynamic systems (MathWork's Inc., 1992). It uses block diagram windows, where models are created, and edited, principally by mouse driven commands. The icons on the HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) # 1997 by John Wiley & Sons, Ltd. TOPMODEL 4: MATLAB IMPLEMENTATION 1117 Figure 1. Schematic representation of the semi-distributed catchment model TOPMODEL SIMULINK window shown on Figure 2 represent SIMULINK built-in routines used to perform dierent operations, such as vector or scalar summation (block `sum'), or block `demux' and `mux', which are used to rearrange vectors into subvectors. Icon `yout' allows writing the results of simulations into the MATLAB workspace. The same icon connected with the clock writes the corresponding time vector to the MATLAB workspace, thus allowing graphic display of the simulation results. The block called `constant' allows a constant parameter to be set [here a vector MATB m ln a=tan b ] as one of the model input variables, while the block `from workspace' represents the vector of time-variable rainfall and evaporation data (data12) loaded into the MATLAB workspace. The standard SIMULINK operations and those built by the user can be grouped together into subsystems, with inputs and outputs corresponding to their structure. Each subsystem can also contain other interconnected subsystems. The icons `root', `vector', `ro ', `gravity zone' and `saturation zone' represent such complex subsystems. All those icons are shown in Figure 2 to help the interested reader in building their own SIMULINK±TOPMODEL model. The basic structure of SIMULINK±TOPMODEL consists of three dynamic subsystems, corresponding to the subsystems from Figure 1. The root zone submodel corresponds to the ®rst storage from the scheme, the gravity drainage zone submodel corresponds to the second storage and the saturated zone submodel corresponds to the third storage. The module `steady-state soil moisture de®cit distribution' is represented by the submodel called `vector'. It evaluates the distribution of the soil moisture de®cits in the catchment, according to the static relation of TOPMODEL [Equation (2)], which can be rewritten in the form: S 3 t S3 t m l ÿ l 3 where S3 t [ S t in Equations (1) and (2)] denotes a scalar averaged catchment soil moisture de®cit, evaluated in the third submodel, and the vector S3 S 3;1 ; S 3;2 , . . . , S3;n is the topography-dependent soil moisture de®cit changing with time according to S3 t, where n denotes the number of discrete values of the topographic distribution (here n 60), and l is a vector representing the topographic index distribution. In the `runo' submodel the overland ¯ow from the root zone and the gravity drainage zone are summed up according to the incremental areas of the topographic index distribution. As shown in Figure 1, both the root zone and gravity drainage zone depend on the topographic index distribution through the soil moisture de®cit vector S3 . Hence, those submodels are also represented in a vector form. This feedback is a simpli®ed description of the dependency of the upward and downward groundwater ¯uxes on the soil moisture de®cit. The submodel dynamics were changed to some extent in comparison with the model presented by Beven and Kirkby (1979), without changing the essential structure of the model. Explanations of the changes will be given in the following sections, together with more detailed descriptions of SIMULINK±TOPMODEL subsystems. # 1997 by John Wiley & Sons, Ltd. HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) 1118 # 1997 by John Wiley & Sons, Ltd. Figure 3. SIMULINK scheme of root zone model, subsystem `root' from Figure 2. Icon `Gain' denotes multiplication by a constant. Icons `time translation', `vector product' and `matrix gain' denote SIMULINK operations R. ROMANOWICZ HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) Figure 2. SIMULINK±TOPMODEL general scheme. Icons `Demux' and `sum' and `clock' represent SIMULINK operations. The other icons are `user de®ned'. The icons with iconographic drawing represent complex subsystems TOPMODEL 4: MATLAB IMPLEMENTATION 1119 Root zone model The search for a better description of the interrelations between the root zone and the unsaturated± saturated zone in the catchment, without introduction of many new parameters, resulted in a submodel based on the simple water balance relation in vector form (corresponding to the introduced vector representation): LRZ y t 1 LRZ y t P t ÿ E p ÿ Qyy t; Z t 4 where P(t) denotes the rainfall; E p the potential evaporation; y t the vector of soil moisture content, averaged over the root zone depth; LRZ is the depth of the root; zone and Z(t) denotes the vector of groundwater levels, de®ned below the root zone depth, which we assume is linearly related to the soil moisture de®cit as: S t Z t Dy0 where Dy0 is some volumetric moisture de®cit formed by rapid drainage assumed constant with depth (Beven, 1986). In this description it is assumed that the root zone has a constant soil moisture with depth. Upward or downward ¯ux in the unsaturated zone is treated as a steady recharge or capillary rise. It is conditioned on the boundary conditions of the root zone moisture content and the depth of the groundwater table. The recharge or capillary rise, Qyy t; Z t, depends on the moisture content in the root zone and the groundwater level, which both depend on the soil±topographic index. For the sake of simplicity, its derivation will be explained using the scalar notation. This relation is obtained on the basis of a Darcian analysis of steady recharge from above or below (an assumption consistent with the TOPMODEL assumptions, see Beven et al., 1995), such that: @h 1 5 Q K h @z where h denotes the moisture pressure head, z is the vertical coordinate and K(h) is the vertical conductivity in the unsaturated zone. The further assumption is made that the relation between vertical conductivity and moisture pressure head is exponential, corresponding to the so-called Gardner model (Gardner, 1958): K h K s exp ÿa1 h 6 In order to get the relation between soil moisture and conductivity, we shall implement a generalized Gardner model (Romanowicz et al., 1995), which allows for a non-linear diusivity±moisture relation and gives a non-linear conductivity±soil moisture relation of the form: a2 y 7 K y K s ys where a1 , from Equation (6), and a2 are coecients depending on soil properties. Combining Equations (4±7) and introducing the time index t and vector notation, the following relation for the ¯ux from the root zone to the saturated zone, or vice versa, is obtained: a2 y t ÿexpÿa1 Z t ys 8 Qyy t; Z t K s 1 ÿ expÿa1 Z t This relation depends on the saturated conductivity K s, soil moisture content in the root zone y , groundwater level Z and soil porosity parameters a1 and a2 . As the groundwater level is changing across the catchment # 1997 by John Wiley & Sons, Ltd. HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) 1120 R. ROMANOWICZ according to the soil±topographic index, the vertical ¯ux and root zone water content will also change. The initial moisture content in the root zone is estimated from the initial average storage de®cit as determined from the inversion of Equation (1). In the original formulation of TOPMODEL the root zone represents a soil water storage re¯ecting the `®eld capacity' concept (Beven et al., 1995). Flow into gravity storage, i.e. unsaturated and saturated storages, occurs only when `®eld capacity' is satis®ed. In the present formulation steady capillary rise or downward ¯ux from the root zone to the water table depends on the root zone moisture content and the water table depth. When the root zone is full to ®eld capacity, rainfall in®ltrates into the gravity storage with a steady ¯ux approaching K s for low water table depths [see Equation (9)], which is consistent with the original TOPMODEL formulation. This case would be regarded in the literature as post-ponding in®ltration with constant saturated soil moisture at the surface (Philip, 1969). The present formulation diers from that given by Wood et al. (1990), where, after ponding, in®ltration proceeds with the rate determined from the concentration boundary condition at the surface (Philip, 1969) and with the vertical ¯ow formulations used in recent versions of TOPMODEL (Beven et al., 1995). The main dierence between the present and original formulation occurs for the intermediate cases, when the root zone water content is small and the water table is close to the root zone and capillary rise takes place. Conductivity is assumed to change exponentially with pressure head according to the Gardner assumptions. The SIMULINK scheme for the root zone is presented in Figure 3. As mentioned above, in order to simplify and generalize the program structure, a vector representation of the topographic index is introduced. This description yields a state space representation of the root zone with a dimension equal to the dimension of the discretized topographic index distribution (60 discrete values in the presented paper). The input to the submodel consists of the catchment average precipitation, evaporation and the local soil moisture de®cits in the catchment evaluated in the `vector' submodel. The submodel output consists of the vector of the resulting water transfers from or to the unsaturated zone and runo from the contributing areas. Gravity drainage model A detailed scheme of the SIMULINK gravity drainage submodel is given in Figure 4. In this particular application the unsaturated zone has very simpli®ed dynamics, as given by Equation (9). In the case when some more detailed observations in the catchment are available it could be developed further without the danger of overparameterization. The input to this submodel consists of the vector of soil moisture transfers from/to the root zone and the vector of soil moisture de®cits evaluated in the `vector' submodel. Hence, this submodel has a vector form dependent on the topographic index. Its dynamics has the form: S 2 t 1 minfS 3 t; max0; S 2 t ÿ Q y t; Z tg 9 where S 2 t denotes the vector of de®cits of the unsaturated zone, which is not allowed to be bigger than the soil moisture de®cit for a given topographic index calculated from the third `saturation zone' submodel. Qyy t; Z t denotes the vector of water ¯ux from the root zone submodel given by Equation (8). Thus, the water transfer to the saturated zone in the vector notation is equal to: Qv t S 2 t 1 ÿ S 2 t Qyy t; Z t 10 As the saturated zone submodel is averaged over the catchment, the vector given by Equation (11) must also be averaged using the aerial weight associated with each discrete value of topographic index. The components of Qv can be positive or negative, depending on the conditions in the catchment. Saturated zone model The third storage is assumed to be non-linear with the exponential out¯ow, Qb t, given by the scalar exponential function of Equation (1). The change of catchment average saturation zone storage de®cit S3 t HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) # 1997 by John Wiley & Sons, Ltd. # 1997 by John Wiley & Sons, Ltd. 1121 HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) Figure 5. SIMULINK scheme of saturation zone submodel from Figure 2. Icon `integrator' represents SIMULINK operation TOPMODEL 4: MATLAB IMPLEMENTATION Figure 4. SIMULINK scheme of `gravity drainage' submodel from Figure 2. Icon `Mux' denotes SIMULINK operation 1122 R. ROMANOWICZ with time can be described by the following balance equation: dS3 t Qb t ÿ Qv t dt 11 where Qb t is the downslope ¯ow and Qv t SAi Qvi t is the total amount of water transferred between the catchment surface and the saturated zone summed over the topographic index distribution aerial weights Ai , with Qv negative in the case of capillary rise. It is assumed that the out¯ow from this storage is non-linear and follows an exponential rule in a relation equivalent to Equation (1): Qb t Q0 expÿ S3 t=m 12 where Q0 T 0 e ÿ l is the ¯ow when S3 t 0 and is a constant for a catchment. The SIMULINK scheme of this submodel is given in Figure 5. Its input is the catchment average recharge from the unsaturated zone and its output is evaluated according to Equation (12). This submodel is onedimensional and is the basic component of TOPMODEL described by Equations (2), (11) and (12). It uses a continuous integrator with initial soil moisture de®cit speci®ed from an initial discharge in accordance with Equation (1). Both root zone and unsaturated zone submodels have discrete integrators represented by `discrete state space' modules. This is owing to the fact that when the scheme was built, continuous integrators were not yet available in vector form within SIMULINK. A continuous integrator is usually recommended for continuous problems and the user can easily change the scheme accordingly. Those discrete integrators have been left here to demonstrate the ability of the model to incorporate dierent submodel descriptions. The `vector' submodel conceptually belongs to the saturated zone model but was shown separately, mainly for the illustrative purpose of stressing the dierent use of the vector and scalar form of the soil moisture de®cits in this form of TOPMODEL. The root zone, gravity drainage zone and saturated zone submodels constitute the main `body' of TOPMODEL. Depending on the goal of the modelling and available data the user can further develop TOPMODEL structure, adding new, or extending and developing existing, components. The next section demonstrates the extension of the root zone model towards the estimation of the spatial patterns of soil moisture and evaporation changes in the catchment. As there are no data available for the calibration of parameters involved, the demonstration has a mainly illustrative purpose. Soil moisture and evaporation The vector of root zone soil moisture, as dependent on the topographic index can be used to produce a two-dimensional graphical representation of the soil moisture and evaporation spatial distribution in a catchment, developed in MATLAB. It is assumed that the distribution of the moisture content over the catchment is consistent with the distribution of the topographic index, i.e. the soil transmissivity is uniform. This assumption may be changed if there is some additional information available about the vegetation/soil distribution in the catchment. To relate the soil moisture at the surface to the initial recharge of the unsaturated zone, Equation (8) is used. The soil moisture content evaluated in the root zone can be related to the actual evaporation from the catchment E a with the help of the relationship introduced by Philip (1957), who expressed the actual evapotranspiration in terms of relative soil moisture and atmospheric humidity: E a t E p hp t ÿ ha 1 ÿ ha 13 where E p denotes potential evaporation and ha and hp are relative atmospheric and soil humidity, respectively. HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) # 1997 by John Wiley & Sons, Ltd. TOPMODEL 4: MATLAB IMPLEMENTATION 1123 Figure 6. Simulated and observed ¯ow, validation period, January 1988, River Severn catchment at Plynlimon, UK The relative soil humidity can be expressed in terms of the soil moisture potential using the thermodynamic equation under the assumptions of negligible temperature changes (see also O'Kane, 1992). Assuming some tractable model of the moisture characteristic curve (e.g. a generalized Gardner form, as in Romanowicz et al., 1995) the following formula can be derived: ( ) y t nfe =a exp nfe ÿha ys 14 E a t E p 1 ÿ ha where ha denotes the relative humidity of the air at the soil surface, E p is the potential evaporation, fe is air entry soil moisture potential, ys is soil moisture at saturation, n is a thermodynamic constant (n 74 10ÿ6 kg Jÿ1 at t 208C) and a a1 =a2 depends on soil porosity; and y t denotes the vector of soil moisture content in the root zone, changing with time. Hence, E a also has a vector form, depending on the soil±topographic index and it is possible to map it back on to the topography using the spatial distribution of that index (Figure 7). In other words, each cell of the grided catchment area has some # 1997 by John Wiley & Sons, Ltd. HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) 1124 R. ROMANOWICZ Figure 7. Topographic index distribution for the River Severn catchment at Plynlimon, UK. Stars on the map indicate the Severn catchment boundaries with an outlet at the right-hand corner. The picture scale corresponds to number of, x and y, 50-m grid pixels (6 km 8 km rectangle) known topographic index value which corresponds, in turn, to the value of evaporation and soil moisture content. In this way both changes of soil moisture content and actual evapotranspiration distributions with time can be represented graphically. Figures 8 and 9 show soil moisture distribution and evapotranspiration for an area of mid-Wales at two dierent time steps during a storm event. In the numerical application presented, soil parameters were set to values typically met in the literature for loamy±clay HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) # 1997 by John Wiley & Sons, Ltd. TOPMODEL 4: MATLAB IMPLEMENTATION 1125 Figure 8. Soil moisture distribution over the Severn catchment at Plynlimon, UK, at t 45 h of an event (validation period), January 1988. Stars on the map indicate the Severn catchment boundaries with an outlet at the right-hand corner. The picture scale corresponds to number of, x and y, 50-m grid pixels (6 km 8 km rectangle) soils: a 037 10 ÿ 4 , fe 01 m, K s 0006 m h ÿ 1 , ha for the soil moisture in Equation (13) is equal to 0.2. Soil in the root zone submodel, have been treated as average tioned, the maps presented have only qualitative meaning calibration. # 1997 by John Wiley & Sons, Ltd. 0001. For those parameters the exponent parameters used in this submodel, as well as values over the catchment. As already menowing to lack of observations for parameter HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) 1126 R. ROMANOWICZ Figure 9. Evaporation distribution over the Severn catchment at Plynlimon, UK, at t 45 h of an event, January 1988. Stars on the map indicate the Severn catchment boundaries with an outlet at the right-hand corner. The picture scale corresponds to number of, x and y, 50-m grid pixels (6 km 8 km rectangle) PARAMETER CALIBRATION OF SIMULINK±TOPMODEL WITHIN MATLAB The model was tested on the Institute of Hydrology experimental catchment on the River Severn at Plynlimon, mid-Wales, UK, which forms part of the 8 6 km2 area shown in Figures 7±9. It is a small, predominantly forested catchment of area 8.7 km2 with continuous hourly ¯ow and rainfall data. The HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) # 1997 by John Wiley & Sons, Ltd. 1127 TOPMODEL 4: MATLAB IMPLEMENTATION Table I. Optimization results for dierent starting points and dierent time horizons in two-dimensional parameter space mstart LRZstart mfinal LRZfinal Time horizon (h) NI 0.02 0.01 0.02 0.03 0.1 0.1 0.2 0.3 0.0098 0.0137 0.0137 0.0133 0.2188 0.1298 0.1291 0.1292 200 400 400 500 62 63 80 108 Table II. TOPMODEL parameters used in the validation experiment shown in Figure 6 m (m) LRZ (m) 0.0098 0.2188 T 0 m2 h ÿ 1 3 10 K s m=h ÿ 1 0.006 a 037 10 ÿ4 ys ha fe m 0.42 0.001 0.1 required data are the same as for the FORTRAN version of TOPMODEL. They consist of rainfall, evaporation and ¯ow data, as well as a topographic index distribution obtained from the elevation data. The available DTM has 50 m resolution and contains also the adjacent Wye experimental catchment. The time data consist of hourly discharges and rainfall series for the years 1986 and 1988. The hourly potential evapotranspiration is estimated from meteorological measurements using the Penman±Monteith formula. In this application the model is used to simulate hourly ¯ows using hourly rainfall inputs. The parameters of the model may be set on the basis of any suitable calibration method outside the MATLAB software. However, it is convenient to calibrate the parameters of SIMULINK±TOPMODEL using the optimization routines within the MATLAB workframe. The multivariable optimization routine in MATLAB uses the non-gradient Nelder±Meade simplex search described in Dennis and Woods (1987). The SIMULINK±TOPMODEL system has the form of an M-®le in MATLAB and constitutes a set of dierential equations that are integrated at each call of the optimization routine. The choice of method of integration is the same as in the SIMULINK Menu (e.g. Runge±Kutta 3rd and 5th order, Gear, Adams or Euler). In the presented application an Adams/Gear method of integration was chosen. The results of the simulations are used to evaluate some performance measure speci®ed by the user that is directly used in the optimization procedure. The results of the subsequent runs of TOPMODEL (e.g. time trajectory of simulated and observed ¯ows) can be displayed on-line within the MATLAB graphical window, together with the corresponding parameter values obtained during the optimization procedure. To ensure proper communication between dierent MATLAB subroutines all the parameters that undergo changes because of the optimization procedure should be declared as `global' in the MATLAB workspace. As can be easily guessed, the MATLAB calibration procedure will take more computer time than a corresponding FORTRAN procedure. However, it might be very useful when experimenting with the model structure. Also, it can save programming time when more complicated, non-linear dierential equation structures are considered, since the integrators are robust and quick and do not require any programming eort. In the corresponding FORTRAN program ordinary dierential equations are replaced by dierence equations with a time step dictated by the discretization of input data. In SIMULINK, integrator algorithms can use a variable time step controlled by the required accuracy of the solution. Four examples of the results of the MATLAB-based joint calibration routine of the recession parameter m and root zone layer depth LRZ , for dierent starting points of parameters and dierent length of time horizon, are given in Table I. The other model parameters are given in Table II. From previous numerical experiments performed on this catchment (Romanowicz et al., 1993) it was known that the transmissivity parameter does not in¯uence the simulated ¯ow when its value is bigger than some threshold value (here T 0 103 m2 h ÿ 1 ). Therefore, this parameter was not included in the optimization. The time horizons of simulations were 200, 400 and 500 hours long. The sum of square dierences between the simulated and observed ¯ows was taken as the objective function. The time of computation of a single # 1997 by John Wiley & Sons, Ltd. HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) 1128 R. ROMANOWICZ simulation was about 20 s on a SUN 10 workstation. A single parameter optimization needs about 22 simulations (objective function evaluations) for a 200 hours time horizon. Parameter NI in Table I denotes the number of simulations needed to obtain some precision of the optimization (minimum value of the objective function) speci®ed by the user. When starting from dierent initial parameter values dierent numbers of simulations are required to obtain the same goodness-of-®t measure of the model performance. The number of simulations required will also be dierent for dierent sets of in¯ow data. As the time of computation of a single simulation increases with the increase of the length of time horizon, so the optimization time will increase. Because of the use of non-gradient optimization procedures, time of computations increases rapidly with the increase in the number of calibrated variables and will depend on how far the starting point is from the best estimate. Hence, because of long times of computations, this software is not recommended for a multiple search through the entire parameter region for long (thousands of hours) time periods. It can be useful in the case when it is expected that owing to changes in the model structure, parameters should change slightly, or when we want to set the initial values for the parameters that would give reasonable results for short time periods. MATLAB graphical facilities allow the display of the results of simulations for each change of parameter set, which might also help in model analysis. THE RESULTS OF SIMULATIONS The model parameters m, and LRZ were optimized using the MATLAB non-gradient optimization routine described above. Sensitivity analysis of the results has shown that the depth of the root zone in¯uences the results in a most pronounced way. Soil parameters as used in the model are treated as averaged over the catchment. From the results presented in Table I it can be seen that the value of optimal parameters depend on the length of the time horizon of simulations and the initial parameter values. Hence, running the optimization procedure for the longest possible time horizons for several dierent starting points is recommended. To minimize the time of computations of a single run of the model, and for clarity of the SIMULINK scheme, all the preparations of data needed by the program, such as initial value of the soil moisture de®cit and the catchment average topographic index, were done in a MATLAB program that is run before the SIMULINK program. When the optimization facilities are used this program is incorporated into the optimization procedures in MATLAB. SIMULINK graphical facilities allow on-line observation of any variables in the model during the simulation process. The results of simulations can also be presented using the MATLAB graphical facilities after the simulations are ®nished. Figure 6 presents the simulated and observed out¯ow hydrographs for a separate validation period with parameters given in Table II. The changes of the soil moisture content for dierent values of topographic index can be mapped back on to the space, thus allowing a two-dimensional (or three-dimensional when over imposed on the topography map) graphical representation of the spatial changes of those variables in the catchment as shown in Figures 7±8. MATLAB allows time and space changes to be shown together, in the form of video images that can be presented on the computer screen. CONCLUSIONS This paper has described a SIMULINK version of TOPMODEL, and its use together with a MATLAB parameter calibration routine. These included: 1. 2. 3. 4. 5. A state space representation of TOPMODEL. The vector representation of the topographic index distribution. The scheme of the main SIMULINK±TOPMODEL structure and the schemes of the submodels. The graphical presentation of the results. Parameter calibration using the MATLAB optimization routines. It is worth noting that SIMULINK forces the modeller to use the language of systems analysis. It encourages a deeper understanding of the model used and clear division of the physical system into the HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997) # 1997 by John Wiley & Sons, Ltd. TOPMODEL 4: MATLAB IMPLEMENTATION 1129 interacting subsystems. Its structure clearly demonstrates the simpli®cations used in the representation of the physical process and the mutual interdependence of the subprocesses. It also allows more complicated descriptions of the subprocesses to be used, while the main structure of the model is still unchanged. For example, we can easily imagine introducing a more precise description of the evapotranspiration process or gravity drainage zone, when more observations are available. Also, in the case when contaminant data are present, another submodel describing transport in the catchment could be added. Also, model parameters can be easily adjusted by the user while comparing the simulation results with the expected ones or observations. The possibility of using the MATLAB powerful non-gradient optimization routines allows for a more precise choice of any parameters, without the need of building the equivalent FORTRAN program. The main advantages of the SIMULINK±TOPMODEL lie in its very illustrative and easy to follow system structure, which makes evident the direction of data ¯ows in the modelled process. This system structure gives the possibility of further investigation and development of its subsystems using the MATLAB graphical tools, including the easy presentation of spatially distributed predictions either during a simulation run as an animation, or later as o-line evaluation of the results. This form of visual presentation is particularly useful in assessing and comparing the performance of distributed models, relative to the expectations of the observed catchment behaviour. ACKNOWLEDGEMENTS I would like to thank Keith Beven for his encouragement and help in developing the root zone submodel and Wlodek Tych (both from Environmental Sciences Division, Lancaster University), for introducing me to MATLAB±SIMULINK. Data used in the numerical examples given were taken from research done by the author as part of NERC grant GST/02/491. REFERENCES Beven, K. 1984. `In®ltration into a class of vertically non uniform soils', Hydrol. Sci. J., 29, 425±434. Beven, K. J. 1986. `Runo production and ¯ood frequency in catchment of order n: an alternative approach', in Rodriguez-Iturbe, I. and Wood, E. F. (Eds), Scale Problems in Hydrology. Reidel, Dordrecht. pp. 107±131. Beven, K. J., 1997. `TOPMODEL: a critique', Hydrol. Process., 11, 1069±1085. Beven, K. and Kirkby, M. J. 1979. `A physically based variable contributing area model of basin hydrology', Hydrol. Sci. Bull., 24, 43±69. Beven, K. J., Lamb, R., Quinn, P., Romanowicz, R. and Freer, J. 1995. `TOPMODEL', in Sing, V. P. (Ed.), Computer Models of Watershed Hydrology. Water Resource Publications, Colorado. pp. 627±668. Dennis, J. E. and Woods, D. J. 1987. New Computing Environments: Microcomputers in Large-Scale Computing, Wouk, A. (Ed.). Society for Industrial and Applied Mathematics, Philadelphia, Pa. pp. 116±122. Gardner, W. R. 1958. `Some steady state solutions of the unsaturated moisture ¯ow equation with application to evaporation from a water table', Soil Sci., 85, 228±232. MathWork's Inc. 1992. SIMULINK Ð Dynamic System Simulation Software, User Guide, MathWork's Inc., Mass., US. O'Kane, P. J. 1992. `The hydrology of milled peat production', in O'Kane, J. P. (Ed.), Advances in Theoretical Hydrology Ð A Tribute to James Dooge. European Geophysical Society Series on Hydrological Sciences, Vol. 1. Elsevier, Amsterdam. Philip, J. R. 1957. `Evaporation and moisture and heat ®elds in soil', J. Meteorol., 14, 354±366. Philip, J. R. 1969. `Theory of in®ltration', Adv. Hydrosci., 5, 215±296. Quinn, P. F., Beven, K., Chevallier, P., and Planchon, O. 1991. `The prediction of hillslope ¯ow paths for distributed hydrological modelling using digital terrain models', Hydrol. Process., 5, 59±79. Quinn, P. F., Beven, K. J., and Lamb, R. 1995. `The l a=tan b index: how to calculate it and how to use it within the TOPMODEL framework', Hydrol. Process., 9, 161±182. Romanowicz, R., Beven, K., Freer, J., and Moore, R. 1993. `TOPMODEL as an application module within WIS', in Kovar, K. and Nachtnebel, H. P. (Eds), Proceedings of the International Conference on Application of Geographic Information Systems in Hydrology and Water Resources, HydroGIS93, IAHS Publ. No 211. IAHS, Wallingford. pp. 211±233. Romanowicz, R., Beven, K. and Moore, R. 1994. `GIS and distributed hydrologic models', in Mather, P. M. (Ed.), Geographical Information Handling Ð Research and Applications. Wiley, Chichester. pp. 197±205. Romanowicz, R. J., Dooge, J. C. I., and O'Kane, J. P. 1995. `Spatial variability of evaporation from the land surface Ð random initial conditions', in Kundzewicz, Z. (Ed.), New Uncertainty Concepts in Hydrology and Water Resources. Cambridge University Press, Cambridge. pp. 197±205. Wood, E. F., Sivapalan, M., and Beven, K. J. 1990. `Similarity and scale in catchment storm response', Rev. Geophys., 28, 1±18. # 1997 by John Wiley & Sons, Ltd. HYDROLOGICAL PROCESSES, VOL. 11, 1115±1129 (1997)