-
Notifications
You must be signed in to change notification settings - Fork 186
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
Calculate tendencies on boundaries #677
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
72105b4
Change function names in RHS calculation to prepare for boundary-tend…
glwagner ed37d46
More descriptive comments in calculate_interior_tendencies
glwagner 2c1e89d
Adds new file defining tendency functions
glwagner 9e6f0aa
Minor docstring reformatting in velocity and tracer tendencies
glwagner d61ec24
Fixes wrong filename for include in TimeSteppers
glwagner 7a36d14
Changes x_velocity to u_velocity, etc, in velocity_and_tracer_tendenc…
glwagner 10e1e55
Implements functions for calculating Gu, Gv, Gw on east, north, top b…
glwagner 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
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,130 @@ | ||
""" | ||
u_velocity_tendency(i, j, k, grid, coriolis, surface_waves, | ||
closure, U, C, K, F, pHY′, parameters, time) | ||
|
||
Return the tendency for the horizontal velocity in the x-direction, or the east-west | ||
direction, ``u``, at grid point `i, j, k`. | ||
|
||
The tendency for ``u`` is called ``G_u`` and defined via | ||
|
||
``∂_t u = G_u - ∂_x ϕ_n`` | ||
|
||
where ∂_x ϕ_n is the non-hydrostatic pressure gradient in the x-direction. | ||
|
||
`coriolis`, `surface_waves`, and `closure` are types encoding information about Coriolis | ||
forces, surface waves, and the prescribed turbulence closure. | ||
|
||
The arguments `U`, `C`, and `K` are `NamedTuple`s with the three velocity components, | ||
tracer fields, and precalculated diffusivities where applicable. `F` is a named tuple of | ||
forcing functions, `pHY′` is the hydrostatic pressure anomaly. | ||
|
||
`parameters` is a `NamedTuple` of scalar parameters for user-defined forcing functions | ||
and `time` is the physical time of the model. | ||
""" | ||
@inline function u_velocity_tendency(i, j, k, grid, coriolis, surface_waves, | ||
closure, U, C, K, F, pHY′, parameters, time) | ||
|
||
return ( - div_ũu(i, j, k, grid, U) | ||
- x_f_cross_U(i, j, k, grid, coriolis, U) | ||
- ∂xᶠᵃᵃ(i, j, k, grid, pHY′) | ||
+ ∂ⱼ_2ν_Σ₁ⱼ(i, j, k, grid, closure, U, K) | ||
+ x_curl_Uˢ_cross_U(i, j, k, grid, surface_waves, U, time) | ||
+ ∂t_uˢ(i, j, k, grid, surface_waves, time) | ||
+ F.u(i, j, k, grid, time, U, C, parameters)) | ||
end | ||
|
||
""" | ||
v_velocity_tendency(i, j, k, grid, coriolis, surface_waves, | ||
closure, U, C, K, F, pHY′, parameters, time) | ||
|
||
Return the tendency for the horizontal velocity in the y-direction, or the north-south | ||
direction, ``v``, at grid point `i, j, k`. | ||
|
||
The tendency for ``v`` is called ``G_v`` and defined via | ||
|
||
``∂_t v = G_v - ∂_y ϕ_n`` | ||
|
||
where ∂_y ϕ_n is the non-hydrostatic pressure gradient in the y-direction. | ||
|
||
`coriolis`, `surface_waves`, and `closure` are types encoding information about Coriolis | ||
forces, surface waves, and the prescribed turbulence closure. | ||
|
||
The arguments `U`, `C`, and `K` are `NamedTuple`s with the three velocity components, | ||
tracer fields, and precalculated diffusivities where applicable. `F` is a named tuple of | ||
forcing functions, `pHY′` is the hydrostatic pressure anomaly. | ||
|
||
`parameters` is a `NamedTuple` of scalar parameters for user-defined forcing functions | ||
and `time` is the physical time of the model. | ||
""" | ||
@inline function v_velocity_tendency(i, j, k, grid, coriolis, surface_waves, | ||
closure, U, C, K, F, pHY′, parameters, time) | ||
|
||
return ( - div_ũv(i, j, k, grid, U) | ||
- y_f_cross_U(i, j, k, grid, coriolis, U) | ||
- ∂yᵃᶠᵃ(i, j, k, grid, pHY′) | ||
+ ∂ⱼ_2ν_Σ₂ⱼ(i, j, k, grid, closure, U, K) | ||
+ y_curl_Uˢ_cross_U(i, j, k, grid, surface_waves, U, time) | ||
+ ∂t_vˢ(i, j, k, grid, surface_waves, time) | ||
+ F.v(i, j, k, grid, time, U, C, parameters)) | ||
end | ||
|
||
""" | ||
w_velocity_tendency(i, j, k, grid, coriolis, surface_waves, | ||
closure, U, C, K, F, parameters, time) | ||
|
||
Return the tendency for the vertical velocity ``w`` at grid point `i, j, k`. | ||
The tendency for ``w`` is called ``G_w`` and defined via | ||
|
||
``∂_t w = G_w - ∂_z ϕ_n`` | ||
|
||
where ∂_z ϕ_n is the non-hydrostatic pressure gradient in the z-direction. | ||
|
||
`coriolis`, `surface_waves`, and `closure` are types encoding information about Coriolis | ||
forces, surface waves, and the prescribed turbulence closure. | ||
|
||
The arguments `U`, `C`, and `K` are `NamedTuple`s with the three velocity components, | ||
tracer fields, and precalculated diffusivities where applicable. `F` is a named tuple of | ||
forcing functions, `pHY′` is the hydrostatic pressure anomaly. | ||
|
||
`parameters` is a `NamedTuple` of scalar parameters for user-defined forcing functions | ||
and `time` is the physical time of the model. | ||
""" | ||
@inline function w_velocity_tendency(i, j, k, grid, coriolis, surface_waves, | ||
closure, U, C, K, F, parameters, time) | ||
|
||
return ( - div_ũw(i, j, k, grid, U) | ||
- z_f_cross_U(i, j, k, grid, coriolis, U) | ||
+ ∂ⱼ_2ν_Σ₃ⱼ(i, j, k, grid, closure, U, K) | ||
+ z_curl_Uˢ_cross_U(i, j, k, grid, surface_waves, U, time) | ||
+ ∂t_wˢ(i, j, k, grid, surface_waves, time) | ||
+ F.w(i, j, k, grid, time, U, C, parameters)) | ||
end | ||
|
||
""" | ||
tracer_tendency(i, j, k, grid, c, tracer_index, closure, buoyancy, U, C, K, Fc, | ||
parameters, time) | ||
|
||
Return the tendency for a tracer field `c` with index `tracer_index` | ||
at grid point `i, j, k`. | ||
|
||
The tendency for ``c`` is called ``G_c`` and defined via | ||
|
||
``∂_t c = G_c`` | ||
|
||
`closure` and `buoyancy` are types encoding information about the prescribed | ||
turbulence closure and buoyancy model. | ||
|
||
The arguments `U`, `C`, and `K` are `NamedTuple`s with the three velocity components, | ||
tracer fields, and precalculated diffusivities where applicable. | ||
`Fc` is the user-defined forcing function for tracer `c`. | ||
|
||
`parameters` is a `NamedTuple` of scalar parameters for user-defined forcing functions | ||
and `time` is the physical time of the model. | ||
""" | ||
@inline function tracer_tendency(i, j, k, grid, c, tracer_index, | ||
closure, buoyancy, U, C, K, Fc, parameters, time) | ||
|
||
return ( - div_uc(i, j, k, grid, U, c) | ||
+ ∇_κ_∇c(i, j, k, grid, closure, c, tracer_index, K, C, buoyancy) | ||
+ Fc(i, j, k, grid, time, U, C, parameters)) | ||
end |
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.
I thought
model.parameters
could be anything passed in by the user, although we usually use named tuples (so do most people for these kinds of parameters).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.
That's true about
model.parameters
--- except that kernels will fail to compile on the GPU unless it only contains simple objects.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.
Hmm, ok, I will change the docstring to be more accurate.
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 we're planning to get rid of
model.parameters
but whatever we replace it (e.g.model.forcing.parameters
) with should probably work the same way for writing forcing functions so thankfully the docstrings will still be correct then.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.
Should we merge this and address when we address #682 ?