Skip to content

Remove unused vertical mixing schemes #557

Closed

Description

@xylar

Since we now only use CVMix, the rich vertical mixing scheme and perhaps others should be removed so we don't have to maintain code we don't use.

Activity

  1. vanroekel commented on May 13, 2020

    @vanroekel
    Contributor

    I agree with @xylar, we should remove the extra schemes. The functionality of all other schemes exists in cvmix. @mark-petersen if you agree, I could put this on my todo list to clean up.

  2. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    @xylar, I'm very much against this because @mark-petersen, @vanroekel, and I used this to do debugging of the noise issue when ENSO was broken. I recognize it is painful to have this type of code in the repo, but not having the option to use does cause a potential problem.

    This being said, if we were able to "swap" this out by replacing the functionality with a proper GOTM implementation, which is in ICoM and @qingli411 is starting to work with @vanroekel and myself, then this seems like the best approach forward because then we would just need to support the single GOTM vertical mixing API, which will give us CVMIX, @vanroekel 's new scheme, etc.

    @vanroekel and @mark-petersen, please speak up if I've mangled something here. There may be some details in the GOTM/CVMIX implementation that may need sorted out.

  3. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    @vanroekel, looks like we were writing at the same time-- we have P&P and Richardson mixing in CVMIX now? If so, I agree we can remove.

    To clarify, the shift to GOTM is expected to include all the current functionality in CVMIX, right?

  4. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    The bottom line is we need to maintain different physical vertical mixing schemes, minimally for debugging but also to have the science capability available for different cases. For instance, SOMA does not and should not use KPP.

  5. xylar commented on May 13, 2020

    @xylar
    CollaboratorAuthor

    @pwolfram, my understanding is that Richardson is fully supported in CVMix and there's no reason to use the MPAS implementation. If we still are, we shouldn't be because it hasn't been getting proper maintenance for a long time already.

  6. vanroekel commented on May 13, 2020

    @vanroekel
    Contributor

    @pwolfram, yes to both questions. Currently CVMix includes PP81 and LMD94 Ri mixing, it also has the Bryan and lewis constant mixing which can replace the tanh mixing, and certainly uniformly constant.

    and yes once @qingli411 finishes incorporation of the new GOTM we will have all of CVMix plus the GOTM family of 2-equation models.

  7. vanroekel commented on May 13, 2020

    @vanroekel
    Contributor

    I'd also add that I'm not terribly convinced the testing we did with other vertical mixing schemes was helpful for the ENSO issue. However, the move toward all of this living in GOTM is a good one in my view.

  8. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    The last question I have is how much will we trust / be sure we don't have latent bugs in the CVMIX / GOTM implementations? Ideally no, practically probably. If so, assuming Richardson still works, we may want to keep it around to make sure we are at least qualitatively consistent with CVMIX.

    For example, if we only have one mixing scheme via GOTM/CVMIX, what happens if there is a hidden bug in this implementation? We won't have an easy way to cross-check it against an existing set of tested code.

    @vanroekel, I agree, the vertical mixing testing wasn't too helpful-- but, that was because it wasn't the issue. One can imagine multiple scenarios where this could be a real problem that produces a pernicious bug in at least the ocean or likely the coupled system.

    We can alleviate these concerns via some type of unit testing for CVMIX/GOTM, but to the best of my knowledge we really don't have this type of testing infrastructure or approach and bugs in CVMIX that have come up have appeared to be solved more on an ad hoc basis, meaning we don't have solid coverage for certainty that the interface is completely working. If this is the case, playing devil's advocate, then we shouldn't remove Richardson.

    This is a question about the trade off between maintenance, which could be highly onerous as more code changes are made (especially for performance), and testing of existing vertical mixing schemes, of which there are probably better approaches that are already in place or could be put in place.

  9. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    And my personal take on this is I would like to see all our mixing be in GOTM with the CVMIX hook under a testing infrastructure that makes us fully comfortable under the scope of science we support and will do, recognizing no testing suite is ever 100% and we will have to hold some degree of risk to be successful here. In this "world", we don't need ad-hoc mixing scheme implementations because these make our code look "hacky" and make it harder to collaborate with others.

  10. vanroekel commented on May 13, 2020

    @vanroekel
    Contributor

    The current RICH / TANH / CONST mixing code does not give me any comfort or a decent test case for the CVMix implementations. All three of those are trivial mixing schemes to implement. The most complex code in CVMix by far is KPP. The others are simple polynomial formations fixed in time and I don't see how maintaining them helps debug cvmix. I would also strongly disagree that the debugging of the CVMix interface has been "ad hoc". It was a detailed comparison vs. LES and against the LMD94 "theory". I am highly dubious that a unit testing framework would have been better/more efficient. So, In my view continuing to maintain the current non CVMix code is much more onerous than any benefits it may have.

    I'm not sure how I feel about all of our code being in GOTM for mixing eventually. There are other issues to consider, e.g. performance. But where mixing code lives ultimately is far afield from this issue.

  11. xylar commented on May 13, 2020

    @xylar
    CollaboratorAuthor

    @pwolfram, I'd like to chat a bit offline about this before continuing the conversion. Please respond on Slack if you get a chance.

  12. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    Thanks @xylar and @vanroekel my concern was related to various bugs you've found and described to me in CVMIX over the years, especially related to the vertical indices, empty or incorrect values, etc. I wasn't suggesting the process to debug it was done incorrectly and to be fair have said and continue to think your analysis is perhaps the most comprehensive one to date. I am not concerned with the science or its embodiment in code here. I'm concerned about unknown unknowns and having tools to protect us against this risk.

    The concern, if any, is whether our existing knowledge is formalized in a regression-suite style, full-coverage (if such a thing is possible) test suite that someone without detailed knowledge can run and use to protect the good work that has already been done and as a debugging tool when more complex simulations we run have issues (e.g, to make sure changes don't break this core functionality).

    Given we don't have robust vertical mixing testing outside CVMIX, we can remove that code and move onward but this doesn't alleviate the broader concern of more comprehensive testing (which applies to other parts of the code not discussed here too).

    For instance, if I change something in MPAS-O and the existing CVMIX test case is no longer BFB, do I have a clear idea of what went wrong just from the test case failing? I recognize this is a high bar but this is my point-- for a critical piece of the code like this it would be good to have this certainty in terms of testing if possible, especially as we consider doing more complex things like going from deep to shallow water and vice versa. This will be especially needed to help facilitate performance work but perhaps the BFB approach we have now is enough. Perhaps a more complete testing suite is too impractical given other constraints. Likely there is a middle ground to find here that makes sense unless the answer is we are already confident enough in the automated testing. Does this make more sense?

    My fundamental concern is how do we know the code we have works and is robust to other changes in the code in terms of some type of automated confirmation? For instance, if we change the vertical mesh, could we qualitatively make sure we don't somehow break the vertical mixing? A follow-on question depending upon the answer would be, "Does this code need generalized and put on the development timeline as fundamental to other science questions?" These are the types of questions I'd like to see readily answerable or at least informed in terms of a clearer "I ran a script and it passed/failed" type result. The concern is obviously much more general than vertical mixing and readily extends to other code like wetting / drying, online diagnostics, etc.

  13. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    My vote:

    Remove the code as recommended here but revisit this higher-level concern of testing for core pieces of the code like vertical mixing (and in the future wetting / drying and high-order pressure gradients) that have potential wide-spread changes to the simulations due to bug senstivities.

  14. 1 remaining item

  15. philipwjones commented on May 13, 2020

    @philipwjones
    Contributor

    Late to the discussion here, but in my previous attempt at GPU porting of all this vmix code, I even discussed with Mark and Luke that these be eliminated at that time. The capabilities exist in almost identical form in cvmix - PP has a slightly different form in each - but the functionality can certainly be captured in the current code with a suitable cvmix configuration. I purposely stopped converting these routines to GPU-enabled form, assuming it'll be replaced soon, but whatever path we take, I hope it includes cleanup/removal of this duplicate code.

  16. pwolfram commented on May 13, 2020

    @pwolfram
    Contributor

    @philipwjones, so you vote 'yes' to removal too?

  17. philipwjones commented on May 13, 2020

    @philipwjones
    Contributor

    Yup. And a replacement for cvmix too. ;^)

  18. mark-petersen commented on May 18, 2020

    @mark-petersen
    Contributor

    I agree, we should remove code that is not used, or that is redundant. Some general comments:

    1. The simple vmix modules were only nice because it was obvious how they work. But simplicity is not a substitute for testing, and then we had redundant methods anyway. When we use an external package like cvmix, it is even more important to have testing for each term and setting, so I'm happy that @vanroekel and @jamilgafur are adding these.
    2. Test cases in COMPASS that use the simple vmix settings will need to be changed.

    These are replace by cvmix, and the main topic of discussion here:

    &vmix_const
        config_use_const_visc = .false.
        config_use_const_diff = .false.
        config_vert_visc = 1.0e-4
        config_vert_diff = 1.0e-5
    /
    &vmix_rich
        config_use_rich_visc = .false.
        config_use_rich_diff = .false.
        config_bkrd_vert_visc = 1.0e-4
        config_bkrd_vert_diff = 1.0e-5
        config_rich_mix = 0.005
    /
    &vmix
        config_convective_visc = 1.0
        config_convective_diff = 1.0
    /
    &vmix_tanh
        config_use_tanh_visc = .false.
        config_use_tanh_diff = .false.
        config_max_visc_tanh = 2.5e-1
        config_min_visc_tanh = 1.0e-4
        config_max_diff_tanh = 2.5e-2
        config_min_diff_tanh = 1.0e-5
        config_zMid_tanh = -100
        config_zWidth_tanh = 100
    /
    

    i.e. remove the flags and associated modules.

    In addition, the tensor formulation of del2 and del4 was something we tried long ago and ended up being noisy, and we never use. I would rather have minimal, well-maintained code than include the kitchen sink. We should remove flags and modules:

    &hmix_del2_tensor
        config_use_mom_del2_tensor = .false.
        config_mom_del2_tensor = 10.0
    /
    &hmix_del4_tensor
        config_use_mom_del4_tensor = .false.
        config_mom_del4_tensor = 5.0e13
    /
    
  19. philipwjones commented on May 18, 2020

    @philipwjones
    Contributor

    I will second the motion to remove the tensor versions - if we're going to support them, they would need a significant rewrite for optimization/GPU support. I skipped them during this first pass so hope they just disappear and we don't have to worry about them.

  20. mark-petersen commented on May 22, 2020

    @mark-petersen
    Contributor

    @vanroekel I'm working on this. I can get a bfb match on runs when I replace

    147 &vmix_const
    148     config_use_const_visc = .true.
    149     config_use_const_diff = .false.
    150     config_vert_visc = 1.0e-4
    151     config_vert_diff = 1.0e-5
    

    with

    109     config_use_cvmix_background = .true.
    110     config_cvmix_background_diffusion = 0.0
    111     config_cvmix_background_viscosity = 1.0e-4
    

    as expected. I wanted to double check with you on the rich/PP. To replace:

    153 &vmix_rich
    154     config_use_rich_visc = .true.
    155     config_use_rich_diff = .true.
    156     config_bkrd_vert_visc = 1.0e-4
    157     config_bkrd_vert_diff = 1.0e-5
    158     config_rich_mix = 0.005
    

    I'm guessing I use these:

    109     config_use_cvmix_background = .true.
    110     config_cvmix_background_diffusion = 1.0e-5
    111     config_cvmix_background_viscosity = 1.0e-4
    
    117     config_use_cvmix_shear = .true.
    118     config_cvmix_num_ri_smooth_loops = 2
    119     config_cvmix_use_BLD_smoothing = .true.
    120     config_cvmix_shear_mixing_scheme = 'PP'
    121     config_cvmix_shear_PP_nu_zero = 0.005
    122     config_cvmix_shear_PP_alpha = 5.0
    123     config_cvmix_shear_PP_exp = 2.0
    

    Does that look right? I need the background on, and also shear, use PP and leave alpha and exp as the default?

    I also want to change the current namelist default

    <nml_option name="config_use_cvmix" type="logical" default_value=".false." units="NA"
    

    to true in the Registry.xml. We always need at least background mixing on. Do you agree? This only affects MPAS setups, as E3SM has its own namelist script.

  21. vanroekel commented on May 23, 2020

    @vanroekel
    Contributor

    Yes, the settings for PP should be right for reproducing what was in vmix_rich. For constant you may want to turn on background diffusivity as well

    config_cvmix_background_diffusion = 1e-5
    
  22. added a commit that references this issue on Jun 1, 2020
    fc22a80
  23. mark-petersen commented on Sep 16, 2020

    @mark-petersen
    Contributor

    Fixed by #569.

  24. added a commit that references this issue on Jan 11, 2021
    9bd85ec
  25. added a commit that references this issue on Jan 14, 2021
    9dc2151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions