| Title: | A Tool for Calculating Stoichiometric Equilibrium Constants (Ks) for Seawater |
|---|---|
| Description: | A unified software package simultaneously implemented in 'Python', 'R', and 'Matlab' providing a uniform and internally-consistent way of calculating stoichiometric equilibrium constants in modern and palaeo seawater as a function of temperature, salinity, pressure and the concentration of magnesium, calcium, sulphate, and fluorine. |
| Authors: | Dennis Mayk [aut, cre] (ORCID: <https://orcid.org/0000-0002-5017-1495>) |
| Maintainer: | Dennis Mayk <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.1 |
| Built: | 2026-05-27 07:40:44 UTC |
| Source: | https://github.com/cran/kgen |
Calculate fluorine
calc_fluorine(sal)calc_fluorine(sal)
sal |
Salinity |
fluorine
From Dickson et al., 2007, Table 2, Note: Sal / 1.80655 = Chlorinity
Ionic strength after Dickson (1990a); see Dickson et al. (2007)
calc_ionic_strength(sal)calc_ionic_strength(sal)
sal |
Salinity |
Ionic strength
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" )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) }# 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) }
Calculate K0
calc_K0(coefficients, temp_c, sal)calc_K0(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
K0
Calculate K1
calc_K1(coefficients, temp_c, sal)calc_K1(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
K1
Calculate K2
calc_K2(coefficients, temp_c, sal)calc_K2(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
K2
Calculate KB
calc_KB(coefficients, temp_c, sal)calc_KB(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KB
Calculate KF
calc_KF(coefficients, temp_c, sal)calc_KF(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KF
Calculate KP1
calc_KP1(coefficients, temp_c, sal)calc_KP1(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KP1
Calculate KP2
calc_KP2(coefficients, temp_c, sal)calc_KP2(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KP2
Calculate KP3
calc_KP3(coefficients, temp_c, sal)calc_KP3(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KP3
Calculate KS
calc_KS(coefficients, temp_c, sal)calc_KS(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KS
Calculate KSi
calc_KSi(coefficients, temp_c, sal)calc_KSi(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KSi
Calculate Ksp
calc_Ksp(coefficients, temp_c, sal)calc_Ksp(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
Ksp
Calculate KW
calc_KW(coefficients, temp_c, sal)calc_KW(coefficients, temp_c, sal)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
sal |
Salinity |
KW
Calculate pressure correction factor for Ks
calc_pc(coefficients, temp_c, p_bar)calc_pc(coefficients, temp_c, p_bar)
coefficients |
Coefficients for K calculation |
temp_c |
Temperature (Celcius) |
p_bar |
Pressure (Bar) |
Pressure correction factor
From Millero et al. (2007, doi:10.1021/cr0503557), Eqns 38-40
Calculate pressure correction factor for a specified equilibrium constant.
calc_pressure_correction(k, temp_c, p_bar)calc_pressure_correction(k, temp_c, p_bar)
k |
K to be calculated |
temp_c |
Temperature (Celcius) |
p_bar |
Pressure (Bar) |
pressure correction factor
Dennis Mayk
calc_pressure_correction("K1", temp_c = 25, p_bar = 100)calc_pressure_correction("K1", temp_c = 25, p_bar = 100)
Kgen seawater composition correction function
calc_seawater_correction( k, sal, temp_c, magnesium = 0.0528171, calcium = 0.0102821, method = "r_polynomial" )calc_seawater_correction( k, sal, temp_c, magnesium = 0.0528171, calcium = 0.0102821, method = "r_polynomial" )
k |
K to be calculated |
sal |
Salinity |
temp_c |
Temperature (Celcius) |
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. |
method |
string describing method which should be either 'myami', 'myami_polynomial', or 'r_polynomial' (Default: 'r_polynomial'). |
list of seawater correction factors
Dennis Mayk
calc_seawater_correction("K1", sal = 35, temp_c = 25)calc_seawater_correction("K1", sal = 35, temp_c = 25)
Calculate sulphate
calc_sulphate(sal)calc_sulphate(sal)
sal |
Salinity |
sulphate
From Dickson et al., 2007, Table 2, Note: Sal / 1.80655 = Chlorinity
List of all functions
K_fnsK_fns
An object of class list of length 13.
Kgen R polynomial function
kgen_poly(sal, temp_c, magnesium = 0.0528171, calcium = 0.0102821)kgen_poly(sal, temp_c, magnesium = 0.0528171, calcium = 0.0102821)
sal |
Salinity |
temp_c |
Temperature (Celcius) |
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. |
Dennis Mayk