Skip to content
Draft
Show file tree
Hide file tree
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 Nov 4, 2025
8ee4d62
Add two_column test for TEOS-10
xylar Nov 4, 2025
1130fc4
Use z-tilde rather than z-star in two_column
xylar Nov 5, 2025
b97962e
Compute and output geometric z in two_column init
xylar Nov 5, 2025
01e0b07
Iteratively compute p and spec vol in two_column
xylar Nov 5, 2025
b75290b
Find iteratively find z-tilde of sea floor
xylar Nov 6, 2025
7dcf082
Add a function for computing geometric height by quadrature
xylar Nov 10, 2025
cb17a8c
Compute geometric height in two-column test by quadrature
xylar Nov 10, 2025
351faf1
Fix sign for z_tilde_nodes in integrate_geometric_height()
xylar Dec 7, 2025
9949454
Switch to reference step and sequence of init steps
xylar Dec 19, 2025
3c72b9b
Move integration into reference step module
xylar Jan 19, 2026
406429e
Rename two-column task to SalinityGradient
xylar Jan 19, 2026
d8352ed
Debug and fix two-column Init step
xylar Jan 20, 2026
4d11128
Add HPGA and Montgomery potential to init
xylar Jan 20, 2026
53fb49c
Fix long names and units in init
xylar Jan 20, 2026
3f90b35
Fix reference output
xylar Jan 20, 2026
f64471e
Fix reference gradient, pressure and dx
xylar Jan 28, 2026
abf5eea
Fix dx in init
xylar Jan 28, 2026
d901b22
Add more outputs for debugging
xylar Jan 28, 2026
fc9c142
Support different vertical coords in each column
xylar Jan 30, 2026
8fa2f49
Add two-column test with z-tilde gradient
xylar Feb 2, 2026
aaab0e2
Switch to interpolating CT and SA with monotone PCHIP
xylar Feb 2, 2026
921bd58
Fix sign of pressure term in Montgomery potential
xylar Feb 2, 2026
28ffdbf
Reduce gradient in z-tilde coordinate
xylar Feb 2, 2026
49490ff
Vary resolution both horizontally and vertically for convergence
xylar Feb 2, 2026
5d6bf7d
Compute ref vertical res as half finest test res
xylar Feb 3, 2026
af77b68
Add surface pressure to init
xylar Feb 5, 2026
b6ea4cb
Switch to a single task class to avoid redundancy
xylar Feb 5, 2026
c02319d
Add forward runs
xylar Feb 5, 2026
2471dab
Add OmegaMesh.nc link
xylar Feb 9, 2026
863a584
Add vertical coordinate vars to variable map
xylar Feb 16, 2026
9baf53a
Get rho0 for Omega from Polaris config option
xylar Feb 16, 2026
9ea7e2a
Add geometric bottom depth and mid-layer pressure to init
xylar Feb 16, 2026
b60dcbf
Temporarily hard-code Omega's acceleration of gravity
xylar Feb 16, 2026
f85c132
Fix sign of HPGA
xylar Feb 16, 2026
6291b1c
Add analysis step
xylar Feb 17, 2026
cc3732e
Fix column concat in init step
xylar Feb 17, 2026
a671d02
Make water column thickness an even multiple of 16
xylar Feb 17, 2026
8700d9f
Mask comparisons in analysis step
xylar Feb 18, 2026
bc13be9
Add thresholds to analysis step
xylar Feb 18, 2026
e562338
Add a temperature gradient task
xylar Feb 18, 2026
a79209d
Add 6 km and 3 km resolutions
xylar Feb 18, 2026
3d496b1
Rename two_column --> horiz_press_grad
xylar Feb 18, 2026
e6049e8
Switch back to absolute RMS error or difference in analysis
xylar Feb 18, 2026
33ebdea
Vary the salinity gradient with depth
xylar Feb 18, 2026
a2d23b2
Stop iterating in init if converged
xylar Feb 18, 2026
47eb59b
Change resolutions
xylar Feb 18, 2026
7267b68
Fix reference vertical res
xylar Feb 18, 2026
6f4a2e5
Add horiz_press_grad tests to Omega suites
xylar Feb 18, 2026
73e5b54
Add horiz_press_grad to the docs
xylar Feb 18, 2026
c1bd022
Fix docstring for Reference step
xylar Feb 18, 2026
57a5f49
Fix f-string for python <3.12
xylar Feb 19, 2026
a385f6b
Remove rho0 config options from horiz press grad
xylar Mar 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/developers_guide/ocean/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,33 @@
viz.Viz.run
```

### horiz_press_grad

```{eval-rst}
.. currentmodule:: polaris.tasks.ocean.horiz_press_grad

