CoherentEddy

CoherentEddy#

class fridom.nonhydro.initial_conditions.coherent_eddy.CoherentEddy(mset: ModelSettings, pos_x: float = 0.5, pos_y: float = 0.5, width: float = 0.1, amplitude: float = 1, gauss_field: str = 'streamfunction')[source]#

Bases: State

Coherent barotropic eddy with Gaussian shape.

Description#

There are two versions of the coherent eddy. In the first version, the streamfunction of the eddy is given by an gaussian function:

\[\psi = A \exp\left( -\frac{(x - p_x L_x)^2 + (y - p_y L_y)^2}{(\sigma L_x)^2}\right)\]

where \(A\) is the amplitude, \((p_x, p_y)\) is the relative position of the eddy, \((\sigma L_x)\) is the width of the eddy, and \(L_x, L_y\) are the domain sizes in the x and y directions. The velocity field is given by:

\[u = \partial_y \psi, \quad v = -\partial_x \psi\]

The second version of the coherent eddy prescribes the horizontal velocity as a gaussian function:

\[\zeta = A \exp\left( -\frac{(x - p_x L_x)^2 + (y - p_y L_y)^2}{(\sigma L_x)^2}\right)\]

Then the streamfunction is computed in spectral space:

\[\hat{\psi} = \frac{\hat{\zeta}}{k_x^2 + k_y^2}\]

Parameters#

msetModelSettings

The model settings.

pos_xfloat, optional (default=0.5)

The relative position of the eddy in the x-direction.

pos_yfloat, optional (default=0.5)

The relative position of the eddy in the y-direction.

widthfloat, optional (default=0.1)

The relative width of the eddy. (relative to the domain size in the x-direction)

amplitudefloat, optional (default=1)

The amplitude of the eddy. When the amplitude negative, the eddy rotates clockwise. Otherwise, it rotates counterclockwise.

gauss_fieldstr, optional (default=’vorticity’)

The field that is prescribed as a gaussian function. It can be either ‘vorticity’ or ‘streamfunction’.

Examples#

This setup creates a coherent eddy in an scaled setup with varying coriolis parameter. The eddy moves in positive x and negative y direction and hits the northern wall.

import fridom.nonhydro as nh
import numpy as np
grid = nh.grid.cartesian.Grid(
    N=(128, 128, 1), L=(3, 3, 1), periodic_bounds=(True, False, False))
mset = nh.ModelSettings(grid=grid, f0=1, beta=0.2)
mset.time_stepper.dt = 0.004
mset.setup()
model = nh.Model(mset)
model.z = nh.initial_conditions.CoherentEddy(mset, width=0.15)
model.run(runlen=np.timedelta64(20, 's'))

The eddy becomes a rossby wave when either the amplitude is very small or the advection term is disabled:

mset.tendencies.advection.disable()
__init__(mset: ModelSettings, pos_x: float = 0.5, pos_y: float = 0.5, width: float = 0.1, amplitude: float = 1, gauss_field: str = 'streamfunction') None[source]#

Methods

__init__(mset[, pos_x, pos_y, width, ...])

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

Examples using fridom.nonhydro.initial_conditions.CoherentEddy#

Dancing Eddies

Dancing Eddies

Tracers and Eddies

Tracers and Eddies