Professional Documents
Culture Documents
Networks
General
The analysis of water flow through a closed, pressurized piping system represents a common
task in hydraulic engineering. Development of a computer system to perform the analysis requires application of the networking concepts explored in class in addition to numerical methods to solve nonlinear equations. The first semester project requires development of a software
system to perform analysis for piping networks. These notes describe the theory of pipe flow
and network analysis needed for the project.
A representative piping network is shown in Fig.1. Pipes are connected in closed loops with
a single reservoir supplying water at one of the junctions. Each pipe is full of water and pressurized. Specified amounts (flow rates) of water may be withdrawn or supplied to the system at
all nodes except the reservoir node. The fundamental quantities in the analysis are the flow
rate in each pipe and the pressure (head) at each node. The reservoir is modeled as a source
capable of supplying any required flow rate to the system and at a constant head. The analysis
determines the flow rate in each pipe and the head at each node.
The engineer describes the network for analysis by providing this information:
(1)
(2)
(3)
(4)
the known external flow rate at each node (equals zero when no external withdrawal or supply is imposed at node);
(5)
We require consecutive pipe and node numbers from 1...np and 1...nn. Each pipe in the network is assigned a positive direction by the order of nodes specified for the pipe incidences. For
example, pipe 2 in Fig. 1 is specified to have the incidences 2, 5 which implies a positive flow
in the pipe transports water from node 2 to node 5. A negative flow for pipe 2 denotes water
flow in the direction from node 5 to node 2.
CEE-490, CSE-491
1.0 cfs
0.5 cfs
[2]
8-- 2000
[5]
8-- 1500
1
8-- 1500
[1]
8-- 2000
[3]
1.0 cfs
6-- 3000
5
6
[4]
8-- 2000
[6]
6-- 1500
10-- 1000
10-- 2000
1.5 cfs
[7]
1.5 cfs
Notation
The following notation is adopted to simplify development of the governing equations and computational procedures. A subscript k denotes a pipe quantity, i.e., qk is the flow rate in the k th
pipe. Subscripts i, j and m denote node quantities, i.e., Hi --Hj is the change in head (pressure)
between nodes i and j (relative to node j). The number of pipes is given by np; the number of
nodes by nn. Other quantities are defined below.
pipe lengths
Lk (units in feet)
pipe diameters
Dk (units in inches)
Hi (units in feet)
Ci > 0
[i]
known external nodal flow Ci (units in cubic feet per second, cfs. A positive value
implies flow is being withdraw from system)
CEE-490, CSE-491
Hi Hj
fk
Hi Hj
(1)
where =0.54 and fk quantifies the frictional resistance to flow. To derive the above model, water is treated as an incompressible fluid. The frictional resistance, fk , is given by
fk =
8.52 10 5 L k
(independent of the flow rate)
HW 1.852
D 4.87
k
k
(2)
The factor of 8.52 also reflects the conversion of various units for terms in the equation (L must
be in feet, D in inches, H in feet, HW is dimensionless). In the above equations, Hi must be algebraically Hj otherwise the exponentiation operator is not defined. When Hi < Hj , Eq. (1) is
recast in the form
qk =
Hj Hi
fk
H j > H i
(3)
The following example employs realistic numbers for a pipe: Hi =26.3, Hj =1.0, L=1500,
HW=130, D=6. Equation (1) yields a flow rate q=1.0 cfs for the head loss of 25.3 over the
1500 length of the pipe. Both Eqs. (1) and (3) may be inverted to solve for the head loss given the
flow rate.
The head loss-flow rate relationship given by Eqs. (1) or (3) is highly nonlinear since 1.0.
This contrasts markedly to similar relationships in structural engineering, for example. In
structural problems, Hi and Hj are the nodal displacements, fk represents the element flexibility (inverse of stiffness) with qk representing the element force. In most structural models,
=1.0, and the resulting system of simultaneous equations is linear. In pipe flow problems,
the system of simultaneous equations is nonlinear which precludes a trivial solution.
Pipe k
[i]
Hj
Flow rate q k
[j]
CEE-490, CSE-491
[3]
[4]
[5]
Fm =
q k Cm = 0
(4)
k=1
where np denotes all pipes connecting to node m. In matrix form, Eq. (4) becomes
F = {0 } .
(5)
The flow rate, qk , for each pipe connected to the node is substituted from Eq. (1) or (3) into
Eq. (4). The Fm continuity equation for the node then contains the heads, Hj , at adjacent nodes
as the unknowns. Thus, {F}={0} represents a set of nn- 1, nonlinear simultaneous equations
for the unknown nodal heads Hi .
Figure 4 defines a simple 3 node, 3 pipe system used to develop the solution process in detail. The continuity equations at nodes 2 and 3 are:
CEE-490, CSE-491
1.5 cfs
[2]
HW
f
120 1.622
1000 12
120 0.667
1500 10
120 2.432
1
3
[1]
3.0 cfs
F2 = q 1 q 2 C2 = 0
(6a)
F3 = q 2 + q 3 C3 = 0 .
(6b)
H1 H2
q1 =
f1
H2 H3
q2 =
f2
H1 H3
q3 =
f3
(7a)
(7b)
(7c)
where we have assumed that H1>H2, H1>H3 and H2>H3 (H1 is a known value) with the result that each q>0. Upon substitution of Eqs. (7) into Eqs. (6), we have
H1 H2
F2 =
f1
H2 H3
F3 =
f2
H2 H3
f2
H1 H3
+
f3
C2 = 0
(8a)
C3 = 0
(8b)
where the only unknowns are H2 and H3. Using numerical values for the example network in
Fig. 4, Eqs. (8) become
100 H 2
F2 =
1.622
CEE-490, CSE-491
0.54
H2 H3
0.667
0.54
1.5 = 0
(9a)
H2 H3
F3 =
0.667
0.54
100 H 3
+
2.432
0.54
3.0 = 0 .
(9b)
This pair of nonlinear, simultaneous equations is solved using Newtons method as described in
the next section. The solution procedure requires an initial estimate for each unknown Hi .
These values are supplied by the engineer based on previous experience with solving pipe flow
problems. Fortunately, convergence of the iterative solution procedure is not overly dependent
on the selection of starting values for Hi .
Equations (6)-(9) assume the head at node 2 is greater than the head at node 3. During the
iterative solution process, the reverse condition may be found. To accommodate this situation,
Eq. (7) is generally evaluated using the absolute value of the term Hi --Hj with the sign of the
resulting flow rate determined by the sign of Hi --Hj . The resulting flow rates (with appropriate
sign) are then substituted into Eq. (6). In no case can the nodal heads H2, H3 be greater than
the head of the reservoir.
(10)
nn1
where the bold character indicates a vector of length nn- 1. Newtons method seeks to find a
correction {H(i)} such that
(11)
(12)
(13)
To first order, the incremental change {F(i)} is approximated by the differential, {dF(i)}, where
(14)
F 1
F
F
dH1 + 1 dH2 + + 1 dHs
H 1
H 2
H s
(15a)
dF s =
F s
F s
F
dH1 +
dH2 + + s dHs
H 1
H 2
H s
(15b)
where s=nn- 1. Row r and column r of [J(i)] corresponding to the reservoir node are omitted;
dHr 0 since the reservoir provides a fixed hydraulic head for the water supply. Note also that
the specified nodal flows Cm do not appear as dCm =0 as well.
The product [J(i)]{H(i)}[J(i)]{dH(i)} provides a linearized approximation to {F(i)} at {H(i)}
that remains valid over a small change in {H}. Use of this approximation for {F(i)} in Eq. (12)
leads to the nn- 1 set of linear, simultaneous equations
[J(H (i))]H (i) = R (i) .
(16)
The symbolic solution for this set of equations is written using the inverse of the Jacobian as
(17)
For all practical problems, the solution of Eq. (16) for the head corrections is accomplished using a standard linear equation solver, for example, Gauss elimination. The specific form of {F}
in the pipe flow model leads to a symmetric Jacobian matrix, i.e., Ji,j =Jj,i . Finally, the new estimate for the solution vector is given by {H(i+1)}={H(i)} + {H(i)}.
The iterative solution continues until the residual nodal flows, {R(i+1)}, computed with the
updated nodal heads approach zero. Since the residual flows have units of cubic feet per second,
an absolute convergence test is applicable and straightforward. The iterations continue until
each term in {R(i+1)} is tol, where tol is specified by the engineering analyst (a typical value
might be 0.01). (Note: in convergence tests of this type, the absolute value of each term in
{R(i+1)} is compared with tol).
Example
Newtons method is applied here to complete the example problem defined in Fig. 4. Eq. (15) is
applied to Eq. (8) to obtain the Jacobian matrix in symbolic form as
100 H 2
dF 2 =
f1
f1
H2 H3
dF 3 =
f2
f2
H2 H3
dH2
f2
f2
H2 H3
dH 2
f2
f2
H 2 H3
dH 2 +
f2
f2
100 H 3
dH 3
f3
f3
dH 3
(18a)
dH 3
(18b)
100 H 2
J 1,1 = 0.3329
1.622
CEE-490, CSE-491
0.46
H H3
0.8096 2
0.667
0.46
(19a)
H H3
J 1,2 = 0.8096 2
0.667
0.46
(19b)
(19c)
J 2,1 = J 1,2
J 2,2 = 0.8096
H
H0.667
0.46
0.2220
H
1002.432
0.46
(19d)
Note also Eq. (19) requires H2H3 otherwise the exponentiation operator is undefined. By re-deriving terms of [J] using the form of Eq. (6) with changed signs for q2 (which implies H3H2),
we find the form of Eq. (19) is identical with only the H2 - H3 terms replaced by H3 - H2.
To initialize the iterative solution, assume {H(1)}=95, 85. When substituted into Eq. (9),
the corresponding residual flows are {R(1)}=--3.9774, 3.9858. Using {H(1)} to form [J] in Eq.
(19), solve the set of linear equations
--0.431359
0.233005
H 2
0.233005
--0.329160
H 3
--3.9774
(20)
3.9858
Implementation
The core tasks in the software implementation of pipe flow analysis are:
(1)
computation of {R(i)} using the current estimate of the nodal heads {H(i)};
(2)
formation of the Jacobian matrix [J(i)] using the current estimate of the nodal
heads {H(i)};
(3)
solution of the simultaneous equations [J(i)]{H(i)}={--R(i)} to determine the corrective nodal heads.
This section describes tasks (1) and (2). Task (3) is performed with a standard Gauss elimination subroutine. The C++ code for task (3) will be provided and does need to be written as part of
the project.
The incidences table and the link_point- nodal_incidences data structure are employed to
complete tasks (1) and (2). We have previously used the names node, ipt and link for these arrays.
Computation of {R(i)}
Two algorithms are available. The first algorithm employs the link_point- nodal_incidences
data structure to compute Rm at node m completely before processing node m+1. The driving
loop spans over all nodes. The second algorithm employs the incidences table to include the contribution of the flow rate in each pipe on {R(i)}. The driving loop spans over all pipes. We adopt
the second algorithm in this project although neither algorithm has a decided advantage for
problems with all data resident in memory. The pseudo-code to generate {R(i)} using the second
algorithm is provided in Fig. 5.
CEE-490, CSE-491
Computation of [J(i)]
Several algorithms are available to construct [J(i)]. The approached outlined here employs the
link_point- nodal_incidences data structure. This data structure provides the list of pipes connected to each node in the network. Each row of [J(i)] is constructed sequentially beginning at
row 1 for node 1 (the reservoir node is simply skipped). The differential of the continuity equation at node m, see Eq. (4), is given by
np
dF m =
dqk
(21)
k=1
where the same result for dFm is also given by row m of [J(i)] multiplied into the column vector
{dH(i)}. Thus,
np
dF m =
nn
k=1
(22)
j=1
In large networks, most terms Jm,j are zero due to small number of pipes connected to a
node. To illustrate this, consider the portion of the network around node m shown in Fig. 6.
Node m is connected by pipes to nodes 2, 3 and 8. Consequently, the term dFm (the differential flow-rate at node m) is affected only by dH changes at nodes 2, 3, and 8. For node m, we
have
dF m = dq 5 dq 2 dq 10
(1) Initialize {R} with zeros
(2) Insert negative of the specified nodal flows into {R}
(3) Loop over all pipes; pipe=1, np
(23)
start
Hi
pipe
(3a)
(3b)
(3c)
compute the flow rate, q, in the pipe using Eq. (1). q is negative if
the flow direction is opposite the positive pipe direction.
(3d)
(3e)
end
Hj
CEE-490, CSE-491
(24)
with all other Jm,j terms=0. Each of the non--zero Jm,j terms has a simple physical interpretation. For example, Jm, 2 is the differential change in flow rate at node m caused by a unit value of
the head change (dH2) at node 2. The Jm,j coefficients are found by substituting expressions for
dq5, dq2 and dq10 into Eq. (23).
[3]
2
5
[2]
[m]
10
[8]
Hi Hj
fk
(H i H j) .
(25)
Hi Hj
dq k =
fk
fk
(dH i dHj) (H i H j) .
(26)
Hi Hj
k =
fk
fk
(H i H j)
(27)
(H i H j) .
(28)
(29)
10
(30a)
dq 10 = 10 dH m 10 dH 8 .
(30b)
Upon substituting these expressions for dq into Eq. (23) and gathering common terms multiplying the differential heads, dH2, dH3, dHm and dH8, we have
dF m = 5 dH 2 + 2 dH 3 + ( 2 5 10)dH m + 10 dH 8
(31)
(32)
J m,m = 2 5 10 ; J m,8 = 10 .
The value for each pipe connected to node m appears twice on row m; the sign of the value
depends on (1) the connectivity of the pipe to node m and (2) the sign of the head difference for
the pipe. In the above example, the proper sign for the connectivity is included directly in Eq.
(23). In computing k , the head difference Hi - Hj is assumed to be positive. Fortunately, the
combinations of sign changes caused by the two connectivities (+,--) and the head difference
(+,--) cancel in two of the four possible cases, leaving only two cases for implementation. k is
always computed as a positive value by using |Hi - Hj | rather than Hi - Hj in Eq. (27). The sign of
the connectivity of the pipe to node m alone then sets the sign applied to k in forming a term
Jm,j .
In the above development, the equation corresponding to the reservoir node r is omitted.
However, to simplify the numerical implementation we construct [J(i)] with size nn by nn. Row
r and column r are zeroed; a value of 1.0 is then placed into term Jr,r. The corresponding term
in the residual flow vector is also zeroed (see step (3) in Fig. 5). When the corrective heads are
computed by solving Eq. (16), the head change at the reservoir node is then zero. The pseudo-code to generate [J(i)] using the above procedure is provided in Fig. 7.
CEE-490, CSE-491
11
(2b)
CEE-490, CSE-491
12