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

Rename permafrost temp profile initializer

parent df0cab50
No related branches found
No related tags found
No related merge requests found
name = "CryoGrid" name = "CryoGrid"
uuid = "a535b82e-5f3d-4d97-8b0b-d6483f5bebd5" uuid = "a535b82e-5f3d-4d97-8b0b-d6483f5bebd5"
authors = ["Brian Groenke <brian.groenke@awi.de>", "Jan Nitzbon <jan.nitzbon@awi.de>", "Moritz Langer <moritz.langer@awi.de>"] authors = ["Brian Groenke <brian.groenke@awi.de>", "Jan Nitzbon <jan.nitzbon@awi.de>", "Moritz Langer <moritz.langer@awi.de>"]
version = "0.23.0" version = "0.23.1"
[deps] [deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
......
...@@ -29,7 +29,7 @@ include("thermal_properties.jl") ...@@ -29,7 +29,7 @@ include("thermal_properties.jl")
export HeatBC, ConstantTemperature, GeothermalHeatFlux, TemperatureBC, GroundHeatFlux, NFactor export HeatBC, ConstantTemperature, GeothermalHeatFlux, TemperatureBC, GroundHeatFlux, NFactor
include("heat_bc.jl") include("heat_bc.jl")
export LinearTwoPhaseInitialTempProfile, ThermalSteadyStateInit export PermafrostTemperatureInit, ThermalSteadyStateInit
include("heat_init.jl") include("heat_init.jl")
export heatconduction! export heatconduction!
......
""" """
LinearTwoPhaseTempProfile{TT1,TT2,TTb,TTm,Tz1,Tz2,Tz3,Tz4} <: VarInitializer{:T} PermafrostTemperatureInit{TT1,TT2,TTb,TTm,Tz1,Tz2,Tz3,Tz4} <: VarInitializer{:T}
Simple, piecewise linear temprature initializer that uses three temperature values Simple, piecewise linear temprature initializer that uses three temperature values
and four characteristic depths to initialize the temperature profile. `T0` is the and four characteristic depths to initialize the temperature profile. `T0` is the
initial surface temperature, `T1` is the permafrost temperature at `z_deep`, initial surface temperature, `Tpf` is the permafrost temperature at `z_deep`,
`z_thaw` and `z_base` are the top and bottom freezing fronts which are both assumed `z_thaw` and `z_base` are the top and bottom freezing fronts which are both assumed
to be have temperature equal to `Tm`. to be have temperature equal to `Tm`.
""" """
Base.@kwdef struct LinearTwoPhaseTempProfile{TT1,TT2,TTb,TTm,Tz1,Tz2,Tz3,Tz4} <: VarInitializer{:T} Base.@kwdef struct PermafrostTemperatureInit{TT1,TT2,TTb,TTm,Tz1,Tz2,Tz3,Tz4} <: VarInitializer{:T}
T0::TT1 = 1.0u"°C" T0::TT1 = 1.0u"°C" # surface temperature
T1::TT2 = -10.0u"°C" Tpf::TT2 = -10.0u"°C" # permafrost temperature
Tm::TTm = 0.0u"°C" Tm::TTm = 0.0u"°C" # melting point
Tbot::TTb = 10.0u"°C" Tbot::TTb = 10.0u"°C" # bottom temperature
z_top::Tz1 = 0.0u"m" z0::Tz1 = 0.0u"m" # surface depth
z_deep::Tz2 = 20.0u"m" z_thaw::Tz3 = 0.5u"m" # thaw depth (top of permafrost)
z_thaw::Tz3 = 0.5u"m" z_pf::Tz2 = 20.0u"m" # depth of peramfrost temperature
z_base::Tz4 = 500.0u"m" z_base::Tz4 = 500.0u"m" # depth of permafrost base
end end
(init::LinearTwoPhaseTempProfile)(::SubSurface, state) = init(state.T, state.grid) (init::PermafrostTemperatureInit)(::SubSurface, state) = init(state.T, state.grid)
""" """
(init::LinearTwoPhaseTempProfile)(T::AbstractVector, grid::Grid) (init::PermafrostTemperatureInit)(T::AbstractVector, grid::Grid)
Evaluate the initializer on the given temperature vector `T` which should match the length of Evaluate the initializer on the given temperature vector `T` which should match the length of
`cells(grid)`. `cells(grid)`.
""" """
function (init::LinearTwoPhaseTempProfile)(T::AbstractVector, grid::Grid) function (init::PermafrostTemperatureInit)(T::AbstractVector, grid::Grid)
@assert length(T) == length(cells(grid)) @assert length(T) == length(cells(grid))
T0 = ustrip(init.T0) T0 = ustrip(init.T0)
T1 = ustrip(init.T1) Tpf = ustrip(init.Tpf)
Tbot = ustrip(init.Tbot) Tbot = ustrip(init.Tbot)
Tm = ustrip(init.Tm) Tm = ustrip(init.Tm)
z_top = ustrip(init.z_top) z0 = ustrip(init.z0)
z_deep = ustrip(init.z_deep) z_deep = ustrip(init.z_pf)
z_thaw = ustrip(init.z_thaw) z_thaw = ustrip(init.z_thaw)
z_base = ustrip(init.z_base) z_base = ustrip(init.z_base)
z_bot = parent(grid)[end] z_bot = parent(grid)[end]
Ts = [T0, Tm, T1, Tm, Tbot] Ts = [T0, Tm, Tpf, Tm, Tbot]
zs = [z_top, z_thaw, z_deep, z_base, z_bot] zs = [z0, z_thaw, z_deep, z_base, z_bot]
f = Interp.extrapolate(Interp.interpolate((zs,), Ts, Interp.Gridded(Interp.Linear())), Interp.Flat()) f = Interp.extrapolate(Interp.interpolate((zs,), Ts, Interp.Gridded(Interp.Linear())), Interp.Flat())
# evaluate interpolant at grid cell midpoints # evaluate interpolant at grid cell midpoints
T .= f.(cells(grid)) T .= f.(cells(grid))
......
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