Contents
Properties
Clapeyron.mean_ionic_activity_coefficient — Function
mean_ionic_activity_coefficient(model::ESElectrolyteModel,p,T,m,zsolv = SA[1.0])
mean_ionic_activity_coefficient(model::ESElectrolyteModel,salts,p,T,m,zsolv = SA[1.0])Calculates the mean ionic activity coefficient of selection of salts at a given pressure p, temperature T and molality m. These are defined as:
γ± = φ±/φ±₀ * ∑zsolv/∑zExample:
model = ePCSAFT(["water"],["sodium","chloride"])
p = 1e5
T = 298.15
m = [1.0]
#supposing all combinations of binary salts
γ± = mean_ionic_activity_coefficient(model,p,T,m)
#specify your own salt composition
salts = [("sodium chloride",("sodium"=>1,"chloride"=>1))]
γ± = mean_ionic_activity_coefficient(model,salts,p,T,m)If multiple solvents are present, the composition of the solvent can be specified with the zsolv keyword argument.
Clapeyron.mean_ionic_activity_coefficient_sat — Function
mean_ionic_activity_coefficient_sat(model::ESElectrolyteModel,T,m,zsolv = SA[1.0])
mean_ionic_activity_coefficient_sat(model::ESElectrolyteModel,salts,T,m,zsolv = SA[1.0])Calculates the mean ionic activity coefficient of selection of salts at the saturation point at a certain temperature T and molality m. These are defined as:
γ± = φ±/φ±₀ * ∑zsolv/∑zExample:
model = ePCSAFT(["water"],["sodium","chloride"])
T = 298.15
m = [1.0]
#supposing all combinations of binary salts
γ± = mean_ionic_activity_coefficient_sat(model,T,m)
#specify your own salt composition
salts = [("sodium chloride",("sodium"=>1,"chloride"=>1))]
γ± = mean_ionic_activity_coefficient_sat(model,salts,T,m)If multiple solvents are present, the composition of the solvent can be specified with the zsolv keyword argument.
Clapeyron.osmotic_coefficient — Function
osmotic_coefficient(model::ESElectrolyteModel,salts,p,T,m,zsolv = SA[1.0])Calculates the osmotic coefficient of selection of solvents at a given pressure, temperature and molality. These are defined as:
ϕ = -1/(∑νi*mi*Mw)*log(asolv)Example:
model = ePCSAFT(["water"],["sodium","chloride"])
p = 1e5
T = 298.15
m = [1.0]
#supposing all combinations of binary salts
ϕ = osmotic_coefficient(model,p,T,m)
#specify your own salt composition
salts = [("sodium chloride",("sodium"=>1,"chloride"=>1))]
ϕ = osmotic_coefficient(model,salts,p,T,m)If multiple solvents are present, the composition of the solvent can be specified with the zsolv keyword argument.
Clapeyron.osmotic_coefficient_sat — Function
osmotic_coefficient_sat(model::ESElectrolyteModel,T,m,zsolv = SA[1.0])
osmotic_coefficient_sat(model::ESElectrolyteModel,salts,T,m,zsolv = SA[1.0])Calculates the osmotic coefficient of selection of solvents at the saturation point at a certain temperature T and molality m. These are defined as:
ϕ = -1/(∑νi*mi*Mw)*log(asolv)Example:
model = ePCSAFT(["water"],["sodium","chloride"])
T = 298.15
m = [1.0]
#supposing all combinations of binary salts
ϕ = osmotic_coefficient_sat(model,T,m)
#specify your own salt composition
salts = [("sodium chloride",("sodium"=>1,"chloride"=>1))]
ϕ = osmotic_coefficient_sat(model,salts,T,m)If multiple solvents are present, the composition of the solvent can be specified with the zsolv keyword argument.
Helper functions
Clapeyron.auto_binary_salts — Function
auto_binary_salts(model)
auto_binary_salts(Z, components)Automatically generate a vector of binary salts from ionic components.
Arguments
model: An electrolyte model containing charge informationZ: Vector of ionic charges for each componentcomponents: Vector of component names
Returns
A vector of tuples, where each tuple contains:
String: Salt name in the format "n₁Cation.n₂Anion" (e.g., "2Na.SO4" for Na₂SO₄)Vector{Pair{String,Int}}: Stoichiometric coefficients as component => count pairs
Description
This function generates n-1 independent binary salts from n ions by pairing cations with anions. The stoichiometric coefficients are determined by the least common multiple (LCM) of the absolute charges to ensure electroneutrality.
For a system with multiple cations and anions, salts are created by iterating through cation-anion pairs until n-1 salts are formed, which is the number of independent salts needed to describe an n-ion system.
Examples
# For a system with Na⁺ (charge = +1) and Cl⁻ (charge = -1)
Z = [1, -1]
comps = ["Na", "Cl"]
Clapeyron.auto_binary_salts(Z, comps)
# Returns: [("Na.Cl", ["Na" => 1, "Cl" => 1])]
# For a system with Ca²⁺ (charge = +2) and Cl⁻ (charge = -1)
Z = [2, -1]
comps = ["Ca", "Cl"]
Clapeyron.auto_binary_salts(Z, comps)
# Returns: [("Ca.2Cl", ["Ca" => 1, "Cl" => 2])] # CaCl₂
# For a system with Na⁺, Ca²⁺, and SO₄²⁻ (3 ions → 2 salts)
Z = [1, 2, -2]
comps = ["Na", "Ca", "SO4"]
Clapeyron.auto_binary_salts(Z, comps)
# Returns: [("2Na.SO4", ["Na" => 2, "SO4" => 1]),
# ("Ca.SO4", ["Ca" => 1, "SO4" => 1])]Throws
DomainError: If only one ion is present (cannot form salts)
Notes
- Returns an empty vector if no ions are present (all charges are zero)
- Stoichiometric coefficients of 1 are omitted from salt names (e.g., "Na.Cl" not "1Na.1Cl")
Clapeyron.molality_to_composition — Function
molality_to_composition(model::ElectrolyteModel,salts,m,zsolv = SA[1.0])
molality_to_composition(model::ElectrolyteModel,m,zsolv = SA[1.0])Convert molality (mol/kg) to composition for a given model, salts, molality, and solvent composition. If no salts argument is specified, it will be created via Clapeyron.auto_binary_salts(model)
Other electrolyte utilities
Clapeyron.dielectric_constant — Function
dielectric_constant(model::ElectrolyteModel, V, T, z)Calculates the dielectric constant (also known as relative static permittivity) for a given electrolyte model.
Examples
model = ConstRSP()
εr = dielectric_constant(model, 1.8e-5, 298.15, [1.0])