19
METHODS FOR ANALYZING PIPE NETWORKS By Hans Bruun Nielsen 1 ABSTRACT: The governing equations for a general network are first set up and then reformulated in terms of matrices. This is developed to show that the choice of model for the flow equations is essential for the behavior of the iterative method used to solve the problem. It is shown that it is better to formulate the flow equa- tions in terms of pipe discharges than in terms of energy heads. The behavior of some iterative methods is compared in the initial phase with large errors. It is explained why the linear theory method oscillates when the iteration gets close to the solution, and it is further demonstrated that this method offers good starting values for a Newton-Raphson iteration. INTRODUCTION Steady-state analysis of flow and pressure in a piping system has been and still is a major task for many engineers, and a large number of competing computer programs exist for solving the problem. In this paper, we approach the problem from linear-algebra and numerical- analysis points of view. The treatment is valid for both water and gas net- works. We first set up the full system of equations, consisting of the continuity equations, which are linear, and the flow equations, which are nonlinear because the flow resistances depend on the solution. The formulation of flow resistances is essential: if they are formulated in terms of flow rates, then we can derive a set of generalized loop equations, while formulating the flow resistances in terms of head losses is equivalent to a set of node equa- tions. Neither of the nonlinear systems of equations can be solved directly, but an iterative method must be employed. A number of methods are in general use [see, e.g., Wood and Rayes (1981)], and we discuss some of them. We do discuss neither the existence nor the uniqueness of a solution, but assume (as in all engineering treatments of the problem) that the system has a unique solution. If we use an iterative method like Newton-Raphson method or the so- called linear theory method (Wood and Charles 1972) and formulate the flow resistances in terms of flow rates, then the successive values for flow rates obtained by iterating on the full system are identical to the values obtained by iterating on the reduced system consisting of the generalized loop equa- tions, and this result is independent of the choice of loops. Further, we ex- plain the oscillating behavior of results from a simple version of the linear theory method, and why a simple averaging modification of the method gives much better results. Finally, through some simple examples, we demonstrate that an efficient method consists in solving the generalized loop equations by means of the 'Assoc. Prof., Inst, for Numerical Analysis, Tech. Univ. of Denmark, Lyngby, Denmark. Note. Discussion open until July 1, 1989. To extend the closing date one month, a written request must be filed with the ASCE Manager of Journals. The manuscript for this paper was submitted for review and possible publication on October 1, 1987. This paper is part of the Journal of Hydraulic Engineering, Vol. 115, No. 2, Feb- ruary, 1989. ©ASCE, ISSN 0733-9429/89/0002-0139/S1.00 + $.15 per page. Pa- per No. 23190. 139 J. Hydraul. Eng. 1989.115:139-157. Downloaded from ascelibrary.org by Swinburne University of Technology on 08/26/14. Copyright ASCE. For personal use only; all rights reserved.

Methods for Analyzing Pipe Networks

Embed Size (px)

Citation preview

Page 1: Methods for Analyzing Pipe Networks

METHODS FOR ANALYZING P I P E NETWORKS

By Hans Bruun Nielsen1

ABSTRACT: The governing equations for a general network are first set up and then reformulated in terms of matrices. This is developed to show that the choice of model for the flow equations is essential for the behavior of the iterative method used to solve the problem. It is shown that it is better to formulate the flow equa­tions in terms of pipe discharges than in terms of energy heads. The behavior of some iterative methods is compared in the initial phase with large errors. It is explained why the linear theory method oscillates when the iteration gets close to the solution, and it is further demonstrated that this method offers good starting values for a Newton-Raphson iteration.

INTRODUCTION

Steady-state analysis of flow and pressure in a piping system has been and still is a major task for many engineers, and a large number of competing computer programs exist for solving the problem.

In this paper, we approach the problem from linear-algebra and numerical-analysis points of view. The treatment is valid for both water and gas net­works.

We first set up the full system of equations, consisting of the continuity equations, which are linear, and the flow equations, which are nonlinear because the flow resistances depend on the solution. The formulation of flow resistances is essential: if they are formulated in terms of flow rates, then we can derive a set of generalized loop equations, while formulating the flow resistances in terms of head losses is equivalent to a set of node equa­tions.

Neither of the nonlinear systems of equations can be solved directly, but an iterative method must be employed. A number of methods are in general use [see, e.g., Wood and Rayes (1981)], and we discuss some of them. We do discuss neither the existence nor the uniqueness of a solution, but assume (as in all engineering treatments of the problem) that the system has a unique solution.

If we use an iterative method like Newton-Raphson method or the so-called linear theory method (Wood and Charles 1972) and formulate the flow resistances in terms of flow rates, then the successive values for flow rates obtained by iterating on the full system are identical to the values obtained by iterating on the reduced system consisting of the generalized loop equa­tions, and this result is independent of the choice of loops. Further, we ex­plain the oscillating behavior of results from a simple version of the linear theory method, and why a simple averaging modification of the method gives much better results.

Finally, through some simple examples, we demonstrate that an efficient method consists in solving the generalized loop equations by means of the

'Assoc. Prof., Inst, for Numerical Analysis, Tech. Univ. of Denmark, Lyngby, Denmark.

