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

Use more ClimaCore operators #573

Merged
merged 1 commit into from
Nov 17, 2021
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
1 change: 1 addition & 0 deletions integration_tests/utils/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ cent_aux_vars_edmf(FT, n_up) = (;
θ_liq_ice_tendency_precip_formation = FT(0),
qt_tendency_precip_formation = FT(0),
Ri = FT(0),
D_env = FT(0),
),
up = ntuple(i -> cent_aux_vars_up(FT), n_up),
en = (;
Expand Down
27 changes: 13 additions & 14 deletions src/Turbulence_PrognosticTKE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ function compute_en_tendencies!(
KH = center_aux_turbconv(state).KH
aux_tc = center_aux_turbconv(state)
aux_bulk = center_aux_bulk(state)
D_env = aux_bulk.D_env
ae = 1 .- aux_bulk.area
aeK = is_tke ? ae .* KM : ae .* KH

Expand All @@ -847,7 +848,7 @@ function compute_en_tendencies!(
@. ∇ρ_ae_K∇ϕ = ∇c(ρ0_f * If(aeK) * ∇f(covar))

mixing_length = aux_tc.mixing_length
minimum_area = edmf.minimum_area
min_area = edmf.minimum_area
pressure_plume_spacing = edmf.pressure_plume_spacing

ρaew_en_ϕ = center_aux_turbconv(state).ρaew_en_ϕ
Expand All @@ -859,25 +860,23 @@ function compute_en_tendencies!(

prog_covar[kc_surf] = covar[kc_surf]

parent(D_env) .= 0

@inbounds for i in 1:N_up
turb_entr = aux_up[i].frac_turb_entr
entr_sc = aux_up[i].entr_sc
w_up = aux_up_f[i].w
a_up = aux_up[i].area
@. D_env += Int(a_up > min_area) * ρ0_c * a_up * Ic(w_up) * (entr_sc + turb_entr)
end

@inbounds for k in real_center_indices(grid)
is_surface_center(grid, k) && continue
D_env = sum(1:N_up) do i
if aux_up[i].area[k] > minimum_area
turb_entr = aux_up[i].frac_turb_entr[k]
entr_sc = aux_up[i].entr_sc[k]
R_up = pressure_plume_spacing[i]
w_up_c = interpf2c(aux_up_f[i].w, grid, k)
D_env_i = ρ0_c[k] * aux_up[i].area[k] * w_up_c * (entr_sc + turb_entr)
else
D_env_i = FT(0)
end
D_env_i
end
dissipation = ρ0_c[k] * area_en[k] * c_d * sqrt(max(tke_en[k], 0)) / max(mixing_length[k], 1)
ρaew_en_ϕ_cut = ccut_downwind(ρaew_en_ϕ, grid, k)
∇ρaew_en_ϕ = c∇_downwind(ρaew_en_ϕ_cut, grid, k; bottom = FreeBoundary(), top = SetGradient(FT(0)))
prog_covar[k] =
press[k] + buoy[k] + shear[k] + entr_gain[k] + rain_src[k] - D_env * covar[k] - dissipation * covar[k] -
press[k] + buoy[k] + shear[k] + entr_gain[k] + rain_src[k] - D_env[k] * covar[k] - dissipation * covar[k] -
∇ρaew_en_ϕ + ∇ρ_ae_K∇ϕ[k]
end

Expand Down