Skip to content

Correct sign in FCT 3rd order advection coefficients - #656

Merged
mattdturner merged 3 commits into
MPAS-Dev:developfrom
mark-petersen:framework/correct_FCT_adv_coefs_3rd
Sep 2, 2020
Merged

mattdturner merged 3 commits into
MPAS-Dev:developfrom
mark-petersen:framework/correct_FCT_adv_coefs_3rd

Conversation

@mark-petersen

Copy link
Copy Markdown
Contributor

Two third-order advection coefficients incorrectly have a plus sign, should be minus. Thanks to @ambrad for his work on this. See discussion at this issue: #583 (comment)

Note that this is a framework merge, but the ocean is the only core that calls the subroutine, mpas_tracer_advection_coefficients, that initializes the FCT cell weights. The atmosphere has nearly identical lines in src/core_atmosphere/mpas_atm_core.F, subroutine atm_adv_coef_compression, which is clearly where this code was originally copied from in 2013.

Also copied comments from the atmospheric core to better explain each term, and cleaned up other comments.

if(k <= nAdvCellsForEdge(iEdge)) then
adv_coefs(k, iEdge) = adv_coefs(k, iEdge) + deriv_two(1,2,iEdge)
adv_coefs_3rd(k, iEdge) = adv_coefs_3rd(k, iEdge) + deriv_two(1,2,iEdge)
adv_coefs_3rd(k, iEdge) = adv_coefs_3rd(k, iEdge) - deriv_two(1,2,iEdge)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Compare to corresponding line for atmosphere, which has a minus sign:

adv_coefs_3rd(j_in,iEdge) = adv_coefs_3rd(j_in,iEdge) - deriv_two(1,2,iEdge)

https://github.com/MPAS-Dev/MPAS-Model/blob/master/src/core_atmosphere/mpas_atm_core.F#L1225

if(k <= nAdvCellsForEdge(iEdge)) then
adv_coefs(k, iEdge) = adv_coefs(k, iEdge) + deriv_two(iCell+1, 2, iEdge)
adv_coefs_3rd(k, iEdge) = adv_coefs_3rd(k, iEdge) + deriv_two(iCell+1, 2, iEdge)
adv_coefs_3rd(k, iEdge) = adv_coefs_3rd(k, iEdge) - deriv_two(iCell+1, 2, iEdge)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Compare to corresponding line for atmosphere, which has a minus sign:

adv_coefs_3rd(j_in,iEdge) = adv_coefs_3rd(j_in,iEdge) - deriv_two(iCell+1,2,iEdge)

https://github.com/MPAS-Dev/MPAS-Model/blob/master/src/core_atmosphere/mpas_atm_core.F#L1233

@mark-petersen

Copy link
Copy Markdown
Contributor Author

@vanroekel and @ambrad, I am testing in various configurations of MPAS-Ocean and will report here. Please post reports of your testing here as well. Also note, @ambrad already conducted convergence tests here #583 (comment) that show improvements with this bug fix.

@mark-petersen

Copy link
Copy Markdown
Contributor Author

@mgduda @matthewhoffman @akturner please add yourselves as reviewers if you like. This is in the operators subdirectory, but the ocean is the only core that calls this subroutine.

@ambrad

ambrad commented Aug 20, 2020 •

Copy link
Copy Markdown

It might be useful to future code readers to add one further comment to the helpers.F code, something along the lines of this:

adv_coefs accounts for terms 1 and 2 in SG11 equation 7. Term 1 is the 2nd-order flux-function term. adv_coefs accounts for this with the "+ 0.5" lines. In the advection routines that use these coefficients, the 2nd-order flux loop is then skipped. Term 2 is the 4th-order flux-function term. adv_coefs_3rd accounts for term 3, the beta term. beta > 0 corresponds to the third-order flux function. The - sign in the deriv_two accumulation is for the i+1 part of term 3, while the + sign is for the i part.

@mark-petersen

Copy link
Copy Markdown
Contributor Author

Done. Thanks for the text @ambrad. That was perfect. I even added a text version of eqn 7 for reference to help the reader.

@ambrad

ambrad commented Aug 20, 2020 •

Copy link
Copy Markdown

Testing was done in two ways. First, I developed a standalone code (part of other ongoing work) that implements these Eulerian flux-form methods. This code revealed some interesting patterns, described in this comment and repeated below. Second, once I knew what I was looking for, I ran the new MPAS-Ocean test of solid-body rotation of a cosine bell. This is described in this comment and again for convenience transcribed below.

Observations from standalone testing:

  1. On a smooth quasiuniform grid (standard icosahedral grid, i.e., 10 pentagons at icosahedron vertices), all three flux functions -- 2nd-, 3rd-, 4th-order -- are empirically 2nd-order accurate on this test.
  2. On a nonsmooth quasiuniform grid, e.g. one produced by Jigsaw, the 2nd- and 4th-order EFF methods empirically degrade to OOA ~1, while the 3rd-order EFF degrades only a small amount below OOA 2.

MPAS-Ocean testing:

  1. I ran one full rotation of the cosine bell for 240, 120, 60km Jigsaw-created grids, with 720, 1440, 2880 time steps, respectively. I used RK4 as the time integration scheme.
  2. I ran 2nd-, 3rd-, 4th-order flux functions, with the 3rd-order one both before and after the fix. I also ran 3rd-order after the fix with monotone advection rather than standard.
  3. Results are as follows, where errors are RMSE as reported by compute_rmse.py in the linked PR:
order-2 flux               [0.04306733 0.0151201  0.00483401] OOA ~ 1.6
order-3 flux beta=1        [0.01030493 0.00226823 0.00050179] OOA > 2
order-3 flux beta=1/4      [0.00471197 0.00106989 0.00028895] OOA 1.9-2.1
order-3 flux beta=1/4 mono [0.00513074 0.00109597 0.00027202] OOA > 2
order-4 flux               [0.0071832  0.00447862 0.00253661] OOA < 1
order-3 flux beta=1/4, wrong sign in ..._helpers.F
                           [0.01326037 0.01270969 0.03431614] nonconvergent

@ambrad

ambrad commented Aug 20, 2020

Copy link
Copy Markdown

@mark-petersen, thanks for adding the comment. Just to be clear, the minus sign in term 3 does not correspond to the - in the deriv_two accumulation. Rather, there are layers of negatives such that it's the i+1 part of term 3 that leads to the - deriv_two.

@vanroekel

vanroekel commented Aug 20, 2020 •

Copy link
Copy Markdown
Contributor

@ambrad and @mark-petersen this looks great. here are two snapshots from a G-case without the fix first then with. These are salinity at 250m from high frequency
Screen Shot 2020-08-20 at 3 51 59 PM

Screen Shot 2020-08-20 at 3 52 08 PM

@vanroekel

Copy link
Copy Markdown
Contributor

this is 2.5 years into a G-case by the way

@stephenprice

Copy link
Copy Markdown
Contributor

Are these two images supposed to be identical?

@ambrad

ambrad commented Aug 21, 2020 •

Copy link
Copy Markdown

@stephenprice they are not. The top image shows small-scale features when the flux function has the sign bug. In the bottom, these are gone. It's possible the features themselves are due to the sign bug, or it's possible they are now dissipated by the now-correct 4th-order hyperdiffusion (SG11 eq 9) produced by the third-order flux function.

@vanroekel you might try a simulation pair with the most extreme, Jigsaw-produced, RRM-like grid you have to look at beta=0.25 vs beta=1.0 with the sign fix. It's possible that beta=1.0 could be best for extremely nonuniform, nonsmooth grids.

@stephenprice

Copy link
Copy Markdown
Contributor

Thanks @ambrad. I see the differences now that you point them out.

@mark-petersen

Copy link
Copy Markdown
Contributor Author

