Skip to content
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

Add background zonal flow U or U(y) in the SingleLayerQG module #360

Merged
merged 39 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
16bd801
Update singlelayerqg.jl to include background flow
mncrowe Jun 17, 2024
30178e1
Fixed typo in previous change
mncrowe Jun 17, 2024
4362a87
added background flow test
mncrowe Jun 27, 2024
76f1643
corrected typo
mncrowe Jun 27, 2024
4781b8d
Added some spaces to cheer up Greg
mncrowe Jun 27, 2024
eada586
more spaces
mncrowe Jun 27, 2024
cc1b78a
added variable U functionality
mncrowe Jul 22, 2024
e756aa1
Merge branch 'main' into main
mncrowe Jul 22, 2024
3ce3abd
reduced memory of Uy assignment and updated function descriptions
mncrowe Jul 22, 2024
8641abe
Merge branch 'main' of https://github.com/mncrowe/GeophysicalFlows.jl
mncrowe Jul 22, 2024
9bd7576
update function descriptions
mncrowe Jul 22, 2024
f0baf3f
T(U) -> convert(T, U)
mncrowe Jul 22, 2024
deea626
clarify U array formulation
mncrowe Jul 22, 2024
f351da2
fix bug with previous push
mncrowe Jul 22, 2024
8c1859f
add additional test function for U as an Array and include tests in
mncrowe Jul 23, 2024
dd93d22
simplify background U and use Rossby wave test for U that does not va…
navidcy Jul 27, 2024
122b713
homogenize notation/docs
navidcy Jul 27, 2024
ab0fe02
bump patch release
navidcy Jul 27, 2024
dd3c1ad
Merge remote-tracking branch 'upstream/main'
navidcy Jul 27, 2024
85d4393
fix test for gpu
navidcy Jul 27, 2024
619f398
== -> ===
navidcy Jul 27, 2024
ace06eb
use different calcN_advection! methods for U const and y-varying
navidcy Jul 27, 2024
2fcccc7
minor tweaks
navidcy Jul 27, 2024
20a361b
update singlelayergq module in docs
navidcy Jul 27, 2024
346f914
homogenize notation/wording
navidcy Jul 27, 2024
e6e7707
add empty line
navidcy Jul 28, 2024
73399f0
code alignment
navidcy Jul 28, 2024
99eb5ff
add Qx and Qy in params; refactor calcN_advection
navidcy Jul 28, 2024
6604120
clarify when U=const
navidcy Jul 28, 2024
f387333
some fixes + cleanup
navidcy Jul 28, 2024
40cc4db
add nonlinear advection test for finite deformation + topo
navidcy Jul 28, 2024
63a7a8c
fixes nonlinear advection w U(y) + add tests
navidcy Jul 28, 2024
6430e59
add comment for β term
navidcy Jul 28, 2024
48f2f1b
remove debug statements + fix test for julia 1.6
navidcy Jul 28, 2024
42d9003
more tests for the nonlinear terms
navidcy Jul 28, 2024
22e3bde
fix test_1layerqg_nonlinearadvection on gpu
navidcy Jul 28, 2024
c6cf36a
fix test_1layerqg_nonlinearadvection on gpu
navidcy Jul 28, 2024
5c9eb93
improve docs
navidcy Jul 28, 2024
1d2509f
drop GeophysicalFlows from docs/Project.toml
navidcy Jul 29, 2024
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "GeophysicalFlows"
uuid = "44ee3b1c-bc02-53fa-8355-8e347616e15e"
license = "MIT"
authors = ["Navid C. Constantinou <[email protected]>", "Gregory L. Wagner <[email protected]>", "and contributors"]
version = "0.16.1"
version = "0.16.2"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down
6 changes: 5 additions & 1 deletion docs/src/modules/multilayerqg.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ with
```math
\begin{aligned}
\partial_y Q_j &\equiv \beta - \partial_y^2 U_j - (1-\delta_{j,1}) F_{j-1/2, j} (U_{j-1} - U_j) - (1 - \delta_{j,n}) F_{j+1/2, j} (U_{j+1} - U_j) + \delta_{j,n} \partial_y \eta , \\
\partial_x Q_j &\equiv \delta_{j, n} \partial_x \eta .
\partial_x Q_j & \equiv \delta_{j, n} \partial_x \eta ,
\end{aligned}
```

the background PV gradient components in each layer and with
``\mathsf{J}(a, b) = (\partial_x a)(\partial_y b)-(\partial_y a)(\partial_x b)`` is the
two-dimensional Jacobian. On the right hand side, ``\mu`` is linear bottom drag, and ``\nu`` is
hyperviscosity of order ``n_\nu``. Plain old viscosity corresponds to ``n_\nu = 1``.

### Implementation

Expand Down
37 changes: 27 additions & 10 deletions docs/src/modules/singlelayerqg.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,50 @@ radius follows is said to obey equivalent-barotropic dynamics. We denote the sum
vorticity and the vortex stretching contributions to the QGPV with ``q \equiv \nabla^2 \psi - \psi / \ell^2``.
Also, we denote the topographic PV with ``\eta \equiv f_0 h / H``.

The dynamical variable is ``q``. Thus, the equation solved by the module is:
The dynamical variable is ``q``. Including an imposed zonal flow ``U(y)``, the equation of motion is:

```math
\partial_t q + \mathsf{J}(\psi, q + \eta) + \beta \partial_x \psi =
\underbrace{-\left[\mu + \nu(-1)^{n_\nu} \nabla^{2n_\nu} \right] q}_{\textrm{dissipation}} + F .
\partial_t q + \mathsf{J}(\psi, q) + (U - \partial_y\psi) \partial_x Q + U \partial_x q + (\partial_y Q)(\partial_x \psi) = \underbrace{-\left[\mu + \nu(-1)^{n_\nu} \nabla^{2n_\nu} \right] q}_{\textrm{dissipation}} + F ,
```

where ``\mathsf{J}(a, b) = (\partial_x a)(\partial_y b)-(\partial_y a)(\partial_x b)`` is the
two-dimensional Jacobian. On the right hand side, ``F(x, y, t)`` is forcing, ``\mu`` is
with

```math
\begin{aligned}
\partial_y Q &\equiv \beta - \partial_y^2 U + \partial_y \eta , \\
\partial_x Q &\equiv \partial_x \eta ,
\end{aligned}
```

the background PV gradient components, and with
``\mathsf{J}(a, b) = (\partial_x a)(\partial_y b) - (\partial_y a)(\partial_x b)``
the two-dimensional Jacobian. On the right hand side, ``F(x, y, t)`` is forcing, ``\mu`` is
linear drag, and ``\nu`` is hyperviscosity of order ``n_\nu``. Plain old viscosity corresponds
to ``n_\nu = 1``.

In the case that the imposed background zonal flow is just a constant, the above simplifies to:

```math
\partial_t q + \mathsf{J}(\psi, q + \eta) + U \partial_x (q + \eta) + β \partial_x \psi = \underbrace{-\left[\mu + \nu(-1)^{n_\nu} \nabla^{2n_\nu} \right] q}_{\textrm{dissipation}} + F ,
```

and thus the advection of ``q`` can be incorporated in the linear term ``L``.

### Implementation

The equation is time-stepped forward in Fourier space:

```math
\partial_t \widehat{q} = - \widehat{\mathsf{J}(\psi, q + \eta)} + \beta \frac{i k_x}{|𝐤|^2 + 1/\ell^2} \widehat{q} - \left(\mu + \nu |𝐤|^{2n_\nu} \right) \widehat{q} + \widehat{F} .
\partial_t \widehat{q} = - \widehat{\mathsf{J}(\psi, q)} - \widehat{U \partial_x Q} - \widehat{U \partial_x q}
+ \widehat{(\partial_y \psi) (\partial_x Q)} - \widehat{(\partial_x \psi)(\partial_y Q)} - \left(\mu + \nu |𝐤|^{2n_\nu} \right) \widehat{q} + \widehat{F} .
```

In doing so the Jacobian is computed in the conservative form: ``\mathsf{J}(f,g) =
\partial_y [ (\partial_x f) g] - \partial_x[ (\partial_y f) g]``.

The state variable `sol` is the Fourier transform of the sum of relative vorticity and vortex
stretching (when the latter is applicable), [`qh`](@ref GeophysicalFlows.SingleLayerQG.Vars).

The Jacobian is computed in the conservative form: ``\mathsf{J}(f, g) =
\partial_y [ (\partial_x f) g] - \partial_x[ (\partial_y f) g]``.

The linear operator is constructed in `Equation`

```@docs
Expand Down Expand Up @@ -122,4 +139,4 @@ Other diagnostic include: [`energy_dissipation`](@ref GeophysicalFlows.SingleLay
(barotropic quasi-geostrophic flow with ``\beta=0``) above topography.

- [`examples/singlelayerqg_decaying_barotropic_equivalentbarotropic.jl`](@ref singlelayerqg_decaying_barotropic_equivalentbarotropic_example):
Simulate two dimensional turbulence (``\beta=0``) with both infinite and finite Rossby radius of deformation and compares the evolution of the two.
Simulate two dimensional turbulence (``\beta=0``) with both infinite and finite Rossby radius of deformation and compares the evolution of the two.
5 changes: 3 additions & 2 deletions src/multilayerqg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Keyword arguments
- `Ly`: Extent of the ``y``-domain.
- `f₀`: Constant planetary vorticity.
- `β`: Planetary vorticity ``y``-gradient.
- `U`: The imposed constant zonal flow ``U(y)`` in each fluid layer.
- `U`: Imposed background constant zonal flow ``U(y)`` in each fluid layer.
- `H`: Rest height of each fluid layer.
- `b`: Boussinesq buoyancy of each fluid layer.
- `eta`: Periodic component of the topographic potential vorticity.
Expand Down Expand Up @@ -757,7 +757,7 @@ function calcN_advection!(N, sol, vars, params, grid)
@. vars.u += params.U # add the imposed zonal flow U

uQx, uQxh = vars.q, vars.uh # use vars.q and vars.uh as scratch variables
@. uQx = vars.u * params.Qx # (U+u)*∂Q/∂x
@. uQx = vars.u * params.Qx # (U+u)*∂Q/∂x
fwdtransform!(uQxh, uQx, params)
@. N = - uQxh # -\hat{(U+u)*∂Q/∂x}

Expand Down Expand Up @@ -803,6 +803,7 @@ function calcN_linearadvection!(N, sol, vars, params, grid)
@. vars.vh = im * grid.kr * vars.ψh

invtransform!(vars.u, vars.uh, params)

@. vars.u += params.U # add the imposed zonal flow U
uQx, uQxh = vars.q, vars.uh # use vars.q and vars.uh as scratch variables
@. uQx = vars.u * params.Qx # (U+u)*∂Q/∂x
Expand Down
Loading
Loading