@@ -4,61 +4,29 @@ import ClimaComms
4
4
ClimaComms. @import_required_backends
5
5
import ClimaCore: Fields, Domains, Geometry, Meshes, Spaces
6
6
7
- Base . @kwdef struct LandParameters{FT}
7
+ struct LandParameters{FT}
8
8
ρ_cloud_ice:: FT
9
- ρ_cloud_liq:: FT
10
- LH_f0:: FT
11
- T_freeze:: FT
12
- grav:: FT
13
9
end
14
10
Base. broadcastable (x:: LandParameters ) = tuple (x)
15
11
16
- ρ_cloud_ice (x) = x. ρ_cloud_ice
17
- ρ_cloud_liq (x) = x. ρ_cloud_liq
18
- LH_f0 (x) = x. LH_f0
19
- T_freeze (x) = x. T_freeze
20
- grav (x) = x. grav
21
-
22
12
struct vanGenuchten{FT}
23
- " The inverse of the air entry potential (1/m)"
24
13
α:: FT
25
- " The van Genuchten pore-size distribution index (unitless)"
26
- n:: FT
27
- " The van Genuchten parameter m = 1 - 1/n (unitless)"
28
- m:: FT
29
- " A derived parameter: the critical saturation at which capillary flow no longer replenishes the surface"
30
- S_c:: FT
31
- function vanGenuchten {FT} (; α:: FT , n:: FT ) where {FT}
32
- m = 1 - 1 / n
33
- S_c = (1 + ((n - 1 ) / n)^ (1 - 2 * n))^ (- m)
34
- return new {FT} (α, n, m, S_c)
35
- end
36
14
end
37
15
Base. broadcastable (x:: vanGenuchten ) = tuple (x)
38
16
39
- function matric_potential (cm:: vanGenuchten{FT} , S:: FT ) where {FT}
40
- (; α, m, n) = cm
41
- ψ = - ((S^ (- FT (1 ) / m) - FT (1 )) * α^ (- n))^ (FT (1 ) / n)
42
- return ψ
43
- end
44
-
45
17
function phase_change_source (
46
18
θ_l:: FT ,
47
- # θ_i::FT,
48
- # T::FT,
49
- # τ::FT,
50
- # ν::FT,
51
- # θ_r::FT,
52
19
hydrology_cm:: C ,
53
20
earth_param_set:: EP ,
54
21
) where {FT, EP, C}
55
- _ρ_i = FT (ρ_cloud_ice (earth_param_set))
56
- # ψw0 = matric_potential(hydrology_cm, _ρ_i)
57
- return (θ_l - _ρ_i)
58
- # return (θ_l - _ρ_i) / τ
22
+ return nothing
59
23
end
60
24
61
- function make_space (:: Type{FT} ; zlim = (FT (- 1 ), FT (0 )), nelements = 200 ) where {FT}
25
+ function make_space (
26
+ :: Type{FT} ;
27
+ zlim = (FT (- 1 ), FT (0 )),
28
+ nelements = 200 ,
29
+ ) where {FT}
62
30
boundary_names = (:bottom , :top )
63
31
column = Domains. IntervalDomain (
64
32
Geometry. ZPoint {FT} (zlim[1 ]),
@@ -70,32 +38,27 @@ function make_space(::Type{FT}; zlim = (FT(-1), FT(0)), nelements = 200) where {
70
38
return subsurface_space
71
39
end
72
40
73
- function call_func (θ_l, θ_i, T, tau, ν, θ_r, hydrology_cm, earth_param_set)
41
+ function call_func (θ_l, hydrology_cm, earth_param_set)
42
+ # function call_func(hydrology_cm, earth_param_set)
74
43
# This fails with dynamic function invocation when `LandParameters`
75
- # and `vanGenuchten` both use `tuple` for broadcasting, and it
76
- # passes when `Ref` is used for either `LandParameters` or `vanGenuchten` broadcasting
77
- # @. -phase_change_source(θ_l, θ_i, T, tau, ν, θ_r, hydrology_cm, earth_param_set)
78
- # @. -phase_change_source(θ_l, tau, hydrology_cm, earth_param_set)
79
- @. - phase_change_source (θ_l, hydrology_cm, earth_param_set)
44
+ # and `vanGenuchten` both use `tuple` for broadcasting,
45
+ # This passes when `Ref` is used for either `LandParameters` or `vanGenuchten` broadcasting
46
+ @. phase_change_source (θ_l, hydrology_cm, earth_param_set)
47
+
48
+ # These don't fail on GPU
49
+ # @. phase_change_source(hydrology_cm, earth_param_set)
50
+ # @. phase_change_source(θ_l, earth_param_set)
51
+ # @. phase_change_source(θ_l, hydrology_cm)
80
52
return nothing
81
53
end
82
54
function main (:: Type{FT} ) where {FT}
83
- Np = length (fieldtypes (LandParameters))
84
- earth_param_set = LandParameters {FT} (zeros (Np)... )
85
- ν = FT (0.495 )
86
- θ_r = FT (0.1 )
87
- hydrology_cm = vanGenuchten {FT} (; α = FT (2.6 ), n = FT (2.0 ))
55
+ earth_param_set = LandParameters {FT} (FT (0 ))
56
+ hydrology_cm = vanGenuchten {FT} (FT (2.6 ))
88
57
89
58
space_3d = make_space (FT; zlim = (FT (- 1 ), FT (0 )), nelements = 200 )
90
-
91
59
θ_l = Fields. ones (space_3d)
92
- θ_i = Fields. ones (space_3d)
93
- T = Fields. ones (space_3d)
94
- κ = Fields. ones (space_3d)
95
- tau = Fields. ones (space_3d)
96
-
97
- call_func (θ_l, θ_i, T, tau, ν, θ_r, hydrology_cm, earth_param_set)
98
60
61
+ call_func (θ_l, hydrology_cm, earth_param_set)
99
62
return nothing
100
63
end
101
64
0 commit comments