Skip to content

Density ​

Methods ​

The density equation of state can be specified in a number of ways

GeoParams.MaterialParameters.Density.ConstantDensity Type
julia
ConstantDensity(ρ=2900kg/m^3)

Set a constant density:

ρ=cst

where ρ is the density [kg/m3].

source
GeoParams.MaterialParameters.Density.PT_Density Type
julia
PT_Density(ρ0=2900kg/m^3, α=3e-5/K, β=1e-9/Pa, T0=0C, P=0MPa)

Set a pressure and temperature-dependent density:

ρ=ρ0(1.0−α(T−T0)+β(P−P0))

where ρ0 is the density [kg/m3] at reference temperature T0 and pressure P0, α is the temperature dependence of density and β the pressure dependence.

source
GeoParams.MaterialParameters.Density.T_Density Type
julia
T_Density(ρ0=2900kg/m^3, α=3e-5/K, T₀=273.15K)

Set a temperature-dependent density:

ρ=ρ0(1−α∗(T−T_0))

where ρ0 is the density [kg/m3] at reference temperature T0 and α the temperature dependence.

source
GeoParams.MaterialParameters.Density.Compressible_Density Type
julia
Compressible_Density(ρ0=2900kg/m^3, β=1e-9/Pa, P₀=0MPa)

Set a pressure-dependent density:

ρ=ρ0exp⁡(β∗(P−P_0))

where ρ0 is the density [kg/m3] at reference pressure P0 and β the pressure dependence.

source
GeoParams.MaterialParameters.Density.MeltDependent_Density Type
julia
MeltDependent_Density(ρsolid=ConstantDensity(), ρmelt=ConstantDensity())

If we use a single phase code the average density of a partially molten rock is

ρ=ϕρmelt+(1−ϕ)ρsolid

where ρ is the average density [kg/m3], ρmelt the melt density, ρsolid the solid density and ϕ the melt fraction.

Note that any density formulation can be used for melt and solid.

