Skip to content

Commit

Permalink
switch to conservative variables in the updrafts
Browse files Browse the repository at this point in the history
  • Loading branch information
yairchn committed Oct 25, 2021
1 parent d04df09 commit 6826e55
Show file tree
Hide file tree
Showing 8 changed files with 361 additions and 322 deletions.
40 changes: 20 additions & 20 deletions integration_tests/utils/initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,34 @@ end

function initialize_updrafts(edmf, grid, state, up::TC.UpdraftVariables, gm::TC.GridMeanVariables)
kc_surf = TC.kc_surface(grid)

prog_up = TC.center_prog_updrafts(state)
aux_up = TC.center_aux_updrafts(state)
prog_gm = TC.center_prog_grid_mean(state)
aux_up = TC.center_aux_updrafts(state)
prog_up_f = TC.face_prog_updrafts(state)
aux_up_f = TC.face_aux_updrafts(state)
aux_gm = TC.center_aux_grid_mean(state)
prog_up = TC.center_prog_updrafts(state)
prog_up_f = TC.face_prog_updrafts(state)
@inbounds for i in 1:(up.n_updrafts)
@inbounds for k in TC.real_face_indices(grid)
prog_up_f[i].w[k] = 0
aux_up_f[i].w[k] = 0
prog_up_f[i].ρaw[k] = 0
end

@inbounds for k in TC.real_center_indices(grid)
aux_up[i].buoy[k] = 0
# Simple treatment for now, revise when multiple updraft closures
# become more well defined
if up.prognostic
prog_up[i].area[k] = 0.0 #up.updraft_fraction/up.n_updrafts
else
prog_up[i].area[k] = up.updraft_fraction / up.n_updrafts
end
prog_up[i].q_tot[k] = prog_gm.q_tot[k]
prog_up[i].θ_liq_ice[k] = prog_gm.θ_liq_ice[k]
aux_up[i].area[k] = 0
aux_up[i].q_tot[k] = prog_gm.q_tot[k]
aux_up[i].θ_liq_ice[k] = prog_gm.θ_liq_ice[k]
aux_up[i].q_liq[k] = aux_gm.q_liq[k]
aux_up[i].T[k] = aux_gm.T[k]
prog_up[i].ρarea[k] = 0
prog_up[i].ρaq_tot[k] = 0
prog_up[i].ρaθ_liq_ice[k] = 0
end

prog_up[i].area[kc_surf] = up.updraft_fraction / up.n_updrafts
aux_up[i].area[kc_surf] = up.updraft_fraction / up.n_updrafts
end
return
end
Expand Down Expand Up @@ -134,9 +135,8 @@ function initialize_updrafts_DryBubble(edmf, grid, state, up::TC.UpdraftVariable
264.1574, 263.6518, 263.1461, 262.6451, 262.1476, 261.6524]
#! format: on