Note. Discussion open until July 1, 1989. To extend the closing date one month, a written request must be filed with the ASCE Manager of Journals. The manuscript for this paper was submitted for review and possible publication on October 1, 1987. This paper is part of the Journal of Hydraulic Engineering, Vol. 115, No. 2, Feb­ruary, 1989. ©ASCE, ISSN 0733-9429/89/0002-0139/S1.00 + $.15 per page. Pa­per No. 23190.

139

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 2: Methods for Analyzing Pipe Networks

Newton-Raphson method combined with the linear theory method as a sim­ple and robust starting procedure.

FORMULATION OF PROBLEM

We consider the stationary flow of water or gas in a network with m pipes, r "reservoir" nodes, and n "interior" nodes. We do not explicitly consider pumps in the network, but they could easily be incorporated in our formu­lation.

The known quantities are: (1) The pipes: lengths, diameters, and material; (2) the discharges drawn from the interior nodes, Qu . . . , Q„; and (3) the energy heads at the reservoir nodes, pn+i, . . . , p„+r. The unknown quantities are: (1) The energy heads at the interior nodes, pu ..., pn; and (2) the dis­charges in the pipes, qu ..., qm. It generally holds that r s 1 and m > n s: m - n.

Before setting up equations for the unknowns, we must introduce a rule for the sign of the discharges in the pipes. Let the fth pipe connect nodes j n , and 7,2, mthji2 > j n . The discharge q, is positive when the flow direction is from node j,2 to node j n .

The unknowns satisfy the continuity equations (one for each interior node) and the flow equations (one for each pipe). We write the continuity equations in the form

m

2 aiMi = Qj, J = 1, • •., n (1)

1=1

where

au = 1, when; = jn (2a)

a,j= - 1 , wheny = j a (2b)

atj = 0, otherwise (2c)

The flow equations can be written

dflt = H,; Hi = hM - h]n, i = 1, . . . , m (3)

Here we have introduced hj, given by

hj = pj, when the fluid is water (4a)

hj = pj, when the fluid is gas (4b) and the flow resistances dt may be given, for example, by Colebrook and White's formula [ see Streeter and Wylie (1979)]. Note that di can be ex­pressed either in terms of qt or Ht. For illustration, we may consider a widely used power expression for d{.

di = c,k,|a-' (5a)

and the dual formulation

di = cfl^l'-P (56)

1 P = - (5c)

a 140

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 3: Methods for Analyzing Pipe Networks

Here c,- = a pipe constant [depending on length, diameter, and material of the pipe, and on the fluid (water or gas)]; and the exponent a = commonly chosen in the range 1.8 ^ a ^ 2.

MATRIX FORMULATION

To facilitate the development, we first reformulate the problem in terms of vectors and matrices. The given quantities and the unknowns can be col­lected in vectors

Q = [Qi. ••

WR = [h„+i,

and

Qnf-

•, h„+,

x =

(6a)

(6b)

• (7)

with q = [qu ..., qm]T; and h = [hu ..., hn]T. We further introduce the m

x (n + r) node incidence matrix A with elements atj given by Eq. 2. This matrix splits into an m X n matrix A and an m X r matrix AR, whose col­umns correspond to interior and reservoir nodes, respectively, i.e., A and A« consist of the first n and the last r columns of A, respectively.

Note that Ht defined in Eq. 3 can be expressed as

Hi = - ^ aahi

Hm]T satisfies so that the vector H = [Hlt

H = -Ah - A«hff

The flow Eqs. 3 can therefore be written

Dq + Ah = -ARII*, D = diag [du ..., d,„]

(8)

(9)

where D = D(x), expressed either in terms of q or in terms of H, i.e., h. The matrix formulation of the continuity Eqs. 1 is obviously

A*q= Q

The full system of equations for determining x can thus be written

(10)

D(x) A Ar O x +

Afihff

- Q o, D(x) = diag [^(x), . . . , dm(x)] (11a)

We shall also write the problem in the form

f(x) = 0 (lift)

REDUCTION OF NUMBER OF PRIMARY UNKNOWNS

The structure of the system in Eq. 11 allows for a reformulation, which depends on whether we choose to express D in terms of q or in terms of h. In both cases the reformulation results in a reduction of the number of "pri-

141

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 4: Methods for Analyzing Pipe Networks

mary" unknowns from the m + n elements in x. As we shall see, the choice D = D(q) leads to a generalization of the well-known loop equations with m — n primary unknowns, while the choice D = D(h) is equivalent with expressing the continuity equations in terms of energy head differences, cor­responding to n primary unknowns.

First consider the choice D = D(h) (i.e., the flow Eqs. 9 are linear in q), and assume that H,^ 0, i = 1, . . . , m. This implies that all d,-^ 0, so that D is nonsingular, and we can multiply Eq. 9 by A 7 ! ) - 1 and subtract it from Eq. 10. It follows that the solution satisfies

A'ET'Ah + A'ir 'Aflh* = - Q , D"1 = diag 1 1

A(h) dm(h). (12)

This is a nonlinear system of n equations in the unknown h. Note that Eq. 12 is just a matrix formulation of the continuity Eqs. 10 with qt expressed by means of Eqs. 3 and 8. Once h has been computed, q is easily found from Eq. 3.

Now consider the choice D = D(q), i.e., the flow Eqs. 9 are linear in h. To reduce the number of primary unknowns in this case, we note that the assumption about a unique solution implies that matrix A has full rank. The complete solution to the underdetermined linear system of Eqs. 10 can then be written in the form

q = qc + Cu (13a)

where qc is any solution to Eq. 10; u is any (m - n) vector, and the m X (m — n) matrix C satisfies

A rC = 0 (13b)

and

C ^ 0 (13c)

(we discuss choices of qc and C in the following). From Eq. 13b, it follows that C rA = 0, and when we multiply Eq. 9 by CT and introduce Eq. 13a we see that the solution to Eq. 11 satisfies

C rDCu + C rDqc = -CfAjjhj,, D = diag [d,(q), . . . , dm(q)] (14a)

This is a nonlinear system of m — n equations in the unknown u. Once u has been computed, q is given by Eq. 13a, and h can then be found by means of Eq. 3, starting with a pipe connected to a reservoir node and pro­ceeding into the network.

Note that Eq. 14a may be written in more compact form as

Cr(Dq + A«h«) = 0 (14b)

This is a matrix formulation, and a generalization, of the well-known loop equations, where the network is divided into m - n closed loops (modified in case of branches in the network). For each loop a discharge correction (corresponding to one component of u) is added to a set of discharges al­ready satisfying the continuity equations (as qc in Eq. 13a). The corrections are determined so that the accumulated head loss around each closed loop is zero. This corresponds to C r H = 0, with H given by Eq. 8.

142

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 5: Methods for Analyzing Pipe Networks

In distribution networks, there often is either only one reservoir node (r = 1) or h„+, = . . . = h„+r (e.g., when a local gas distribution network is supplied at several nodes from a major network, it is common practice to ignore the small differences in reservoir energy heads). In such cases we can ignore h^ in Eqs. 11, 12, and 14, since only differences between h-values appear in the equations. Therefore, if we subtract /i„+1 from all hj, j = 1, . . . , n + r, then these equations simplify to

D A _AT 0.

q

.h.

ATr 'Ah = - Q

CrDCu + CrDqc

0

LQ.

= 0

h = [hi - h„ ..,hn-hn+1]T

(15)

(16)

(17)

(18)

From the definition of H, it follows that D(h) = D(h), which is used for D in Eq. 16. In Eq. 17 D = D(q) = D(qc + Cu), and in Eq. 15, either of these two expressions may be used.

Note that Eq. 17 can be identified as the normal equations corresponding to the overdetermined system of equations

WCu = -Wqc + r W = diag[V^, . . . , Vd~m] (19)

where r = a residual vector, and the solution minimizes rTr. The approach taken in Vallaster et al. (1985) may be said to be connected with this inter­pretation.

Finally, qc and C in Eq. 13 may be computed as follows. From the as­sumption that A has full rank, it follows that there exists an n x n per­mutation matrix P such that

ArP = [F| G ] . (20)

where matrix F is nonsingular. qc and C, given by

F ' Q qc = P

C = P

0

- F ' G I

(21a)

(21*)

satisfy the requirements of Eq. 13. It follows from the definition of A that the elements of C given by Eq. 21 are 0, —1, or 1.

The columns of ArP are just the columns of AT in a permuted order. Often there is not a unique choice of which columns enter F and which enter G in Eq. 20. This corresponds to the well-known fact that in general there is not a unique choice of loops.

ITERATIVE SOLUTION

With an iterative method we choose a starting vector XQ and compute a series of iterates xu x2, ..., that (it is to be hoped) converge to the solution

143

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 6: Methods for Analyzing Pipe Networks

x*: f(x*) = 0. In accordance with Eq. 7, we let qk and hk — the first m and the last n components of \k, respectively. We shall discuss three different, widely used methods.

The first method is the so-called "linear theory method" (LTM), as de­scribed in Wood and Charles (1972). In our notation, it is derived by simply replacing D(x) in Eq. 11 by D* = D(x t), and then solving for x t + i :

Bk A] r-A*h*l _ xk+i = (22)

_Ar oj L Q J This method is reported to have poor convergence properties: the iterates oscillate when xk is close to x*. We explain this behavior below and show that the method is well suited for starting the iterative process.

The second method is Newton-Raphson iteration (NR). For our problem, this is based on the approximation

f(x* + e) « f, + J,e. . (23a)

where

«*=«(**) • (23fc)

and

J* = { 7 ^ } (23c)

and on the approximation being set equal to 0. NR can thus be written

x*+i = xk + hk (24a)

J*b» = -f* (24fc)

This method is known to have fast (quadratic) convergence when xk is close to x*.

The last method we consider is actually a class of methods that has be­come increasingly popular in the last few years [see Hansen (1988) and Val-laster et al. (1985)]. These methods consist in applying a general-purpose optimization algorithm to the problem, reformulated as

x* = argmin {||f(x)||} (25)