source
GeoParams.MaterialParameters.Density.BubbleFlow_Density Type
julia
BubbleFlow_Density(ρmelt=ConstantDensity(), ρgas=ConstantDensity(), c0=0e0, a=0.0041MPa^(-1//2))

Defines the BubbleFlow_Density as described in Slezin (2003) with a default gas solubility constant of 0.0041MPa−1/2 used in e.g. Sparks et al. (1978)

ρ=1c0−cρg+1−(c0−c)ρm

with

c={aP1/2for P<c02a2c0for P≥c02a2

Arguments

  • ρmelt: Density of the melt

  • ρgas: Density of the gas

  • c0: Total volatile content

  • a: Gas solubility constant (default: 4.1e-6Pa−1/2) (after Sparks et al., 1978)

Possible values for a are 3.2e-6-6.4e-6Pa−1/2 where the lower value corresponds to mafic magmas at rather large pressures (400-600MPa) and the higher value to felsic magmas at low pressures (0 to 100-200MPa) (after Slezin (2003))

Example

julia
julia> rheology = SetMaterialParams(;
           Phase = 1,
           CreepLaws = (PowerlawViscous(), LinearViscous(; η = 1e21Pa * s)),
           Gravity = ConstantGravity(; g = 9.81m / s^2),
           Density = BubbleFlow_Density(;
               ρmelt = ConstantDensity(ρ = 2900kg / m^3),
               ρgas = ConstantDensity(ρ = 1kg / m^3),
               c0 = 0.0,
               a = 0.0041MPa^(-1 // 2),
           ),
       );

julia> rheology.Density[1]
Bubble flow density: ρ = 1/((c0-c)/ρgas + (1-(c0-c))/ρmelt); ρmelt=Constant density: ρ=2900.0 kg m⁻³·⁰; ρgas=Constant density: ρ=1.0 kg m⁻³·⁰; c0=0.0; a=0.0041 MPa⁻⁰·⁵

References

source
GeoParams.MaterialParameters.Density.GasPyroclast_Density Type
julia
GasPyroclast_Density(ρmelt=ConstantDensity(), ρgas=ConstantDensity(), δ=0e0)

Defines the GasPyroclast_Density as described in Slezin (2003) with a default volume fraction of free gas in the flow of 0.0 This is also used to model partly destroyed foam in the conduit.

ρ=ρgδ+ρp(1−δ)

with

ρp=ρm(1−β)+ρgβ≈ρl(1−β)

Arguments

  • ρmelt: Density of the melt

  • ρgas: Density of the gas

  • δ: Volume fraction of free gas in the flow

  • β: Gas volume fraction enclosed within the particles

Example

julia
julia> rheology = SetMaterialParams(;
           Phase = 1,
           CreepLaws = (PowerlawViscous(), LinearViscous(; η = 1e21Pa * s)),
           Gravity = ConstantGravity(; g = 9.81m / s^2),
           Density = GasPyroclast_Density(;
               ρmelt = ConstantDensity(ρ = 2900kg / m^3),
               ρgas = ConstantDensity(ρ = 1kg / m^3),
               δ = 0.0,
               β = 0.0,
           ),
       );

julia> rheology.Density[1]
Gas-Pyroclast mixture density: ρ = ρgas*δ + ρmelt*(1-β); ρmelt=Constant density: ρ=2900.0 kg m⁻³·⁰; ρgas=Constant density: ρ=1.0 kg m⁻³·⁰; δ=0.0; β=0.0

References

source
GeoParams.MaterialParameters.Density.Melt_DensityX Type
julia
Melt_DensityX(; oxd_wt = oxd_wt)

Set a density depending on the oxide composition after the python script by Iacovino K & Till C (2019)

Arguments

  • oxd_wt::NTuple{9, T}: Melt composition as 9-element Tuple containing concentrations in [wt%] of the following oxides ordered in the exact sequence

           (SiO2 TiO2 Al2O3 FeO MgO CaO Na2O K2O H2O) 
    
           Default values are for a hydrous N-MORB composition

The callable also accepts an mH2O keyword (melt water content, mass fraction) that overrides the struct's own oxd_wt[9] for that call, recomputing only the water-dependent aggregates. mH2O is accepted as given: GeoParams does not check it for consistency with any Solubility or other closure's dissolved-water output — that is the caller's/solver's responsibility.

References

  • Iacovino K & Till C (2019). DensityX: A program for calculating the densities of magmatic liquids up to 1,627 °C and 30 kbar. Volcanica 2(1), p 1-10. doi:10.30909/vol.02.01.0110
source
GeoParams.MaterialParameters.Density.RedlichKwong_Density Type
julia
RedlichKwong_Density(; coeffs=(-112.528, 127.811, 112.04), T0=273.15K, Tref=1K, Pref=1e5Pa, ρref=1e3kg/m^3)

H2O gas density from the fit of Huber et al. (2010, eq. 7, Fig. 4) to the modified Redlich–Kwong equation of Halbach & Chatterjee (1982), as used by Degruyter & Huber (2014); the fit avoids solving the cubic equation and is stated for 600–900 °C and 30–400 MPa:

ρg=ρref(a1τ−0.381+a2ϖ−1.135+a3τ−0.411ϖ0.033),τ=T−T0Tref, ϖ=PPref

The fit's specific units (°C, bar) enter through the reference quantities: with T0=273.15K, Tref=1K the group τ equals T in °C, and with Pref=1e5Pa (1 bar) ϖ equals P in bar. Because τ and ϖ are ratios of like-dimensioned quantities, the expression is dimensionally homogeneous and nondimensionalizes cleanly: only the reference GeoUnits scale, the fitted dimensionless coeffs do not. The parameterisation ignores gas composition (pseudo-pure H2O), matching the reference.

Against IAPWS-95 (Wagner & Pruß 2002) the fit is within 10 % only above about 120 MPa. At the lower end of its stated range, 30 MPa, it is off by +36 % at 600 °C and −35 % at 850 °C; outside that range it is off by −80 % at 30 MPa and 1000 °C, negative at 1200 °C, and grows without bound as P→0. HalbachChatterjee_Density evaluates the equation that the fit approximates, in closed form, and is within 0.8 % for 0.1–400 MPa and 600–1200 °C.

Returns NaN for T ≤ 273.15K or P ≤ 0 (τ ≤ 0 or ω ≤ 0), since τ^(-0.381)/τ^(-0.411) and ω^(-1.135) require a positive base: raising to those exponents would otherwise throw an opaque low-level DomainError about complex exponentiation.

References

  • Huber C., Bachmann O. , Manga M., Two Competing Effects of Volatiles on Heat Transfer in Crystal-rich Magmas: Thermal Insulation vs Defrosting, Journal of Petrology, 847–867, https://doi.org/10.1093/petrology/egq003

  • 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

  • Wagner W., Pruß A. (2002), The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use, J. Phys. Chem. Ref. Data 31, 387-535, https://doi.org/10.1063/1.1461829

source
GeoParams.MaterialParameters.Density.IdealGas_Density Type
julia
IdealGas_Density(; Rs=461.5J/kg/K)

Ideal-gas density

ρg=PRsT

with specific gas constant Rs (default: water vapor, R/Mw=8.314/0.01802). Unlike RedlichKwong_Density this is dimensionally homogeneous, so it nondimensionalizes cleanly and serves as the analytic derivative check for the Redlich–Kwong fit.

source
GeoParams.MaterialParameters.Density.HalbachChatterjee_Density Type
julia
HalbachChatterjee_Density()

H2O gas density from the empirical Redlich–Kwong equation of state of Halbach & Chatterjee (1982, eq. 3),

P=RTV−b(P)−a(T)TV(V+b(P)),

with a(T)=1.616×108−4.989×104T−7.358×109/T (eqs. 8, 14) and b(P)=(1+3.4505×10−4P+3.8980×10−9P2−2.7756×10−15P3)/(6.3944×10−2+2.3776×10−5P+4.5717×10−10P2) (eqs. 9, 15), where T is in K, P in bar, V in cm³/mol and R=83.143 cm³ bar/(mol K). The equation is solved in closed form as the cubic Z3−Z2+(A−B−B2)Z−AB=0 for the compressibility Z=PV/(RT), with A=aP/(R2T2.5) and B=bP/(RT), and returns ρ=MP/(ZRT) with M=18.0153 g/mol. The largest root is taken; below the critical temperature (647 K) it is the vapor branch even where liquid water is stable.

Against IAPWS-95 (Wagner & Pruß 2002) the density is within 0.8 % for 0.1–400 MPa and 600–1200 °C (fitted to data at 100–1000 °C and 0.002–5 GPa), and it tends to the ideal-gas density as P→0. Below the critical temperature it deviates up to ~10 % from IAPWS-95 (e.g. 370 °C and 15 MPa). The cubic has three real roots up to ~690 K: between 647 and 690 K at ~13–31 MPa the largest root is up to 60 % below IAPWS-95 (650 K, 24 MPa), and the density jumps where the vapor-like root vanishes (at 673 K from 205 to 480 kg/m³ between 27.7 and 27.8 MPa). Invalid inputs (P≤0 or T≤0) give NaN.

The fit's units enter through the reference quantities Tref = 1K, Pref = 1e5Pa (1 bar) and ρref = 1e3kg/m^3 (1 g/cm³), so the law nondimensionalizes like RedlichKwong_Density; they are not material parameters.

References

  • Halbach H., Chatterjee N.D. (1982), An empirical Redlich-Kwong-type equation of state for water to 1,000 °C and 200 kbar, Contributions to Mineralogy and Petrology 79, 337-345, https://doi.org/10.1007/BF00371526

  • Wagner W., Pruß A. (2002), The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use, J. Phys. Chem. Ref. Data 31, 387-535, https://doi.org/10.1063/1.1461829

source
GeoParams.MaterialParameters.Density.ThreePhase_Density Type
julia
ThreePhase_Density(; ρmelt=ConstantDensity(ρ=2300kg/m^3), ρsolid=ConstantDensity(ρ=2600kg/m^3), ρgas=IdealGas_Density(), ρ=2400kg/m^3)

Volume-fraction mixture density of a melt + crystal + gas magma (Degruyter & Huber 2014):

ρ=εmρm+εgρg+εxρx,εm=1−εx−εg

The gas and crystal volume fractions ϕ_gas, ϕ_x are inputs (from the solver's ODE state / a melting law), passed through args; the sub-densities receive the same args (e.g. P, T) so an equation-of-state gas density is evaluated in place. ρ is a dimensional-tracking sentinel.

ρgas is only evaluated when ϕ_gas != 0: a cell with no exsolved gas never depends on the gas closure at all, so a gas law that returns NaN for invalid inputs (e.g. P ≤ 0) cannot poison a ϕ_gas=0 cell.

Arguments

References

source

H2O gas density ​

The figure compares the H2O gas laws at 850 °C. IdealGas_Density is close to HalbachChatterjee_Density below about 10 MPa, but is 10 % too low near 100 MPa and 27 % too high at 400 MPa. RedlichKwong_Density is a fit stated for 30–400 MPa; it is off by up to 35 % near 30 MPa and diverges below it.

julia
using GeoParams, CairoMakie
T = 1123.15
P = exp10.(range(5, log10(4.0e8), 300))
hc, rk, ig = HalbachChatterjee_Density(), RedlichKwong_Density(), IdealGas_Density()
ρ(law) = [compute_density(law, (; P = p, T)) for p in P]
ρ_hc, ρ_rk, ρ_ig = ρ(hc), ρ(rk), ρ(ig)
fit = P .≥ 3.0e7    # RedlichKwong_Density is stated for 30–400 MPa
fig = Figure(size = (1000, 420))
ax1 = Axis(fig[1, 1]; xscale = log10, yscale = log10, xlabel = "pressure P (MPa)", ylabel = "ρ (kg/m³)", title = "H2O gas density at 850 °C")
ax2 = Axis(fig[1, 2]; xscale = log10, xlabel = "pressure P (MPa)", ylabel = "ρ / ρ_HalbachChatterjee (–)", title = "relative to HalbachChatterjee_Density")
for (ax, f) in ((ax1, identity), (ax2, r -> r ./ ρ_hc))
    lines!(ax, P ./ 1.0e6, f(ρ_hc); label = "HalbachChatterjee_Density")
    lines!(ax, P ./ 1.0e6, f(ρ_rk); color = Cycled(2), linestyle = :dash, label = "RedlichKwong_Density, outside its fit")
    lines!(ax, P[fit] ./ 1.0e6, f(ρ_rk)[fit]; color = Cycled(2), label = "RedlichKwong_Density")
    lines!(ax, P ./ 1.0e6, f(ρ_ig); color = Cycled(3), label = "IdealGas_Density")
end
ylims!(ax1, 0.1, 2.0e3)
ylims!(ax2, 0.4, 1.6)
axislegend(ax1; position = :lt)
fig

Computational routines ​

To evaluate density within a user routine, use this:

GeoParams.MaterialParameters.Density.compute_density Function
julia
compute_density(s::Vector_Density; index::Int64, kwargs...)

Pointwise calculation of density from a vector where index is the index of the point

source
julia
compute_density(P,T, s::AbstractPhaseDiagramsStruct)

Interpolates density as a function of T,P from a lookup table

source
GeoParams.MaterialParameters.Density.compute_density! Function
julia
compute_density!(rho::AbstractArray{_T, ndim}, MatParam::NTuple{N,AbstractMaterialParamsStruct}, Phases::AbstractArray{_I, ndim}; P=nothing, T=nothing) where {ndim,N,_T,_I<:Integer}

In-place computation of density rho for the whole domain and all phases, in case a vector with phase properties MatParam is provided, along with P and T arrays. This assumes that the Phase of every point is specified as an Integer in the Phases array.

Example

julia
julia> MatParam = (
           SetMaterialParams(Name = "Mantle", Phase = 1,
               CreepLaws = (PowerlawViscous(), LinearViscous(η = 1e23Pa * s)),
               Density = PT_Density()),
           SetMaterialParams(Name = "Crust", Phase = 2,
               CreepLaws = (PowerlawViscous(), LinearViscous(η = 1e23Pa * s)),
               Density = ConstantDensity(ρ = 2900kg / m^3)),
       );

julia> Phases = ones(Int64, 2, 4); Phases[:, 3:end] .= 2;

julia> rho = zeros(size(Phases));

julia> args = (P = ones(size(Phases)) * 10, T = ones(size(Phases)) * 273.15);

julia> compute_density!(rho, MatParam, Phases, args)

julia> rho
2×4 Matrix{Float64}:
 2900.0  2900.0  2900.0  2900.0
 2900.0  2900.0  2900.0  2900.0

The routine is made to minimize allocations:

julia
using BenchmarkTools
@btime compute_density!($rho, $MatParam, $Phases, P = $P, T = $T)

compute_density!(rho::AbstractArray{_T, N}, MatParam::NTuple{K,AbstractMaterialParamsStruct}, PhaseRatios::AbstractArray{_T, M}, P=nothing, T=nothing)

In-place computation of density rho for the whole domain and all phases, in case a vector with phase properties MatParam is provided, along with P and T arrays. This assumes that the PhaseRatio of every point is specified as an Integer in the PhaseRatios array, which has one dimension more than the data arrays (and has a phase fraction between 0-1)

source

Note that density values are usually not used in itself in the governing PDE's, but usually in combination with other parameters, such as ρg or ρcp. The non-dimensional value of ρ may thus have very large or small values, but multiplied with the other values one often obtains numbers that are closer to one.