R/fct_plot_sigma.R

Defines functions plot_sigma

Documented in plot_sigma

#' Plot sigma for Incipient, Constant and Maximum cavitation
#'
#' @param cyl_name  Name of the control characteristic
#' @param b steepness
#' @param d upper value
#' @param e the effective dose
#' @param fls liquid pressure recovery full open (max between fl and Flp/Fp)
#' @import ggplot2 latex2exp glue hyd4gpv
#' @return ggplot graphic. of the sigma for Incipient, Constant and Maximum cavitation
#' @export
#'
#' @examples
#' library(dplyr)
#' param <- cylinder_parameter("VAG") %>% filter(cyl_name == "E")
#' plot_sigma(param$cyl_name,  param$kv_b,  param$kv_d, param$kv_e, param$fls)
#'
plot_sigma <- function(cyl_name, b, d, e, fls){

  Max.fls <- format(fls,digits = 3, nsmall = 0, big.mark = ',')

  x <- data.frame(x = 1:100)
  ggplot2::ggplot( data = x, mapping = aes(x = x)) +
    stat_function( fun = function(x) {sigma_mv(x, b, d, e, fls)}, size = 1, aes(colour = "3.-Maximum")) +
    stat_function( fun = function(x) {sigma_c(x, b, d, e, fls)},  size = 1,  aes(colour = "2.-Constant")) +
    stat_function( fun = function(x) {sigma_i(x, b, d, e, fls)},  size = 1,  aes(colour = "1.-Incipient")) +
    scale_colour_manual("Borders of the cavitation: ", values = c("green", "orange", "red")) +
    scale_x_continuous( breaks = seq(0, 100, 10)) +
    labs( title    = latex2exp::TeX(glue::glue("Sigma values $(\\sigma)$ for cilinder Typ <<cyl_name>>", .open = "<<", .close = ">>")),
          subtitle = latex2exp::TeX(glue::glue("$F_{L_{100\\%}}=$ <<Max.fls>>", .open = "<<", .close = ">>")),
          caption  = "Dr.Trujillo",
          x        = "Opening degree (%)",
          y        = latex2exp::TeX('Sigma value ($\\sigma$)')) +
    theme_bw() + theme(legend.position = "bottom")
}
ratral/gpvapp documentation built on May 13, 2022, 12:51 a.m.