HarmonicDiffusion#
- class fridom.framework.modules.closures.harmonic_diffusion.HarmonicDiffusion(field_flags: list[str], diffusion_coefficients: list[float | FieldVariable])[source]#
Bases:
ModuleHarmonic diffusion module
Description#
The harmonic diffusion operator \(\mathcal{H}\) on a scalar field \(u\) is given by:
\[\mathcal{H}(u) = \nabla \cdot \left (\mathbf{A} \cdot \nabla u \right)\]with the diagonal diffusion tensor \(\mathbf{A}\) given by:
\[\begin{split}\mathbf{A} = \begin{pmatrix} \kappa_1 & \dots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \dots & \kappa_n \end{pmatrix}\end{split}\]where \(\kappa_i\) is the harmonic diffusion coefficient in the \(i\)-th direction.
Parameters#
- field_flagslist[str]
A list of strings that indicate which fields should be diffused. For example, if field_flags=[“ENABLE_MIXING”], all fields with the flag “ENABLE_MIXING” will be diffused. For more information on possible flags, see
fridom.framework.FieldVariable.- diffusion_coefficientstuple[float | fr.FieldVariable]
A tuple of diffusion coefficients. The length of the tuple must match the number of dimensions of the grid.
- namestr, (default=”Harmonic Diffusion”)
Name of the module.
- __init__(field_flags: list[str], diffusion_coefficients: list[float | FieldVariable])[source]#
Methods
__init__(field_flags, diffusion_coefficients)diffuse(z, dz)Applies the harmonic diffusion operator on a scalar field \(u\).
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
diff_moduleThe differentiation module to be used by this module.
A list of diffusion coefficients.
A list of field flags that indicate which fields should be diffused.
gridThe grid of the model settings
infoReturn a dictionary with information about the time stepper.
interp_moduleThe interpolation module to be used by this module.
msetThe model settings
required_haloExamples using
fridom.framework.modules.closures.HarmonicDiffusion#- name = 'Harmonic Diffusion'#
- diffusion_operator(u: FieldVariable) FieldVariable[source]#
Applies the harmonic diffusion operator on a scalar field \(u\).
- 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.
- property field_flags: list[str]#
A list of field flags that indicate which fields should be diffused.
- property diffusion_coefficients: list[float | FieldVariable]#
A list of diffusion coefficients.