Skip to content

Commit f20481a

Browse files
Merge pull request #3844 from CliMA/as/hypdiff-ref
Enthalpy perturbation in hyperdiffusion tendency
2 parents 2ff6481 + d4d61aa commit f20481a

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

reproducibility_tests/ref_counter.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
246
1+
247
22

33
# **README**
44
#
@@ -20,6 +20,9 @@
2020

2121

2222
#=
23+
247
24+
- Hyperdiffusion of enthalpy perturbation
25+
2326
246
2427
- Prognostic edmf docstrings + refactor + scm_coriolis change
2528

src/cache/cache.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,46 @@ function build_cache(
129129
sfc_local_geometry =
130130
Fields.level(Fields.local_geometry_field(Y.f), Fields.half)
131131

132+
# Reference enthalpy for hyperdiffusion computation
133+
ᶜz = Fields.coordinate_field(Y.c).z
134+
T_ref = similar(ᶜz)
135+
p_ref = similar(ᶜz)
136+
q_tot_ref = similar(ᶜz)
137+
cv_m = similar(ᶜz)
138+
R_m = similar(ᶜz)
139+
thermo_params = CAP.thermodynamics_params(params)
140+
decay_scale_height = FT(8000)
141+
142+
# Reference State
143+
temp_profile = TD.TemperatureProfiles.DecayingTemperatureProfile{FT}(
144+
thermo_params,
145+
FT(300), # surface temperature
146+
FT(220), # top temperature
147+
decay_scale_height, # decay height scale
148+
)
149+
150+
rel_hum_ref =
151+
atmos.moisture_model isa DryModel ? FT(0) :
152+
@. FT(0.5) * exp(- ᶜz / decay_scale_height)
153+
154+
T_0 = CAP.T_0(params)
155+
grav = CAP.grav(params)
156+
@. T_ref = first(temp_profile(thermo_params, ᶜz))
157+
@. p_ref = last(temp_profile(thermo_params, ᶜz))
158+
@. q_tot_ref =
159+
TD.q_vap_from_RH_liquid(thermo_params, p_ref, T_ref, rel_hum_ref)
160+
@. cv_m = TD.cv_m(thermo_params, TD.PhasePartition(q_tot_ref, FT(0), FT(0)))
161+
@. R_m = TD.gas_constant_air(
162+
thermo_params,
163+
TD.PhasePartition(q_tot_ref, FT(0), FT(0)),
164+
)
165+
166+
ᶜh_ref = @. TD.total_specific_enthalpy(
167+
cv_m * (T_ref - T_0) + grav * ᶜz,
168+
R_m,
169+
T_ref,
170+
)
171+
132172
core = (
133173
ᶜΦ,
134174
ᶠgradᵥ_ᶜΦ = ᶠgradᵥ.(ᶜΦ),
@@ -139,6 +179,7 @@ function build_cache(
139179
surface_ct3_unit = CT3.(
140180
unit_basis_vector_data.(CT3, sfc_local_geometry)
141181
),
182+
ᶜh_ref,
142183
)
143184
external_forcing = external_forcing_cache(Y, atmos, params, start_date)
144185
sfc_setup = surface_setup(params)

src/prognostic_equations/hyperdiffusion.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ NVTX.@annotate function prep_hyperdiffusion_tendency!(Yₜ, Y, p, t)
8686
n = n_mass_flux_subdomains(turbconv_model)
8787
diffuse_tke = use_prognostic_tke(turbconv_model)
8888
(; ᶜp, ᶜspecific) = p.precomputed
89+
(; ᶜh_ref) = p.core
8990
(; ᶜ∇²u, ᶜ∇²specific_energy) = p.hyperdiff
9091
if turbconv_model isa PrognosticEDMFX
9192
(; ᶜ∇²uₕʲs, ᶜ∇²uᵥʲs, ᶜ∇²uʲs, ᶜ∇²mseʲs) = p.hyperdiff
@@ -97,7 +98,7 @@ NVTX.@annotate function prep_hyperdiffusion_tendency!(Yₜ, Y, p, t)
9798
C123(wcurlₕ(C123(curlₕ(p.precomputed.ᶜu))))
9899

99100
@. ᶜ∇²specific_energy =
100-
wdivₕ(gradₕ(specific(Y.c.ρe_tot, Y.c.ρ) + ᶜp / Y.c.ρ))
101+
wdivₕ(gradₕ(specific(Y.c.ρe_tot, Y.c.ρ) + ᶜp / Y.c.ρ - ᶜh_ref))
101102

102103
if diffuse_tke
103104
(; ᶜtke⁰) = p.precomputed

0 commit comments

Comments
 (0)