Skip to content

Change shear mixing to LMD94 formulation and add ri smoothing#352

Open
katsmith133 wants to merge 2 commits intoE3SM-Project:developfrom
katsmith133:omega/add-vertical-mixing
Open

Change shear mixing to LMD94 formulation and add ri smoothing#352
katsmith133 wants to merge 2 commits intoE3SM-Project:developfrom
katsmith133:omega/add-vertical-mixing

Conversation

@katsmith133
Copy link

@katsmith133 katsmith133 commented Feb 23, 2026

This PR changes the shear vertical mixing formulation from Pacanowski and Philander (1981) to Large et al (1994), adds in vertical smoothing to the gradient Richardson number, and updates the tests and docs to reflect these changes.

Passes all CTests on PM-CPU and PM-GPU. Hangs on tests in polaris omega_pr test suite. Not sure how to address as I would not expect this PR to affect those tests.

Checklist

  • Documentation
  • Linting
  • Building
    • CMake build does not produce any new warnings from changes in this PR
  • Testing
    • Add a comment to the PR titled Testing with the following:
      • Which machines CTest unit tests
        have been run on and indicate that are all passing.
      • The Polaris omega_pr test suite
        has passed, using the Polaris e3sm_submodules/Omega baseline
      • Document machine(s), compiler(s), and the build path(s) used for -p for both the baseline (Polaris e3sm_submodules/Omega) and the PR build
      • Indicate "All tests passed" or document failing tests
      • Document testing used to verify the changes including any tests that are added/modified/impacted.
    • New tests:
      • CTest unit tests for new features have been added per the approved design.

Testing

CTest unit tests

  • Machine: PM-CPU, PM-GPU
  • Compiler: intel, gnugpu
  • Build type: Relase
  • Result: All tests passed

Polaris omega_pr regression suite

  • Baseline build (-p): /pscratch/sd/k/katsmith/polaris/e3sm_submodules/Omega
  • Baseline workdir (-w): /pscratch/sd/k/katsmith/polaris_testing/baseline_omega_pr/
  • PR build (-p): /pscratch/sd/k/katsmith/Omega-VM/
  • PR workdir (-w): /pscratch/sd/k/katsmith/polaris_testing/my_branch_omega_pr/
  • Machine/partition: PM
  • Compiler/build type: , <Debug|Release>
  • Result: All tests passed on baseline, PR build hangs on ocean/planar/manufactured_solution/convergence_both/default - forward_50km_75s
  • Logs (if applicable): /pscratch/sd/k/katsmith/polaris_testing/my_branch_omega_pr/polaris_omega_pr.o49143835

Tests added/modified/impacted

  • CTest: in VertMixTest added tests: testGradRichNum and testOneTwoOneFilter, and modified: testShearVertMix and testTotalVertMix.

Documentation

Documentation has be built locally here and charges are as expected: https://portal.nersc.gov/project/e3sm/katsmith/omega_docs/html/devGuide/VerticalMixingCoeff.html

BaseShearValue: 0.005
RiCrit: 0.7
Exponent: 3.0
RiSmoothLoops: 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

three is a lot for smoothing passes. I'd only do 2 here.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I think 3 was the default in MPAS, so I was just going off of that, but happy to change it.

constant background mixing value, (2) a convective instability mixing value, and (3) a Richardson
number dependent shear mixing value from the [Pacanowski and Philander (1981)](https://journals.ametsoc.org/view/journals/phoc/11/11/1520-0485_1981_011_1443_povmin_2_0_co_2.xml) parameterization. These options are linearly additive. In the future, additional additive options will be implemented, such as the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872). For both the convective and shear mixing values `BruntVaisalaFreqSq` is needed, which
is calculated by the `EOS` class.
number dependent shear mixing value from the [Large et al (1994)](https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/94RG01872) or LMD94 interior shear parameterization. These options are linearly additive. In the future, additional additive options will be implemented, such as the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872). For both the convective and shear mixing values `BruntVaisalaFreq` is needed, which
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a little pedantic, but let's change shear mixing -> shear instability driven mixing throughout.

