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

Refactor compute_zbl_qt_grad #65

Merged
merged 1 commit into from
Aug 1, 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
24 changes: 7 additions & 17 deletions src/Turbulence_PrognosticTKE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ function compute_entrainment_detrainment(self::EDMF_PrognosticTKE, GMV::GridMean
input.wstar = self.wstar

input.dz = get_grid(self).dz
input.zbl = compute_zbl_qt_grad(self, GMV)
input.zbl = compute_zbl_qt_grad(GMV)
input.sort_pow = self.sorting_power
input.c_ent = self.entrainment_factor
input.c_det = self.detrainment_factor
Expand Down Expand Up @@ -1104,24 +1104,14 @@ function compute_entrainment_detrainment(self::EDMF_PrognosticTKE, GMV::GridMean
return
end

function compute_zbl_qt_grad(self::EDMF_PrognosticTKE, GMV::GridMeanVariables)
function compute_zbl_qt_grad(GMV::GridMeanVariables)
grid = get_grid(GMV)
# computes inversion height as z with max gradient of qt
zbl_qt = 0.0
qt_grad = 0.0
grid = get_grid(self)
dzi = grid.dzi

@inbounds for k in real_center_indicies(grid)
z_ = grid.z_half[k]
qt_up = GMV.QT.values[k + 1]
qt_ = GMV.QT.values[k]

if fabs(qt_up - qt_) * dzi > qt_grad
qt_grad = fabs(qt_up - qt_) * dzi
zbl_qt = z_
end
z∇q_tot = map(real_center_indicies(grid)) do k
(grid.z_half[k], abs(∇c2f(GMV.QT.values, grid, k)))
end
return zbl_qt
k_star = argmax(last.(z∇q_tot))
return first.(z∇q_tot)[k_star]
end

function compute_pressure_plume_spacing(self::EDMF_PrognosticTKE, GMV::GridMeanVariables, Case::CasesBase)
Expand Down
1 change: 1 addition & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ mutable struct EDMF_PrognosticTKE{PS, A1, A2}
end
end
get_grid(edmf::EDMF_PrognosticTKE) = edmf.base.Gr
get_grid(obj) = obj.Gr
reference_state(edmf::EDMF_PrognosticTKE) = edmf.base.Ref
prandtl_number(edmf::EDMF_PrognosticTKE) = edmf.base.prandtl_number
turbulence_tendency(edmf::EDMF_PrognosticTKE) = edmf.base.turbulence_tendency
Expand Down