| calc_K | R Documentation |
Calculate a single specified stoichiometric equilibrium constant at given temperature, salinity, pressure and the concentration of magnesium, calcium, sulphate, and fluorine.
calc_K(
k,
temp_c = 25,
sal = 35,
p_bar = NULL,
magnesium = 0.0528171,
calcium = 0.0102821,
sulphate = NULL,
fluorine = NULL,
method = "r_polynomial"
)
calc_Ks(
ks = NULL,
temp_c = 25,
sal = 35,
p_bar = NULL,
magnesium = 0.0528171,
calcium = 0.0102821,
sulphate = calc_sulphate(sal = sal),
fluorine = calc_fluorine(sal = sal),
method = "r_polynomial"
)
k |
K to be calculated |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
p_bar |
Pressure (Bar) (optional) |
magnesium |
Magnesium concentration in mol/kgsw. Default is modern seawater (0.0528171). Should be the average magnesium concentration in seawater - a salinity correction is then applied to calculate the magnesium concentration in the sample. |
calcium |
Calcium concentration in mol/kgsw. Default is modern seawater (0.0102821). Should be the average calcium concentration in seawater - a salinity correction is then applied to calculate the calcium concentration in the sample. |
sulphate |
Sulphate concentration in mol/kgsw. Calculated from salinity if not given. |
fluorine |
Fluorine concentration in mol/kgsw. Calculated from salinity if not given. |
method |
string describing method which should be either 'myami', 'myami_polynomial', or 'r_polynomial' (Default: 'r_polynomial'). |
ks |
character vectors of Ks to be calculated e.g., c("K0", "K1") (Default: NULL, calculate all Ks) |
A single K at given conditions
Data.table of multiple Ks at given conditions
calc_Ks(): Wrapper to calculate multiple stoichiometric equilibrium constants at given temperature, salinity, pressure and the concentration of magnesium, calcium, sulphate, and fluorine.
Dennis Mayk
# Calculate K1 at default conditions
calc_K("K1", temp_c = 25, sal = 35)
# Calculate K1 with pressure correction
calc_K("K1", temp_c = 25, sal = 35, p_bar = 100)
# Calculate all Ks at default conditions
calc_Ks(temp_c = 25, sal = 35)
# Calculate specific Ks
calc_Ks(ks = c("K1", "K2"), temp_c = 25, sal = 35)
# Parallel execution (requires future + future.apply packages)
if (requireNamespace("future", quietly = TRUE)) {
future::plan(future::multisession,
workers = future::availableCores() - 1
)
dt_list <- as.list(data.table::CJ(
temp_c = seq_len(40),
sal = 30:40,
p_bar = 0:100,
magnesium = seq(0, 0.06, by = 0.01),
calcium = seq(0, 0.06, by = 0.01)
))
res <- do.call(what = calc_Ks, args = dt_list)
future::plan(future::sequential)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.