Learn R Programming

tidywater (version 0.9.0)

chemdose_chloramine: Calculate chlorine and chloramine Concentrations with the breakpoint cblorination approach

Description

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.

Usage

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" )

Value

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.

Arguments

water

Source water object of class "water" created by define_water

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".

Details

The function will calculate the chlorine and chloramine concentrations and update the "water" class object proceed to the next steps of the treatment chain.

Examples

Run this code
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
  )

# \donttest{
# 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)
# }

Run the code above in your browser using DataLab