9494@inline function (f:: PainterKarra )(
9595 T,
9696 ψ₀= nothing ,
97- :: Val{return_all } = Val {false } ();
97+ :: Val{output } = Val {:θw } ();
9898 θtot= stripparams (f. swrc. water. θtot),
9999 θsat= stripparams (f. swrc. water. θsat),
100100 θres= stripparams (f. swrc. water. θres),
101101 Tₘ= f. freezethaw. Tₘ,
102102 β= f. β,
103103 ω= f. ω,
104104 swrc_kwargs...
105- ) where return_all
105+ ) where output
106106 let θsat = max (θtot, θsat),
107107 ψ₀ = isnothing (ψ₀) ? waterpotential (swrc (f), θtot; θsat, θres, swrc_kwargs... ) : ψ₀,
108108 g = f. g,
@@ -111,14 +111,20 @@ end
111111 Lsl = f. freezethaw. Lsl,
112112 Tₘ = normalize_temperature (Tₘ),
113113 T = normalize_temperature (T),
114- Tstar = Tₘ + ω* g* Tₘ/ Lsl* ψ₀,
114+ Tstar = Tₘ + ω* g* Tₘ/ Lsl* ψ₀;
115115 # matric potential as a function of T (same as Dall'Amico but with β parameter)
116- ψ = ψ₀ + β* Lsl/ (g* Tstar)* (T- Tstar)* heaviside (Tstar- T),
117- θw = f. swrc (ψ; θsat, θres, swrc_kwargs... );
118- if return_all
116+ ψ = ψ₀ + β* Lsl/ (g* Tstar)* (T- Tstar)* heaviside (Tstar- T)
117+ # output is a compile-time constant so will be compiled away
118+ if output == :all || output == true # allow 'true' for backwards compatibility w/ 0.4
119+ θw = f. swrc (ψ; θsat, θres, swrc_kwargs... )
119120 return (; θw, ψ, Tstar)
120- else
121+ elseif output == :θw || output == false # allow 'false' for backwards compatibility w/ 0.4
122+ θw = f. swrc (ψ; θsat, θres, swrc_kwargs... )
121123 return θw
124+ elseif output == :ψ
125+ return ψ
126+ elseif output == :Tstar
127+ return Tstar
122128 end
123129 end
124130end
@@ -157,18 +163,18 @@ end
157163@inline function (f:: DallAmico )(
158164 T,
159165 ψ₀= nothing ,
160- :: Val{return_all } = Val {false } ();
166+ :: Val{output } = Val {:θw } ();
161167 θtot= stripparams (f. swrc. water. θtot),
162168 θsat= stripparams (f. swrc. water. θsat),
163169 θres= stripparams (f. swrc. water. θres),
164170 Tₘ= f. freezethaw. Tₘ,
165171 swrc_kwargs...
166- ) where return_all
172+ ) where output
167173 # Dall'Amico is a special case of Painter-Karra with ω = β = 1
168174 pkfc = PainterKarra ()
169175 ω = 1.0
170176 β = 1.0
171- return pkfc (T, ψ₀, Val {return_all } (); θtot, θsat, θres, Tₘ, ω, β, swrc_kwargs... )
177+ return pkfc (T, ψ₀, Val {output } (); θtot, θsat, θres, Tₘ, ω, β, swrc_kwargs... )
172178end
173179function inflectionpoint (
174180 f:: DallAmico ,
@@ -200,14 +206,14 @@ end
200206function (f:: DallAmicoSalt )(
201207 T,
202208 ψ₀= nothing ,
203- :: Val{return_all } = Val {false } ();
209+ :: Val{output } = Val {:θw } ();
204210 θtot= stripparams (f. swrc. water. θtot),
205211 θsat= stripparams (f. swrc. water. θsat),
206212 θres= stripparams (f. swrc. water. θres),
207213 Tₘ= f. freezethaw. Tₘ,
208214 saltconc= f. saltconc,
209215 swrc_kwargs...
210- ) where return_all
216+ ) where output
211217 let θsat = max (θtot, θsat),
212218 ψ₀ = isnothing (ψ₀) ? waterpotential (swrc (f), θtot; θsat, θres, swrc_kwargs... ) : ψ₀,
213219 g = f. g,
@@ -222,12 +228,17 @@ function (f::DallAmicoSalt)(
222228 # water matric potential
223229 ψ = ψ₀ + Lf / (ρw * g * Tstar) * (T - Tstar) * heaviside (Tstar- T),
224230 ψ = IfElse. ifelse (ψ < zero (ψ), ψ, zero (ψ));
225- # van Genuchten evaulation to get θw
226- θw = f . swrc (ψ; θres, θsat, swrc_kwargs ... )
227- if return_all
231+ # output is a compile-time constant so will be compiled away
232+ if output == :all || output == true # allow 'true' for backwards compatibility w/ 0.4
233+ θw = f . swrc (ψ; θsat, θres, swrc_kwargs ... )
228234 return (; θw, ψ, Tstar)
229- else
235+ elseif output == :θw || output == false # allow 'false' for backwards compatibility w/ 0.4
236+ θw = f. swrc (ψ; θsat, θres, swrc_kwargs... )
230237 return θw
238+ elseif output == :ψ
239+ return ψ
240+ elseif output == :Tstar
241+ return Tstar
231242 end
232243 end
233244end
0 commit comments