R/flow_calculation.R

Defines functions flow_calculation

Documented in flow_calculation

#' Flow Calculation
#' @description Pressure Drop in Pipe with Losses (Determine flow)
#' @param pipe_length length of pipe  (m)
#' @param dn inner diameter of pipe  (m)
#' @param roughness internal roughness of the pipe in (m)
#' @param zeta loss coefficient
#' @param dp pressure diff.
#' @param temp temperature in °C
#' @importFrom stats uniroot
#'
#' @return flow in m3/s
#' @export
#'
flow_calculation <- function(pipe_length, dn, roughness, zeta, dp, temp = 15.6){

  root <- uniroot( function(x){ darcy_weisbach(x, pipe_length, dn, roughness, temp) +
      minor_losses(x, dn, zeta) - dp } ,
      lower = 0.0001,
      upper = 10,
      tol   = 1e-10)
  return(root$root)
}
ratral/hyd4gpv documentation built on Feb. 5, 2022, 10:30 p.m.