hardycross {hydraulics}R Documentation

Applies the Hardy-Cross method to solve for pipe flows in a network.

Description

This function uses the Hardy-Cross method to iteratively solve the equations for conservation of mass and energy in a water pipe network. The input consists of a data frame with the pipe characteristics and lists of the pipes in each loop (listed in a clockwise direction) and the initial guesses of flows in each pipe (positive flows are in a clockwise direction).

Usage

hardycross(
  dfpipes = dfpipes,
  loops = loops,
  Qs = Qs,
  n_iter = 1,
  units = c("SI", "Eng"),
  ret_units = FALSE
)

Arguments

dfpipes

data frame with the pipe data. Format is described above, but must contain a column named _ID_.

loops

integer list defining pipes in each loop of the network.

Qs

numeric list of initial flows for each pipe in each loop [m3s1m^3 s^{-1} or ft3s1ft^3 s^{-1}]

n_iter

integer identifying the number of iterations to perform.

units

character vector that contains the system of units [options are SI for International System of Units and Eng for English (US customary) units.

ret_units

If set to TRUE the value(s) returned for pipe flows are of class units with units attached to the value. [Default is FALSE]

Details

The input data frame with the pipe data must contain a pipe ID column with the pipe numbers used in the loops input list. There are three options for input column of the pipe roughness data frame:

Column Name Approach for Determining K
ks f calculated using Colebrook equation, K using Darcy-Weisbach
f f treated as fixed, K calculated using Darcy-Weisbach
K K treated as fixed

In the case where absolute pipe roughness, ksks (in m or ft), is input, the input pipe data frame must also include columns for the length, LL and diameter, DD, (both in m or ft) so KK can be calculated. In this case, a new ff and KK are calculated at each iteration, the final values of which are included in the output. If input KK or ff columns are provided, values for ksks are ignored. If an input KK column is provided, ksks and ff are ignored. If the Colebrook equation is used to determine ff, a water temperature of 20oC20^{o}C or 68oF68^{o}F is used.

The number of iterations to perform may be specified with the n_iter input value, but execution stops if the average flow adjustment becomes smaller than 1 percent of the average flow in all pipes.

The Darcy-Weisbach equation is used to estimate the head loss in each pipe segment, expressed in a condensed form as hf=KQ2h_f = KQ^{2} where:

K=8fLπ2gD5K = \frac{8fL}{\pi^{2}gD^{5}}

If needed, the friction factor ff is calculated using the Colebrook equation. The flow adjustment in each loop is calculated at each iteration as:

ΔQi=j=1piKijQjQjj=1pi2KijQj2\Delta{Q_i} = -\frac{\sum_{j=1}^{p_i} K_{ij}Q_j|Q_j|}{\sum_{j=1}^{p_i} 2K_{ij}Q_j^2}

where ii is the loop number, jj is the pipe number, pip_i is the number of pipes in loop ii and ΔQi\Delta{Q_i} is the flow adjustment to be applied to each pipe in loop ii for the next iteration.

Value

Returns a list of two data frames:

See Also

colebrook, darcyweisbach

Examples


#              A----------B --> 0.5m^3/s
#              |\   (4)   |
#              | \        |
#              |  \       |
#              |   \(2)   |
#              |    \     |(5)
#              |(1)  \    |
#              |      \   |
#              |       \  |
#              |        \ |
#              |   (3)   \|
# 0.5m^3/s --> C----------D

#Input pipe characteristics data frame. With K given other columns not needed
dfpipes <- data.frame(
ID = c(1,2,3,4,5),                     #pipe ID
K = c(200,2500,500,800,300)            #resistance used in hf=KQ^2
)
loops <- list(c(1,2,3),c(2,4,5))
Qs <- list(c(0.3,0.1,-0.2),c(-0.1,0.2,-0.3))
hardycross(dfpipes = dfpipes, loops = loops, Qs = Qs, n_iter = 1, units = "SI")


[Package hydraulics version 0.7.0 Index]