hardycross  R Documentation 
This function uses the HardyCross 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).
hardycross(
dfpipes = dfpipes,
loops = loops,
Qs = Qs,
n_iter = 1,
units = c("SI", "Eng"),
ret_units = FALSE
)
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 [ 
n_iter 
integer identifying the number of iterations to perform. 
units 
character vector that contains the system of units [options are

ret_units 
If set to TRUE the value(s) returned for pipe flows are of
class 
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 DarcyWeisbach 
f  f treated as fixed, K calculated using DarcyWeisbach 
K  K treated as fixed 
In the case where absolute pipe roughness, ks
(in m or ft), is input,
the input pipe data frame must also include columns for the length, L
and
diameter, D
, (both in m or ft) so K
can be calculated. In this case,
a new f
and K
are calculated at each iteration, the final values of
which are included in the output. If input K
or f
columns are provided, values
for ks
are ignored. If an input K
column is provided, ks
and f
are
ignored. If the Colebrook equation is used to determine f
, a water
temperature of 20^{o}C
or 68^{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 DarcyWeisbach equation is used to estimate the head loss in each
pipe segment, expressed in a condensed form as h_f = KQ^{2}
where:
K = \frac{8fL}{\pi^{2}gD^{5}}
If needed, the friction factor f
is calculated using the Colebrook
equation. The flow adjustment in each loop is calculated at each iteration as:
\Delta{Q_i} = \frac{\sum_{j=1}^{p_i} K_{ij}Q_jQ_j}{\sum_{j=1}^{p_i} 2K_{ij}Q_j^2}
where i
is the loop number, j
is the pipe number, p_i
is the number of
pipes in loop i
and \Delta{Q_i}
is the flow adjustment to be applied
to each pipe in loop i
for the next iteration.
Returns a list of two data frames:
dfloops  the final flow magnitude and direction (clockwise positive) for each loop and pipe
dfpipes  the input pipe data frame, with additional columns including final Q
colebrook
, darcyweisbach
# AB > 0.5m^3/s
# \ (4) 
#  \ 
#  \ 
#  \(2) 
#  \ (5)
# (1) \ 
#  \ 
#  \ 
#  \ 
#  (3) \
# 0.5m^3/s > CD
#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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.