-
Notifications
You must be signed in to change notification settings - Fork 26
Allow for Modifications to DYCOMS-RF02 Initial Conditions via Config #3951
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
Open
ericmpham
wants to merge
1
commit into
main
Choose a base branch
from
ep/modify_dycoms_rf02
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 hidden or 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 hidden or 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
41 changes: 41 additions & 0 deletions
41
config/model_configs/diagnostic_edmfx_dycoms_rf02_column.yml
This file contains hidden or 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,41 @@ | ||
| initial_condition: DYCOMS_RF02 | ||
| subsidence: DYCOMS | ||
| scm_coriolis: DYCOMS_RF02 | ||
| rad: DYCOMS | ||
| surface_setup: DYCOMS_RF02 | ||
| turbconv: "diagnostic_edmfx" | ||
| implicit_diffusion: true | ||
| approximate_linear_solve_iters: 2 | ||
| 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_filter: true | ||
| prognostic_tke: true | ||
| moist: "nonequil" | ||
| cloud_model: "grid_scale" | ||
| precip_model: "1M" | ||
| call_cloud_diagnostics_per_stage: true | ||
| config: "column" | ||
| x_elem: 2 | ||
| y_elem: 2 | ||
| z_elem: 30 | ||
| z_max: 1500 | ||
| z_stretch: false | ||
| perturb_initstate: false | ||
| dt: 10secs | ||
| t_end: 5hours | ||
| dt_save_state_to_disk: 10mins | ||
| toml: [toml/diagnostic_edmfx_1M.toml] | ||
| netcdf_interpolation_num_points: [8, 8, 30] | ||
| diagnostics: | ||
| - short_name: [ts, ta, thetaa, ha, pfull, rhoa, ua, va, wa, hur, hus, cl, clw, cli, hussfc, evspsbl, pr, lwp, rwp] | ||
| period: 10mins | ||
| - short_name: [arup, waup, taup, thetaaup, haup, husup, hurup, clwup, cliup, husraup, hussnup, tke] | ||
| period: 10mins | ||
| - short_name: [entr, detr, lmix, bgrad, strain, edt, evu] | ||
| period: 10mins | ||
| - short_name: [husra, hussn] | ||
| period: 10mins |
47 changes: 47 additions & 0 deletions
47
config/model_configs/prognostic_edmfx_perturbed_dycoms_rf02_column.yml
This file contains hidden or 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,47 @@ | ||
| initial_condition: DYCOMS_RF02 | ||
| subsidence: DYCOMS | ||
| scm_coriolis: DYCOMS_RF02 | ||
| rad: DYCOMS | ||
| surface_setup: DYCOMS_RF02 | ||
| q_tot_0_dycoms_rf02: 8.0 | ||
| theta_0_dycoms_rf02: 284.0 | ||
| theta_i_dycoms_rf02: 291.0 | ||
| z_max: 800.0 | ||
| turbconv: "prognostic_edmfx" | ||
| implicit_diffusion: false | ||
| approximate_linear_solve_iters: 2 | ||
| 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_filter: true | ||
| prognostic_tke: true | ||
| moist: "nonequil" | ||
| cloud_model: "quadrature_sgs" | ||
| precip_model: "1M" | ||
| call_cloud_diagnostics_per_stage: true | ||
| config: "column" | ||
| x_elem: 2 | ||
| y_elem: 2 | ||
| z_elem: 30 | ||
| z_max: 1500 | ||
| z_stretch: false | ||
| perturb_initstate: false | ||
| dt: 10secs | ||
| t_end: 5hours | ||
| dt_save_state_to_disk: 10mins | ||
| toml: [toml/prognostic_edmfx_1M.toml] | ||
| netcdf_interpolation_num_points: [8, 8, 30] | ||
| diagnostics: | ||
| - short_name: [ts, ta, thetaa, ha, pfull, rhoa, ua, va, wa, hur, hus, cl, clw, cli, hussfc, evspsbl, pr] | ||
| period: 10mins | ||
| - short_name: [arup, waup, taup, thetaaup, haup, husup, hurup, clwup, cliup, husraup, hussnup] | ||
| period: 10mins | ||
| - short_name: [waen, taen, thetaaen, haen, husen, huren, clwen, clien, husraen, hussnen, tke] | ||
| period: 10mins | ||
| - short_name: [entr, detr, lmix, bgrad, strain, edt, evu] | ||
| period: 10mins | ||
| - short_name: [husra, hussn] | ||
| period: 10mins |
This file contains hidden or 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 hidden or 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 hidden or 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,112 @@ | ||
|
|
||
| # Creating custom arguments for perturbation experiments | ||
| In cases where it is of interest to run ensembles of the same model configuration but with perturbed initial conditions, it may be of use to add new keyword arguments to the .yml file. The idea is to allow modifications to initial conditions to be passed directly through the .yml file and then creating multiple copies of the files but with different variations and combinations of these parameters. | ||
|
|
||
| As an example, we will explore modifying the total water mixing ratio (`q_tot_0`), liquid-ice potential temperature profiles (`theta_0` & `theta_i`), and initial boundary layer height (`z_i`) in the DYCOMS-RF02 simulation setup. | ||
|
|
||
| ### Modify initial_conditions.jl | ||
| To start, we need to go to the part of the source code responsible for defining the initial conditions. For both of the DYCOMS research flight simulation setups, the total water mixing ratio and liquid-ice potential temperature are pulled from another library called AtmosphericProfilesLibrary (APL). | ||
|
|
||
| There are many ways to modify the functions to allow for perturbation to the initial conditions, but for the sake of this example we will overwrite the function signature with our own version where we can pass in our own custom profiles. We must import the functions from the APL library and then define a new function with the same signature. This looks like: | ||
|
|
||
| ``` | ||
| import AtmosphericProfilesLibrary: Dycoms_RF02_θ_liq_ice, Dycoms_RF02_q_tot | ||
| [...] | ||
|
|
||
| # Redefine the profile functions here. Here we redefine the functions such that | ||
| # we can pass in our own values for q_tot and θ_liq_ice, as well as modifying | ||
| # the initial boundary layer height. | ||
|
|
||
| """ [Ackerman2009](@cite) """ | ||
| Dycoms_RF02_θ_liq_ice(::Type{FT}, theta_0, theta_i, z_i) where {FT} = | ||
| APL.ZProfile(z -> if z <= z_i | ||
| FT(theta_0) | ||
| else | ||
| FT(theta_i) + (z - FT(z_i))^FT(1.0 / 3.0) | ||
| end) | ||
|
|
||
| """ [Ackerman2009](@cite) """ | ||
| Dycoms_RF02_q_tot(::Type{FT}, q_tot_0, z_i) where {FT} = | ||
| APL.ZProfile(z -> if z <= z_i | ||
| FT(q_tot_0) / FT(1000.0) | ||
| else | ||
| (FT(5) - FT(3) * (FT(1) - exp(-(z - FT(z_i)) / FT(500)))) / FT(1000) | ||
| end) | ||
| ``` | ||
|
|
||
| Now that we have redefined our functions, we can pass these new functions to our intial conditions structure for the DYCOMS-RF02 setup. Here we can also begin to define our new keyword arguments that will serve as inputs for the new functions we defined. In the `DYCOMS_RF02` structure, we add the names of our new inputs: | ||
|
|
||
| ``` | ||
| Base.@kwdef struct DYCOMS_RF02 <: InitialCondition | ||
| prognostic_tke::Bool = false | ||
| q_tot_0_dycoms_rf02 # Define total water mixing ratio. | ||
| theta_0_dycoms_rf02 # Define liquid-ice θ at surface. | ||
| theta_i_dycoms_rf02 # Define liquid-ice θ at initial boundary layer height. | ||
| z_i_dycoms_rf02 # Define initial boundary layer height. | ||
| end | ||
|
|
||
| for IC in (:Dycoms_RF01, :Dycoms_RF02) | ||
| IC_Type = Symbol(uppercase(string(IC))) | ||
| θ_func_name = Symbol(IC, :_θ_liq_ice) | ||
| q_tot_func_name = Symbol(IC, :_q_tot) | ||
| [...] | ||
| if IC == :Dycoms_RF02 | ||
| @eval function (initial_condition::$IC_Type)(params) | ||
| (; prognostic_tke, q_tot_0_dycoms_rf02, theta_0_dycoms_rf02, theta_i_dycoms_rf02, z_i_dycoms_rf02) = initial_condition #unpack the new arguments here. These arguments will be provided through the model .yml file. | ||
| FT = eltype(params) | ||
| [...] | ||
| θ = $θ_func_name(FT, FT(theta_0_dycoms_rf02), FT(theta_i_dycoms_rf02), FT(z_i_dycoms_rf02)) # Change function signature here. | ||
| q_tot = $q_tot_func_name(FT, FT(q_tot_0_dycoms_rf02), FT(z_i_dycoms_rf02)) # Change function signature here. | ||
| end | ||
| else | ||
| [...] | ||
| end | ||
| end | ||
| ``` | ||
|
|
||
| ### Add keywords to .yml & Modify default_config.yml | ||
| Now that we have added a new keyword argument to be used in initial conditions, it is time to define the keyword argument in the YAML files responsible for configuring the model runs. In the YAML file for running a DYCOMS-RF02 single column experiment, we add and adjust the following lines: | ||
|
|
||
| ``` | ||
| q_tot_0_dycoms_rf02: 9.45 # Define variables here. | ||
| theta_0_dycoms_rf02: 288.3 # Define variables here. | ||
| theta_i_dycoms_rf02: 295.0 # Define variables here. | ||
| z_i_dycoms_rf02: 795.0 # Define variables here. | ||
| ``` | ||
|
|
||
| These are the same default values being used by the original APL function, but we can modify it in the YAML file if we want to test different initial conditions. Additionally, we need to provide a backup default value in the case that the keyword argument is not used or provided in the setup YAML file. To do this, we go to default_config.yml and add the following: | ||
|
|
||
| ``` | ||
| q_tot_0_dycoms_rf02: # Additional variables here. | ||
| help: "Surface total water mixing ratio for DYCOMS RF02." | ||
| value: 9.45 # Default value. | ||
| theta_0_dycoms_rf02: # Additional variables here. | ||
| help: "Surface liquid-ice potential temperature for DYCOMS RF02." | ||
| value: 288.3 # Default value. | ||
| theta_i_dycoms_rf02: # Additional variables here. | ||
| help: "Initial boundary layer liquid-ice potential temperature for DYCOMS RF02." | ||
| value: 295.0 # Default value. | ||
| z_i_dycoms_rf02: # Additional variables here. | ||
| help: "Initial boundary layer height." | ||
| value: 795.0 # Default value. | ||
| ``` | ||
|
|
||
| ### Modify type_getters.jl | ||
| Finally, we need to update type_getters.jl with our new keyword arguments as well. We find where DYCOMS-RF02 is specified and then we replace it with a separate block that looks like: | ||
|
|
||
| ``` | ||
| [...] | ||
| elseif parsed_args["initial_condition"] == "DYCOMS_RF02" | ||
| return getproperty(ICs, Symbol(parsed_args["initial_condition"]))( | ||
| parsed_args["prognostic_tke"], | ||
| parsed_args["q_tot_0_dycoms_rf02"], # Add parsed args here. | ||
| parsed_args["theta_0_dycoms_rf02"], # Add parsed args here. | ||
| parsed_args["theta_i_dycoms_rf02"], # Add parsed args here. | ||
| parsed_args["z_i_dycoms_rf02"], # Add parsed args here. | ||
| ) | ||
| [...] | ||
| ``` | ||
|
|
||
| With this step complete, we are now ready to pass a new keyword argument that we defined ourselves to modify or change the initial conditions. | ||
|
|
||
| The recommended workflow is the create multiple copies of the .yml files and label them according to the initial conditions used. For example, the default file might look like `prognostic_edmfx_dycoms_rf02_column_qtot0_6.5_theta0_284.0_thetai_290.0_zi_795.0_prescribedN_1.0e8.yml`. | ||
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
It might be useful to talk to Nat, Costa & Julian about how they've implemented this for calibration -- I don't know how similar what you've done is to that?
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.
@nefrathenrici @costachris what are your opinions of doing things this way?
Uh oh!
There was an error while loading. Please reload this page.
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.
I think this is a great start (especially the initial conditions) but modifying the source code is probably time consuming and error-prone. I think the perturbation variables should be specified via parameters rather than parsed args, with an extra dycoms initial condition to read them in automatically.
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.
If you want to merge this quickly, I would request a test case that can run as part of buildkite to ensure that this feature stays supported.
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.
@nefrathenrici is what I put in the pipeline.yml okay? I consulted with Sajjad cause I was not really sure what to put for a test case.
I agree that it's also a tedious process, I wish I had more time to restructure it.