Solubility
Methods
Coupled H2O–CO2 volatile solubility (dissolved-content) closures can be set with:
GeoParams.MaterialParameters.Solubility.Liu2005_Solubility Type
Liu2005_Solubility(; coeffs=(b1..b6, c1..c4), Pref=1MPa, Tref=1K)Coupled H2O–CO2 solubility for silicic (rhyolite) melt after Liu et al. (2005), as used by Degruyter & Huber (2014). It applies to rhyolite only and is useful to reproduce Degruyter & Huber-type models; for other melt compositions, for CO2 and for pressures above ~500 MPa use SunYao2026_Solubility. compute_dissolved returns the dissolved H2O and CO2 mass fractions of the melt as a function of pressure, temperature, and the CO2 mole fraction of the gas X_co2:
with the dimensionless partial pressures Pref=1MPa, Tref=1K these equal the reference partial pressures in MPa and reproduce the Liu (2005) numbers; because they are ratios of like-dimensioned quantities, the closure is dimensionally homogeneous and nondimensionalizes cleanly. The fitted coeffs are dimensionless; isdimensional tracks the reference GeoUnits.
References
Liu, Y., Zhang, Y., Behrens, H. (2005), Solubility of H2O in rhyolitic melts at low pressures and a new empirical model for mixed H2O-CO2 solubility, JVGR 143, 219-235, https://doi.org/10.1016/j.jvolgeores.2004.09.019
Degruyter, W., Huber, C. (2014), A model for the eruption frequency of upper crustal silicic magma chambers, EPSL 403, 117-130, https://doi.org/10.1016/j.epsl.2014.06.047
GeoParams.MaterialParameters.Solubility.Mafic_Solubility Type
Mafic_Solubility(; coeffs=(b1..b10, c1..c4), T0=273.15K, Tref=1K, Pref=1MPa)Coupled H2O–CO2 solubility for mafic (basalt) melt. Dissolved H2O follows the mafic polynomial of Scholz et al. (2023; MagmaChamberBoxModel, exsolve_mafic.m) in the dimensionless groups Liu2005_Solubility. The H2O polynomial has no floor at zero and goes negative outside its calibration (high X_co2, low P); the dissolved H2O output is floored at zero rather than returned as a negative mass fraction. At low pressure it does not tend to zero: with pure H2O gas it gives 2.74 wt% at P → 0 and 850 °C (1.52 wt% at 1100 °C), so the law is meaningful only at magma-chamber pressures, not near fragmentation.
References
Scholz, K., Townsend, M., Huber, C., et al. (2023), Investigating the Impact of an Exsolved H2O-CO2 Phase on Magma Chamber Growth, Geochemistry, Geophysics, Geosystems 24, https://doi.org/10.1029/2023GC011151
Degruyter, W., Huber, C. (2014), A model for the eruption frequency of upper crustal silicic magma chambers, EPSL 403, 117-130, https://doi.org/10.1016/j.epsl.2014.06.047
Liu, Y., Zhang, Y., Behrens, H. (2005), Solubility of H2O in rhyolitic melts at low pressures and a new empirical model for mixed H2O-CO2 solubility, JVGR 143, 219-235, https://doi.org/10.1016/j.jvolgeores.2004.09.019
GeoParams.MaterialParameters.Solubility.SunYao2026_Solubility Type
SunYao2026_Solubility(; oxd_wt = (77.0, 0.1, 12.8, 0.8, 0.1, 0.6, 4.0, 4.6, 0.02), a = (a0..a9), b = (b0..b20))Coupled H2O–CO2 solubility of Sun & Yao (2026), calibrated on 2090 experiments on melts from carbonatite to pure silica at 660–1924 °C and 1 bar–6 GPa. oxd_wt is the volatile-free melt composition in wt% of (SiO2, TiO2, Al2O3, FeOt, MgO, CaO, Na2O, K2O, P2O5), the oxide order of GiordanoMeltViscosity with P2O5 in place of H2O; the default is a high-silica rhyolite. It is converted once to the oxide mole fractions
Dissolved H2O (wt%) is the sum of molecular H2O and hydroxyl (eq. 7),
and dissolved CO2 (ppm) is the sum of molecular CO2 and carbonate (eq. 8),
with a and b are Table 1. compute_dissolved returns the totals as mass fractions; the species split is not returned. Pressure and temperature enter through the reference GeoUnits Pref = 1 bar and Tref = 1 K, so the law nondimensionalizes like Liu2005_Solubility.
Pure gases give exact zeros: no H2O at X_co2 = 1 and no CO2 at X_co2 = 0, with zero derivatives in P and T. The slopes in X_co2 are infinite at these endpoints (∂dissolved_∂Xco2 is not finite there. The H2O data reach 2 GPa and the mixed-fluid data 1 GPa; only the pure-CO2 data reach 6 GPa. Above ~2 GPa the formula fails: the term X_co2 = 0.5: rhyolite at 900 °C from ~2 GPa, basalt at 1200 °C below 2.5 GPa).
References
- Sun, C., Yao, L. (2026), A unified H2O–CO2 solubility–speciation model for magmatic liquids: Constraints on magma storage architecture in continental rifts, EPSL 689, 120115, https://doi.org/10.1016/j.epsl.2026.120115
GeoParams.MaterialParameters.Solubility.GasMixture Type
GasMixture(; Cp_h2o=3880J/kg/K, Cp_co2=1200J/kg/K, M_h2o=18.02e-3kg/mol, M_co2=44.01e-3kg/mol)H2O–CO2 gas-mixture properties keyed on the CO2 mole fraction of the gas X_co2 (Degruyter & Huber 2014). The effective molar mass is
and the mass-weighted specific heat is
with the reference convention
All fields are GeoUnits, so the struct nondimensionalizes, but both accessors read values rather than Quantitys: neither return carries units.
SunYao2026_Solubility is the recommended law: it takes the melt composition, covers H2O and CO2 and is calibrated up to 2 GPa for H2O and 1 GPa for mixed H2O–CO2 fluids; above ~2 GPa its dissolved contents exceed 100 wt%. Liu2005_Solubility applies to rhyolite only and is useful to reproduce Degruyter & Huber (2014)-type models. Mafic_Solubility is a polynomial fit for mafic melts; its dissolved H2O does not vanish as the pressure goes to zero (2.7 wt% at 850 °C in the figure), so it is meaningful only at chamber pressures.
The figure compares the dissolved H2O in equilibrium with pure H2O gas at 850 °C.
using GeoParams, CairoMakie
basalt = (50.42, 1.53, 15.13, 9.81, 7.76, 11.35, 2.83, 0.14, 0.0)
laws = (
"Liu2005_Solubility" => Liu2005_Solubility(),
"Mafic_Solubility" => Mafic_Solubility(),
"SunYao2026_Solubility, rhyolite" => SunYao2026_Solubility(),
"SunYao2026_Solubility, basalt" => SunYao2026_Solubility(; oxd_wt = basalt),
)
P = range(1.0e5, 4.0e8, 200)
fig = Figure(size = (800, 500))
ax = Axis(fig[1, 1]; xlabel = "pressure P (MPa)", ylabel = "dissolved H₂O (wt%)")
for (name, law) in laws
lines!(ax, P ./ 1.0e6, [100 * compute_dissolved(law, p, 1123.15, 0.0)[1] for p in P]; label = name)
end
axislegend(ax; position = :lt)
fig
Computational routines
To evaluate dissolved H2O and CO2 (mass fractions) within a user routine, use this:
GeoParams.MaterialParameters.Solubility.compute_dissolved Function
compute_dissolved(s::AbstractSolubility, P, T, X_co2) -> (m_h2o, m_co2)Dissolved H2O and CO2 mass fractions of the melt (P in Pa, T in K, X_co2 the CO2 mole fraction of the gas). Also callable as compute_dissolved(s; P, T, X_co2) and compute_dissolved(s, args::NamedTuple).
GeoParams.MaterialParameters.Solubility.compute_dissolved! Function
compute_dissolved!(m_h2o, m_co2, MatParam, Phases, args)In-place dissolved H2O and CO2 over a domain. args is a NamedTuple of P, T, X_co2 index-matched to the output arrays. Also accepts a single solubility or phase struct in place of (MatParam, Phases).
Partial derivatives (via ForwardDiff, useful for implicit/Newton solves) are available for pressure, temperature, and gas composition:
GeoParams.MaterialParameters.Solubility.∂dissolved_∂P Function
∂dissolved_∂P(s, P, T, X_co2) -> (∂m_h2o/∂P, ∂m_co2/∂P)ForwardDiff partial derivatives of compute_dissolved with respect to pressure. Companions ∂dissolved_∂T, ∂dissolved_∂Xco2.
GeoParams.MaterialParameters.Solubility.∂dissolved_∂T Function
∂dissolved_∂T(s, P, T, X_co2) -> (∂m_h2o/∂T, ∂m_co2/∂T)GeoParams.MaterialParameters.Solubility.∂dissolved_∂Xco2 Function
∂dissolved_∂Xco2(s, P, T, X_co2) -> (∂m_h2o/∂X_co2, ∂m_co2/∂X_co2)Given a target dissolved H2O content, the gas composition X_co2 that produces it can be found with:
GeoParams.MaterialParameters.Solubility.find_Xco2 Function
find_Xco2(s::AbstractSolubility, P, T, m_h2o_target; X0=0.5, tol=1e-8, max_iter=50) -> X_co2Invert compute_dissolved for the gas composition: solve for X_co2 ∈ [0,1] such that compute_dissolved(s, P, T, X_co2)[1] == m_h2o_target, at fixed pressure P and temperature T. Uses a safeguarded Newton iteration (via ∂dissolved_∂Xco2) bracketed by bisection, so an out-of-bounds Newton step always falls back to a bisection halving instead of leaving [0,1].
Throws an ErrorException if m_h2o_target is infeasible at this P,T (outside the achievable range between X_co2=0 and X_co2=1) or if the iteration fails to converge within max_iter steps — this never returns a clamped or out-of-tolerance answer.
Given both dissolved contents, the saturation pressure and the gas composition follow from:
GeoParams.MaterialParameters.Solubility.compute_saturation_pressure Function
compute_saturation_pressure(s::AbstractSolubility, m_h2o, m_co2, T; tol=100eps, max_iter=50) -> (P, X_co2)Fluid-saturation pressure P of a melt with dissolved H2O and CO2 mass fractions m_h2o and m_co2 at temperature T, and the CO2 mole fraction X_co2 of the coexisting H2O–CO2 gas: the inverse of compute_dissolved in P and X_co2. P is in Pa and T in K, or both nondimensional for a nondimensionalized law. Applied to the volatile contents of melt inclusions, this is the saturation barometer of Sun & Yao (2026, sect. 3–4).
m_co2 = 0 gives a pure H2O gas (X_co2 = 0) and m_h2o = 0 a pure CO2 gas (X_co2 = 1), with P matching the nonzero content alone. Otherwise a Newton iteration in tol, using ∂dissolved_∂P and ∂dissolved_∂Xco2. Each step changes P by at most a factor X_co2 at most halfway towards 0 or 1.
The solve is iterative and meant for analysis, such as melt-inclusion barometry or setting initial conditions, not for evaluation at every grid point of a solver. It throws a DomainError for negative or all-zero contents and an ErrorException if it does not converge within max_iter iterations; it never returns an unconverged answer. Outside its calibration, a polynomial law such as Mafic_Solubility can match the same contents at more than one pressure.
For rhyolite with SunYao2026_Solubility the solve converges up to ~1 GPa. Above ~1.5 GPa with small X_co2 it can fail although a solution exists, because the model's
Example
P, X_co2 = compute_saturation_pressure(SunYao2026_Solubility(), 0.04, 0.001, 1173.15)
# (2.76e8, 0.54): 4 wt% H2O and 1000 ppm CO2 saturate at 276 MPa in rhyolite at 900 °CReferences
- Sun, C., Yao, L. (2026), A unified H2O–CO2 solubility–speciation model for magmatic liquids: Constraints on magma storage architecture in continental rifts, EPSL 689, 120115, https://doi.org/10.1016/j.epsl.2026.120115
The figure applies it as a melt-inclusion barometer in rhyolite at 850 °C. The isobars are the dissolved contents in equilibrium with gases of all compositions at fixed pressure. Each of six illustrative inclusions, not measured data, is labeled with its saturation pressure and the depth Liu2005_Solubility, which are up to 10 % higher.
using GeoParams, CairoMakie
rhyolite, liu = SunYao2026_Solubility(), Liu2005_Solubility()
T = 1123.15 # 850 °C
ρ, g = 2600.0, 9.81 # crust density (kg/m³), gravity (m/s²)
# illustrative melt inclusions, not data: (H2O wt%, CO2 ppm)
inclusions = [(2.5, 100.0), (3.0, 400.0), (4.0, 150.0), (4.5, 900.0), (5.5, 300.0), (6.0, 1200.0)]
fig = Figure(size = (1000, 520))
ax = Axis(fig[1, 1]; xlabel = "dissolved H₂O (wt%)", ylabel = "dissolved CO₂ (ppm)", title = "SunYao2026_Solubility, rhyolite, 850 °C")
X = range(0, 1, 201)
for (k, P) in enumerate((50.0e6, 100.0e6, 200.0e6, 300.0e6, 400.0e6))
m = [compute_dissolved(rhyolite, P, T, x) for x in X]
lines!(ax, 100 .* first.(m), 1.0e6 .* last.(m); color = k, colormap = :viridis, colorrange = (1, 5), label = "$(round(Int, P / 1.0e6)) MPa")
end
P_sy = [compute_saturation_pressure(rhyolite, h / 100, c / 1.0e6, T)[1] for (h, c) in inclusions]
P_liu = [compute_saturation_pressure(liu, h / 100, c / 1.0e6, T)[1] for (h, c) in inclusions]
scatter!(ax, inclusions; color = :black, label = "illustrative inclusions")
for ((h, c), P) in zip(inclusions, P_sy)
text!(ax, h, c; text = "$(round(Int, P / 1.0e6)) MPa, $(round(P / (ρ * g) / 1.0e3; digits = 1)) km", offset = (6, 2), fontsize = 11)
end
Legend(fig[2, 1:2], ax; orientation = :horizontal, framevisible = false)
ax2 = Axis(fig[1, 2]; xlabel = "P, SunYao2026_Solubility (MPa)", ylabel = "P, Liu2005_Solubility (MPa)", title = "same inclusions, two laws", aspect = 1)
ablines!(ax2, 0, 1; color = :gray, linestyle = :dash)
scatter!(ax2, P_sy ./ 1.0e6, P_liu ./ 1.0e6; color = :black)
colsize!(fig.layout, 2, Relative(0.35))
fig
The equilibrium volume fraction of exsolved H2O gas, given the total water content, follows in closed form from a solubility law and the melt and gas densities of a ThreePhase_Density:
GeoParams.MaterialParameters.Solubility.compute_gas_fraction Function
compute_gas_fraction(s::AbstractSolubility, ρ::ThreePhase_Density, args)Equilibrium volume fraction of exsolved H2O gas in a melt + crystal + gas magma, the ϕ_gas input of ThreePhase_Density, Suspension and CriticalPorosityFragmentation. args holds the pressure P, the temperature T, the melt fraction ϕ of the condensed (melt + crystal) phases as returned by a melting law, and the total water mass fraction m_h2o_total of the melt + gas, i.e. on a crystal-free basis; crystals hold no water. args is also passed to the ρmelt and ρgas laws of ρ. Also callable as compute_gas_fraction(s, ρ; args...).
The gas is pure H2O, so the dissolved water mass fraction of the melt is compute_dissolved(s, P, T, 0)[1]. The water mass balance of Degruyter & Huber (2014, eq. 18) gives the gas mass fraction of the melt + gas,
and with the crystal volume fraction
Pass ϕ_gas together with ϕ_x = (1 - ϕ_gas) * (1 - ϕ) to ThreePhase_Density and Suspension.
Undersaturated magma (ρgas. For the H2O gas density use HalbachChatterjee_Density, which is within 0.8 % of IAPWS-95 for 0.1–400 MPa and 600–1200 °C. The result is NaN for m_h2o_total outside ϕ outside SunYao2026_Solubility returns above ~2.5 GPa. It is dimensionless and the same for dimensional and nondimensionalized laws and inputs.
Example
ρ = ThreePhase_Density(; ρgas = HalbachChatterjee_Density())
args = (; P = 1.0e8, T = 1100.0, ϕ = 0.6, m_h2o_total = 0.05)
ϕ_gas = compute_gas_fraction(SunYao2026_Solubility(), ρ, args)
ρ_magma = compute_density(ρ, (; args..., ϕ_gas, ϕ_x = (1 - ϕ_gas) * (1 - args.ϕ)))References
- Degruyter, W., Huber, C. (2014), A model for the eruption frequency of upper crustal silicic magma chambers, EPSL 403, 117-130, https://doi.org/10.1016/j.epsl.2014.06.047
The figure shows the gas fraction of crystal-free rhyolite (ϕ = 1) at 850 °C for the SunYao2026_Solubility law and a HalbachChatterjee_Density gas. Gas exsolves below the saturation pressure of each water content. The dashed line is the default critical gas fraction of CriticalPorosityFragmentation.
using GeoParams, CairoMakie
ρ = ThreePhase_Density(; ρgas = HalbachChatterjee_Density())
solubility = SunYao2026_Solubility()
P = exp10.(range(5, log10(4.0e8), 200))
fig = Figure(size = (800, 500))
ax = Axis(fig[1, 1]; xscale = log10, xlabel = "pressure P (MPa)", ylabel = "gas volume fraction ϕ_gas (–)")
for m_h2o_total in (0.03, 0.05, 0.07)
ϕ_gas = [compute_gas_fraction(solubility, ρ, (; P = p, T = 1123.15, ϕ = 1.0, m_h2o_total)) for p in P]
lines!(ax, P ./ 1.0e6, ϕ_gas; label = "total H₂O = $(round(Int, 100 * m_h2o_total)) wt%")
end
hlines!(ax, 0.75; color = :black, linestyle = :dash, label = "ϕ_crit = 0.75")
axislegend(ax; position = :rc)
fig
Gas-mixture helpers for the energy equation:
GeoParams.MaterialParameters.Solubility.compute_gas_heatcapacity Function
compute_gas_heatcapacity(s::GasMixture, X_co2)Mass-weighted specific heat of the H2O–CO2 gas mixture; zero at X_co2 == 0 (reference convention).
GeoParams.MaterialParameters.Solubility.effective_molar_mass Function
effective_molar_mass(s::GasMixture, X_co2)Effective molar mass of the H2O–CO2 gas mixture at CO2 mole fraction X_co2.
Only for pure H2O gas in equilibrium does the exsolved-gas volume fraction ε_g close algebraically at a point, through compute_gas_fraction. With CO2, ε_g and X_co2 (CO2 mole fraction of the gas) are typically ODE state variables owned by the solver; the closures above are the entries to that mass balance, not a replacement for it.