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_dictReturn the dictionary of arrays (not FieldVariables).
Buoyancy
The CFL number.
The kinetic energy
The potential energy
The total energy
field_listReturn the list of fields.
gridReturn the grid of the model.
Linearized potential vorticity
Local Rossby number
Scaled potential vorticity field.
The relative vorticity
X-component of the relative vorticity
Y-component of the relative vorticity
Z-component of the relative vorticity (Horizontal Vorticity)
Velocity in the x-direction.
Velocity in the y-direction.
Velocity in the z-direction.
xrState as xarray dataset
xrsState of sliced domain as xarray dataset
Examples using
fridom.nonhydro.State#- 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.