© 2005 Adri Verwey
Copyright © 2005, Adri Verwey
The right of Adri Verwey to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988
Contents
1 Introduction...7
1.1 Introductory remarks...7
1.2 Unsteady flow hydraulics ...8
1.3 Numerical methods...11
1.4 Mathematical modelling model ...11
2 Introduction to numerical methods...17
2.1 Introduction...17
2.2 Introduction to finite difference approximations ...18
2.3 The Euler scheme ...18
2.4 The improved Euler scheme ...21
2.5 The implicit scheme...22
2.6 The Newton-Raphson scheme ...22
2.7 A more formal analysis of accuracy ...23
2.8 Stability...26
2.9 Consistency and convergence...27
2.10 The choice of a time step ...27
2.11 Reservoir routing ...29
2.12 Routing of a decayable pollutant through a reservoir...33
2.13 Non-uniform steady flow in channels...34
2.14 An inverse scheme for the backwater curve computation ...38
2.15 Non-uniform flow in non-uniform channels...40
2.16 What have we learnt?...41
3 Basic Unsteady Channel Flow Equations ...43
3.1 Introduction...43
3.2 Continuity equation ...43
3.3 Momentum equation...44
3.4 Transformation to the characteristic form...45
3.5 The significance of the characteristics...48
3.6 The method of characteristics ...51
3.7 More complex boundary conditions ...55
3.8 The formation of positive and negative hydraulic jumps ...57
3.9 The limited practical importance of the method of characteristics...59
3.10 Questions and assignments ...60
4 Introducing Numerical Solutions for Partial Differential Equations...61
4.1 Introduction...61
4.2 The advection equation...63
4.3 The characteristic solution ...64
4.4 Finite difference schemes ...65
4.5 Characteristic solutions on a fixed grid ...70
4.6 Introducing diffusion ...72
4.7 An explicit finite difference scheme...73
4.8 Explicit schemes for the combination of advection and diffusion...76
4.9 Implicit schemes for the diffusion equation...77
5 De Saint Venant equations and their solutions...81
5.1 Introduction...81
5.2 The continuity equation ...82
5.3 The momentum equation ...84
5.5 Description of hydraulic structures...92
5.6 Topological model schematisation...94
5.7 Hydraulic model schematisation...95
5.8 Boundary- and initial conditions...97
5.9 Model calibration and validation ...99
6 Mathematical modelling of floods ...101
6.1 Introduction...101
6.2 Flood model requirements ...101
6.3 The role of new data collection technologies ...103
6.4 The nature of flood wave propagation...104
6.5 Deformation of flood waves ...105
6.5.1 The role of varying celerities...105
6.5.2 The role of the diffusion term ...106
6.5.3 The role of the lateral flow terms...107
6.6 Link to hydrologic flood routing models...107
6.7 Two-dimensional modelling of floods...108
6.8 Integrated 1D/2D modelling ...113
6.9 Exercise...116
7 Water Hammer ...117
7.1 Introduction...117
7.2 Water Hammer Equations...119
7.3 The Method of Characteristics for Water Hammer...125
7.4 Exercise...128
1
Introduction
1.1
Introductory remarks
The topic of computational hydraulics is dealing with the question how water resources engineers and planners can be assisted in dealing with complex hydraulic problems. When these problems are very local, they can generally be addressed by using empirical relationships and a well trained engineer usually is equipped with methods and tools dealing with it. In these cases, the use of laws and relationships in hydraulics is often limited to steady flow approximations.
For larger scale problems, however, the unsteady nature of flows becomes more dominant and methods used will become more complex. Whereas until various decades ago, the focus has been on developing approximations, partly empirical, of the full hydrodynamic behaviour of the water system, the use of computers has made it possible to describe hydraulic systems quite accurately. Over the past decades enormous progress has been made in developing simulators or mathematical models for all kinds of hydraulic systems, such as rivers, drainage networks, irrigation networks, water distribution networks etc.
Currently, the level of accuracy of such simulators is primarily limited by the quality of data available to construct and calibrate the models. A variety of good software packages is available to construct such models. However, good schematisations of hydraulic systems in models requires some insight in the laws and techniques behind these modelling systems in order to use them correctly in building one’s own model. In this series of lectures we address this need by providing insight into the nature of one-dimensional unsteady flow. After the introduction of the unsteady flow equations, the link between the equations and the physical system is shown by the characteristic celerities of disturbances propagating along channels. This provides the basis for the numerical schemes developed to solve the equations. Moreover, it shows clearly the effect of boundary variations and, in particular, the effects of control of hydraulic systems.
With this understanding as a basis, numerical method is introduced. First, only the so-called ordinary differential equations are treated, enabling us to do simple backwater computations, water quality simulation in well mixed reservoirs etc. However, at the same time numerical concepts and their evaluation are introduced relating to the accuracy, stability, robustness and efficiency of numerical operations. This will serve as a necessary basis for those who want to develop their own models, as well as for those applying existing modelling systems.
Subsequently, numerical descriptions of more complex problems described by partial differential equations are discussed, primarily to provide enough insight as a basis for good mathematical modelling practice. Also here, the role and choice of numerical parameters in mathematical model simulation is emphasised.
Finally, the overall construction of good mathematical models is discussed. Based upon a clear idea about the objective of model use, rules for the most economical and correct schematisation are developed, starting with a topological schematisation of the system. In addition, the derivation of correct physical parameters is discussed, such as those describing channel conveyance, storage and lateral flows. Moreover, the possibilities and limitations of such models is discussed, with special attention given to the use of models under extrapolated conditions, such as often the case in the modelling of floods.
1.2
Unsteady flow hydraulics
In teaching, the topic of hydraulics is generally first introduced from the steady flow concept. In principle, it would be more logical to start with the unsteady flow concept and than introduce steady flow as a special case of unsteady flow. In this case a clear indication has to be made of the underlying assumptions and the simplification of the problem. In each application these assumptions have to be verified.
It should be realised that a real steady flow does not exist in nature. There will always be some small variations in the flow distribution, even if there are no observable water level variations. The steady flow is a concept of our engineering mind, which sometimes can simplify engineering without unacceptable differences from reality. However, the danger exists that engineers turn too easily towards the concept of steady flow, even in cases where this is a quite wrong schematization of reality and where this approach may lead to quite wrong conclusions.
For this reason, it is important to familiarize oneself with problems which typically show more significant variations both in time and in space. Hydraulic problems in channels are governed by two important concepts: storage and conveyance. For incompressible flow, the first concept deals with water volume conservation. The second concept deals with balance of forces acting upon the water mass and their effect on the momentum balance. Of particular importance in this description is the magnitude of flow momentum losses due to channel friction relative to the gain of momentum due to gravity or other forces.
Before we can discuss more in detail the difference between steady and unsteady flow, the concept of boundary conditions has to be introduced. In general, one is only interested in a specific part of a hydraulic system. To illustrate this idea, it is useful to consider the hydrological cycle. Water evaporates from the sea surface, precipitates partly above land and flows via the land surface, or via infiltration through the subsurface, to the rivers and, in most cases, back to the sea. Let us now consider the river part of this cycle, or even a small part of this river system. The link to the upstream part of this river subsystem is specified in the form of a
The link to the lower part of the river system, or to the sea, is specified as the downstream boundary condition. In the sequel, we will discuss these boundary conditions in more detail, including the question of the real need for such conditions in our computations.
The question of the flow type is very much linked to the nature of the changes at the boundaries of the area described (or modelled). When the part of the river system studied adapts its state only slowly to the changes at the boundaries, the system is considered to be unsteady. However, when the river system adapts its state nearly instantaneously to the changes at the boundaries, the system is said to be quasi-steady and some quasi-steady flow concepts might be used. This is usually the case when local or near-field problems are studied, such as local structures with their typical backwater effects.
One of the important parameters influencing this ease to adaptation is the storage in the system. If this storage capacity is large compared to the difference between inflow and outflow the time scale of adaptation is also large. It is very likely, then, that we will observe a strongly unsteady flow phenomenon. If, however, there is little storage capacity available between the boundaries, the adaptation of the state of the system to the new boundary conditions may be fast and the flow may pass through a sequence of nearly-steady states. This adaptation is also dependent on the facility of the flow to accelerate or decelerate. If the adaptation of flow particle velocities to changing boundary conditions is fast, the system will pass through a series of nearly-steady states. Where the adaptation is slow compared to the changes at the boundaries, the result will be clearly an unsteady flow.
These concepts are best illustrated by giving some practical examples. Flood waves in rivers
Floods in a river are the result of the surface- and subsurface runoff generated during periods of intense rainfall. This response usually leads to a typical hydrograph shape discharge and water level variation in the river, which is more pronounced when the rain is uniformly distributed over the period of the rain event. However, as rainfall is generally not uniformly distributed in time, the discharge distribution from the catchments into the river is usually less irregular. While the flood wave propagates down the river it undergoes further deformations due to varying storage and conveyance characteristics of the river channel and due to additional lateral inflows from other catchments. These processes together form a typical unsteady flow phenomenon, which can only be studied by simulations on the basis of unsteady flow equations.
Flow in an urban drainage or combined sewer system
Drainage from urban catchments is to be seen as a special case of flood routing. Differences with a rural catchment are the faster response to the rainfall, the smaller amount of storage usually available and the more important role of channel conveyance, compared to channel or reservoir storage. In systems with drainage pipes, the open channel flow may temporarily change into a pressurized flow. The unsteadiness of the phenomenon, however, is very pronounced.
Despite these differences, it will be shown in the sequel that these problems require the same modelling tools as the ones used for the study of flood routing in rivers. Flow in a desert wadi
In wadis, the unsteady nature of the flow is even more pronounced than in many other rivers, due to the infiltration of the water into the river and flood plain bed. This leads to the steepening up of the flood wave front. Also, if often leads to the complete disappearance of the flood wave after some time.
Flow in irrigation systems
Flow in irrigation systems is usually controlled for the optimum use of the water resources. This control introduces variations in time. A fast control may even lead to the formation of hydraulic jumps travelling along the channel. Although the design of the irrigation canals is often based on steady flow concepts, the performance under operation usually requires checks on the basis of unsteady flow computations. Flow over or through a hydraulic structure
The description of flow through a hydraulic structure within a river branch is usually based on an assumption of steady flow. The discharge at each moment in time is directly dependent on the water level boundary conditions. Although these water levels may vary rather fast, the discharge generated will respond more or less instantaneously. The immediate adaptation of the flow to changing boundary conditions is the result of the lack of storage between the upstream and downstream section and the presence of a relatively small water mass to be accelerated or decelerated. As will be shown in the sequel, the possibility to link a steady flow channel element to channel elements where the flow has a distinctly unsteady nature, depends on the relative importance of the various terms of the equations describing the flow problem.
Flow in pipe networks
Flow in pipe networks for water distribution in a town is often computed as steady flow. For given constant water demands at various places in town and constant water levels in reservoirs, the flow and pressure distribution over the complete network can indeed be computed. These computed pressures can be checked against minimum pressure requirements. However, the assumption of constant demands is an oversimplification of reality. Water demands usually have daily and weekly cycles. Reservoirs may be filled during the night at cheaper electricity rates and emptied during the day, when demands are higher. Fire fighting may suddenly change the water demands over the network. These varying demands and storage lead to unsteady flow phenomena in pipe networks, although these are still often computed as series of quasi-steady states. Complete unsteady flow may occur as a result of sudden changes caused by failures or misoperation of the distribution network. This may cause unacceptable water hammer and cavitation effects. In this case computations are based on the use of the full unsteady flow equations for pipe flow, including storage of water resulting from water compressibility and pipe
1.3
Numerical methods
Although numerical methods have been developed already for centuries, the possibilities offered by computers have given a strong impulse to the further development of these methods. With numerical methods one tries to solve sets of differential equations, such as the De Saint Venant equations for unsteady flow in river- and channel systems. In the derivation of the differential equations one starts with finite control volumes for the definition of balance equations and than assumes that these volumes reduce to an infinitesimal small size. Under this assumption, these equations provide a correct and valid description of continuous flows.
With numerical methods this process is reversed and balance equations are derived over finite control volumes, starting from the differential equations. For this reason, one cannot expect that this procedure leads to the same results as those which might have been obtained by solving the partial differential equations directly. However, in most cases such solutions do not exist, particularly when the equations are non-linear. This, unfortunately, is usually the case when solving practical problems in hydraulics.
Currently, for nearly all applications in hydraulics, numerical methods have been developed that work well and have the potential of limiting the differences between exact solutions and the approximate solutions. In these lectures we are discussing the differences by dealing with concept such as consistency, stability, robustness and economy of numerical operations. In particular, it will be shown how partial differential equations can be transformed into linear finite difference equations, to which extent these linearization’s require iterations and what sort of algorithms exist to solve the systems of equations in an economical way.
It will also be shown, wherever applicable, that numerical behaviour is related to the physical behaviour described. Most obvious is the relation between boundary data requirements and the way changes at boundaries are affected by the hydraulic system. However, also the performance of iteration techniques are influenced by the physical behaviour of the system.
The objective of dealing with numerical methods in this lecture series is to provide enough background information to serve as a basis for the correct development of models and for the best choice of modelling systems offered for use in a project.
1.4
Mathematical modelling
Modelling has become a frequently used tool for studies in hydraulic and environmental engineering. Whereas in the past many engineers turned to physically based models or simplified descriptions for the support of engineering studies, the increasing availability of personal computers and the powerful developments in computer graphics, data bases and on-line control, software has brought computer support to the desk of consulting engineers. In line with these developments we also see a strongly increased availability and use of mathematical modelling software tools.
For a better understanding of what a model represents, let us look at one of the many possible ways of defining such a tool:
a model is a physical or mathematical description of a physical system, including the interaction with its outside world, which can be used to simulate the effect of changes in the system itself or the effect of changes in the conditions imposed upon it.
In the development of a mathematical model one may distinguish the following main elements:
· definition of objectives · schematisation
· equations and conditions · solution algorithm
· software choice or development · data collection
· model calibration · model verification · simulations
Definition of objectives
Definition of objectives is a very important and often underestimated element in the decision process which leads to the use of a model. The first question to be posed is whether a model can add important information to what is already understood about a system. It also involves the estimation of the possibility to save project costs by using a model and the economic value that may be attached to the development and use of the model. This process will also lead to the choice of the level of complexity of model description. The use of models is generally associated to their use for simulations. However, another interesting field of application is in the analysis of possible hypothesis about empirical relations. Finally, models define relations between the various variables describing a state of a physical system and consequently models may be used for data consistency checking. As typical examples of model objectives in the fields of environmental, hydraulic and hydrological engineering one may mention:
· effects of hydraulic works;
· simulation of the impacts of floods; · on-line flood forecasting;
· flood prediction;
· design of urban drainage systems; · simulation of the impacts of dam breaks; · study of field irrigation water supply; · control of salt intrusion in estuaries; · BOD-DO computations along rivers;
· soil remediation studies;
· effects of sewerage overflows upon the receiving waters; · consistency checking of water quality data;
· consistency checking of hydrological data. Model schematization
The schematisation of the physical system follows from the complexity of the processes and the economical interest in studying these processes in all their details. The use of simplified models, based on a simplified description of the physical processes is only justified if the results of the model can still be used reliably in the design process. In other words, if the results still fall within the reliability range of data used by the designer. All processes in nature are of a three-dimensional and unsteady nature. The choice in the model schematisation is primarily:
· choice of the number of spatial dimensions; · choice of time variability.
From the spatial dimensions and the time, the modeller selects one or more independent variables x,y,z or t, or other independent variables if certain transformations are applied, e.g. r and in a polar coordinate system. Such a choice is strongly linked to the model objectives. For example, a reservoir can be schematized into a single point, if one wants to study the water level variations and the reservoir outflow as a function of time. The same reservoir, however, will require a three-dimensional schematization in space in a study of wind-induced circulations or velocity patterns following from density stratification.
Equations and boundary conditions
A mathematical model is based primarily on the choice of equations describing the state of the physical system. Water levels, discharges, velocities, temperatures, salinities etc. are so-called state variables or dependent variables. One equation is needed for each of these variables describing the state of the physical system. Most of these equations are balance equations of mass, or, simplified, of volumes. Other equations are based on balances of other physical quantities, such as momentum, energy or turbulence. Often, also, simplified forms of these equations are used for the description of processes within our computational domain in space and time. In space this domain might represent the axis of a river flowing from town A to town B further downstream and in time the duration of a typical flood wave, including an antecedent period. Additional conditions have to be provided at the model boundaries, to specify the interaction of the outside world with the domain described by our model. These conditions will follow from the nature of the physical processes, translated into mathematical conditions through the equations describing the system.
Solution algorithms
The balance equations in space and time provide us, generally, with partial differential equations. These equations are transformed from a continuous form into a discrete form by writing them out as relations between variables at points in the computational domain. Such formulations are based on finite differences, finite elements or boundary integrals and provide systems of linear equations. Completed with a linearized formulation of boundary conditions and special elements, such as hydraulic structures, the total system of linear equations may be solved with a variety of algorithms, ranging from simple Gaussian elimination as a direct matrix solver, to iterative techniques such as the conjugate gradient method. The solution algorithm usually has to follow a specific sequence of operations, consistent with the physical links in the system.
Software
For most environmental studies standard software tools are available. For simple problems engineers usually turn to spread sheet packages, whereas for problems related to open channel flow in networks, reservoirs, flow in pipe networks, sewer systems, water hammer, coastal management, short waves computations etc. various software products are available, developed at specialized hydraulic research institutes. The use of these packages assures a flexible user environment and a reliable solution of all sorts of numerical problems.
Data collection
Over the past years more and more effort has been spent on the collection of all sorts of data and the processing and storage of these data in data bases. However, for model development, data available in data bases is not always sufficient, as the calibration of models often requires data measured over short periods in time, available at various locations simultaneously. For this reason, the models are usually set up with whatever data available in the standard data base, completed with data collected during some specially organised campaigns.
Model calibration and verification
Some data required for a model can be collected directly in the field. Examples are salinities, channel cross-sections, discharges, water levels and concentrations of dissolved substances. Some data can only be collected with a certain degree of uncertainty, such as the details of the topography in the flood plains. Other types of data cannot be measured at all, such as Manning numbers and diffusion coefficients. Such data can only be estimated on the basis of a sound engineering judgement, based on the interpretation of recorded values of other variables and parameters. The more uncertainty we have in the model parameters, the more we are dependent on a good set of calibration data. The fit between measurements and computations and the knowledge of the processes enables the adjustment of the parameters until an acceptable fit has been obtained. For model calibration one will usually select a number of events, which are complementary to each other in terms of the calibration
A calibration of a river model, for example, will typically start with low flow calibration and finish up with the calibration of some typical flood events. This procedure allows for the calibration of channel roughness parameters, prior to the calibration of flood plain conveyance and storage parameters. After completion of a model calibration the model should be verified on a set of data not yet used for parameter estimation. However, in practise it is not easy to reserve such a set and even if such verification runs are made, the differences between model and prototype performance may lead to lengthy arguments about the quality of the model data. In other words, why should one trust the results of verification more than the results of a model calibration?
Simulations
Once the model has been accepted it can be used for the typical simulations following from the definition of the model objectives. It should be kept in mind that the use of the model with modified parameters may, in turn, modify other parameters. As an example, the construction of river embankments may also change the bed roughness. The use of such models, therefore, should always be accompanied with sound engineering judgement based on a thorough knowledge of the physical processes.
2
Introduction to numerical methods
2.1
Introduction
This chapter deals with the solution of problems described on the basis of one single independent variable, such as x or t. A typical example is the simulation of flow through a reservoir, where water level variations in the horizontal plan are neglected and the point water level fluctuates in time as a result of time-variations in inflow and outflow. The water volume balance leads to an ordinary differential equation of the first order which can conveniently be solved by a finite difference approximation.
Another typical example connected to this problem is the description of the variation in time of the concentration of a chemical substance in the reservoir water, assuming that this reservoir is well-mixed. The balance equation for this substance also leads to an ordinary differential equation with time as the independent variable.
In a further extension one may consider the interaction of various substances, leading to coupled systems of first-order ordinary differential equations. A well-known example is given by the Streeter-Phelps equations, describing the decay of organic pollutants and the effects on the oxygen concentration in a well-mixed pond. The same set of equations is found by considering the BOD and DO concentrations in a particle of water moving with the stream velocity in a river and neglecting the influence of exchange by diffusion between various water particles. Although this set of equations may be described as a function of time, it might also be convenient to apply a transformation which takes the channel axis x as the independent variable. Such transformation facilitates the inclusion of typical influences along the river, such as point effluent loads, weirs providing additional reaeration and the effects of variations in the channel topography on stream velocity and reaeration.
Although the simplest problems of this category can be studied by exact solutions of the differential equations, the more flexible formulation of model equations and parameters requires solutions formulated by numerical schemes, such as finite difference schemes or finite element schemes. In the sequel, a range of finite difference approximation are introduced and discussed in terms of accuracy, stability and convergence of solutions.
2.2
Introduction to finite difference approximations
Let us consider one of the simplest ordinary differential equations expressing the volume balance of groundwater in a cylindrical reservoir as shown in Figure (2.1). Assuming a constant reservoir surface area A, a constant porosity n and an outflow defined as a linear function of the hydraulic head h, the water level is described by the continuity equation and Darcy law, respectively, as
dh nA Q dt = - ; Q = -kAh or, by elimination of Q, Article 2. dh h dt = -a (2.1)
where is a linear reservoir coefficient. This equation has the exact solution
0 t
h = h e-a (2.2)
where h0 is the initial water level in the reservoir.
This exact solution is given here primarily with the purpose of comparing various numerical schemes, solved with a variety of numerical parameters for these schemes. The numerical schemes that will be introduced successively are the
· Euler scheme;
· Improved Euler scheme; · Implicit scheme;
· Newton-Raphson scheme.
The numerical parameter in this example is the time step of numerical integration t.
2.3
The Euler scheme
For the definition of a finite difference approximation we will first return to the concept of derivatives and the differential equations that may be constructed from these. The meaning of Equation (2.1) is that at any point along t, the derivative dh/dt to the function h(t) is equal to the value of the right hand side of that equation.
Figure 2.2 Situation sketch for the definition of a derivative (tangent) to a function h(t) Keeping in mind (Figure 2.2) that this derivative is defined as
0 ( ) ( ) im t dh h t t h t L dt D ® t + D -= D (2.3)
one may use the inverse of this definition to construct a finite difference scheme of Equation (2-3) on the basis of the approximation
1 n n n dh h h h h dt t t a + D -@ = @ -D D or
(
)
1 1 n n h + @ - Da t h (2.4)where it should be noted that n is introduced as a counter for the time step and written as a superscript to the variable h or to any other quantity defined at a grid point at time t=n t. This notation should not be confused with an exponent. The numerical scheme introduced this way is called an Euler scheme. The right hand side of Equation (2.6) is taken at time t=n t. Assuming that the value of h is known at that point, we call such a scheme a forward difference scheme as we construct a solution forward in time proceeding from a point where the solution is already known.
Figure 2.3 Sketch of a finite difference approximation as the inverse of the definition of a derivative at a point A at t=n t
Figure (2.3) also shows that for any non-linear solution the finite difference scheme introduces at each time step an error , defined as the difference between the exact solution of the equation and the solution obtained with the scheme. From the figure it may also be concluded that this error usually increases with an increasing time step. It will also be clear that the error depends on the curvature of the function, expressed by the influence of the higher-order derivatives. In other words, for solutions deviating slowly from straight lines one may take larger time steps than for solutions which deviate fast from straight lines, if one wants to obtain the same relative accuracy of the solution.
Let us demonstrate the effect of the choice of time step by solving Equations (2.1) and with the Euler scheme of Equation (2.4) for the following data:
h0 = 10 mm
= 0.1 day-1
Table 2.1 shows results at T=4 days for the exact solution of the equations, compared with numerical solutions obtained with Equation (2.4) for time steps t = 0.5 days, 1.0 day and 2.0 days respectively. Differences between the exact solution and the numerical solution are 1 %, 2 % and 4.5 %, respectively. It is also observed that the errors are larger than those found at T = 2 days, demonstrating the accumulative effect of the errors during the integration of the differential equation along the time axis.
Table 2.1 Influence of the numerical scheme and the time step on the accuracy of results
time Exact Euler Improved Euler Implicit
(days) t=½
(days) (days)t=1 (days)t=2 (days)t=1 (days)t=2 (days)t=1 (days)t=2 0.0 10.00 10.00 10.00 10.00 10.00 10.00 10.00 10.00 0.5 9.50 9.50 1.0 9.05 9.03 9.00 9.05 9.00 9.05 1.5 8.57 8.60 2.0 8.19 8.15 8.10 8.00 8.19 8.20 8.19 8.18 2.5 7.74 7.78 3.0 7.41 7.35 7.29 7.41 7.38 7.41 3.5 6.98 7.04 4.0 6.70 6.63 6.56 6.40 6.71 6.72 6.70 6.69
Figure 2.4 Various derivatives used in the finite difference approximation: (a) derivative used in the Euler scheme; (b) ideal choice of derivative bringing the solution from point A to point B; (c) approximate derivative used in the centred schemes
2.4
The improved Euler scheme
From Figure (2.4) it is observed that one possible way of reducing the errors is by selecting a better location for the derivative along the time axis. A good location would be a place C, approximately halfway the time levels n t and (n+1) t. However, the exact location of the point is not known, due to the influence of the higher-order derivatives on the shape of the solution function. Moreover, even if this exact location would be known, the solution of the function is not known at this point and, hence the value of the derivative. The principle of a better positioning of the derivative leads us to the improved Euler scheme based on an additional iteration of the solution. As a first step in the improved Euler method the value of hn+½,
halfway the time step, is approximated by
(
)
½
1 ½
n n
h + @ - aDt h (2.5)
Substitution of this approximate value in the expression of the derivative gives the finite difference approximation over the total time step from grid point n to (n+1) as
1 ½ n n n h h h t a + + @ -D or 1 ½ n n n h + @ h - Da t h + (2.6)
Results of this scheme, also given in Table (2.1), show considerable improvements in accuracy, with errors of 0.15 % and 0.3 % for time steps of 1.0 and 2.0 days, respectively. Even considering that the amount of computational work done with the improved Euler scheme is approximately twice the amount of work done with the normal Euler scheme, the improvement in terms of efficiency is still remarkable. For an equivalent computational effort the improved Euler scheme produces only 15 % of the error of the normal Euler scheme. Although similar improvements in accuracy are not always obtained for all problems, the example demonstrates the potential of efficiency improvements by using higher-accurate numerical schemes.
2.5
The implicit scheme
The numerical schemes introduced so far are based on the concept that the derivative of the function is known at the initial point in the computation over a time step and does not change during that time step or, at best, is adapted in its value and location during an additional iteration. A next logical step for improvement, then, is to include the variables composing the derivative in the expression for the yet unknown variable h at time level (n + 1) t. For Equation (2.1) this leads to a centred implicit finite difference scheme of the form
(
)
1 1 ½ ½ n n n n h h h h t a a + + - @ - + D or 1 1 ½ 1 ½ n t n h h t a a + = - D + D (2.7)For the given value of and a time step of 1 day this leads to the simple relation 1 0.9048
n n
h + = h .
Results of this computation are shown in Table (2.1). The errors are 0.017% and 0.13% for time steps of 1.0 and 2.0 days, respectively. In terms of accuracy, this approach gives another considerable improvement over the earlier introduced so-called explicit schemes. Although this conclusion may not be generalized to other numerical schemes without exceptions, the implicit schemes, in general, have the potential of providing more accurate results, at lower computations cost, due to the better centring of the finite difference equations. However, for problems involving more unknown variables, the implicit schemes lead to systems of linear equations, which have to be solved simultaneously through matrix operations.
In most cases the overall solution algorithm leads to more numerical operations per time step. However, this is generally compensated by the much larger time steps that can be taken. As a consequence, currently most numerical algorithms are based upon implicit schemes. Apart from the higher accuracy, another important advantage of implicit schemes is their improved stability or robustness behaviour, as discussed in § 2.8.
2.6
The Newton-Raphson scheme
One special form of implicit schemes is the Newton-Raphson scheme. Although the Newton- Raphson approach is generally presented as a method for solving nonlinear equations, we introduce it here as an approach to the formulation of linear finite difference schemes and notably the linearization of individual terms and coefficients in the scheme.
Assume, for example, that the coefficient in Equation (2.1) is given as a linear function of h by the relation
0 1
a a h
a = +
where a0 and a1 are constants. Substitution into Equation (2.1) gives
2
0 1
dh
a h a h F
dt = - - = (2.8)
where F is a general function of h. An implicit finite difference scheme, centred halfway the time step, could be written as
½ n h F F t D = + D D
As F is a function of h, the Newton-Raphson approach gives
(
0 2 1)
dF
F h a a h h
dh
D = D = - + D
leading to the finite difference scheme
(
0 1)
1 ½ 2 n n F t h t a a h D D = + D + (2.9)The advantage of this approach is that the change in the value of the coefficient is already partly taken into account during the integration over the time step. From Equation (2.13) one may conclude that the process is not yet ideal, as the value of h in the right hand side of the expression is taken at grid point n, whereas the substitution of a value at grid point (n+½) would be more precise. Referring, again, to the implicit scheme of § 2.5, the value of would be taken at grid point n, whereas an improved centring would require an additional iteration, similar to the approach followed in the improved Euler method. The Newton- Raphson implicit scheme is generally used without such additional iteration as in most cases this extra step is hardly cost effective.
2.7
A more formal analysis of accuracy
Although the concept of accuracy was discussed on the basis of a common sense approach and such a reasoning should always accompany the use of numerical and physical concepts, it is also useful to introduce more fundamental analysis techniques. One of the most frequently used tools for the analysis of the accuracy of numerical schemes is the Taylor's series expansion.
Referring to Equation (2.2) and assuming a continuous behaviour of the function h and all its first and higher-order derivatives in time, the value of h at grid point n+1 can be expanded from its value at grid point n through the infinite Taylor's series
1 1 ! n k k n n k k t d h h h k dt ¥ + = æ ö D = + ç ÷ è ø
å
(2.10)with all derivatives taken at grid point n. In Equation (2.10) k! should be read as “k factorial”, defined as the product 1*2*3*… .*k.
It will be useful to discuss the meaning of the term under the summation sign in a pragmatic way. The term tk refers to a step in time raised to the power k and cancels, at least in magnitude, against the contribution dtk. The notation dkh has the meaning of expressing differences in function values at points in the vicinity of the point where the Taylor's series is expanded upon and has a value comparable in order of magnitude to the average function value at these points. As the value of k! increases rapidly with increasing k, it may be expected then that the contribution of the higher-order derivative terms in this expanded series decreases rapidly with increasing k.
Referring to Equation (2.10), one may divide all terms by t to give
1 2 2 3 2 3 . . . 2 6 n n n n n h h dh t d h t d h h o t t dt dt dt + - æ ö D æ ö D æ ö = ç ÷ + ç ÷ + ç ÷ + D è ø è ø è ø (2.11)
where h.o.t. refers to all higher-order terms in this series expansion. Substitution of the Euler scheme of Equation (2.4) into Equation (2.11) and dropping the superscript
n provides 2 2 3 2 3 . . . 2 6 dh t d h t d h h h o t dt dt dt TE a D D = - - - + -14444244443 (2.12)
Comparison of Equation (2.12)with Equation (2.1) leads to a difference TE between the differential equation and the Euler scheme defined with the intention to solve this equation.
This difference TE is called the truncation error of the finite difference scheme. For the improved Euler scheme, Figure (2.3) visualizes this truncation error by the magnitude . For the special case of Equation (2.1), the magnitude of all higher-order derivatives can be expressed in terms of the value of h at those points, as shown for constant by successive differentiation of the equation with respect to t.
At all points in time this gives the truncation error in the form 2 3 2 . . . 2 6 h h TE = a D -t a D +t h o t (2.13)
From Equation (2.13) it is readily seen that by decreasing t in the integration of Equation (2.1), the total error in h decreases linearly with t with respect to the first term in the right hand side of Equation (2.13) and decreases even faster than linearly with respect to the remaining terms in the truncation error. A truncation error of this type is said to be of first order in t or simply O( t), while the numerical scheme is said to be first order accurate.
As the numerical integration proceeds in time, the errors of each individual time step are accumulated. It should be remarked here that the accumulative error for any t is subject to a decay by virtue of the meaning of Equation (2.1) and for any realistic time step t the accumulated error will tend to zero for t à . Another interesting observation regarding the truncation error in the numerical integration of Equation (2.1) is the nearly-linear decrease of the error when reducing the time step t from 2.0 days to 0.5 days, as shown in Table 2. 1. This behaviour points at a rapidly decreasing influence of the higher-order derivatives in the truncation error, for this application.
The much smaller truncation error in the implicit scheme of Equation (2.7) can also conveniently be demonstrated by a Taylor's series expansion. This derivation follows a more common introduction of Taylor's series in numerical schemes. After the selection of the appropriate centre point of the scheme all values of the dependent variables introduced at neighbouring grid points are expanded from that centre point. For the implicit scheme, centred at point n+½, the Taylor's series expansion gives
(
)
(
)
(
)
(
)
(
)
(
)
(
)
2 2 3 3 2 3 2 2 3 3 2 3 ½ ½ 1 ½ ½ . . . 2 6 -½ -½ 1 ½ ½ . . . 2 6 t t dh d h d h t h t h o t dt dt dt t t dh d h d h t h t h o t dt dt dt a a æ D D ö + D çç + D + + + ÷÷ = è ø æ D D ö - D çç + - D + + + ÷÷ è øwhere all values of h and the derivatives with respect to time are taken at grid point n+½. Expanding these expressions further leads to the equation
2 3 2 2 2 3 1 . . . 8 24 TE dh d h d h h t t h o t dt dt dt a a -= - - D - D + 144444424444443 (2.14)
Considering, again, that for this application all third- and higher-order derivatives are small, the remaining part of the truncation error is indeed much smaller than that of Equation (2.12) for any realistic choice of t. A realistic time step in this context is a choice which relates t to the value of as discussed in § 2.10.
Figure 2.5 Oscillations and instabilities generated for large time steps: (a) exact solution; (b) stable oscillatory solution for t=18 days; (c) unstable solution for t=22 days
2.8
Stability
Despite the truncation error in the computation presented in Table (2.1) most results are quite acceptable for practical purposes. However, it is interesting to observe what kind of results would have been produced if the time step had been taken much larger. As an example, let us consider a time step of 25 days in an application of the Euler scheme for the same equation and data as used in Table (2.1). For successive time steps the sequence of results would be 10, -15, 22.5, -33.75, 50.63, -75.94 etc., leading to infinity or an exponent overflow message on a digital computer after a sufficiently large number of time steps. In any hand computation the sequence of operations would have been interrupted after one or a few time steps as the results would appear to be unrealistic for any practical interpretation. A computation of this kind is called an instability. In an unstable computation results will always exceed a limit which has been set by the engineer as a realistic maximum or minimum value, for which exceedance is not to be expected (Figure 2.5). A frequently used analysis for the definition of stability criteria is based on the notion of amplification factors between results at successive time steps. If the absolute value of the amplification exceeds unity at each and every step in time, one has sufficient proof of the unstable nature of the computation. The application of this analysis to the Euler scheme of Equation (2.4) gives 1 | | 1 1 n n h A t h a + = = - D £ (2.15)
as a stability condition for the scheme. Since t is definite positive the stability condition for the Euler scheme is derived as t 2.
Applying the same reasoning to the implicit scheme of Equation (2.7) leads to 1 ½ 1 1 ½ t t a a - D £ + D (2.16)
and to the conclusion that the implicit scheme is unconditionally stable. However, the stability limit of t=20 days obtained for this application of the Euler scheme is far beyond any time step that would be set as a maximum from the accuracy point of view. Even for the implicit scheme the results obtained with this time step are very inaccurate, as h drops to zero over the first time step and remains zero over all successive time steps, whereas in the exact solution the value of h decreases exponentially from the given initial value and only approaches the value of zero for tà .
It may be included that the unconditional stability of the implicit scheme does not have special advantages in this application to the solution of ordinary differential equations. When moving to applications on partial differential equations, however, the increased stability of the implicit schemes will turn out to be of such great importance that currently, nearly all finite difference schemes are based upon implicit formulations.
2.9
Consistency and convergence
The Taylor's series expansion of the numerical scheme visualizes the difference between the differential equation as a continuous description of the physical system and the finite difference equation as a discrete description on a set of grid points. As t decreases, the difference between both equations reduces to the extent that they become equivalent as tà0. In such case the difference equation is said to be consistent With the differential equation. In the case of ordinary differential equations this generally implies that the results also converge towards the exact solution as tà0. An additional condition for such convergence is that the results are computed under stable conditions.
2.10
The choice of a time step
The choice of a time step in the numerical integration of the differential equation is a balance between the maximum tolerable error and the economy of the numerical operations. In any model application, errors are introduced from the following sources :
· accuracy of basic data;
· choice of additional parameter values; · model schematization;
· choice of simulation data; · numerical errors.
Of all these sources of errors the numerical error is easiest controlled and a general requirement in model simulations is that the numerical error does not add to the uncertainties in the results introduced by the other sources. To satisfy this condition, the numerical error should be of an order of magnitude smaller than the overall expected error. So, if the overall error is expected to be some centimetres in level, the admissible numerical error should not exceed a few millimetres. Whereas it is already difficult to estimate the magnitude of the overall error, it is even more difficult to estimate the numerical error generated during one single time step and even more so the accumulated effect over various steps.
As the truncation error contains higher-order derivatives, a first estimate of the time step is based on an idea about the curvature of the solution function. Strongly curved solution functions require smaller computational steps than solutions with more gentle variations.
Figure 2.6 Process of diminishing errors by reducing the time step t
A better estimate of the time step is based on a sensitivity analysis. By taking successively smaller grid steps, solutions are compared and if the differences appear to be sufficiently small, similar computations can be made with that acceptable grid step. It should be noted that the difference obtained by successively halving the time step is less than half the total numerical error ,as shown in Figure (2.6), where this total numerical error at a given point in time is plotted as a function of the number of computational time steps N over a given period of integration. This leads to the conclusion that it is more efficient to refine coarse grids than refining further already fine grids.
In a pragmatic approach one might also limit the allowable change in the function derivative over a single time step. For the simple Equation (2.4), this condition is equivalent to setting a maximum to the change in the value of h from one time step to the other. Setting, for example, as a criterion that over a single time step a change of 5% is allowed, this criterion leads to t 0.05, or t 0.5 days.
Even in this simple case, however, it remains difficult to estimate the accumulated effect of this error over various time steps. In an attempt to do so and keeping in mind the decaying nature of the error, the accumulated error E at time step n=N, is approximated as
(
)
2 ½ 1 N N n n E =å
Dta h - Da t - (2.17)where in this notation N-n represents an exponent. In principle, it is possible to follow the magnitude of E during the computational process, assuming that the effect of third- and higher-order derivative contributions to the truncation error are negligible. Such an approach, however, is not practical for more complex problems and it is better to turn to sensitivity analysis for determining an acceptable time step.
2.11
Reservoir routing
Consider a reservoir with a level-dependent storage area A, an inflow Qi given as a hydrograph and a level-dependent spillway outflow Q0, as shown in Figure (2.7).
Figure 2.7 Sketch of a reservoir with spillway flow
Reservoir volume balance and spillway flow are given by the following set of equations
( )
i o dh A Q t Q dt = - (2.18)(
)
1.5 0 1.71 cr Q = m L h h- (2.19) whereA - level dependent surface area of the reservoir;
h - reservoir water level above a general reference (e.g. mean sea level MSL);
hcr - level of the spillway crest;
L - length of the crest; m - discharge coefficient.
In principle, Equation (2.19) may be substituted into Equation (2.18) to give one single equation with h as the only dependent variable. However, in general it is preferred to do such substitutions at the level of the numerical formulation after linearization of the equation and/or the finite difference formulation.
In a simple Euler approach the equation reads as follows:
(
)
1.50 1.71
n n
cr
( )
{
}
1 n n n n i o n t h h Q t Q A + = + D - (2.21)where n, again, has the meaning of a superscript indicating the grid point along the time axis. To demonstrate the computational algorithm, a small example is worked out with the following data:
hinitial= 24.70 m t (hours) Q(mi(t)3/s) h(m) A(h)m2 hcr= 24.00 m 0 50 24 0.4*106 L = 30 m 1 150 25 0.8*106 t = 1 hour 2 360 26 1.0*106 m = 1.1 3 340 27 1.1*106
The results of the computation are given in Table (2.2).
Table 2.2 Results of the reservoir routing simulation with the Euler method time (hrs) gridpoint h n (m) Qo n (m3/s) Qi n (m3/s) A n (m2) (m)h 0.0 0 24.700 33.05 50 6.80*105 0.090 1.0 1 24.790 39.62 150 7.16*105 0.555 2.0 2 25.345 88.02 360 8.69*105 1.127 3.0 3 26.472 219.32 340
With reference to Figure (2.8) it is readily seen that the time step of 1 hour is too large, as the error introduced by using a reservoir surface area at time n t is significant. Moreover, the use of the discharge at time n t contributes to the error in the time derivative, although it does not affect the volume balance in a direct way.
Figure 2.8 Volume error at successive time steps in reservoir routine using the Euler scheme A much improved formulation is based on the Newton-Raphson approach. Apart from the better centring of the derivative of Equation (2.23) the variation in the surface area is included implicitly. Although this variation is only introduced as a linear function, it is a great improvement over including A as a constant over a computational step, defined at time level n t.
For the Newton-Raphson formulation the equations are rewritten in the form
( )
(
)
(
)
1 , , = i - o = i o dh Q t Q F h Q Q dt A (2.22)and discretized, jointly with Equation (2.20), as ½ n h F F t D = + D D (2.23)
( )
n n n o o o o dQ Q Q Q h h dh æ ö + D = +ç ÷ D è ø (2.24) where(
)
( )
2(
( )
)
1 1 i o i o n n n i o i o n n F F F F Q Q h Q Q h dA Q Q Q t Q h A A dh ¶ ¶ ¶ D = D + D + D ¶ ¶ ¶ æ ö = D - D - - ç ÷ D è ø (2.25) and(
)
0.5 1.5*1.71* o cr dQ m L h h dh = - (2.26)Special attention is drawn to the use of Q0(hn) in Equation (2.24) instead of
substituting the already known value Q0n. As shown in Figure (2-9) the value Q0n
was obtained from a linearized Q-h relation at time level (n-1) t (line a at point A). The solution should proceed from point B along the line b during the next time step. If in the right hand side of Equation (2.24) Qon had been used instead of Qo(hn), the
solution would proceed from point C along the dotted line c and the accumulation of errors over various time steps would bring us further and further away from the correct Q-h relation. Note that for consistency reasons this correction is not included in the volume balance equation.
The coefficients in the two linear equations can be collected to the form 11 12 1 21 22 2 o o a h a Q b a h a Q b D + D = D + D = (2.27) or A x- = b- (2.28)
with matrix A and vectors x- and b- given as
11 12 1 0 21 22 2 ; h ; a a b A x b Q a a b - é D ù -é ù é ù = ê ú = ê ú = ê ú D ë û ë û ë û (2.29) where
( )
(
)
( )
(
)
( )
11 12 0 21 22 1 2 2 1 1 1 2 ½ n n n n i o n n n n i i o n n o o A dA a Q t Q t A dh a dQ a dh a b Q t Q Q b Q Q h æ ö = + - ç ÷ D è ø = æ ö = ç ÷ è ø = -= + D -= -(2.30) Elimination of Q leads to 1 2 11 21 b b h a a + D = + (2.31) 1 11 Q b a h D = - D (2.32)The computation over the same time steps as taken for the demonstration of the Euler method gives results as shown in Table (2.3). The results, indeed, are more realistic than those of Table 2.2. However, the differences between Q0n and Q0(hn)
Table 2.3 Results of the reservoir routing simulation with the implicit Newton-Raphson method time (hrs) grid point h n (m) Q 0n (m3/s) Q0(hn) (m3/s) Qi(t) (m3/s) A n*105 (m2) dA/dh*105(m) dQ(m20/s)/dh 0.0 0 24.700 33.05 33.05 50 6.80 4.00 70.82 1.0 1 24.992 53.73 55.75 150 7.97 4.00 84.31 2.0 2 25.688 114.45 123.78 360 9.38 2.00 109.98 3.0 3 26.379 199.71 207.02 340 time (hrs) grid point a11 a21 b1 b2 h (m) Q0(m3/s) 0.0 0 388 70.8 133.9 0.00 0.292 20.68 1.0 1 491 84.3 402.5 -2.03 0.696 60.72 2.0 2 573 110.0 481.1 -9.33 0.690 85.27 3.0 3
2.12
Routing of a decayable pollutant through a reservoir
Let us consider next a similar reservoir which is polluted by a decayable substance with concentration c. Assuming that the reservoir volume can be schematized as well mixed and introducing a first order decay, with reaction coefficient k, gives
( )
i i o d cV c Q c Q k cV dt = - - (2.33) or( )
i i o dc dh V c cA c Q c Q k cV dt + dt = - - (2.34)Substitution of Equation (2.18) into Equation (2.34) and division of all terms by the reservoir volume V leads to
(
)
i i Q dc c c kc dt = V - - (2.35)where the volume V, as a function of the reservoir level, follows from the integration of the surface area A along h. Such integration is best based upon a simple trapezium rule as the surface area, obtained from planimetering a topography from a map, is never accurate enough to justify higher-accuracy integrations of the A-h relation, such as the Simpson's rule or even integrations based on cubic spline functions. Moreover, linear A-h relations are used in the Newton-Raphson method and the use of the trapezium rule for the integration of the V-h relation is consistent with this approach. Although in a quick analysis the dilution coefficient
i
Q D
V
= (2.36)
is often set as a constant, giving for Equation (2.35) the exact solution
(
)
( ) ( ) 0 k D t i k D t 1 D c c e c e k D - + - + = - -+ (2.37)We will focus here on the general case where D is a function of time and the exact solution of Equation (2.35) does not exist. The simplest numerical solution of Equation (2.35) is, again, based on the Euler method, giving
(
)
1 n n n i n i Q c c t c c kc t V + = + D æ ö - - D ç ÷ è ø (2.38)Numerical solutions have the advantage over analytical solutions that all parameters can easily be made a function of the dependent variables c and h and of the independent variable t.
Examples of such further generalization of relations both in the water quantity and quality part are:
· outflow partly given as a user demand, possibly affected by reservoir operation levels;
· inclusion of the effects of precipitation to and evapotranspiration from the reservoir surface in a longer term water balance simulation;
· stage dependent width of the spillway crest;
· controlled spillway crest level as a function of h or t; · the use of m, calibrated as a function of the reservoir level; · various sources of pollutant inflows into the reservoir;
· decay described as a function of the time-varying water temperature;
· inclusion of additional substances, such as dissolved oxygen with dependence on wind-generated reaeration, photosynthesis, bottom sediment processes etc. Again, in this example more accurate results are obtained for a given time step with the improved Euler method and implicit methods, including the Newton-Raphson formulation. As the water balance is not affected by the pollutant concentration, any implicit technique leads to a system of linear equations with the unknown concentration at the new time level decoupled from the unknown level and out flowing discharge. It is also rather common to simulate the water quantity part first, write results to a data base and subsequently retrieve the necessary information in a separate water quantity computation. We will return to this approach when discussing water quality studies in rivers, coastal areas and in reservoirs where the assumption of a well mixed estuary is not correct.
2.13
Non-uniform steady flow in channels
As an example of computations which describe steady processes with variations in the spatial x-direction let us consider the backwater computation in a uniform channel. A typical channel cross-section is shown in Figure (2.10), including the conveyance K plotted as a function of the water level, where
2 / 3 1 1 jj j j j j K A R n = =
å
(2.39)with
nj = Manning roughness coefficient for the sub section j;
Aj = sub area of the cross-section j;
Rj = local hydraulic radius of the sub area j;
jj = number of vertical slices used in the integration across the section.
Figure 2.10 Cross-section and cross-sectional parameters used in the non-uniform flow computation Assuming the absence of lateral flow, the steady state De Saint Venant equations reduce to the form
tan cons t Q = Q (2.40) 2 2 0 2 1 0 d Q dh Q I gA dx A dx K æ ö + + + = ç ÷ è ø (2.41)
Further differentiation of the first term of Equation (2.41) gives, for constant Q,
2 2 0 3 2 1 Q dA dh I Q 0 gA dh dx K æ ö - + + = ç ÷ è ø (2.42) or 2 0 2 2 1 1 dh Q I dx Fr K æ ö = ç + ÷ - è ø (2.43)
with the dimensionless Froude number Fr defined as a function of the flow velocity
u, the cross-sectional area A and the storage width b, as
2 2 2 3 s u Q dA Fr A gA dh g b = = (2.44)
For a given discharge, the right hand side of Equation (2.43) is a function of the water level above the channel bottom, giving
( )
dhF h