State#

class fridom.nonhydro.State(mset: ModelSettings, is_spectral: bool = False, field_list=None)[source]#

Bases: StateBase

__init__(mset: ModelSettings, is_spectral: bool = False, field_list=None) None[source]#

Methods

__init__(mset[, is_spectral, field_list])

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.State#

Barotropic Jet

Barotropic Jet

Reflecting Wave Package

Reflecting Wave Package

Convection and Closures

Convection and Closures

Rayleigh-Taylor Instability

Rayleigh-Taylor Instability

Rayleigh-Bénard Convection

Rayleigh-Bénard Convection

Single Internal Wave

Single Internal Wave

Dancing Eddies

Dancing Eddies

Symmetric Instability

Symmetric Instability

Tracers and Eddies

Tracers and Eddies
property u: FieldVariable#

Velocity in the x-direction.

property v: FieldVariable#

Velocity in the y-direction.

property w: FieldVariable#

Velocity in the z-direction.

property b: FieldVariable#

Buoyancy

property ekin: FieldVariable#

The kinetic energy

\[E_{kin} = \frac{1}{2} (u^2 + v^2 + \delta^2 w^2)\]
property epot: FieldVariable#

The potential energy

If the background stratification is set, the potential energy is calculated as:

\[E_{pot} = \frac{1}{2} \frac{b^2}{N^2}\]

If the background stratification is not set, the potential energy is calculated as:

\[E_{pot} = b z\]

where \(z\) is the vertical coordinate.

property etot: FieldVariable#

The total energy

\[E_{tot} = E_{kin} + E_{pot}\]
property rel_vort: tuple[FieldVariable]#

The relative vorticity

\[\boldsymbol{\zeta} = \nabla \times \boldsymbol{u}\]
property rel_vort_x: FieldVariable#

X-component of the relative vorticity

\[\zeta_x = \delta^2 \partial_y w - \partial_z v\]
property rel_vort_y: FieldVariable#

Y-component of the relative vorticity

\[\zeta_y = \partial_z u - \delta^2 \partial_x w\]
property rel_vort_z: FieldVariable#

Z-component of the relative vorticity (Horizontal Vorticity)

\[\zeta_z = \partial_x v - \partial_y u\]
property pot_vort: FieldVariable#

Scaled potential vorticity field.

\[Q = \left( f \boldsymbol{k} + Ro\,\boldsymbol{\zeta} \right) \cdot \nabla \left( Ro\,b + N^2 z \right)\]

where \(\boldsymbol{k}\) is the vertical unit vector, \(f\) is the Coriolis parameter, \(\boldsymbol{\zeta}\) is the relative vorticity, \(b\) is the buoyancy field, and \(N^2\) is the buoyancy frequency.

property linear_pot_vort: FieldVariable#

Linearized potential vorticity

\[Q = Ro \left( \frac{f}{N^2} \partial_z b + \zeta_z \right)\]

where \(Ro\) is the Rossby number, \(f\) is the Coriolis parameter, \(N^2\) is the buoyancy frequency, \(b\) is the buoyancy field, and \(\zeta_z\) is the vertical component of the relative vorticity.

property local_Ro: FieldVariable#

Local Rossby number

\[Ro_\text{local} = Ro \, \frac{\zeta_z}{f_0}\]

where \(Ro\) is the Rossby number, \(\zeta_z\) is the vertical component of the relative vorticity, and \(f_0\) is the Coriolis parameter.

property cfl: FieldVariable#

The CFL number.

\[CFL = \max\left\{ \frac{u}{\Delta x}, \frac{v}{\Delta y}, \frac{w}{\Delta z} \right\} \Delta t\]

where \(\Delta t\) is the time step and \(\Delta x\) is the grid spacing.

Returns:

cfl (FieldVariable) : Horizontal CFL number.