diff --git a/src/Density/Density.jl b/src/Density/Density.jl index 806fa684..bec89599 100644 --- a/src/Density/Density.jl +++ b/src/Density/Density.jl @@ -27,7 +27,8 @@ export compute_density, # calculation routines Compressible_Density, # Compressible density T_Density, # T dependent density Vector_Density, # Vector with density - MeltDependent_Density # Melt dependent density + MeltDependent_Density, # Melt dependent density + get_α # Define "empty" computational routines in case nothing is defined function compute_density!( @@ -123,7 +124,6 @@ end @inline (ρ::PT_Density)(args) = ρ(; args...) @inline compute_density(s::PT_Density, args) = s(args) - # Print info function show(io::IO, g::PT_Density) return print( @@ -403,4 +403,14 @@ for type in (ConstantDensity, PT_Density, Compressible_Density, T_Density, MeltD @extractors(type, :Density) end +import GeoParams.get_α + +function get_α(rho::MeltDependent_Density; ϕ::T=0.0, kwargs...) where {T} + αsolid = rho.ρsolid.α.val + αmelt = rho.ρmelt.α.val + return @muladd ϕ * αmelt + (1-ϕ) * αsolid +end + +get_α(rho::MeltDependent_Density, args) = get_α(rho; args...) + end diff --git a/src/GeoParams.jl b/src/GeoParams.jl index 754c28a7..89ebfc2f 100644 --- a/src/GeoParams.jl +++ b/src/GeoParams.jl @@ -115,7 +115,6 @@ export MaterialParams, SetMaterialParams, No_MaterialParam, MaterialParamsInfo using .MaterialParameters.PhaseDiagrams export PhaseDiagram_LookupTable, PerpleX_LaMEM_Diagram - # Density using .MaterialParameters.Density export compute_density, # computational routines @@ -445,4 +444,5 @@ export ntuple_idx # PeierlsCreep_info, # NonLinearPeierlsCreep_info + end # module diff --git a/src/Utils.jl b/src/Utils.jl index dcc1f6f9..2a4a6cbc 100644 --- a/src/Utils.jl +++ b/src/Utils.jl @@ -151,4 +151,4 @@ function add_extractor_functions(::Type{_T}, param_field) where _T end end end -end \ No newline at end of file +end diff --git a/test/test_Density.jl b/test/test_Density.jl index 442a78a8..634bc716 100644 --- a/test/test_Density.jl +++ b/test/test_Density.jl @@ -325,6 +325,13 @@ using Test, GeoParams, StaticArrays, LaTeXStrings @test ρmelt ≈ 2198.68 @test ρ == (1-args.ϕ)*ρsolid + args.ϕ*ρmelt + x = MeltDependent_Density( + ρsolid = PT_Density(α= 1e-3), + ρmelt = PT_Density(α= 1e-2), + ) + @test GeoParams.get_α(x, (;ϕ = 1)) == 1e-2 + @test GeoParams.get_α(x, (;ϕ = 0)) == 1e-3 + @test GeoParams.get_α(x, (;ϕ = 0.5)) == 0.0055 rheologies = ( SetMaterialParams(;