Skip to content

Commit

Permalink
change format
Browse files Browse the repository at this point in the history
  • Loading branch information
谢萧涯 authored and 谢萧涯 committed Aug 7, 2024
1 parent 75532c0 commit 9647638
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 48 deletions.
16 changes: 8 additions & 8 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
version = "0.27.2"

[[deps.ClimaComms]]
git-tree-sha1 = "ec303a4a66dc0a0ebe15a639a7e685afeaa0daef"
git-tree-sha1 = "2ca8c9ca6131a7be8ca262e6db79bc7aa94ab597"
uuid = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
version = "0.6.4"
version = "0.6.3"
weakdeps = ["CUDA", "MPI"]

[deps.ClimaComms.extensions]
Expand Down Expand Up @@ -415,9 +415,9 @@ version = "0.7.33"

[[deps.ClimaUtilities]]
deps = ["Artifacts", "Dates"]
git-tree-sha1 = "f516cf47cf12eaade1e326e7566738147a2e924a"
git-tree-sha1 = "2e171face2f5ee218ebaa9aee7b5e14a28b14366"
uuid = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513"
version = "0.1.11"
version = "0.1.10"
weakdeps = ["Adapt", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Interpolations", "NCDatasets"]

[deps.ClimaUtilities.extensions]
Expand Down Expand Up @@ -623,9 +623,9 @@ version = "1.9.1"

[[deps.DiffEqBase]]
deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "Setfield", "Static", "StaticArraysCore", "Statistics", "Tricks", "TruncatedStacktraces"]
git-tree-sha1 = "72950e082d2241a1da1c924147943e2918471af9"
git-tree-sha1 = "a49034d21181e6ed3c2ae0ab5a586d7f0a4ee912"
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
version = "6.152.2"
version = "6.152.1"

[deps.DiffEqBase.extensions]
DiffEqBaseCUDAExt = "CUDA"
Expand Down Expand Up @@ -2288,9 +2288,9 @@ version = "0.6.43"

