View source: R/decarbonate_ph.R
decarbonate_ph | R Documentation |
Calculates the new water quality (pH, alkalinity, etc) after a specified amount of CO2 is removed (removed as bicarbonate).
The function takes an object of class "water" and a fraction of CO2 removed, then returns a water class object with updated water slots.
For a single water, use decarbonate_ph
; to apply the model to a dataframe, use decarbonate_ph_chain
.
For most arguments, the _chain
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.
decarbonate_ph(water, co2_removed)
decarbonate_ph_chain(
df,
input_water = "defined_water",
output_water = "decarbonated_water",
co2_removed = "use_col"
)
water |
Source water of class "water" created by |
co2_removed |
Fraction of CO2 removed |
df |
a data frame containing a water class column, which has already been computed using define_water_chain. The df may include a column with names for each of the chemicals being dosed. |
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 "dosed_chem_water". |
decarbonate_ph
uses water@h2co3
to determine the existing CO2 in water, then applies chemdose_ph to match the CO2 removal.
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.
A water with updated pH/alk/etc.
decarbonate_ph_chain
returns a data frame with a column containing a water with updated pH, alk, etc.
chemdose_ph
water <- define_water(ph = 4, temp = 25, alk = 5) %>%
decarbonate_ph(co2_removed = .95)
example_df <- water_df %>%
define_water_chain() %>%
decarbonate_ph_chain(input_water = "defined_water", output_water = "decarb", co2_removed = .95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.