Skip to content
Snippets Groups Projects
Commit 62be22cc authored by Brian Groenke's avatar Brian Groenke
Browse files

Move SWRC to Soils module

parent 182919da
No related branches found
No related tags found
1 merge request!90Preparatory changes for adding water processes
...@@ -10,10 +10,6 @@ using IfElse ...@@ -10,10 +10,6 @@ using IfElse
using ModelParameters using ModelParameters
using Unitful using Unitful
export SWRC, VanGenuchten include("water_bucket.jl")
include("swrc.jl")
# TODO: implement water fluxes
end end
...@@ -24,6 +24,9 @@ import Flatten: @flattenable, flattenable ...@@ -24,6 +24,9 @@ import Flatten: @flattenable, flattenable
export Soil, SoilParameterization, CharacteristicFractions, SoilProfile export Soil, SoilParameterization, CharacteristicFractions, SoilProfile
export soilcomponent, porosity, mineral, organic export soilcomponent, porosity, mineral, organic
const Enthalpy = HeatConduction.Enthalpy
const Temperature = HeatConduction.Temperature
""" """
SoilComposition SoilComposition
...@@ -126,7 +129,32 @@ function CryoGrid.initialcondition!(::Heterogeneous, soil::Soil{<:Characteristic ...@@ -126,7 +129,32 @@ function CryoGrid.initialcondition!(::Heterogeneous, soil::Soil{<:Characteristic
@. state.θo = soilcomponent(Val{:θo}(), χ, ϕ, θ, ω) @. state.θo = soilcomponent(Val{:θo}(), χ, ϕ, θ, ω)
end end
"""
mineral(soil::Soil, state, i)
Retrieves the mineral content for the given layer at grid cell `i`, if provided.
Defaults to using the scalar mineral content defined on `soil`.
"""
@inline mineral(soil::Soil, state, i) = Utils.getscalar(mineral(soil, state), i)
"""
organic(soil::Soil, state, i)
Retrieves the organic content for the given layer at grid cell `i`, if provided.
Defaults to using the scalar organic content defined on `soil`.
"""
@inline organic(soil::Soil, state, i) = Utils.getscalar(organic(soil, state), i)
"""
porosity(soil::Soil, state, i)
Retrieves the porosity for the given layer at grid cell `i`, if provided.
Defaults to using the scalar porosity defined on `soil`.
"""
@inline porosity(soil::Soil, state, i) = Utils.getscalar(porosity(soil, state), i)
export SWRC, VanGenuchten
include("sfcc/swrc.jl")
export SFCC, DallAmico, Westermann, McKenzie, SFCCNewtonSolver, SFCCPreSolver export SFCC, DallAmico, Westermann, McKenzie, SFCCNewtonSolver, SFCCPreSolver
include("sfcc/sfcc.jl")
include("soilheat.jl") include("soilheat.jl")
end end
...@@ -49,12 +49,9 @@ CryoGrid.variables(::Soil, ::Heat, s::SFCCSolver) = () ...@@ -49,12 +49,9 @@ CryoGrid.variables(::Soil, ::Heat, s::SFCCSolver) = ()
Dall'Amico M, 2010. Coupled water and heat transfer in permafrost modeling. Ph.D. Thesis, University of Trento, pp. 43. Dall'Amico M, 2010. Coupled water and heat transfer in permafrost modeling. Ph.D. Thesis, University of Trento, pp. 43.
""" """
Base.@kwdef struct DallAmico{T,Θ,A,N,G,Tvg} <: SFCCFunction Base.@kwdef struct DallAmico{T,Θ,A,N,G,Tvg<:VanGenuchten} <: SFCCFunction
Tₘ::T = Param(0.0, units=u"°C") Tₘ::T = Param(0.0, units=u"°C")
θres::Θ = Param(0.0, bounds=(0,1)) θres::Θ = Param(0.0, bounds=(0,1))
# TODO: remove α and n from here since they are now in VanGenuchten
α::A = Param(4.0, bounds=(eps(),Inf), units=u"1/m")
n::N = Param(2.0, bounds=(1,Inf))
g::G = 9.80665u"m/s^2" # acceleration due to gravity g::G = 9.80665u"m/s^2" # acceleration due to gravity
swrc::Tvg = VanGenuchten() swrc::Tvg = VanGenuchten()
end end
...@@ -64,12 +61,12 @@ sfccargs(f::DallAmico, soil::Soil, heat::Heat, state) = ( ...@@ -64,12 +61,12 @@ sfccargs(f::DallAmico, soil::Soil, heat::Heat, state) = (
heat.prop.Lf, # specific latent heat of fusion, L heat.prop.Lf, # specific latent heat of fusion, L
f.θres, f.θres,
f.Tₘ, f.Tₘ,
f.α, f.swrc.α,
f.n, f.swrc.n,
) )
# pressure head at T # pressure head at T
@inline ψ(T,Tstar,ψ₀,Lf,g) = ψ₀ + Lf/(g*Tstar)*(T-Tstar)*heaviside(Tstar-T) @inline ψ(T,Tstar,ψ₀,Lf,g) = ψ₀ + Lf/(g*Tstar)*(T-Tstar)*heaviside(Tstar-T)
@inline function (f::DallAmico)(T, θsat, θtot, Lf, θres=f.θres, Tₘ=f.Tₘ, α=f.α, n=f.n) @inline function (f::DallAmico)(T, θsat, θtot, Lf, θres=f.θres, Tₘ=f.Tₘ, α=f.swrc.α, n=f.swrc.n)
let θsat = max(θtot, θsat), let θsat = max(θtot, θsat),
g = f.g, g = f.g,
Tₘ = normalize_temperature(Tₘ), Tₘ = normalize_temperature(Tₘ),
......
File moved
const Enthalpy = HeatConduction.Enthalpy
const Temperature = HeatConduction.Temperature
# === Thermal properties === # === Thermal properties ===
# We use methods with optional index arguments `i` to allow for implementations both # We use methods with optional index arguments `i` to allow for implementations both
# where these variables are treated as constants and as state variables. # where these variables are treated as constants and as state variables.
# In the latter case, specializations should override only the index-free form # In the latter case, specializations should override only the index-free form
# and return a state vector instead of a scalar. The `getscalar` function will # and return a state vector instead of a scalar. The `getscalar` function will
# handle both the scalar and vector case! # handle both the scalar and vector case!
"""
mineral(soil::Soil, state, i)
Retrieves the mineral content for the given layer at grid cell `i`, if provided.
Defaults to using the scalar mineral content defined on `soil`.
"""
@inline mineral(soil::Soil, state, i) = Utils.getscalar(mineral(soil, state), i)
"""
organic(soil::Soil, state, i)
Retrieves the organic content for the given layer at grid cell `i`, if provided.
Defaults to using the scalar organic content defined on `soil`.
"""
@inline organic(soil::Soil, state, i) = Utils.getscalar(organic(soil, state), i)
"""
porosity(soil::Soil, state, i)
Retrieves the porosity for the given layer at grid cell `i`, if provided.
Defaults to using the scalar porosity defined on `soil`.
"""
@inline porosity(soil::Soil, state, i) = Utils.getscalar(porosity(soil, state), i)
# Functions for retrieving constituents and volumetric fractions # Functions for retrieving constituents and volumetric fractions
@inline HeatConduction.thermalconductivities(soil::Soil, heat::Heat) = (heat.prop.kw, heat.prop.ki, heat.prop.ka, soil.prop.km, soil.prop.ko) @inline HeatConduction.thermalconductivities(soil::Soil, heat::Heat) = (heat.prop.kw, heat.prop.ki, heat.prop.ka, soil.prop.km, soil.prop.ko)
@inline HeatConduction.heatcapacities(soil::Soil, heat::Heat) = (heat.prop.cw, heat.prop.ci, heat.prop.ca, soil.prop.cm, soil.prop.co) @inline HeatConduction.heatcapacities(soil::Soil, heat::Heat) = (heat.prop.cw, heat.prop.ci, heat.prop.ca, soil.prop.cm, soil.prop.co)
...@@ -42,9 +18,6 @@ Defaults to using the scalar porosity defined on `soil`. ...@@ -42,9 +18,6 @@ Defaults to using the scalar porosity defined on `soil`.
end end
end end
# SFCC
include("sfcc.jl")
""" """
Initial condition for heat conduction (all state configurations) on soil layer w/ SFCC. Initial condition for heat conduction (all state configurations) on soil layer w/ SFCC.
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment