-
Notifications
You must be signed in to change notification settings - Fork 19
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
add vertical fluctuation and nudging for GCM driven SCM #2903
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
config/model_configs/prognostic_edmfx_gcmdriven_column.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
job_id: "prognostic_edmfx_gcmdriven_column" | ||
initial_condition: "Bomex" | ||
subsidence: "Bomex" | ||
edmf_coriolis: "Bomex" | ||
ls_adv: "Bomex" | ||
vert_fluc: "GCMDriven" | ||
nudging: "GCMDriven" | ||
surface_setup: "Bomex" | ||
turbconv: "prognostic_edmfx" | ||
implicit_diffusion: true | ||
implicit_sgs_advection: true | ||
approximate_linear_solve_iters: 2 | ||
max_newton_iters_ode: 3 | ||
edmfx_upwinding: first_order | ||
edmfx_entr_model: "Generalized" | ||
edmfx_detr_model: "Generalized" | ||
edmfx_sgs_mass_flux: true | ||
edmfx_sgs_diffusive_flux: true | ||
edmfx_nh_pressure: true | ||
edmfx_velocity_relaxation: true | ||
prognostic_tke: true | ||
moist: "equil" | ||
config: "column" | ||
z_max: 3e3 | ||
z_elem: 60 | ||
z_stretch: false | ||
perturb_initstate: false | ||
dt: "50secs" | ||
t_end: "6hours" | ||
dt_save_to_disk: "10mins" | ||
toml: [toml/prognostic_edmfx_bomex.toml] | ||
netcdf_output_at_levels: true | ||
netcdf_interpolation_num_points: [2, 2, 60] | ||
diagnostics: | ||
- short_name: [ts, ta, thetaa, ha, pfull, rhoa, ua, va, wa, hur, hus, cl, clw, cli, hussfc, evspsbl] | ||
period: 10mins | ||
- short_name: [arup, waup, taup, thetaaup, haup, husup, hurup, clwup, cliup, waen, taen, thetaaen, haen, husen, huren, clwen, clien, tke] | ||
period: 10mins | ||
- short_name: [entr, detr, lmix, bgrad, strain, edt, evu] | ||
period: 10mins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
##### | ||
##### Nudging/relaxation tendency for GCM-driven SCM | ||
##### | ||
|
||
import ClimaCore.Fields as Fields | ||
|
||
nudging_cache(Y, atmos::AtmosModel) = nudging_cache(Y, atmos.nudging) | ||
|
||
nudging_cache(Y, ::Nothing) = (;) | ||
nudging_tendency!(Yₜ, Y, p, t, colidx, ::Nothing) = nothing | ||
|
||
function nudging_cache(Y, ::Nudging) | ||
FT = Spaces.undertype(axes(Y.c)) | ||
ᶜT_mean = similar(Y.c, FT) | ||
ᶜq_tot_mean = similar(Y.c, FT) | ||
ᶜu_mean = similar(Y.c, FT) | ||
ᶜv_mean = similar(Y.c, FT) | ||
# TODO: read profiles from LES | ||
@. ᶜT_mean = 290 | ||
@. ᶜq_tot_mean = 0.010 | ||
@. ᶜu_mean = 5 | ||
@. ᶜv_mean = 0 | ||
# TODO: make it a function of z and add timescale to climaparams | ||
hr = 3600 | ||
ᶜτ_scalar = 24hr | ||
ᶜτ_wind = 6hr | ||
return (; ᶜτ_scalar, ᶜτ_wind, ᶜT_mean, ᶜq_tot_mean, ᶜu_mean, ᶜv_mean) | ||
end | ||
|
||
function nudging_tendency!(Yₜ, Y, p, t, colidx, ::Nudging) | ||
|
||
thermo_params = CAP.thermodynamics_params(p.params) | ||
T_0 = TD.Parameters.T_0(thermo_params) | ||
Lv_0 = TD.Parameters.LH_v0(thermo_params) | ||
cv_v = TD.Parameters.cv_v(thermo_params) | ||
R_v = TD.Parameters.R_v(thermo_params) | ||
|
||
(; ᶜu_mean, ᶜv_mean, ᶜτ_wind, ᶜτ_scalar, ᶜT_mean, ᶜq_tot_mean) = p.nudging | ||
(; ᶜspecific, ᶜts) = p.precomputed | ||
ᶜlg = Fields.local_geometry_field(Y.c) | ||
ᶜuₕ_mean = p.scratch.ᶜtemp_C12 | ||
@. ᶜuₕ_mean[colidx] = | ||
C12(Geometry.UVVector(ᶜu_mean[colidx], ᶜv_mean[colidx]), ᶜlg[colidx]) | ||
@. Yₜ.c.uₕ[colidx] -= (Y.c.uₕ[colidx] - ᶜuₕ_mean[colidx]) / ᶜτ_wind | ||
|
||
ᶜdTdt_nudging = p.scratch.ᶜtemp_scalar | ||
ᶜdqtdt_nudging = p.scratch.ᶜtemp_scalar_2 | ||
@. ᶜdTdt_nudging[colidx] = | ||
-(TD.air_temperature(thermo_params, ᶜts[colidx]) - ᶜT_mean[colidx]) / | ||
ᶜτ_scalar | ||
@. ᶜdqtdt_nudging[colidx] = | ||
-(ᶜspecific.q_tot[colidx] - ᶜq_tot_mean[colidx]) / ᶜτ_scalar | ||
|
||
@. Yₜ.c.ρe_tot[colidx] += | ||
Y.c.ρ[colidx] * ( | ||
TD.cv_m(thermo_params, ᶜts[colidx]) * ᶜdTdt_nudging[colidx] + | ||
( | ||
cv_v * (TD.air_temperature(thermo_params, ᶜts[colidx]) - T_0) + | ||
Lv_0 - R_v * T_0 | ||
) * ᶜdqtdt_nudging[colidx] | ||
) | ||
@. Yₜ.c.ρq_tot[colidx] += Y.c.ρ[colidx] * ᶜdqtdt_nudging[colidx] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
##### | ||
##### Vertical fluctuation (for single column experiments) | ||
##### | ||
|
||
import Thermodynamics as TD | ||
import ClimaCore.Spaces as Spaces | ||
import ClimaCore.Fields as Fields | ||
|
||
vertical_fluctuation_cache(Y, atmos::AtmosModel) = | ||
vertical_fluctuation_cache(Y, atmos.vert_fluc) | ||
|
||
vertical_fluctuation_cache(Y, ::Nothing) = (;) | ||
function vertical_fluctuation_cache(Y, ::VerticalFluctuation) | ||
FT = Spaces.undertype(axes(Y.c)) | ||
ᶜdTdt_fluc = similar(Y.c, FT) | ||
ᶜdqtdt_fluc = similar(Y.c, FT) | ||
# TODO: read profiles from LES | ||
@. ᶜdTdt_fluc = 0 | ||
@. ᶜdqtdt_fluc = 0 | ||
return (; ᶜdTdt_fluc, ᶜdqtdt_fluc) | ||
end | ||
|
||
vertical_fluctuation_tendency!(Yₜ, Y, p, t, colidx, ::Nothing) = nothing | ||
function vertical_fluctuation_tendency!( | ||
Yₜ, | ||
Y, | ||
p, | ||
t, | ||
colidx, | ||
::VerticalFluctuation, | ||
) | ||
(; params) = p | ||
(; ᶜts) = p.precomputed | ||
(; ᶜdTdt_fluc, ᶜdqtdt_fluc) = p.vertical_fluctuation | ||
thermo_params = CAP.thermodynamics_params(params) | ||
T_0 = TD.Parameters.T_0(thermo_params) | ||
Lv_0 = TD.Parameters.LH_v0(thermo_params) | ||
cv_v = TD.Parameters.cv_v(thermo_params) | ||
R_v = TD.Parameters.R_v(thermo_params) | ||
|
||
@. Yₜ.c.ρe_tot[colidx] += | ||
Y.c.ρ[colidx] * ( | ||
TD.cv_m(thermo_params, ᶜts[colidx]) * ᶜdTdt_fluc[colidx] + | ||
( | ||
cv_v * (TD.air_temperature(thermo_params, ᶜts[colidx]) - T_0) + | ||
Lv_0 - R_v * T_0 | ||
) * ᶜdqtdt_fluc[colidx] | ||
) | ||
@. Yₜ.c.ρq_tot[colidx] += Y.c.ρ[colidx] * ᶜdqtdt_fluc[colidx] | ||
|
||
return nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a coefficient rather than timescale so that we can have 0 relaxation for scalar or wind separately (by setting the coefficient to 0) without an additional flag.