-
Notifications
You must be signed in to change notification settings - Fork 20
Add Omega horizontal pressure gradient tests #465
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
Draft
xylar
wants to merge
53
commits into
E3SM-Project:main
Choose a base branch
from
xylar:add-omega-two-column
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
fc789b3
Fix single_column docstring
xylar 8ee4d62
Add two_column test for TEOS-10
xylar 1130fc4
Use z-tilde rather than z-star in two_column
xylar b97962e
Compute and output geometric z in two_column init
xylar 01e0b07
Iteratively compute p and spec vol in two_column
xylar b75290b
Find iteratively find z-tilde of sea floor
xylar 7dcf082
Add a function for computing geometric height by quadrature
xylar cb17a8c
Compute geometric height in two-column test by quadrature
xylar 351faf1
Fix sign for z_tilde_nodes in integrate_geometric_height()
xylar 9949454
Switch to reference step and sequence of init steps
xylar 3c72b9b
Move integration into reference step module
xylar 406429e
Rename two-column task to SalinityGradient
xylar d8352ed
Debug and fix two-column Init step
xylar 4d11128
Add HPGA and Montgomery potential to init
xylar 53fb49c
Fix long names and units in init
xylar 3f90b35
Fix reference output
xylar f64471e
Fix reference gradient, pressure and dx
xylar abf5eea
Fix dx in init
xylar d901b22
Add more outputs for debugging
xylar fc9c142
Support different vertical coords in each column
xylar 8fa2f49
Add two-column test with z-tilde gradient
xylar aaab0e2
Switch to interpolating CT and SA with monotone PCHIP
xylar 921bd58
Fix sign of pressure term in Montgomery potential
xylar 28ffdbf
Reduce gradient in z-tilde coordinate
xylar 49490ff
Vary resolution both horizontally and vertically for convergence
xylar 5d6bf7d
Compute ref vertical res as half finest test res
xylar af77b68
Add surface pressure to init
xylar b6ea4cb
Switch to a single task class to avoid redundancy
xylar c02319d
Add forward runs
xylar 2471dab
Add OmegaMesh.nc link
xylar 863a584
Add vertical coordinate vars to variable map
xylar 9baf53a
Get rho0 for Omega from Polaris config option
xylar 9ea7e2a
Add geometric bottom depth and mid-layer pressure to init
xylar b60dcbf
Temporarily hard-code Omega's acceleration of gravity
xylar f85c132
Fix sign of HPGA
xylar 6291b1c
Add analysis step
xylar cc3732e
Fix column concat in init step
xylar a671d02
Make water column thickness an even multiple of 16
xylar 8700d9f
Mask comparisons in analysis step
xylar bc13be9
Add thresholds to analysis step
xylar e562338
Add a temperature gradient task
xylar a79209d
Add 6 km and 3 km resolutions
xylar 3d496b1
Rename two_column --> horiz_press_grad
xylar e6049e8
Switch back to absolute RMS error or difference in analysis
xylar 33ebdea
Vary the salinity gradient with depth
xylar a2d23b2
Stop iterating in init if converged
xylar 47eb59b
Change resolutions
xylar 7267b68
Fix reference vertical res
xylar 6f4a2e5
Add horiz_press_grad tests to Omega suites
xylar 73e5b54
Add horiz_press_grad to the docs
xylar c1bd022
Fix docstring for Reference step
xylar 57a5f49
Fix f-string for python <3.12
xylar a385f6b
Remove rho0 config options from horiz press grad
xylar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| (dev-ocean-horiz-press-grad)= | ||
|
|
||
| # horiz_press_grad | ||
|
|
||
| The {py:class}`polaris.tasks.ocean.horiz_press_grad.task.HorizPressGradTask` | ||
| provides two-column Omega tests for pressure-gradient-acceleration (`HPGA`) | ||
| accuracy and convergence across horizontal and vertical resolutions. | ||
|
|
||
| The task family includes three variants: | ||
|
|
||
| - `salinity_gradient` | ||
| - `temperature_gradient` | ||
| - `ztilde_gradient` | ||
|
|
||
| ## framework | ||
|
|
||
| The config options for these tests are described in | ||
| {ref}`ocean-horiz-press-grad` in the User's Guide. | ||
|
|
||
| The task dynamically rebuilds `init` and `forward` steps in `configure()` so | ||
| user-supplied `horiz_resolutions` and `vert_resolutions` in config files are | ||
| reflected in the work directory setup. | ||
|
|
||
| ### reference | ||
|
|
||
| The class {py:class}`polaris.tasks.ocean.horiz_press_grad.reference.Reference` | ||
| defines a step that builds a high-fidelity reference HPGA solution in | ||
| `reference_solution.nc`. | ||
|
|
||
| It computes pseudo-height and geometric-height profiles on a refined reference | ||
| grid, evaluates TEOS-10 specific volume, and computes HPGA at the center | ||
| column using a 4th-order finite-difference stencil. | ||
|
|
||
| ### init | ||
|
|
||
| The class {py:class}`polaris.tasks.ocean.horiz_press_grad.init.Init` | ||
| defines one step per `(horiz_res, vert_res)` pair. | ||
|
|
||
| Each `init` step: | ||
|
|
||
| - builds and culls a planar two-cell mesh, | ||
| - sets up z-tilde vertical coordinates and profile fields, | ||
| - iteratively adjusts pseudo-bottom depth to match target geometric | ||
| water-column thickness, and | ||
| - writes `culled_mesh.nc` and `initial_state.nc`. | ||
|
|
||
| ### forward | ||
|
|
||
| The class {py:class}`polaris.tasks.ocean.horiz_press_grad.forward.Forward` | ||
| defines one model step per horizontal resolution. | ||
|
|
||
| It runs Omega from the corresponding `init` output and writes `output.nc` | ||
| (with `NormalVelocityTend` validation), using options from `forward.yaml`. | ||
|
|
||
| ### analysis | ||
|
|
||
| The class {py:class}`polaris.tasks.ocean.horiz_press_grad.analysis.Analysis` | ||
| compares each `forward` result with: | ||
|
|
||
| - the high-fidelity reference solution, and | ||
| - the Python-computed HPGA from `initial_state.nc`. | ||
|
|
||
| The step writes: | ||
|
|
||
| - `omega_vs_reference.nc` and `omega_vs_reference.png` | ||
| - `omega_vs_python.nc` and `omega_vs_python.png` | ||
|
|
||
| and enforces regression criteria from `[horiz_press_grad]`, including: | ||
|
|
||
| - allowed convergence-slope range for Omega-vs-reference, | ||
| - high-resolution RMS threshold for Omega-vs-reference, and | ||
| - RMS threshold for Omega-vs-Python consistency. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| (ocean-horiz-press-grad)= | ||
|
|
||
| # horizontal pressure gradient | ||
|
|
||
| ## description | ||
|
|
||
| The `horiz_press_grad` tasks in `polaris.tasks.ocean.horiz_press_grad` | ||
| exercise Omega's hydrostatic pressure-gradient acceleration (`HPGA`) | ||
| for a two-column configuration with prescribed horizontal gradients. | ||
|
|
||
| Each task includes: | ||
|
|
||
| - a high-fidelity `reference` solution for HPGA, | ||
| - an `init` step at each horizontal/vertical resolution pair, | ||
| - a single-time-step `forward` run at each horizontal resolution, and | ||
| - an `analysis` step comparing Omega output with both the reference and | ||
| Python-initialized HPGA. | ||
|
|
||
| The tasks currently provided are: | ||
|
|
||
| ``` | ||
| ocean/horiz_press_grad/salinity_gradient | ||
| ocean/horiz_press_grad/temperature_gradient | ||
| ocean/horiz_press_grad/ztilde_gradient | ||
| ``` | ||
|
|
||
| ```{image} images/horiz_press_grad_salin_grad.png | ||
| :align: center | ||
| :width: 600 px | ||
| ``` | ||
| ## supported models | ||
|
|
||
| These tasks currently support Omega only. | ||
|
|
||
| ## mesh | ||
|
|
||
| The mesh is planar with two adjacent ocean cells. For each resolution in | ||
| `horiz_resolutions`, the spacing between the two columns is set by that value | ||
| (in km). | ||
|
|
||
| ## vertical grid | ||
|
|
||
| The vertical coordinate is `z-tilde` with a uniform pseudo-height spacing for | ||
| each test in `vert_resolutions`. | ||
|
|
||
| The `reference` step uses a finer spacing `vert_res` chosen so that every test | ||
| spacing is an integer multiple of `2 * vert_res`. This allows reference | ||
| interfaces to align with test midpoints for exact subsampling in analysis. | ||
|
|
||
| (ocean-horiz-press-grad-config)= | ||
| ## config options | ||
|
|
||
| Shared options are in section `[horiz_press_grad]`: | ||
|
|
||
| ```cfg | ||
| # resolutions in km (distance between the two columns) | ||
| horiz_resolutions = [4.0, 3.0, 2.0, 1.5, 1.0, 0.75, 0.5] | ||
|
|
||
| # vertical resolution in m for each two-column setup | ||
| vert_resolutions = [4.0, 3.0, 2.0, 1.5, 1.0, 0.75, 0.5] | ||
|
|
||
| # geometric sea-surface and sea-floor midpoint values and x-gradients | ||
| geom_ssh_mid = 0.0 | ||
| geom_ssh_grad = 0.0 | ||
| geom_z_bot_mid = -500.0 | ||
| geom_z_bot_grad = 0.0 | ||
|
|
||
| # pseudo-height bottom midpoint and x-gradient | ||
| z_tilde_bot_mid = -576.0 | ||
| z_tilde_bot_grad = 0.0 | ||
|
|
||
| # midpoint and gradient node values for piecewise profiles | ||
| z_tilde_mid = [0.0, -48.0, -144.0, -288.0, -576.0] | ||
| z_tilde_grad = [0.0, 0.0, 0.0, 0.0, 0.0] | ||
|
|
||
| temperature_mid = [22.0, 20.0, 14.0, 8.0, 5.0] | ||
| temperature_grad = [0.0, 0.0, 0.0, 0.0, 0.0] | ||
|
|
||
| salinity_mid = [35.6, 35.4, 35.0, 34.8, 34.75] | ||
| salinity_grad = [0.0, 0.0, 0.0, 0.0, 0.0] | ||
|
|
||
| # reference settings | ||
| reference_quadrature_method = gauss4 | ||
| reference_horiz_res = 0.25 | ||
| ``` | ||
|
|
||
| The three task variants specialize one horizontal gradient field: | ||
|
|
||
| - `salinity_gradient`: nonzero `salinity_grad` | ||
| - `temperature_gradient`: nonzero `temperature_grad` | ||
| - `ztilde_gradient`: nonzero `z_tilde_bot_grad` | ||
|
|
||
| ## time step and run duration | ||
|
|
||
| The `forward` step performs one model time step and outputs pressure-gradient | ||
| diagnostics used in the analysis. | ||
|
|
||
| ## analysis | ||
|
|
||
| The `analysis` step computes and plots: | ||
|
|
||
| - Omega RMS error versus reference (`omega_vs_reference.png`), including a | ||
| power-law fit and convergence slope, and | ||
| - Omega RMS difference versus Python initialization (`omega_vs_python.png`). | ||
|
|
||
| The corresponding tabulated data are written to | ||
| `omega_vs_reference.nc` and `omega_vs_python.nc`. | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from polaris.tasks.ocean.horiz_press_grad.task import HorizPressGradTask | ||
|
|
||
|
|
||
| def add_horiz_press_grad_tasks(component): | ||
| """ | ||
| Add tasks for various tests involving the horizonal pressure-gradient | ||
| acceleration between two adjacent ocean columns | ||
|
|
||
| Parameters | ||
| ---------- | ||
| component : polaris.tasks.ocean.Ocean | ||
| the ocean component that the tasks will be added to | ||
| """ | ||
| for name in [ | ||
| 'salinity_gradient', | ||
| 'temperature_gradient', | ||
| 'ztilde_gradient', | ||
| ]: | ||
| component.add_task(HorizPressGradTask(component=component, name=name)) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we provide more detail here to explain exactly what we're evaluating against? It's not immediately apparent to me why, in order to evaluate the pressure gradient tendency at the midpoint of edges given the T,S,layerThickness fields at the midpoint of cells, we choose as "truth" a 4th-order reconstruction given T,S,dTdx,dSdx at the midpoint of edges (not sure that I got all these details right, just trying to be specific about what details would be helpful). I realize that some of this info might be in the design doc but I think it would be good to include here or in the description section.