Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to get rid of MSLP overwrite #2053

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/hybrid/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ end

if config.parsed_args["check_conservation"]
FT = Spaces.undertype(axes(sol.u[end].c.ρ))
@test sum(sol.u[1].c.ρ) ≈ sum(sol.u[end].c.ρ) rtol = 25 * eps(FT)
@test sum(sol.u[1].c.ρ) ≈ sum(sol.u[end].c.ρ) rtol = 50 * eps(FT)
@test sum(sol.u[1].c.ρe_tot) +
(p.net_energy_flux_sfc[][] - p.net_energy_flux_toa[][]) ≈
sum(sol.u[end].c.ρe_tot) rtol = 30 * eps(FT)
Expand Down
2 changes: 1 addition & 1 deletion regression_tests/ref_counter.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122
123
8 changes: 4 additions & 4 deletions src/initial_conditions/initial_conditions.jl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be more consistent to change MSLP to p_ref_theta in the initial conditions in this file as it is used in p = p_0 * π_exn^(cp_d / R_d), so π_exn = (p / p_0)^(R_d/cp_d) when p_0 = p_ref_theta. It probably doesn't matter much though, as it is just the initial condition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the MSLP in the isothermal one and in the baroclinic wave initial conditions, but changed the rest. Lets see what the CI thinks about that

Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function (initial_condition::AgnesiHProfile)(params)
(; x, z) = local_geometry.coordinates
cp_d = CAP.cp_d(params)
cv_d = CAP.cv_d(params)
p_0 = CAP.MSLP(params)
p_0 = CAP.p_ref_theta(params)
R_d = CAP.R_d(params)
T_0 = CAP.T_0(params)
# auxiliary quantities
Expand Down Expand Up @@ -141,7 +141,7 @@ function (initial_condition::ScharProfile)(params)
R_d = CAP.R_d(params)
cp_d = CAP.cp_d(params)
cv_d = CAP.cv_d(params)
p₀ = CAP.MSLP(params)
p₀ = CAP.p_ref_theta(params)
(; x, z) = local_geometry.coordinates
θ₀ = FT(280.0)
buoy_freq = FT(0.01)
Expand Down Expand Up @@ -192,7 +192,7 @@ function (initial_condition::DryDensityCurrentProfile)(params)
θ_c = FT(-15)
cp_d = CAP.cp_d(params)
cv_d = CAP.cv_d(params)
p_0 = CAP.MSLP(params)
p_0 = CAP.p_ref_theta(params)
R_d = CAP.R_d(params)
T_0 = CAP.T_0(params)

Expand Down Expand Up @@ -250,7 +250,7 @@ function (initial_condition::RisingThermalBubbleProfile)(params)
θ_c = FT(0.5)
cp_d = CAP.cp_d(params)
cv_d = CAP.cv_d(params)
p_0 = CAP.MSLP(params)
p_0 = CAP.p_ref_theta(params)
R_d = CAP.R_d(params)
T_0 = CAP.T_0(params)

Expand Down
10 changes: 7 additions & 3 deletions src/parameterized_tendencies/radiation/held_suarez.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function forcing_tendency!(Yₜ, Y, p, t, colidx, ::HeldSuarezForcing)
cv_d = FT(CAP.cv_d(params))
day = FT(CAP.day(params))
MSLP = FT(CAP.MSLP(params))
p_ref_theta = FT(CAP.p_ref_theta(params))
grav = FT(CAP.grav(params))
ΔT_y_dry = FT(CAP.ΔT_y_dry(params))
ΔT_y_wet = FT(CAP.ΔT_y_wet(params))
Expand Down Expand Up @@ -79,14 +80,17 @@ function forcing_tendency!(Yₜ, Y, p, t, colidx, ::HeldSuarezForcing)
T_min,
(
T_equator - ΔT_y * abs2(sin(ᶜφ[colidx])) -
Δθ_z * log(ᶜp[colidx] / MSLP) * abs2(cos(ᶜφ[colidx]))
) * fast_pow(ᶜp[colidx] / MSLP, κ_d),
Δθ_z *
log(ᶜp[colidx] / p_ref_theta) *
abs2(cos(ᶜφ[colidx]))
) * fast_pow(ᶜp[colidx] / p_ref_theta, κ_d),
)
)

@. Yₜ.c.uₕ[colidx] -= (k_f * ᶜheight_factor[colidx]) * Y.c.uₕ[colidx]
if :ρθ in propertynames(Y.c)
@. Yₜ.c.ρθ[colidx] -= ᶜΔρT[colidx] * fast_pow((MSLP / ᶜp[colidx]), κ_d)
@. Yₜ.c.ρθ[colidx] -=
ᶜΔρT[colidx] * fast_pow((p_ref_theta / ᶜp[colidx]), κ_d)
elseif :ρe_tot in propertynames(Y.c)
@. Yₜ.c.ρe_tot[colidx] -= ᶜΔρT[colidx] * cv_d
end
Expand Down
3 changes: 1 addition & 2 deletions src/parameters/create_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,14 @@ function create_parameter_set(config::AtmosConfig)
dt = FT(CA.time_to_seconds(parsed_args["dt"]))

return if CA.is_column_edmf(parsed_args)
overrides = (; MSLP = 100000.0, τ_precip = dt)
overrides = (; τ_precip = dt)
create_climaatmos_parameter_set(toml_dict, parsed_args, overrides)
elseif CA.is_column_without_edmf(parsed_args)
overrides = (; τ_precip = dt)
create_climaatmos_parameter_set(toml_dict, parsed_args, overrides)
else
overrides = (;
R_d = 287.0,
MSLP = 1.0e5,
grav = 9.80616,
Omega = 7.29212e-5,
planet_radius = 6.371229e6,
Expand Down
7 changes: 4 additions & 3 deletions src/prognostic_equations/implicit/wfact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function Wfact!(W, Y, p, dtγ, t, colidx)
κ_d = FT(CAP.kappa_d(params))
cv_d = FT(CAP.cv_d(params))
T_tri = FT(CAP.T_triple(params))
MSLP = FT(CAP.MSLP(params))
p_ref_theta = FT(CAP.p_ref_theta(params))

dtγ_ref[] = dtγ

Expand Down Expand Up @@ -207,12 +207,13 @@ function Wfact!(W, Y, p, dtγ, t, colidx)
# If we ignore the dependence of pressure on moisture,
# ∂(ᶠgradᵥ(ᶜp - ᶜp_ref))/∂(ᶜρθ) =
# ᶠgradᵥ_stencil(
# R_d / (1 - κ_d) * (ᶜρθ * R_d / MSLP)^(κ_d / (1 - κ_d))
# R_d / (1 - κ_d) * (ᶜρθ * R_d / p_ref_theta)^(κ_d / (1 - κ_d))
# )
ᶜρθ = Y.c.ρθ
@. ∂ᶠ𝕄ₜ∂ᶜ𝔼[colidx] = map_get_data(
-1 / ᶠinterp(ᶜρ[colidx]) * ᶠgradᵥ_stencil(
R_d / (1 - κ_d) * (ᶜρθ[colidx] * R_d / MSLP)^(κ_d / (1 - κ_d)),
R_d / (1 - κ_d) *
(ᶜρθ[colidx] * R_d / p_ref_theta)^(κ_d / (1 - κ_d)),
),
)

Expand Down