R/coef_emitter.R

Defines functions coef_emitter

Documented in coef_emitter

#' Emmiter equation
#'
#' \code{coef_emitter} Calculates the coefficients of the emitter pressure-flow power equation
#'
#' @param h Pressure
#' @param q Flow rate
#' @importFrom stats lm
#' @importFrom stats coef
#' @export
#' @examples
#' h <- c(10, 20, 30)
#' q <- c(7.9, 11.4, 14.1)
#' coef_emitter(h, q)
coef_emitter <- function(h, q) {
  m <- lm(log(q) ~ log(h))

  return(list(
    coef_em = unname(exp(coef(m)[1])),
    exp_em = unname(coef(m)[2])
  ))
}
joaobtj/hydirrig documentation built on Oct. 2, 2023, 2:08 p.m.