View source: R/solvect_chlorine.R
solvect_chlorine | R Documentation |
This function takes a water defined by define_water and other disinfection parameters
and outputs a data frame of the required CT (ct_required
), actual CT (ct_actual
), and giardia log removal (glog_removal
).
For a single water, use solvect_chlorine
; to apply the model to a dataframe, use solvect_chlorine_once
.
For most arguments, the _chain
and _once
helpers
"use_col" default looks for a column of the same name in the dataframe. The argument can be specified directly in the
function instead or an unquoted column name can be provided.
solvect_chlorine(water, time, residual, baffle, free_cl_slot = "residual_only")
solvect_chlorine_once(
df,
input_water = "defined_water",
time = "use_col",
residual = "use_col",
baffle = "use_col",
free_cl_slot = "residual_only",
water_prefix = TRUE
)
water |
Source water object of class "water" created by |
time |
Retention time of disinfection segment in minutes. |
residual |
Minimum chlorine residual in disinfection segment in mg/L as Cl2. |
baffle |
Baffle factor - unitless value between 0 and 1. |
free_cl_slot |
Defaults to "residual_only", which uses the residual argument. If "slot_only", the model will use the free_chlorine slot in the input water. "sum_with_residual", will use the sum of the residual argument and the free_chlorine slot. |
df |
a data frame containing a water class column, which has already been computed using define_water_chain |
input_water |
name of the column of Water class data to be used as the input for this function. Default is "defined_water". |
water_prefix |
name of the input water used for the calculation will be appended to the start of output columns. Default is TRUE. |
CT actual is a function of time, chlorine residual, and baffle factor, whereas CT required is a function of pH, temperature, chlorine residual, and the standard 0.5 log removal of giardia requirement. CT required is an empirical regression equation developed by Smith et al. (1995) to provide conservative estimates for CT tables in USEPA Disinfection Profiling Guidance. Log removal is a rearrangement of the CT equations.
For large datasets, using fn_once
or fn_chain
may take many minutes to run. These types of functions use the furrr package
for the option to use parallel processing and speed things up. To initialize parallel processing, use
plan(multisession)
or plan(multicore)
(depending on your operating system) prior to your piped code with the
fn_once
or fn_chain
functions. Note, parallel processing is best used when your code block takes more than a minute to run,
shorter run times will not benefit from parallel processing.
solvect_chlorine
returns a data frame containing required CT (mg/Lmin), actual CT (mg/Lmin), and giardia log removal.
solvect_chlorine_once
returns a data frame containing the original data frame and columns for required CT, actual CT, and giardia log removal.
Smith et al. (1995)
USEPA (2020)
See references list at: https://github.com/BrownandCaldwell-Public/tidywater/wiki/References
example_ct <- define_water(ph = 7.5, temp = 25) %>%
solvect_chlorine(time = 30, residual = 1, baffle = 0.7)
library(dplyr)
ct_calc <- water_df %>%
define_water_chain() %>%
solvect_chlorine_once(residual = 2, time = 10, baffle = .5)
chlor_resid <- water_df %>%
mutate(br = 50) %>%
define_water_chain() %>%
mutate(
residual = seq(1, 12, 1),
time = seq(2, 24, 2),
baffle = 0.7
) %>%
solvect_chlorine_once()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.