SingleWave

SingleWave#

class fridom.shallowwater.initial_conditions.single_wave.SingleWave(mset: ModelSettings, k: tuple[int], s: int = 1, phase: float = 0, use_discrete: bool = True)[source]#

Bases: State

An initial condition that consist of a single wave with a given wavenumber and a given mode.

Description#

Creates a polarized wave from the eigenvectors of the linearized equations of motion. The wave is initizalized in spectral space as:

\[z(\boldsymbol{k}) = \boldsymbol{q}_s(\boldsymbol{k}) \delta_{\boldsymbol{k}, \boldsymbol{k}_0} \exp(i\phi)\]

where \(\boldsymbol{q}_s\) is the eigenvector of the mode s (see fridom.shallowwater.grid.cartesian.eigenvectors), and \(\delta_{\boldsymbol{k}, \boldsymbol{k}_0}\) is the Kronecker delta function:

\[\begin{split}\delta_{\boldsymbol{k}, \boldsymbol{k}_0} = \begin{cases} 1 & \text{if } \boldsymbol{k} = 2\pi\boldsymbol{k}_0/\boldsymbol{L} \\ 0 & \text{otherwise} \end{cases}\end{split}\]

with \(\boldsymbol{L}\) the domain size in the x, y, and z directions and \(\boldsymbol{k}_0\) the wavenumber that is passed as an argument. The phase \(\phi\) is also passed as an argument. Finally, the state is fourier transformed to physical space and normalized so that its L2 norm is equal to 1.

Parameters#

msetModelSettings

The model settings.

ktuple[int]

The wavenumber in the x and y directions. A wavenumber of one means that the wave has a wavelength equal to the domain size in that direction.

sint

The mode (0, 1, -1) 0 => geostrophic mode 1 => positive inertia-gravity mode -1 => negative inertia-gravity mode

phasefloat

The phase of the wave. (default: 0)

use_discretebool (default: True)

Whether to use the discrete eigenvectors or the analytical ones.

__init__(mset: ModelSettings, k: tuple[int], s: int = 1, phase: float = 0, use_discrete: bool = True) None[source]#

Methods

__init__(mset, k[, s, phase, use_discrete])

abs()

Map the field by taking the absolute value (\(|f|\)).

apply_elementwise(vector_field, op)

Apply an operation elementwise to the vector field.

apply_water_mask()

Apply a water mask to the field.

conj()

Compute the complex conjugate.

cumulative_integral(axis[, direction])

Compute the cumulative integral along an axis.

diff(axis[, order])

Compute the partial derivative along an axis.

div()

Compute the divergence.

dot(other)

Compute the dot product with another field.

extend(topo)

Extend the field in the specified directions.

fft([padding])

Perform a Fast Fourier Transform (FFT) on the field.

from_netcdf(mset, path)

Create a field from a NetCDF file.

from_xarray(mset, ds)

Create a field from an xarray object.

grad([axes])

Compute the gradient.

has_nan()

Check if the field contains NaN values.

ifft([padding])

Perform an Inverse Fast Fourier Transform (IFFT) on the field.

integrate([axes])

Global integral of the Field in specified axes.

laplacian([axes])

Compute the Laplacian.

max([axes])

Maximum value of the Field over the whole domain.

mean([axes])

Global mean of the Field in specified axes.

min([axes])

Minimum value of the Field over the whole domain.

norm_l2()

Calculate the L2 norm of the field.

norm_of_diff(other)

Norm of difference between two vector fields.

project(p_vec, q_vec)

Project a Vector Field onto a (spectral) vector.

set_random([seed])

Set the field to random values.

sum([axes])

Sum of the Field over the whole domain in the specified axes.

sync()

Synchronize the field across all MPI ranks and apply boundary conditions.

to_netcdf(path)

Save the field to a NetCDF file.

Attributes

cfl

The CFL number.

ekin

Vertically integrated kinetic energy.

epot

Vertically integrated kinetic energy.

etot

The total energy.

field_list

The list of scalar fields.

fields

The dictionary of scalar fields.

grid

The grid object.

info

Dictionary with information about the field.

is_constant

Flag indicating whether the field is constant.

is_spectral

Flag indicating whether the field is in spectral space.

local_rossby_number

Local Rossby number.

mset

The model settings.

p

Pressure \(p\).

pot_vort

Scaled potential vorticity field.

rel_vort

Relative vorticity.

spectral_ekin

Spectral kinetic energy density.

tracers

The tracer fields.

u

Velocity in the x-direction.

v

Velocity in the y-direction.

vector_dim

The vector dimension.

velocity

Velocity vector.

xr

The xarray representation of the field.

xrs

Convert a slice of the field to an xarray object.