View source: R/chemdose_chloramine.R
chemdose_chloramine | R Documentation |
chemdose_chloramine
, adopted from the U.S. EPA's Chlorine Breakpoint Curve Simulator,
calculates chlorine and chloramine concentrations based on the two papers Jafvert & Valentine
(Environ. Sci. Technol., 1992, 26 (3), pp 577-586) and Vikesland et al. (Water Res., 2001, 35 (7), pp 1766-1776).
Required arguments include an object of class "water" created by define_water
, chlorine dose, and reaction time.
The function also requires additional water quality parameters defined in define_water
including temperature, pH, and alkalinity.
chemdose_chloramine(
water,
time,
cl2 = 0,
nh3 = 0,
use_free_cl_slot = FALSE,
use_tot_nh3_slot = FALSE
)
chemdose_chloramine_chain(
df,
input_water = "defined_water",
output_water = "chlorinated_water",
time = "use_col",
cl2 = "use_col",
nh3 = "use_col",
use_free_cl_slot = "use_col",
use_tot_nh3_slot = "use_col"
)
water |
Source water object of class "water" created by |
time |
Reaction time (minutes). Time defined needs to be greater or equal to 1 minute. |
cl2 |
Applied chlorine dose (mg/L as Cl2), defaults to 0.If not specified, use free_chlorine slot in water. |
nh3 |
Applied ammonia dose (mg/L as N), defaults to 0. If not specified, use tot_nh3 slot in water. |
use_free_cl_slot |
Defaults to FALSE. If TRUE, uses free_chlorine slot in water. If TRUE AND there is a cl2 input, both the free_chlorine water slot and chlorine dose will be used. |
use_tot_nh3_slot |
Defaults to FALSE. If TRUE, uses tot_nh3 slot in water. If TRUE AND there is a nh3 input, both the tot_nh3 water slot and ammonia dose will be used. |
df |
a data frame containing a water class column, which has already been computed using define_water_chain. The df may include a column named for the applied chlorine dose (cl2_dose), and a column for time in hours. |
input_water |
name of the column of water class data to be used as the input for this function. Default is "defined_water". |
output_water |
name of the output column storing updated parameters with the class, water. Default is "chlorinated_water". |
The function will calculate the chlorine and chloramine concentrations and update the "water" class object proceed to the next steps of the treatment chain.
chemdose_chloramine
returns a water class object with predicted chlorine and chloramine concentrations.
chemdose_chloramine_chain
returns a data frame containing water class column with updated chlorine residuals.
See references list at: https://github.com/BrownandCaldwell-Public/tidywater/wiki/References
breakpoint <- define_water(7.5, 20, 65, free_chlorine = 5, tot_nh3 = 1) %>%
chemdose_chloramine(time = 40, cl2 = 2, nh3 = 1, use_free_cl_slot = TRUE)
library(dplyr)
breakpoint <- water_df %>%
mutate(free_chlorine = 5, tot_nh3 = 1) %>%
slice_head(n = 3) %>%
define_water_chain() %>%
mutate(
time = 8,
cl2dose = c(2, 3, 4)
) %>%
chemdose_chloramine_chain(
input_water = "defined_water",
cl2 = cl2dose,
use_free_cl_slot = TRUE,
use_tot_nh3_slot = TRUE
)
# Initialize parallel processing
library(furrr)
# plan(multisession)
example_df <- water_df %>%
define_water_chain() %>%
chemdose_chloramine_chain(
input_water = "defined_water", cl2 = c(2, 4), nh3 = 2, time = 8
)
# Optional: explicitly close multisession processing
# plan(sequential)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.