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

order update aux - fuse loops #507

Merged
merged 1 commit into from
Nov 4, 2021
Merged

order update aux - fuse loops #507

merged 1 commit into from
Nov 4, 2021

Conversation

yairchn
Copy link
Member

@yairchn yairchn commented Nov 3, 2021

This PR organizes update_aux in order to prevent issues of using aux vars from from previous time steps, fuse k loops and follow this general order:

  • upd primitive vars
  • bulk primitive vars
  • env primitive vars
  • ThermodynamicStates ts_gm, ts_up, ts_env
  • buoyancy
  • diagnostic variables (RH, T , q_liq, q_ice)
  • bulk diagnostic variables
  • closures

I separated the face and center updates in order to reduce the number of loops from each case

src/update_aux.jl Outdated Show resolved Hide resolved
@yairchn yairchn force-pushed the yc/order_update_aux branch 5 times, most recently from 4800ea2 to 70d1f76 Compare November 4, 2021 02:34
src/update_aux.jl Outdated Show resolved Hide resolved
aux_gm.q_liq[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.q_liq[k] + (1 - aux_tc.bulk.area[k]) * aux_en.q_liq[k])
aux_gm.q_ice[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.q_ice[k] + (1 - aux_tc.bulk.area[k]) * aux_en.q_ice[k])
aux_gm.T[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.T[k] + (1 - aux_tc.bulk.area[k]) * aux_en.T[k])
aux_gm.buoy[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.buoy[k] + (1 - aux_tc.bulk.area[k]) * aux_en.buoy[k])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already computed above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you referring to 'aux_gm.buoy[k]', its a question of which "aux_gm.buoy[k]" we would like to keep.
the RHS of this expression
aux_gm.buoy[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.buoy[k] + (1 - aux_tc.bulk.area[k]) * aux_en.buoy[k])
is changed in 133-139 after 'aux_gm.buoy[k]' was computed the first time. Therefore 'aux_gm.buoy[k]' is recomputed here.
All other grid mean variables in these lines are computed only here

Comment on lines +168 to +166
aux_gm.q_liq[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.q_liq[k] + (1 - aux_tc.bulk.area[k]) * aux_en.q_liq[k])
aux_gm.q_ice[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.q_ice[k] + (1 - aux_tc.bulk.area[k]) * aux_en.q_ice[k])
aux_gm.T[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.T[k] + (1 - aux_tc.bulk.area[k]) * aux_en.T[k])
aux_gm.buoy[k] = (aux_tc.bulk.area[k] * aux_tc.bulk.buoy[k] + (1 - aux_tc.bulk.area[k]) * aux_en.buoy[k])
Copy link
Member

@charleskawczynski charleskawczynski Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker (I know that we're currently already doing this), but why aren't we using thermodynamics to compute these from grid mean quantities? Isn't that what the dycore will do without edmf?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a great point. in theory the updraft and environment are not well mixed so better compute their individual thermodynamic states and get the temperature as area weighted mean. However I am not sure what the dycore will do, it should be discussed in the future.

Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the code changes look fine to me. It would be nice to get a second set of eyes on this PR, though, since update_aux! is pretty intricate.

anew_k = interpc2f(aux_up[i].area, grid, k; a_up_bcs...)
if anew_k >= edmf.minimum_area
aux_up_f[i].w[k] = max(prog_up_f[i].ρaw[k] / (ρ0_f[k] * anew_k), 0)
if is_surface_center(grid, k)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to fill out the surface points separately. And then loop over updrafts starting from the first point above the ground?

This way we would avoid checking an if/else for every height point in this loop

if anew_k >= edmf.minimum_area
aux_up_f[i].w[k] = max(prog_up_f[i].ρaw[k] / (ρ0_f[k] * anew_k), 0)
if is_surface_center(grid, k)
if prog_up[i].ρarea[k] / ρ0_c[k] >= edmf.minimum_area
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to use some common minimum area!

src/update_aux.jl Outdated Show resolved Hide resolved
@yairchn
Copy link
Member Author

yairchn commented Nov 4, 2021

Bors r+

@bors
Copy link
Contributor

bors bot commented Nov 4, 2021

Build succeeded:

@bors bors bot merged commit 4c391c4 into main Nov 4, 2021
@bors bors bot deleted the yc/order_update_aux branch November 4, 2021 19:06
charleskawczynski referenced this pull request Nov 9, 2021
511: Use relaxation to LES profiles + define initial conditions more precisely for LES_driven_SCM r=costachris a=costachris

Addresses points 4, 7 from #505. 
Averages 1 hour window around `t_end` - 6 hours for initial conditions. `thetali` and `qt` are relaxed to the mean LES profile following eqn 9 in Shen et al. 2021


Co-authored-by: costachris <christopouloscosta@gmail.com>
charleskawczynski referenced this pull request Nov 9, 2021
545: Bump version for new release r=charleskawczynski a=charleskawczynski



Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants