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 [ |
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 |
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, (in m or ft), is input,
the input pipe data frame must also include columns for the length,
and
diameter,
, (both in m or ft) so
can be calculated. In this case,
a new
and
are calculated at each iteration, the final values of
which are included in the output. If input
or
columns are provided, values
for
are ignored. If an input
column is provided,
and
are
ignored. If the Colebrook equation is used to determine
, a water
temperature of
or
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
where:
If needed, the friction factor is calculated using the Colebrook
equation. The flow adjustment in each loop is calculated at each iteration as:
where is the loop number,
is the pipe number,
is the number of
pipes in loop
and
is the flow adjustment to be applied
to each pipe in loop
for the next iteration.
Value
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
See Also
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")