@vanroekel and @jamilgafur, would it be possible to rerun your advection convergence tests with these two changes? Getting the correct behavior and order of convergence on those tests would be a great confirmation of this change. I know @jamilgafur might be back in school next week.

@vanroekel

Copy link
Copy Markdown
Contributor

@mark-petersen sure, I can run the case in #583 and post convergence here

@ambrad

ambrad commented Aug 28, 2020

Copy link
Copy Markdown

@vanroekel, I'll collect a few notes here re: the #583 convergence test:

  • split_explicit should be switched to RK4.
  • Currently, all three grids use the same 5min time step. For convergence analysis, I recommend a sequence of 30min, 15min, 7.5min.
  • In your OOA script, I believe you should multiply the "Order of Convergence" numbers by d=2, the dimension of the grid. Each mesh refinement step increases the number of cells by 4, which means a refinement of sqrt(4)=2 in each direction.
  • I was not able to get a good reading of OOA 2 until I lengthened the test to run one full rotation. Part of the challenge of convergence testing is being sure the test shows results in the asymptotic regime.
  • That aside, a plot showing before-fix vs after-fix results should have a clear signal independent of any of the above details.

@vanroekel

Copy link
Copy Markdown
Contributor

Here is the OOA for the current code
convergence

Here is with this PR
convergenceFix

@vanroekel vanroekel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

approved by advection convergence test result

@mattdturner

Copy link
Copy Markdown
Collaborator

@mgduda I would like to merge this today. I wasn't brought into the loop on this PR until recently, so I'm not sure if you've weighed in or not. Can you confirm whether or not you want to review this. @mark-petersen asked if you wanted to review in #656 (comment)

@mgduda

mgduda commented Sep 2, 2020

Copy link
Copy Markdown
Contributor

@mattdturner Thanks very much for checking. I haven't thoroughly reviewed the code changes with context, but the convergence results are convincing enough for me. I won't add myself as a reviewer, but I have no objections to merging this today.

@mattdturner
mattdturner merged commit 965d0f4 into MPAS-Dev:develop Sep 2, 2020
mattdturner added a commit that referenced this pull request Sep 2, 2020
* develop:
  Correct sign in FCT 3rd order advection coefficients #656
jonbob added a commit to E3SM-Project/E3SM that referenced this pull request Sep 2, 2020
…to next (PR #3809)

Update mpas-source: bugfix 3rd order advection coeff

This PR brings in a new mpas-source submodule with changes only to the
MPAS operators. It fixes a bug in MPAS third-order advection coefficients,
where the coefficients incorrectly have a plus sign instead of a minus.

See MPAS-Dev/MPAS-Model#656

[non-BFB]
jonbob added a commit to E3SM-Project/E3SM that referenced this pull request Sep 3, 2020
…#3809)

Update mpas-source: bugfix 3rd order advection coeff

This PR brings in a new mpas-source submodule with changes only to the
MPAS operators. It fixes a bug in MPAS third-order advection coefficients,
where the coefficients incorrectly have a plus sign instead of a minus.

See MPAS-Dev/MPAS-Model#656

[non-BFB]
@mark-petersen
mark-petersen deleted the framework/correct_FCT_adv_coefs_3rd branch September 14, 2020 21:51
sael9740 pushed a commit to sael9740/MPAS-Model that referenced this pull request Oct 9, 2026
…3rd' into develop

Two third-order advection coefficients incorrectly have a plus sign, should be minus. Thanks to @ambrad for his work on this. See discussion at this issue: MPAS-Dev#583 (comment)

Note that this is a framework merge, but the ocean is the only core that calls the subroutine, mpas_tracer_advection_coefficients, that initializes the FCT cell weights. The atmosphere has nearly identical lines in src/core_atmosphere/mpas_atm_core.F, subroutine atm_adv_coef_compression, which is clearly where this code was originally copied from in 2013.

Also copied comments from the atmospheric core to better explain each term, and cleaned up other comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants