Functions

GeophysicalFlows

Exported functions

GeophysicalFlows.lambdipoleFunction
lambdipole(U, R, grid::TwoDGrid; center=(mean(grid.x), mean(grid.y))

Return the two-dimensional vorticity field of the Lamb dipole with strength U and radius R, centered on center=(xc, yc) and on the grid. Default value for center is the center of the domain.

source
GeophysicalFlows.peakedisotropicspectrumFunction
peakedisotropicspectrum(grid, kpeak, E₀; mask=mask, allones=false)

Generate a random two-dimensional relative vorticity field $q(x, y)$ with Fourier spectrum peaked around a central non-dimensional wavenumber kpeak and normalized so that its total kinetic energy is E₀.

source

TwoDNavierStokes

Exported functions

GeophysicalFlows.TwoDNavierStokes.ProblemFunction
Problem(dev::Device=CPU();
            nx = 256,
            ny = nx,
            Lx = 2π,
            Ly = Lx,
             ν = 0,
            nν = 1,
             μ = 0,
            nμ = 0,
            dt = 0.01,
       stepper = "RK4",
         calcF = nothingfunction,
    stochastic = false,

aliased_fraction = 1/3, T = Float64)

Construct a two-dimensional Navier-Stokes problem on device dev.

Keyword arguments

- `dev`: (required) `CPU()` or `GPU()`; computer architecture used to time-step `problem`.
- `nx`: Number of grid points in ``x``-domain.
- `ny`: Number of grid points in ``y``-domain.
- `Lx`: Extent of the ``x``-domain.
- `Ly`: Extent of the ``y``-domain.
- `ν`: Small-scale (hyper)-viscosity coefficient.
- `nν`: (Hyper)-viscosity order, `nν```≥ 1``".
- `μ`: Large-scale (hypo)-viscosity coefficient".
- `nμ`: (Hypo)-viscosity order, `nμ```≤ 0``.
- `dt`: Time-step.
- `stepper`: The extent of the ``y``-domain.
- `calcF`: Function that calculates the Fourier transform of the forcing, ``F̂``.
- `stochastic`: `true` or `false`; boolean denoting whether `calcF` is temporally stochastic.
- `aliased_fraction`: the fraction of high-wavenubers that are zero-ed out by `dealias!()`.
- `T`: `Float32` or `Float64`; floating point type used for `problem` data.
source

Private functions

GeophysicalFlows.TwoDNavierStokes.calcN_advection!Function
calcN_advection!(N, sol, t, clock, vars, params, grid)

Calculate the Fourier transform of the advection term, $- 𝖩(ψ, ζ)$ in conservative form, i.e., $- ∂_x[(∂_y ψ)ζ] - ∂_y[(∂_x ψ)ζ]$ and store it in N:

\[N = - \widehat{𝖩(ψ, ζ)} = - i k_x \widehat{u ζ} - i k_y \widehat{v ζ} .\]

source
GeophysicalFlows.TwoDNavierStokes.energy_dissipationFunction
energy_dissipation(prob, ξ, νξ)

Return the domain-averaged energy dissipation rate done by the viscous term,

\[- ξ (-1)^{n_ξ+1} \int ψ ∇^{2n_ξ} ζ \frac{𝖽x 𝖽y}{L_x L_y} = - ξ \sum_{𝐤} |𝐤|^{2(n_ξ-1)} |ζ̂|² ,\]

where $ξ$ and $nξ$ could be either the (hyper)-viscosity coefficient $ν$ and its order $n_ν$, or the hypo-viscocity coefficient $μ$ and its order $n_μ$.

source
GeophysicalFlows.TwoDNavierStokes.enstrophy_dissipationFunction
enstrophy_dissipation(prob, ξ, νξ)

Return the domain-averaged enstrophy dissipation rate done by the viscous term,

\[ξ (-1)^{n_ξ+1} \int ζ ∇^{2n_ξ} ζ \frac{𝖽x 𝖽y}{L_x L_y} = - ξ \sum_{𝐤} |𝐤|^{2n_ξ} |ζ̂|² ,\]

where $ξ$ and $nξ$ could be either the (hyper)-viscosity coefficient $ν$ and its order $n_ν$, or the hypo-viscocity coefficient $μ$ and its order $n_μ$.

source

SingleLayerQG

Exported functions

GeophysicalFlows.SingleLayerQG.ProblemFunction
Problem(dev::Device=CPU();
                  nx = 256,
                  ny = nx,
                  Lx = 2π,
                  Ly = Lx,
                   β = 0.0,
  deformation_radius = Inf,
                 eta = nothing,
                   ν = 0.0,
                  nν = 1,
                   μ = 0.0,
                  dt = 0.01,
             stepper = "RK4",
               calcF = nothingfunction,
          stochastic = false,
    aliased_fraction = 1/3,
                   T = Float64)

Construct a single-layer quasi-geostrophic problem on device dev.

Keyword arguments

- `dev`: (required) `CPU()` or `GPU()`; computer architecture used to time-step `problem`.
- `nx`: Number of grid points in ``x``-domain.
- `ny`: Number of grid points in ``y``-domain.
- `Lx`: Extent of the ``x``-domain.
- `Ly`: Extent of the ``y``-domain.
- `β`: Planetary vorticity ``y``-gradient.
- `deformation_radius`: Rossby radius of deformation; set `Inf` for purely barotropic.
- `eta`: Topographic potential vorticity.
- `ν`: Small-scale (hyper)-viscosity coefficient.
- `nν`: (Hyper)-viscosity order, `nν```≥ 1``".
- `μ`: Linear drag coefficient.
- `dt`: Time-step.
- `stepper`: The extent of the ``y``-domain.
- `calcF`: Function that calculates the Fourier transform of the forcing, ``F̂``.
- `stochastic`: `true` or `false`; boolean denoting whether `calcF` is temporally stochastic.
- `aliased_fraction`: the fraction of high-wavenubers that are zero-ed out by `dealias!()`.
- `T`: `Float32` or `Float64`; floating point type used for `problem` data.
source
GeophysicalFlows.SingleLayerQG.enstrophyFunction
enstrophy(prob)
enstrophy(sol, vars, params, grid)

Return the domain-averaged enstrophy

\[\int \frac1{2} (q + η)² \frac{𝖽x 𝖽y}{L_x L_y} = \sum_{𝐤} \frac1{2} |q̂ + η̂|² .\]

source

Private functions

GeophysicalFlows.SingleLayerQG.calcN_advection!Function
calcN_advection!(N, sol, t, clock, vars, params, grid)

Calculate the Fourier transform of the advection term, $- 𝖩(ψ, q+η)$ in conservative form, i.e., $- ∂_x[(∂_y ψ)(q+η)] - ∂_y[(∂_x ψ)(q+η)]$ and store it in N:

\[N = - \widehat{𝖩(ψ, q+η)} = - i k_x \widehat{u (q+η)} - i k_y \widehat{v (q+η)} .\]

source

MultiLayerQG

Exported functions

GeophysicalFlows.MultiLayerQG.ProblemFunction
Problem(nlayers::Int,
            dev = CPU();
             nx = 128,
             ny = nx,
             Lx = 2π,
             Ly = Lx,
             f₀ = 1.0,
              β = 0.0,
              g = 1.0,
              U = zeros(nlayers),
              H = 1/nlayers * ones(nlayers),
              ρ = Array{Float64}(1:nlayers),
            eta = nothing,
              μ = 0,
              ν = 0,
             nν = 1,
             dt = 0.01,
        stepper = "RK4",
         calcFq = nothingfunction,
     stochastic = false,
         linear = false,

aliased_fraction = 1/3, T = Float64)

Construct a multi-layer quasi-geostrophic problem with nlayers fluid layers on device dev.

Keyword arguments

- `nlayers`: (required) Number of fluid layers.
- `dev`: (required) `CPU()` or `GPU()`; computer architecture used to time-step `problem`.
- `nx`: Number of grid points in ``x``-domain.
- `ny`: Number of grid points in ``y``-domain.
- `Lx`: Extent of the ``x``-domain.
- `Ly`: Extent of the ``y``-domain.
- `f₀`: Constant planetary vorticity.
- `β`: Planetary vorticity ``y``-gradient.
- `g`: Gravitational accelaration constant.
- `U`: T imposed constant zonal flow U(y) in each fluid layer.
- `H`: Rest height of each fluid layer.
- `ρ`: Densities of each fluid layer.
- `eta`: Topographic potential vorticity.
- `μ`: Linear bottom drag coefficient.
- `ν`: Small-scale (hyper)-viscosity coefficient.
- `nν`: (Hyper)-viscosity order, `nν```≥ 1``".
- `dt`: Time-step.
- `stepper`: The extent of the ``y``-domain.
- `calcF`: Function that calculates the Fourier transform of the forcing, ``F̂``.
- `stochastic`: `true` or `false`; boolean denoting whether `calcF` is temporally stochastic.
- `aliased_fraction`: the fraction of high-wavenubers that are zero-ed out by `dealias!()`.
- `T`: `Float32` or `Float64`; floating point type used for `problem` data.
source

Private functions

GeophysicalFlows.MultiLayerQG.LinearEquationFunction
LinearEquation(dev, params, grid)

Return the equation for a multi-layer quasi-geostrophic problem with params and grid. The linear opeartor $L$ includes only (hyper)-viscosity and is computed via hyperviscosity(dev, params, grid).

The nonlinear term is computed via function calcNlinear!.

source
GeophysicalFlows.MultiLayerQG.calcNlinear!Function
calcNlinear!(N, sol, t, clock, vars, params, grid)

Compute the nonlinear term of the linearized equations:

\[N_j = - \widehat{U_j ∂_x Q_j} - \widehat{U_j ∂_x q_j} + \widehat{(∂_y ψ_j)(∂_x Q_j)} - \widehat{(∂_x ψ_j)(∂_y Q_j)} + δ_{j, n} μ |𝐤|^2 ψ̂_n + F̂_j .\]

source
GeophysicalFlows.MultiLayerQG.calcN_advection!Function
calcN_advection!(N, sol, vars, params, grid)

Compute the advection term and stores it in N:

\[N_j = - \widehat{𝖩(ψ_j, q_j)} - \widehat{U_j ∂_x Q_j} - \widehat{U_j ∂_x q_j} + \widehat{(∂_y ψ_j)(∂_x Q_j)} - \widehat{(∂_x ψ_j)(∂_y Q_j)} .\]

source
GeophysicalFlows.MultiLayerQG.calcN_linearadvection!Function
calcN_linearadvection!(N, sol, vars, params, grid)

Compute the advection term of the linearized equations and stores it in N:

\[N_j = - \widehat{U_j ∂_x Q_j} - \widehat{U_j ∂_x q_j} + \widehat{(∂_y ψ_j)(∂_x Q_j)} - \widehat{(∂_x ψ_j)(∂_y Q_j)} .\]

source

SurfaceQG

Exported functions

GeophysicalFlows.SurfaceQG.ProblemFunction
Problem(dev::Device=CPU();
             nx = 256,
             Lx = 2π,
             ny = nx,
             Ly = Lx,
              ν = 0,
             nν = 1,
             dt = 0.01,
        stepper = "RK4",
          calcF = nothingfunction,
     stochastic = false,

aliased_fraction = 1/3, T = Float64)

Construct a surface quasi-geostrophic problem on device dev.

Keyword arguments

- `dev`: (required) `CPU()` or `GPU()`; computer architecture used to time-step `problem`.
- `nx`: Number of grid points in ``x``-domain.
- `ny`: Number of grid points in ``y``-domain.
- `Lx`: Extent of the ``x``-domain.
- `Ly`: Extent of the ``y``-domain.
- `ν`: Small-scale (hyper)-viscosity coefficient.
- `nν`: (Hyper)-viscosity order, `nν```≥ 1``".
- `dt`: Time-step.
- `stepper`: The extent of the ``y``-domain.
- `calcF`: Function that calculates the Fourier transform of the forcing, ``F̂``.
- `stochastic`: `true` or `false`; boolean denoting whether `calcF` is temporally stochastic.
- `aliased_fraction`: the fraction of high-wavenubers that are zero-ed out by `dealias!()`.
- `T`: `Float32` or `Float64`; floating point type used for `problem` data.
source
GeophysicalFlows.SurfaceQG.buoyancy_dissipationFunction
buoyancy_dissipation(prob)

Return the domain-averaged dissipation rate of surface buoyancy variance due to small scale (hyper)-viscosity,

\[2 ν (-1)^{n_ν} \int b ∇^{2n_ν} b \frac{𝖽x 𝖽y}{L_x L_y} = - 2 ν \sum_{𝐤} |𝐤|^{2n_ν} |b̂|² ,\]

where $ν$ the (hyper)-viscosity coefficient $ν$ and $nν$ the (hyper)-viscosity order. In SQG, this is identical to twice the rate of kinetic energy dissipation

source
GeophysicalFlows.SurfaceQG.buoyancy_workFunction
buoyancy_work(prob)
buoyancy_work(sol, vars, grid)

Return the domain-averaged rate of work of buoyancy variance by the forcing,

\[\int 2 b F \frac{𝖽x 𝖽y}{L_x L_y} = \sum_{𝐤} 2 b̂ F̂^* .\]

source

Private functions

GeophysicalFlows.SurfaceQG.calcN_advection!Function
calcN_advection(N, sol, t, clock, vars, params, grid)

Calculate the Fourier transform of the advection term, $- 𝖩(ψ, b)$ in conservative form, i.e., $- ∂_x[(∂_y ψ)b] - ∂_y[(∂_x ψ)b]$ and store it in N:

\[N = - \widehat{𝖩(ψ, b)} = - i k_x \widehat{u b} - i k_y \widehat{v b} .\]

source

BarotropicQGQL

Exported functions

GeophysicalFlows.BarotropicQGQL.ProblemFunction
Problem(dev::Device=CPU();
                  nx = 256,
                  ny = nx,
                  Lx = 2π,
                  Ly = Lx,
                   β = 0.0,
  deformation_radius = Inf,
                 eta = nothing,
                   ν = 0.0,
                  nν = 1,
                   μ = 0.0,
                  dt = 0.01,
             stepper = "RK4",
               calcF = nothingfunction,
          stochastic = false,
    aliased_fraction = 1/3,
                   T = Float64)

Construct a quasi-linear barotropic quasi-geostrophic problem on device dev.

Keyword arguments

- `dev`: (required) `CPU()` or `GPU()`; computer architecture used to time-step `problem`.
- `nx`: Number of grid points in ``x``-domain.
- `ny`: Number of grid points in ``y``-domain.
- `Lx`: Extent of the ``x``-domain.
- `Ly`: Extent of the ``y``-domain.
- `β`: Planetary vorticity ``y``-gradient.
- `eta`: Topographic potential vorticity.
- `ν`: Small-scale (hyper)-viscosity coefficient.
- `nν`: (Hyper)-viscosity order, `nν```≥ 1``".
- `μ`: Linear drag coefficient.
- `dt`: Time-step.
- `stepper`: The extent of the ``y``-domain.
- `calcF`: Function that calculates the Fourier transform of the forcing, ``F̂``.
- `stochastic`: `true` or `false`; boolean denoting whether `calcF` is temporally stochastic.
- `aliased_fraction`: the fraction of high-wavenubers that are zero-ed out by `dealias!()`.
- `T`: `Float32` or `Float64`; floating point type used for `problem` data.
source

Private functions