Learn R Programming

tidywater (version 0.9.0)

solvect_o3: Determine disinfection credit from ozone.

Description

This function takes a water defined by define_water() and the first order decay curve parameters from an ozone dose and outputs a dataframe of actual CT, and log removal for giardia, virus, and crypto. For a single water, use solvect_o3; to apply the model to a dataframe, use solvect_o3_once. For most arguments, the _once helper "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.

Usage

solvect_o3(water, time, dose, kd, baffle)

solvect_o3_once( df, input_water = "defined_water", time = "use_col", dose = "use_col", kd = "use_col", baffle = "use_col", water_prefix = TRUE )

Value

solvect_o3 returns a data frame containing actual CT (mg/L*min), giardia log removal, virus log removal, and crypto log removal.

solvect_o3_once returns a data frame containing the original data frame and columns for required CT, actual CT, and giardia log removal.

Arguments

water

Source water object of class "water" created by define_water(). Water must include ph and temp

time

Retention time of disinfection segment in minutes.

dose

Ozone dose in mg/L. This value can also be the y intercept of the decay curve (often slightly lower than ozone dose.)

kd

First order decay constant. This parameter is optional. If not specified, the default ozone decay equations will be used.

baffle

Baffle factor - unitless value between 0 and 1.

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.

Details

First order decay curve for ozone has the form: residual = dose * exp(kd*time). kd should be a negative number. Actual CT is an integration of the first order curve. The first 30 seconds are removed from the integral to account for instantaneous demand.

When kd is not specified, a default decay curve is used from the Water Treatment Plant Model (2002). This model does not perform well for ozone decay, so specifying the decay curve is recommended.

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.

Examples

Run this code

# Use kd from experimental data (recommended):
define_water(ph = 7.5, temp = 25) %>%
  solvect_o3(time = 10, dose = 2, kd = -0.5, baffle = 0.9)
# Use modeled decay curve:
define_water(ph = 7.5, alk = 100, doc = 2, uv254 = .02, br = 50) %>%
  solvect_o3(time = 10, dose = 2, baffle = 0.5)

# \donttest{
library(dplyr)
ct_calc <- water_df %>%
  mutate(br = 50) %>%
  define_water_chain() %>%
  mutate(
    dose = 2,
    O3time = 10,
  ) %>%
  solvect_o3_once(time = O3time, baffle = .7)
# }

Run the code above in your browser using DataLab