Water Quality Models for Drinking Water Treatment Processes

Provides multiple water chemistry-based models and published empirical models in one standard format. As many models have been included as possible, however, users should be aware that models have varying degrees of accuracy and applicability. To learn more, read the references provided below for the models implemented. Functions can be chained together to model a complete treatment process and are designed to work in a 'tidyverse' workflow. Models are primarily based on these sources: Benjamin, M. M. (2002, ISBN:147862308X), Crittenden, J. C., Trussell, R., Hand, D., Howe, J. K., & Tchobanoglous, G., Borchardt, J. H. (2012, ISBN:9781118131473), USEPA. (2001) < https://www.epa.gov/sites/default/files/2017-03/documents/wtp_model_v._2.0_manual_508.pdf>.


tidywater

R-CMD-check License:MIT License:Apache2.0

Overview

Tidywater incorporates published water chemistry and empirical models in a standard format. The modular functions allow for building custom, comprehensive drinking water treatment processes. Functions are designed to work in a tidyverse workflow.

Installation

# Install tidywater from CRAN:
install.packages("tidywater")

# Alternatively, install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("BrownandCaldwell-Public/tidywater")

Examples

In this first example, acid-base chemistry and TOC removal models are demonstrated. This example uses tidywater base functions to model a single water quality scenario.

library(tidywater)
library(tidyverse)
## Use base tidywater functions to model water quality for a single scenario.
base_coagulation <- define_water(ph = 8, alk = 90, tds = 50, toc = 3, doc = 2.8, uv254 = 0.08) %>%
  # note that we get a warning about sulfate from this code because we didn't specify sulfate in the define_water
  chemdose_ph(alum = 30) %>%
  chemdose_toc(alum = 30)
#> Warning in chemdose_ph(., alum = 30): Sulfate-containing chemical dosed, but
#> so4 water slot is NA. Slot not updated because background so4 unknown.

To model multiple water quality scenarios, use tidywater’s helper functions (x_df) to apply the models to a dataframe. The pluck_cols argument can be added to return the parameters impacted by the model as separate columns. The pluck_water function can pull any parameter from a water into a separate column.


coagulation <- water_df %>%
  define_water_df(output_water = "raw") %>%
  mutate(alum = 30) %>%
  chemdose_ph_df(input_water = "raw", output_water = "phchange") %>% # return "phchange" water
  chemdose_toc_df(input_water = "phchange", output_water = "coag", pluck_cols = TRUE) # return "coag" water and coag_doc, coag_toc, coag_uv254 as columns

## To get individual parameters, use `pluck_water`
coagulation <- coagulation %>%
  pluck_water(input_waters = c("raw", "coag"), parameter = c("ph", "doc"))

Note that these functions use a “water” class. The “water” class is the foundation of the package; it provides a mechanism for linking models in any order while maintaining water quality information. The define_water function takes water quality inputs, but define_water_df may be used to convert a dataframe to a list of “waters”.

For more detailed examples on tidywater functions and how to use “water” class data, please see the tidywater vignettes: browseVignettes("tidywater")

Limitations

This project is maintained by volunteers and is provided without warranties or guarantees of any kind.

Use at your own risk. For official support, please contact Brown and Caldwell.

Please read our CONTRIBUTING.md and SECURITY.md before submitting issues or pull requests.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("tidywater")

0.11.0 by Sierra Johnson, 2 days ago


https://github.com/BrownandCaldwell-Public/tidywater, https://brownandcaldwell-public.github.io/tidywater/


Report a bug at https://github.com/BrownandCaldwell-Public/tidywater/issues


Browse source code at https://github.com/cran/tidywater


Authors: Sierra Johnson [aut, cre] , Libby McKenna [aut] , Riley Mulhern [aut] , Chris Corwin [aut] , Rachel Merrifield [ctb] , Mayuri Namasivayam [ctb] , Phoebe Chen [ctb] , Jiaming Yuan [ctb] , Atticus Fretz [ctb] , Bengu Kilinc [ctb] , Hania Zanib [ctb] , USEPA [cph] (Copyright holder of included TELSS fragments (dissolve_pb function)) , Brown and Caldwell [fnd, cph]


Documentation:   PDF Manual  


Apache License (>= 2) | MIT + file LICENSE license


Imports dplyr, tidyr, forcats, knitr, ggplot2, ggrepel, magrittr, methods, rlang, deSolve, lifecycle, cli

Suggests rmarkdown, purrr, testthat


See at CRAN