R/psychrometric-graph-enthalpy-intersect.R

#' Intersection between enthalpy line and 100 \% RH line
#'
#' Calculates the intersection of RH 100 \% line and the enthalpy line.
#' @param enthalpy Vector of enthalpies [kJ/kg].
#' @param alt Vector of altitudes [m]. Defaults to 0 m (sea level).
#' @family PsychrometricGraph
#' @return Returns the dry-bulb temperature at which the enthalpy and
#'  100 \% RH line intersects [degC].
#' @keywords internal
#' @examples
#' enthalpy_intersect(enthalpy = 50)
#' @author Christoffer Rasmussen

enthalpy_intersect <- function(enthalpy, alt = 0) {
  
  temp <- seq(-75, 75, 0.1)
  
  df.test <- data.frame(
    temp = temp,
    enthalpy.diff =
      abs(-0.557341 * (temp - 0.994036 * enthalpy) / (temp + 1385.6) -
            sat_hum_ratio(temp, alt))
  )
  
  return(df.test$temp[which.min(df.test$enthalpy.diff)])
}
jinlee86/bems_analysisr_package documentation built on May 14, 2019, 8:34 a.m.