Skip to content

Commit

Permalink
add sourcetype choice
Browse files Browse the repository at this point in the history
  • Loading branch information
谢萧涯 authored and 谢萧涯 committed Aug 28, 2024
1 parent 5295563 commit 097fc08
Showing 1 changed file with 106 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand All @@ -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,
)
Expand All @@ -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
Expand Down Expand Up @@ -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,
)
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 097fc08

Please sign in to comment.