BaseShearValue: 0.005
RiCrit: 0.7
Exponent: 3.0
RiSmoothLoops: 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

again change to 2

- `ShearNuZero`: Base coefficient for Pacanowski-Philander scheme (Default: 0.005)
- `ShearAlpha`: Alpha parameter for P-P scheme (Default: 5.0)
- `ShearExponent`: Exponent parameter for P-P scheme (Default: 2.0)
- `BaseShearValue`: Base values of shear for the LMD94 interior shear mixing formulation (Default: 0.005)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `BaseShearValue`: Base values of shear for the LMD94 interior shear mixing formulation (Default: 0.005)
- `BaseShearValue`: Base values of maximum viscosity and diffusivity for the LMD94 interior shear instability driven mixing formulation (Default: 0.005)

- `ShearAlpha`: Alpha parameter for P-P scheme (Default: 5.0)
- `ShearExponent`: Exponent parameter for P-P scheme (Default: 2.0)
- `BaseShearValue`: Base values of shear for the LMD94 interior shear mixing formulation (Default: 0.005)
- `RiCrit`: Critical Richerson number for the LMB94 formulation (Default: 0.7)
Copy link
Collaborator

@vanroekel vanroekel Feb 25, 2026

Choose a reason for hiding this comment

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

Suggested change
- `RiCrit`: Critical Richerson number for the LMB94 formulation (Default: 0.7)
- `RiCrit`: Critical Richardson number for the LMD94 formulation (Default: 0.7)

- `ShearExponent`: Exponent parameter for P-P scheme (Default: 2.0)
- `BaseShearValue`: Base values of shear for the LMD94 interior shear mixing formulation (Default: 0.005)
- `RiCrit`: Critical Richerson number for the LMB94 formulation (Default: 0.7)
- `ShearExponent`: Exponent parameter number for the LMB94 formulation (Default: 3.0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `ShearExponent`: Exponent parameter number for the LMB94 formulation (Default: 3.0)
- `ShearExponent`: Exponent parameter number for the LMD94 formulation (Default: 3.0)

- `BaseShearValue`: Base values of shear for the LMD94 interior shear mixing formulation (Default: 0.005)
- `RiCrit`: Critical Richerson number for the LMB94 formulation (Default: 0.7)
- `ShearExponent`: Exponent parameter number for the LMB94 formulation (Default: 3.0)
- `RiSmoothLoops`: Number of 1-2-1 filter passes to apply to the gradient Richardson number smoothing (Default: 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `RiSmoothLoops`: Number of 1-2-1 filter passes to apply to the gradient Richardson number smoothing (Default: 3)
- `RiSmoothLoops`: Number of 1-2-1 filter passes to apply to the gradient Richardson number smoothing (Default: 2)

dependent shear instability driven mixing value from the [Pacanowski and Philander (1981)](https://journals.ametsoc.org/view/journals/phoc/11/11/1520-0485_1981_011_1443_povmin_2_0_co_2.xml) parameterization. These are linearly additive and are describe a bit
more in detail below. Other mixing processes and parameterizations, such as the the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872) will be added in the future.
dependent shear instability driven mixing value from the [Large et al (1994)](https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/94RG01872) or LMD94 interior shear parameterization. These are linearly additive and are describe a bit
more in detail below. Other mixing processes and parameterizations, such as the the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872) will be added in the future. In addition to diffusivity and viscosity coefficients, the vertical mixing module calculates the gradient Richardson number and smooths that gradient Richardson number using a 1-2-1 filter before using it in the shear mixing calculation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
more in detail below. Other mixing processes and parameterizations, such as the the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872) will be added in the future. In addition to diffusivity and viscosity coefficients, the vertical mixing module calculates the gradient Richardson number and smooths that gradient Richardson number using a 1-2-1 filter before using it in the shear mixing calculation.
more in detail below. Other mixing processes and parameterizations, such as the the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872) will be added in the future. In addition to diffusivity and viscosity coefficients, the vertical mixing module calculates the gradient Richardson number and smooths that gradient Richardson number using a 1-2-1 filter before using it in the shear instability driven mixing calculation.

