diff --git a/src/parameterized_tendencies/gravity_wave_drag/non_orographic_gravity_wave.jl b/src/parameterized_tendencies/gravity_wave_drag/non_orographic_gravity_wave.jl index 462e01a0e48..e54535f218c 100644 --- a/src/parameterized_tendencies/gravity_wave_drag/non_orographic_gravity_wave.jl +++ b/src/parameterized_tendencies/gravity_wave_drag/non_orographic_gravity_wave.jl @@ -310,9 +310,19 @@ function non_orographic_gravity_wave_forcing( u_waveforcing, v_waveforcing, p, - source_type="convection", + source_type = "convection", ) where {nc} - (; gw_source_ampl, gw_nk) = p.non_orographic_gravity_wave + (; + gw_source_ampl, + gw_Bw, + gw_Bn, + gw_c, + gw_cw, + gw_cn, + gw_flag, + gw_c0, + gw_nk, + ) = p.non_orographic_gravity_wave ᶜρ_p1 = p.scratch.ᶜtemp_scalar ᶜz_p1 = p.scratch.ᶜtemp_scalar_2 ᶜu_p1 = p.scratch.ᶜtemp_scalar_3 @@ -381,6 +391,12 @@ function non_orographic_gravity_wave_forcing( ᶜz_p1, ᶜz, source_level, + gw_Bw, + gw_Bn, + gw_cw, + gw_cn, + gw_c, + gw_flag, ᶜlevel, gw_source_ampl, ) @@ -397,6 +413,12 @@ function non_orographic_gravity_wave_forcing( ᶜz_p1, ᶜz, source_level, + gw_Bw, + gw_Bn, + gw_cw, + gw_cn, + gw_c, + gw_flag, ᶜlevel, gw_source_ampl, ) @@ -417,6 +439,12 @@ function non_orographic_gravity_wave_forcing( z_kp1, z_k, source_level, + Bw, + Bn, + cw, + cn, + c, + flag, level, source_ampl, ) @@ -431,30 +459,34 @@ function non_orographic_gravity_wave_forcing( fm = 0.0 if level == (source_level - 1) mask .= 1 - if source_type == "convection" - B0 = ntuple( - n -> wave_source_convection( - c[n], - u_source, - k, - 0.004, - 5000, - ), - Val(nc), - ) - else - B0 = ntuple( - n -> wave_source_original( - c[n], - u_source, - k, - 0.004, - 5000, - ), - Val(nc), - ) - - end + if source_type == "convection" + B0 = ntuple( + n -> wave_source_convection( + ρ_source, + ν[n], + u_source, + k, + 0.004, + 5000, + ), + Val(nc), + ) + else + B0 = ntuple( + n -> wave_source_original( + c[n], + u_source, + Bw, + Bn, + cw, + cn, + gw_c0, + flag, + ), + Val(nc), + ) + + end Bsum = sum(abs.(B0)) end @@ -538,6 +570,12 @@ function non_orographic_gravity_wave_forcing( z_kp1, z_k, source_level, + Bw, + Bn, + cw, + cn, + c, + flag, level, source_ampl, ) @@ -553,18 +591,35 @@ function non_orographic_gravity_wave_forcing( fm = 0.0 if level == (source_level - 1) - mask .= 1 - B0 = ntuple( - n -> wave_source( - ρ_source, - ν[n], - u_source, - k, - 0.004, - 5000, - ), - Val(nc), - ) + if source_type == "convection" + B0 = ntuple( + n -> wave_source_convection( + ρ_source, + ν[n], + u_source, + k, + 0.004, + 5000, + ), + Val(nc), + ) + else + B0 = ntuple( + n -> wave_source_original( + c[n], + u_source, + Bw, + Bn, + cw, + cn, + gw_c0, + flag, + ), + Val(nc), + ) + + end + Bsum = sum(abs.(B0)) end for n in 1:nci @@ -748,3 +803,16 @@ function wave_source_convection( end #Need to be specify from convection Profiles: heating depth h, heating amplitude Q₀, mean wind in heating region U. #Now they are simply setted as 5000, 0.004, and velocity at the source level. + +function wave_source_original(c, u_source, Bw, Bn, cw, cn, gw_c0, flag) + sign((c - u_source)) * ( + Bw * exp( + -log(2.0) * + ((c[n] * flag + (c[n] - u_source) * (1 - flag) - gw_c0) / cw)^2, + ) + + Bn * exp( + -log(2.0) * + ((c[n] * flag + (c[n] - u_source) * (1 - flag) - gw_c0) / cn)^2, + ) + ) +end