Skip to content

Commit 1a40a8c

Browse files
committed
Fix bg_gradient lh bug
1 parent d68ea75 commit 1a40a8c

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/parameterized_tendencies/microphysics/microphysics_wrappers.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ end
3232
function moisture_fixer(q, qᵥ, dt)
3333
FT = eltype(q)
3434
return triangle_inequality_limiter(
35-
-min(FT(0), q / dt),
36-
limit(qᵥ, dt, 5),
35+
-min(FT(0), q / FT(dt)),
36+
limit(qᵥ, FT(dt), 5),
3737
FT(0),
3838
)
3939
end

src/prognostic_equations/eddy_diffusion_closures.jl

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,20 @@ function buoyancy_gradients(
152152
error("Unsupported moisture model")
153153
end
154154

155+
t_sat = get_t_sat(thermo_params, bg_model)
155156
phase_part = TD.PhasePartition(thermo_params, ts_sat)
156-
lh = TD.latent_heat_liq_ice(thermo_params, phase_part)
157+
lh =
158+
(
159+
get_ql_sat(thermo_params, bg_model) *
160+
TD.latent_heat_vapor(thermo_params, t_sat) +
161+
get_qi_sat(thermo_params, bg_model) *
162+
TD.latent_heat_sublim(thermo_params, t_sat)
163+
) /
164+
(
165+
get_ql_sat(thermo_params, bg_model) +
166+
get_qi_sat(thermo_params, bg_model) + sqrt(eps(FT))
167+
)
157168
cp_m = TD.cp_m(thermo_params, ts_sat)
158-
t_sat = get_t_sat(thermo_params, bg_model)
159169
qv_sat = get_qv_sat(thermo_params, bg_model)
160170
∂b∂θli_sat = (
161171
∂b∂θv *
@@ -257,8 +267,8 @@ end
257267
Calculates the surface flux of TKE, a C3 vector used by
258268
ClimaAtmos operator boundary conditions.
259269
260-
The flux magnitude is modeled as
261-
c_k * ρa_sfc * ustar^3`,
270+
The flux magnitude is modeled as
271+
c_k * ρa_sfc * ustar^3`,
262272
directed along the surface upward normal.
263273
264274
Details:
@@ -323,12 +333,12 @@ where:
323333
- `scale_blending_method`: The method to use for blending physical scales.
324334
325335
Point-wise calculation of the turbulent mixing length, limited by physical constraints (wall distance,
326-
TKE balance, stability) and grid resolution. Based on
327-
Lopez‐Gomez, I., Cohen, Y., He, J., Jaruga, A., & Schneider, T. (2020).
328-
A generalized mixing length closure for eddy‐diffusivity mass‐flux schemes of turbulence and convection.
336+
TKE balance, stability) and grid resolution. Based on
337+
Lopez‐Gomez, I., Cohen, Y., He, J., Jaruga, A., & Schneider, T. (2020).
338+
A generalized mixing length closure for eddy‐diffusivity mass‐flux schemes of turbulence and convection.
329339
Journal of Advances in Modeling Earth Systems, 12, e2020MS002161. https://doi.org/ 10.1029/2020MS002161
330340
331-
Returns a `MixingLength{FT}` struct containing the final blended mixing length (`master`)
341+
Returns a `MixingLength{FT}` struct containing the final blended mixing length (`master`)
332342
and its constituent physical scales.
333343
"""
334344

@@ -370,8 +380,8 @@ function mixing_length_lopez_gomez_2020(
370380
# Ensure l_z is non-negative when ᶜz is numerically smaller than z_sfc.
371381
l_z = max(l_z, FT(0))
372382

373-
# l_W: Wall-constrained length scale (near-surface limit, to match
374-
# Monin-Obukhov Similarity Theory in the surface layer, with Businger-Dyer
383+
# l_W: Wall-constrained length scale (near-surface limit, to match
384+
# Monin-Obukhov Similarity Theory in the surface layer, with Businger-Dyer
375385
# type stability functions)
376386
tke_sfc_safe = max(sfc_tke, eps_FT)
377387
ustar_sq_safe = max(ustar * ustar, eps_FT) # ustar^2 may vanish in certain LES setups

0 commit comments

Comments
 (0)