KelvinWave

KelvinWave#

class fridom.nonhydro.initial_conditions.kelvin_wave.KelvinWave(mset: ModelSettings, side: str, kz: int, k_parallel: int, phase: float = 0)[source]#

Bases: State

Initial condition with a kelvin wave at the boundary.

TODO: Add some more details about the math, add proper gallery example.

Description#

Lets consider a Kelvin wave at the southern boundary of the domain with the horizontal wavenumber kh and the vertical wavenumber kz. Searching in the linearized nonhydrostatic equations for a solution of the form:

\[(U, V, W, B) \exp(- k_n y) \exp(i(k_h x + k_z z - \omega t))\]

yields

\[\omega = \sqrt{\frac{k_h^2 N^2}{k_h^2 + k_z^2}} \quad k_n = \frac{k_h f_0}{\omega}\]
\[U = - k_z \quad V = 0 \quad W = k_h \quad B = -i N^2 k_h / \omega\]

Similar polarizations can be found for the other boundaries.

Parameters#

msetModelSettings

The model settings object.

sidestr

The side of the domain where the wave is located. Possible values are ‘N’: North, ‘S’: South, ‘E’: East, ‘W’: West.

kzint

The vertical wavenumber. (Can be positive or negative)

khint

The horizontal wavenumber in the direction of the boundary. (Must be positive)

Examples#

import fridom.nonhydro as nh
import numpy as np
grid = nh.grid.cartesian.Grid(
    N=[128]*3, L=[1]*3, periodic_bounds=(True, False, True))
mset = nh.ModelSettings(grid=grid)
mset.time_stepper.dt = np.timedelta64(10, 'ms')
mset.tendencies.advection.disable()
mset.setup()
z = nh.initial_conditions.KelvinWave(mset, 'N', kh=1, kz=2)
model = nh.Model(mset)
model.z = z
model.run(runlen=np.timedelta64(5, 's'))

A vertical mode may be constructed with

z  = nh.initial_conditions.kelvin_wave(mset, 'N', kh=1, kz=2)
z += nh.initial_conditions.kelvin_wave(mset, 'N', kh=1, kz=-2, phase=np.pi)
__init__(mset: ModelSettings, side: str, kz: int, k_parallel: int, phase: float = 0)[source]#

Methods

__init__(mset, side, kz, k_parallel[, phase])

dot(other)

Calculate the dot product of the state with another state.

fft([padding])

Calculate the Fourier transform of the state.

from_netcdf(mset, path)

Read the state from a NetCDF file.

has_nan()

Check if the state contains NaN values.

ifft([padding])

Calculate the inverse Fourier transform of the state.

norm_l2()

Calculate the L2 norm of the state.

norm_of_diff(other)

The norm of the difference between two states.

project(p_vec, q_vec)

Project the state on a (spectral) vector.

sync()

Synchronize the state.

to_netcdf(path)

Write the state to a NetCDF file.

Attributes

arr_dict

Return the dictionary of arrays (not FieldVariables).

b

Buoyancy

cfl

The CFL number.

ekin

The kinetic energy

epot

The potential energy

etot

The total energy

field_list

Return the list of fields.

grid

Return the grid of the model.

linear_pot_vort

Linearized potential vorticity

local_Ro

Local Rossby number

pot_vort

Scaled potential vorticity field.

rel_vort

The relative vorticity

rel_vort_x

X-component of the relative vorticity

rel_vort_y

Y-component of the relative vorticity

rel_vort_z

Z-component of the relative vorticity (Horizontal Vorticity)

u

Velocity in the x-direction.

v

Velocity in the y-direction.

w

Velocity in the z-direction.

xr

State as xarray dataset

xrs

State of sliced domain as xarray dataset