NaNChecker#

class fridom.framework.modules.NaNChecker(clock_trigger: ClockTrigger | None = None)[source]#

Bases: Module

Check if a state vector contains NaN values.

Description#

This module checks if the state vector contains NaN values. If it does, the model panic flag is set to True and the model is stopped. Since it can be computationally expensive to check for NaNs every iteration, the module has a clock trigger that specifies when to check for NaNs.

Parameters#

clock_triggerfr.ClockTrigger, optional

When to check for NaNs. If not specified, the module will check every 100 iteration steps.

__init__(clock_trigger: ClockTrigger | None = None) None[source]#

Methods

__init__([clock_trigger])

disable()

Disable the module.

enable()

Enable the module.

is_enabled()

Whether the module is enabled or not.

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

clock_trigger

When to check for NaNs.

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.

name = 'NaN Checker'#
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.

property clock_trigger: ClockTrigger#

When to check for NaNs.