Post on 14-Mar-2018
transcript
Application of the Gradient Method for theAnalysis of Unsteady Flow in Water Networks
Item Type Thesis-Reproduction (electronic); text
Authors Ahmed, Iftekhar, 1973-
Publisher The University of Arizona.
Rights Copyright © is held by the author. Digital access to this materialis made possible by the University Libraries, University of Arizona.Further transmission, reproduction or presentation (such aspublic display or performance) of protected items is prohibitedexcept with permission of the author.
Download date 16/05/2018 23:35:07
Link to Item http://hdl.handle.net/10150/192098
APPLICATION OF THE GRADIENT METHOD FOR THE ANALYSIS
OF UNSTEADY FLOW IN WATER NETWORKS
by
Iftekhar Ahmed
A Thesis Submitted to the Faculty of the
DEPARTMENT OF CIVIL ENGINEERING
In Partial Fulfillment of the RequirementsFor the Degree of
MASTER OF SCIENCE
In the Graduate College
THE UNIVERSITY OF ARIZONA
1997
STATEMENT BY AUTHOR
This thesis has been submitted in partial fulfillment of requirements for anadvanced degree at The University of Arizona and is deposited in the University Libraryto be made available to borrowers under rules of the Library.
Brief quotations from this thesis are allowable without special permission,provided that accurate acknowledgment of source is made. Requests for permission forextended quotation from or reproduction of this manuscript in whole or in part may begranted by the head of the major department or the Dean of the Graduate College when inhis or her judgment the proposed use of the material is in the interests of scholarship. Inall other instances, however, permission must be obtained from the author.
SIGNED:
2
APPROVAL BY THESIS DIRECTOR
This thesis has been approved on the date shown below:
DateL?
Kevin E. L, eyProfessor of Civil ngineering
3
ACKNOWLEDGMENTS
The author would like to express his appreciation to his major advisor, Professor
Kevin E. Lansey for his support, guidance and patience during the length of this work.
Acknowledgments are also due to Dr. Dinshaw N. Contractor and Dr. Avi Ostfeld for
serving as members of the author's committee and for their valuable advice and moral
support.
Dr. Vincent F. Bralts and Dr. Rabi H. Mohtar of the Department of Agricultural
and Biological Engineering at Purdue University, and Dr. Don J. Wood of the
Department of Civil Engineering at the University of Kentucky were instrumental in
providing information on water distribution network modeling.
Special thanks are also extended to Farhana Ahmed for sharing valuable ideas on
computer modeling, and to Alicia L. Urban for editing a significant portion of this thesis.
The author would like to recognize his parents, Nazim U. Ahmed and Mumtaj
Nazim, who encouraged him to follow an engineering career and instilled in him the
work ethic and integrity essential for undertaking and completing the tasks required of
this work.
4
DEDICATION
The author would like to dedicate this work to his grandparents who, through their
stalwart struggle in the face of insurmountable odds taught him the meaning of
perseverance and fortitude.
5
TABLE OF CONTENTS
LIST OF ILLUSTRATIONS 7
LIST OF TABLES. 9
ABSTRACT 10
1. INTRODUCTION 11
2. LITERATURE REVIEW 14
3. BASIC EQUATIONS AND SOLUTION TECHNIQUESFOR STEADY-STATE FLOW CONDITIONS 18
3.1 Introduction 183.2 Basic Equations for Steady-State Flow Conditions in Pipe Networks. 19
3.2.1 The Flow (Q) Equations 213.2.2 The Node (h) Equations 263.2.3 The Loop (AQ) Equations 293.2.4 Comparison of the Solution Techniques 313.2.5 Gradient Method 323.2.6 Comparison of the Gradient Method with Traditional Methods 383.2.7 Governing Equations in Dynamic Pipe Network Analysis 41
3.3 Conclusions 51
4. GRADIENT ALGORITHM FOR UNSTEADY FLOW CONDITIONS 52
4.1 Introduction 524.2 Basic Equations 534.3 Solution Algorithm 584.4 Conclusions 62
5. BOUNDARY CONDITIONS AND INTERNAL COMPONENTS 64
5.1 Introduction 645.2 Boundary Conditions 64
5.2.1 Constant Nodal Demand 645.2.2 Variable Nodal Demand 655.2.3 Constant-level Reservoir (FGN) 655.2.4 Variable-level Tank 66
5.3 Internal Components 66
5.3.1 Minor Losses 66
6
TABLE OF CONTENTS --- Continued
5.3.2 Check Valves 685.3.3 Pumps 68
5.4 Conclusions 71
6. DEVELOPMENT OF THE NETWORK MODEL 73
6.1 Introduction 736.2 Network Representation 746.3 Model Formulation 776.4 Stopping Criteria 78
7. MODEL VERIFICATION AND SENSITIVITY 81
7.1 Introduction 817.2 Model Verification 817.3 Model Sensitivity 1157.4 Conclusions 121
8. CONCLUSIONS 122
APPENDIX A: LIST OF SYMBOLS 124
APPENDIX B: LIST OF VARIABLES IN SOURCE CODE 126
APPENDIX C: SOURCE CODE 133
APPENDIX D: EXAMPLE INPUT DATA 165
APPENDIX E: NETWORK SPECIFICATION 173
APPENDIX F: TABLES 175
REFERENCES 185
LIST OF ILLUSTRATIONS
7
Figure 3.1
Figure 3.2
Figure 4.1
Figure 5.1
Figure 5.2
Figure 6.1
Figure 6.2
Figure 7.1
Figure 7.2
Figure 7.3
Figure 7.4
Figure 7.5
Figure 7.6
Figure 7.7
Figure 7.8
Figure 7.9
Figure 7.10
Figure 7.11
Figure 7.12
Figure 7.13
Figure 7.14a
Figure 7.14b
Figure 7.15
Figure 7.16
Figure 7.17
Figure 7.18
Network Analyzed by Todini for Examples A, B, C and D 40
Free Body Diagram with Notation for Dynamic Equations 43
Typical Setup of Water Distribution Network 55
Variable Level Tank Setup 67
Pump Operation Characteristic Curve 69
Flowchart (Steady-State) 79
Flowchart (Unsteady-State) 80
Network A (taken from Holloway, 1985) 83
Network B 84
Demand Factor for Networks A and B 85
Comparison of Calculated Heads for Network A 86
Comparison of Calculated Flows for Network A 87
Head Profile for Varied Time Step in Network A 88
Flow Profile for Varied Time Step in Network A 89
Calculated Head (node 2) for Network B 91
Calculated Head (node 7) for Network B 92
Calculated Flows for Network B 93
Network C (taken from Onizuka, 1986) 95
Head Profile for Network C 96
Flow Profile for Network C 97
Network D 99
Applied Demand Function 99
Head Profile (node 2) for Network D 100
Head Profile (node 5) for Network D 101
Flow Profile (pipe 2) for Network D 102
Flow Profile (pipe 7) for Network D 103
LIST OF ILLUSTRATIONS --- Continued
8
Figure 7.19a
Figure 7.19b
Figure 7.20
Figure 7.21
Figure 7.22
Figure 7.23
Figure 7.24
Figure 7.25
Figure 7.26
Figure 7.27
Figure 7.28
Figure 7.29
Figure 7.30
Figure 7.31
Figure D- 1 a
Figure D- lb
Network E 105
Applied Demand Function 105
WSEL Profile (D-10m) for Network E 106
Head Profile (node 4) at D=10m for Network E 107
Flow Profile (pipe 5) at D=1 0m for Network E 108
WSEL Profile (D=12m) for Network E 109
Head Profile (node 4) at D-12m for Network E 110
Flow Profile (pipe 5) at D=12m for Network E 111
Flow Profile (pipe 1) for Network D with Pump in Pipe 1 113
Pump Head Profile for Network D with Pump in Pipe 1 114
Sensitivity Analysis (± %D) for Network A 117
Sensitivity Analysis (± %L) for Network A 118
Sensitivity Analysis (± %f) for Network A 119
Sensitivity Analysis (± %q ) for Network A 120
Setup for Example Input Data 172
Example Demand Function 172
9
LIST OF TABLES
Table 3.1 Comparison of the Gradient Method with Traditional Methods. 39
Table E-1 Specification for Networks C, D and E 174
Table F-1 Hourly Variation of Flow (cfs) and Head (ft) for Network A 176
Table F-2 Hourly Variation of Flow (cfs) and Head (ft) for Network A 177
Table F-3 Hourly Variation of Flow (cfs) and Head (ft) for Network B 178
Table F-4 Variation of Flow and Head for Network C 179
Table F-5 Hourly Variation of Head (m) at Node 2 of Network D 180
Table F-6 Hourly Variation of Head (m) at Node 5 of Network D 181
Table F-7 Hourly Variation of Flow (cms) in Pipe 2 of Network D 182
Table F-8 Hourly Variation of Flow (cms) in Pipe 7 of Network D 183
Table F-9 Sensitivity Analysis on Network A 184
10
ABSTRACT
Gradually varied unsteady flow in water distribution networks is studied using the
Gradient Method and the Newton-Raphson Solution Technique. The Gradient Algorithm
has shown robust behavior when run with examples simulating different operational
situations. In the attempt to obtain solutions rapidly, a computer program has been
developed in FORTRAN 77. The computer program developed herein is general, easy to
use, and allows a dynamic analysis of complex looped and open water distribution
networks. Piezometric heads at nodes and flow rates in pipes are computed for water
distribution networks. Results obtained from the Gradient Method are compared with an
existing dynamic model. The benefits of using the Gradient Algorithm appear to be
flexibility in coding, versatility in operational conditions, and its application to
complicated water distribution networks.
1 1
CHAPTER 1
INTRODUCTION
Water is vital to man's existence. Apart from the day to day potable
requirements, water is needed for irrigation, power generation, recreation, industrial
production, and receiving wastewater. According to the United Nations Population
Reference Bureau, by the end of the century the world population may reach 6 billion.
Therefore, the total water requirement will continue to increase. In addition, per capita
water consumption is also on the rise. In 1965, the per capita consumption in the USA
for domestic, public, and commercial purposes was 460 liters per day (lpd), and the
industrial requirement was 137 lpd; by 1985 it increased to approximately 465 and 152
lpd respectively. It is now predicted that usage will increase to 474 lpcpd and 163 lpcpd,
respectively, or an overall increase of 0.3 percent per year by the year 2000.
As demands increase, building of state-of-the-art water distribution systems and
rehabilitation of the existing ones to satisfy the demand are major concerns for the water
industry. The two primary objectives in design and operation of water distribution
systems are to (1) minimize the cost of supplying water and (2) maximize the reliability
of water supply. However, these two objectives are in conflict because increased
reliability leads to increased cost.
The problem of design and operation of water distribution networks is multi-
objective in nature. One of the major issues facing engineers and governments involved
12
in the design, operation, and maintenance of water distribution system is to reconcile cost
and reliability. Significant capital investments are required to improve the current level
of service with emphasis on correct establishment of priorities and development of
adequate engineering decision support tools. One such tool for engineers is a well
documented computer model that is reliable.
A hydraulic model will provide information on local water consumption,
geographical distribution of design flows, and pressure gradients for the system. The
simplest hydraulic model considers a steady-state analysis where the flow parameters are
time invariant. The more realistic representation is to incorporate the time variant or
unsteady nature of the network demands. Flow conditions within a water supply system
vary throughout the year and each day, but these changes generally occur slowly. Typical
conditions within a system range from the small winter demands to the large summer
discharges. Flow conditions vary not only seasonally but also hourly within a typical
day. For instance, demand is low at night when most people have gone to rest and
factories sit idle. Demand is high during the day with several peak flow rates that occur
in the morning and the evening, when people take showers, wash dishes, and do laundry.
Other network parameters that change over time are the water levels in system storage
tanks, the cycle of pumps, and the effect of pressure reducing valves. To model this
variation, extended period simulation (EPS) is commonly applied to a network hydraulic
model. Extended period simulation is performed assuming steady flow conditions and
adjusting tank water levels over the simulation period at discrete time intervals.
13
Steady-state analysis, even with the "extended simulation" option, may not truly
represent the flow and pressure variations within a system. In addition, water quality
changes may be sensitive to the time variant flow conditions. Some work has been done
on dynamic network modeling where the flow parameters are time variant. The water
hammer distribution analysis program by Streeter (1967) is a good example of such a
model. Unfortunately, the program has very limited "real world" use. Simple network
modifications require extensive input data changes, and the program is limited in the size
network that can be analyzed. Such models are designed for rapid changes and small
time step in order to effectively study the water hammer phenomenon. Rapid changes
may occur in a network due to unavoidable circumstances. As the shock wave travels
through the network, it rapidly decreases in severity as it passes through each node in the
system. Since change in pressure is proportional to change in velocity, the pressure
changes become smaller as the wave passes through each node. Thus, rapid changes are
local problems, and they do not normally necessitate the use of water hammer analysis
over the entire network. This practice is simply not cost effective.
A gap exists in modeling unsteady flow conditions, between very slow changes
to the rapid changes resulting in water hammer. In this study, an efficient hydraulic water
distribution model is developed using the Gradient Algorithm to model gradually varied
unsteady flow in every link (pipe, pump, valve etc.) and the piezometric heads throughout
a system.
14
CHAPTER 2
LITERATURE REVIEW
A large number of papers have been published on numerical methods for
determining the solution of unsteady flow problems in water distribution networks. But,
among these publications only a handful investigate the problem of gradually varied
unsteady flow in hydraulic networks. Due to the fact that rapid pressure changes are
actually local problems in water distribution networks, a literature review on gradually
varied unsteady flow analyses is of utmost importance.
Sevuk (1979) attempted to simulate gradually varied unsteady flows by a single
mathematical model. His formulation of such model is based on the fact that at any
particular time t, the mathematical model of flow consists of:
(i) two link equations expressing the principles of conservation of mass and energy
for each element (e.g., pipes)
(ii) a node equation expressing the principle of conservation of mass at the junction
of elements
(iii) an external boundary condition expressing either the inflow to the system, or the
piezometric head at each node.
The primary variables in Sevuk's mathematical model are:
15
(i) inflow to and outflow from each link, i e, link flow
(ii) inflow to or outflow from each node, i.e., node flows
(iii) piezometric head at each node.
An Implicit Finite Difference Scheme was used to solve the following one-dimensional
mass and momentum conservation equations:
aQ/0x + (gA/a2) ah/at = 0 (2.1)
aQ/at + (gA) ah/ax + f Q1Q1/(2DA) = 0 (2.2)
where
g = gravitational acceleration
D = diameter of pipe
f = friction factor (Darcy-Weisbach)
a = (K/01/2 / (1 + KD/Ee)/2
where
K = bulk modulus of the fluid
E = modulus of elasticity of pipe walls
p = fluid density
e = wall thickness of the pipe
16
Holloway (1985) performed surge analysis to simulate gradually varied flow in
water distribution networks. The surge analysis differs from the water-hammer analysis
in that the flow change is felt throughout the pipe instantaneously. Holloway obtained
the solution by solving one non-linear ordinary differential equation per pipe line instead
of solving numerous non-linear partial differential equations per pipeline. Due to slow
rates of flow variation in a water distribution network during its normal operating cycle,
surge analysis gives satisfactory results with far less computational effort than that
required by water-hammer analysis. A detailed discussion of Holloway's work is
presented in this study to appreciate the flexibility of the Gradient Method.
Onizuka (1986) presented a method of analysis based on rigid water column
theory for slow transients in pipe networks. Onizuka formulated a system of first order
ordinary differential equations that describes the dynamic response of the network. The
time integration is performed directly by using, for example, the Runge-Kutta method
without involving any iterative procedure. A network example from Onizuka's paper has
been presented in this study with minor modifications.
Todini and Pilati (1987) proposed a gradient algorithm that operates on the field
of piezometric heads and flows simultaneously. Salgado (1987) extended the original
method to incorporate pumps into the system, and showed some of the advantages of the
method when compared with the methods recommended by Wood (1981). Todini
provided a unified mathematical framework for the most widely used existing gradient
based methods. This study extends the application of the Gradient Method for
17
simultaneous solution of piezometric heads and flows in distribution networks under the
slow-transient conditions.
Reference to further literature study is embedded throughout this work in order to
appreciate the efficiency and robustness of the Gradient Method for solving water
distribution network problems.
18
CHAPTER 3
BASIC EQUATIONS AND SOLUTION TECHNIQUES
FOR STEADY-STATE FLOW CONDITIONS
3.1 Introduction
The equations describing steady and gradually varied unsteady fluid flow in
closed conduits are derived in this chapter. The determination of steady-state pressure
and flow in a complex pipe network has long been of great importance in hydraulic
engineering. Steady-state network analysis is not only an important problem when
studied by itself, but is also essential in giving the transient analysis a starting point.
Existing basic equations such as the flow (Q), the node (h), and the loop (AQ) equations
are derived. Numerical solution techniques corresponding to these equations are also
investigated. A full derivation of the gradient method for the steady-state analysis and
comparison with existing models is presented. The chapter concludes with a detailed
derivation of existing basic equations as presented by Holloway (1985) describing the
physical behavior of fluid in a pipeline undergoing gradual changes in the flow
conditions. The assumptions made in the derivations, and the limitations that these
assumptions impose, are briefly discussed.
Following definitions are relevant to the derivation of the governing equations:
19
a. Steady-State Flow: Steady-state flow condition is that in which the velocity (of
the fluid in motion) at any fixed point does not change over time.
b. Dynamic (Unsteady) Flow: Dynamic or unsteady flow condition is that in
which the velocity (of the fluid in motion) at any fixed point changes from instant to
instant.
c. Rigid Wall (gradually varied unsteady flow): Under the assumption of rigid wall
conduit flow, a flow change is felt throughout a pipeline instantaneously and the fluid
in the pipe moves like a solid slug. In this approach, the inertia of the fluid in a
particular pipe is treated as lumped instead of continuously distributed.
d. Extended Period Simulation (EPS): Adjustment of water surface elevation in a
tank over a time period. Extended period simulation is performed by adjusting tank
water levels over the simulation period at discrete time intervals.
3.2 Basic Equations for Steady-State Flow Conditions in a Pipe Network
Fluid flow in a network is in steady-state when at any given point the velocity
does not vary in magnitude or direction with time. The steady-state network problem is
solved for pressure at nodes and flow distributions in pipes. The following two
fundamental physical laws result in a system of equations that are solved to determine the
unknowns:
1. Conservation of Mass --- the algebraic sum of the flows (known or unknown) at a
junction must equal zero (Kirchhoff' s 1" law), and
20
2. Conservation of Energy --- the net algebraic change in energy around any closed loop
must equal zero (Kirchhoff's 2' law).
In practice, for closed conduit flow, the "energy per unit weight" is given in terms
of the pressure head (ply), the elevation head (Z), and the velocity head (v2/2g), where p is
the pressure in pipes, y is the unit weight of the fluid, v is the fluid velocity and g is the
gravitational acceleration. It is common practice to lump all these head or energy terms
together as total hydraulic head with dimensions of length. In order for the pressure
throughout the system to be uniquely determined, at least one location must have a fixed
hydraulic head or a head that is a known function of the external flow. Every nodal
boundary (i.e., pump, reservoir, valve) will introduce an additional unknown (external
flow) and an additional equation (head/flow relationship). Therefore, these nodes do not
influence the balance between the number of equations and the number of unknowns.
The relationship between pipe flow and the change in head across that pipe is non-
linear. Friction losses are usually modeled in the following form:
hf = K Q IQI m
(3.2.1)
where
hf = the head loss due to friction in the pipeline
Q = the pipeline flow rate
K & m = constant parameters that depend on the units used and the particular
equation chosen (e.g., Hazen-Williams or Darcy-Weisbach)
21
Likewise, the head-flow relationships introduced by pumps, and valves are also non-
linear functions of flow. These relationships are usually approximated by piecewise
polynomials, oftentime, using a least-squares routine, over the operating range
(Holloway, 1985).
The two conservation laws can be posed in several ways to determine the desired
unknowns. Three classes of approaches have been investigated for steady-state
conditions. One such approach is to use the pipe flow rates as the unknown and set up a
total of p equations where p is the number of pipes. There will be one energy equation
for each independent loop and one continuity equation for each node. These equations
are called the flow (or Q) equations since the flows are the unknowns. The next section
deals with this formulation. Two other formulations, the node (h) and the loop (AQ)
equations are discussed in the following sections.
3.2.1 The Flow (Q) Equations
The flow equations are given below for a system with L loops including psuedo-
loops and NN nodes:
PiE - E hpk, = dh, (/ = 1,2, .L) (3.2.1.1)
i=1 i=1
Pn
1=1 Q11 = q
(n = 1,2, NN) (3.2.1.2)
22
where
= head loss in pipe i in loop Ihpki = head supplied by pump k in loop 1
dh, = change in head between the nodes at the beginning and end of loop Ip, = number of pipes in loop IP, = number of pumps in loop IQin = flow into node n from pipe i connected to the nodeqn = consumptive use at node n, and
p„ = number of pipes into node n
The 1 loops consist of the number of independent closed circuits in which the head
difference around the loop, dh, is zero. Also within this set are so called pseudo-loops 1
which are paths connecting two fixed-grade nodes. The dh for these loops is the
difference in energy between the fixed grade nodes.
To state the above equations, the appropriate head loss formula (Darcy-Weisbach
or Hazen-Williams) must be used to determine the head loss (h), and a pump head curve
must be used to determine the head supplied by the pump. The flow (Q) equations result
in a larger number of equations than the next two approaches, but the continuity
equations are linear and the energy equations can be linearized. Therefore, efficient
numerical solution methods are available to solve this formulation's equations. One such
numerical tool is discussed next.
Psuedo-loops are non-existent loops that have to be created by introducing an imaginarypipeline between the fixed-grade nodes (e.g., reservoirs). These fictitious pipes have alarge frictional factor, thereby assuring that the flow through this pipeline will be small.
23
Linear Theory Method
In the linear theory method, the continuity equations are obviously linear.
However, the energy equations are non-linear since they cannot be written in the form:
PIE K, Q = dh
i=1(3.2.1.3)
where
Q = flow in pipe i in loop
= constant
dh = difference in water elevation in tanks (zero for loops, L), and
Pi = number of pipes in loop.
The energy equations are linearized by setting Qm as a constant for a given
iteration. By doing this, a system of linear equations are created that can be solved by
some linear technique (e.g., Gaussian elimination, Jacobi iterative method). The a, terms
are then given by:
= KiQm (3.2.1.4)
The a, terms can also contain the coefficients for the pump head characteristic
equations. Thus, L + NN - 1 linear equations will be created with the same number of
unknowns. For this purpose, the a's must be double subscripted: the first subscript (1)
refers to the loop number, while the second (i) refers to the number of the pipe. The
entire system of equations becomes
24
anQi + a12Q2 + + a., ;Q; = dh l
L equations (3.2.1.5)
aLl au _2 + + Q atiQ; = dhi
bilQi + b12Q2 + + bliQi qi
NN-1 equations (3.2.1.6)
bn -1,1Q1 + bn -1,2Q2 + + bn q -1
where
Q. = flow in pipe i in a loop
, if pipe i is in loop 1
0, if pipe i is not in loop 1
+1 if flow in pipe i is positive into node n
bni = -1 if flow in pipe i is negative into node n
0 if pipe i is not connected to node n
To solve the network problem, it is necessary to solve the linear set of equations,
recalculate the a terms, and resolve the linear equations iteratively until the solution
converges. The linear-theory method tends to overcorrect the Q's, so a weighted average
is usually taken of the old and new Q's. The major advantage of the linear-theory method
is that it does not require an initial solution. The Q's can be set to some arbitrary value,
and it will still converge correctly.
25
It has been reported (Holloway 1985) that Wood (1972, 1980) uses the linear-
theory method in his KYPIPE program. Wood's technique is best described as a
modified-linear-theory-newton (Holloway, 1985) method. The equation for a given
pipeline within a network system can be written as
F=KQIQr+MQ2±hp (3.2.1.7)
where,
M = algebraic sum of the minor losses in the pipe, and
= head supplied by a pump (if one is located in the pipeline considered) and
can be represented as:
hp = C l Q2 + C2Q + C3 (3.2.1.8)
This quadratic pump head-flow relationship is obtained by using a least-squares best fit of
three head-flow points on the pump discharge curve. The derivative of function F is:
G = (m+1)KT + 2MQ + 2C,Q + C2 (3.2.1.9)
Wood then uses the following gradient relationship to solve for the unknown Q:
GoQ = [GoQo - Fo]
(3.2.1.10)
where the subscript (0) indicates an initial guess or previous iteration. This equation is
summed around loops and solved simultaneously with the continuity equations to obtain
Qk , +„ or the flow at the following iteration step. This step will be repeated until Q 0 and Q
are within some desired tolerance.
26
3.2.2 The Node (h) Equations
By combining the energy equation for each pipe with the continuity equation, the
number of equations to be solved can be reduced from 4 + NN - 1 to NN, where NN is
the total number of nodes in the network. The unknowns are the head at each node.
Once the heads are known, the flow rates in each pipe can be obtained. The head loss
equation for a single pipe which has previously been written as hf = KT can now be
rewritten as
- h = 1%1 ti) gn) Qi; (3.2.2.1)
where
= head at node i
hi = head at node j
= head loss coefficient for pipe from node i to node j
= flow in pipe from node i to node j
= exponent in head loss equation for pipe from i to j
Since the head loss is positive in the flow direction, (sgn) Q ii = (sgn) (hi - hi), it is
possible to rewrite equation (3.2.2.1) to give
Q (sgn) (hi - h;) (lhi - (3.2.2.2)
The continuity equation at node i can be written as
Pi
E qi (3.2.2.3)k =1
where
27
Qki = flow into node i from node k
q 1 = consumptive use at node i, andp i = number of pipes at node i
The energy and continuity equations can be combined by substituting equation (3.2.2.2)
for each flow into equation (3.2.2.3) to give
Pi
k=1 (sgn) (hk (Ihk hiliKki) 1mki ) = ch
(3.2.2.4)
One such equation can be written for each node, and the set of node equations can be
solved for the unknown head (h i). Since the equations are non-linear, several solution
techniques are available for solving them, such as the Newton-Raphson method.
Newton-Raphson Method
The Newton-Raphson method is a powerful numerical equation solver. It is suited for
problems that can be expressed as F(x) 0, where the solution is the value of x for which
F is zero. The derivative of F can be approximated by:
F' = [F(x+Ax) - F(x)]/(Ax) (3.2.2.5)
With an initial estimate of x, the solution to the problem is simply the value of x + Ax
that forces F to zero. Therefore,
Ax = -F(x)/F'(x) (3.2.2.6)
The new value of x + Ax becomes x for the next iteration, and the process is repeated
until F converges toward zero within a specified tolerance.
28
The Newton-Raphson method can also be applied to a system of equations. The
remainder of this section will discuss its application to the NN - 1 nodal equations
(application to loop equations is also possible).
For each node (1 through k), the following head equation can be written
piE (sgn) (h - h) h - - q i = 0 (i = 1,2,..., NN-1)
J=1(3.2.2.7)
where
p i = number of pipes at node i, and
q i = consumptive use at node i
The difference in the value of the function at iteration k' and (k' + 1) is
dF = F(k' + 1) - F(k') (3.2.2.8)
This can also be approximated by the total derivative:
dF = (aF/ah,)Ah l + (ap5h2).612 + + (apahjAnk (3.2.2.9)
where
Ah = change in head between iteration k' and (k' + 1)
Thus the problem is finding values of Ah that force F(k'+1) to zero. This is accomplished
by setting equation (3.2.2.7) equal to equation (3.2.2.9), resulting in a system of k linear
equations with k unknowns (Ah) that can be solved by one of the linear methods
mentioned earlier. hi is then found by tracking through paths.
29
The solution procedure consists of picking some initial values of Ah, calculating
the partial derivatives of each F with respect to each h, solving the system of linear
equations to find h, and repeating until all of the F's are sufficiently close to zero.
3.2.3 The Loop (AQ) Equations
The third approach for solving for the flow and pressure distributions is to set up
the looped system so that the energy equations, as an initial condition, satisfy the
continuity equation. Thus, the problem becomes a matter of correcting the flows in each
loop in such a way that the continuity equations are not violated. To do so, flow in every
pipe in the loop can be corrected by adding flow (i.e., if there is too little head loss) or
subtracting flow (i.e., if there is too much head loss). Thus, the problem is reduced to
finding the correction factor, AQ, such that each loop energy equation is satisfied. These
loop energy equations may be written as:
PI
E Ki (Q0 + AQ) IQ0 + AQ 1 m = = (3.2.3.1)i =1
where
Q ic, = initial estimate of flow in the pipe i
AQ I = correction to flow in loop 1
Pi = number of pipes in lth loop, and
= number of loops
30
The AQ terms refer to the loop in which the pipe falls. If a pipe lies only in one loop,
then the flow in the pipe is Q . AQ. For a pipe that is part of several loops (i.e., a, and
b), the flow might be
Q, + AQa - AQb
(3.2.3.2)
The negative sign in front of the b term is included merely to show that a given pipe may
be so situated such that it is in the positive direction in one loop and in the negative
direction in another. When the loop approach is used, a total of 4 equations are required
since there are 4 unknowns, one for each loop. The Hardy-Cross method, which dates
back to 1936, is usually applied to the AQ equations (Walsh, 1984).
Hardy-Cross Method
When applied to the AQ equations, the method requires an initial solution which
satisfies the continuity equation. For loop l in a pipe network the AQ equation can be
written as:
PIF(AQ I) = E K [sgn (Qio AQ)] I Qio AQI r - dh, = 0 (3.2.3.3)
j=1
where
AQ, = correction to loop / to achieve convergence
Q0 = initial estimate of flow in pipe i (satisfies continuity)
= number of pipes in loop I
Applying the Newton-Raphson method for a single equation gives:
31
PiKi(Qi0 AQ) I Qi0 AQ, r
i=1
AQ(k' + 1) = AQ (3.2.3.4)
Pi
E Koni I Qio AQ1 r1=1
where the (k'+1) refers to the values of AQ in iteration (k' + 1). All other values refer to
iterations k', but they will be omitted from the equation for ease of reading. Equation
(3.2.3.4) should be recognized as being equivalent to:
AQ (k' + 1) = AQ (k') - F(k')/F'(k')
The signs on the Qi terms depend on how that pipe is situated in the loop under
consideration. It should be emphasized that the same pipe may have different signs in
different loops.
3.2.4 Comparison of the Solution Techniques
According to Jeppson (1976), the linear-theory method as used by Wood (1972,
1980) has two distinct advantages over the Newton-Raphson method:
1. it requires no initialization, and
2. according to Wood and Charles (1972), it always converges quickly.
Jeppson (1976) suggests that the linear-theory method should not be used with the head
oriented equations or the corrective loop equations. Linear-theory is reportedly best
suited for the flow equations, which is the system of equations chosen by Wood.
32
Wood and Charles (1972) did a comparison between Hardy Cross, Newton-
Raphson, and Linear-Theory methods. Pipe flows in a 19 pipe network were computed
using the three different analysis techniques. Only the Linear-Theory analysis technique
was analyzed by Wood; the other data was taken from previous literature. The results of
this comparison were (Holloway, 1985)
I. Hardy Cross --- 635 iterations,
2. Newton-Raphson --- 24 iterations, and
3. Linear-Theory --- 4 iterations.
Holloway and Chaudhry (1983) did a comparative study between Newton-Raphson
models (NETWK by Jeppson of the University of Utah (1980) and FLOW by Epp and
Fowler of the University of British Columbia (1970)), and the Linear-Theory model
(KYPIPE) by Wood of the University of Kentucky (1980). These studies indicated that
the rate of convergence of the two methods for a large 200 pipe network were close or
equal (Holloway, 1985). NETWK (Newton-Raphson) and KYPIPE (Linear-Theory) both
converged in eight iterations, and FLOW (Newton-Raphson) converged in nine iterations
(Holloway, 1985). However, FLOW required least amount of computation time,
followed by KYPIPE and then NETWK.
3.2.5 Gradient Method
A gradient algorithm is derived for flow analysis of pipe networks. The Newton-
Raphson technique is applied both in terms of nodal heads (h) and pipe flows (Q) to
33
obtain a simultaneous solution of the system of equations expressing mass and energy
balance. The problem is then solved through an iterative solution of a system of linear
equations, the size of which equals the number of unknown heads.
A pipe network is defined by its topology, pipe characteristics and system
constraints. System constraints include water demands (q) or fixed heads (ho) for each
node and head loss laws for each pipe [Ki(Q,)]. The problem is to determine all of the
flow rates (Q) in the pipes and all of the unknown heads (h) at the nodes under the steady-
state assumption.
In matrix form the problem can be formulated as follows (Todini, 1987):
Al2 h + K(Q) = -A10 ho
A21 Q
(3.2.5.1)
Al2 A21 T
(ne,nn) unknown head nodes incidence matrix
= A 01T
(ne,no) fixed head nodes incidence matrix
QT = EQI,Q2,....,Q.el (1 ,ne) flowrates in each pipe
T= (1 ,nn) nodal demands
hT = (1 ,mi) unknown nodal heads
hoT = (1,no) fixed nodal heads
KT(Q) = (1,ne) laws expressing head losses in pipes (K, = KI(Q))
where, nn = number of nodes with unknown head
34
no = number of nodes with fixed head
ne = number of pipes with unknown flow
1 if flow of pipe i enters node j
0 if pipe i and node j are not connected
-1 if flow of pipe i leaves node j
and with A 10 defined similarly to A l2 for fixed head nodes.
The system represented by equation (3.2.5.1) may have more than one solution
depending upon the form of [K,(Q,)]. If all [KI(Q)] are monotonically increasing
functions, it can be proved that the solution of the system exists and is unique (Todini and
Pilati, 1987). Note the first set of equations (3.2.5.1) are head loss equations for each
pipe while the second are the set of nodal balance relationship.
Derivation
Todini and Pilati (1987) showed that the necessary conditions for the steady-state
flow are simply the simultaneous fulfillment of nodal balance and the head loss-flow
relationship. Both conditions can be expressed in the following compact system of
equations:
Al210Q1 F— Alohol
q(3.2.5.2)
where
An = matrix (ne,ne) dependent on the particular head loss-flow relationship
Al2 = topological (incidence) matrix (ne,nn)
A21 [A-12]
T
A 21 0 dh dq (3.2.5.6)NA, A l2 1 [dQi [dE]
35
A0-10 = known vector (ne, 1)
The upper part of the system represents the head loss-flow relationship and the lower part
corresponds to the nodal flow (mass) balance. Since A 11 clearly depends on the flow, the
upper part of the above system is a set of non-linear equations in Q. A generalized
relation between flow and head may be written as
= Qim (i = 1 ,2,..., ne) (3.2.5.3)
Using the link to node topological matrix (A l2), one can express the head loss (or head
gain in the presence of pumps) of each link connecting two different nodes as
A„ Q + Au h = - ADD ho (3.2.5.4)
where
O
K 21Q2I m (3.2.5.5)
o ne IsrL e
Because the system represented by equation (3.2.5.2) is non-linear, a direct solution is not
possible, but an iterative gradient approach is indeed feasible. Differentiating the system
of equation (3.2.5.2) gives
where
36
N = diagonal matrix (ne,ne) of the exponents m of the head loss-flow relationship.
At iteration k', where convergence has not yet been achieved, a (ne, 1) vector dE
and a (nn, 1) vector dq are defined as
dE = A,, Qi k' Al2 Aloho (3.2.5.7)
and dq A21 Q ik' - q (3.2.5.8)
Equation (3.2.5.7) represents the energy imbalance at each link while (3.2.5.8) represents
the flow imbalance at each node. The solution of (3.2.5.6) is
[NA,,
Ldh A21
Al dE1 [1dgi (3.2.5.9)
Following a similar approach to Todini and Pilati (1987), the inverse of the block-
triangular matrix in (3.2.5.9) can be computed as another block matrix:
rNA ll Al2 -I B11 B 12
[ A21 0(3.2.5.10)
B21 B 22
Assuming
NA,, = (3.2.5.11)
(and therefore D A il = N-1 ; N, A,, and D being diagonal), and computing the blocks of the
inverse in equation (3.2.5.10), one gets:
13 1 , = D - D Al2 (Ai2D Al2) -1 AND
B12 = D Al2 (A21 D Al2)
B21 = (A21 D A l2) -1 A2 1 D
B 22 = — (A21 D A l2 )4
The solution of equation (3.2.5.2) is thus obtained from the fact that
dQ = B 11 dE + B 12 dq
dh = B21 dB + B22 dq
(3.2.5.12)
(3.2.5.13)
37
By substituting set of equations (3.2.5.12) into equations (3.2.5.13), the following can be
obtained:
dh (A21 D A IX A21 D (An + Al2 hic' A10 h0) — (A21 D A l2) 1 (A2I Qk' C1)
= hk' (A21 D Al2) - ' {A21 D (An Qk' Alo ho) ± - A2I Q1(')}
(3.2.5.14)
dQ = {D - D Al2 (A21 D A l2) 1 A21 D) (A ll Qk' + Al2 hie + A10 hip) + D A l2 (A2I D Al2) -1
s, (A21 Qk'
= D (A,, Qk ' + Alo ho) - D Al2 (A21 D A l2)- ' {A2 , D (An Qle + A lo ho) + (ci - A21 Qk)}
(3.2.5.15)
Using the definition of D as presented earlier:
dQ = Q ic - Qk '+1
dh = hic - (3.2.5.16)
A recursive Newton-Raphson algorithm is obtained as follows:
38
hk'-1 -(A211\1-1 A ll -1 A l2) -1 {A l2 N I (Q1(' A 11 -1 A10 h0) ± (C1 - A21 Qk.)}
(3.2.5.17)
Q" (1 - N-1 ) - A„' (A, 2 h" + A, o ho)
(3.2.5.18)
where A, is computed using Q . k' and (k'+1) are consecutive iteration steps.
3.2.6 Comparison of the Gradient Method with Traditional Methods
Salgado and Todini (1987) compared the gradient algorithm for the analysis of
water distribution networks with other traditional gradient algorithms (Simultaneous Path
(or Loop) and Linear Theory). The gradient algorithm has shown robust behavior when
run with some examples simulating different operational situations. A set of examples as
presented by Todini and Salgado (1987) is investigated in this section. A common
network is used to simulate different hydraulic conditions.
The behavior is presented in a tabular form.
1. Example A
The network shown in Figure 3.1 incorporates small diameter pipes connected to larger
diameter pipes and contains 66 pipes, 41 nodes and 2 reservoirs (nodes 1 and 2). Nodal
demands are controlled to maintain fluid velocities under 0.2 m/s to simulate the behavior
of the network during the night. This example network includes 2 gravitational sources
and does not include pumps.
2. Example B
39
This example resembles Example A with the addition of 6 pumps. Also, a branched
connection has been added at node 25 to give a total of 74 pipes, 48 nodes and 8 sources.
3. Example C
This is the same basic network as presented in Example B, but nodal demands have been
increased tenfold to simulate extremely high daytime consumption.
4. Example D
The previous network has been modified to include 2 valves (in links 67 and 70) that are
completely closed in order to simulate the case when a particular link ceases to carry
flow. When the valves are fully closed, the original network becomes two independent
systems with their own sources. It is clear from Table 3.1 that the gradient method
worked extremely well for steady-state conditions. Thus, it is extended in chapter 4 to
consider gradually varied flow conditions. The equations describing Dynamic flow are
presented in the next section.
Table 3.1. Comparison of the Gradient Method with Traditional Methods (Todini, 1987)
PROGRAMEXAMPLE
LOOP LT GRAD
converged converged convergedA iter=16 iter=17 . iter=16
t=69.53 sec [1] t=788.51 sec t=29.77 sec
converged slow convergence convergedB iter=12 iter=13 iter=10
t=91.67 sec t=961.69 sec t=34.00 sec
converged slow convergence convergedC iter=13 iter=15 iter=12
t=100.13 sec t=1109.82 sec t=39.16 sec
converged [2] slow convergence convergedD iter=21 iter=21 [2] iter=19 .
t=154.94 sec t=1551.76 sec t=57.28 secsome heads unavail.some heads unavail. • • .
40
Figure 3.1. Network Analyzed by Todini (1987) for Examples A, B, C and D
41
3.2.7 Governing Equations in Dynamic Pipe Network Analysis
In this section, equations describing unsteady fluid flow in closed conduits are
investigated. Standard references derive the basic partial differential water-hammer
equations in detail (Chaudhry, 1979), and the ordinary differential equation for surge
tank analysis has also been presented previously (Chaudhry, 1979). The surge equations
for a pipeline in a network, as presented in this section, were published by Holloway
(1985).
This section will introduce the derivation of the basic equations describing the
physical behavior of fluid in pipeline undergoing gradual changes in the flow conditions.
Whenever flow conditions change slowly, the transient response of a hydraulic system
can be described by using surge analysis instead of water-hammer analysis. Thus, the
flow change is considered to occur instantaneously throughout a pipeline (i.e., the
transient wave celerity is considered to be infinitely large). Except in rare instances,
flow changes in water supply pipe networks are gradual. These flow changes, whether
in the nodal demand, tank water level, or slow pump response can be easily handled by
the ordinary differential equations (Holloway, 1985). The following basic solution
techniques are applicable to solving these differential equations:
1. Explicit Runge-Kutta Method
2. Implicit Method
42
Assumptions
To simplify the derivation of the dynamic and continuity equations, the following
assumptions are made:
1. Flow conditions change gradually.
2. Conduit walls are rigid and the liquid is incompressible. Thus, a flow change
is felt throughout a pipeline instantaneously and the fluid in the pipe moves as
a solid slug.
3. The conduit remains full at all times, and the fluid in it does not boil, i.e., the
minimum pressure in any pipeline is always greater than the vapor pressure
(no cavitation).
4. Head losses in the system during the transient state can be represented by
using the steady-state formulae for the corresponding flow velocities. This
assumption, while not proven experimentally, is accepted for transient
analysis (Holloway, 1985).
Dynamic Equation
A free-body diagram of a conduit cross-sectional area is shown in Figure 3.2. The
forces acting on the fluid element are
F I = yAh, (3.2.7.1)
F2 = yAh2 (3.2.7.2)
43
F3 = yAh f (3.2.7.3)
where
A = cross-sectional area of pipe
y -- specific weight of fluid
h, = piezometric head at node 1
h2 = piezometric head at node 2
h f = friction loss along pipe
HGL
F3
Fl F2
pipe 'i
Figure 3.2. Free Body Diagram with Notation for Dynamic Equations
If the downstream flow direction is considered positive, then the net force acting on the
fluid element in the positive direction is a = F, - F2 - F3 . Therefore, it follows from
equations (3.2.7.1) to (3.2.7.3) that,
hl h2
44
IF = yA(h, - h2 -hf) (3.2.7.4)
The mass of the fluid element is
yAL/g (3.2.7.5)
where
L = length of conduit sectiong = gravitational acceleration
If Q is the conduit flow and t is the time, then the rate of change of momentum of the
element can be written as,
(yL/g). dQ/dt (3.2.7.6)
According to Newton's second law of motion, the rate of change of momentum is equal
to the net applied force. Therefore,
(yL/g). dQ/dt = yA(h, - h2 -hf)
(3.2.7.7)
By defining hf = KQIQr in which K and m are constants, depending on the friction
formula chosen, equation (3.2.7.7) can be written as,
(L/gA) dQ/dt = h, - h2 - KQIQI'n (3.2.7.8)
Equation (3.2.7.8) is valid for horizontal and sloping pipes.
45
Continuity Equation
Due to mass conservation, at any instant the sum of the flow into or out of any node
within the system must equal zero (Kirchhoff's 1st Law). Thus, the continuity equation
for each node can be written as:
i E Q i +q= 0
(3.2.7.9)
where
q = external flow in or out of the node
p = number of pipes connected to the node
The dynamic response of a pipe network can be mathematically represented by
simultaneously solving equation (3.2.7.8) for each pipe, equation (3.2.7.9) for each node,
and network boundary conditions. It is noted that 3.2.7.8 is a first order ordinary
differential equation that must be solved in some step wise fashion.
Methods of Solution
1. Explicit Runge-Kutta Method
In the past, whenever the dynamic (ordinary differential) equation was solved in
surge tank analysis (Chaudhry, 1979) one of the Runge-Kutta type numerical methods
was chosen. The e-Order Runge-Kutta method was usually utilized for accuracy.
Basically, the e-Order Runge-Kutta method may be explained as follows (Holloway,
1985):
To approximate the solution of the following initial-value problem:
Q' = f (t,h), a < t < b, Q(a) = a (3.2.7.10)
at (NSEC + 1) equally spaced numbers in the interval [a,13].
Input: endpoints a and b, integer number of sections (NSEC), and initial condition a.
Output: approximation w to Q at the (NSEC + 1) values of t.
This can be accomplished by the following steps:
1. Initialize the process by setting
x = (b - a)/NSEC
t=a
2. Output values for t and w.
3. For j = 1 to NSEC the following steps are performed:
(i) 7, = x[f (t,w)]
(ii) R = x[f(t + x12, w + ,I2)]
(ill) Z 3 = x[f(t + x12, w +
(iv) ; = X[f(t + X, W ± R-.3)]
(V) Set w = w + ( -1 + 2R"2 + 2R-3 +
(vi) t = a + jx
46
47
(vii) Output values for t and w.
where values of w will be the approximation of Q at different t times. Steps (i) through
(vii) are repeated until t = b.
Runge-Kutta method is easy to apply for a single surge tank. However, in a pipe
network, the solution of the ordinary differential equation for each pipe length is
interconnected amongst the others via Kirchhoff's 1st Law applied to each node.
Computational difficulties arise when the Runge-Kutta method is used in such a case.
Thus, the implicit method of solution is more suitable for a pipe network.
2. Implicit Method
Since the head-flow relationship at each node must be applied simultaneously to
solve the ordinary differential equations, use of the Runge-Kutta method is
computationally difficult. For a pipe network, it is much easier to solve the system
implicitly.
Following Holloway (1985), to use the implicit method, equation (3.2.7.8) is first
summed around a closed loop in the network:
E [(L i/gAi). d(Vdt] = E (11 1; - h21) - E hfi
1=1 i=1 1=1(3.2.7.11)
where
p = number of pipes in the loop
48
Equation (2.2.7.11) can be integrated as follows:
Qt-f-At pt-FAt p t+At p
{ [Li/(gAi) dQd} =J { [h 11 - h21ll dt -J { hfi } dtQ t 1.1 t 1=1 t 1=1
(3.2.7.12)
At any instant in time, Kirchhoff s 2" Law requires the difference in head around a loop
to equal zero. Therefore,
E (11, 1 - h2i) = 0i=1
The remaining terms can be modified to obtain the following:
p ti-et
{[L i/(gAi)] (Q i t+At - Q t)} = -[ f h i; dt]1=1 i=1 t
(3.2.7.13)
(3.2.7.14)
Note that dropping out the h-terms results in a drastic reduction in the number of
unknowns to be determined. Once the flows have been determined, the heads can be
obtained. Separation of the known Q (at time t) from the unknown Q (at time t + At) in
equation (3.2.7.14) yields:
p t+At
E {[L i/(gAi)](Q")} = E {[Li/(gAi)](Q t)} - E [ J h dt]i=1 1.1 i=1 t
(3.2.7.15)
The friction loss term can be rewritten as:
49
p t+At p t+At
E [ J hf, dti = f ((NW) dt]i=1 ti=1 t(3.2.7.16)
where K and m are constants depending on the friction loss formula chosen (i.e., Darcy-
Weisbach, Hazen-Williams) and the units. The head loss term is non-linear in Q, and the
variation of Q during the time increment zit is unknown.
At this point, it is important to note the approximations used in the literature for
the non-linear friction-loss term. In transient analysis of rapid flow changes analyzed by
the method of characteristics, several approximations have been used for the non-linear
friction-loss term for water-hammer analysis, such as:
t+At
K Q1Q1m dt = K Qt+Atpri At
(3.2.7.17)
t+At
K Qlqm dt = K [(Q` + TA) 1Qt Qt+At i m/(2 .+1 )] At (3.2.7.18)
t+ At
or, KQIQjm dt K [(Q1Qr Qt+AlQt+Ar)/21 At
(3.2.7.19)
where time t represents known values of Q and time (t + At) the unknown values. Wylie
(1983) suggested an approximation for the term in water-hammer analysis done by the
method of characteristics that is numerically stable and accurate. Holloway (1985)
obtained results that compared favorably with the non-linear approximations of equations
50
(3.2.7.18) and (3.2.7.19) by using Wylie's approximation known as the integration
approximation.
The separate ordinary differential equations used to describe water-hammer by the
method of characteristics and pipeline surges are integrated in a similar manner. The
suggested approximation is as follows:
K Qpim dt = K Qt+AtiQtri At
(3.2.7.20)
If equation (3.2.7.20) is substituted back into equation (3.2.7.15), then the numerical
dynamic equation written around a loop in the network is:
E {[Li/(gAi)] Q" t} = E {[Li/(gAi)] (01 - E [(Ki QrAt iQ itim At1=1 i=1 i=1
(3.2.7.21)
Thus, the numerical representation of the dynamic equation written around a loop
in the network is linear in Qt+et• The entire system of equations (linearized dynamic
equations written around each loop and the linear continuity at each node) can be solved
simultaneously to obtain the dynamic response of the network. Holloway has presented
an efficient hydraulic network model. Although the number of equations is reduced with
dynamic surge analysis, much effort is still required for computer coding a model with
loops. Salgado and Todini's work on steady-state analysis suggest that dynamic network
51
analysis can be further simplified by using the Gradient Method as applied to solve for
nodal heads and flows in each pipe in a network.
3.3 Conclusions
This chapter introduced the basic solution methods for water distribution
networks. Governing equations to describe steady and gradually varied unsteady fluid
flow in closed conduits have been derived. The most suitable solution techniques
available have been investigated in detail. From such derivations, one can observe the
complications related to network analysis. Existing steady-state algorithms require
formulating the loop and flow equations which necessitates additional coding.
However, the gradient method effectively simplifies the analysis. The existing models
had to be presented in order to appreciate the effectiveness of the unsteady gradient
algorithm, as presented in the next chapter.
52
CHAPTER 4
GRADIENT ALGORITHM FOR UNSTEADY FLOW CONDITIONS
4.1 Introduction
In this chapter, an extension to the gradient algorithm is presented to include
gradually varied unsteady fluid flow in closed conduits. The derivation of the gradient
method for steady-state simulation was presented in the previous chapter. In the
extension, Newton-Raphson technique is applied both in terms of nodal heads (h) and
pipe flows (Q) to the simultaneous solution of the system of partly linear and partly non-
linear equations expressing mass and energy balance. The rate of change of momentum
has been introduced in the head loss-flow equation for dynamic response. Thus, a non-
linear head-flow relationship is derived for each pipe in a network which is solved for
heads and flow rates in conjunction with mass balance at each node. An appropriate
friction loss term has also been introduced. This leads to the non-linear friction loss term
approximation as discussed in the Dynamic Pipe Network Analysis in the last chapter.
A recursive Newton-Raphson algorithm is thus obtained to simulate gradually
varied unsteady fluid flow in water distribution networks. Detail mathematical
derivations are presented in the next section in reference to the gradient algorithm
introduced earlier in this study.
53
4.2 Basic Equations
The necessary conditions for the gradually varied unsteady flow are simply the
simultaneous fulfillment of nodal balance and the head loss-flow relationships.
Whenever flow conditions change slowly, the dynamic response of a hydraulic network
can be described by the equations derived in this section.
Assumptions
To simplify the derivation of the dynamic equations, the same assumptions as
defined in section 3.2.7 have been considered:
1. The flow conditions change gradually.
2. The conduit walls are rigid and the liquid is incompressible. Thus, a flow
change is felt throughout a pipeline instantaneously and the fluid in the pipe
moves as a solid slug.
3. The conduit remains full at all times and the fluid in it does not boil, i.e., the
minimum pressure in any pipeline is always greater than the vapor pressure
(no cavitation).
4. The head losses in the system during the transient state can be represented by
the rate of change of momentum for the corresponding flow velocities and the
steady-state friction equation.
54
Dynamic Equations
The dynamic head-flow equation for a single pipe in the system is derived in
reference to Figure. 4.1. The figure represents a simple water distribution network with 5
pipes, 2 fixed grade nodes (FGN), and appropriate nodal consumption. The flow
directions are obtained from a steady-state run of a computer program based on the
gradient algorithm. The following equations are derived in conjunction with these flow
directions for consistency. It should be noted that the computer program developed in
this study is capable of generating the solution to a problem regardless of the initially
assumed flow directions.
For pipe element 1 (Figure 4.1) in the network, the head-flow relationship takes
following form:
Pipe 1: K,Q,' + h, - ho , = (L,/gA I ) dQ l/dt (4.2.1)
where
K1 = constant depending on the friction formula (H-W or D-W) used
m = exponent depending on the friction formula (H-W or D-W) used
L, = length of the pipe
h, = piezometric head at node 1
ho , = fixed grade head connected to pipe 1
Q, = flow rate in pipe 1
t = time
Similarly, head-flow equations for the other pipe elements in the network are,
Pipe 2: K2Q2m + h2 - h, = (L2/gA2) dQ2/dt (4.2.2)
q3
55
Pipe 3: K3Q3 + h 3 - h 2 = (L3/gA 3) dQ,/dt (4.2.3)
Pipe 4: K4Q4"1 + h 3 - h, = (L4/gA4) dQ,/dt (4.2.4)
Pipe 5: K5Q5' + h2 - h02 = (L5/gA5) dQ5/dt (4.2.5)
where
h02 = fixed grade head connected to pipe 5
FGN .
Pipe #
0 Node #
q
Nodal demand
Flow direction (arbitrary)
Figure 4.1 Typical Setup of Water Distribution Network
56
One pipe element is chosen to show the time-line integration. The following
derivation is valid for pipe element 1 (Figure 4.1). Equation (4.2.1) can be integrated to
the form:
t+At t+At Q 1 t+At
S K,Q,' dt + j (h, - ho ,) dt = (L,/gA l ) f dQit t Qt
(4.2.6)
The above equation is non-linear and therefore, following valid approximations
(Holloway, 1985) are made:
t+At
f K,Q,- dt — (KA t+At ig tril) Att
t+At
J h, dt = [(h i t + la 1 ')/2] Att
t+At
f ho, dt = Rhol t + hol t+At)/2] Att
(4.2.7)
(4.2.8)
(4.2.9)
where
At = time increment
Q t = known flow rate at time t
Q"` = unknown flow rate at time t+ At
li t = known piezometric head at time tht+At = unknown piezometric head at time t+ tit
Equation (4.2.7) is the only major numerical simplification. Equations (4.2.8) and (4.2.9)
are arithmetic mean (linear) that could be substituted for geometric mean (non-linear).
57
The head loss formula due to friction, hf = KQ IQI m-1 accounts for reverse flow anywhere
in the system.
Substitution of the above approximations and further simplification of equation
(4.2.6) lead to the following form:
(K, Qi t±At ig t i m-1 ) + [(h i t + h i t ) - (ki t hoi t+A)] At/2 = (L i/gA i) (Qi" t - Q t)
(4.2.10)
{(Ki IQ] t i m-1 At) - (Li/gAi)] [(hit hi") - Om` + h01 t )] At/2 = - (L i /gA i ) Qi
(4.2.11)
Upon placing the known terms to the right hand side of the equation the final form is obtained:
[(Ki t i m-I . At) - (Li/gAI)] * Qt-F4t [ * At/2
= - (L I /gA I) Q,` + [-hli (hol i ho1i÷,61)} .At/2
(4.2.12)
It should be noted that the fixed grade head term (ham ) remains a known boundary at all times.
Similar dynamic head-flow relationship can be obtained for the remaining pipes in
the network. A general equation of the following form can be written for the pipes with
two node connections:
RKIQ tr i At) - (L/gA)] Cr t + [ hrAt - h t ] At/2 = - (L/gA) + [hit - hi t] . At/2
(4.2.13)
58
where
i = starting node for a pipe
j = ending node for a pipe
The above set of dynamic equations is used to set up the Unsteady Gradient Algorithm.
Continuity Equation
Due to mass conservation, the sum of the flow into or out of any node within a
system must equal zero (Kirchhoff s 1' Law). Thus, the continuity equation can be
written for each node as,
1=1 Q+q=0
(4.2.14)
where q is the external flow in/out of a node and p = number of pipes in the system.
Based on the above equations the dynamic gradient algorithm can thus be
presented for a typical water distribution network as shown in Figure 4.1. Solution to
such recursive algorithm will provide the piezometric head (h) at every node and the flow
rate (Q) in every pipe of the system.
4.3 Solution Algorithm
The gradient algorithm for steady-state fluid flow in water distribution network
was derived in chapter 3. Given a pipe network defined by its topology, pipe
characteristics and system constraints, the problem consists in determining the flow rates
59
in the pipes as well as all the unknown piezometric heads at the nodes. The steady-state
gradient algorithm provides a starting point for the gradually varied unsteady simulation.
In matrix form, the two basic equations introduced earlier are:
A l 2 h K(Q) = -A10 ho
Q
(4.3.1)
where,
Al2 = A21 T
(ne,nn) unknown head nodes incidence matrix
Al0 = A OI T
(ne,no) fixed head nodes incidence matrix
QT = [Q ,Q2,....,Q.e] (1 ,ne) flow rates in each pipe
T= [q1,q2,....,q. ] (1 ,nn) nodal demands
hT = [h1,1125. • —9hnni (1 ,nn) unknown nodal heads
hoT = [h01 ,h02 ,....,h00] (1,no) fixed nodal heads
KT(Q) = (1 ,ne) laws expressing head losses in pipes (K.; = Ki(Q))
where, nn = number of nodes with unknown head
no = number of nodes with fixed head
ne = number of pipes with unknown flow
1 if flow of pipe i enters node j
= 0 if pipe i and node j are not connected
-1 if flow of pipe i leaves node j
and with A 10 defined similarly to A l 2 for fixed head nodes.
60
The following compact system of equations was introduced earlier in Chapter 3
for the of nodal balance and the head loss-flow relationships:
[A ll A l2 1 [Q] Awhol
A21 0 h q(4.3.2)
where,
A1 1 = matrix (ne,ne) dependent on the particular head loss-flow relationship
A l2 = topological (incidence) matrix (ne,nn)
A21 = [AIX
Awho = known right hand side vector (ne,l) obtained from the dynamic head-flowequations
The upper part of the system represents the head-flow relationship and the lower one
corresponds to the nodal flow (mass) balance. Since A11 clearly depends on the flows, the
upper part of the above system is a set of non-linear equations in Q.
A generalized relation between flow and head may be written as
h=KQm
(i = 1,2,..., ne) (4.3.3)
Using the link-to-node topological matrix (A l2), one can express the head loss (or head
gain in presence of pumps) of each link (i e, pipes, pumps, etc.) connecting two different
nodes as
A„ Q + h = - Aio ho (4.3.4)
where, for the network in Figure 4.1,
-
K i 1Q i tm-1 L,
At — 'gA i
61
i 1 m-1 L2 K21Q2 tl At —
gA2
-
0
0 K51 m 1 L5 Q 5 t 1At —
gA5
(4.3.5)
and
A11
Al2 = (4.3.6)
Combining all the terms at the known time step, matrix A ieho is writen in the following
compact form:
L1QltgA i 1 —1 0 0 0- h0
1t
± h ol t+At
L 2 0 1 —1 0 0 hitQ2t
gA 2 + 0 0 1 —1 0 * h2t */2
0 1 0 —1 0 h3t•
L s t_ 0 0 —1 0 1 h 02 t + h 02t+At
_Q 5 .gA 5
-
A lchi, = -
(4.3.7)
which, upon algebraic manipulation, is a (ne,l) matrix for the system.
62
Because the system represented by equation (4.3.2) is non-linear, a direct solution
is not possible, but an iterative gradient approach has been introduced in the last chapter
that solves the problem.
The resulting recursive Newton-Raphson algorithm is:
hk '+' = - (A21 N1 A il -
A l2) -1 {A 12 (Qk ' + A,0 ho) + (q - A21 Qie)}
(4.3.8)
= _ N-1 ) Qie _(An h" ADD ho)
(4.3.9)
where A ll is computed using Q k'. k' and (k'+1) are consecutive iteration steps. The
above set of equations are solved at every time step with a specified number of iterations.
A computer program has been developed in this study that can perform this simulation.
4.4 Conclusions
This chapter introduced the gradient algorithm for simulation of gradually varied
unsteady flow problems in water distribution networks. Governing equations have been
derived in reference to a typical water distribution network (Figure 4.1). The gradient
algorithm effectively simplifies the analysis whereas the existing dynamic algorithms
remain fairly complicated with loop and flow equations that can be time consuming to
solve. Furthermore, this chapter represented the application of approximation for the
non-linear friction loss term in the head loss-flow equations. Direct application of the
friction loss equation (3.2.7.17) allows equation (4.3.4) to be solved directly rather than
applying the gradient method. Any future work with friction loss equations (3.2.7.18)
63
and (3.2.7.19) can be successfully implemented with the application of the gradient
method. In Chapter 7, results obtained from these approximations are in good agreement
with the existing models. Appropriate boundary conditions implemented in this model
are discussed in the next chapter.
64
CHAPTER 5
BOUNDARY CONDITIONS AND INTERNAL COMPONENTS
5.1 Introduction
In the previous chapter, the gradient algorithm was derived. For a complete
solution of these equations, the initial values of pipe flows, nodal heads, and the boundary
conditions (if any) throughout the transient analysis must be specified. More importantly
the boundary conditions of the dynamic model must be defined.
Dynamic boundary conditions are similar to steady-state boundary conditions ---
the difference being that they may vary with time. At the end of each time step during the
simulation, proper subroutines in the developed code update the possible changes in the
boundary conditions. Such changes may be the variation of water surface elevations in
tanks, the variations in the energy gained by internal components like pumps, etc. The
following subsections describe alternative boundary conditions and internal components
used in the dynamic model.
5.2 Boundary Conditions
5.2.1 Constant Nodal Demand
A constant nodal demand is the simplest of all the boundaries in a water
distribution network. The analyst is required to input the demand for each node in a
65
network. Thus, the proper execution of the mass balance equation in the model is
performed. These nodal demands are time invariant.
5.2.2 Variable Nodal Demand
It is often the case that nodal demands vary over a typical day depending on the
water usage. These cases can be studied effectively with the introduction of a functional
change in demands. The functional relationship with respect to time can be introduced
within a subroutine. Data input is thus not required for nodal demands described as
functions; the demands at different time steps are simply generated by the program. It is
up to the analyst to decide whether the demand function be linear, step-wise or of any
other mathematical form.
5.2.3 Constant-level Reservoir (FGN)
A constant-level reservoir is treated as in any steady-state model. Such a
reservoir, popularly known as the fixed grade node, is used as a starting point in the
computation of the pressures throughout a system. Pseudo-loops are used in the existing
loop equations for more than one fixed grade node. This study investigates head loss-
flow equations for each pipe element in a network and therefore, no matter how many
fixed grade nodes are present, pseudo-loops are never introduced in the dynamic
equations. The energy or hydraulic head at such reservoir locations remain time invariant
during a simulation period.
66
5.2.4 Variable-level Tank
More common in networks are tanks in which water level varies over time.
Variable-level tanks are treated similar to the constant-level reservoir boundary with a
few additional features. As depicted in Figure 5.1, the minimum and maximum
allowable head, and the tank diameter are physical data necessary to describe the tank.
The initial head is treated as a fixed grade node. The model will subtract or add volume,
and thus head, to the tank as dictated by the calculated flow rate through the connecting
pipe. The flow in the pipeline to the tank will be shut off if the tank empties or becomes
totally full. Whenever flow conditions allow, the tank will go back on-line. A subroutine
is introduced in the model that simulates water surface level in such tanks at the end of
each time step.
5.3 Internal Components
5.3.1 Minor Losses
Minor losses occur when fluid flow through appurtenances in pipelines. A minor
loss coefficient for components, typically valves, can be input for any pipe. The common
form for the relation representing minor losses is:
dhi = 1(„; Qm (5.3.1)
where
dhi = minor head loss in pipe i
K, = minor loss coefficient for valve(s) in pipe i
Q = flow rate in pipe i
m = minor loss exponent (typically 2)
67
D
y
Hmax
Hmin
D = Tank diameterHmax = Maximum allowable water surface elevationHmin = Minimum allowable water surface elevation
Figure 5.1. Variable Level Tank Setup
68
In this study, the minor loss constant is simply added to the friction-loss term in the head
loss-flow equations. The minor loss equation is of the same form as the friction loss
formula discussed in Chapter 3.
5.3.2 Check Valves
Check valves act in the same manner as in the existing steady-state analyses and
EPS. They allow pipe flow to occur in only one direction. These valves may switch
between open and closed condition during a temporal simulation. Valve shut-off has not
been coded in this study.
5.3.3 Pumps
A pump adds energy to water and can be included in any line of the pipe system.
The characteristic of a pump can be described from pump curve data (Wood 1980). An
exponential curve can be fit to this data to obtain a pump characteristic curve of the form:
Ep = h, - CV (5.3.2)
Following Wood (1980), the developed computer program determines the coefficient C
and exponent n for this curve from the pump shut-off head, h1, and two additional points
of operating data (head-discharge) input for this purpose. Figure 5.2 depicts this
representation. The data points are shown along with the curve of the form of Equation
(5.3.2) which passes through these data points. The procedure for determining C and n is
illustrated on the next page with an example. Pump shut-off has not been coded in this
study.
Ep = A - SQConstant Slope
QQI
Shut-off Head (hl)
t
i
t
' Normal Operating Range 1g1
g
1
t1
Figure 5.2. Pump Operation Characteristic Curve
69
70
EXAMPLE OF OBTAINING A CHARACTERISTIC
PUMP CURVE FROM PERFORMANCE DATA (taken from Wood, 1980)
A pump head (Ed, flow rate (Q) relation is used of the form:
Ep = h, - CQ" (a)
where C and n are determined by passing the curve through (13.2 , Q2) and (n3 , Q3).
The constants are computed as
n = log [(h 1 -h3)/(h 1 -h2)] / log (Q 3/Q2) (b)
and C= (h, -112) / Q211 (C )
This expression holds in range 0 Q Q3. Above Q3 the characteristic is extended at aconstant slope (as shown in Fig. 4.2) equal to the slope of Equation (a) evaluated at Q =Q3*
For Q> Q3 the characteristic has the form:
Ep =A+SQ (d)
where
S= - nCQ,' (e)
A = h3 - S Q3 (f)
An example of this characteristic follows for the data below:
Shut-off head, 11 1 = 200 ft.
Second point: h, = 180 ft. Q2 = 2 cfs
Third point: h3 = 150 ft. Q3 = 4 cfs
From Equation (b), n = 1.322 and from Equation (c ), C = 8.000
Therefore,
= 200 - 8 Q' 322 for 0 � Q � 4 cfs
For the range Q > 4 cfs, the following holds. From Equation (e),
S = - 16.53 and from Equation (f), A = 216
Thus, ;= 216- 16.53 Q for Q >4 cfs
71
The exponential relation given in Equation (5.3.2) represents a pump very well
between zero flow and the third data point (h3 , Q3) but is not suitable for negative flows
and may not be suitable for flows in excess of Q3. In order to satisfactorily handle this,
the computer program is designed to do the following:
1. A normal pump design is to include a check valve downstream of a pump. The check
valve closes if pressure conditions cause flow reversal through the pipe. In these
conditions the pump is not adequate to overcome the system grade caused by other
factors, and the pump as described will be unable to operate.
2. If the solution indicates that the pump is operating at a flow rate above the third
operating point (Q,) then it operates on a straight line described by Ep = A + S Q
where the slope is the same as given by Equation (5.8.1) at Q = Q3 . The computer
program determines the values of A and S as described on the previous page. This
representation gives a characteristic which is more realistic than Equation (5.8.1) for
Q > Q3*
5.4 Conclusions
In summary, all of the network boundary conditions and internal components in
this dynamic model are in the same form as those in the existing steady-state models.
The basic difference is the possible time variation of demands, pump operation, and water
surface elevations in variable-level tanks. The boundary conditions are introduced in
subroutine forms in the developed computer program. This provides flexibility in
72
possible future updates of the model. Moreover, it is easy to understand the basic theory
behind such special conditions in hydraulic water distribution networks.
73
CHAPTER 6
DEVELOPMENT OF THE NETWORK MODEL
6.1 Introduction
The objective of this study is the development of an efficient, reliable algorithm
for the analysis of complex water distribution networks in the gradually varied transient
state. This goal is accomplished in three stages:
1. Derivation of mathematical model,
2. Development of a procedure to solve the adopted mathematical model, and
3. Selection of a convenient representation for the input data needed by the
model.
Chapters 3 through 5 developed the steady-state and dynamic gradient algorithm
for fluid flow in closed conduits, and the equations describing the typical network
boundary conditions. Thus, these three chapters have satisfied the first stage of the
computer program development with the introduction of a full mathematical description
of a hydraulic network. In addition, a recursive Newton-Raphson algorithm presented in
Chapter 3 fulfills the requirement for the second stage of the development.
To the author's knowledge, the use of the gradient algorithm for dynamic analysis
of water distribution networks has not been previously completed. Thus, the main
74
concern of the third stage in development is the formulation of procedures and data input
structure that will allow the solutions developed in the first two stages to be efficiently
implemented.
The program must be general --- with the ability to solve a wide variety of
systems. The organization of the input data should allow the calculation of the final
solution and still keep the input requirement of the program at a bare minimum. The
implementation of the solution procedures previously presented is described in this
chapter.
6.2 Network Representation
After reliability, the most important function of computer representation of water
distribution networks is for it to accurately describe the hydraulic system while requiring
a minimal amount of input data. Unlike network water-hammer analysis, the model
developed in this study requires no more input data than that required by the available
steady-state models. To simulate the system, the following information must be supplied
to the model:
1. System data:
a. Option for dynamic or steady state analysis
b. Flow units (SI or English), determined by the gravitational constant used
c. Number of pipes
75
d. Number of nodes
e. Option to print out all calculations or just the summary of nodal heads and
pipe flows
f. Option to change the maximum number of iterations allowed
g. Option to change the relative accuracy for convergence (default value is
0.0001)
h. Option to use Darcy-Weisbach or Hazen-Williams friction formula
i. Option to allow non-consecutive nodal numbering
2. Pipe line data:
a. Check valve
b. Upstream node number
c. Downstream node number
d. Line length
e. Inside pipe diameter
f. Friction coefficient (Hazen-Williams or Darcy-Weisbach)
g. Total grade head for pipes connecting to a fixed grade node
h. Pipe number as required by non-consecutive numbering
3. Node (junction) data:
a. External demand (+ outflow, - inflow)
b. Elevation
c. Node number
4. Dynamic data:
a. Total analysis time (sec), and
b. Time period for calculations (At)
5. Pump data (if any):
a. Number of pumps in the network
b. Pipe number in which pump is located
c. Shut-off head
d. Two points (h,Q) on operating curve
6. Variable tank data (if any):
a. Number of tanks in the network
b. Pipe number connecting to variable level tank
c. Maximum allowable water surface elevation
d. Minimum allowable water surface elevation
e. Tank diameter
76
77
7. Valve data:
a. Number of valves in the network
b. Pipe number in which valve is located
c. Valve coefficient (KJ
8. Demand function (if applicable):
Supplied in the program subroutine.
6.3 Model Formulation
The gradient algorithm developed by Todini (1987) was adopted for the initial
steady-state analysis. Ease of model set up (pipe connections), and smaller number of
equations with apparent stability (Todini 1987) for steady-state were the two reasons for
adopting the algorithm. Redundant work was saved by coupling the dynamic model with
this steady-state model. The coding for the steady-state analysis was also programmed
(in FORTRAN 77) by the author. The input data is read into the program via the normal
input statements. After the initial values of nodal heads (h) and flow rates in pipe (Q) are
obtained, the analysis is transferred to the dynamic algorithm. After performing a
specified number of iterations per time step the results are sent to an output file. A
stopping criteria based on desired tolerance is taken into account
The stopping criteria and program FLOWCHARTS are presented in following
pages.
78
6.4 Stopping Criteria
The following convergence scheme is used as a stopping criteria:
t-1-itQ
t+t _ t-(4.4-11 ÷ Qtk+,At > CLOSR (6.4.1)
where
Q t = Flow at previous iteration step at time t+ At
rit+At = Flow at current iteration step at time t+ AtV k '+1
CLOSR ---- desired tolerance (default is 0.0001)
Iterations will be performed as long as the above relation is true. Otherwise, the program
will terminate with the indication of convergence.
STARTk' = 0
CALL NPUTRead in data
CALL SETUPFSetup fixed matrices
CALL SOLVESet iteration#
CALL MULTMXSetup variable matrices& perform computations
CALL SETALLCheck convergence criteria
Is Convergence Achieved?
I I I Update Flow & Head I I Print results I
I I I
YES
k' = k' + 1Set iteration step
STOP
Figure 6.1. Flowchart (Steady-State)
79
CALL TLEVEL & PUMPUpdate WSEL & hp
Print Results
80
STARTk' = 0, t = 0
CALL INPUTRead in data
CALL SETUPFSetup fixed matrices
CALL SOLVESet iteration#
CALL MULTMXSetup variable matrices& perform computations
CALL SETALLCheck convergence criteria
N 0 l Is Convergence Achieved? y E
Update Flow & Head
k = k' + 1Set iteration step
nn••nITIIIn
t=t+dtSet time step
STOP
Figure 6.2. Flowchart (Unsteady-State)
81
CHAPTER 7
MODEL VERIFICATION AND SENSITIVITY
7.1 Introduction
This chapter summarizes the results and comparisons. This thesis has considered
the problem of predicting the dynamic response of a water distribution network to
changes in daily demands. Procedures have been presented that conveniently represent
the topology of such networks. The chapter concerns the accuracy of the Gradient
Algorithm in case of different operational conditions. The task is divided into two
sections:
1. Model Verification
2. Model Sensitivity
Appropriate figures are presented with brief discussion to support the accuracy of
the developed model.
7.2 Model Verification
Test 1
Holloway (1985) applied his dynamic surge model to analyze the head-flow
profile for the network represented in Figure 7.1. It consists of 48 pipes, 30 nodes, 4
fixed-grade reservoirs and two fluctuating nodal demands. The network is hi-axially
symmetric and thus, for the same nodal demands at any time, the flow rates in all pipes
82
are equal. Nodes 29 and 30 have an initial demand of 4 cfs, and this demand is subjected
to the following factor (Figure 7.3):
Demand Factor = 0.6 sin(wt) + 1
where
w = 5.8178E-4
t = time (seconds)
The network is analyzed by the Gradient Method for a period of 3 hours to compare with
results from Holloway's Dynamic Model. The results of head and flow profile are
plotted in Figure 7.4 and 7.5.
Figure 7.4: Illustrates the head profile at node 26 of the network. The model was run
at a time increment of At (or dt) — 120s to get a near perfect agreement between the two
models. With the fluctuating nodal demand, as demand is increased by the appropriate
factor, hydraulic head decreased. In time, head started to increase as nodal demand
decreased.
Figure 7.5: Illustrates the flow profile for all pipes (due to topological symmetry) in
the network. Once again, a perfect match is observed. The pattern of the profile
corresponds to the head profile in a way that as head decreased, flow rate in all pipes
increased and vice versa.
Figure 7.6 - 7.7: Illustrates the variation in head and flow with change in time step.
AH 4 Reservoirs at 1500' I
All Pipes are 3000' Long I
83
4 cfs
4 cfs
(D,
D =10"f=0.030
D =12"f=0.025
D =14"f=0.020
Figure 7.1. Network A (taken from Holloway, 1985)
AH Pipes are 3000' Long
4 cfs
All 4 Reservoirs at 1500'
4 cfs
84
Figure 7.2. Network B
Demand Factor vs Time
0
0 4 8 12 16 20 24
time (hr)
1
demand factor = 0.6 sin(wt) +1
85
Figure 7.3. Demand Factor for Networks A and B
0 0.5 1 1.5 2 2.5 3
1500
1450
1400
1350
1300
1200
1150
1100
1050
1 000
Head vs Time (Node 26)dt = 120 s
time (hr)
Dynamic A Gradient Algorithm
86
Figure 7.4. Comparison of Calculated Heads for Network A
Flow vs Time (All Pipes)
dt = 120 s3.5
0.5 —
0 0.5 1 1.5 2 2.5 3
time (hr)
Dynamic p Gradient Algorithm
Figure 7.5. Comparison of Calculated Flows for Network A
87
iIII12.5 3
timl*W1r) 20 0.5 1
1500
1450 —
1400 —
1150 —
1100 —
1050 —
1000
Head vs Time(node 26)
I --*— dt=360s -At- dt=240s —e— dt=120s
88
Figure 7.6. Head Profile for Varied Time Step in Network A
1 --À—dt=240s —e—dt=120s
89
Figure 7.7. Flow Profile for Varied Time Step in Network A
90
Test 2
As a second attempt to verify the accuracy of the Gradient Algorithm, the network
in Figure 7.1 is modified as presented in Figure 7.2. The first half of the original
symmetric network is presented. This network is still symmetric and equal flow rates are
expected in all pipes for equal demands at nodes 9 and 10. The network consists of 16
pipes, 10 nodes, 4 fixed-grade reservoirs. Nodal demands are factored as in Test 1. The
model was run for a time increment of At = 400s and the head-flow pattern was observed.
These observations are presented in Figures 7.8 through 7.10. As observed previously,
for a decrease in nodal head with higher demand, and increase in flow rates is observed.
This 3 hour simulation further verifies the stability of the model regardless of the network
size.
1500
Head vs Time (Node 2)dt = 400 s
91
1492 —
1490
0 0.5 1 1.5 2 2.5 3
time (hr)
Gradient Algorithm
Figure 7.8. Calculated Head (node 2) for Network B
Head vs Time (Node 7)dt = 400 s
0 0.5
1
1.5 2 2.5
3
time (hr)
Gradient Algorithm
Figure 7.9. Calculated Head (node 7) for Network B
92
Flow vs Time (All Pipes)
dt = 400 s
Gradient Algorithm
93
Figure 7.10. Calculated Flows for Network B
94
Test 3
Onizuka (1986) presented a system dynamics approach to pipe network analysis.
Network C is the representation of one of the two networks studied by Onizuka. The
network consists of 9 pipes, 3 fixed-grade nodes, 1 variable-level tank and 2 valves. The
valve coefficients are varied linearly with time from 1 to 0.04 in 360 seconds and
therafter are fixed constant with time. Dynamic response from this valve throttling is
plotted for the variable-level tank and two pipes in Figures 7.12 and 7.13. Onizuka
further studied the case of networks powered by pump which is referred herein for future
work. A time step of 1 second is used.
FGN
95
—1>÷- Valve in line
Figure 7.11. Network C (taken from Onizuka, 1986)
WSEL vs Time
96
45
42.5 -
o o 0
37.5 -
35
0 200
400
600 800
time (sec)
-e-WSEL
Figure 7.12. Head Profile for Network C
How vs Time
2
1.8
1.6 —
1.4 —
0 200 400
time (sec)
600 800
—A--Q1 —e— Q5
97
Figure 7.13. Flow Profile for Network C
98
Test 4
The network presented in Figure 7.14a is a modified version of what was analyzed
by Onizuka (1986). It consists of 7 pipes, 4 nodes and 1 fixed-grade reservoir. The goal
is to simulate the network using the Gradient Algorithm for different values of At. For a
step demand function (Figure 7.14b) the variation in head and flow patterns are
investigated. The author's interest is in the time it takes for the head or flow patterns to
reach the steady-state values as the demand function is varied in time; before getting back
to its steady-state form.
Figures 7.15 - 7.18: Illustrate head and flow profile for Network D. The model was run
for varying time increments of At = 120s, 300s, 600s and 900s. For a step-increase in
demand between 6-12 hours during simulation, a consistent drop in head is observed for
all the rims. Corresponding to the decrease in the head values, the flow rates increased.
As the time increment At is increased, the steady-state condition was reached in a longer
period of time. The analysis verifies, a change in At can considerably impact the estimate
of time the time to reach steady-state conditions.
99
I FGN I
q4
q3
q (crns) t
00.6.4 1- 1
I I 1 )1i-
6 12 24t (hr)
Figure 7.14. (a) Network D
(b) Applied Demand Function
Head vs Time(node 2)
90
16 20 241284
85
80
75
65
60
55
50
0
time (hr)
I —•—dt=900s —A— dt=600s —e—dt=300s —B—dt=120s
100
Figure 7.15. Head Profile (node 2) for Network D
Head vs Time
(node 5)
time (hr)
-4— dt=900s —ik— dt=600s —e—dt=300s --a— dt=1 20s
101
Figure 7.16. Head Profile (node 5) for Network D
Flow vs Time(pipe 2)
0.2
0.19 —
0.18 —
0.17 —
0.13
0.12
0.11 —
0.1
0 4 8 12 16 20 24
time (hr)
—•—dt=900s —A—dt=600s —e—dt=300s —s—dt=120s
Figure 7.17. Flow Profile (pipe 2) for Network D
102
103
0.55
0.5
0.45
V')E(.)
ô4-
0.4
0.35
0.3
0
4 8 12 16
20
24
time (hr)
--4- d t = 9 0 0 s —A— dt=600s —e— dt=300s —•— dt=120s
Figure 7.18. Flow Profile (pipe 7) for Network D
104
Test 5
This test refers to Network E presented in Figure 7.19a. This is a modified
version of Network D in Figure 7.14 in that, a variable level tank is added to observe the
hydraulic response of the network. The goal is to observe whether the model is sensitive
enough to readjust hydraulically (in terms of nodal mass balance etc.) with the fluctuation
of water surface level in the tank. This test is not to control the water surface level in the
tank over a specific time period, but it is yet another hydraulic verification of the Gradient
Algorithm. For a relatively smaller diameter tank the variation in nodal heads is expected
to be less since water surface elevation in tank fluctuates faster than in the case of larger
diameter tanks. Head variation is observed to be larger in the case of large diameter tanks
in the system. Flow rates are expected to vary according to the nodal head fluctuations.
A time step of 960 seconds is used.
Figures 7.20 - 7.25: Two simulations are performed. One with a tank diameter of 10m
and the other with a tank diameter of 12m. The maximum and minimum allowable water
surface elevation is 70m and 30m, respectively. The fixed-grade elevation is 50m The
nodal demands are subjected to the demand function presented in Figure 7.19b. For a
gradual increase in the water surface elevation in tank, the head at node 4 (adjoining node
for the connecting pipe) increases as expected and in time it drops as the water surface
elevation starts to drop. The flow variation in pipe 5 (connecting pipe) takes place
accordingly. Since the variation in flow rate is very small (in cubic meters per second),
enlarged scale plots are presented along with the original scale ones.
FGN
12
24t (hr)
Figure 7.19. (a) Network E
(b) Applied Demand Function
105
70 —t
65 —I
60
55 I
50 —
75
Water Surface Elevation vs Timetank diameter D = 10m
106
45
o 3 6 9 12 15
time (hr)
Figure 7. 20. WSEL Profile (D=10m) for Network E
100
-c
E0co
40
60a) 50
70
-
90 180
30 —
20
Head vs Time (Node 4)tank diameter D = 10 m
107
0 3 6 9 12 15
time (hr)
Figure 7.21. Head Profile (node 4) at D=10m for Network E
1
4.6 7.6 10.6 13.6
time (hr)
4.5
3
1.5
-1.5
Flow vs Time (Pipe 5)tank diameter D = 10 m
o 3 6 9 12
15
time (hr)
108
0.06
0.04 —
-,-,-, 0.02 —E(.) 0
o-..= -0.02
-0.04 —
-0.06
1.6
Flow vs Time (Pipe 5, Enlarged Scale)tank diameter D = 10 m
Figure 7.22. Flow Profile (pipe 5) at D=1 0m for Network E
75
Water Surface Elevation vs Time
tank diameter D = 12 m
50
451 1 1
3 6 9 12 15
time (hr)
109
Figure 7.23. WSEL Profile (D=12m) for Network E
120
Head vs Time (Node 4)tank diameter D = 12 m
110
20
0 3 12
.00111•11•1111n1
15
Figure 7.24. Head Profile (node 4) at D=12m for Network E
Flow vs Time (Pipe 5)tank diameter D = 12 m
111
-1
2
0 3 6 9 12 15
time (hr)
0.1
0.05
0 —Eo
o
-0.05
-0.15
-0.2
1.6
Flow vs Time (Pipe 5, Enlarged Scale)tank diameter D = 12 m
4.6
7.6 10.6
time (hr)
13.6
Figure 7.25. Flow Profile (pipe 5) at D=12m for Network E
112
Test 6
A pump is included in pipe 1 of Network D in Figure 7.14. The objective is to
simulate the system for 24 hours with the demand function previously used, and to
observe the variation of flow and pump head. It is seen in Figures 7.26 and 7.27 that as
the flow in pipe 1 started to increase with increasing demand, the pump head dropped
according to the Pump Curve Equation Ep = hl - Cq. As the demand dropped, the pump
head profile shows the corresponding increase. Since the fluctuation is confined within a
narrow range of values, the pump head profile is presented in enlarged scale.
The fixed-grade head is 50m, and the pump data in Appendix E provides the
points on the pump characteristic curve. A time step of 900 seconds is used. The
computer algorithm can thus successfully solve this problem.
2.14
2.12
2.1
---co 2.08Eo 2.06
a 2.04
2.02
2
1.98
Flow vs Time (pipe 1)dt = 900 s
113
0 3 6 9 12 15
18 21
24
time (hr)-
Figure 7.26. Flow Profile (pipe 1) for Network D with Pump in Pipe 1
Pump Head (Ep) vs Time(Enlarged Scale)
Pump Head (Ep) vs Time
60
50
f40—
30 —
E 20 —=o-
10 —
0
3 6 9 12 15 18 21 24
time (hr)
1.5 4.5 7.5 10.5 13.5 16.5 19.5 22.5
time (hr)
1J4
Figure 7.27. Pump Head Profile for Network D with Pump in Pipe 1
115
7.3 Model Sensitivity
Model sensitivity analysis was performed on Network A presented in Figure 7.1.
In both cases, the network parameters are varied (± ) to observe how the piezometric
heads and flow rates vary at a particular time during simulation. A time increment of At
= 120s was used for a 3 hour simulation of each network. Sensitivity plots are obtained
form data collected at t = 1 hour. Figures 7.28 through 7.31 illustrate the results. On the
plots, hL(0), D(0) etc. refer to the initial head loss and diameter (as an example) obtained
form unsteady simulations with initial steady-state heads and flow rates. The hL, D etc.
refer to the values obtained after changes in the network parameters. Table F-9
summarizes the sensitivity analysis results.
The variation of heads and flow rates based on the Darcy-Weisbach head loss
equation is presented here for better understanding of the plots. The Darcy-Weisbach
formula states:
h, = (fl_ID) . V2/2g (7.1)
In general, following mathematical relations can be drawn from the above equation:
(i) h, a 1/D
(ii) h, a f, L
(iii) h, a 1/h ; where h = pressure head
(iv) q a 1/h ; where q = nodal demand
116
The sensitivity analysis plots correspond to one or more of the above mathematical facts.
It is also to be noted that a node, at the end of a pipe line that connects to a fixed-
grade reservoir, has a constant source of flow and is quite insensitive to network
parameter changes. Furthermore, changes in the diameters or lengths of pipes are
expected to affect the nodes that are located closer to the pipes than the ones far away
from them. An increased demand is expected to lower the heads at the nodes and a
decrease in demand should increase the heads. Head loss is increases with decreasing
head. Also, an increase in the fixed-grade head is expected to increase the nodal heads.
The plots in Figures 7.28 through 7.31 illustrate the above facts.
1.11.050.95
1.4
1.3
1.2
EDT, 1.1
•c
0.9
0.8
0.70.9 1
DID(0)
Sensitivity Analysis+/- %D (All Pipes, @ t = 1 hr)
117
Node 2 71: Node 25 =1 - Node 26
Figure 7.28. Sensitivity Analysis (± %D) for Network A
1.3
1.2
1.1
0.9
0.8
0.7
EC
Sensitivity Analysis+1- %L (All Pipes, @ t = 1 hr)
118
1
1.2
1.4
1.6
UL(0)
Node 2 Node 251= Node 26
0.4
0.6
0.8
Figure 7.29. Sensitivity Analysis ( ± %L) for Network A
Sensitivity Analysis+1- %f (All Pipes, @ t = 1 hr)
119
1.15
1.1
1.05o
-S 1
0.95
0.9
0.850.7
0.8
0.9
1
1.1
1.2
1.3
f/f(0)
Node 2
Node 25 Node 26
Figure 7.30. Sensitivity Analysis (± %f) for Network A
1.6
1.4
1.2
0.6
0.4
Sensitivity Analysis+1- %q (nodal consumption)
120
1
1.2
1.4
1.6
q/q(0)
-÷E,— Node 2 Node 25 Node 26
0.4
0.6
0.8
Figure 7.31. Sensitivity Analysis ( ± %q ) for Network A
121
7.4 Conclusions
Successful completion of Model Verification and Sensitivity leads to the
conclusion that the Gradient Algorithm developed herein provides stable hydraulic
results. Any size water distribution network can be simulated under slow-transient
conditions. The results have been presented to support different operating conditions.
Each condition provided distinct patterns for head and flow profiles. This was obtained
without any major computational difficulties.
The linearized friction term approximation and the linearized minor loss term
yields satisfactory results. The task of analyzing gradually varied flows in water
distribution networks can thus be accomplished efficiently.
122
CHAPTER 8
CONCLUSIONS
The Gradient Method and the Newton-Raphson Solution Technique have been
successfully applied to the analysis of gradually varied unsteady flow in water
distribution networks. It has been shown that, in order to find the solution to a system of
equations describing the network flow problem, the application of the Newton-Raphson
Solution Technique leads to an extremely convergent scheme. Such conclusion is valid
in the case of both unknown piezomefric heads and unknown pipe flows. The scheme,
which requires an iterative solution of a system of linear equations, compares favorably
with the linear theory and the loop Newton-Raphson procedures (Todini, 1987).
Practical application of the scheme, which can simulate looped and open networks
at the same time, are affected neither by the choice of an initially guessed solution nor by
the complexity of the network. Implementation of the Gradient Method on personal
computer enlightens its flexibility and versatility regardless of the network size and data
structure.
The overall conclusions that can be drawn from this study are:
1. The proposed Gradient Method is flexible in the sense that it does not require a loop
or path definition, as in the cases of the simultaneous path adjustment and the linear
theory methods. Thus, computational cost may be reduced to a minimum.
123
2. The lumped-system (lumped fluid inertia) approach investigated by Holloway (1985)
is an acceptable method for the analysis of the typical gradually varying network flow
conditions.
3. The Recursive Newton-Raphson Algorithm developed herein is efficient and
accurate.
4. The linearized approximation for the head loss (h f) term, and minor loss term (IQ
yields satisfactory results when compared with Holloway's (1985) work.
5. Development of an efficient computer code in FORTRAN 77 completes the task of
analyzing water distribution systems over daily gradually varied flow conditions.
Accuracy and stability of the Newton-Raphson Solution Technique enhanced the
numerical analysis.
Future Work
This study sets the path for future advancement in modeling water distribution
networks. Following are a few tasks that can be implemented to enhance the application
of the model developed herein:
1. Study the effect of variation in demand as function of pressure .
2. Investigate the effect of varying time step (At) as function of change in flow rate
(AQ).
3. Couple the developed model with an unsteady water quality model in water networks.
APPENDIX A
124
LIST OF SYMBOLS
APPENDIX A
LIST OF SYMBOLS
Symbol Description Dimension
A cross-sectional area [LI
D pipe and tank diameter [L]
dh change in piezometric head [L]
g gravitational acceleration [L/T1
h piezometric head [L]
hf friction loss [L]
hp(or, Ep) pump head [L]
k' iteration step
K constant in friction formula
L length of conduit [L]
cl nodal consumption/demand [L3/T]
Q flow rate in conduit [L3/T]
t time [T]
At time increment [T]
125
APPENDIX B
126
LIST OF VARIABLES IN SOURCE CODE
APPENDIX B
LIST OF VARIABLES IN SOURCE CODE
Variables are listed as they appear in the program subroutines:
1. Subroutine INPUT
Variable Description
AR (ne) cross-sectional area of pipes (real)
C (ne) Hazen-Williams roughness coefficient (real)
D (ne) diameter of pipes (real)
DT time increment (integer)
FR (ne) Darcy-Weisbach friction factor (real)
GR gravitational acceleration (real)
H (nn) piezometric head (real)
HFGN (ne) fixed-grade reservoir head (real)
IlFGN (nnn=nn+nfgn) fixed-grade reservoir head read in specific format (real)
ITMAX maximum allowable number of iterations (integer)
I (ne) starting node for each pipe (integer)
J (ne) ending node for each pipe (integer)
127
128
JO (ne) starting node to set up matrix [ INC (ne,nnn) ] (integer)
Ji (ne) ending node to set up matrix [ INC (ne,nnn) ] (integer)
KO (ne) constant in friction formula (real)
L (ne) length of pipes (real)
M exponent for friction formula (real)
NE number of elements (pipes) in a network (integer)
NN number of nodes in a network (integer)
NFGN number of fixed-grade nodes in a network (integer)
NNN nn + nfgn (integer)
PI constant (real)
TMAX maximum time of simulation (integer)
TS time step number (integer)
Q (ne) flow rate (real)
Z (nn) node elevation (real)
2. Subroutine SETUPF
Variable Description
AHED (ne,l) storage vector for [ INC (ne,rum) . HED (nnn,l) ]
129
A0h0 (ne, 1) matrix [ A m h, ]
B (ne,ne) diagonal matrix [ N' ] = [ M- ]
DEM (nn, 1) storage vector for demand, QD (nn)
FLOW (ne,l) storage vector for flow rate, Q (ne)
HED (nnn,l) storage vector for fixed-grade head, HFGN (nnn)
HI' (nn, 1) storage vector for piezometric head, H (nn)
ICON (ne,nn) incidence (connectivity) matrix [ A i , . At/2 ]
ICONT (nn,ne) transpose of the incidence matrix [ A2 , = A, 2T . At/2 ]
ICONI (ne,nn) Incidence matrix [ Al2 ]
'CONTI (nn,ne) transpose of incidence matrix [ A.,, ]
INC (ne,nnn) R.H.S incidence matrix obtained from JO (ne) and JI (ne)
QAG (ne, 1) storage vector for (L/gA) terms
3. Subroutine MULTMX
Variable Description
A (ne,ne) diagonal matrix [ A„ - ' ]
C (ne,nn) storage matrix for [ A (ne,ne) . ICON (ne,nn) ]
D (nn,ne) storage matrix for [ ICONT (nn,ne) . B (ne,ne) ]
130
E (nn,nn) storage matrix for [ D (nn,ne) . C (ne,nn) ]
F (ne, 1) storage vector for [ A (ne,ne) . A0h0 (ne, 1) ]
G (ne, 1) storage vector for [ F (ne, 1) + FLOW (ne, 1) ]
H (nn,l) storage vector for [ D (nn,ne) . G (ne,l) ]
P (nn,l) storage vector for [ ICONT (nn,ne) . FLOW (ne,l) ]
Or, storage vector for [ ICONTI (nn,ne) . Flow (ne,l) ]
PP (nn,l) storage vector for [ DEM (nn,l) - P (nn,l) ]
R (nn,l) storage vector for [ H (nn,l) + PP (nn,l) ]
RESH (nn, 1) piezometric head at the end of each time step
4. Subroutine FLOWCALC
Variable Description
AH (ne, 1) storage vector for [ ICON (ne,rm) . RESH (nn, 1) ]
AHA (ne,l) storage vector for [ AH (ne,l) + A0h0 (ne,l) ]
AHB (ne,l) storage vector for [ BA (ne,ne) + AHA (ne,l) ]
BA (ne,ne) storage matrix for [ B (ne,ne) . A (ne,ne) ]
BF (ne,l) storage vector for [ B (ne,ne) . FLOW (ne,l) ]
BFQ (ne,l) storage vector for [ FLOW (ne,l) - BF (ne,l) ]
131
QRES (ne, 1) flow at the end of each time step
storage vector for [ BFQ (ne,l) - AHB (ne,l) ]
5. Subroutine TLEVEL
Variable Description
ADJN (nel)
downstream node [J-end] of pipe connected to variable
level tank (integer)
FGNN (ne!)
HMAX (nel)
HMIN (nel)
NEL
fixed-grade node number (nnn#) connecting a pipe to a
variable level tank (integer)
maximum allowable water surface elevation (real)
minimum allowable water surface elevation (real)
number of elements (pipes) connected to a variable level
tank (integer)
SLN (ne!) the pipe# that is/are connected to a variable level tank
(integer)
TD (nel)
tank diameter (real)
6. Subroutine PUMP
Variable Description
H1 (pin) shut-off head (real)
H2 (pin)
H3 (pin)
Q2 (pin)
Q3 (pin)
head at point 2 on pump characteristic curve (real)
head at point 3 on pump characteristic curve (real)
flow rate at point 2 on pump characteristic curve (real)
flow rate at point 3 on pump characteristic curve (real)
132
Ni log [(H1 - H3)/(H1 - H2)]/log [Q3/Q2]
exponent 'n' in Ep = HI - C Qn
ci [HI - H2]/(Q2)N'
coefficient `C' in Ep = H1 - C Q"
Si - NI . Ci. (Q3)- l)
coefficient `S' in Ep = A + SQ
Al H3 - (S1 . Q3)
constant `A' in Ep = A + SQ
7. Valves
Variable Description
KV (nvl) valve loss coefficient (real)
NVL number of valves in the network (integer)
APPENDIX C
SOURCE CODE
133
134
******************************************************************************
• Program NETT (Steady-State)
• This program simulates water distribution systems using the Gradient• Algorithm. The program setup is analogous to the governing Newton-* Raphson Recursive Algorithm presented in Chapter 3.
• The program reads in data from an Input File (free format) and writes• results in an Output File (formatted). Both Input and Output file• names are to be supplied by the user at the execution of the program.
Major computations for HEAD values are performed within programSubroutine MULTMX. Calculated Head values are used to obtain the
• FLOWS in Subroutine FLOWCALC. Intermediate subroutines perform minormatrix calculations. FLOWCHART is included in Chapter 5.
While the program has been succesfully compiled and run on MicrosoftFORTRAN Powerstation, the author accepts no responsibility for itscorrectness.
**************** ************************* *************************************
PROGRAM NETTINTEGER 1(48), J(48), X, Y, W, NE, NN, NR, NC, CNR, CNC, DNR, DNCINTEGER ENR, ENC, FNR, FNCREAL D(48),L(48),C(48),K0(48),H(30),Q(48),AR(48),Z(30),QD(30)REAL HFGN(48),M,GR,PI,FR(48)DIMENSION A(48,48),B(48,48),FLOW(48,1),DEM(30,1),ICON(48,30)DIMENSION AOH0(48,1),ICONT(30,48)PARAMETER (GR=32.2, PI=3.142)CHARACTER*20 FNAMEIN, FNAMOUTWRITE(*, 1 (AW) 'ENTER THE NAME OF YOUR INPUT FILE :'READ(*,! (A)') FNAMEINOPEN(5,FILE=FNAMEIN, STATUS='OLD')WRITE(*, 1 (AW) 1 ENTER NAME OF YOUR OUTPUT FILE :'READ(*,'(A)') FNAMOUTOPEN(6,FILE=FNAMOUT, STATUS='NEW',FORM='FORMATTED')CALL INPUT(I,J,D,L,C,KO,H,Q,Z,QD,AR,HEGN,NE,NN,GR,M,FR,PI)INITIALIZE VARIABLES FOR THE FOLLOWING SUBROUTINESFNC = 1NR = NENC = NNCNR=NECNC=NNDNR=NNDNC=NEENR=NNENC=NNFNR=NECALL SETUPF(I,J,X,Y,W,NE,NN,QD,HFGN,B,DEM,ICON,ICONT,
AOHO,M,NR,NC,FNC,FLOW,Q)CALL SOLVE (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,
* AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M)END
***********************************************************************• Subroutine INPUT• This subprogram reads in data from the Input file (free format).**** * ****** * ************** * *********** * **** * ******* * ********************
SUBROUTINE INPUT(I,J,D,L,C,KO,H,Q,Z,QD,AR,HFGN,NE,NN,GR,M,FR,PI)
135
INTEGER 1(48), J(48), NE, NNREAL D( 48 ),L(48),C(48),K0(48),H(30),Q(48),Z(30),QD(48),HFGN(48),MREAL FR(48),AR(48),GR,PI
READ NE, NN, NFGN, MREAD (5,*) NE, NN, NFGN, MWRITE (6,1317) NE, NN, NFGN, M
1317 FORMAT(///10X,'NUMBER OF ELEMENTS :',I3,/,10X,*'NUMBER OF NODES : 1 ,I3,/,10X,'NUMBER OF FGN :',I3,/,10X,*'EXPONENT FOR FRICTION FORMULA, M :',F7.5,////)
READ DATA OF ELEMENTSREAD (5,*) (I(II), II=1,NE)READ (5,*) (J(II), II=1,NE)READ (5,*) (D(II), II=1,NE)READ (5,*) (L(II), II=1,NE)READ (5,*) (C(II), II=1,NE)READ (5,*) (FR(II), II=1,NE)DO 1890 II = 1, NE
AR(II) = (PI/4.)*(D(II)**2.)1890 CONTINUE
WRITE (6,1891)1891 FORMAT(//16X,'ELEMENT I J D(FT) L(FT) AR(FT^2) FR',/,15X,
*46(1H-))DO 1885 II=1,NEWRITE(6,1893) II, I(II), J(II), D(II), L(II), AR(II),FR(II)
1885 CONTINUE1893 FORMAT(18X,I3,3X,I3,3X,I3,1X,F8.3,1X,F8.2,1X,F8.5,1X,F5.3)
READ Z,H,Q,K,QDREAD (5,*) (Z(II), II=1,NN)READ (5,*) (H(II), II=1,NN)READ (5,*) (QD(II),II=1,NN)WRITE (6,2119)
2119 FORMAT(///20X,'NODE# ELEVATION INIT HEADS DEMAND',/,* 31X,'(FT) 1 ,8X, 1 (FT)',8X,P(CFS)',/,20X,39(1H-))DO 2221 II=1,NNWRITE(6,2220) II, Z(II), H(II), QD(II)
2221 CONTINUE2220 FORMAT (22X,I3,3X,F8.2,5X,F8.2,5X,F7.3)
READ Q, HFGN & SET UP 'KO'=CONSTANT IN D-W OR H-W FRICTION FORMULA]READ (5,*) (Q(II), II=1,NE)READ (5,*) (HFGN(II), II=1,NE)DO 2222 II = 1, NEIF (M .EQ. 1.852) THEN
KO(II) = (4.727/(D(II)**4.87))*L(II)*(1/(C(II)**1.85))ELSE
KO(II) = (FR(II)*(L(II)/D(II)))*(1/(2*GR*(AR(II)**2.)))KO(II) = (FR*L(II))/(12.10*(D(II)**5.))
END IF2222 CONTINUE
WRITE (6,1894)1894 FORMAT(//18X,'ELEMENT KO(II) Q(II) HFGN(II)',/,
*36X,'(CFS)',/,19X,41(1H-))DO 1895 II=1,NEWRITE (6,1896) II, KO(II), Q(II), HFGN(II)
1895 CONTINUE1896 FORMAT(18X,I3,3X,F10.3,3X,F8.2,3X,F8.2)
RETURNEND
************************************************************************
Subroutine SETUPFThis subprogarm sets up the matrices that remain fixed over time.*
************************************************************************
SUBROUTINE SETUPF(I,J,X,Y,W,NE,NN,QD,HFGN,B,DEM,ICON,ICONT,
AOHO,M,NR,NC,FNC,FLOW,Q)INTEGER I(48),J(48),NE,NN,X,Y,W,NR,NC,FNCREAL QD(30),HFGN(48),M,Q(48)DIMENSION B(NE,NE),DEM(NN,FNC),ICON(NR,NC)DIMENSION ICONT(NC,NR),AOHO(NE,FNC),FLOW(NE,FNC)
DEVELOP MATRIX NA-1 (DIAGONAL) NE*NEDO 35 X = 1, NE
DO 30 Y = 1, NEIF (X .EQ. Y) THEN
B(X,Y) 1/MELSE
B(X,Y) = 0.0END IF
30 CONTINUE35 CONTINUE
WRITE OUT MATRIX [NA-1] OR [B]WRITE (6, *)WRITE (6, *) 'MATRIX [N"-1] OR [B]DO 25 X = 1,NEWRITE (6,1822) (B(X,Y), Y = 1, NE)
1822 FORMAT(/1X,12(F5.3,2X))25 CONTINUE
DEVELOP & WRITE MATRIX Q (FLOW): NE*1WRITE (6, *)WRITE (6, *) 'MATRIX [Q] OR [FLOW] :'
Y= 1DO 40 II = 1, NE
FLOW(II,Y) = Q(II)WRITE (6,1824) FLOW(II,1)
1824 FORMAT (/1X, (F8.3))40 CONTINUE
DEVELOP & WRITE MATRIX q (DEMAND): NN*1WRITE (6, *)WRITE (6, *) 'MATRIX [q] OR [DEM]Y= 1DO 42 II = 1, NN
DEM(II,Y) = QD(II)WRITE (6,1825) DEM(II,1)
1825 FORMAT (/1X, (F7.5)42 CONTINUE
DEVELOP CONNECTIVITY MATRIX A(12): NE*NNZERO OUT ALL ELEMENTS & DEVELOP
DO 400 II = 1, NEDO 400 Y = 1, NN
400 ICON(II,Y)=0DO 45 II = 1, NEICON (II,J(II)) = 1IF (I(II) .GT. 0) ICON(II,I(II)) = -1
45 CONTINUEWRITE OUT MATRIX A(12)
WRITE (6, *)WRITE (6, *) 'MATRIX [A(12)] OR [ICON] :'DO 50 II = 1, NEWRITE (6,1826) (ICON(II,Y), Y = 1,NN)
1826 FORMAT(/1X,12(I2,X))50 CONTINUE
DEVELOP TRANSPOSE MATRIX [A(21)] OR [ICONT(NN*NE)]DO 46 X = 1, NNW=XDO 47 Y = 1, NEII = Y
136
ICONT (X,Y) = ICON (II,W)47 CONTINUE46 CONTINUE
WRITE OUT MATRIX A(21)WRITE (6, *)WRITE (6, *) 'MATRIX [A(21)] OR [ICONT]DO 55 X = 1,NNWRITE (6,1828) (ICONT(X,Y), Y = 1,NE)
1828 FORMAT(/1X,12(I2,X))55 CONTINUE
DEVELOP MATRIX A(10)*H(0): NE*1& WRITE OUT
WRITE (6, *)WRITE (6, *) 'MATRIX [A(10)H(0)] OR [AOHO]Y= 1DO 65 II = 1, NE
AOHO(II,Y) = -HFGN(II)WRITE (6,1830) AOHO(II,Y)
1830 FORMAT(/1X,(F8.2))65 CONTINUE
RETURNEND
************************************************************************• Subroutine SOLVE• This subprogram sets up the iteration# and checks convergence• criteria by calling on Subroutine SETALL.************************************************************************
SUBROUTINE SOLVE (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M)
INTEGER NE,NN,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,FNR,FNC,ITMAX,XREAL KO(48),Q(48),MDIMENSION A(NE,NE),ICON(NR,NC),ICONT(NC,NR),B(NE,NE),AOHO(NE,FNC)DIMENSION FLOW(NE,FNC),DEM(NN,FNC),QRES(NE,FNC)PARAMETER (ITMAX=20)CALL MULTMX (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,
FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES)DO 555 X = 1, ITMAXWRITE (*,*) 'ITERATION# =',XCALL SETALL (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,
FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES)555 CONTINUE
WRITE (*,*) 'WARNING: Maximum Iteration Exceeded!!!'RETURNENDSUBROUTINE SETALL (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,
ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES)INTEGER NE,FNC,X,Y,NN,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,FNRREAL Q(48),K0(48),MDIMENSION QRES(NE,FNC),FLOW(NE,FNC),CLOSR(NE,FNC)DIMENSION A(NE,NE),B(NE,NE),ICON(NR,NC),ICONT(NC,NR),AOHO(NE,FNC)DIMENSION DEM(NN,FNC)Y= 1DO 556 X = 1, NE
CLOSR (X, Y) = 0.0001556 CONTINUE
Y= 1DO 557 X = 1, NEWRITE (6,3000) CLOSR(X,Y)
3000 FORMAT (/1X, (F6.4))557 CONTINUE
IF ((ABS(FLOW(NE,FNC) -QRES(NE,FNC)))/(FLOW(NE,FNC)) .GT.
137
*CLOSR(NE,FNC)) THENFLOW = QRESDO 558 II = 1, NEQ(II) = FLOW(II,FNC)
558 CONTINUECALL MULTMX (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,
FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES)ELSESTOP 'STOP: CONVERGED'END IFRETURNEND
************************************************************************
• Subroutine MULTMX• This subprogram performs necessary computations to obtain HEAD *• values. It calls on Subroutine GAUSSJ for matrix inversion.** ** **** * *** * *** * ** * *** * *** * **** ** ******************* * **** * ****** ** *****
SUBROUTINE MULTMX(A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES)
INTEGER NE,NN,NR,NC,CNR,CNC,I,J,K,X,y,DNR,DNC,ENR,ENC,FNR,FNCREAL KO(48),Q(48),MDIMENSION A(NE,NE),ICON (NR,NC),C(CNR,CNC),ICONT(NC,NR)DIMENSION B(NE,NE),D(DNR,DNC),E(ENR,ENC),F(FNR,FNC),AOHO(NE,FNC)DIMENSION FLOW(NE,FNC),G(NE,FNC),H(NN,FNC),P(NN,FNC),DEM(NN,FNC)DIMENSION QRES(NE,FNC)LOGICAL ERRORERROR = .FALSE.
DEVELOP MATRIX A(11)^-1: (DIAGONAL) NE*NEDO 2 X = 1, NE
DO 3 Y = 1, NEDO 4 II = 1, NEIF ((X .EQ. Y) .AND. (KO(II) .NE. 0.0)) THEN
A(II,II) = 1 . 0 /(KO(II) * ((ABS(Q(II)))* * (M- 1)))ELSE
A(X,Y) = 0.0END IF
4 CONTINUE3 CONTINUE2 CONTINUE
WRITE OUT MATRIX [A(11)^-1] OR [A]WRITE (6, *)WRITE (6, *) 'MATRIX [A(11)^-1] OR [A]DO 1 X = 1, NEWRITE (6, 1820) (A(X,Y), Y = 1, NE)
1820 FORMAT (/1X,12(F5.4,2X)/)1 CONTINUE
IF TEST TO MULTIPLY [A(NE,NE)*ICON(NE,NN)]IF (NE .NE. NR) ERROR = .TRUE.IF (NE .NE. CNR) ERROR = .TRUE.IF (NC .NE. CNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 5 I = 1, CNR
DO 10 J = 1, CNCC(I,J) = 0.0DO 15 K = 1, NE
C(I,J) = C(I,J) + A(I,K)*ICON(K,J)15 CONTINUE10 CONTINUE5 CONTINUE
END IFWRITE OUT RESULT OF [A(11)^-1 * A(12)] OR [A * ICON]
WRITE (6, *)
138
139
WRITE (6, * ) 'RESULT OF [A(11)^-1 * A(12)] OR [A*ICON]DO 20 X = 1 ,CNRWRITE (6, 1 000) (C(X,Y), Y = 1, CNC)
1000 FORMAT (/1X ,12(F6.4,2X))20 CONTINUE
IF TEST TO MULTIPLY [ICONT(NN,NE)*B(NE,NE)]IF (NR .NE. NE) ERROR = .TRUE.IF (NC .NE. DNR) ERROR = .TRUE.IF (NE .NE. DNC) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 25 I = 1, DNR
DO 30 J = 1, DNCD(I,J) = 0.0DO 35 K = 1, NR
D(I,J) = D(I,J) + ICONT(I,K)*B(K,J)35 CONTINUE30 CONTINUE25 CONTINUE
END IFWRITE OUT RESULT OF [A(21)*N^-1] OR [ICONT * B]
WRITE (6, *)WRITE (6, *) 'RESULT OF [A(21)*N^-1] OR [ICONT*B]DO 40 X = 1, DNRWRITE (6, 1001) (D(X,Y), Y = 1, DNC)
1001 FORMAT (/X,12(F6.4,2X))40 CONTINUE
IF TEST TO MULTIPLY [D(DNR,DNC)*C(CNR,CNC)] OR[A(21)*N^-1]*[A(11)^-1 * A(12)]
IF (DNC .NE. CNR) ERROR = .TRUE.IF (DNR .NE. ENR) ERROR = .TRUE.IF (CNC .NE. ENC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 45 I = 1, ENR
DO 50 J = 1, ENCE(I,J) = 0.0DO 55 K = 1, DNC
E(I,J) = E(I,J) + D(I,K)*C(K,J)55 CONTINUE50 CONTINUE45 CONTINUE
END IFWRITE OUT RESULT OF [D(DNR,DNC)*C(CNR,CNC)]
WRITE (6, *)WRITE (6, *) 'RESULT OF [D(DNR,DNC)*C(CNR,CNC)]DO 60 X = 1, ENRWRITE (6, 1002) (E(X,Y), Y = 1, ENC)
1002 FORMAT (/X,12(F6.4,2X))60 CONTINUE
IF TEST TO MULTIPLY [A(NE,NE)*AOHO(NE,FNC)] OR[A(11) ^ -1*A(10)H(0)]
IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. FNR) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 65 I = 1, FNR
DO 70 J = 1, FNCF(I,J) = 0.0DO 75 K 1, NE
F(I,J) = F(I,J) + A(I,K)*AOHO(K,J)75 CONTINUE70 CONTINUE
140
65 CONTINUEEND IF
WRITE OUT RESULT OF [A(NE,NE)*AOHO(NE,FNC)]WRITE (6, *)WRITE (6, *) 'RESULT OF [A(NE,NE)*AOHO(NE,FNC)]Y= 1DO 80 X = 1, FNRWRITE (6, 1003) F(X,Y)
1003 FORMAT (/1X, (F9.5))80 CONTINUE
ADD MATRICES [F(FNR,FNC) + FLOW(NE,1)] & PUT INTO G(NE,FNC) DEVELOPED
IN SUBROUTINE 'ADDMX'***********************************************************************
CALL ADDMX (F,FLOW,NE,NN,FNR,FNC,G,E,ENR,ENC,B,A,ICON,AOHO,QRES)IF TEST TO MULTIPLY [D(DNR,DNC) * G(NE,FNC)]
IF (DNC .NE. NE) ERROR = .TRUE.IF (DNR .NE. NN) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 95 I = 1, NN
DO 100 J = 1, FNCH(I,J) = 0.0DO 105 K = 1, DNCH(I,J) = H(I,J) + D(I,K)*G(K,J)
105 CONTINUE100 CONTINUE95 CONTINUE
END IFWRITE OUT RESULT OF [D(DNR,DNC) * G(NE,FNC)]
WRITE (6, *)WRITE (6, *) 'RESULT OF [D(DNR,DNC) * G(NE,FNC)]Y= 1DO 110 X = 1, NNWRITE (6, 1005) H(X,Y)
1005 FORMAT (/1X,(F9.5))110 CONTINUE
IF TEST TO MULTIPLY [A(21)*Q] OR [ICONT(NC,NR)*FLOW(NE,FNC)]IF (NR .NE. NE) ERROR = .TRUE.IF (NC .NE. NN) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 115 I = 1, NN
DO 120 J = 1, FNCP(I,J) = 0.0DO 125 K 1, NR
P(I,J) = P(I,J) + ICONT(I,K)*FLOW(K,J)125 CONTINUE120 CONTINUE115 CONTINUE
END IFWRITE OUT RESULT OF [A(21)*Q] OR [ICONT(NC,NR)*FLOW(NE,FNC)]
WRITE (6, *)WRITE (6, *) 'RESULT OF [A(21)*Q] OR [ICONT(NC,NR)*FLOW(NE,FNC)]:'Y= 1DO 130 X = 1, NNWRITE (6, 1006) P(X,Y)
1006 FORMAT (/1X, (F10.3)130 CONTINUE***********************************************************************
CALL SUBMX (DEM,P,NN,FNC,H,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,QRES)RETURN
END***************** * * * ******* * ****** * ******* * *** ** ****** ***** ** *** *******
• Subroutine ADDMX• Intermediate subprogram to perform minor matrix algebra.************** * ** * *** * *** * * * ******* * ********* * ************ **** *********
SUBROUTINE ADDMX (F,FLOW,NE,NN,FNR,FNC,G,E,ENR,ENC,B,A,ICON,AOHO,QRES)
INTEGER NE,NN,FNR,FNC,I,J,X,Y,ENR,ENCDIMENSION F(FNR,FNC),FLOW(NE,FNC),G(NE,FNC),E(ENR,ENC),B(NE,NE)DIMENSION A(NE,NE),ICON(NE,NN),AOHO(NE,FNC),QRES(NE,FNC)J= 1DO 85 I = 1,NE
G(I,J) = F(I,J) + FLOW(I,J)85 CONTINUE
WRITE OUT RESULT OF [F(FNR,FNC) + FLOW(NE,1)]WRITE (6, *)WRITE (6, *) 'RESULT OF [F(FNR,FNC) + FLOW(NE,FNC)]Y= 1DO 90 X = 1, NEWRITE (6, 1004) G(X,Y)
1004 FORMAT (/1X, (F9.5))90 CONTINUE
RETURNEND
***********************************************************************• Subroutine SUBMX• Intermediate subprogram to perform minor matrix algebra.***********************************************************************
SUBROUTINE SUBMX (DEM,P,NN,FNC,H,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,QRES)
INTEGER NN,FNC,I,J,X,Y,ENR,ENC,NEDIMENSION DEM(NN,FNC), P(NN,FNC), PP(NN,FNC),H(NN,FNC),E(ENR,ENC)DIMENSION B(NE,NE),FLOW(NE,FNC),A(NE,NE),ICON(NE,NN),AOHO(NE,FNC)DIMENSION QRES(NE,FNC)J= 1DO 135 I = 1, NN
PP(I,J) = DEM(I,J) - P(I,J)135 CONTINUE
141
WRITE (6,WRITE OUT RESULT OF [q - {A(21)*Q(K)] OR [DEM(NN,FNC)-P(NN,FNC)]
*)WRITE (6, *) 'RESULT OF [DEM(NN,FNC)-P(NN,FNC)]Y= 1DO 140 X = 1, NNWRITE (6, 1007) PP(X,Y)FORMAT (/ lx, (F7.3)CONTINUE
********** ******************** ******** ********************* *******
CALL ADDMXII (H,PP,NN,FNC,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,QRES)RETURNEND
******************* **** ******************** **** *******************
Subroutine ADDMXIIIntermediate subprogram to perform minor matrix algebra.
***********************************************************************SUBROUTINE ADDMXII (H,PP,NN,FNC,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,
QRES)INTEGER NN,FNC,I,J,X,Y,ENR,ENC,NEDIMENSION H(NN,FNC),PP(NN,FNC),R(NN,FNC),E(ENR,ENC),B(NE,NE)DIMENSION FLOW(NE,FNC),A(NE,NE),ICON(NE,NN),AOHO(NE,FNC)DIMENSION QRES(NE,FNC)J= 1
142
DO 145 I = 1, NNR(I,J) = H(I,J) + PP(I,J)
145 CONTINUEWRITE OUT RESULT OF [{A(21)*N^-1}*{Q(K)+A(11)^-1*A(10)H(0)1)+Eq-{A(21)*Q
} ]WRITE (6, *)WRITE (6, *) 'RESULT OF [H(NN,FNC) + PP(NN,FNC))Y= 1DO 150 X = 1, NNWRITE (6, 1008) R(X,Y)
1008 FORMAT (/1X, (F9.5))CONTINUE
***********************************************************************CALL GAUSSJ (e,enr,enc,r,nn,fnc,B,FLOW,NE,A,ICON,AOHO,QRES)RETURNEND
***********************************************************************
Subroutine GAUSSJUsed to perform matrix inversion.
***********************************************************************SUBROUTINE gaussj(e,enr,enc,r,nn,fnc,B,FLOW,NE,A,ICON,AOHO,QRES)INTEGER enr,enc,nn,fnc,NMAX,NEINTEGER ICON(NE,NN)REAL e(enr,enc),r(nn,fnc),S,RESH(NN,FNC),B(NE,NE),FLOW(NE,FNC)REAL A(NE,NE),AOHO(NE,FNC),QRES(NE,FNC)PARAMETER (NMAX=50,S=-1.)INTEGER i f icol,irow,j,k,1,11,indxc(NMAX),indxr(NMAX),ipiv(NMAX)INTEGER x,yREAL big,dum,pivinvdo 11 j=1,nn
ipiv(j)=011 continue
do 22 i=1,nnbig=0.do 13 j=1,nn
if(ipiv(j).ne.1)thendo 12 k=1,nn
if (ipiv(k).eq.0) thenif (abs(e(j,k)).ge.big)then
big=abs(e(j,k))irow=jicol=k
endifelse if (ipiv(k).gt.1) thenpause 'singular matrix in gaussj'
endif12 continue
endif13 continue
ipiv(ico1)=ipiv(icol)+1if (irow.ne.icol) thendo 14 1=1,nn
dum=e(irow,l)e(irow,1)=e(ico1,1)e(ico1,1)=dum
14 continuedo 15 1=1,fnc
dum=r(irow,l)r(irow,1)=r(ico1,1)r(ico1,1)=dum
15 continueendif
indxr(i)=irowindxc(i)=icolif (e(icol,icol).eq.0.) pause 'singular matrix in gaussj'pivinv=1./e(icol,icol)e(icol,icol)=1.do 16 1=1,nn
e(ico1,1)=e(ico1,1)*pivinv16 continue
do 17 1=1,fncr(ico1,1)=r(ico1,1)*pivinv
17 continuedo 21 11=1,nn
if(11.ne.icol)thendum=e(11,icol)e(11,icol)=0.do 18 1=1,nn
e(11,1)=e(11,1)-e(ico1,1)*dum18 continue
do 19 1=1,fncr(11,1)=r(11,1)-r(ico1,1)*dum
19 continueendif
21 continue22 continue
do 24 1=nn,1,-1if(indxr(1).ne.indxc(1))thendo 23 k=1,nn
dum=e(k,indxr(1))e(k,indxr(1))=e(k,indxc(1))e(k,indxc(1))=dum
23 continueendif
24 continuewrite out the result of inverted matrix 'e'
write (6, *)write (6, *) 'result of inverted matrix Edo 25 x = 1, enrwrite (6,1009) (e(x,y), y = 1, enc)
1009 format (/x,7(f10.4,2x))25 continue
write out the result of [H(k+1)] stored in matrix 'r'write (6, *)write (6, *) 'result of [H(k+1)] stored in matrix (r) by GAUSSJy= 1do 26 x = 1, nnwrite (6, 1010) r(x,y)
1010 format (./lx, (f12.5))26 continue
multiply the result of [H(k+1)] by -1 to take care of sign(s)in the original formulation(s)
j = 1do 27 i = 1, nn
RESH(i,j) = S*r(i,j)27 continue
write out the result of [H(k+1)] with proper sign, stored inmatrix RESH(nn,fnc)
write (6, *)write (6, *)'result of [H(k+1)] with proper sign; RESH(nn,fnc):y= 1do 28 x = 1, nnwrite (6, 1011) RESH(x,y)
1011 format Ulx,(f10.5))
143
144
28 continue***************** * ***** * ***************** * ** * * * ** * *********************
CALL FLOWCALC (B,FLOW,NE,NN,FNC,A,RESH,ICON,AOHO,QRES)returnEND
** * ******** * *** * * * *** * ****** ***** ********* * ******** **** * ***** * *** * ***Subroutine FLOWCALCThis subprogram uses the computed HEAD values to obtain FLOWS. *
***********************************************************************SUBROUTINE FLOWCALC (B,FLOW,NE,NN,FNC,A,RESH,ICON,AOHO,QRES)INTEGER NE,NN,FNC,I,J,K,X,YDIMENSION B(NE,NE),FLOW(NE,FNC),BF(NE,FNC),BFQ(NE,FNC),BA(NE,NE)DIMENSION A(NE,NE),RESH(NN,FNC),ICON(NE,NN),AH(NE,FNC)DIMENSION AOHO(NE,FNC),AHA(NE,FNC),AHB(NE,FNC),QRES(NE,FNC)LOGICAL ERRORERROR = .FALSE.
IF TEST TO MULTIPLY [N^-1*Q(K)] OR [B(NE,NE)*FLOW(NE,FNC)]IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 155 I = 1, NE
DO 160 J = 1, FNCBF(I,J) = 0.0DO 165 K = 1, NE
BF(I,J) = BF(I,J) + B(I,K)*FLOW(K,j)
165 CONTINUE
160 CONTINUE
155 CONTINUEEND IF
WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *)'RESULT OF [N ^ -1*Q(K)] OR [B(NE,NE)*FLOW(NE,FNC)]:'Y= 1DO 170 X = 1, NEWRITE (6, 1012) BF(X,Y)
1012 FORMAT (/1X, (F10.5)170 CONTINUE
CALCULATE [Q(K) - {NA-1*Q(K)] & STORE IN [BFQ(NE,FNC)]J= 1DO 175 I = 1, NE
BFQ(I,J) = FLOW(I,J) - BF(I,J)175 CONTINUE
WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *)'RESULT OF [Q(K)-{N^-1*Q(K)] STORED IN [BFQ(NE,FNC)]:'Y= 1DO 180 X = 1, NEWRITE (6, 1013) BFQ(X,Y)
1013 FORMAT (/1X, (F10.5))
180 CONTINUECALCULATE [N ^-1*A(11)^-1] & STORE IN [BA(NE,NE)]IF TEST TO MULTIPLY [N A -1*A(11)^-1] OR [B(NE,NE)*A(NE,NE)]
IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 185 I = 1, NE
DO 190 J = 1, NEBA(I,J) = 0.0DO 195 K = 1, NE
BA(I,J) = BA(I,J) + B(I,K)*A(K,J)
145
195 CONTINUE190 CONTINUE185 CONTINUE
END IFWRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *) 'RESULT OF [N^-1*A(11)A-1] STORED IN [BA(NE,NE)]DO 200 X = 1, NEWRITE (6, 1014) (BA(X,Y), Y = 1, NE)
1014 FORMAT (/1X,12(F10.5,2X))200 CONTINUE
CALCULATE [A(12)*H(K+1)] & STORE IN [AH(NE,NE)]IF TEST TO MULTIPLY [A(12)*H(K+1)] OR [ICON(NE,NN)*RESH(NN,FNC)]
IF (NN .NE. NN) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 205 I = 1, NE
DO 210 J = 1, FNCAH(I,J) = 0.0DO 215 K = 1, NN
AH(I,J) = AH(I,J) + ICON(I,K)*RESH(K,J)215 CONTINUE210 CONTINUE205 CONTINUE
END IFWRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *) 'RESULT OF [A(12)*H(K+1)] STORED IN [AH(NE,FNC)]Y= 1DO 220 X = 1, NEWRITE (6, 1015) AH(X,Y)
1015 FORMAT (/1X, (F10.5)220 CONTINUE
CALCULATE [{A(12)*H(K+1)1+{A(10)H(0)1] & STORE IN [AHA(NE,FNC)]J= 1DO 225 I = 1, NE
AHA(I,J) = AH(I,J) + AOHO(I,J)225 CONTINUE
WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *) 'RESULT OF [{A(21)*H(K+1)1+1A(10)H(0)1] STORED IN',
' [AHA(NE,FNC)]Y= 1DO 230 X = 1, NEWRITE (6, 1016) AHA(X,Y)
1016 FORMAT (/1X, (F10.5))230 CONTINUE
CALCULATE [N^-1*A11^-1]*[Al2*H(K+1)+A(10)H(0)] & STORE IN [AHB(NE,FNC)]
IF TEST TO DO THE ABOVE MULTIPLICATIONIF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 235 I = 1, NE
DO 240 J = 1, FNCAHB(I,J) = 0.0DO 245 K = 1, NE
AHB(I,J) = AHB(I,J) + BA(I,K)*AHA(K,J)245 CONTINUE240 CONTINUE
235 CONTINUEEND IF
C WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *) 'RESULT OF
' STORED INY= 1DO 250 X = 1, NEWRITE (6, 1017) AHB(X,Y)
1017 FORMAT (/1X, (F10.5)250 CONTINUEC CALCULATE [Q(K+1)] =C [QRES(NE,FNC)]
J= 1DO 255 I = 1, NE
QRES(I,J) = BFQ(I,J) - AHB(I,J)255 CONTINUEC WRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *) 'RESULT OF [Q(K+1)] :'Y= 1DO 260 X = 1, NEWRITE (6, 101 8) QRES(X,Y)
1018 FORMAT (/1X,( F10.5))260 CONTINUE
RETURNEND
146
[N^-1*A11^-1]*[Al2*H(K+1)+A(10)H(0)1',[AHB(NE,FNC)] :'
[BFQ(NE,FNC) - AHB(NE,FNC)] & STORE IN
147
*****************************************************************************• Program NETT (Unsteady-State)
• This program simulates water distribution systems using the Gradient• Algorithm. The program setup is analogous to the governing Newton-• Raphson Recursive Algorithm presented in Chapter 4.
• The program reads in data form an Input File (free fromat) and writes *• results in an Output File (formatted). Both Input and Output file• names are to be supplied by the user at the execution of the program. **• Major computations for HEAD values are performed within program• Subroutine MULTMX. Calculated Head values are used to obtain the• FLOWS in Subroutine FLOWCALC. Intermediate subroutines perform minor *• matrix calculations. FLOWCHART is included in Chapter 5.
• While the program has been succesfully compiled and run on Microsoft *• FORTRAN Powerstation, the author accepts no responsibility for its• correctness.
*****************************************************************************
PROGRAM NETTINTEGER I(12), J(12),X,Y,W,NE,NN,NR,NC,CNR,CNC,DNR,DNCINTEGER ENR,ENC,FNR,FNC,DT,I0(12),JI(12),TMAX,TS,INCR,NNNINTEGER NEL,ADJN(1),SLN(1),FGNN(1),NVL,PLN,PSLN(1)REAL D(12),L(12),C(12),K0(12),H(7),Q(12),Z(7),QD(7),HFGN(9),M,GRREAL AR(12),FR,PI,HMAX(1),HMIN(1),TD(1),TA(1),WSEL(1),KV(12)REAL H1(1),H2(1),H3(1),Q2(1),Q3(1),N1(1),C1(1),A1(1),S1(1),EP(1)DIMENSION A(12,12),B(12,12),FLOW(12,1),DEM(7,1),ICON(12,7)DIMENSION AOH0(12,1),ICONT(7,12),HED(9,1),INC(12,9),ICONI(12,7)DIMENSION ICONTI(7,12),HP(7,1),QAG(12,1),QRES(12,1),RESH(7,1)PARAMETER (GR=9.81, PI=3.142)CHARACTER*20 FNAMEIN, FNAMEOUTWRITE(*,'(AW) 'ENTER THE NAME OF YOUR INPUT FILE :'READ(*,'(A) 1 ) FNAMEINOPEN(5,FILE=FNAMEIN, STATUS='OLD')WRITE(*, 1 (AW)'ENTER NAME OF YOUR OUTPUT'FILE .16READ(*,'(A)') FNAMEOUTOPEN(6,FILE=FNAMEOUT, STACUS :='NEW,FORM='FORMATTED')
'IO' & 'JI' ARE USE6 TO SET UP R.H.S. INCIDENCE MATRIX [INC(NE,NE)]CALL INPUT(I,J,D,L,C,KO,H,Q,Z,QD,HFGN,NE,NN,DT,AR,I0,JI,TMAX,PI,M,
FR,GR,NNN,NEL,ADJN,SLN,FGNN,HMAX,HMIN,TD,TA,NVL,KV,PLN,PSLN,H1,H2,H3,Q2,Q3)
INITIALIZE VARIABLES FOR THE FOLLOWING SUBROUTINES:FNC = 1NR = NENC = NNCNR=NECNC=NNDNR=NNDNC=NEENR=NNENC=NNFNR=NEIF (DT .NE. 0) THENINCR = TMAX/DTEND IFDO 10 TS = 1, INCR
148
WRITE (*,*) 'TIME STEP # =',TSWRITE (6,*)WRITE (6,*) 'TIME STEP # =', TSCALL SETUPF( I,J,X,Y,W,NE,NN,QD,HFGN,B,DEM,ICON,ICONT,QAG,HED,
INC,AOHO,M,NR,NC,FNC,FLOW,Q,DT,AR,L,GR,H,ICONI,ICONTI,IO,JI,HP,NNN,TS)
CALL SOLVE ( A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,DT,AR,L,GR,ICONI,ICONTI,I,J,X,Y,W,QD,HFGN,QAG,HED,INC,HP,H,I0,JI,NNN,QRES,RESH,KV,NEL,SLN,FGNN,HMAX,ADJN,TS)
IF (NEL .NE. 0) THENCALL TLEVEL (NEL,DT,QRES,RESH,HFGN,NE,NN,FNC,SLN,ADJN,FGNN,
HMAX,HMIN,TA,WSEL,Q)END IFWRITE(*,*) DEM(7,1)IF (PLN .NE. 0) THENCALL PUMP (PLN,PSLN,H1,H2,H3,Q2,Q3,N1,C1,A1,S1,EP,QRES,NE,FNC)END IF
10 CONTINUEEND
*************************** * *******************************************
• Subroutine INPUT• This subprogram reads in data from the Input file (free format).*** * ***** ****** *** ** ***** ************ ******* *** ***** *** ***** *** *********
SUBROUTINE INPUT(I,J,D,L,C,KO,H,Q,Z,QD,HEGN,NE,NN,DT,AR,I0,JI,TMAX,PI,M,FR,GR,NNN,NEL,ADJN,SLN,FGNN,HMAX,HMIN,TD,TA,NVL,KV,PLN,PSLN,H1,H2,H3,Q2,Q3)
INTEGER I(12),J(12),NE,NN,DT,I0(12),JI(12),TMAX,NNNINTEGER NEL,1DJN(1),SLN(1),FGNN(1),NVL,PLN,PSLN(1)REAL HMAX(1),HMIN(1),TD(1),TA(1),KV(12)REAL D(12),L(12),C(12),K0(12),H(7),Q(12),Z(7),QD(7),HFGN(9)REAL AR(12),PI,M,FR,GRREAL H1(1),H2(1),H3(1),Q2(1),Q3(1)
READ NE, NN, NFGN, DT, TMAX, M, FR, NEL, NVL, PLNREAD (5,*) NE, NN, NFGN, DT, TMAX, M, FR, NEL, NVL,PLNWRITE (6,1317) NE, NN, NFGN, DT, TMAX, M, FR, NEL, NVL, PLN
1317 FORMAT(///10X,'NUMBER OF ELEMENTS :',I3,/,10X,*'NUMBER OF NODES :',I3,/,10X,'NUMBER OF FGN :',I3,/,10X,*'DT :',I4,/,10X,'TMAX :',I6,/,10X,'EXPONENT FOR FRICTION FORMULA,* M :',F7.5,/,10X,'DARCY-WEISBACH FRICTION FACTOR, FR :',F7.5,/,* lox, 'NUMBER OF ELEMENTS CONNECTED TO VARIABLE HEAD TANKS, NEL :',* I3,/,10X,'NUMBER OF VALVES IN THE NETWORK, NVL :',I3,/,*10X,'NUMBER OF PUMPS IN THE NETWORK, PLN :',I3,////)
READ DATA OF ELEMENTSREAD (5,*) (I(II), II=1,NE)READ (5„*) (J(II), II=1,NE)READ (5,*) (D(II), II=1,NE)READ (5,*) (L(II), II=1,NE)READ (5,*) (C(II), II=1,NE)DO 1890 II = 1, NE
AR(II) = (PI/4.)*(D(II)**2)1890 CONTINUE
WRITE (6,1891)1891 FORMAT(//16X,'ELEMENT I J D(FT) L(FT) C AR(FTA2)',/,15X,
*46(1H-))DO 1885 II=1,NEWRITE(6,1893) II, I( II), J(II), D(II), L(II), C(II), AR(II)
1885 CONTINUE1893 FOR1AT(18X,I3,3X,I3, 3X,I3,1X,F8.3,1X,F8.2,1X,F8.2,1X,F8.5)
READ R.H.S. INCI DENCE MATRIX DATA, 'ID' & 'JI'READ (5,*) (10(11), 11=1, NE)READ (5,*) (JI(II), 11=1, NE)
READ Z,H,Q,K,QDREAD (5,*) (Z(II), II=1,NN)READ (5,*) (H(II), II=1,NN)READ (5,*) (QD(II),II=1,NN) "[only if Subroutine DEMF is not used]"WRITE (6,2119)
2119 FORMAT(///20X,'NODE# ELEVATION INIT HEADS',/,* 31X,'(FT)',8X,'(FT)',/,20X,39(1H-))DO 2221 II=1,NNWRITE(6,2220) II, Z(II), H(II)
2221 CONTINUE2220 FORMAT (22X,I3,3X,F8.2,5X,F8.5)
READ Q, HFGNNNN=NN+NFGNREAD (5,*) (Q(II), II=1,NE)READ (5,*) (HFGN(II), II=1,NNN)DO 2222 II = 1, NEIF (M .EQ. 1.852) THEN
KO(II) = (4.727/(D(II)**4.87))*L(II)*(1/(C(II)**1.85))ELSE
KO(II) = (FR*(L(II)/D(II)))*(1/(2*GR*(AR(II)**2.)))END IF
2222 CONTINUEWRITE (6,1894)
1894 FORMAT(//18X,'ELEMENT KO(II) Q(II) HFGN(II)',/,*36X,'(CFS)',/,19X,41(1H-))DO 1895 II=1,NEWRITE (6,1896) II, KO(II), Q(II), HFGN(II)
1895 CONTINUE1896 FORMAT(18X,I3,3X,F10.3,3X,F8.5,3X,F8.2)
READ PARAMETERS FOR VARIABLE TANK(S) IN THE NETWORK"READ "ONLY IF" THEIR IS A VARIABLE LEVEL TANK"
IF (NEL .NE. 0) THENREAD (5,*) (SLN(II), II=1,NEL)READ (5,*) (ADJN(II), II=1,NEL)READ (5,*) (FGNN(II), II=1,NEL)READ (5,*) (HMAX(II), II=1,NEL)READ (5,*) (HMIN(II), II=1,NEL)READ (5,*) (TD(II), II=1,NEL)
COMPUTE TANK AREA, 'TA' & WRITE OUTDO 10 II = 1,NEL
TA(II) = (PI/4.)*(TD(II)**2.)10 CONTINUE
WRITE (6,*)WRITE (6,*) 'VARIABLE TANK AREADO 12 II = 1,NELWRITE (6,100) TA(II)
100 FORMAT(20X,F10.2)12 CONTINUE
WRITE OUT PARAMETERS FOR VARIABLE TANK(S)WRITE (6,110)
110 FORMAT(//10X,'ELEM( SLN ADJN FGNN HMAX HMIN TD TA',/,* 8X, 46(1H-))DO 14 II = 1,NELWRITE (6,120) II,SLN(II),ADJN(II),FGNN(II),HMAX(II),HMIN(II),
TD(II),TA(II)14 CONTINUE120 FORMAT(12X,13,3X,13,3X,13,3X,13,1X,F8.2,1X,F8.2,1X,F8.2,1X,
*F8.2)END IF
READ PARAMETERS FOR VALVES IN THE NETWORKREAD "ONLY IF" THERE ARE VALVES IN THE NETWORK PIPES
IF (NVL .NE. 0) THEN
149
READ (5,*) (KV(II), II = 1, NE)WRITE OUT PARAMETERS FOR VALVES IN THE NETWORK PIPES
WRITE (6,130)130 FORMAT (//10X, 'ELEM# KV',/,8X,20(1H-))
DO 16 II = 1, NEWRITE (6,140) II,KV(II)
16 CONTINUE140 FORMAT (12X,I3,3X,F5.2)
END IFREAD PARAMETERS FOR VALVES IN THE NETWORKREAD "ONLY IF" THERE ARE VALVES IN THE NETWORK PIPES
IF (PLN .NE. 0) THENREAD (5,*) (PSLN(II), II = 1, PLN)READ (5,*) (H1(II), II = 1, PLN)READ (5,*) (H2(II), II = 1, PLN)READ (5,*) (H3(II), II = 1, PLN)READ (5,*) (Q2(II), II = 1, PLN)READ (5,*) (Q3(II), II = 1, PLN)
WRITE OUT PARAMETERS FOR PUMPS IN THE NETWORK PIPESWRITE (6,150)
150 FORMAT (//10X,'PUMP# PSLN H1 H2 H3 Q2 Q3',/,8X,46(1H-))DO 18 II = 1, PLNWRITE (6,160) II, PSLN(II), 51(II), H2(II), H3(II), Q2(II), Q3(II)
18 CONTINUE160 FORMAT ( 12X, 13,1X,13,1X,F8.2,1X,F8.2,1X,F8.2,1X,F8.2,1X,F8.2)
END IFRETURNEND
************************************************************************Subroutine SETUPFThis subprogarm sets up the matrices that remain fixed over time.*
************************************************************************SUBROUTINE SETUPF(I,J,X,Y,W,NE,NN,QD,HEGN,B,DEM,ICON,ICONT,QAG,
HED,INC,AOHO,M,NR,NC,FNC,FLOW,Q,DT,AR,L,GR,H,ICONI,ICONTI,I0,JI,HP,NNN,TS)
INTEGER I(12),J(12),NE,NN,X,Y,W,NR,NC,FNC,DT,KI,KJ,K,I0(12),JI(12)INTEGER NNN,TSREAL QD(7),HFGN(9),M,Q(12),AR(12),L(12),GR,H(7)DIMENSION B(NE,NE),DEM(NN,FNC),ICON(NR,NC),HED(NNN,FNC)DIMENSION ICONT(NC,NR),AOHO(NE,FNC),FLOW(NE,FNC),QAG(NE,FNC)DIMENSION AHED(NE,FNC),ICONI(NE,NN),ICONTI(NN,NE),HP(NN,FNC)DIMENSION INC(NE,NNN)LOGICAL ERROR
DEVELOP MATRIX N"-1 (DIAGONAL) NE*NEDO 35 X = 1, NE
DO 30 Y = 1, NEIF (X .EQ. Y) THEN
B(X,Y) = 1/MELSE
B(X,Y) = 0.0END IF
30 CONTINUE35 CONTINUE
WRITE OUT MATRIX [N"-1] OR [B]WRITE (6, *)WRITE (6, *) 'MATRIX [NA-1] OR [B]DO 25 X = 1,NEWRITE (6,1822) (B(X,Y), Y = 1, NE)
1822 FORMAT(/1X,12(F5.3,2X))25 CONTINUE
DEVELOP & WRITE MATRIX [HP(NN,FNC)] WHICH STORES NODAL HEAD VALUESWRITE (6,*)
150
WRITE (6,*) 'MATRIX [H] OR [HP(NN,FNC)]Y= 1DO 41 II = 1, NN
HP(II,Y) = H(II)WRITE (6,1823) HP(II,Y)
1823 FORMAT (/1X, (F8.5))41 CONTINUE
DEVELOP & WRITE MATRIX Q (FLOW): NE*1WRITE (6, *)WRITE (6, *) 'MATRIX [Q] OR [FLOW] :'Y= 1DO 40 II = 1, NE
FLOW(II,Y) = Q(II)WRITE (6,1824) FLOW(II,1)
1824 FORMAT (/1X, (F8.5))40 CONTINUE
DEVELOP & WRITE MATRIX q (DEMAND): NN*1WRITE (6, *)WRITE (6, *) 'MATRIX [q] OR [DEMI :'
***********************************************************************CALL DEMF(NN,FNC,TS,DEM)Y= 1DO 42 II = 1, NN
DEM(II,Y) = QD(II) "[only if Subroutine DEMF is not used]"WRITE (6,1825) DEM(II,1)
1825 FORMAT (/1X,(F8.5))42 CONTINUE
DEVELOP CONNECTIVITY MATRIX A(12): NE*NNZERO OUT ALL ELEMENTS & DEVELOP
DO 400 II = 1, NEDO 400 Y = 1, NN
400 ICON(II,Y)=0DO 45 II = 1, NEICON (II,J(II)) = 1*(DT/2)IF (I(II) .GT. 0) ICON(II,I(II)) = - 1*(DT/2)
45 CONTINUEWRITE OUT MATRIX A(12)
WRITE (6, *)WRITE (6, *) 'MATRIX [A(12)] OR [ICON] :'DO 50 II = 1, NEWRITE (6,1826) (ICON(II,Y), Y = 1,NN)
1826 FORMAT(/1X,12(I4,X))50 CONTINUE
DEVELOP TRANSPOSE MATRIX [A(21)] OR [ICONT(NN*NE)]DO 46 X = 1, NNW=XDO 47 Y = 1, NEII = YICONT (X,Y) = ICON (II,W)
47 CONTINUE46 CONTINUE
WRITE OUT MATRIX A(21)WRITE (6, *)WRITE (6, *) 'MATRIX [A(21)] OR ['CONT] :'DO 55 X = 1,NNWRITE (6,1828) (ICONT(X,Y), Y = 1,NE)
1828 FORMAT(/1X,12(I4,X))55 CONTINUE
DEVELOP MATRIX A(10)*H(0): NE*1SETUP MATRIX QAG(NE,FNC):
WRITE (6, *)WRITE (6, *) 'MATRIX [QAG(NE,FNC)]
151
Y= 1DO 65 II = 1, NE
QAG(II,Y) = (L(II)/(GR *AR(II)))*FLOW(II,Y)WRITE (6,1830) QAG(II,Y)
1830 FORMAT(/1X,(F10.5))65 CONTINUE
SETUP MATRIX HED(NE,FNC):Y= 1DO 656 II = 1, NNN
IF(HFGN(II) .GT. 0.) THENHED(II,y) = 2.*HFGN(II)ELSE IF (II .NE. 1) THENHED(II,Y) = HP(II-1,Y)END IF
656 CONTINUEWRITE (6,*)WRITE (6,*) 'MATRIX [HED(NE,FNC)]DO 66 II = 1,NNNWRITE (6,1831) HED(II,Y)
1831 FORMAT(/1X,(F10.5))66 CONTINUE
SETUP R.H.S. INCEDENCE MATRIX [INC(NE,NE)]:DO 667 II=1,NE
INC(II,JI(II))=-1*(DT/2)INC(II,I0(II))= 1*(DT/2)
667 CONTINUEWRITE (6,*)WRITE (6,*) 'MATRIX [INC(NE,NE)]DO 67 II = 1,NEWRITE(6,1832) (INC(II,Y), Y=1,NNN)
1832 FORMAT(/1X,12(I2,1X))
67 CONTINUEMULTIPLY MATRICES [INC*HED] & STORE IN MATRIX [AHED(NE,1)]:
ERROR = .FALSE.IF (NE.NE.NE) ERROR = .TRUE.IF (NE.NE.NE) ERROR = .TRUE.IF (FNC.NE.FNC) ERROR = .TRUE.IF (.NOT. ERROR) THEN
DO 68 KI = 1, NEDO 69 KJ = 1, FNC
AHED(KI,KJ) = 0.0DO 70 K = 1, NE
AHED(KI,KJ) = AHED(KI,KJ) + INC(KI,K)*HED(K,KJ)
70 CONTINUE
69 CONTINUE
68 CONTINUEEND IFWRITE (6,*)WRITE (6,*) 'MATRIX [AHED(NE,1)=INC(NE,NE)*HED(NE,I)]Y=1DO 71 II = 1, NEWRITE(6,1833) AHED(II,Y)
1833 FORMAT(/1X,(F10.5))
71 CONTINUEADD MATRICES [AHED+QAG] & STORE IN MATRIX [AOHO(NE,1)]:
KJ=1DO 72 KI=1,NE
AOHO(KI,Kj) = QAG(KI,Kj) - AHED(KI,KJ)
72 CONTINUEWRITE (6,*)WRITE (6,*) 'MATRIX [AOHO(NE,1)) : 7Y=1
152
DO 73 II - 1, NEWRITE(6,1834) AOHO(II,Y)
1834 FORMAT(/1X,(F10.5 ) )73 CONTINUE
SETUP MATRICES [ICONI(NE,NN)] & [ICONTI(NN,NE)] TO USE INSETTING UP MATRIX [P(NN,FNC)]:
DO 401 II = 1, NEDO 401 Y = 1, NN
401 ICONI(II,Y)=0DO 74 II - 1, NEICONI (II,J(II)) = 1IF (I(II) .GT. 0) ICONI(II,I(II)) = -1
74 CONTINUEDO 75 X = 1, NNW=XDO 76 Y = 1, NEII = YICONTI (X,Y) = ICONI (II,W)
76 CONTINUE75 CONTINUE
RETURNEND
***********************************************************************• Subroutine DEMF• This subprogram sets up the user-defined Demand Function.• A sample Step Demand Function is presented here.*************************************************************** * *******
SUBROUTINE DEMF(NN,FNC,TS,DEM)INTEGER NN,FNC,TSDIMENSION DEM(NN,FNC)DO 777 II = 1, NNIF (TS .GE. 0 .AND.DEM(II,FNC) = 0.015
TS .LT. 2) THEN
ELSE IF (TS .GE. 2 .AND. TS .LT. 6) THENDEM(II,FNC) = 0.010ELSE IF (TS .GE. 6 .AND. TS .LT. 8) THENDEM(II,FNC) = 0.015ELSE IF (TS .GE. 8 .AND. TS .LT. 12) THENDEM(II,FNC) = 0.030ELSE IF (TS .GE. 12 .AND. TS .LT. 14) THENDEM(II,FNC) = 0.040ELSE IF (TS .GE. 14 .AND. TS .LT. 16) THENDEM(II,FNC) = 0.030ELSE IF (TS .GE. 16 .AND. TS .LT. 20) THENDEM(II,FNC) = 0.020ELSE IF (TS .GE. 20 .AND. TS .LT. 22) THENDEM(II,FNC) = 0.040ELSE IF (TS .GE. 22 .AND. TS .LT. 24) THENDEM(II,FNC) = 0.030ELSE IF (TS .EQ. 24) THENDEM(II,FNC) = 0.015END IF
777 CONTINUERETURNEND
************************************************************************• Subroutine SOLVE• This subprogram sets up the iteration# and checks convergence• criteria by calling on Subroutine SETALL.**** * *** * *************** * **** * **** *** **** ** **** * ** * ****** ***** **********
SUBROUTINE SOLVE (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,DT,AR,L,GR,
153
ICONI,ICONTI,I,J,X,Y,W,QD,HFGN,QAG,HED,INC,HP,H,IO,JI,NNN,QRES,RESH,KV,NEL,SLN,FGNN,HMAX,ADJN,TS)
INTEGER NE,NN,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,FNR,FNC,ITMAX,XX,DTINTEGER I( 12 ),J(12),X,Y,W,I0(12),jI(12),NNN,NEL,SLN(1),FGNN(1)INTEGER ADJN(1),TSREAL KO( 12 ),Q(12),L(12),GR,M,AR(12),QD(7),HFGN(9),H(7),KV(12)REAL HMAX(1)DIMENSION A(NE,NE),ICON(NR,NC),ICONT(NC,NR),B(NE,NE),AOHO(NE,FNC)DIMENSION FLOW(NE,FNC),DEM(NN,FNC),QRES(NE,FNC),ICONI(NE,NN)DIMENSION ICONTI(NN,NE),QAG(NE,FNC),HED(NNN,FNC),INC(NE,NNN)DIMENSION HP(NN,FNC),RESH(NN,FNC)PARAMETER (ITMAX=20)CALL MULTMX (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,
FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES,DT,AR,L,GR,ICONI,
DO 555 XX =WRITE (*,*)CALL SETALL
555 CONTINUEWRITE (*,*)RETURNEND
ICONTI,RESH,KV,NEL,SLN,FGNN,HMAX,HFGN,ADJN)1, ITMAX'ITERATION# =',XX(A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES,I,J,X,Y,W,QD,HFGN,QAG,HED,INC,HP,H,I0,JI,DT,AR,L,GR,ICONI,ICONTI,RESH,NNN,KV,NEL,SLN,FGNN,HMAX,ADJN,TS)
'WARNING: Maximum Iteration Exceeded!!!'
SUBROUTINE SETALL (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES,I,J,X,Y,W,QD,HFGN,QAG,HED,INC,HP,H,I0,JI,DT,AR,L,GR,ICONI,ICONTI,RESH,NNN,KV,NEL,SLN,FGNN,HMAX,ADJN,TS)
INTEGER NE,FNC,X,Y,NN,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,FNRINTEGER I(12),J(12),I0(12),JI(12),W,DT,NNN,NEL,SLN(1),FGNN(1)INTEGER ADJN(1),TSREAL Q(12),K0(12),H(7),HFGN(9),QD(7),AR(12),L(12),KV(12),M,GRREAL HMAX(1)DIMENSION QRES(NE,FNC),FLOW(NE,FNC),CLOSR(NE,FNC)DIMENSION A(NE,NE),B(NE,NE),ICON(NR,NC),ICONT(NC,NR),AOHO(NE,FNC)DIMENSION DEM(NN,FNC),QAG(NE,FNC),HED(NNN,FNC),INC(NE,NNN)DIMENSION HP(NN,FNC),ICONI(NE,NN),ICONTI(NN,NE),RESH(NN,FNC)Y= 1DO 556 X = 1, NE
CLOSR (X, Y) = 0.0001556 CONTINUE
Y= 1DO 557 X = 1, NEWRITE (6,3000) CLOSR(X,Y)
3000 FORMAT (/1X, (F6.4))557 CONTINUE
IF ((ABS(FLOW(NE,FNC)-QRES(NE,FNC)))/(FLOW(NE,FNC)) .GT.*CLOSR(NE,FNC)) THENFLOW = QRESDO 558 II = 1, NE
Q(II) = FLOW(II,FNC)558 CONTINUE
HP = RESHDO 559 II = 1, NN
H(II) = HP(II,FNC)559 CONTINUE
CALL SETUPF(I,J,X,Y,W,NE,NN,QD,HFGN,B,DEM,ICON,ICONT,QAG,HED,INC,AOHO,M,NR,NC,FNC,FLOW,Q,DT,AR,L,GR,H,ICONI,ICONTI,
154
IO,JI,HP,NNN,TS)
CALL MULTMX (A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC.FLOW,NN,DEM,KO,Q,M,QRES,DT,AR,L,GR,ICONI,ICONTI,RESH,KV,NEL,SLN,FGNN,HMAX,HFGN,ADJN)
ELSESTOP 'STOP: CONVERGED'END IFRETURNEND
************************************************************************
• Subroutine MULTMX• This subprogram performs necessary computations to obtain HEAD *• values. It calls on Subroutine GAUSSJ for matrix inversion.************************************************************************
SUBROUTINE MULTMX(A,ICON,ICONT,B,NE,NR,NC,CNR,CNC,DNR,DNC,ENR,ENC,AOHO,FNR,FNC,FLOW,NN,DEM,KO,Q,M,QRES,DT,AR,L,GR,ICONI,ICONTI,RESH,KV,NEL,SLN,FGNN,HMAX,HFGN,ADJN)
INTEGER NE,NN,NR,NC,CNR,CNC,I,J, K,X,Y,DNR,DNC,ENR,ENC,FNR,FNC,DTINTEGER NEL,SLN(1),FGNN(1),ADJN( 1)REAL KO(12),Q(12),L(12),GR,M,AR( 12),KV(12),HMAX(1),HFGN(9)DIMENSION A(NE,NE),ICON (NR,NC), C(CNR,CNC),ICONT(NC,NR)DIMENSION B(NE,NE),D(DNR,DNC),E( ENR,ENC),F(FNR,FNC),AOHO(NE,FNC)DIMENSION FLOW(NE,FNC),G(NE,FNC) ,H(NN,FNC),P(NN,FNC),DEM(NN,FNC)DIMENSION QRES(NE,FNC),ICONI(NE, NN),ICONTI(NN,NE),RESH(NN,FNC)LOGICAL ERRORERROR = .FALSE.
DEVELOP MATRIX A(11)^-1: (DIAGONAL) NE*NEX = 1, NEDO 3 Y = 1, NE
DO 4 II = 1, NEIF (X .EQ. Y) THEN
,II) = 1.0/((((KO(II)*((ABS(Q(II)))**(M-1)))+(KV(II)*(ABS(Q(II)*DT) - (L(II)/(GR*AR(II))))
ELSEA(X,Y) = 0.0
END IF4 CONTINUE3 CONTINUE2 CONTINUE
WRITE OUT MATRIX [A(11)^-1] OR [A]WRITE (6, *)WRITE (6, *) 'MATRIX [A(11)^-1] OR [A] :'DO 1 X = 1, NEWRITE (6, 1820) (A(X,Y), Y = 1, NE)
1820 FORMAT (/1X,12(F8.5,2X)/)1 CONTINUE
IF TEST TO MULTIPLY [A(NE,NE)*ICON(NE,NN)]IF (NE .NE. NR) ERROR = .TRUE.IF (NE .NE. CNR) ERROR = .TRUE.IF (NC .NE. CNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 5 I = 1, CNR
DO 10 J = 1, CNCC(I,J) = 0.0DO 15 K = 1, NE
C(I,J) = C(I,J) + A(I,K)*ICON(K,J)15 CONTINUE10 CONTINUE5 CONTINUE
END IF
155
WRITE OUT RESULT OF [A(11)^-1 * A(12)] OR [A * ICON]WRITE (6, *)WRITE (6, *) 'RESULT OF [A(11) ^- 1 * A(12)] OR [A*ICON]DO 20 X = 1,CNRWRITE (6, 1000) (C(X,Y), Y = 1, CNC)
1000 FORMAT (/1X,12(F6.4,2X))20 CONTINUE
IF TEST TO MULTIPLY [ICONT(NN,NE)*B(NE,NE)]IF (NR .NE. NE) ERROR = .TRUE.IF (NC .NE. DNR) ERROR = .TRUE.IF (NE .NE. DNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 25 I - 1, DNR
DO 30 J = 1, DNCD(I,J) = 0.0DO 35 K = 1, NR
D(I,J) = D(I,J) + ICONT(I,K)*B(K,J)35 CONTINUE30 CONTINUE25 CONTINUE
END IFWRITE OUT RESULT OF [A(21)*NA-1] OR [ICONT * B]
WRITE (6, *)WRITE (6, *) 'RESULT OF [A(21)*NA-1] OR [ICONT*B]DO 40 X = 1, DNRWRITE (6, 1001) (D(X,Y), Y = 1, DNC)
1001 FORMAT (/X,12(F6.4,2X))40 CONTINUE
IF TEST TO MULTIPLY [D(DNR,DNC)*C(CNR,CNC)] OR[A(21)*N^-1]*[A(11)^-1 * A(12)]
IF (DNC .NE. CNR) ERROR = .TRUE.IF (DNR .NE. ENR) ERROR = .TRUE.IF (CNC .NE. ENC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 45 I = 1, ENR
DO 50 J = 1, ENCE(I,J) = 0.0DO 55 K = 1, DNC
E(I,J) = E(I,J) + D(I,K)*C(K,J)55 CONTINUE50 CONTINUE45 CONTINUE
END IFWRITE OUT RESULT OF [D(DNR,DNC)*C(CNR,CNC)]
WRITE (6, *)WRITE (6, *) 'RESULT OF [D(DNR,DNC)*C(CNR,CNC)]DO 60 X = 1, ENRWRITE (6, 1002) (E(X,Y), Y = 1, ENC)
1002 FORMAT (/X,12(F6.4,2X))60 CONTINUE
IF TEST TO MULTIPLY [A(NE,NE)*AOHO(NE,FNC)] OR[A(11)^-1*A(10)H(0)]
IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. FNR) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.IF (.NOT. ERROR) THENDO 65 I = 1, FNR
DO 70 J = 1, FNCF(I,J) = 0.0DO 75 K = 1, NE
F(I,J) = F(I,J) + A(I,K)*AOHO(K,J)75 CONTINUE
156
157
70 CONTINUE65 CONTINUE
END IFWRITE OUT RESULT OF [A(NE,NE)*AOHO(NE,FNC)]
WRITE (6, *)WRITE (6, *) 'RESULT OF [A(NE,NE)*AOHO(NE,FNC)]Y= 1DO 80 X = 1, FNRWRITE (6, 1003) F(X,Y)
1003 FORMAT (/1X, (F9.5)80 CONTINUE
ADD MATRICES [F(FNR,FNC) + FLOW(NE,1)] & PUT INTO G(NE,FNC) DEVELOPED
IN SUBROUTINE 'ADDMX'** ***************************************************** ****************
CALL ADDMX (F,FLOW,NE,NN,FNR,FNC,G,E,ENR,ENC,B,A, ICON,AOHO,QRES,RESH)
IF TEST TO MULTIPLY [D(DNR,DNC) * G(NE,FNC)]IF (DNC .NE. NE) ERROR = .TRUE.IF (DNR .NE. NN) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 95 I = 1, NN
DO 100 J = 1, FNC11(1, J) = 0.0DO 105 K = I, DNCH(I,J) = H(I,J) + D(I,K)*G(K,J)CONTINUE
CONTINUE10510095 CONTINUE
END IFWRITE OUT
WRITE (6, *)WRITE (6, *)Y= 1DO 110 X = 1,WRITE (6, 100
1005 FORMAT (/1X,(110 CONTINUE
RESULT OF [D(DNR,DNC) * G(NE,FNC)]
'RESULT OF [D(DNR,DNC) * G(NE,FNC)]
NN5) H(X,Y)F9.5))
IF TEST TO MULTIPLY [A(21)*Q] OR [ICONTI(NC,NR)*FLOW(NE,FNC)]IF (NE .NE. NE) ERROR = .TRUE.IF (NN .NE. NN) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 115 I = 1, NN
DO 120 J = 1, FNCP(I,J) = 0.0DO 125 K = 1, NE
P(I,J) = P(I,J) + ICONTI(I,K)*FLOW(K,J)125 CONTINUE120 CONTINUE115 CONTINUE
END IFWRITE OUT RESULT OF [A(21)*Q] OR [ICONTI(NN,NE)*FLOW(NE,FNC)]
WRITE (6, *)WRITE (6, *)'RESULT OF [A(21)*Q] OR [ICONTI(NN,NE)*FLOW(NE,FNC)]:'Y= 1DO 130 X = 1, NNWRITE (6, 1006) P(X,Y)
1006 FORMAT (/1X,(F5.3))
158
130 CONTINUE***********************************************************************
CALL SUBMX (DEM,P,NN,FNC,H,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,QRES,RESH)
RETURNEND
***********************************************************************• Subroutine ADDMX• Intermediate subprogram to perform minor matrix algebra.***********************************************************************
SUBROUTINE ADDMX (F,FLOW,NE,NN,FNR,FNC,G,E,ENR,ENC,B,A,ICON,AOHO,QRES,RESH)
INTEGER NE,NN,FNR,FNC,I,J,X,Y,ENR,ENCDIMENSION F(FNR,FNC),FLOW(NE,FNC),G(NE,FNC),E(ENR,ENC),B(NE,NE)DIMENSION A(NE,NE),ICON(NE,NN),AOHO(NE,FNC),QRES(NE,FNC)DIMENSION RESH(NN,FNC)J= 1DO 85 I = 1,NE
G(I,J) = F(I,J) + FLOW(I,J)85 CONTINUE
WRITE OUT RESULT OF [F(FNR,FNC) + FLOW(NE,1)]WRITE (6, *)WRITE (6, *) 'RESULT OF [F(FNR,FNC) + FLOW(NE,FNC)]Y= 1DO 90 X = 1, NEWRITE (6, 1004) G(X,Y)
1004 FORMAT (/1X,(F9.5))90 CONTINUE
RETURNEND
***********************************************************************• Subroutine SUBMX• Intermediate subprogram to perform minor matrix algebra.***********************************************************************
SUBROUTINE SUBMX (DEM,P,NN,FNC,H,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,QRES,RESH)
INTEGER NN,FNC,I,J,X,Y,ENR,ENC,NEDIMENSION DEM(NN,FNC), P(NN,FNC), PP(NN,FNC),H(NN,FNC),E(ENR,ENC)DIMENSION B(NE,NE),FLOW(NE,FNC),A(NE,NE),ICON(NE,NN),AOHO(NE,FNC)DIMENSION QRES(NE,FNC),RESH(NN,FNC)J= 1DO 135 I = 1, NN
PP(I,J) = DEM(I,J) - P(I,J)135 CONTINUE
WRITE OUT RESULT OF [q - (A(21)*Q(K)] OR [DEM(NN,FNC)-P(NN,FNC)]WRITE (6, *)WRITE (6, *) 'RESULT OF [DEM(NN,FNC)-P(NN,FNC)]Y= 1DO 140 X = 1, NNWRITE (6, 1007) PP(X,Y)
1007 FORMAT (/1X, (F7.3)140 CONTINUE***********************************************************************
CALL ADDMXII (H,PP,NN,FNC,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,QRES,RESH)
RETURNEND
***********************************************************************• Subroutine ADDMXII• Intermediate subprogram to perform minor matrix algebra.***********************************************************************
SUBROUTINE ADDMXII (H,PP,NN,FNC,E,ENR,ENC,B,FLOW,NE,A,ICON,AOHO,
159
QRES,RESH)INTEGER NN,FNC,I,J,X,Y,ENR,ENC,NEDIMENSION H(NN,FNC),PP(NN,FNC),R(NN,FNC),E(ENR,ENC),B(NE,NE)DIMENSION FLOW(NE,FNC),A(NE,NE),ICON(NE,NN),AOHO(NE,FNC)DIMENSION ORES(NE,FNC),RESH(NN,FNC)J= 1DO 145 I = 1, NN
R(I,J) = H(I,J) + PP(I,J)145 CONTINUE
WRITE OUT RESULT OF [{A(21)*N^- 1}*{Q(K)+A(11)^-1*A(10)H(0)1]+[q-{A(21)*4
WRITE (6, *)WRITE (6, *) 'RESULT OF [H(NN,FNC) + PP(NN,FNC)]Y= 1DO 150 X = 1, NNWRITE (6, 1008) R(X,Y)
1008 FORMAT (/1X, (F9.5)150 CONTINUE***********************************************************************
CALL GAUSSJ (e,enr,enc,r,nn,fnc,B,FLOW,NE,A,ICON,AOHO,QRES,RESH)RETURNEND
***********************************************************************
Subroutine GAUSSJUsed to perform matrix inversion.
***********************************************************************
SUBROUTINE gaussj(e,enr,enc,r,nn,fnc,B,FLOW,NE,A,ICON,AOHO,QRES,RESH)
INTEGER enr,enc,nn,fnc,NMAX,NEINTEGER ICON(NE,NN)REAL e(enr,enc),r(nn,fnc),S,RESH(NN,FNC),B(NE,NE),FLOW(NE,FNC)REAL A(NE,NE),AOHO(NE,FNC),QRES(NE,FNC)PARAMETER (NMAX=50,S=-1.)INTEGER i,icol,irow,j,k,1,11,indxc(NMAX),indxr(NMAX),ipiv(NMAX)INTEGER x,yREAL big,dum,pivinvdo 11 j=1,nn
ipiv(j)=011 continue
do 22 i=1,nnbig=0.do 13 j=1,nn
if(ipiv(j).ne.1)thendo 12 k=1,nn
if (ipiv(k).eq.0) thenif (abs(e(j,k)).ge.big)then
big=abs(e(j,k))irow=jicol=k
endifelse if (ipiv(k).gt.1) thenpause 'singular matrix in gaussj'
endif12 continue
endif13 continue
ipiv(icol)=ipiv(icol)+1if (irow.ne.icol) thendo 14 1=1,nn
dum=e(irow,l)e(irow,1)=e(ico1,1)e(ico1,1)=dum
160
14 continuedo 15 1=1,fnc
dum=r(irow,l)r(irow,1)=r(ico1,1)r(ico1,1)=dum
15 continueendifindxr(i)=irowindxc(i)=icolif (e(icolficol).eq.0.) pause 'singular matrix in gaussj'pivinv=1./e(icol,ico1)e(ico1,icol)=1.do 16 1=1,nne(ico1,1)=e(ico1,1)*pivinv
16 continuedo 17 1=1,fnc
r(ico1,1)=r(icol,1)*pivinv17 continue
do 21 11=1,nnif(11.ne.icol)then
dum=e(11,icol)e(11,icol)=0.do 18 1=1,nn
e(11,1)=e(11,1)-e(ico1,1)*dum18 continue
do 19 1=1,fncr(11,1)=r(11,1)-r(ico1,1)*dum
19 continueendif
21 continue22 continue
do 24 1=nn,1,-1if(indxr(1).ne.indxc(1))thendo 23 k=1,nn
dum=e(k,indxr(1))e(k,indxr(1))=e(k,indxc(1))e(k,indxc(1))=dum
23 continueendif
24 continuewrite out the result of inverted matrix 'e'
write (6, *)write (6, *) 'result of inverted matrix Edo 25 x = 1, enrwrite (6,1009) (e(x,y), y = 1, enc)
1009 format (/x,7(f10.4,2x))25 continue
write out the result of [H(k+1)] stored in matrix 'r'write (6, *)write (6, *) 'result of [H(k+1)] stored in matrix (r) by GAUSSJy= 1do 26 x = 1, nnwrite (6, 1010) r(x,y)
1010 format (/lx, (f12.5))26 continue
multiply the result of [H(k+1)] by -1 to take care of sign(s)in the original formulation(s)
j = 1do 27 i = 1, nn
RESH(i,j) = S*r(i,j)27 continue
write out the result of [H(k+1)] with proper sign, stored in
matrix RESH(nn,fnc)write (6, *)write (6, *)'result of [H(k+1)] with proper sign; RESH(nn,fnc):y = 1do 28 x = 1, nnwrite (6, 1011) RESH(x.Y)
1011 format (/1x, (f10.5))28 continue******* *** *** * ** * * * * * ** * ***************** * ** * *** ** *********** ******* ***
CALL FLOWCALC (B,FLOW,NE,NN,FNC,A,RESH,ICON,AOHO,QRES)returnEND
**** ** ** ** *** * **** * * * * * * * ******** *** *** ** ** ** **** ********************* *Subroutine FLOWCALCThis subprogram uses the computed HEAD values to obtain FLOWS. *
***********************************************************************SUBROUTINE FLOWCALC (B,FLOW,NE,NN,FNC,A,RESH,ICON,AOHO,QRES)INTEGER NE,NN,FNC,I,j,K,X,YDIMENSION B(NE,NE),FLOW(NE,FNC),BF(NE,FNC),BFQ(NE,FNC),BA(NE,NE)DIMENSION A(NE,NE),RESH(NN,FNC),ICON(NE,NN),AH(NE,FNC)DIMENSION AOHO(NE,FNC),AHA(NE,FNC),AEB(NE,FNC),QRES(NE,FNC)LOGICAL ERRORERROR = .FALSE.
IF TEST TO MULTIPLY [N ^ -1*Q(K)] OR [B(NE,NE)*FLOW(NE,FNC)]IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 155 I = 1, NE
DO 160 J = 1, FNCBF(I,J) = 0.0DO 165 K = 1, NE
BF(I,J) = BF(I,J) + B(I,K)*FLOW(K,J)165 CONTINUE160 CONTINUE155 CONTINUE
END IFWRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *)'RESULT OF [N^-1*Q(K)] OR [B(NE,NE)*FLOW(NE,FNC)]:'Y= 1DO 170 X = 1, NEWRITE (6, 1012) BF(X,Y)
1012 FORMAT (/1X,(F10.5))170 CONTINUE
CALCULATE [Q(K)-INA-1*Q(K)] & STORE IN [BFQ(NE,FNC)]J= 1DO 175 I = 1, NE
BFQ(I,J) = FLOW(I,J) - BF(I,J)175 CONTINUE
WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *)'RESULT OF [Q(K)-{N^-1*Q(K)] STORED IN [BFQ(NE,FNC)]:'Y= 1DO 180 X = 1, NEWRITE (6, 1013) BFQ(X,Y)
1013 FORMAT (/1X, (F10.5))180 CONTINUE
CALCULATE [N^- 1*A(11)A-1] & STORE IN [BA(NE,NE)]IF TEST TO MULTIPLY [N^-1*A(11)^-1] OR [B(NE,NE)*A(NE,NE)]
IF (NE .NE. NE) ERROR = .TRUE.
161
IF (NE .NE. NE) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 185 I = 1, NE
DO 190 J = 1, NEBA(I,J) = 0.0DO 195 K = 1, NE
BA(I,J) = BA(I,J) + B(I,K)*A(K,J)195 CONTINUE190 CONTINUE185 CONTINUE
END IFWRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *) 'RESULT OF [N^-1*A(11)^-1] STORED IN [BA(NE,NE)]DO 200 X = 1, NEWRITE (6, 1014) (BA(X,Y), Y = 1, NE)
1014 FORMAT (/1X,12(F10.5,2X))200 CONTINUE
CALCULATE [A(12)*H(K+1)] & STORE IN [AH(NE,NE)]IF TEST TO MULTIPLY [A(12)*H(K+1)] OR [ICON(NE,NN)*RESH(NN,FNC)]
IF (NN .NE. NN) ERROR = .TRUE.IF (NE .NE. NE) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 205 I = 1, NE
DO 210 J = 1, FNCAH(I,J) = 0.0DO 215 K = 1, NN
AH(I,J) = AH(I,J) + ICON(I,K)*RESH(K,J)215 CONTINUE210 CONTINUE205 CONTINUE
END IFWRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *) 'RESULT OF [A(12)*H(K+1)] STORED IN [AH(NE,FNC)]Y= 1DO 220 X = 1, NEWRITE (6, 1015) AH(X,Y)
1015 FORMAT (/1X, (F10.5)220 CONTINUE
CALCULATE [{A(12)*H(K+1)1+{A(10)H(0)}] & STORE IN [ABA(NE,FNC)]J= 1DO 225 I = 1, NE
AHA(I,J) = AH(I,J) + AOHO(I,J)225 CONTINUE
WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *) 'RESULT OF [(A(21)*H(K+1)}+{A(10)H(0)1] STORED IN',
' [AHA(NE,FNC)]Y= 1DO 230 X = 1, NEWRITE (6, 1016) AHA(X,Y)
1016 FORMAT (/1X, (F10.5)230 CONTINUE
CALCULATE [N ^- 1*A11^-1]*[Al2*H(K+1)+A(10)H(0)] & STORE IN [AHB(NE,FNC)]
IF TEST TO DO THE ABOVE MULTIPLICATIONIF (NE .NE. NE) ERROR = .TRUE.
162
IF (NE .NE. NE) ERROR = .TRUE.IF (FNC .NE. FNC) ERROR = .TRUE.
IF (.NOT. ERROR) THENDO 235 I = 1, NE
DO 240 J = 1, FNCAHB(I,J) = 0.0DO 245 K = 1, NE
AHB(I,J) = AHB(I,J) + BA(I,K)*AHA(K,J)245 CONTINUE240 CONTINUE235 CONTINUE
END IFWRITE OUT THE RESULT
WRITE (6, *)WRITE (6, *) 'RESULT OF [N ^- 1*A11 ^- 1]*[Al2*H(K+1)+A(10)H(0)]',
' STORED IN [AHB(NE,FNC)]Y= 1DO 250 X = 1, NEWRITE (6, 1017) AHB(X,Y)
1017 FORMAT (/1X, (F10.5)250 CONTINUE
CALCULATE [Q(K+1)] = [BFQ(NE,FNC) - AHB(NE,FNC)] & STORE IN[QRES(NE,FNC)]
J= 1DO 255 I = 1, NE
QRES(I,J) = BFQ(I,J) - AHB(I,J)255 CONTINUE
WRITE OUT THE RESULTWRITE (6, *)WRITE (6, *) 'RESULT OF [Q(K+1)]Y= 1DO 260 X = 1, NEWRITE (6, 1018) QRES(X,Y)
1018 FORMAT (/1X, (F10.5)260 CONTINUE
RETURNEND
***********************************************************************• Subroutine TLEVEL• This subprogram updates WSEL in tank at the end of every time• step.***********************************************************************
SUBROUTINE TLEVEL (NEL,DT,QRES,RESH,HFGN,NE,NN,FNC,SLN,ADJN,FGNN,HMAX,HMIN,TA,WSEL,Q)
INTEGER NEL, DT, NE, NN, FNC, ADJN(1),SLN(1),FGNN(1)REAL HMAX(1), HMIN(1), TA(1),WSEL(1),HFGN(9),Q(12)DIMENSION QRES(NE,FNC),RESH(NN,FNC)DO 10 II = 1,NELIF (HFGN(FGNN(II)) .LT. HMAX(II) .AND. Q(SLN(II)) .LT. 0.) THENWSEL(II)=((ABS(Q(SLN(II)))*DT)/TA(II))+HFGN(FGNN(II))HFGN(FGNN(II))=WSEL(II)ELSE IF (HFGN(FGNN(II)) .GE. HMAX(II)) THENWSEL(II)=HFGN(FGNN(II))-((ABS(Q(SLN(II)))*DT)/TA(II))HFGN(FGNN(II))=WSEL(II)Q(SLN(II))=-Q(SLN(II))ELSE IF (HFGN(FGNN(II)) .GT. HMIN(II) .AND. Q(SLN(II)) .GT. 0.*) THENWSEL(II)=HFGN(FGNN(II)) - ((ASS(Q(SLN(II)))*DT)/TA(II))HFGN(FGNN(II))=WSEL(II)ELSE IF (HFGN(FGNN(II)) .LE. HMIN(II)) THEN
163
Q(SLN(II))=-Q(SLN(II))END IFWRITE (*,*) Q(SLN(II))WRITE (*,*) HFGN(FGNN(II))WRITE (*,*) RESH(ADJN(II),FNC)WRITE (*,*) QRES(SLN(II),FNC)
10 CONTINUEWRITE(6,100)
100 FORMAT (//10X,'ELEM# WSEL',/,8X,10(1H-))DO 12 II = 1,NELWRITE (6,110) II, WSEL(II)
12 CONTINUE110 FORMAT (10X,I3,3X,F8.2)
RETURNEND
***********************************************************************• Subroutine PUMP• This subprogram calculates Pump Head at the end of each time• step.***********************************************************************
SUBROUTINE PUMP (PLN,PSLN,H1,H2,H3,Q2,Q3,N1,C1,A1,S1,EP,QRES,NE,FNC)
INTEGER NE,FNC,PLN,PSLN(1)REAL H1(1),H2(1),H3(1),Q2(1),Q3(1),N1(1),C1(1),A1(1),S1(1),EP(1)REAL N2(1),N3(1)DIMENSION QRES(NE,FNC)DO 10 II = 1, PLNN2(II)=(LOG10((H1(II)-H3(11))/(H1(II)-H2(II))))N3(II)=(LOG10(Q3(II)/Q2(II)))N1(II)=N2(II)+N3(II)Cl(II) = (H1(II)-H2(II))/(Q2(II)**N1(II))Sl(II) = -(N1(II)*C1(II)*(Q3(II)**(N1(II)-1)))Al(II) = H3(II) - (S1(II)*Q3(II))IF (QRES(PSLN(II),FNC) .GE. 0 .AND. QRES(PSLN(II),FNC) .LE. Q3(II)
*) THENEP(II) = H1(II) - (C1(II)*(QRES(PSLN(II),FNC)**(N1(II))))ELSE IF (QRES(PSLN(II),FNC) .GT. Q3(II)) THENEP(II) = Al(II) + (S1(II)*QRES(PSLN(II),FNC))END IF
10 CONTINUEWRITE (6,100)
100 FORMAT (//10X,'PUMP# Ni Cl Si Al EP',/,8X,10(1H-))DO 20 II = 1, PLNWRITE (6,110) II, N1(II), Cl(II), Sl(II), Al(II), EP(II)
20 CONTINUE110 FORMAT (10X,I3,1X,F10.4,1X,F10.4,1X,F10.4,1X,F10.4,1X,F10.4)
RETURNEND
164
APPENDIX D
165
EXAMPLE INPUT DATA
166
APPENDIX D
EXAMPLE INPUT DATA
The example input data instructions included herein is in no way a reference to
any of the results presented in this work. The example is to help the user of the computer
program in Appendix C. Free format is used for input data. English units and the Darcy-
Weisbach friction loss formula are used for this purpose. The program is also capable of
solving problems in SI units. It is up to the user to make a choice between the Darcy-
Weisbach and the Hazen-Williams friction loss formulae. Figure D-1 corresponds to the
following data set.
1. Input Data (Steady-State)
a. READ (5,*) NE, NN, NFGN, M, GR, ITMAX
NE = 5
NN = 3
NFGN =2
M = 2.0 (1.852 if Hazen-Williams formula was to be used)
GR = 32.2
ITMAX =20
167
b. READ (5,*) (I(H), II = 1, NE)
( I values for all pipes are read in from one line in the input file. Numbers correspond to
the node#s in the network)
0, 1, 2, 1,0
c. READ (5,*) (J(II), II = 1, NE)
(J values for all pipes are read in from one line in the input file. Numbers must
correspond to those in the line that reads in the I values)
1 , 2, 3, 3, 2
d. READ (5,*) (D(II), II = 1, NE)
1., 0.833, 0.833, 0.5, 1.
e. READ (5,*) (L(II), II = 1, NE)
1000., 1500., 1500., 500., 1000.
f. READ (5,*) (C(H), II = 1, NE)
skip since Hazen-Williams formula is not used in this example
g. READ (5,*) (FR(H), II = 1, NE)
0.02, 0.03, 0.03, 0.015, 0.02
h. READ (5,*) (Z(II), II = 1, NN)
0., 0., 0.
168
i. READ (5,*) (H(II), II = 1, NN)
Any initial value is valid
0., 0., 0.
j. READ (5,*) (QD(II), II = 1, NN)
skip since demand function is used in program Subroutine DEMF
k. READ (5,*) (Q(II), II = 1, NE)
Any initial value is valid
1., 1., 1., 1., 1.
1. READ (5,*) (I1FGN(II), II = 1, NE)
100., 0., 0., 0., 80.
169
2. Input data (Unsteady-State)
a. READ (5,*) NE, NN, NFGN, DT, TMAX, M, GR, ITMAX, NEL, NVL, PLN
NE = 5
NN = 3
NFGN = 2
DT = 3600S
TMAX = 86400s
M =2.0
GR = 32.2
ITMAX = 20
NEL = 1
NVL = 1
PLN = 1
The lines below are read in as before:
b. READ (5,*)
C. READ (5,*)
d. READ (5,*)
170
e. READ (5,*) (L(H), II -- 1, NE)
f. READ (5,*) (FR(II), II = 1, NE)
g. READ (5,*) (IO(11), II = 1, NE)
(Node numbers that are not circled in Figure D-la. These are the starting nodes for pipes,
corresponding to the I values previously stated in steady-state)
5, 2, 3, 2,6
h. READ (5,*) (JI(II), II = 1, NE)
(Numbers must correspond to the IO values above.)
2, 3, 4, 4, 3
The lines below are read in as before:
i. READ (5,*) (Z(II), H = 1, NN)
J. READ (5,*) (H(II), II = 1, NN)
heads from the steady-state results are read in
k. READ (5,*) (QUO, II = 1, NE)
flows from the steady-state results are read in
1. READ (5,*) (HFGN(II), II = 1, NNN)
100., 0., 0., 0., 80.
3. Variable Tank Data
a. READ (5,*) (SLN(II), II = 1, NEL)
1
b. READ (5,*) (ADJN(II), II = 1, NEL)
1
a. READ (5,*) (FGNN(II), II = 1, NEL)
5
a. READ (5,*) (HMAX(II), II = 1, NEL)
100.
a. READ (5,*) (HMIN(II), II = 1, NEL)
60.
a. READ (5,*) (TD(II), II = 1, NFL)
20.
4. Valve Data
a. READ (5,*) (KV(II), II = 1, NE)
171
10.
q3
172
0 Pipe #
0 Node #
a Nodal demand
Flow direction (arbitrary)
6
12
24t (hr)
Figure D-1. (a) Setup for Example Input Data
(b) Example Demand Function
APPENDIX E
173
NETWORK SPECIFICATION
Table E-1. Specification for Networks C, D and E
Pipe# L (m) D (m) f FGN (m) Hmax(m Hmin(m) TD (m)
1 1000 1 0.0179 1001 Network C 502 1000 0.3 0.02683 2000 0.5 0.02264 2000 1 0.01795 50 0.5 0.0226 50 70 30 105 Network C 37.93 45 30 106 1000 0.5 0.02267 1000 0.5 0.02268 0 0.5 0.0226 09 0 0.5 0.0226 0
TD = Tank Diameter = 10m
Pump Data (Pipe 1 in Network D)
hl h2 h3 Q2 Q3(m) (m) (m) (cms) (cms)
70 50 30 1.2 4
HFGN = 50m for simulation with pump
174
APPENDIX F
TABLES
175
Table F-1. Hourly Variation of Flow (cfs) and Head (ft) for Network A
dt = 120stime Q Q time Head Head
(hour) Dynamic Grad. Alg. (hour) Dynamic Grad. Alg.(All Pipes) (Node 26)
0 2 2 0 1395 13900.25 2.6 2.61 0.25 1300 13000.5 3 3.01 0.5 1200 1205
0.75 3.2 3.21 0.75 1165 11691 3 3.01 1 1200 1205
1.25 2.6 2.61 1.25 1280 12841.5 2 2.05 1.5 1365 1370
1.75 1.4 1.45 1.75 1430 14352 1 0.95 2 1470 1474
2.25 0.8 0.75 2.25 1480 14852.5 1 0.95 2.5 1470 1474
2.75 1.4 1.45 2.75 1430 14353 2 2 3 1360 1365
176
Table F-2. Hourly Variation of Flow (cfs) and Head (ft) for Network A
time(hour)
Head Flow
dt = 120s
Head Flow
dt = 240s
Head Flow
dt = 360s
0 1390 2 1390 2 1390 2
0.25 1300 2.61 1305.67 2.469 1312 2.171
0.5 1205 3.01 1210.67 2.869 1217 2.571
0.75 1169 3.21 1174.67 3.069 1181 2.771
1 1205 3.01 1210.67 2.869 1217 2.571
1.25 1284 2.61 1289.67 2.469 1296 2.171
1.5 1370 2.05 1375.67 1.909 1382 1.611
1.75 1435 1.45 1429.33 1.591 1423 1.889
2 1474 0.95 1468.33 1.091 1462 1.389
2.25 1485 0.75 1479.33 0.891 1473 1.189
2.5 1474 0.95 1468.33 1.091 1462 1.389
2.75 1435 1.45 1429.33 1.591 1423 1.889
3 1365 2 1359.33 2.141 1353 2.439
177
Figure F-3. Hourly Variation of Flow (cfs)and Head (ft) for Network B
time(hour)
dt =Head
(node 2)
400sHead
(node 7)Flow
(All Pipes)
0 1497.21 1491.63 20.5 1493.92 1481.76 2.950.75 1493.17 1479.5 3.13
1 1493.27 1479.83 3.11.25 1494.49 1483.46 2.811.5 1496.95 1490.83 2
1.75 1498.29 1494.85 1.62 1499.11 1497.3 1
2.25 1499.46 1498.36 0.882.5 1499.36 1498.07 1
2.75 1498.83 1496.51 1.33 1497.7 1493.4 2
178
Table F-4. Variation of Flow and Head for Network C
time
(sec)
Flowpipe 1(cms)
Flowpipe 5(cms)
WSELtank
(m)
0 1.79 0 37.93100 1.78 0.05 37.95200 1.76 0.1 37.98300 1.7 0.27 38360 1.5 1.2 38.4400 1.45 1 39500 1.36 0.9 40600 1.3 0.79 41.6700 1.23 0.72 42.5800 1.17 0.69 44
179
Table F-5. Hourly Variation of Head (m) at Node 2 of Network D
time 900 secdt
600 sec 300 sec 120 sec
(hour)0 80.895 80.895 80.895 80.8951 80.931 80.928 80.918 80.9132 80.928 80.924 80.916 80.9133 80.927 80.921 80.915 80.9134 80.925 80.919 80.915 80.9135 80.923 80.918 80.914 80.9146 80.001 79.547 78.237 74.7037 76.846 73.021 61.829 56.9858 74.028 68.145 57.983 56.9839 71.544 64.652 57.189 56.98310 69.379 62.211 57.028 56.98311 67.506 60.53 56.995 56.98312 65.895 59.383 56.989 80.99313 68.728 67.491 76.957 80.99314 70.92 72.321 80.176 80.99315 72.694 75.339 80.793 80.99316 74.135 77.264 80.916 80.99317 75.312 78.51 80.939 80.99318 76.276 79.325 80.943 80.993
19 77.068 79.861 80.944 80.993
20 77.72 80.217 80.944 80.993
21 78.259 80.454 80.945 80.99322 78.704 80.612 80.945 80.99323 79.074 80.717 80.945 80.993
24 79.381 80.787 80.945 80.993
180
Table F-6. Hourly Variation of Head (m) at Node 5 of Network D
time 900 secdt
600 sec 300 sec 120 sec
(hour)0 87.133 87.133 87.133 87.1331 87.131 87.131 87.131 87.132 87.131 87.131 87.131 87.13
3 87.131 87.132 87.131 87.1294 87.131 87.132 87.132 87.129
5 87.131 87.132 87.131 87.13
6 86.512 86.211 85.334 82.979
7 84.387 81.815 74.282 71.032
8 82.489 78.531 71.691 71.03
9 80.817 76.179 71.155 71.03
10 79.359 74.536 71.047 71.03
11 78.098 73.403 71.025 71.03
12 77.014 72.631 71.021 87.186
13 78.922 78.091 84.466 87.186
14 80.399 81.344 86.634 87.186
15 81.594 83.376 87.05 87.186
16 82.565 84.673 87.133 87.186
17 83.357 85.512 87.149 87.186
18 84.007 86.061 87.151 87.186
19 84.54 86.422 87.152 87.186
20 84.979 86.662 87.151 87.186
21 85.342 86.822 87.152 87.186
22 85.642 86.928 87.152 87.186
23 85.892 86.999 87.152 87.186
24 86.098 87.046 87.152 87.186
181
Table F-7. Hourly Variation of Flow (cms) in Pipe 2 of Network D
dttime 900 sec 600 sec 300 sec 120 sec
(hour)0 0.12 0.12 0.12 0.121 0.12 0.12 0.12 0.122 0.12 0.12 0.12 0.123 0.12 0.12 0.12 0.124 0.12 0.12 0.12 0.125 0.12 0.12 0.12 0.126 0.123 0.124 0.128 0.1387 0.132 0.143 0.17 0.188 0.14 0.155 0.178 0.189 0.147 0.164 0.18 0.1810 0.152 0.169 0.18 0.1811 0.157 0.173 0.18 0.1812 0.161 0.175 0.18 0.1213 0.154 0.157 0.132 0.1214 0.148 0.145 0.123 0.1215 0.144 0.137 0.121 0.1216 0.14 0.131 0.12 0.1217 0.137 0.128 0.12 0.1218 0.134 0.125 0.12 0.1219 0.132 0.124 0.12 0.12
20 0.13 0.123 0.12 0.1221 0.128 0.122 0.12 0.12
22 0.127 0.121 0.12 0.12
23 0.126 0.121 0.12 0.12
24 0.122 0.121 0.12 0.12
182
Table F-8. Hourly Variation of Flow (cms) in Pipe 7 of Network D
time 900 sec
dt600 sec 300 sec 120 sec
(hour)
0 0.344 0.344 0.344 0.3441 0.344 0.344 0.344 0.344
2 0.344 0.344 0.344 0.344
3 0.344 0.344 0.344 0.3444 0.344 0.344 0.344 0.344
5 0.344 0.344 0.344 0.344
6 0.352 0.356 0.367 0.396
7 0.379 0.409 0.486 0.517
8 0.401 0.445 0.511 0.517
9 0.42 0.468 0.515 0.517
10 0.436 0.484 0.516 0.517
11 0.449 0.495 0.516 0.517
12 0.46 0.502 0.516 0.344
13 0.441 0.449 0.378 0.344
14 0.425 0.415 0.351 0.344
15 0.412 0.392 0.346 0.344
16 0.401 0.376 0.345 0.344
17 0.392 0.366 0.344 0.344
18 0.384 0.358 0.344 0.344
19 0.377 0.354 0.344 0.344
20 0.372 0.351 0.344 0.344
21 0.367 0.348 0.344 0.344
22 0.364 0.347 0.344 0.344
23 0.361 0.346 0.344 0.344
24 0.345 0.345 0.344 0.344
183
Table F-9. Sensitivity Analysis on Network A
% change Node 2 Node 25 Node 26
h(0) 1493.457 1297.119 1244.16hL(0) 6.543 202.881 255.84
+10% D h 1493.457 1330 1278.7hL 6.543 170.014 221.302
-10% D h 1493.457 1237.23 1193hL 6.543 262.77 307.008
+50% L h 1493.457 1253.85 1198.11hL 6.543 246.15 301.891
-50% L h 1493.457 1340.39 1304.28hL 6.543 159.613 195.718
+25% f h 1493.457 1276.63 1230hL 6.543 223.372 269.911
-25% f h 1493.457 1318 1264.62hL 6.543 182.3 235.373
+25%q h 1493.457 1188.95 1141.82hL 6.543 311.053 358.176
-25% q h 1493.457 1362.02 1356.73hL 6.543 137.978 143.27
Dimension in feetResults obtained at t = 1 hourh = piezometric headhL = head Loss = FGNh - h = 1500 - h
184
REFERENCES
Al-Layla, M. A., et. al., Water Supply Engineering Design, Ann Arbor Science, AnnArbor, Michigan, 1977.
Cabrera, E., and Vela, A. F., ed., Improving Efficiency and Reliability in WaterDistribution Systems, Kluwer Academic Publishers, London, 1994.
Chaudhry, M. H., Applied Hydraulic Transients, Van Nostrand Rienhold, New York,1979.
Epp, R., and Fowler, A. G., "Efficient Code for Steady-State Flows in Networks,"Journal of the Hydraulics Division, ASCE, Vol. 96, No. HY1, January,1970, pp. 43-56.
Etter, D. M., Structured FORTRAN 77 for Engineers and Scientists,Benjamin/Cummings, New York, 1993.
Fox, J. A., Hydraulic Analysis of Unsteady Flow in Pipe Networks, MacMillan Press,London, 1977.
Gerald, C. F., and Wheatley, P. 0., Applied Numerical Analysis, Addison-Wesley, NewYork, 1994.
Holloway, M. B., "Dynamic Pipe Network Computer Model," Ph.D. dissertation(Civil Engineering), Washington State University, Pullman, Washington,1985.
Holloway, M. B., Chaudhry, M. H., "Comparison of Pipe-Network-AnalysisComputer Programs," Proceedings Volume 2, 6th Canadian Hydro-technical Conference, the Canadian Society for Civil Engineering, June,1983, Ottawa, Ontario, Canada, pp. 543-558.
Jeppson, R. W., Analysis of Flow in Pipe Networks, Ann Arbor Science, Ann Arbor,Michigan, 1976.
Jeppson, R. W., "User's Manual---Pipe Network Simulation Analysis ComputerProgram---NETWK," Civil and Environmental Engineering, Utah Water
185
186
Research Laboratory, Utah State University, Logan, Utah, 1980.
Koffman, E. B., and Friedman, F. L., Problem Solving and Structured Programming inFORTRAN 77, Addison-Wesley, New York, 1990.
Mohtar, R. H., Bralts, V. F., and Shayya, W. H., "A Finite Element Model forthe Analysis and Optimization of Pipe Networks," Soil and WaterDiv. of ASAE, Vol. 34, No. 2, March-April, 1991, pp. 393-401.
Onizuka, K., "System Dynamics Approach to Pipe Network Analysis," Journalof Hydraulic Engineering, ASCE, Vol. 112, No. 8, August, 1986.
Prasuhn, A. L., Fundamentals of Hydraulic Engineering, Saunders HBJ, New York,1987.
Press, W. H., et. al., Numerical Recipes (FORTRAN), Cambridge University Press,Cambridge, 1989.
Roberson, J. A., and Crowe, C. T., Engineering Fluid Mechanics, Houghton Mifflin,New Jersey, 1993.
Salgado, R., Todini, E., and O'Connel, P. E., "Comparison of the Gradient Method withsome Traditional Methods for the Analysis of Water Supply DistributionNetworks," International Conference on Computer Applications for Water Supplyand Distribution 1987, Leicester Poly-technic, U.K., 8-10 September, 1987.
Sevuk, S., "Steady and Unsteady flow Simulation in Pipe Networks," EngineeringSoftware Conference 1979, Southampton, U.K., 4-6 September, 1979.
Streeter, V. L., "Water Hammer Analysis of Distribution Systems," Journal of theHydraulics Division, ASCE, Vol. 93, No. HY5, September, 1967, pp. 185-201.
Todini, E., Pilati, S., "A Gradient Method for the Analysis of Pipe Networks,"International Conference on Computer Applications for Water Supply andDistribution 1987, Leicester Polytechnic, U.K., 8-10 September, 1987.
Walski, T. M., Analysis of Water Distribution Systems, Van Nostrand Reinhold, NewYork, 1984.
Wood, D. J., Funk, J. E., and Boulos, P. F., "Pipe Network Transients---Distributed andLumped Parameter Modeling," Pressure Surges—Proceedings of the 6thInternational Conference 1990, Bedford, U.K., 1990, pp. 131-142.
Wood, D. J., "Algorithms for Pipe Network Analysis and Their Reliability,"Research Report No. 127, Water Resources Research Institute, Universityof Kentucky, Lexington, Kentucky, 1981.
Wood, D. J., "User's Manual---Computer Analysis of Flow in Pipe Networks IncludingExtended Period Simulations," Department of Civil Engineering, University ofKentucky, Lexington, Kentucky, 1980.
Wood, D. J., Charles, C. O. A., "Hydraulic Network Analysis Using Linear Theory,"Journal of the Hydraulics Division, ASCE, Vol. 98, No. HY7,July, 1972, pp. 1157-1170.
Wylie, E. B., "The Microcomputer and Pipeline Transients," Journal of theHydraulics Division, ASCE, Vol. 109, No. HY12, December, 1983, pp.1723-1739.
187