@@ -7,59 +7,35 @@ import ClimaCore.Spaces as Spaces
7
7
import ClimaCore. Fields as Fields
8
8
import ClimaCore. Operators as Operators
9
9
10
- # ####
11
- # #### No subsidence
12
- # ####
13
-
14
- subsidence_tendency! (Yₜ, Y, p, t, :: Nothing ) = nothing
15
-
16
10
# ####
17
11
# #### Subsidence
18
12
# ####
19
13
20
- subsidence! (ᶜρχₜ, ᶜρ, ᶠu³, ᶜχ, :: Val{:none} ) =
21
- @. ᶜρχₜ -= ᶜρ * (ᶜsubdivᵥ (ᶠu³ * ᶠinterp (ᶜχ)) - ᶜχ * ᶜsubdivᵥ (ᶠu³))
22
- subsidence! (ᶜρχₜ, ᶜρ, ᶠu³, ᶜχ, :: Val{:first_order} ) =
23
- @. ᶜρχₜ -= ᶜρ * (ᶜsubdivᵥ (ᶠupwind1 (ᶠu³, ᶜχ)) - ᶜχ * ᶜsubdivᵥ (ᶠu³))
24
- subsidence! (ᶜρχₜ, ᶜρ, ᶠu³, ᶜχ, :: Val{:third_order} ) =
25
- @. ᶜρχₜ -= ᶜρ * (ᶜsubdivᵥ (ᶠupwind3 (ᶠu³, ᶜχ)) - ᶜχ * ᶜsubdivᵥ (ᶠu³))
26
-
27
- function subsidence_tendency! (Yₜ, Y, p, t, :: Subsidence )
28
- (; moisture_model) = p. atmos
29
- subsidence_profile = p. atmos. subsidence. prof
30
- (; ᶜh_tot, ᶜspecific) = p. precomputed
31
-
32
- ᶠz = Fields. coordinate_field (axes (Y. f)). z
33
- ᶠlg = Fields. local_geometry_field (Y. f)
34
- ᶠsubsidence³ = p. scratch. ᶠtemp_CT3
35
- @. ᶠsubsidence³ =
36
- subsidence_profile (ᶠz) * CT3 (unit_basis_vector_data (CT3, ᶠlg))
37
-
38
- # LS Subsidence
39
- subsidence! (Yₜ. c. ρe_tot, Y. c. ρ, ᶠsubsidence³, ᶜh_tot, Val {:first_order} ())
40
- subsidence! (
41
- Yₜ. c. ρq_tot,
42
- Y. c. ρ,
43
- ᶠsubsidence³,
44
- ᶜspecific. q_tot,
45
- Val {:first_order} (),
46
- )
47
- if moisture_model isa NonEquilMoistModel
48
- subsidence! (
49
- Yₜ. c. ρq_liq,
50
- Y. c. ρ,
51
- ᶠsubsidence³,
52
- ᶜspecific. q_liq,
53
- Val {:first_order} (),
54
- )
55
- subsidence! (
56
- Yₜ. c. ρq_ice,
57
- Y. c. ρ,
58
- ᶠsubsidence³,
59
- ᶜspecific. q_ice,
60
- Val {:first_order} (),
61
- )
62
- end
14
+ subsidence_tracer (:: Val{:h_tot} , thermo_params, ts, ρ, ρe_tot) =
15
+ TD. total_specific_enthalpy (thermo_params, ts, ρe_tot / ρ)
16
+ subsidence_tracer (:: Val{:q_tot} , thermo_params, ts, ρ, ρe_tot) =
17
+ TD. total_specific_humidity (thermo_params, ts)
18
+ subsidence_tracer (:: Val{:q_liq} , thermo_params, ts, ρ, ρe_tot) =
19
+ TD. liquid_specific_humidity (thermo_params, ts)
20
+ subsidence_tracer (:: Val{:q_ice} , thermo_params, ts, ρ, ρe_tot) =
21
+ TD. ice_specific_humidity (thermo_params, ts)
22
+
23
+ function subsidence_tendency (χname, subsidence, thermo_params, ᶜts, ᶜρ, ᶜρe_tot)
24
+ subsidence isa Nothing && return NullBroadcasted ()
25
+ ᶠu³ = ᶠsubsidence³ (axes (ᶜρ), subsidence)
26
+ ᶜχ = @lazy @. subsidence_tracer (χname, thermo_params, ᶜts, ᶜρ, ᶜρe_tot)
27
+ return subsidence_tendency (ᶜρ, ᶜχ, ᶠu³, Val {:first_order} ())
28
+ end
63
29
64
- return nothing
30
+ function ᶠsubsidence³ (ᶠspace, subsidence:: Subsidence )
31
+ ᶠz = Fields. coordinate_field (ᶠspace). z
32
+ ᶠlg = Fields. local_geometry_field (ᶠspace)
33
+ (; prof) = subsidence
34
+ return @lazy @. prof (ᶠz) * CT3 (unit_basis_vector_data (CT3, ᶠlg))
65
35
end
36
+ subsidence_tendency (ᶜρ, ᶜχ, ᶠu³, :: Val{:none} ) =
37
+ @lazy @. - ᶜρ * (ᶜsubdivᵥ (ᶠu³ * ᶠinterp (ᶜχ)) - ᶜχ * ᶜsubdivᵥ (ᶠu³))
38
+ subsidence_tendency (ᶜρ, ᶜχ, ᶠu³, :: Val{:first_order} ) =
39
+ @lazy @. - ᶜρ * (ᶜsubdivᵥ (ᶠupwind1 (ᶠu³, ᶜχ)) - ᶜχ * ᶜsubdivᵥ (ᶠu³))
40
+ subsidence_tendency (ᶜρ, ᶜχ, ᶠu³, :: Val{:third_order} ) =
41
+ @lazy @. - ᶜρ * (ᶜsubdivᵥ (ᶠupwind3 (ᶠu³, ᶜχ)) - ᶜχ * ᶜsubdivᵥ (ᶠu³))
0 commit comments