fluidsim_ocean.sw2l.solver

Shallow water 2 layers solver (fluidsim_ocean.sw2l.solver)

class fluidsim_ocean.sw2l.solver.InfoSolverSW2L(**kargs)[source]

Bases: fluidsim.base.solvers.pseudo_spect.InfoSolverPseudoSpectral

Information about the solver SW2L.

_init_root(self)[source]

The simulation object is instantiated with classes defined in this function.

The super function InfoSolverPseudoSpectral._init_root is called first. A few classes defined by this function are retained as it is:

  • fluidsim.solvers.sw1l.OperatorsPseudoSpectralSW1L

  • fluidsim.base.preprocess.pseudo_spect.PreprocessPseudoSpectral

Solver-specific first-level classes are added:

  • fluidsim_ocean.solvers.sw2l.solver.Simul

  • fluidsim_ocean.solvers.sw2l.state.StateSW2L

  • fluidsim_ocean.time_stepping.TimeSteppingPseudoSpectralSWnL

  • fluidsim_ocean.solvers.sw2l.init_fields.InitFieldsSW2L

  • fluidsim_ocean.solvers.sw2l.output.OutputSW2L

  • fluidsim_ocean.solvers.sw2l.forcing.ForcingSW2L

class fluidsim_ocean.sw2l.solver.Simul(params)[source]

Bases: fluidsim.base.solvers.pseudo_spect.SimulBasePseudoSpectral

A solver of the shallow-water 2 layers equations (SW2L).

Inheritance diagram of Simul

Todo

I guest the topography (bathymetry) can be handle in this class. We will need specific parameters about the topography.

InfoSolver

alias of InfoSolverSW2L

static _complete_params_with_default(params)[source]

This static method is used to complete the params container.

Notes

  • \(f\) is the Coriolis frequency [1/s].

  • densities, list/array of layer densities \(\rho\) [kg/m^3]

  • \(g\) gravity [m/s]

  • \(H\) background layer thicknesses [m]

  • \(drag_coef\) bottom friction coefficient [1/s]

compute_vertical_modes(self, params)[source]

Compute vertical mode structure

tendencies_nonlin(self, state_spect=None, old=None)[source]

Compute the nonlinear tendencies.

Parameters
state_spectfluidsim.base.setofvariables.SetOfVariables

optional

Array containing the state, i.e. the horizontal velocities and surface displacement scalar in Fourier space. When state_spect is provided, the variables vorticity and the velocities and surface displacement are computed from it, otherwise, they are taken from the global state of the simulation, self.state.

These two possibilities are used during the Runge-Kutta time-stepping.

Returns
tendencies_fftfluidsim.base.setofvariables.SetOfVariables

An array containing the tendencies for the velocities \(\mathbf u_n\) and layer thicknesses \(h_n\).

Notes

In this function, we have to compute the right hand sides of these equations:

\[ \begin{align}\begin{aligned}\partial_t \mathbf{u}_n(x,y) &= -\boldsymbol{\nabla} \Big \{ g m_n + \frac{1}{2} |\mathbf{u}_n|^2 \Big \} - (\zeta_n + f) \mathbf{e_z}\times\mathbf{u}_n,\\\partial_t h_n(x,y) &= - \nabla \cdot (\mathbf{u}_n h_n)\end{aligned}\end{align} \]

The gradient of the Montgomery potential is related to interface vertical positions according to:

\[\boldsymbol{\nabla} m_0 = \boldsymbol{\nabla} z_0 = \boldsymbol{\nabla} (T + h_0 + h_1),\]
\[\boldsymbol{\nabla} m_1 = \frac{\rho_0}{\rho_1} \boldsymbol{\nabla} m_0 + \big(1 - \frac{\rho_0}{\rho_1}\big) \boldsymbol{\nabla} (T + h_1).\]

This function computes all terms on the RHS of the equations above, including the nonlinear term. The linear dissipation term (not shown above) is computed implicitly, as demonstrated in fluidsim.base.time_stepping.pseudo_spect.TimeSteppingPseudoSpectral.

Todo

Write a decent unittest file for this solver…

Classes

InfoSolverSW2L(**kargs)

Information about the solver SW2L.

Simul(params)

A solver of the shallow-water 2 layers equations (SW2L).