Skip to content

Docs for zstar vertical coordinate #4588

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5f64fbc
start with this
simone-silvestri Jun 9, 2025
693e8f5
add in docs
navidcy Jun 10, 2025
cf12e7a
start with the continuity equation
simone-silvestri Jun 10, 2025
fc221b4
Merge branch 'ss/non-linear-docs' of github.com:CliMA/Oceananigans.jl…
simone-silvestri Jun 10, 2025
54afaf5
continue with the tracer equations
simone-silvestri Jun 10, 2025
f218fd5
adding the tracer equation
simone-silvestri Jun 10, 2025
561cd04
need to fix the derivation of the tracer equation
simone-silvestri Jun 10, 2025
7b4d07b
add more content
simone-silvestri Jun 10, 2025
ae168a1
better description
simone-silvestri Jun 10, 2025
787a202
Merge branch 'main' into ss/non-linear-docs
simone-silvestri Jun 10, 2025
bfb54d5
generalized vertical coordinate
simone-silvestri Jun 10, 2025
0f0de5d
Merge branch 'ss/non-linear-docs' of github.com:CliMA/Oceananigans.jl…
simone-silvestri Jun 10, 2025
0192f8a
comment
simone-silvestri Jun 10, 2025
c73cdd6
use r
simone-silvestri Jun 10, 2025
714b686
beautifications + add citation
navidcy Jun 10, 2025
d393993
add Adcroft and Campin 2004 star
navidcy Jun 10, 2025
39c4cc9
Merge branch 'main' into ss/non-linear-docs
navidcy Jun 10, 2025
8cf6aca
few rendering
navidcy Jun 10, 2025
518cbe2
Update zstar_vertical_coordinate.md
navidcy Jun 10, 2025
099a3b4
fix tracer equation
simone-silvestri Jun 11, 2025
542e7d5
Merge branch 'ss/non-linear-docs' of github.com:CliMA/Oceananigans.jl…
simone-silvestri Jun 11, 2025
65e72cc
ready to go
simone-silvestri Jun 11, 2025
010923e
Merge branch 'main' into ss/non-linear-docs
simone-silvestri Jun 11, 2025
d3db236
removing a cdot
simone-silvestri Jun 11, 2025
bf1315d
Merge branch 'ss/non-linear-docs' of github.com:CliMA/Oceananigans.jl…
simone-silvestri Jun 11, 2025
70ac5d3
adding horizontal pressure gradients
simone-silvestri Jun 11, 2025
87c2f78
add a comment
simone-silvestri Jun 11, 2025
c464adb
add this
simone-silvestri Jun 11, 2025
3e1bbcd
vertical coordinates
simone-silvestri Jun 11, 2025
7a87593
just build docs
simone-silvestri Jun 11, 2025
ff19777
citet -> citep + few tweaks
navidcy Jun 11, 2025
cf8f2e8
few tweaks
navidcy Jun 11, 2025
8bd9e3a
Merge branch 'main' into ss/non-linear-docs
navidcy Jul 6, 2025
0b7a3e6
better format in docstring
navidcy Jul 6, 2025
bed5ede
$..$ -> ..
navidcy Jul 6, 2025
54a5351
Merge branch 'main' into ss/non-linear-docs
navidcy Jul 6, 2025
acbec1a
Update zstar_vertical_coordinate.md
navidcy Jul 6, 2025
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
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ model_setup_pages = [

physics_pages = [
"Coordinate system and notation" => "physics/notation.md",
"Vertical coordinates" => "physics/zstar_vertical_coordinate.md",
"Boussinesq approximation" => "physics/boussinesq.md",
"`NonhydrostaticModel`" => [
"Nonhydrostatic model" => "physics/nonhydrostatic_model.md",
Expand Down
11 changes: 11 additions & 0 deletions docs/oceananigans.bib
Original file line number Diff line number Diff line change
Expand Up @@ -999,3 +999,14 @@ @inproceedings{Verstappen14
pages={417--426},
year={2014}
}

@article{adcroft2004rescaled,
title={Rescaled height coordinates for accurate representation of free-surface flows in ocean circulation models},
author={Adcroft, Alistair and Campin, Jean-Michel},
journal={Ocean Modelling},
volume={7},
number={3-4},
pages={269--284},
year={2004},
doi={10.1016/j.ocemod.2003.09.003}
}
128 changes: 128 additions & 0 deletions docs/src/physics/zstar_vertical_coordinate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Generalized vertical coordinate

For `HydrostaticFreeSurfaceModel()`, the user can choose between a `ZCoordinate` and a `ZStar` vertical coordinate.
Copy link
Member

Choose a reason for hiding this comment

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

given that this section is only relevant for HydrostaticFreeSurfaceModel() perhaps we move it a bit further down in the docs structure?

A `ZStar` vertical coordinate conserves tracers and volume with the grid following the evolution of the free surface in the domain [adcroft2004rescaled](@citet).
To obtain the (discrete) equations evolved in a general framework where the vertical coordinate is moving, we perform a scaling of the continuous primitive equations to a generalized coordinate ``r(x, y, z, t)``.

We have that:

```math
\begin{alignat}{2}
& \frac{\partial \phi}{\partial s}\bigg\rvert_{z} && = \frac{\partial \phi}{\partial s}\bigg\rvert_{r} + \frac{\partial \phi}{\partial r}\cdot \frac{\partial r}{\partial s} \\
& \frac{\partial \phi}{\partial z} && = \frac{1}{\sigma}\frac{\partial \phi}{\partial r}
\end{alignat}
```
where $s = x, y, t$ and
```math
\begin{equation}
\sigma = \frac{\partial z}{\partial r} \bigg\rvert_{x, y, t}
\end{equation}
```
We can also write the spatial derivatives of the ``r``-coordinate as follows
```math
\frac{\partial r}{\partial x}\bigg\rvert_{y, z, t} = - \frac{\partial z}{\partial x}\bigg\rvert_{y, s, t} \frac{1}{\sigma}
```
Such that the chain rule above for horizontal spatial derivatives (``x`` and ``y``) becomes

```math
\begin{alignat}{2}
& \frac{\partial \phi}{\partial x}\bigg\rvert_{z} && = \frac{\partial \phi}{\partial x}\bigg\rvert_{r} - \frac{1}{\sigma}\frac{\partial \phi}{\partial r} \frac{\partial z}{\partial x} \\
& \frac{\partial \phi}{\partial y}\bigg\rvert_{z} && = \frac{\partial \phi}{\partial y}\bigg\rvert_{r} - \frac{1}{\sigma}\frac{\partial \phi}{\partial r} \frac{\partial z}{\partial y}
\end{alignat}
```
## Continuity Equation
Following the above ruleset, the divergence of the velocity field can be rewritten as
```math
\begin{align}
\boldsymbol{\nabla} \boldsymbol{\cdot} \boldsymbol{u} & = \frac{\partial u}{\partial x} \bigg\rvert_{z} + \frac{\partial v}{\partial y} \bigg\rvert_{z} + \frac{\partial w}{\partial z} \\
& = \frac{\partial u}{\partial x} \bigg\rvert_{r} + \frac{\partial v}{\partial y} \bigg\rvert_{r} - \frac{1}{\sigma} \left( \frac{\partial u}{\partial r} \frac{\partial z}{\partial x} + \frac{\partial v}{\partial y} \frac{\partial z}{\partial y} - \frac{\partial w}{\partial r} \right) \\
& = \frac{1}{\sigma} \left( \frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y} \bigg\rvert_{r} - u \frac{\partial \sigma}{\partial x} \bigg\rvert_{r} - v \frac{\partial \sigma}{\partial y} \bigg\rvert_{r} \right)- \frac{1}{\sigma} \left( \frac{\partial u}{\partial r} \frac{\partial z}{\partial x} + \frac{\partial v}{\partial y} \frac{\partial z}{\partial y} - \frac{\partial w}{\partial r} \right)
\end{align}
```
We can rewrite $\partial_x \sigma \rvert_r = \partial_r(\partial_x z)$ and the same for the ``y`` direction. Then the above yields
```math
\begin{align}
\boldsymbol{\nabla} \boldsymbol{\cdot} \boldsymbol{u} & = \frac{1}{\sigma} \left( \frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y}\bigg\rvert_{r} \right)- \frac{1}{\sigma} \left( u \frac{\partial^2 z}{\partial x \partial r} + v \frac{\partial^2 z}{\partial y \partial r} + \frac{\partial u}{\partial r} \frac{\partial z}{\partial x} + \frac{\partial v}{\partial y} \frac{\partial z}{\partial y} - \frac{\partial w}{\partial r} \right) \\
& = \frac{1}{\sigma} \left( \frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} \frac{\partial}{\partial r} \left( u \frac{\partial z}{\partial x} + v \frac{\partial z}{\partial y} + w \right)
\end{align}
```
Here, $w$ is the vertical velocity corresponding to the ``z`` coordinate. We can define a vertical velocity $w_p$ of a point moving with the horizontal velocity along an ``r`` surface
```math
w_p = \frac{\partial z}{\partial t} \bigg\rvert_r + u \frac{\partial z}{\partial x} + v \frac{\partial z}{\partial y}
```
The vertical velocity across the ``r`` surfaces will be
```math
\omega = w - w_p = w - \frac{\partial z}{\partial t} \bigg\rvert_r - u \frac{\partial z}{\partial x} - v \frac{\partial z}{\partial y}
```
Therefore, adding the definition of $\omega$ to the velocity divergence we get
```math
\begin{align}
\boldsymbol{\nabla} \boldsymbol{\cdot} \boldsymbol{u} & = \frac{1}{\sigma} \left( \frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} \frac{\partial}{\partial r} \left( \omega + \frac{\partial z}{\partial t}\bigg\rvert_r \right) \\
& = \frac{1}{\sigma} \left( \frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} \frac{\partial \omega}{\partial r} + \frac{1}{\sigma} \frac{\partial \sigma}{\partial t} \\
\end{align}
```
Which finally leads to the continuity equation
```math
\frac{\partial \sigma}{\partial t} + \frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y}\bigg\rvert_{r} + \frac{\partial \omega}{\partial r} = 0
```
### Finite volume discretization of the continuity equation

It is usefull to think about this equation in the discrete form in a finite volume staggered C-grid framework, where we integrate over a volume $V_r = \Delta x \Delta y \Delta r$ remembering that in the discrete $\Delta z = \sigma \Delta r$. The indices `i`, `j`, `k` correspond to the `x`, `y`, and vertical direction.
```math
\frac{1}{V_r}\int_{V_r} \frac{\partial \sigma}{\partial t} \, \mathrm{d}V + \frac{1}{V_r} \int_{V_r} \left(\frac{\partial \sigma u}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v}{\partial y}\bigg\rvert_{r} + \frac{\partial \omega}{\partial r}\right) \, \mathrm{d}V = 0
```
Using the divergence theorem, and introducing the notation of cell-average values $V_r^{-1}\int_{V_r} \phi dV = \overline{\phi}$
```math
\frac{\partial \overline{\sigma}}{\partial t} + \frac{1}{\Delta x\Delta y \Delta r} \left( \Delta y \Delta r \sigma u\rvert_{i-1/2}^{i+1/2} + \Delta x \Delta r \sigma v\rvert_{j-1/2}^{j+1/2} \right ) + \frac{\overline{\omega}_{k+1/2} - \overline{\omega}_{k-1/2}}{\Delta r} = 0
```
The above equation is used to diagnose the vertical velocity (in `r` space) given the grid velocity and the horizontal velocity divergence:
```math
\overline{\omega}_{k+1/2} = \overline{\omega}_{k-1/2} + \Delta r \frac{\partial \overline{\sigma}}{\partial t} + \frac{1}{Az} \left( \mathcal{U}\rvert_{i-1/2}^{i+1/2} + \mathcal{V}\rvert_{j-1/2}^{j+1/2} \right )
```
where $\mathcal{U} = Axu$, $\mathcal{V} = Ayv$, $Ax = \Delta y \Delta z$, $Ay = \Delta x \Delta z$, and $Az = \Delta x \Delta y$.

## Tracer equations
The tracer equation with vertical diffusion reads
```math
\frac{\partial T}{\partial t} + \boldsymbol{\nabla} \boldsymbol{\cdot} ( \boldsymbol{u}T ) = \partial_z \left( \kappa \frac{\partial T}{\partial z} \right)
```
Using the same procedure we followed for the continuity equation, $\partial_t T + \boldsymbol{\nabla} \boldsymbol{\cdot} ( \boldsymbol{u}T )$ yields
```math
\begin{align}
\frac{\partial T}{\partial t} + \boldsymbol{\nabla} \boldsymbol{\cdot} ( \boldsymbol{u}T ) & = \frac{\partial T}{\partial t} + \frac{1}{\sigma} \left( \frac{\partial \sigma u T}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v T}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} \frac{\partial}{\partial r}\left( T\omega + T \frac{\partial z}{\partial t}\bigg\rvert_r \right) \\
& = \frac{\partial T}{\partial t} + \frac{1}{\sigma} \left( \frac{\partial \sigma u T}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v T}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} T\left( \frac{\partial \omega}{\partial r} + \frac{\partial \sigma}{\partial t} \right) + \frac{1}{\sigma} \left( \omega + \frac{\partial z}{\partial t}\bigg\rvert_r \right)\frac{\partial T}{\partial r}\\
& = \frac{1}{\sigma}\frac{\partial \sigma T}{\partial t} + \frac{1}{\sigma} \left( \frac{\partial \sigma u T}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v T}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} T \frac{\partial \omega}{\partial r}+ \frac{1}{\sigma} \omega\frac{\partial T}{\partial r}\\
\end{align}
```
We add vertical diffusion to the RHS to recover the tracer equation
```math
\frac{1}{\sigma}\frac{\partial \sigma T}{\partial t} + \frac{1}{\sigma} \left( \frac{\partial \sigma u T}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v T}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} \frac{\partial T \omega}{\partial r} = \frac{1}{\sigma}\frac{\partial}{\partial r} \left( \kappa \frac{\partial T}{\partial z} \right)
```
### Finite-volume discretization of the tracer equation

We discretize the equation in a finite volume framework
```math
\frac{1}{V_r}\int_{V_r} \frac{1}{\sigma}\frac{\partial \sigma T}{\partial t} + \frac{1}{V_r} \int_{V_r} \left[ \frac{1}{\sigma} \left( \frac{\partial \sigma u T}{\partial x} \bigg\rvert_{r} + \frac{\partial \sigma v T}{\partial y}\bigg\rvert_{r} \right) + \frac{1}{\sigma} \frac{\partial T \omega}{\partial r}\right] \, \mathrm{d}V = \frac{1}{V_r}\int_{V_r} \frac{1}{\sigma}\frac{\partial}{\partial r} \left( \kappa \frac{\partial T}{\partial z} \right) \, \mathrm{d}V
```
leading to
```math
\frac{1}{\sigma}\frac{\partial \sigma \overline{T}}{\partial t} + \frac{\mathcal{U}T\rvert_{i-1/2}^{i+1/2} + \mathcal{V}T\rvert_{j-1/2}^{j+1/2} + \mathcal{W} T\rvert_{k-1/2}^{k+1/2}}{V} = \frac{1}{V} \left(\mathcal{K} \frac{\partial T}{\partial z}\bigg\rvert_{k-1/2}^{k+1/2} \right)
```
where $V = \sigma V_r = \Delta x \Delta y \Delta z$, $\mathcal{U} = Axu$, $\mathcal{V} = Ay v$, $\mathcal{W} = Az \omega$, and $\mathcal{K} = Az \kappa$. <br>
In case of an explicit formulation of the diffusive fluxes, the time discretization of the above equation (using Forward Euler) yields
```math
\begin{equation}
T^{n+1} = \frac{\sigma^n}{\sigma^{n+1}}\left(T^n + \Delta t \, G^n \right)
\end{equation}
```
where $G^n$ is tendency computed on the `z`-grid. <br>
Note that in case of a multi-step method, like second-order Adams Bashorth, the grid at different time-steps must be accounted for, and the time discretization becomes
```math
\begin{equation}
T^{n+1} = \frac{1}{\sigma^{n+1}}\left[\sigma^n T^n + \Delta t \left(\frac{3}{2}\sigma^n G^n - \frac{1}{2} \sigma^{n-1} G^{n-1} \right)\right]
\end{equation}
```
For this reason, we store tendencies pre-multipled by $\sigma$ at their current time-level.
In case of an implicit discretization of the diffusive fluxes we first compute $T^{n+1}$ as in the above equation (where $G^n$ does not contain the diffusive fluxes).
Then the implicit step is done on a `z`-grid as if the grid was static, using the grid at $n+1$ which includes $\sigma^{n+1}$.