55
66Base type for unsaturated hydraulic conductivity parameterizations.
77"""
8- abstract type AbstractUnsatK end
8+ abstract type AbstractUnsatK{NF} end
99
1010"""
1111 get_swrc(::AbstractUnsatK)
@@ -63,7 +63,7 @@ measurements of hydraulic properites are available.
6363Properties:
6464$TYPEDFIELDS
6565"""
66- @kwdef struct ConstantSoilHydraulics{NF, RC, UnsatK} <: AbstractSoilHydraulics{NF, RC, UnsatK}
66+ @kwdef struct ConstantSoilHydraulics{NF, RC, UnsatK <: AbstractUnsatK{NF} } <: AbstractSoilHydraulics{NF, RC, UnsatK}
6767 " Soil water retention curve"
6868 swrc:: RC
6969
@@ -78,12 +78,6 @@ $TYPEDFIELDS
7878
7979 " Prescribed wilting point [-]"
8080 wilting_point:: NF = 0.05
81-
82- # TODO : Remove once FreezeCurves.jl allows for generic type bounds
83- function ConstantSoilHydraulics (swrc:: SWRC , unsat_hydraulic_cond:: AbstractUnsatK , args:: NF... ) where {NF}
84- adapted_swrc = adapt (NumberFormatAdaptor {NF} (), ustrip (swrc))
85- return new {NF, typeof(adapted_swrc), typeof(unsat_hydraulic_cond)} (adapted_swrc, unsat_hydraulic_cond, args... )
86- end
8781end
8882
8983function ConstantSoilHydraulics (
@@ -92,7 +86,8 @@ function ConstantSoilHydraulics(
9286 unsat_hydraulic_cond = UnsatKLinear (NF),
9387 kwargs...
9488 ) where {NF}
95- return ConstantSoilHydraulics (; swrc, unsat_hydraulic_cond, kwargs... )
89+ swrc = adapt (NumberFormatAdaptor {NF} (), ustrip (swrc))
90+ return ConstantSoilHydraulics {NF, typeof(swrc), typeof(unsat_hydraulic_cond)} (; swrc, unsat_hydraulic_cond, kwargs... )
9691end
9792
9893@inline saturated_hydraulic_conductivity (hydraulics:: ConstantSoilHydraulics , args... ) = hydraulics. sat_hydraulic_cond
@@ -110,7 +105,7 @@ and wilting point as a function of soil texture.
110105Properties:
111106$TYPEDFIELDS
112107"""
113- @kwdef struct SoilHydraulicsSURFEX{NF, RC, UnsatK} <: AbstractSoilHydraulics{NF, RC, UnsatK}
108+ @kwdef struct SoilHydraulicsSURFEX{NF, RC, UnsatK <: AbstractUnsatK{NF} } <: AbstractSoilHydraulics{NF, RC, UnsatK}
114109 " Soil water retention curve"
115110 swrc:: RC
116111
@@ -128,12 +123,6 @@ $TYPEDFIELDS
128123
129124 " Exponent of field capacity adjustment due to clay content [-]"
130125 field_capacity_exp:: NF = 0.35
131-
132- # TODO : Remove once FreezeCurves.jl allows for generic type bounds
133- function SoilHydraulicsSURFEX (swrc:: SWRC , unsat_hydraulic_cond:: AbstractUnsatK , args:: NF... ) where {NF}
134- adapted_swrc = adapt (NumberFormatAdaptor {NF} (), ustrip (swrc))
135- return new {NF, typeof(adapted_swrc), typeof(unsat_hydraulic_cond)} (adapted_swrc, unsat_hydraulic_cond, args... )
136- end
137126end
138127
139128function SoilHydraulicsSURFEX (
@@ -142,7 +131,8 @@ function SoilHydraulicsSURFEX(
142131 unsat_hydraulic_cond = UnsatKLinear (NF),
143132 kwargs...
144133 ) where {NF}
145- return SoilHydraulicsSURFEX (; swrc, unsat_hydraulic_cond, kwargs... )
134+ swrc = adapt (NumberFormatAdaptor {NF} (), ustrip (swrc))
135+ return SoilHydraulicsSURFEX {NF, typeof(swrc), typeof(unsat_hydraulic_cond)} (; swrc, unsat_hydraulic_cond, kwargs... )
146136end
147137
148138# TODO : this is not quite correct, SURFEX uses a hydraulic conductivity function that decreases exponentially with depth
169159Simple formulation of hydraulic conductivity as a linear function of the liquid water saturated fraction,
170160i.e. `soil.water / (soil.water + soil.ice + soil.air)`.
171161"""
172- struct UnsatKLinear{NF} <: AbstractUnsatK end
162+ struct UnsatKLinear{NF} <: AbstractUnsatK{NF} end
173163
174164UnsatKLinear (:: Type{NF} ) where {NF} = UnsatKLinear {NF} ()
175165
@@ -194,7 +184,7 @@ volumetric fractions, assumed to include those of water, ice, and air.
194184
195185See van Genuchten (1980) and Westermann et al. (2023).
196186"""
197- struct UnsatKVanGenuchten{NF} <: AbstractUnsatK
187+ struct UnsatKVanGenuchten{NF} <: AbstractUnsatK{NF}
198188 " Exponential scaling factor for ice impedance"
199189 impedance:: NF
200190end
0 commit comments