BaseShearValue: 0.005 # Base viscosity/diffusivity value
RiCrit: 0.7 # Critical Richardson number
Exponent: 3.0 # Richardson number exponent
RiSmoothLoops: 3 # Number of Richardson number smoothing loops
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
RiSmoothLoops: 3 # Number of Richardson number smoothing loops
RiSmoothLoops: 2 # Number of Richardson number smoothing loops


A constant background mixing value that represents small-scale mixing processes not explicitly resolved by the model. Typically, this is chosen to represent low values of vertical mixing
happening in the ocean's stratified interior.
A constant background mixing value that represents small-scale mixing processes not explicitly resolved or modeled. Typically, this is chosen to represent low values of vertical mixing happening in the ocean's stratified interior.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
A constant background mixing value that represents small-scale mixing processes not explicitly resolved or modeled. Typically, this is chosen to represent low values of vertical mixing happening in the ocean's stratified interior.
A constant background mixing value that represents small-scale mixing processes not explicitly resolved or modeled. Typically, this is chosen to represent low values of vertical mixing happening in the ocean's stratified interior and is assumed roughly equivalent to the globally averaged interior mixing from all sources (e.g., from internal wave breaking).

$$

where $\nu_o$, $\alpha$, $n$, $\nu_b$, $\kappa_b$ are constant parameters set in the `VertMix` section of the yaml file (`NuZero`, `Alpha`, `Exponent` under the `Shear` header and `Viscosity`, `Diffusivity` under the `Background` header). $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer. In a later development, the shear mixing option will be changed to the interior shear mixing formulation in [Large et al., 1994](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872).
where $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $Ri$ is calculated by the vertical mixing module and then smoothed with a 1-2-1 filter before being used to calculate the shear. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
where $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $Ri$ is calculated by the vertical mixing module and then smoothed with a 1-2-1 filter before being used to calculate the shear. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer.
where $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $Ri$ is calculated by the vertical mixing module and then smoothed with a 1-2-1 filter before being used to calculate the shear instability driven mixing. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of 'surface layer' should we say 'at the surface'?

0.005; ///< Numerator of Pacanowski and Philander (1981) Eq (1).
Real ShearAlpha = 5.0; ///< Alpha value used in Pacanowski and Philander
///< (1981) Eqs (1) and (2).
Real BaseShearValue = 0.005; ///< Base shear vertical viscosity and
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Real BaseShearValue = 0.005; ///< Base shear vertical viscosity and
Real BaseShearValue = 0.005; ///< Base shear instability driven vertical viscosity and

///< (1981) Eqs (1) and (2).
Real BaseShearValue = 0.005; ///< Base shear vertical viscosity and
///< diffusivity (m^2 s^-1) of LMG94
Real ShearRiCrit = 0.7; ///< Critical Richardson number of LMG94
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Real ShearRiCrit = 0.7; ///< Critical Richardson number of LMG94
Real ShearRiCrit = 0.7; ///< Critical Richardson number of LMD94

Real ShearRiCrit = 0.7; ///< Critical Richardson number of LMG94
Real ShearExponent =
2.0; /// Exponent value used in Pacanowski and Philander (1981) Eqs (1).
3.0; /// Exponent value used interior shear mixing calculation of LMG94
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
3.0; /// Exponent value used interior shear mixing calculation of LMG94
3.0; /// Exponent value used interior shear instability driven mixing calculation of LMG94

Real ShearExponent =
2.0; /// Exponent value used in Pacanowski and Philander (1981) Eqs (1).
3.0; /// Exponent value used interior shear mixing calculation of LMG94
I4 RiSmoothLoops = 3; ///< Number of smoothing loops for Richardson number
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
I4 RiSmoothLoops = 3; ///< Number of smoothing loops for Richardson number
I4 RiSmoothLoops = 2; ///< Number of smoothing loops for Richardson number

