Linear Semi-Lagrangian Vertical Transport - #777
James Kent (jameskent-metoffice) wants to merge 2 commits into
Conversation
|
Your CLA signature was found on the base branch, but you appear to have modified the CONTRIBUTORS.md file in this PR. Please do not edit the CONTRIBUTORS.md file. If you have already signed the CLA, revert changes to the file and your signature will be picked up. |
DanStoneMO
left a comment
There was a problem hiding this comment.
Testing with JEDI and it works fine. No linked PR needed for it
cjohnson-pi
left a comment
There was a problem hiding this comment.
Thanks James for adding this SL code. I just have a couple of comments from a linear code owner perspective.
| !! contribution from the gradient of the ls field in the | ||
| !! departure cell. | ||
| !> @param[in] nlayers The number of layers | ||
| !> @param[in,out] field The perturbation field to be advected |
There was a problem hiding this comment.
Please could you add ACTIVE/PASSIVE
| @@ -0,0 +1,100 @@ | |||
| !----------------------------------------------------------------------------- | |||
There was a problem hiding this comment.
Note: In addition to this test, we also need to test the validity of the linearisation. I will allow this to be added on a separate ticket - and so I have added it to issue #507
| w2_idx = map_w2(1) | ||
| wc_idx = map_wc(1) | ||
|
|
||
| ! Create local arrays |
There was a problem hiding this comment.
Please could the code be reordered so that PASSIVE fields (such as ls_field_local and grad_ls_field) are all computed first, followed by the ACTIVE fields. This will allow for easier implementation of the corresponding adjoint code.
| + cubic_coef_4(wc_idx : wc_idx+nl-1)*field_local(:,4) & | ||
| ) | ||
|
|
||
| ! Compute gradient of ls_field in departure cell |
There was a problem hiding this comment.
Please can you review the comments in the code to make sure that they actually reflect the code. For example, for a gradient I would expect a dividing by the distance between the points. But I think this must be incorporated into the departure distance number. I always get confused with the departure distance in LFRic - is it a distance, a velocity, a Courant number?
| ffsl_vertical_order=5*1 | ||
| horizontal_method=2,1,2,2,2 | ||
| log_space=.false.,.true.,.false.,.false.,.false. | ||
| log_space=5*.false. |
There was a problem hiding this comment.
Can you just note here why this has changed from true to false. Is it because the target is to have 5*false and this is a permanent change, or is it because the log-space code is still to be created and this is temporary.
Thomas Bendall (tommbendall)
left a comment
There was a problem hiding this comment.
I'm happy with the science and have just suggested fixing some typos and a couple of very trivial syntactical suggestions (which proves I've read the PR)
If you can address cjohnson-pi's comments, I'll be happy to approve
| !----------------------------------------------------------------------------- | ||
| ! | ||
| !------------------------------------------------------------------------------- | ||
| !> @brief Kernel to compute the vertical cubic semi-Lagragian advection of a field |
There was a problem hiding this comment.
| !> @brief Kernel to compute the vertical cubic semi-Lagragian advection of a field | |
| !> @brief Kernel to compute the vertical cubic semi-Lagrangian advection of a field |
| !> @brief Kernel to compute the vertical cubic semi-Lagragian advection of a field | ||
| !! in the vertical direction for the linear model. | ||
| !> @Details The 1D vertical advective transport equation for a W3/Wtheta variable | ||
| !! is solved using a cubic semi-Lagragian advection scheme. There are two |
There was a problem hiding this comment.
| !! is solved using a cubic semi-Lagragian advection scheme. There are two | |
| !! is solved using a cubic semi-Lagrangian advection scheme. There are two |
| ! Compute gradient of ls_field in departure cell | ||
| grad_ls_field(:) = ls_field_local(:,2)-ls_field_local(:,1) | ||
|
|
||
| ! Compute pert dist based on whether this is W3 or W3theta field |
There was a problem hiding this comment.
| ! Compute pert dist based on whether this is W3 or W3theta field | |
| ! Compute pert dist based on whether this is W3 or Wtheta field |
| ! Compute pert dist based on whether this is W3 or W3theta field | ||
| if (ndf_wf == 1) then | ||
| ! W3 field so require pert dist averaged to W3 point | ||
| pert_dist(1:nlayers) = ( dep_dist_pert(w2_idx : w2_idx + nlayers - 1) & |
There was a problem hiding this comment.
| pert_dist(1:nlayers) = ( dep_dist_pert(w2_idx : w2_idx + nlayers - 1) & | |
| pert_dist(:) = ( dep_dist_pert(w2_idx : w2_idx + nlayers - 1) & |
I think also works
| + dep_dist_pert(w2_idx + 1 : w2_idx + nlayers) ) / 2.0_r_tran | ||
| else | ||
| ! Wtheta field so can use pert dist at W2v point | ||
| pert_dist(1:nl) = dep_dist_pert(w2_idx : w2_idx + nl - 1) |
There was a problem hiding this comment.
| pert_dist(1:nl) = dep_dist_pert(w2_idx : w2_idx + nl - 1) | |
| pert_dist(:) = dep_dist_pert(w2_idx : w2_idx + nl - 1) |
I think also works
PR Summary
Sci/Tech Reviewer: Thomas Bendall (@tommbendall)
Code Reviewer: Oakley Brunt (@oakleybrunt)
This adds the semi-Lagrangian (SL) vertical transport to the linear model. The FFSL linear transport scheme has issues with potential temperature, partly because it is a Wtheta variable that FFSL puts on the shifted mesh. One way around this is to use the SL transport as this works on the native mesh.
The full SL vertical transport scheme solves the advection equation$dq/dt + w dq/dz = 0$ by interpolating the field to the departure point $q^{n+1}_a = q^{n}_d$ , where $q$ is the field, $w$ is the vertical velocity, $n$ is the time index, and subscript $a$ and $d$ are the arrival and departure points respectively.
For the linear model we write the variables in terms of the linearisation state,$\bar{q}$ and $\bar{w}$ , and the perturbation state, $q'$ and $w'$ , and hence the advection equation now becomes
which, when removing the transport of$\bar{q}$ with $\bar{w}$ , gives the advection equation for the perturbation field
The first terms can be computed using the standard SL scheme with the linearisation state wind, and the last term can be computed using the perturbation departure point (as this is the perturbation Courant number) multiplied by the gradient of$\bar{q}$ in the departure cell (note this is in the linearisation state departure cell)
where$\delta' = w' \Delta{t} / \Delta{z}$ and $\nabla \bar{q}$ is computed using the difference of $\bar{q}$ values either side of the departure point.
Note that I did not start this branch from stable as I wanted to pick up the fixes to linear MoL in PR543.
Code Quality Checklist
Testing
There are kgo changes in the linear model app as I have changed the vertical transport for the FFSL tests to use the SL scheme (instead of MoL) for potential temperature.
Below shows the linear DCMIP gravity wave test with the vertical SL scheme for theta.
This can be compared with using MoL for theta (below).
trac.log
For some reason there are two lfricinputs failures. As my ticket does not touch any part of this code, I believe that it is unrelated to my PR.
Test Suite Results - lfric_apps - linear_vert_sl/run2
Suite Information
Task Information
❌ failed tasks - 2
⌛ waiting tasks - 1
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review