Learn R Programming

tidywater (version 0.7.0)

balance_ions: Add Na, K, Cl, or SO4 to balance overall charge in a water

Description

This function takes a water defined by define_water and balances charge.

Usage

balance_ions(water)

Value

A water class object with updated ions to balance water charge.

Arguments

water

Water created with define_water, which may have some ions set to 0 when unknown

Details

If more cations are needed, sodium will be added, unless a number for sodium is already provided and potassium is 0, then it will add potassium. Similarly, anions are added using chloride, unless sulfate is 0. If calcium and magnesium are not specified when defining a water with define_water, they will default to 0 and not be changed by this function. This function is purely mathematical. User should always check the outputs to make sure values are reasonable for the input source water.

Examples

Run this code
water_defined <- define_water(7, 20, 50, 100, 80, 10, 10, 10, 10, tot_po4 = 1) %>%
  balance_ions()

Run the code above in your browser using DataLab