Relaxation#

class fridom.framework.modules.forcings.relaxation.Relaxation(tau: float, field_name: str, target: float | FieldVariable, domain_function: callable)[source]#

Bases: Module

Biharmonic diffusion module

Description#

This module implements the relaxation operator \(\mathcal{R}(\phi)\) for a scalar field \(\phi\). The relaxation operator is defined as:

\[\mathcal{R}(\phi) = \frac{\phi^* - \phi}{\tau} \delta_\Omega\]

where \(\phi^*\) is the target value of the field, \(\tau\) is the relaxation time scale, and \(\delta_\Omega\) is one on the domain \(\Omega\) and zero elsewhere. At each time step, \(\mathcal{R}(\phi)\) is added to the tendency of the field \(\phi\). The analytical solution of the relaxation operator with no other forcing terms is:

\[ \begin{align}\begin{aligned}\partial_t \phi = \frac{\phi^* - \phi}{\tau}\\\Rightarrow \phi(t) = \phi^* + C e^{-t/\tau}\end{aligned}\end{align} \]

with a constant \(C\).

The relaxation operator can be used to add heating or cooling to a fluid, but also for example for wind stress forcing.

Parameters#

taufloat

The relaxation time scale \(\tau\).

field_namestr

The name of the field that should be relaxed.

targetfloat | fr.FieldVariable

The target value of the field.

domain_functioncallable

A function that takes the mesh as input and returns a boolean array that indicates the domain where the relaxation should be applied.

__init__(tau: float, field_name: str, target: float | FieldVariable, domain_function: callable)[source]#

Methods

__init__(tau, field_name, target, ...)

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.

relax(z, dz)

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

diff_module

The differentiation module to be used by this module.

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

Examples using fridom.framework.modules.forcings.Relaxation#

Rayleigh-Bénard Convection

Rayleigh-Bénard Convection
name = 'Relaxation'#
setup(mset: ModelSettingsBase)[source]#

Start the module

Description#

This method is called by the ModelSettings.setup() and sets the ModelSettings as well as the differentiation and interpolation modules.

update(mz: ModelState) ModelState[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.

relax(z: StateBase, dz: StateBase) StateBase[source]#