Skip to content

Commit a832aea

Browse files
committed
use cloud fraction in buoyancy gradient
1 parent 767ab99 commit a832aea

File tree

7 files changed

+35
-33
lines changed

7 files changed

+35
-33
lines changed

src/cache/diagnostic_edmf_precomputed_quantities.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,8 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
13671367
moisture_model,
13681368
ᶜts,
13691369
C3,
1370-
p.precomputed.ᶜgradᵥ_θ_virt, # ∂θv∂z_unsat
1371-
p.precomputed.ᶜgradᵥ_q_tot, # ∂qt∂z_sat
1372-
p.precomputed.ᶜgradᵥ_θ_liq_ice, # ∂θl∂z_sat
1370+
p.precomputed.ᶜgradᵥ_q_tot,
1371+
p.precomputed.ᶜgradᵥ_θ_liq_ice,
13731372
ᶜlg,
13741373
)
13751374

src/cache/precomputed_quantities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ function precomputed_quantities(Y, atmos)
8585
TST = thermo_state_type(atmos.moisture_model, FT)
8686
SCT = SurfaceConditions.surface_conditions_type(atmos, FT)
8787
cspace = axes(Y.c)
88-
fspace = axes(Y.f)
8988
n = n_mass_flux_subdomains(atmos.turbconv_model)
9089
n_prog = n_prognostic_mass_flux_subdomains(atmos.turbconv_model)
9190
@assert !(atmos.turbconv_model isa PrognosticEDMFX) || n_prog == 1
@@ -98,6 +97,7 @@ function precomputed_quantities(Y, atmos)
9897
)
9998
cloud_diagnostics_tuple =
10099
similar(Y.c, @NamedTuple{cf::FT, q_liq::FT, q_ice::FT})
100+
@. cloud_diagnostics_tuple.cf = FT(0)
101101
surface_precip_fluxes = (;
102102
surface_rain_flux = zeros(axes(Fields.level(Y.f, half))),
103103
surface_snow_flux = zeros(axes(Fields.level(Y.f, half))),

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,20 +421,20 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_explicit_clos
421421
)
422422
end
423423

