State#
- class fridom.shallowwater.State(mset: ModelSettings, is_spectral: bool = False, field_list=None)[source]#
Bases:
StateBaseState vector of the 2D shallow water model.
\[\begin{split}\boldsymbol{z} = \begin{pmatrix} u \\ v \\ p \end{pmatrix}\end{split}\]where \(u\) and \(v\) are the velocity components in the x- and y-directions, and \(p=g\eta\) is the pressure field, with \(\eta\) the free surface elevation.
- __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).
The CFL number.
Vertically integrated kinetic energy
Vertically integrated kinetic energy
The total energy
field_listReturn the list of fields.
gridReturn the grid of the model.
Local Rossby number
Pressure \(p = g \eta\), where \(\eta\) is the free surface elevation.
Scaled potential vorticity field.
Relative vorticity
Velocity in the x-direction.
Velocity in the y-direction.
xrState as xarray dataset
xrsState of sliced domain as xarray dataset
Examples using
fridom.shallowwater.State#- property u: FieldVariable#
Velocity in the x-direction.
- property v: FieldVariable#
Velocity in the y-direction.
- property p: FieldVariable#
Pressure \(p = g \eta\), where \(\eta\) is the free surface elevation.
- property ekin: FieldVariable#
Vertically integrated kinetic energy
\[E_{\text{kin}} = \frac{Ro^2}{2} h_{\text{full}} (u^2 + v^2)\]with
\[h_{\text{full}} = c^2 + Ro p\]- Note:
The energy is scaled with the gravity acceleration g.
- property epot: FieldVariable#
Vertically integrated kinetic energy
\[E_{\text{pot}} = \frac{1}{2} h_{\text{full}}^2\]with
\[h_{\text{full}} = c^2 + Ro p\]- Note:
The energy is scaled with the gravity acceleration g.
- property etot: FieldVariable#
The total energy
\[E_{tot} = E_{kin} + E_{pot}\]
- property rel_vort: FieldVariable#
Relative vorticity
\[\zeta = \partial_x v - \partial_y u\]
- property pot_vort: FieldVariable#
Scaled potential vorticity field.
\[Q = \frac{\zeta + f \right}{c^2 + Ro p}\]where \(f\) is the Coriolis parameter, and \(\zeta\) is 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} \right\} \Delta t\]where \(\Delta t\) is the time step and \(\Delta x\) is the grid spacing.