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

Fixes for visc_rem in split mode #639

Merged
merged 8 commits into from
Jun 6, 2024

Conversation

herrwang0
Copy link

@herrwang0 herrwang0 commented May 17, 2024

Description

This PR aims to solve the problem that visc_rem term is incorrectly applied in the split mode. There are three issues identified:

  1. vertvisc_remnant() call at the end of the predictor stage uses dt_pred, while the calculations visc_rem_[uv] is applied to (continuity() and btstep()) use dt. This results in undercounting (baroclinic) vertical viscous term in the barotropic solver.
  2. In barotropic solver, wt_[uv], a function of visc_rem_[uv], is not normalized by the vertically-integrated vertical viscosity. This results in doublecounting (baroclinic) vertical viscous term in the barotropic solver.
  3. In continuity solver, velocity cell thickness BT_cont%h_[uv] from zonal_flux_thickness() and meridional_flux_thickness() calls are multiplied by visc_rem_[uv] if present. Currently, BT_cont%h_[uv] is only used in calculating frhat[uv], a normalized thickness weight parameter used in a) calculating vertical weights aforementioned wt_[uv], which is already multiplying visc_rem_[uv]. b) calculating vertical averaged visc_rem_[uv], which should just use thickness as weights.
    Besides, for options other than BT_cont, frhat[uv] calculation is not based on visc_rem modified thickness.

The three newly-added runtime flags VISC_REM_TIMESTEP_FIX, VISC_REM_BT_WEIGHT_FIX, and VISC_REM_CONT_HVEL_FIX, fix the three issues, respectively.

Issue 1 and 2 are directly responsible for mismatching barotropic velocities from the barotropic solver and baroclinic steps.
Issue 3 is more subtle as it has a negligible effect in the test case. But physically it seems that the fix makes more sense.

An idealized test case

The fixes are tested in "flow downslope" style run, but with only 1 layer.
Fig.1 Comparison of velocity from barotropic solver and baroclinic steps
pr_compare_ts_split_fixcont

Fig.2 Comparison of unsplit (used as a reference for "truth"), old and fix
compare_dyncores_dt20s_u


As it stands, all flags are defaulted to be False, so no answer changes are expected. Turning them on will obviously change the answer.

Some minor points:

  • Tentatively, these flags have the appendix of "_FIX" rather than using the opposite (and more assertive) "_BUG". Let me know if the latter is more preferred and less confusing.
  • Answer date flag is not yet used in this PR. It may be helpful tool in the future to make sure these three flags are adopted together.

herrwang0 added 6 commits May 6, 2024 11:13
The "eta has dropped below bathT" warning message has indices off by 1.
This is because G%isd_global = G%isd + HI%idg_offset and G%isd is
(most of the time) 1.

G%isd_global/G%jsd_global are now replaced by
G%HI%idg_offset/G%HI%jdg_offset.
Add an option to normalize wt_[uv] in the barotropic solver. This is
fix step 1 of 2 to address the issue that visc_rem is applied
incorrectly to the barotropic solver.

A runtime flag BAROTROPIC_VERTICAL_WEIGHT_FIX is added to control the
behavior of this commit. The current default is false (not applying the
fix).
Add an option to use `dt` instead of `dt_pred` in the calculation of
vertvisc_remnant() at the end of predictor stage. The change affects
the following `continuity`() call and `btstep`() call in corrector step.

Combined with the changes from the previous commit, the new options
should solve the issue of inconsistent barotropic velocities from
barotropic solver and baroclinic step.

A runtime flag VISC_REM_TIMESTEP_FIX is added to control the behavior of
 this commit. The current default is false (not applying the fix).
This commit is the third fix related to visc_rem in split mode. h_[uv]
from `zonal_flux_thickness`() and `meridional_flux_thickness`() is
currently multiplied by `visc_rem_[uv]`. This seems to be
double-counting as `visc_rem_[uv]` is accounted for in the barotropic
solver vertical weights. Moreover, for options other than BT_cont, the
velocity point thickness does not include visc_rem. The fix removes the
visc_rem factor from h_[uv] when BT_cont is used.

A runtime flag VISC_REM_CONT_HVEL_FIX is added to control the behavior
 of this commit. The current default is false (not applying the fix).

Other small changes:
* Write out explicitly all keyword arguments in `continuity`() calls
in MOM_dynamics_split_RK2.
* Rename a runtime parameter BAROTROPIC_VERTICAL_WEIGHT_FIX from a
previous commit to  VISC_REM_BT_WEIGHT_FIX, to be consistent with the
style of the other two flags.
* Add VISC_REM_TIMESTEP_FIX parameter to MOM_dynamics_split_RK2b
Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.85%. Comparing base (270ba59) to head (6a49189).

Current head 6a49189 differs from pull request most recent head 7bc0d51

Please upload reports for the commit 7bc0d51 to get more accurate results.

Additional details and impacted files
@@             Coverage Diff              @@
##           dev/gfdl     #639      +/-   ##
============================================
- Coverage     36.89%   35.85%   -1.05%     
============================================
  Files           271      268       -3     
  Lines         81627    80183    -1444     
  Branches      15259    15139     -120     
============================================
- Hits          30119    28749    -1370     
+ Misses        45861    45750     -111     
- Partials       5647     5684      +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@herrwang0 herrwang0 marked this pull request as ready for review May 22, 2024 20:21
@herrwang0 herrwang0 changed the title Fix mismatching barotropic velocities from the barotropic solver Fixes for visc_rem in split mode May 22, 2024
@herrwang0 herrwang0 force-pushed the add_visc_rem_patches branch from 02cb60f to af64503 Compare June 3, 2024 20:24
* Correct a bug using dimensional h_neglect in calculating
non-dimensional Iwt_[uv]_tot, by replacing the division with
an Adcroft_reciprocal style division.

* Add a parameter VISC_REM_BUG to control the defaults of all three
viscous remnant bug related parameters. The individual parameters should
 be removed in the future.
@herrwang0 herrwang0 force-pushed the add_visc_rem_patches branch from af64503 to d7489ec Compare June 5, 2024 17:27
Copy link
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

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

With the latest updates, this PR is now looking good to me.

@marshallward
Copy link
Member

@herrwang0 Did you want me to retain all of these commits? I wasn't able to tell if all of them were valid or not.

@herrwang0
Copy link
Author

@marshallward Please do, they are all valid.

@marshallward
Copy link
Member

Gaea regression: https://gitlab.gfdl.noaa.gov/ogrp/mom6ci/MOM6/-/pipelines/23752 ✔️ 🟡

@marshallward marshallward merged commit 09774d4 into NOAA-GFDL:dev/gfdl Jun 6, 2024
10 checks passed
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