@@ -61,7 +61,7 @@ function external_forcing_tendency!(Yₜ, Y, p, t, colidx, ::GCMForcing)
6161 # horizontal advection, vertical fluctuation, nudging, subsidence (need to add),
6262 (; params) = p
6363 thermo_params = CAP. thermodynamics_params (params)
64- (; ᶜspecific, ᶜts) = p. precomputed
64+ (; ᶜspecific, ᶜts, ᶜh_tot ) = p. precomputed
6565 (;
6666 ᶜdTdt_fluc,
6767 ᶜdqtdt_fluc,
@@ -105,6 +105,7 @@ function external_forcing_tendency!(Yₜ, Y, p, t, colidx, ::GCMForcing)
105105 Lv_0 = TD. Parameters. LH_v0 (thermo_params)
106106 cv_v = TD. Parameters. cv_v (thermo_params)
107107 R_v = TD. Parameters. R_v (thermo_params)
108+ # total energy
108109 @. Yₜ. c. ρe_tot[colidx] +=
109110 Y. c. ρ[colidx] * (
110111 TD. cv_m (thermo_params, ᶜts[colidx]) * ᶜdTdt_sum[colidx] +
@@ -113,7 +114,27 @@ function external_forcing_tendency!(Yₜ, Y, p, t, colidx, ::GCMForcing)
113114 Lv_0 - R_v * T_0
114115 ) * ᶜdqtdt_sum[colidx]
115116 )
117+ # total specific humidity
116118 @. Yₜ. c. ρq_tot[colidx] += Y. c. ρ[colidx] * ᶜdqtdt_sum[colidx]
117119
120+ # # subsidence -->
121+ tom (f) = Spaces. level (f, Spaces. nlevels (axes (f))) # get value at top of the model
122+ wvec = Geometry. WVector
123+ RBh = Operators. RightBiasedC2F (;
124+ top = Operators. SetValue (tom (ᶜh_tot[colidx])),
125+ )
126+ RBq = Operators. RightBiasedC2F (;
127+ top = Operators. SetValue (tom (ᶜspecific. q_tot[colidx])),
128+ )
129+ @. Yₜ. c. ρe_tot[colidx] -=
130+ Y. c. ρ[colidx] *
131+ ᶜls_subsidence[colidx] *
132+ ᶜdivᵥ (wvec (RBh (ᶜh_tot[colidx]))) # ρ⋅w⋅∇h_tot
133+ @. Yₜ. c. ρq_tot[colidx] -=
134+ Y. c. ρ[colidx] *
135+ ᶜls_subsidence[colidx] *
136+ ᶜdivᵥ (wvec (RBq (ᶜspecific. q_tot[colidx]))) # ρ⋅w⋅∇q_tot
137+ # <-- subsidence
138+
118139 return nothing
119140end
0 commit comments