ShearExponent) *
BaseShearValue;
} else {
VertDiff(ICell, K) += 0.0_Real;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do this? Do we really need this else chunk? We could just have a comment that says 'do nothing' or something like that

Copy link
Collaborator

@vanroekel vanroekel left a comment

Choose a reason for hiding this comment

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

Looks pretty good @katsmith133 just a few minor comments in the docs and one larger one in the main code.

@katsmith133
Copy link
Author

Thanks for the review, @vanroekel! I will have a look at it today. Seems like I misspelled LMD94 A LOT, haha.

@katsmith133
Copy link
Author

@cbegeman I mostly included you on this review because the polaris omega_pr tests just hang and I want to figure out if this is a polaris problem or a this PR problem, especially after Youngsung mentioned that he saw these tests hanging on PM as well. Let me know your thoughts.

@cbegeman
Copy link

@katsmith133 Thanks for the ping. I'd like to do polaris tests including the single column shear mixing one. Can you provide me with the appropriate mapping from Omega config options to MPAS-O config options (or indicate where there is no direct mapping? See https://github.com/E3SM-Project/polaris/pull/435/files#diff-d953af580e6050fd590b94c370ebc3401d6ed1b24e282d8d2d568536c35f8949R132 for an example.

Is there anything else I should know about when comparing to MPAS-O and with the current Omega develop?


### 2. Convective Mixing

Enhanced convective adjustment mixing that occurs in statically unstable regions of the water column to parameterize convection and homogenize properties. In Omega this is mixing is defaulted to occur when the squared Brunt Vaisala Frequency is less than 0.0 (unstable), and is off when equal to (neutral) or greater than (stable) 0.0.

Choose a reason for hiding this comment

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

Suggested change
Enhanced convective adjustment mixing that occurs in statically unstable regions of the water column to parameterize convection and homogenize properties. In Omega this mixing is defaulted to occur when the squared Brunt Vaisala Frequency is less than 0.0 (unstable), and is off when equal to (neutral) or greater than (stable) 0.0.

background mixing value, (2) a convective instability mixing value, and (3) a Richardson number
dependent shear instability driven mixing value from the [Pacanowski and Philander (1981)](https://journals.ametsoc.org/view/journals/phoc/11/11/1520-0485_1981_011_1443_povmin_2_0_co_2.xml) parameterization. These are linearly additive and are describe a bit
more in detail below. Other mixing processes and parameterizations, such as the the K Profile Parameterization [(KPP; Large et al., 1994)](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872) will be added in the future.
dependent shear instability driven mixing value from the [Large et al (1994)](https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/94RG01872) or LMD94 interior shear parameterization. These are linearly additive and are describe a bit

Choose a reason for hiding this comment

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

For readability, I'd recommend hyphenating parts of this sentence (including previous line "Richardson-number-

Suggested change
dependent shear instability driven mixing value from the [Large et al (1994)](https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/94RG01872) or LMD94 interior shear parameterization. These are linearly additive and are describe a bit
-dependent shear-instability-driven mixing value from the [Large et al (1994)](https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/94RG01872) or LMD94 interior shear parameterization. These are linearly additive and are describe a bit

@@ -51,20 +51,21 @@

### 3. Shear Mixing

Choose a reason for hiding this comment

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

Suggested change
### 3. Shear Mixing
### 3. Shear-driven Mixing


$$
\kappa = \frac{\nu}{(1+\alpha Ri)} + \kappa_b\,.
\nu_{shear}\,, \kappa_{shear} = =

Choose a reason for hiding this comment

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

Suggested change
\nu_{shear}\,, \kappa_{shear} = =
\nu_{shear} = = \kappa_{shear} = =

$$

where $\nu_o$, $\alpha$, $n$, $\nu_b$, $\kappa_b$ are constant parameters set in the `VertMix` section of the yaml file (`NuZero`, `Alpha`, `Exponent` under the `Shear` header and `Viscosity`, `Diffusivity` under the `Background` header). $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer. In a later development, the shear mixing option will be changed to the interior shear mixing formulation in [Large et al., 1994](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/94rg01872).
where $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $Ri$ is calculated by the vertical mixing module and then smoothed with a 1-2-1 filter before being used to calculate the shear. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer.
Copy link

@alicebarthel alicebarthel Feb 26, 2026

Choose a reason for hiding this comment

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

Suggested change
where $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $Ri$ is calculated by the vertical mixing module and then smoothed with a 1-2-1 filter before being used to calculate the shear. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer.
where $N^2$ is calculated by the EOS based on the ocean state and $\mathbf{U}$ is the magnitude of the horizontal velocity. $Ri$ is calculated by the vertical mixing module and then smoothed with a 1-2-1 (vertical) filter before being used to calculate the shear-instability-driven mixing. $N^2$, $\partial \mathbf{U}}{\partial z}\right|^2$ and $Ri$ of `K` are all defined at the cell center, top interface of layer `K`. $N^2$, $\nu_{shear}$ and $\kappa_{shear}$ are set to zero for the surface layer.

@alicebarthel
Copy link

@katsmith133 do you need more testing from me or just a code read-through?

If `SpecVolDisplaced` is calculated with the linear EOS option, it will be equal to `SpecVol` as there
is no pressure/depth dependence for the linear EOS. `SpecVolDisplaced` computes specific volume
adiabatically displaced to `K + KDisp` (where `K` counted positive downward, ie `K+1` is one layer below `K`). Note: `SpecVol` must be calculated before `BruntVaisalaFreqSq`, as
adiabatically displaced to `K + KDisp` (where `K` counted positive downward, ie `K+1` is one layer below `K`). Note: `SpecVol` must be calculated before `BruntVaisalaFreq`, as

Choose a reason for hiding this comment

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

I am not sure why this change is there. Is that intentional or a version mix-up?

\nu_{shear}\,, \kappa_{shear} = =
\begin{cases}
\nu_o \quad \text{ if } Ri_g < 0\\
\nu_o \left[1 - \left( \frac{Ri_g}{Ri_{crit}} \right)^2 \right]^p \text{ if } 0 < Ri_g < Ri_{crit}\\
Copy link

@alicebarthel alicebarthel Feb 26, 2026

Choose a reason for hiding this comment

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

Suggested change
\nu_o \left[1 - \left( \frac{Ri_g}{Ri_{crit}} \right)^2 \right]^p \text{ if } 0 < Ri_g < Ri_{crit}\\
\nu_o \left[1 - \left( \frac{Ri_g}{Ri_{crit}} \right)^2 \right]^p \text{ if } 0 \leq Ri_g < Ri_{crit}\\

Copy link
Author

Choose a reason for hiding this comment

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

@alicebarthel and @vanroekel This is actually a good point to discuss that I hadn't thought about. The LMD94 paper only has < and >, no <= or >=... I think I just naturally put the >= in for the code, but can't remember what my reasoning was. I am not too sure it matters too much which side the equals goes on when Ri_g ~ Ri_{crit}, since Ri_{crit} is a somewhat fudgey number anyway, but when Ri_g ~ 0 you are switching from a shear dominated regime to strong convection, so it might matter more which side 0 falls to? But maybe not, since this part of the code does not decide which is more dominant, it just decides how strong the shear is. Thoughts? I will take a look to see what cvmix does.

Copy link
Author

Choose a reason for hiding this comment

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

Looking more at the form of the equation, I don't think it matters too much which side the equals is on since its asymptoting to those end values anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes that's right. It should be good to go either way. My recollection is the equals isn't necessary and the original could be fine too.

Choose a reason for hiding this comment

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

My main point was to align the code and the documentation, and to make sure we don't create edge cases that we did not intend or do not test for. I have no preference as to where the equal goes.

\begin{cases}
\nu_o \quad \text{ if } Ri_g < 0\\
\nu_o \left[1 - \left( \frac{Ri_g}{Ri_{crit}} \right)^2 \right]^p \text{ if } 0 < Ri_g < Ri_{crit}\\
0.0 \quad \text{ if } Ri_{crit} < Ri_g

Choose a reason for hiding this comment

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

Suggested change
0.0 \quad \text{ if } Ri_{crit} < Ri_g
0.0 \quad \text{ if } Ri_{crit} \leq Ri_g

I4 K1 = K - 1;
I4 K2 = K;

if (K <= MinLayerCell(ICell)) {

Choose a reason for hiding this comment

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

A couple of clarifying questions here on the vertical indexing:

  • can you confirm that maxLayerCell is below topography? I.e. the water column goes from minLayerCell (valid) to maxLayerCell-1?
  • If K < MinLayerCell or K > MaxLayerCell, we are still at risk of using invalid/undefined velocities in the shear calculation. Looking at the loop, I don't think we are supposed to ever get there, but wouldn't it be safer to exit with an error (hopefully never exercised) in that case rather than risk using garbage? Is there a reason not to use something similar to the code above? e.g.
         if (K < MinLayerCell(ICell) || K > MaxLayerCell(ICell))
            continue;

Copy link

@alicebarthel alicebarthel left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @katsmith133!
I did a visual inspection and it looks good. I made minor suggestions, but let me know if it's helpful for me to run tests.
Question over testing in general: do we have any tests where we have more vertLayers than valid layers? I.e. do we ever test the interplay between nvertLayers and maxLayerCell, or minLayerCell? I suspect the former gets used when topography is used, but not the latter at this stage?

@katsmith133
Copy link
Author

@cbegeman here is the mapping for Omega to MPAS-O for the VertMix variables:

| Omega -> MPAS-O |
VertMix: Background: Diffusivity -> config_cvmix_background_diffusion
VertMix: Background: Viscosity -> config_cvmix_background_viscosity
VertMix: Convective -> config_use_cvmix_convection
VertMix: Convective: Diffusivity -> config_cvmix_convective_diffusion,config_cvmix_convective_viscosity
VertMix: Convective: TriggerBVF -> config_cvmix_convective_triggerBVF
VertMix: Shear -> config_use_cvmix_shear
VertMix: Shear: BaseShearValue -> config_cvmix_shear_KPP_nu_zero
VertMix: Shear: RiCrit -> config_cvmix_shear_KPP_Ri_zero
VertMix: Shear: Exponent -> config_cvmix_shear_KPP_exp
VertMix: Shear: RiSmoothLoops -> config_cvmix_num_ri_smooth_loops

These do not have direct mappings to anything in Omega, yet, but make sure they are set as following:
config_use_cvmix = true
config_use_cvmix_kpp = false
config_cvmix_shear_mixing_scheme = 'KPP'
config_cvmix_background_scheme = 'constant'

These do not have direct mappings to anything in Omega, yet, and the default values should be fine to keep:
config_cvmix_prandtl_number
config_cvmix_background_diffusion_passive_enable
config_cvmix_BryanLewis_bl1
config_cvmix_BryanLewis_bl2
config_cvmix_BryanLewis_transitionDepth
config_cvmix_BryanLewis_transitionWidth
config_cvmix_convective_basedOnBVF
config_cvmix_use_BLD_smoothing
config_cvmix_shear_PP_nu_zero
config_cvmix_shear_PP_alpha
config_cvmix_shear_PP_exp
config_use_cvmix_tidal_mixing
config_use_cvmix_double_diffusion
config_use_cvmix_fixed_boundary_layer
config_cvmix_kpp_boundary_layer_depth
config_cvmix_kpp_criticalBulkRichardsonNumber
config_cvmix_kpp_matching
config_cvmix_kpp_EkmanOBL
config_cvmix_kpp_MonObOBL
config_cvmix_kpp_interpolationOMLType
config_cvmix_kpp_surface_layer_extent
config_cvmix_kpp_surface_layer_averaging
configure_cvmix_kpp_minimum_OBL_under_sea_ice
config_cvmix_kpp_stop_OBL_search
config_cvmix_kpp_use_enhanced_diff
config_cvmix_kpp_nonlocal_with_implicit_mix
config_cvmix_kpp_use_theory_wave
config_cvmix_kpp_langmuir_mixing_opt
config_cvmix_kpp_langmuir_entrainment_opt
config_cvmix_kpp_use_active_wave

Let me know if you need more than these variables!

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.

4 participants