This function takes user-defined water quality parameters and creates an S4 "water" class object that forms the input and output of all tidywater models.
define_water(
ph,
temp = 25,
alk,
tot_hard,
ca,
mg,
na,
k,
cl,
so4,
mno4,
free_chlorine = 0,
combined_chlorine = 0,
tot_po4 = 0,
tot_nh3 = 0,
tds,
cond,
toc,
doc,
uv254,
br,
f,
fe,
al,
mn,
no3
)
define_water outputs a water class object where slots are filled or calculated based on input parameters. Water slots have different units than those input into the define_water function, as listed below.
pH, numeric, in standard units (SU).
temperature, numeric, in °C.
alkalinity, numeric, mg/L as CaCO3.
total dissolved solids, numeric, mg/L.
electrical conductivity, numeric, uS/cm.
total hardness, numeric, mg/L as CaCO3.
dissociation constant for water, numeric, unitless.
alkalinity as equivalents, numeric, equivalent (eq).
total organic carbon, numeric, mg/L.
dissolved organic carbon, numeric, mg/L.
biodegradable organic carbon, numeric, mg/L.
light absorption at 254 nm, numeric, cm-1.
dissolved inorganic carbon, numeric, mg/L as C.
ionic strength, numeric, mol/L.
sodium, numeric, mols/L.
calcium, numeric, mols/L.
magnesium, numeric, mols/L.
potassium, numeric, mols/L.
chloride, numeric, mols/L.
sulfate, numeric, mols/L.
permanganate, numeric, mols/L.
nitrate, numeric, mols/L.
bicarbonate, numeric, mols/L.
carbonate, numeric, mols/L.
phosphoric acid, numeric, mols/L.
hydrogen phosphate, numeric, mols/L.
phosphate, numeric, mols/L.
ammonium, numeric, mol/L as N.
hydrogen ion, numeric, mol/L.
hydroxide ion, numeric, mol/L.
total phosphate, numeric, mol/L.
total ammonia, numeric, mol/L.
total carbonate, numeric, mol/L.
bromide, numeric, mol/L.
bromate, numeric, mol/L.
fluoride, numeric, mol/L.
iron, numeric, mol/L.
aluminum, numeric, mol/L.
manganese, numeric, mol/L.
free chlorine, numeric, mol/L.
hypochlorite ion, numeric, mol/L.
sum of chloramines, numeric, mol/L.
monochloramine, numeric, mol/L.
dichloramine, numeric, mol/L.
trichloramine, numeric, mol/L.
chloroform, numeric, ug/L.
bromodichloromethane, numeric, ug/L.
dibromodichloromethane, numeric, ug/L.
bromoform, numeric, ug/L.
total trihalomethanes, numeric, ug/L.
chloroacetic acid, numeric, ug/L.
dichloroacetic acid, numeric, ug/L.
trichloroacetic acid, numeric, ug/L.
bromoacetic acid, numeric, ug/L.
dibromoacetic acid, numeric, ug/L.
sum of haloacetic acids, numeric, ug/L.
bromochloroacetic acid, numeric, ug/L.
chlorodibromoacetic acid, numeric, ug/L.
dichlorobromoacetic acid, numeric, ug/L.
tribromoacetic acid, numeric, ug/L.
water pH
Temperature in degree C
Alkalinity in mg/L as CaCO3
Total hardness in mg/L as CaCO3
Calcium in mg/L Ca2+
Magnesium in mg/L Mg2+
Sodium in mg/L Na+
Potassium in mg/L K+
Chloride in mg/L Cl-
Sulfate in mg/L SO42-
Permanganate in mg/L MnO4-
Free chlorine in mg/L as Cl2. Used when a starting water has a free chlorine residual.
Combined chlorine (chloramines) in mg/L as Cl2. Used when a starting water has a chloramine residual.
Phosphate in mg/L as PO4 3-. Used when a starting water has a phosphate residual.
Total ammonia in mg/L as N
Total Dissolved Solids in mg/L (optional if ions are known)
Electrical conductivity in uS/cm (optional if ions are known)
Total organic carbon (TOC) in mg/L
Dissolved organic carbon (DOC) in mg/L
UV absorbance at 254 nm (cm-1)
Bromide in ug/L Br-
Fluoride in mg/L F-
Iron in mg/L Fe3+
Aluminum in mg/L Al3+
Manganese in ug/L Mn2+
Nitrate in mg/L as N
Carbonate balance is calculated and units are converted to mol/L. Ionic strength is determined from ions, TDS, or conductivity. Missing values are handled by defaulting to 0 or NA. Calcium defaults to 65 percent of the total hardness when not specified. DOC defaults to 95 percent of TOC.
water_missingions <- define_water(ph = 7, temp = 15, alk = 100, tds = 10)
water_defined <- define_water(7, 20, 50, 100, 80, 10, 10, 10, 10, tot_po4 = 1)
Run the code above in your browser using DataLab