[[deps.SciMLBase]]
deps = ["ADTypes", "Accessors", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "Expronicon", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"]
git-tree-sha1 = "7f0e208db50f5fee2386b6d8dc9608d580059331"
git-tree-sha1 = "b316ed5e5e71a6414b0c0e0c9f334afcc701ebf8"
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
version = "2.48.1"
version = "2.48.0"

[deps.SciMLBase.extensions]
SciMLBaseChainRulesCoreExt = "ChainRulesCore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function non_orographic_gravity_wave_forcing(
ᶜz_p1 .= R2.(R1.(ᶜz))

mask = BitVector(ones(nc))
level_end= Spaces.nlevels(axes(ᶜρ))
level_end = Spaces.nlevels(axes(ᶜρ))
B1 = ntuple(i -> 0.0, Val(nc))

for ink in 1:nk
Expand Down Expand Up @@ -501,41 +501,57 @@ function non_orographic_gravity_wave_forcing(
fm = 0.0
if level == 1
#mask = ntuple(i -> true, Val(nc))
mask .=1
mask .= 1
Bsum = 0.0
B0 = ntuple(n -> sign(( (n - 1) * dc - cmax-u_kp1) ) * (
Bw * exp(
-log(2.0) *
((( (n - 1) * dc - cmax) * flag + ( (n - 1) * dc - cmax-u_source) * (1 - flag) - c0) / cw)^2,
) +
Bn * exp(
-log(2.0) *
((( (n - 1) * dc - cmax) * flag + ( (n - 1) * dc - cmax-u_source) * (1 - flag) - c0) / cn)^2,
)
),Val(nc))
Bsum = sum(abs.(B0))
B0 = ntuple(
n ->
sign(((n - 1) * dc - cmax - u_kp1)) * (
Bw * exp(
-log(2.0) *
(
(
((n - 1) * dc - cmax) * flag +
((n - 1) * dc - cmax - u_source) *
(1 - flag) - c0
) / cw
)^2,
) +
Bn * exp(
-log(2.0) *
(
(
((n - 1) * dc - cmax) * flag +
((n - 1) * dc - cmax - u_source) *
(1 - flag) - c0
) / cn
)^2,
)
),
Val(nc),
)
Bsum = sum(abs.(B0))
end
for n in 1:nci
# check only those waves which are still propagating, i.e., mask = 1.0
if (mask[n]) == 1
c_hat = c[n] - u_kp1 # c0mu
# f phase speed matches the wind speed, remove c(n) from the set of propagating waves.
if c_hat == 0.0
mask[n] =0
mask[n] = 0
else
c_hat0 = c[n] - u_source
# define the criterion which determines if wave is reflected at this level (test).
test = abs(c_hat) * kwv - ω_r
if test >= 0.0
# wave has undergone total internal reflection. remove it from the propagating set.
mask[n] =0
mask[n] = 0
else
if level ==level_end
if level == level_end
# this is added in MiMA implementation:
# all momentum flux that escapes across the model top
# is deposited to the extra level being added so that
# momentum flux is conserved
mask[n] =0
mask[n] = 0
if level >= source_level
fm = fm + B0[n]
end
Expand All @@ -550,7 +566,7 @@ function non_orographic_gravity_wave_forcing(
# waves moving upwards to the next level.
Foc = B0[n] / FT1((c_hat)^3) - fac
if Foc >= 0.0 || (c_hat0 * c_hat <= 0.0)
mask[n] =0
mask[n] = 0
if level >= source_level
fm = fm + B0[n]
end
Expand All @@ -567,8 +583,7 @@ function non_orographic_gravity_wave_forcing(
eps = calc_intermitency(ρ_source, source_ampl, nk, FT1(Bsum))
if level >= source_level
rbh = sqrt(ρ_k * ρ_kp1)
wave_forcing =
(ρ_source / rbh) * FT1(fm) * eps / (z_kp1 - z_k)
wave_forcing = (ρ_source / rbh) * FT1(fm) * eps / (z_kp1 - z_k)
else
wave_forcing = FT1(0.0)
end
Expand All @@ -577,7 +592,7 @@ function non_orographic_gravity_wave_forcing(
end



Operators.column_accumulate!(
v_waveforcing,
input_v;
Expand Down Expand Up @@ -620,41 +635,57 @@ function non_orographic_gravity_wave_forcing(
fm = 0.0
if level == 1
#mask = ntuple(i -> true, Val(nc))
mask .=1
mask .= 1
Bsum = 0.0
B0 = ntuple(n -> sign(( (n - 1) * dc - cmax-u_kp1) ) * (
Bw * exp(
-log(2.0) *
((( (n - 1) * dc - cmax) * flag + ( (n - 1) * dc - cmax-u_source) * (1 - flag) - c0) / cw)^2,
) +
Bn * exp(
-log(2.0) *
((( (n - 1) * dc - cmax) * flag + ( (n - 1) * dc - cmax-u_source) * (1 - flag) - c0) / cn)^2,
)
),Val(nc))
Bsum = sum(abs.(B0))
B0 = ntuple(
n ->
sign(((n - 1) * dc - cmax - u_kp1)) * (
Bw * exp(
-log(2.0) *
(
(
((n - 1) * dc - cmax) * flag +
((n - 1) * dc - cmax - u_source) *
(1 - flag) - c0
) / cw
)^2,
) +
Bn * exp(
-log(2.0) *
(
(
((n - 1) * dc - cmax) * flag +
((n - 1) * dc - cmax - u_source) *
(1 - flag) - c0
) / cn
)^2,
)
),
Val(nc),
)
Bsum = sum(abs.(B0))
end
for n in 1:nci
# check only those waves which are still propagating, i.e., mask = 1.0
if (mask[n]) == 1
c_hat = c[n] - u_kp1 # c0mu
# f phase speed matches the wind speed, remove c(n) from the set of propagating waves.
if c_hat == 0.0
mask[n] =0
mask[n] = 0
else
c_hat0 = c[n] - u_source
# define the criterion which determines if wave is reflected at this level (test).
test = abs(c_hat) * kwv - ω_r
if test >= 0.0
# wave has undergone total internal reflection. remove it from the propagating set.
mask[n] =0
mask[n] = 0
else
if level == level_end
# this is added in MiMA implementation:
# all momentum flux that escapes across the model top
# is deposited to the extra level being added so that
# momentum flux is conserved
mask[n] =0
mask[n] = 0
if level >= source_level
fm = fm + B0[n]
end
Expand All @@ -669,7 +700,7 @@ function non_orographic_gravity_wave_forcing(
# waves moving upwards to the next level.
Foc = B0[n] / FT2((c_hat)^3) - fac
if Foc >= 0.0 || (c_hat0 * c_hat <= 0.0)
mask[n] =0
mask[n] = 0
if level >= source_level
fm = fm + B0[n]
end
Expand All @@ -686,8 +717,7 @@ function non_orographic_gravity_wave_forcing(
eps = calc_intermitency(ρ_source, source_ampl, nk, FT2(Bsum))
if level >= source_level
rbh = sqrt(ρ_k * ρ_kp1)
wave_forcing =
(ρ_source / rbh) * FT2(fm) * eps / (z_kp1 - z_k)
wave_forcing = (ρ_source / rbh) * FT2(fm) * eps / (z_kp1 - z_k)
else
wave_forcing = FT2(0.0)
end
Expand Down Expand Up @@ -778,4 +808,4 @@ end

function get_nc(::Val{nc}) where {nc}
nc
end
end

0 comments on commit 9647638

Please sign in to comment.