diff --git a/test/Atmos/EDMF/closures/mixing_length.jl b/test/Atmos/EDMF/closures/mixing_length.jl index 6444a92eddf..fc0cddb904a 100644 --- a/test/Atmos/EDMF/closures/mixing_length.jl +++ b/test/Atmos/EDMF/closures/mixing_length.jl @@ -65,7 +65,7 @@ function mixing_length( # compute L1 Nˢ_fact = (sign(Nˢ_eff - eps(FT)) + 1) / 2 - coeff = min(sqrt(ml.c_b * tke_en) / Nˢ_eff, ml.max_length) + coeff = min(ml.c_b * sqrt(tke_en) / Nˢ_eff, ml.max_length) L_Nˢ = coeff * Nˢ_fact + ml.max_length * (FT(1) - Nˢ_fact) # compute L2 - law of the wall @@ -80,7 +80,10 @@ function mixing_length( tke_surf = surf_vals.tke L_W = ml.κ * z / (sqrt(tke_surf) * ml.c_m / ustar / ustar) stab_fac = -(sign(obukhov_length) - 1) / 2 - L_W *= stab_fac * min((FT(1) - ml.a2 * z / obukhov_length)^ml.a1, 1 / ml.κ) + L_W *= ( + stab_fac * min((FT(1) - ml.a2 * z / obukhov_length)^ml.a1, 1 / ml.κ) + + (FT(1) - stab_fac) + ) # compute L3 - entrainment detrainment sources # Production/destruction terms @@ -97,7 +100,7 @@ function mixing_length( end, ) - c_neg = ml.c_d * tke_en * sqrt(abs(tke_en)) + c_neg = ml.c_d * tke_en * sqrt(tke_en) if abs(a) > ml.random_minval && 4 * a * c_neg > -b^2 l_entdet = max(-b / FT(2) / a + sqrt(b^2 + 4 * a * c_neg) / 2 / a, FT(0)) diff --git a/test/Atmos/EDMF/edmf_kernels.jl b/test/Atmos/EDMF/edmf_kernels.jl index 224642145ac..ac678043399 100644 --- a/test/Atmos/EDMF/edmf_kernels.jl +++ b/test/Atmos/EDMF/edmf_kernels.jl @@ -347,9 +347,8 @@ function compute_gradient_argument!( en_tf.q_tot_cv = enforce_positivity(en.ρaq_tot_cv) / (env.a * gm.ρ) en_tf.θ_liq_q_tot_cv = en.ρaθ_liq_q_tot_cv / (env.a * gm.ρ) - # TODO: is this supposed to be grabbed from grid mean? - en_tf.θv = virtual_pottemp(ts.gm) - e_kin = FT(1 // 2) * ((gm.ρu[1] * ρ_inv)^2 + (gm.ρu[2] * ρ_inv)^2 + env.w^2) + en_tf.θv = virtual_pottemp(ts.en) + e_kin = FT(1 // 2) * ((gm.ρu[1] * ρ_inv)^2 + (gm.ρu[2] * ρ_inv)^2 + env.w^2) # TBD: Check en_tf.e = total_energy(e_kin, _grav * z, ts.en) end; @@ -390,7 +389,7 @@ function compute_gradient_flux!( en_dif.∇θv = en_∇tf.θv en_dif.∇e = en_∇tf.e - tc_dif.S² = ∇transform.u[3, 1]^2 + ∇transform.u[3, 2]^2 + en_dif.∇w[3]^2 + tc_dif.S² = ∇transform.u[3, 1]^2 + ∇transform.u[3, 2]^2 + en_dif.∇w[3]^2 # ∇transform.u is Jacobian.T end; struct TurbconvSource <: AbstractSource end @@ -548,18 +547,22 @@ function atmos_source!( # production from mean gradient and Dissipation en_src.ρatke += ρa₀ * K_m * Shear² # tke Shear source - en_src.ρatke += -ρa₀ * K_h * ∂b∂z_env # tke Bouyancy source + en_src.ρatke += -ρa₀ * K_h * ∂b∂z_env # tke Buoyancy source en_src.ρatke += -ρa₀ * Diss₀ * tke_en # tke Dissipation en_src.ρaθ_liq_cv += - ρa₀ * - (K_h * en_dif.∇θ_liq[3] * en_dif.∇θ_liq[3] - Diss₀ * en.ρaθ_liq_cv) + ρa₀ * ( + FT(2) * K_h * en_dif.∇θ_liq[3] * en_dif.∇θ_liq[3] - + Diss₀ * en.ρaθ_liq_cv + ) en_src.ρaq_tot_cv += - ρa₀ * - (K_h * en_dif.∇q_tot[3] * en_dif.∇q_tot[3] - Diss₀ * en.ρaq_tot_cv) + ρa₀ * ( + FT(2) * K_h * en_dif.∇q_tot[3] * en_dif.∇q_tot[3] - + Diss₀ * en.ρaq_tot_cv + ) en_src.ρaθ_liq_q_tot_cv += ρa₀ * ( - K_h * en_dif.∇θ_liq[3] * en_dif.∇q_tot[3] - + FT(2) * K_h * en_dif.∇θ_liq[3] * en_dif.∇q_tot[3] - Diss₀ * en.ρaθ_liq_q_tot_cv ) # covariance microphysics sources should be applied here @@ -645,7 +648,7 @@ function flux(::Advect{en_ρaθ_liq_q_tot_cv}, m, state, aux, t, ts, direction) return en.ρaθ_liq_q_tot_cv * env.w * ẑ end -# # in the EDMF first order (advective) fluxes exist only in the grid mean (if is nonzero) and the uprdafts +# # in the EDMF first order (advective) fluxes exist only in the grid mean (if is nonzero) and the updrafts function flux_first_order!( turbconv::EDMF{FT}, m::AtmosModel{FT}, @@ -750,7 +753,6 @@ function flux_second_order!( massflux_e = sum( vuntuple(N_up) do i up[i].ρa * - ρ_inv * (gm.ρe * ρ_inv - e_tot_up[i]) * (gm.ρu[3] * ρ_inv - up[i].ρaw / ρa_up[i]) end, @@ -759,7 +761,6 @@ function flux_second_order!( massflux_q_tot = sum( vuntuple(N_up) do i up[i].ρa * - ρ_inv * (ρq_tot * ρ_inv - up[i].ρaq_tot / up[i].ρa) * (gm.ρu[3] * ρ_inv - up[i].ρaw / ρa_up[i]) end, @@ -768,7 +769,6 @@ function flux_second_order!( massflux_w = sum( vuntuple(N_up) do i up[i].ρa * - ρ_inv * (gm.ρu[3] * ρ_inv - up[i].ρaw / up[i].ρa) * (gm.ρu[3] * ρ_inv - up[i].ρaw / ρa_up[i]) end, diff --git a/test/Atmos/EDMF/report_mse.jl b/test/Atmos/EDMF/report_mse.jl index 613343e5c5d..6af4b778323 100644 --- a/test/Atmos/EDMF/report_mse.jl +++ b/test/Atmos/EDMF/report_mse.jl @@ -16,13 +16,13 @@ best_mse[:Bomex]["ρ"] = 3.4943021267397123e-02 best_mse[:Bomex]["ρu[1]"] = 3.0714039084256679e+03 best_mse[:Bomex]["ρu[2]"] = 1.3375796498101822e-03 best_mse[:Bomex]["moisture.ρq_tot"] = 4.8463531712319707e-02 -best_mse[:Bomex]["turbconv.environment.ρatke"] = 6.6626829120765967e+02 -best_mse[:Bomex]["turbconv.environment.ρaθ_liq_cv"] = 8.5667200586224638e+01 -best_mse[:Bomex]["turbconv.environment.ρaq_tot_cv"] = 1.6455724508026515e+02 -best_mse[:Bomex]["turbconv.updraft[1].ρa"] = 7.9577347148736081e+01 -best_mse[:Bomex]["turbconv.updraft[1].ρaw"] = 8.4352020356445540e-02 -best_mse[:Bomex]["turbconv.updraft[1].ρaθ_liq"] = 9.0101465706333848e+00 -best_mse[:Bomex]["turbconv.updraft[1].ρaq_tot"] = 1.0768121066483779e+01 +best_mse[:Bomex]["turbconv.environment.ρatke"] = 6.6626422991098286e+02 +best_mse[:Bomex]["turbconv.environment.ρaθ_liq_cv"] = 8.5667099987715503e+01 +best_mse[:Bomex]["turbconv.environment.ρaq_tot_cv"] = 1.6439116552012851e+02 +best_mse[:Bomex]["turbconv.updraft[1].ρa"] = 7.9577348413012515e+01 +best_mse[:Bomex]["turbconv.updraft[1].ρaw"] = 8.4352188057391225e-02 +best_mse[:Bomex]["turbconv.updraft[1].ρaθ_liq"] = 9.0101464252959325e+00 +best_mse[:Bomex]["turbconv.updraft[1].ρaq_tot"] = 1.0768120864370509e+01 #! format: on sufficient_mse(computed_mse, best_mse) = computed_mse <= best_mse + eps()