R/water_density.R

Defines functions water_density

Documented in water_density

#' @title Saturated water Density
#' @description The density of water is about 1 gram per cubic centimetre (62 lb/cu ft):
#' this relationship was originally used to define the gram.
#' The density varies with temperature, but not linearly:
#' as the temperature increases, the density rises to a peak at 3.98 °C (39.16 °F)
#' and then decreases.
#' http://ddbonline.ddbst.de/DIPPR105DensityCalculation/DIPPR105CalculationCGI.exe
#' @author Dr. Raúl Trujillo Álvarez \email{dr.ing.trujillo@gmail.com}
#' @param temp  is in °C
#' @return density of water in (kg/m³)
#' @export
#' @examples
#' water_density(14.5)
#'
water_density <- function(temp = 20){
  stopifnot("The temperature must be between 3C and 60C !" = dplyr::between(temp, 3, 90))
  a <- 0.14395
  b <- 0.0112
  c <- 649.727
  d <- 0.05107
  temp = temp + 273.15
  density <- a/(b^(1+(1-temp/c)^d))
  return(density)
}
ratral/hyd4gpv documentation built on Feb. 5, 2022, 10:30 p.m.