% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regulation_matrix_concentration.R
\name{regulation_matrix_concentration}
\alias{regulation_matrix_concentration}
\title{Concentration reduction matrix calculation}
\usage{
regulation_matrix_concentration(scenario, regulation)
}
\arguments{
\item{scenario}{data.frame with log_reduction column obtained with simulate_treatment function}

\item{regulation}{data.frame regulation table to compare to simulation results}
}
\value{
formattable
}
\description{
Calculate the difference of achieve concentration in effluent according to regulation
}
\examples{
\donttest{
library(dplyr)
library(purrr)
scenario_example <- create_scenario(system.file("input_1culture_2pop.xlsx", 
                                                package = "ambre"))

scenario_exposure <- scenario_example |> mutate(
     volume = map(
         .x = config,                                         
         .f = ~ simulate_exposure(config = .x)))

scenario_patho <- update_pathogen(scenario = scenario_exposure, 
                                  pathoName = c("Rotavirus", "Campylobacter jejuni", "Norovirus"))
concentration = map(.x = scenario_patho$config,
                   .f= ~ simulate_inflow(.x))
scenario_concentration <- scenario_patho |> mutate(inflow_concentration = concentration)
scenario_ini_dose <- initial_dose_calculation(scenario = scenario_concentration)

scenario_barrier <- update_treatment_scheme(scenario = scenario_ini_dose, initial_situation = TRUE)

scenario_barrier$config <- purrr::pmap(
  list(
    config = scenario_barrier$config,
    barrierID = scenario_barrier$SupplementaryProcessID,
    cropHeight = scenario_barrier$CropHeight,
    matrixID = scenario_barrier$MatrixID,
    popID = scenario_barrier$PopulationID,
    decay = scenario_barrier$nb_day_decay
  ),
  function(config, barrierID, cropHeight, matrixID, popID, decay) {

    if (barrierID \%in\% c(24, 26, 27, 28) &&
        matrixID \%in\% c(3, 5)) {

      update_logreduction_specific_barrier(
        config = config,
        cropHeight = cropHeight,
        barrierID = barrierID
      )

    } else if (barrierID \%in\% c(12)) {

      update_logreduction_decay(
        config = config,
        cropHeight = cropHeight,
        barrierID = barrierID,
        popID = popID,
        nb_day_decay = decay
      )

    } else if (barrierID \%in\% c(9,13,14,15,16,17,18,24,26,27,28)) {

      update_logreduction_path(
        config = config,
        matrixID = matrixID,
        barrierID = barrierID,
        popID = popID
      )

    } else {
      config
    }
  }
)
  
scenario_logreduction <- scenario_barrier |> 
    mutate(log_reduction = map(config, simulate_treatment))

regulation_concentration <- config_ambre$regulation$regulation_value |> 
  dplyr::filter(Country == "France") |>
  dplyr::select(-c(Country, RegulationID, Reduction))

regulation_matrix_concentration(scenario = scenario_logreduction,
                                regulation = regulation_concentration)
}
}
