Skip to content

Commit

Permalink
Simplify assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Nov 8, 2021
1 parent a3c5ccb commit b1b75e2
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/Turbulence_PrognosticTKE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,15 @@ function compute_covariance_dissipation(edmf::EDMF_PrognosticTKE, grid, state, c
return
end

function compute_en_tendencies!(edmf::EDMF_PrognosticTKE{N_up}, grid::Grid, state, param_set, TS, covar_sym::Symbol, prog_sym::Symbol) where {N_up}
function compute_en_tendencies!(
edmf::EDMF_PrognosticTKE{N_up},
grid::Grid,
state,
param_set,
TS,
covar_sym::Symbol,
prog_sym::Symbol,
) where {N_up}
kc_surf = kc_surface(grid)
kc_toa = kc_top_of_atmos(grid)
ρ0_c = center_ref_state(state).ρ0
Expand Down Expand Up @@ -821,11 +829,14 @@ function compute_en_tendencies!(edmf::EDMF_PrognosticTKE{N_up}, grid::Grid, stat
ρaew_en_ϕ = center_aux_turbconv(state).ρaew_en_ϕ

Ic = CCO.InterpolateF2C()
@. ρaew_en_ϕ = ρ0_c * aux_en.area * Ic(w_en_f) * covar
area_en = aux_en.area
tke_en = aux_en.tke
@. ρaew_en_ϕ = ρ0_c * area_en * Ic(w_en_f) * covar

covar_surf = covar[kc_surf]
prog_covar[kc_surf] = covar[kc_surf]

@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]
Expand All @@ -838,16 +849,12 @@ function compute_en_tendencies!(edmf::EDMF_PrognosticTKE{N_up}, grid::Grid, stat
end
D_env_i
end
dissipation = ρ0_c[k] * aux_en.area[k] * c_d * sqrt(max(aux_en.tke[k], 0)) / max(mixing_length[k], 1)
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)))
if is_surface_center(grid, k)
prog_covar[k] = covar_surf
else
prog_covar[k] =
press[k] + buoy[k] + shear[k] + entr_gain[k] + rain_src[k] - D_env * covar[k] - dissipation * covar[k] -
∇ρaew_en_ϕ + ∇ρ_ae_K∇ϕ[k]
end
prog_covar[k] =
press[k] + buoy[k] + shear[k] + entr_gain[k] + rain_src[k] - D_env * covar[k] - dissipation * covar[k] -
∇ρaew_en_ϕ + ∇ρ_ae_K∇ϕ[k]
end

return nothing
Expand Down

0 comments on commit b1b75e2

Please sign in to comment.