424-
(; ᶜgradᵥ_θ_virt, ᶜgradᵥ_q_tot, ᶜgradᵥ_θ_liq_ice) = p.precomputed
424+
(; ᶜgradᵥ_θ_virt, ᶜgradᵥ_q_tot, ᶜgradᵥ_θ_liq_ice, cloud_diagnostics_tuple) = p.precomputed
425425
# First order approximation: Use environmental mean fields.
426-
@. ᶜgradᵥ_θ_virt = ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts))) # ∂θv∂z_unsat
426+
@. ᶜgradᵥ_θ_virt = ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts)))
427427
ᶜq_tot = @. lazy(specific(Y.c.ρq_tot, Y.c.ρ))
428-
@. ᶜgradᵥ_q_tot = ᶜgradᵥ(ᶠinterp(ᶜq_tot)) # ∂qt∂z_sat
428+
@. ᶜgradᵥ_q_tot = ᶜgradᵥ(ᶠinterp(ᶜq_tot))
429429
@. ᶜgradᵥ_θ_liq_ice =
430-
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts))) # ∂θl∂z_sat
430+
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts)))
431431
@. ᶜlinear_buoygrad = buoyancy_gradients( # TODO - do we need to modify buoyancy gradients based on NonEq + 1M tracers?
432432
BuoyGradMean(),
433433
thermo_params,
434434
moisture_model,
435435
ᶜts,
436+
cloud_diagnostics_tuple.cf,
436437
C3,
437-
ᶜgradᵥ_θ_virt,
438438
ᶜgradᵥ_q_tot,
439439
ᶜgradᵥ_θ_liq_ice,
440440
ᶜlg,

src/prognostic_equations/eddy_diffusion_closures.jl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import ClimaCore.Fields as Fields
1515
# Arguments for the first method (most commonly called):
1616
ts::TD.ThermodynamicState,
1717
::Type{C3}, # Covariant3 vector type, for projecting gradients
18-
∂θv∂z_unsat::AbstractField, # Vertical gradient of virtual potential temperature in unsaturated part
1918
∂qt∂z_sat::AbstractField, # Vertical gradient of total specific humidity in saturated part
2019
∂θli∂z_sat::AbstractField, # Vertical gradient of liquid-ice potential temperature in saturated part
2120
local_geometry::Fields.LocalGeometry,
@@ -50,7 +49,6 @@ Arguments:
5049
- `moisture_model`: Moisture model (e.g., `EquilMoistModel`, `NonEquilMoistModel`).
5150
- `ts`: Center-level thermodynamic state of the environment.
5251
- `C3`: The `ClimaCore.Geometry.Covariant3Vector` type, used for projecting input vertical gradients.
53-
- `∂θv∂z_unsat`: Field of vertical gradients of virtual potential temperature in the unsaturated part.
5452
- `∂qt∂z_sat`: Field of vertical gradients of total specific humidity in the saturated part.
5553
- `∂θli∂z_sat`: Field of vertical gradients of liquid-ice potential temperature in the saturated part.
5654
- `local_geometry`: Field of local geometry at cell centers, used for gradient projection.
@@ -66,8 +64,8 @@ function buoyancy_gradients(
6664
thermo_params,
6765
moisture_model,
6866
ts,
67+
cf,
6968
::Type{C3},
70-
∂θv∂z_unsat,
7169
∂qt∂z_sat,
7270
∂θli∂z_sat,
7371
ᶜlg,
@@ -78,9 +76,9 @@ function buoyancy_gradients(
7876
moisture_model,
7977
EnvBuoyGradVars(
8078
ts,
79+
cf,
8180
projected_vector_buoy_grad_vars(
8281
C3,
83-
∂θv∂z_unsat,
8482
∂qt∂z_sat,
8583
∂θli∂z_sat,
8684
ᶜlg,
@@ -99,13 +97,10 @@ function buoyancy_gradients(
9997

10098
g = TDP.grav(thermo_params)
10199
Rv_over_Rd = TDP.Rv_over_Rd(thermo_params)
102-
R_d = TDP.R_d(thermo_params)
103100
R_v = TDP.R_v(thermo_params)
104101

105102
ts = bg_model.ts
106-
p = TD.air_pressure(thermo_params, ts)
107-
Π = TD.exner_given_pressure(thermo_params, p)
108-
∂b∂θv = g * (R_d * TD.air_density(thermo_params, ts) / p) * Π
103+
∂b∂θv = g / TD.virtual_pottemp(thermo_params, ts)
109104

110105
t_sat = TD.air_temperature(thermo_params, ts)
111106
λ = TD.liquid_fraction(thermo_params, ts)
@@ -115,20 +110,25 @@ function buoyancy_gradients(
115110
cp_m = TD.cp_m(thermo_params, ts)
116111
qv_sat = TD.vapor_specific_humidity(thermo_params, ts)
117112
qt_sat = TD.total_specific_humidity(thermo_params, ts)
113+
θ = TD.dry_pottemp(thermo_params, ts)
114+
∂b∂θli_unsat = ∂b∂θv * (1 + (Rv_over_Rd - 1) * qt_sat)
115+
∂b∂qt_unsat = ∂b∂θv * (Rv_over_Rd - 1) * θ
118116
∂b∂θli_sat = (
119117
∂b∂θv *
120118
(1 + Rv_over_Rd * (1 + lh / R_v / t_sat) * qv_sat - qt_sat) /
121-
(1 + lh * lh / cp_m / R_v / t_sat / t_sat * qv_sat)
119+
(1 + lh^2 / cp_m / R_v / t_sat^2 * qv_sat)
122120
)
123121
∂b∂qt_sat =
124122
(lh / cp_m / t_sat * ∂b∂θli_sat - ∂b∂θv) *
125-
TD.dry_pottemp(thermo_params, ts)
123+
θ
126124

127125
∂b∂z = buoyancy_gradient_chain_rule(
128126
ebgc,
129127
bg_model,
130128
thermo_params,
131129
∂b∂θv,
130+
∂b∂θli_unsat,
131+
∂b∂qt_unsat,
132132
∂b∂θli_sat,
133133
∂b∂qt_sat,
134134
)
@@ -177,17 +177,21 @@ function buoyancy_gradient_chain_rule(
177177
bg_model::EnvBuoyGradVars,
178178
thermo_params,
179179
∂b∂θv,
180+
∂b∂θli_unsat,
181+
∂b∂qt_unsat,
180182
∂b∂θli_sat,
181183
∂b∂qt_sat,
182184
)
183-
en_cld_frac = ifelse(TD.has_condensate(thermo_params, bg_model.ts), 1, 0)
185+
#en_cld_frac = ifelse(TD.has_condensate(thermo_params, bg_model.ts), 1, 0)
184186

187+
∂b∂z_θli_unsat = ∂b∂θli_unsat * bg_model.∂θli∂z_sat
188+
∂b∂z_qt_unsat = ∂b∂qt_unsat * bg_model.∂qt∂z_sat
189+
∂b∂z_unsat = ∂b∂z_θli_unsat + ∂b∂z_qt_unsat
185190
∂b∂z_θl_sat = ∂b∂θli_sat * bg_model.∂θli∂z_sat
186191
∂b∂z_qt_sat = ∂b∂qt_sat * bg_model.∂qt∂z_sat
187192
∂b∂z_sat = ∂b∂z_θl_sat + ∂b∂z_qt_sat
188-
∂b∂z_unsat = ∂b∂θv * bg_model.∂θv∂z_unsat
189193

190-
∂b∂z = (1 - en_cld_frac) * ∂b∂z_unsat + en_cld_frac * ∂b∂z_sat
194+
∂b∂z = (1 - bg_model.cf) * ∂b∂z_unsat + bg_model.cf * ∂b∂z_sat
191195

192196
return ∂b∂z
193197
end

src/prognostic_equations/gm_sgs_closures.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ NVTX.@annotate function compute_gm_mixing_length(Y, p)
7575
p.atmos.moisture_model,
7676
ᶜts,
7777
C3,
78-
p.precomputed.ᶜgradᵥ_θ_virt, # ∂θv∂z_unsat
79-
p.precomputed.ᶜgradᵥ_q_tot, # ∂qt∂z_sat
80-
p.precomputed.ᶜgradᵥ_θ_liq_ice, # ∂θl∂z_sat
78+
p.precomputed.ᶜgradᵥ_q_tot,
79+
p.precomputed.ᶜgradᵥ_θ_liq_ice,
8180
ᶜlg,
8281
)
8382

src/solver/types.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,18 @@ Variables used in the environmental buoyancy gradient computation.
376376
"""
377377
Base.@kwdef struct EnvBuoyGradVars{FT, TS}
378378
ts::TS
379-
∂θv∂z_unsat::FT
379+
cf::FT
380380
∂qt∂z_sat::FT
381381
∂θli∂z_sat::FT
382382
end
383383

384384
function EnvBuoyGradVars(
385385
ts::TD.ThermodynamicState,
386-
∂θv∂z_unsat_∂qt∂z_sat_∂θli∂z_sat,
386+
cf,
387+
∂qt∂z_sat_∂θli∂z_sat,
387388
)
388-
(; ∂θv∂z_unsat, ∂qt∂z_sat, ∂θli∂z_sat) = ∂θv∂z_unsat_∂qt∂z_sat_∂θli∂z_sat
389-
return EnvBuoyGradVars(ts, ∂θv∂z_unsat, ∂qt∂z_sat, ∂θli∂z_sat)
389+
(; ∂qt∂z_sat, ∂θli∂z_sat) = ∂qt∂z_sat_∂θli∂z_sat
390+
return EnvBuoyGradVars(ts, cf, ∂qt∂z_sat, ∂θli∂z_sat)
390391
end
391392

392393
Base.eltype(::EnvBuoyGradVars{FT}) where {FT} = FT

src/utils/utilities.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,11 @@ The type should correspond to a vector with only one component, i.e., a basis ve
279279
projected_vector_data(::Type{V}, vector, local_geometry) where {V} =
280280
V(vector, local_geometry)[1] / unit_basis_vector_data(V, local_geometry)
281281

282-
function projected_vector_buoy_grad_vars(::Type{V}, v1, v2, v3, lg) where {V}
282+
function projected_vector_buoy_grad_vars(::Type{V}, v1, v2, lg) where {V}
283283
ubvd = unit_basis_vector_data(V, lg)
284284
return (;
285-
∂θv∂z_unsat = V(v1, lg)[1] / ubvd,
286-
∂qt∂z_sat = V(v2, lg)[1] / ubvd,
287-
∂θli∂z_sat = V(v3, lg)[1] / ubvd,
285+
∂qt∂z_sat = V(v1, lg)[1] / ubvd,
286+
∂θli∂z_sat = V(v2, lg)[1] / ubvd,
288287
)
289288
end
290289

0 commit comments

Comments
 (0)