AdvectionBase#

class fridom.framework.modules.advection.advection_base.AdvectionBase[source]#

Bases: Module

Base class for advection schemes.

Description#

This class implements the base interface for 1D, 2D, and 3D advection schemes. For that, it is assumed that the velocity field is stored in the state vector as the components u, v, and w. Child classes must implement the advection method to calculate the advection term:

\[\mathcal{A}(\boldsymbol{v}, q) = -\boldsymbol{v} \cdot \nabla q\]

where \(q\) is the quantity to be advected and \(\boldsymbol{v}\) is the velocity field, which is the sum of the velocity field in the state vector and the background velocity field, stored in the background attribute. This update routine of this module adds the advection term multiplied by the nonlinear scaling factor to the tendency term of all fields that are not flagged with NO_ADV:

\[\partial_t q \leftarrow \partial_t q + \rho \mathcal{A}(\boldsymbol{v}, q)\]

where \(\rho\) is the nonlinear scaling factor.

__init__() None[source]#

Methods

__init__()

advect_state(z, dz)

advection(velocity, quantity)

Advect a quantity using the given velocity field.

disable()

Enabling the module means that it will be executed at each time step.

enable()

Enabling the module means that it will be executed at each time step.

is_enabled()

Return whether the module is enabled or not.

reset()

Stop and start the module.

setup(mset)

Start the module

start()

Start the module

stop()

Stop the module

update(mz)

Update the module

Attributes

background

The background state.

diff_module

The differentiation module to be used by this module.

disable_nonlinear

Whether to disable advection by the state vector itself.

grid

The grid of the model settings

info

Return a dictionary with information about the time stepper.

interp_module

The interpolation module to be used by this module.

mset

The model settings

name

required_halo

scaling

A scaling factor for the nonlinear terms (default: 1.0)

name = 'Advection Base'#
abstract advection(velocity: tuple[FieldVariable], quantity: FieldVariable) FieldVariable[source]#

Advect a quantity using the given velocity field.

advect_state(z: StateBase, dz: StateBase) StateBase[source]#
update(mz: ModelState) None[source]#

Update the module

Description#

This method is called by the model at each time step. Child classes should overwrite this method to update the module. Make sure to decorate the method with the @module_method decorator.

Parameters#

mzfr.ModelState

The model state at the current time step.

Returns#

fr.ModelState

The updated model state.

property disable_nonlinear#

Whether to disable advection by the state vector itself.

Advection by the background state is still enabled.

property scaling#

A scaling factor for the nonlinear terms (default: 1.0)

Description#

Some modules require to scale the nonlinear terms, as for example the optimal balance projection (fridom.framework.projection.OptimalBalance). This parameter provides an interface to set this scaling factor.

property background: StateBase#

The background state.