305305 obukhov_length,
306306 ᶜstrain_rate_norm,
307307 ᶜPr,
308- ᶜtke_exch,
309308 scale_blending_method,
310309)
311310
@@ -321,7 +320,6 @@ where:
321320- `obukhov_length`: Surface Monin-Obukhov length [m].
322321- `ᶜstrain_rate_norm`: Frobenius norm of strain rate tensor [1/s].
323322- `ᶜPr`: Turbulent Prandtl number [-].
324- - `ᶜtke_exch`: TKE exchange term [m^2/s^3].
325323- `scale_blending_method`: The method to use for blending physical scales.
326324
327325Point-wise calculation of the turbulent mixing length, limited by physical constraints (wall distance,
@@ -346,7 +344,6 @@ function mixing_length_lopez_gomez_2020(
346344 obukhov_length,
347345 ᶜstrain_rate_norm,
348346 ᶜPr,
349- ᶜtke_exch,
350347 scale_blending_method,
351348)
352349
@@ -451,43 +448,12 @@ function mixing_length_lopez_gomez_2020(
451448 # For the quadratic expression below, c_neg ≡ c_d · k^{3/2}.
452449 c_neg = c_d * tke_pos * sqrt_tke_pos
453450
454- l_TKE = FT (0 )
455451 # Solve for l_TKE in
456- # a_pd · l_TKE − c_neg / l_TKE + ᶜtke_exch = 0
457- # ⇒ a_pd · l_TKE² + ᶜtke_exch · l_TKE − c_neg = 0
452+ # a_pd · l_TKE − c_neg / l_TKE = 0
453+ # ⇒ a_pd · l_TKE² − c_neg = 0
458454 # yielding
459- # l_TKE = (−ᶜtke_exch ± √(ᶜtke_exch² + 4 a_pd c_neg)) / (2 a_pd).
460- if abs (a_pd) > eps_FT # If net of shear and buoyancy production (a_pd) is non-zero
461- discriminant = ᶜtke_exch * ᶜtke_exch + 4 * a_pd * c_neg
462- if discriminant >= FT (0 ) # Ensure real solution exists
463- # Select the physically admissible (positive) root for l_TKE.
464- # When a_pd > 0 (production exceeds dissipation) the root
465- # (−ᶜtke_exch + √D) / (2 a_pd)
466- # is positive. For a_pd < 0 the opposite root is required.
467- l_TKE_sol1 = (- (ᶜtke_exch) + sqrt (discriminant)) / (2 * a_pd)
468- # For a_pd < 0 (local destruction exceeds production) use
469- # (−ᶜtke_exch − √D) / (2 a_pd).
470- if a_pd > FT (0 )
471- l_TKE = l_TKE_sol1
472- else # a_pd < FT(0)
473- l_TKE = (- (ᶜtke_exch) - sqrt (discriminant)) / (2 * a_pd)
474- end
475- l_TKE = max (l_TKE, FT (0 )) # Ensure it's non-negative
476- end
477- elseif abs (ᶜtke_exch) > eps_FT # If a_pd is zero, balance is between exchange and dissipation
478- # ᶜtke_exch = c_neg / l_TKE => l_TKE = c_neg / ᶜtke_exch
479- # Ensure division is safe and result is positive
480- if ᶜtke_exch > eps_FT # Assuming positive exchange means TKE sink from env perspective
481- l_TKE = c_neg / ᶜtke_exch # if c_neg is positive, l_TKE is positive
482- elseif ᶜtke_exch < - eps_FT # Negative exchange means TKE source for env
483- # -|ᶜtke_exch| = c_neg / l_TKE. If c_neg > 0, this implies l_TKE < 0, which is unphysical.
484- # This case (a_pd=0, tke_exch < 0, c_neg > 0) implies TKE source and dissipation, no production.
485- # Dissipation = Source. So, c_d * k_sqrt_k / l = -tke_exch. l = c_d * k_sqrt_k / (-tke_exch)
486- l_TKE = c_neg / (- (ᶜtke_exch))
487- end
488- l_TKE = max (l_TKE, FT (0 ))
489- end
490- # If a_pd = 0 and ᶜtke_exch = 0 (or c_neg = 0), l_TKE remains zero.
455+ # l_TKE = √c_neg / a_pd.
456+ l_TKE = ifelse (a_pd > eps_FT, sqrt (c_neg / max (a_pd, eps_FT)), FT (0 ))
491457
492458 # --- l_N: Static-stability length scale (buoyancy limit), constrained by l_z ---
493459 N_eff_sq = max (ᶜN²_eff, FT (0 )) # Use N^2 only if stable (N^2 > 0)
@@ -572,7 +538,6 @@ function ᶜmixing_length(Y, p, property::Val{P} = Val{:master}()) where {P}
572538 obukhov_length,
573539 ᶜstrain_rate_norm,
574540 ᶜprandtl_nvec,
575- ᶜtke_exch,
576541 p. atmos. edmfx_model. scale_blending_method,
577542 ),
578543 )
0 commit comments