where ||-|| = any norm. We only mention two widely used algorithms, the Marquardt method and Powell's "dog-leg" method. Both are based on Eq. 25 with the squared two-norm:

||z||2 = xTx (26)

and on the approximation derived from Eq. 23:

||f(x, + e)f - \\tk + Jkef = fkfk + 2e rJfo + eTj[j,e (27)

The right-hand side is minimal when e = ek, the solution to

XfcJ*** = ~3k^k • (28)

This is identical to the Newton step defined by Eq. 24 (we assume that J^ is nonsingular). Both Marquardt's method and Powell's dog-leg method take

144

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 7: Methods for Analyzing Pipe Networks

this form called the Gauss-Newton method, in which xk is close to x*. In the initial steps, however, Eq. 23 may be a too crade approximation, and instead, it is developed that for small e, the steepest descent in the norm of f is obtained when e is in the direction of the negative gradient

x*+i = x* + kg* (29a)

gt = ~& • (.29b)

where Jk = the Jacobian defined in Eq. 23, and the choice of tk depends on the method.

It is outside the scope of this paper to discuss stopping criteria; we are more concerned with the errors in the initial stages of the iterative process.

BEHAVIOR OF NR AND LTIM

For our problem, the first two methods, LTM and NR, exhibit a very interesting behavior, which is not common knowledge. This behavior de­pends on the choice of formulation of the flow equations.

If the flow resistances are expressed in terms of discharges, i.e., D = D(q), and if q0 satisfies the continuity Eqs. 10, then the iterates ql7 q2, . . . determined by LTM or NR are the same when the method is applied to the full system, Eq. 11, as when it is applied to the reduced system, Eq. 14.

If the flow resistances are expressed in terms of differences in energy heads, i.e., D = D(h), then the iterates hi, h2, . . . determined by LTM or NR are the same when the method is applied to the full system, Eq. 11, as when it is applied to the reduced system, Eq. 12.

A detailed proof of these statements is given in Nielsen (1987). For LTM, the results are obtained directly as in the reductions from Eq. 11 to Eq. 14 or Eq. 12, respectively. For NR, it is developed that the only nontrivial elements in the Jacobian correspond to the diagonal D, and similar reduc­tions can then be performed.

The first statement is independent of the choice of C in Eq. 13, and an interesting implication is that the iteration process is independent of the choice of loops. This is contrary to a widespread belief. Note, however, that in our analysis, we assume direct solution of the successive linear systems of equa­tions given by Eqs. 22 or 24. The original Hardy Cross method corresponds to only solving the systems approximately by one sweep of point relaxation, combined with successive updating of the coefficient matrix. Our reasoning does not apply to this approach.

With the methods based on the formulation of the problem, in Eq. 25 the statements are not valid. Irrespective of the choice of formulation of the flow resistances, the first m elements in the negative gradient gk, defined in Eq. 29, depend on both qk and hk. However, experiments by Hansen (1988) indicate that gradient steps are only profitable for the first few iteration steps with a poor starting vector XQ. After that, it is better to use Gauss-Newton; then the method is identical to NR.

When the power expression of Eq. 5a is used, then it is easy to show [see Nielsen (1987)] that LTM and NR can be expressed in common form

q*+i = q* - •Y"IC[C7btC]-,Cr(Dicit + ARh«), k = 0,1,2, (30)

where y = 1 for LTM; and 7 = a for NR. Wood and Charles (1972) ob-

145

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 8: Methods for Analyzing Pipe Networks

served that the results from LTM oscillate when qk is close to the solution q* (we explain this behavior in the next section) and recommended to use instead the average of qk and the q*+i given by Eq. 30 with 7 = 1. It is easy to see that this average is also given by Eq. 30 but with 7 = 2. Thus, when a = 2, the "averaged LTM" is identical to NR.

Also when the power expression of Eq. 5b is used, the two methods can be expressed in common form

bft+i = h* - 7[A7D*-1Ar1[Q + ArD,-'(Ah, + A*hff)] (31)

where again 7 = 1 for LTM and 7 = a for NR. The results for LTM with Dk = D(ht) have not been observed to exhibit the oscillating behavior found with D t = D(q*).

WHY DOES LTM OSCILLATE?

We shall explain the oscillating behavior of LTM with D = D(q). For simplicity, we only consider the case where dt is given by the power expres­sion Eq. 5a with a = 2, as used in Wood and Charles (1972).

Let the flow resistances be given by Eq. 5a with a = 2, and let

q* = a + b (32a)

where Ara = Q and Arb = 0. If

k | a \b,\, i = 1, . . . , m (326)

then the solution to Eq. 22 is given by

q*+i = a - b (32c)

hk+i=hk (32d)

To see this, note that qk+1 = a - b obviously satisfies the continuity equations. In the flow equations, we have (for d, given by Eq. 5a with a = 2, and a and b satisfying Eq. 32b)

diqiMi = Ct\ot + bi\(flt - bd = c,|a,|( 1 + - ja,( 1 -

= c,|a,|a/l - ^j (33)

which is independent of k. This implies that

qk+p = a + ( - l ) ' b (34a)

hk+p = hk, p = 1, 2 (346)

and the statement is proven.

EFFECT OF SINGULAR D,

During the iterative process, it may happen that one or more quk — 0 or, equivalently, Hu = 0. Then also dtik = 0 (which is easily seen with the

146

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 9: Methods for Analyzing Pipe Networks

power expressions Eqs. 5a and 5b for a > 1, i.e., D t will be singular, and Di"1 does not exist.

With D = D(q), the effect of one or more vanishing dUk is simply that the contribution from the ith pipe is ignored in the system of equations cor­responding to Eq. 14. As long as not all the qUk are zero in any loop, the coefficient matrix is nonsingular, and we have a well-defined solution for updating q*.

With D = D(h), the situation is more serious, since we cannot construct the matrices needed in the iteration corresponding to Eq. 12. A simple rem­edy consists in replacing di(Hu) by

dt,k = 4(|#ul + S) (35)

where 8 = a small, positive number, chosen so that dj = d0It\) for //, significantly nonzero. However, this remedy does not really cure the prob­lem. In Nielsen (1987), we show that

Hi.k — 0 ^ Hiik+i 0 (36)

Thus, the simple modification given by Eq. 35 is not sufficient to guar­antee convergence of LTM or NR when the flow resistances are given by d, = 4(h).

EXAMPLES

In this section, we illustrate some of the given theoretical results and dem­onstrate that a robust and efficient iterative method is obtained if LTM is used for the first step and NR for all subsequent steps.

Example 1 Consider the very simple network shown in Fig. 1. Interior and reservoir

nodes are shown with circles and squares, respectively. We have m = 2, n = 1, r = 2, and h2 = h3 = H. We can use the simple version of the for­mulation of the problem, given by Eq. 15, and assume that the flow resis­tances are given by Eq. 5:

di

0 1

o r d2 1 1 0.

"«l"

92

_h_ =

"0" 0

LeJ

d, = 4q,r with

dt = cflgt" This simple problem can be solved explicitly:

i + e i

(37)

(38a)

FIG. 1. Simple Network

147

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 10: Methods for Analyzing Pipe Networks

*'--HifW om

- (38c)

We shall investigate how LTM and NR behave for this problem. First consider d{ = dt(qi). The 2 x 1 matrix C = [-1 1]T satisfies Eq. 13b, and we write

Q <lk= (I* + ——- Ce» = i + e I + e

(39)

i.e., e* is the relative error in q2yk. The common iteration formula of Eq. 30 yields the following expression for the relative error in q2,k+i'-

7 - 1 1 |0 — e*|a-1e - 6a|l + et|a_1

e- = — ^ + - | e - £ , r + r|1 + 6,r (40)

For —1 < e* < 9, both components of q* have the correct sign. It follows that

7 - a a(a - 1)(1 - 9) , . . r , e*+i « e* + 4, for e* « min {1,9} (41)

7 76 Therefore, with 7 = a, we get the well-known quadratic convergence of NR. Further

7 - 1 Be* «*+i = e* - —— 7—, for a = 2 and - 1 < e* < 9 (42)

7 9 + (9 - l)e* and it follows that ek+2 = ek, when 7 = 1, i.e., the oscillating behavior of LTM. It also follows from Eq. 40 that even when a 5̂ 2, we get oscillation between the end points of the region of correct sign: e* = — 1 —» €k+l = 9, and ek = 9 -» €k+1 = - 1 . Thus we conclude that NR is far superior to LTM for small |eJ.

For large |et| the situation is reversed. It follows from Eq. 40 that

7 - 1 1 9 - 9 " e*+i e* + - ——a, for e* » max {1,9} (43)

7 7 1 + 9

so that

NR: linear convergence

a - 1 / 1 \ e*+i ** ek, I « - e*, when a = 2 (44a)

a \ 2 / LTM:

1 "1" W

Thus, with LTM both components of qk+1 have the correct sign.

148

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 11: Methods for Analyzing Pipe Networks

I I I I I I I I I I I ! I I I I I I | I I I i I I I I I | I I I I I I I I I | I I I I I I I I I | I I i I I I I I I

- 4 - 2 0 2 4 6 8

FIG. 2. et+, (et) (Defined by Eq. 37) for LTM (Solid Curve) and NR (Dashed Curve); a = 1.85, 9 = 4 (With LTM ei+1 - * -0.643 for |et| -» «>)

i i i i i i i i i I i i i i i i i i i—i i i i i i i i i | i i i i i i i i i | i i i i i i i i i | i i i i i i i i i

- 4 - 2 0 2 4 6 8

FIG. 3. €(+2 (€,) (Defined by Eq. 37) for [(LTM,NR) Solid Curve] and [(NR.NR) Dashed Curve]; a = 1.85; 6 = 4 [with (LTM.NR) ek+2 -» 0.259 for \et\ -» » ]

This observation suggests that a robust and efficient method is obtained if we use LTM for the first iteration step, and then change to NR. In Fig. 2, we show €JB-I as a function of ek for LTM and NR, and in Fig. 3 we show ei+2(et) for (LTM.NR) and (NR,NR), i.e., one LTM-step followed by an NR-step and two NR-steps, respectively. It is seen that if qk is in the region of correct sign, then it is best to use NR twice, but outside this region it is better to use LTM for the first step.

Now consider d, = d,(h). We introduce the relative error bk

hk = -c2 Q

i + e (1 + 8*) (45a)

By means of Eq. 31, we find

S*+1 = 8, - 7d + 8t - |1 + 8,|'-p)

For 8* > — 1, hj, has the correct sign, and we get

(45b)

149

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 12: Methods for Analyzing Pipe Networks

3 T - 1

1 -j

y

2 — i i i i i i i i i 1 i i i i i i i i i

i ^ y

y y y y y / /

i i i i i i i i i i | i i i i i i i i i 1 i i i i i i i i i 1 i i i i i i i i i

FIG. 4. 8»+2 (84) Defined by Eq. 39) for [(LTM.NR) Solid Curve] and [(NR.NR) Dashed Curve]; a = 1.85

FIG. 5. Network with Two Closed Loops

8*+i - (1 - 7P)S* - - P7d - P)8|, for 18t| « 1 (45c)

Therefore, also with this choice, NR (7 = a = 1/3) had quadratic conver­gence in the limit. Further, for 8* = - 1 , Eq. 45b gives 8*+1 = - 1 ; i.e., be - 0 -» ht+i = 0, see Eq. 36. Finally, for large values of |8*| we get

S*+i « (1 - 7)8* + 7|5*P~P, for |8t| » 1 (45d)

so that bk+l « - ( a - 1)8* for NR, while LTM gives the more favorable &*+i » N ' " 3 HS*|1/2 for a « 2).

In Fig. 4, we show 8t+2(8t). As in Fig. 3, we give results for (LTM.NR) and (NR.NR). For 8* < - 1 and 8t > 2, it is best to use LTM for the first step.

Example 2 In Fig. 5, we show a network with m = 5, n = 3, and r — 1. We have

1 1 0 0 0 - 1 0 1 1 0

0 - 1 - 1 0 1

and we consider three different choices of C that satisfy Eq. 13b:

150

(46)

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 13: Methods for Analyzing Pipe Networks

c,=

~ 1 - 1

1 0

_o

o~ 0 i

- i i_

c2 =

" 1 - 1

0 1

-1

1 - 1

1 0 0.

1 - 1

0 1

_ - l

o" 0 1

- 1 1_

(47)

C[DC] =

CfDC2 =

CfDC3

d\ + dz + d3

dt+ d2

d\ + d2 + d± --dA - d<

The corresponding coefficient matrices in, for example, Eq. 14a are

<k d-s + d$ + d5_

d\ + di + 04 + ds d\ + d2

di + d2 + d3_

-d4 - d5

d3 + d4 + d5_

(48a)

(48fe)

(48c)

Cj corresponds to the closed loops 1-3-2-1 and 2-4-3-2, while C2 and C3 correspond to the loop 1-3-4-2-1 being coupled with 1-3-2-1 and 2-4-3-2, respectively.

When dt = d,(qi), we have shown that the iterates q* are independent of the choice of loops, i.e., choice of C (that satisfies Eq. 13b). However, it is seen that Ci offers the simplest expression for the matrix CrDC, and we use C = Ci in the following.

As in example 1, we use the power expressions of Eq. 5 for the flow resistances, and consider first the network given by c,- = c0(5,3,4,4,5); Qj - Go(0-9,0.5,1); and a = 1.85, where c0 and Q0 = constants. The flow (rounded to three digits) is given by

fio

0.447 0.453

-0.302 1.25 1.15

h* = - C o e > - ! 7.17 6.04 6.48

(49a)

(49b)

To investigate the behavior of LTM and NR, we first consider d, = d,(qi), and let

qk = q* + Cu* (50)

Uj has two components (m - n = 2). Therefore, the error qk+1 - q* cannot be expressed in a simple way as in example 1. Instead, we have computed the maximum relative error after one iteration as a function of the relative error before the step. More specifically, in Fig. 6 we show Eq(t) for LTM and NR, where

Eq{t) = max [We*)] (51a)

151

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 14: Methods for Analyzing Pipe Networks

f T j M M I I M I | M I M M M | I I MM M I | M M I M M J I M I M I I l | I I I I I M M | I M I M l l i | l l M M M I | l

1 6 8 9 10

FIG. 6. Eq(t) (Defined by Eq. 41) for Network Given by Fig. 5 and Eq. 40; LTM (Solid Curve) and NR (Dashed Curve)

e* = (51*)

It is seen that for e* larger than 1.6, NR has linear convergence, while the error from LTM does not exceed 1.2. Therefore, an initial LTM step is sure to give an iterate from which NR has fast convergence.

The network described previously is well balanced. To see whether this fact has a significant influence on the behavior of the iterations we have also investigated the network given by c, = c0(0.1,3,4,200,5); Qj = go(0.9,0.5, i); and a = 1.85, i.e., the first and fourth pipes are changed. The flow (rounded to three digits) is now given by

i * = Go

0.303 0.597 0.508 0.295 2.10

h* -c0Q^ 20.96 20.95 19.81

(52a)

(52b)

In Fig. 7, we show the behavior of Eq(i) for this network. It is seen that apart from certain irregularities (which probably correspond to the peak on the NR curve in Fig. 2), the bound on the error after one NR step grows linearly already from t «= 0.3. The bound on the error after one LTM step

FIG. 7. Eq(t) (Defined by Eq. 41) for Network Given by Fig. 5 and Eq. 42; LTM (Solid Curve) and NR (Dashed Curve)

152

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 15: Methods for Analyzing Pipe Networks

TABLE 1. Relative Error for Iteration on Network Given by Fig. S and Eq. 42

k (1)

4"" , (2)b

,<3)c

Iteration

0 (2)

5.0 x 10"' 5.0 x 10"' 5.0 x 10"'

1 (3)

1.2 6.8 x 10"'

1.2

2 (4)

3.5 x 10"' 1.7 x 10"' 1.2 x 10"'

3 (5)

8.3 x 10"' 2.7 x 10"2

1.7 x 10"2

4 (6)

2.1 x 10"' 1.2 x 10"3

4.4 x 10"4

5 (7)

5.6 x 10"' 1.2 x 10"6

3.3 x 10"7

"el0 = LTM used in all iterations. bet2) = NR used in all iterations. ceS.3) = LTM used in the first, and NR in all subsequent iterations. Note: q0 = e„[0.8073, 0.0927, 1.3017, 0.0056, 2.3944f,

exhibits a much less systematic behavior, but note that for all t we have Eq{t) < 1.5.

Because Eq(t) > t for some small values of t, it is not obvious from Fig. 7 that any of the iteration strategies discussed will converge. However, even when the starting vector q0 has an error in the direction that maximizes the error in q1( the error in q! is probably not in the worst direction. This is demonstrated in Table 1.

For k S: 2, we again observe the oscillating behavior of LTM. The best

FIG. 8. Eh(t) (Defined by Eq. 63) for Network Given by Fig. S and Eq. 40; LTM (Solid Curve) and NR (Dashed Curve)

FIG. 9. Network with Branch

153

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 16: Methods for Analyzing Pipe Networks

results are obtained by using LTM for the first step and NR for all the sub­sequent steps.

With the flow resistances given by Eq. 5b, we combine Eqs. 16 and 31 to give

h/n-i = (1 - 7)h* - 7[A7brlA]-1Q, D* = diag [dltk, ..., dm,k] (53)

where djik is given by Eq. 35 with 8 = 1(T40. In Fig. 8, we show the max­imum relative error Eh(t) after one iteration step on the second network. Similarly to Eq. 51, we define

Eh{t) = max {W8*)} (54a)

» . = •

h i (54b)

Note that even for this well-balanced net, we can only guarantee quadratic convergence of NR when 8* < 0.02.

Example 3 Finally, to demonstrate the versatility of our approach, we consider the

network shown in Fig. 9. Note that the network has a branch and two res­ervoir nodes (w = 1, n = , r = 2).

The node incidence matrix is given by

Ar =

1 - 1

0 0 0 0

0 0

1 0

- 1 0 0 0

0 0

0 1

- 1 0 0 0

0 0

0 0 1

- 1 0 0

0 0

0 0 0 1

- 1 0

0 0

0 0 0 1 0

- 1

0 0

0 0 0 1 0 0

- 1 0

0 0 0 0 1

- 1

0 0

0 0 0 0 1 0

0 - 1

0 0 0 0 0 1

- 1 0

0 0 0 0 0 1

0 - 1

(55)

The dotted line divides AT from (AR)T. Proceedings as in Eqs. 20 and 21, we can choose P so that matrix G corresponds to contributions from pipes 1, 5, 7, 9, and 10. A possible set of (qc,C) is given by

0 1 0 1 0 1 0 0 0 0 1

0 0 1 1 0 1 0 0 0 0 1

0 0 0 1 0 1 0 0 0 0 1

0 0 0 0 0 1 0 0 0 0 1

0 0 0 0 0 0 0 1 0 0 1

0 0 0 0 0 0 0 0 0 0 1

c =

1 1 1 0 0 0 0 0 0 0 0

0 0 0 0 1

- 1 0 1 0 0 0

0 0 0 0 0

- 1 1 0 0 0

- 1

0 0 0 0 0 0 0

- 1 1 0

- 1

0 0 0 0 0 0 0 0 0 1

- 1

(56)

Note that q4 is given explicitly: q4 = Q1 4- Q2 + Q3- This may also be seen directly from the network. Further

154

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 17: Methods for Analyzing Pipe Networks

CTA«H = (Ag - hi) (57)

so that when the two reservoir energy heads are equal, there is no contri­bution from this term (see the derivation of Eqs. 15-17).

CONCLUSION

We have shown that with commonly used iterative methods, the choice of formulating the flow resistances in terms of pipe discharges or in terms of energy heads completely determines the iterative process: the iterates for the primary unknowns obtained from the full system are identical to the iterates obtained from a reduced system of equations.

Choosing to formulate the flow resistances in terms of energy heads has two great advantages: (1) The reduced system, Eq. 12, is unique; and (2) it is easy to implement a computer program that solves this system. The dis­advantages with this choice, however, are serious: (1) It is difficult to get a good starting vector; and (2) as shown in Eq. 34 and illustrated by ex­amples, the convergence may be very slow. In accordance with Wood and Rayes (1981), but disagreeing with with, e.g., Edwin and Braun (1981) and Isaacs and Mills (1980), we therefore discourage the use of energy heads as primary unknowns.

Formulating the flow resistances in terms of pipe discharges has one dis­advantage; the need for computing a basis for the complete solution to the continuity equations, i.e., a matrix C that satisfies Eq. 13b. This, however, may be quite easily implemented as sketched in Eqs. 20 and 21, and at the same time one gets a starting vector q0 that satisfies the continuity equations. Once this computation has been done, the advantages of this choice are great: The number of primary unknowns, m — n, is typically about n/2, where n = the number of primary unknowns with the other choice. Further, if the linear theory method is used for the first iteration step, then our examples indicate that the Newton-Raphson method should converge to reasonable ac­curacy within very few iteration steps.

Finally, it should be emphasized that if a power expression is used for the flow resistances, then it follows from Eqs. 30 and 31 that the choice between the linear theory method and the Newton-Raphson method is simply a choice between the two values 1 and a for the parameter 7.

APPENDIX I. REFERENCES

Edwin, K. W., and Braun, H. (1981). "Lastfluprechnung in vermaschten Fern-warmenetzen." Fernwarme International, FWI, Jg.15, 27-33.

Hansen, C. T. (1988). "Optimization of large networks for natural gas," thesis pre­sented to the Institute of Numerical Analysis, Technical University of Denmark, at Lyngby, Denmark, in partial fulfillment of the requirements for the degree of Doctor of Philosophy.

Isaacs, L. T., and Mills, K. G. (1980). "Linear theory methods for pipe network analysis." J. Hydr. Div., ASCE, 106(HY7), 1191-1201.

155

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 18: Methods for Analyzing Pipe Networks

Nielsen, H. B., (1987). "An efficient method for analyzing pipe networks." Report No. 362, DCAMM, Technical University of Denmark, Lyngby, Denmark.

Streeter, V. L., and Wylie, E. B. (1979). Fluid mechanics. McGraw-Hill, Tokyo, Japan.

Vallaster, W. B., Burchard, H. G., and Sasscer, E. P. (1985). "Nonlinear least squares applied to liquid piping design." Proc, 60th Annual Tech. Conf. SPE, Las Vegas, Nev.

Wood, D. J., and Charles, C. O. A. (1972). "Hydraulic network analysis using linear theory." J. Hydr. Div., ASCE, 98(HY7), 1157-1170.

Wood, D. J., and Rayes, A. G. (1981). "Reliability of algorithms for pipe network analysis." J. Hydr. Div., ASCE, 107(HY7), 1145-1161.

APPENDIX II. NOTATION

The following symbols are used in this paper:

A A

A* <h c Ci

D d,

• •,zp]

) = 0 Hi

H hj h

hR h I

J* it

LTM m

NR n r

Q q

qc

T u X

a P 1

= = = = = = = = = = =

= = = = = = = = = = = = = = = =

= = = = = =

m x n matrix, first n columns of A; m x (n + r) node incidence matrix with elements %; m X r matrix, last r columns of A; coefficient in continuity equations (Eq. 2); m X (m — n) matrix that satisfies Eq. 13fo; resistance coefficient (Eq. 5); diagonal m x m matrix (Eq. 9); flow resistance (Eq. 3); diagonal p X p matrix with z, as fth diagonal element; nonlinear system of equations to solve Eq. 11; difference between ft-values at endpoints of the fth pipe (Eq. 3); m-vector of //,; defined in Eq. 4; n-vector of ^-values at interior nodes (Eq. 7); r-vector of reservoir /j-values (Eq. 6); defined in Eq. 18; identity matrix; Jacobian computed at xk (Eq. 23); iteration number used as index on iterates; abbreviation for linear theory method (Eq. 22); number of pipes; abbreviation for Newton-Raphson method (Eq. 24); number of interior nodes; number of reservoir nodes; n-vector of discharges drawn at interior nodes (Eq. 6); m-vector of pipe discharges (Eq. 7); any w-vector that satisfies the continuity equations (Eq. 1.3a); used as superscript, Ar is transpose of matrix A; any (m — ri) vector; (m + n) vector of unknowns (Eq. 7); exponent in resistance formula Eq. 5; = l /« ; iteration parameter, defining choice between LTM and NR (Eqs. 30 and 31);

156

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.

Page 19: Methods for Analyzing Pipe Networks

8 = defined in Eq. 38; 0 = vector or matrix (determined by the context) with all

elements equal to zero; •| = norm; two-norm defined in Eq. 26; * = indicates true solution.

157

J. Hydraul. Eng. 1989.115:139-157.

Dow

nloa

ded

from

asc

elib

rary

.org

by

Swin

burn

e U

nive

rsity

of

Tec

hnol

ogy

on 0

8/26

/14.

Cop

yrig

ht A

SCE

. For

per

sona

l use

onl

y; a

ll ri

ghts

res

erve

d.