.. autosummary::
:toctree: generated/

add_horiz_press_grad_tasks

task.HorizPressGradTask
task.HorizPressGradTask.configure

reference.Reference
reference.Reference.run

init.Init
init.Init.run

forward.Forward
forward.Forward.setup

analysis.Analysis
analysis.Analysis.setup
analysis.Analysis.run
```

### ice_shelf_2d

```{eval-rst}
Expand Down
72 changes: 72 additions & 0 deletions docs/developers_guide/ocean/tasks/horiz_press_grad.md
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.
1 change: 1 addition & 0 deletions docs/developers_guide/ocean/tasks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cosine_bell
customizable_viz
external_gravity_wave
geostrophic
horiz_press_grad
divergent_2d
ice_shelf_2d
inertial_gravity_wave
Expand Down
108 changes: 108 additions & 0 deletions docs/users_guide/ocean/tasks/horiz_press_grad.md
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`).
Comment on lines +102 to +104
Copy link
Copy Markdown
Collaborator

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.


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.
1 change: 1 addition & 0 deletions docs/users_guide/ocean/tasks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cosine_bell
customizable_viz
external_gravity_wave
geostrophic
horiz_press_grad
divergent_2d
ice_shelf_2d
inertial_gravity_wave
Expand Down
6 changes: 6 additions & 0 deletions polaris/ocean/model/mpaso_to_omega.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ variables:
cellsOnVertex: CellsOnVertex
edgesOnVertex: EdgesOnVertex

# vertical coordinate
minLevelCell: MinLayerCell
maxLevelCell: MaxLayerCell
# currently hard-coded in horizontal mesh
# bottomDepth: BottomDepth

# tracers
temperature: Temperature
salinity: Salinity
Expand Down
3 changes: 3 additions & 0 deletions polaris/suites/ocean/omega_nightly.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ocean/planar/barotropic_gyre/munk/free-slip
ocean/horiz_press_grad/salinity_gradient
ocean/horiz_press_grad/temperature_gradient
ocean/horiz_press_grad/ztilde_gradient
ocean/planar/manufactured_solution/convergence_both/default
ocean/planar/manufactured_solution/convergence_both/del2
ocean/planar/manufactured_solution/convergence_both/del4
Expand Down
1 change: 1 addition & 0 deletions polaris/suites/ocean/omega_pr.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ocean/planar/barotropic_channel/default # Supported but fails
ocean/planar/merry_go_round/default
ocean/planar/barotropic_gyre/munk/free-slip
ocean/horiz_press_grad/salinity_gradient
ocean/planar/manufactured_solution/convergence_both/default
ocean/planar/manufactured_solution/convergence_both/del2
ocean/planar/manufactured_solution/convergence_both/del4
Expand Down
2 changes: 2 additions & 0 deletions polaris/tasks/ocean/add_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
add_external_gravity_wave_tasks as add_external_gravity_wave_tasks,
)
from polaris.tasks.ocean.geostrophic import add_geostrophic_tasks
from polaris.tasks.ocean.horiz_press_grad import add_horiz_press_grad_tasks
from polaris.tasks.ocean.ice_shelf_2d import add_ice_shelf_2d_tasks
from polaris.tasks.ocean.inertial_gravity_wave import (
add_inertial_gravity_wave_tasks as add_inertial_gravity_wave_tasks,
Expand Down Expand Up @@ -36,6 +37,7 @@ def add_ocean_tasks(component):
add_baroclinic_channel_tasks(component=component)
add_barotropic_channel_tasks(component=component)
add_barotropic_gyre_tasks(component=component)
add_horiz_press_grad_tasks(component=component)
add_ice_shelf_2d_tasks(component=component)
add_inertial_gravity_wave_tasks(component=component)
add_internal_wave_tasks(component=component)
Expand Down
19 changes: 19 additions & 0 deletions polaris/tasks/ocean/horiz_press_grad/__init__.py
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))
Loading
Loading