Relaxation#

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

Bases: Module

A relaxation module for scalar fields.

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.ScalarField

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 | ScalarField, domain_function: callable) None[source]#

Methods

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

disable()

Disable the module.

enable()

Enable the module.

is_enabled()

Whether the module is enabled or not.

relax(z, dz)

reset()

Stop and start the module.

setup(mset[, setup_mode])

Set the module up.

start()

Start the module.

stop()

Stop the module.

update(mz)

Update the model state.

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.

is_setup

Whether the module is set up.

mset

The model settings.

name

required_halo

The required halo points for this module.

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

Rayleigh-Bénard Convection

Rayleigh-Bénard Convection
name = 'Relaxation'#
update(mz: ModelState) ModelState[source]#

Update the model state.

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: VectorField, dz: VectorField) VectorField[source]#