prog_up = TC.center_prog_updrafts(state)
aux_up = TC.center_aux_updrafts(state)
prog_up_f = TC.face_prog_updrafts(state)
aux_up_f = TC.face_aux_updrafts(state)
aux_gm = TC.center_aux_grid_mean(state)
prog_gm = TC.center_prog_grid_mean(state)
Area_in = TC.pyinterp(grid.zc, z_in, Area_in)
Expand All @@ -145,22 +145,22 @@ function initialize_updrafts_DryBubble(edmf, grid, state, up::TC.UpdraftVariable
@inbounds for i in 1:(up.n_updrafts)
@inbounds for k in TC.real_face_indices(grid)
if minimum(z_in) <= grid.zf[k] <= maximum(z_in)
prog_up_f[i].w[k] = 0.0
aux_up_f[i].w[k] = 0.0
end
end

@inbounds for k in TC.real_center_indices(grid)
if minimum(z_in) <= grid.zc[k] <= maximum(z_in)
prog_up[i].area[k] = Area_in[k] #up.updraft_fraction/up.n_updrafts
prog_up[i].θ_liq_ice[k] = θ_liq_in[k]
prog_up[i].q_tot[k] = 0.0
aux_up[i].area[k] = Area_in[k] #up.updraft_fraction/up.n_updrafts
aux_up[i].θ_liq_ice[k] = θ_liq_in[k]
aux_up[i].q_tot[k] = 0.0
aux_up[i].q_liq[k] = 0.0

# for now temperature is provided as diagnostics from LES
aux_up[i].T[k] = T_in[k]
else
prog_up[i].area[k] = 0.0 #up.updraft_fraction/up.n_updrafts
prog_up[i].θ_liq_ice[k] = prog_gm.θ_liq_ice[k]
aux_up[i].area[k] = 0.0 #up.updraft_fraction/up.n_updrafts
aux_up[i].θ_liq_ice[k] = prog_gm.θ_liq_ice[k]
aux_up[i].T[k] = aux_gm.T[k]
end
end
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/utils/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cent_aux_vars_en_2m(FT) = (;
rain_src = FT(0),
)
cent_aux_vars_up(FT) =
(; q_liq = FT(0), T = FT(0), RH = FT(0), buoy = FT(0), area_new = FT(0), q_tot_new = FT(0), θ_liq_ice_new = FT(0))
(; q_liq = FT(0), T = FT(0), RH = FT(0), buoy = FT(0), area = FT(0), q_tot = FT(0), θ_liq_ice = FT(0))
cent_aux_vars_edmf(FT, n_up) = (;
turbconv = (;
bulk = (; area = FT(0), θ_liq_ice = FT(0), RH = FT(0), buoy = FT(0), q_tot = FT(0), q_liq = FT(0), T = FT(0)),
Expand Down Expand Up @@ -91,7 +91,7 @@ cent_aux_vars(FT, n_up) = (; aux_vars_ref_state(FT)..., cent_aux_vars_gm(FT)...,

# Face only
face_aux_vars_gm(FT) = ()
face_aux_vars_up(FT) = (; w_new = FT(0))
face_aux_vars_up(FT) = (; w = FT(0))

face_aux_vars_edmf(FT, n_up) = (;
turbconv = (;
Expand Down Expand Up @@ -125,7 +125,7 @@ face_diagnostic_vars(FT, n_up) = (; face_diagnostic_vars_gm(FT)..., face_diagnos
# Center only
cent_prognostic_vars(FT, n_up) = (; cent_prognostic_vars_gm(FT)..., cent_prognostic_vars_edmf(FT, n_up)...)
cent_prognostic_vars_gm(FT) = (; u = FT(0), v = FT(0), θ_liq_ice = FT(0), q_tot = FT(0))
cent_prognostic_vars_up(FT) = (; area = FT(0), θ_liq_ice = FT(0), q_tot = FT(0))
cent_prognostic_vars_up(FT) = (; ρarea = FT(0), ρaθ_liq_ice = FT(0), ρaq_tot = FT(0))
cent_prognostic_vars_en(FT) = (; tke = FT(0), Hvar = FT(0), QTvar = FT(0), HQTcov = FT(0))
cent_prognostic_vars_edmf(FT, n_up) = (;
turbconv = (;
Expand All @@ -136,7 +136,7 @@ cent_prognostic_vars_edmf(FT, n_up) = (;

# Face only
face_prognostic_vars(FT, n_up) = (; w = FT(0), face_prognostic_vars_edmf(FT, n_up)...)
face_prognostic_vars_up(FT) = (; w = FT(0))
face_prognostic_vars_up(FT) = (; ρaw = FT(0))
face_prognostic_vars_edmf(FT, n_up) = (; turbconv = (; up = ntuple(i -> face_prognostic_vars_up(FT), n_up)))
# face_prognostic_vars_edmf(FT, n_up) = (;) # could also use this for empty model

Expand Down
Loading

0 comments on commit 6826e55

Please sign in to comment.