ModelSettingsBase#

class fridom.framework.model_settings_base.ModelSettingsBase(grid: GridBase, **kwargs: dict)[source]#

Bases: object

Base class for model settings container.

Description#

This class should be used as a base class for all model settings containers. It provides a set of attributes and methods that are common to all models. Child classes should override the following attributes: - n_dims - model_name - tendencies - diagnostics

And the following methods: - state_constructor - diagnostic_state_constructor

Examples#

Create a new model settings class by inheriting from ModelSettingsBase:

import fridom.framework as fr
class ModelSettings(fr.ModelSettingsBase):
    def __init__(self, grid, **kwargs):
        super().__init__(grid)
        self.model_name = "MyModel"
        # set other parameters
        self.my_parameter = 1.0
        # Finally, set attributes from keyword arguments
        self.set_attributes(**kwargs)

    # optional: override the parameters property
    @property
    def parameters(self):
        res = super().parameters
        res["my_parameter"] = self.my_parameter
        return res
__init__(grid: GridBase, **kwargs: dict) None[source]#

Methods

__init__(grid, **kwargs)

diagnostic_state_constructor()

Construct the diagnostic state vector from this model settings.

set_attributes(**kwargs)

Set model settings attributes from keyword arguments.

setup([setup_mode])

Set the model settings up.

setup_grid([setup_mode])

Set the grid object up.

setup_settings_parameters()

Set the model settings parameters up.

state_constructor()

Construct the state vector from this model settings.

Attributes

custom_diagnostic_fields

List of custom diagnostic fields.

custom_state_fields

List of custom state fields.

diagnostics

The module container for all diagnostics.

grid

The spatial grid.

halo

Return the halo size of the model.

is_setup

Return whether the model settings are set up.

model_name

nan_checker

The NaN checker object (default: NaNChecker).

parameters

Return a dictionary with all parameters of the model settings.

progress_bar

The progress bar object (default: ProgressBar).

raise_error_when_something_goes_wrong

Raise an error when something goes wrong.

restart_module

The restart module.

tendencies

The module container for all tendencies.

time_stepper

The time stepper object (default: AdamBashforth).

timer

The timing module.

Examples using fridom.framework.ModelSettingsBase#

Barotropic Jet

Barotropic Jet

Convection and Closures

Convection and Closures

Dancing Eddies

Dancing Eddies

Internal Gravity Wave Maker

Internal Gravity Wave Maker

Multiple Wave Makers

Multiple Wave Makers

Rayleigh-Bénard Convection

Rayleigh-Bénard Convection

Rayleigh-Taylor Instability

Rayleigh-Taylor Instability

Single Internal Wave

Single Internal Wave

Symmetric Instability

Symmetric Instability

Tracers and Eddies

Tracers and Eddies

Reflecting Wave Package

Reflecting Wave Package

Barotropic Instability.

Barotropic Instability.

Equatorial Waves.

Equatorial Waves.
model_name = 'Unnamed model'#
set_attributes(**kwargs: dict) None[source]#

Set model settings attributes from keyword arguments.

Parameters#

kwargsdict

Keyword arguments to set the attributes of the model settings.

Raises#

AttributeError

The attribute does not exist in the model settings.

setup_grid(setup_mode: Literal['default', 'forced'] = 'default') None[source]#

Set the grid object up.

setup_settings_parameters() None[source]#

Set the model settings parameters up.

setup(setup_mode: Literal['default', 'forced'] = 'default') T[source]#

Set the model settings up.

Description#

This method will initialize the grid object and setup all modules. It must be called before accessing any attributes of the grid or modules.

Returns#

ModelSettingsBase

The model settings object

state_constructor() None[source]#

Construct the state vector from this model settings.

diagnostic_state_constructor() VectorField[source]#

Construct the diagnostic state vector from this model settings.

property parameters: dict#

Return a dictionary with all parameters of the model settings.

Description#

This method should be overridden by the child class to return a dictionary with all parameters of the model settings. This dictionary is used to print the model settings in the __repr__ method.

property grid: GridBase#

The spatial grid.

property time_stepper: None#

The time stepper object (default: AdamBashforth).

property progress_bar: ProgressBar#

The progress bar object (default: ProgressBar).

property nan_checker: NaNChecker#

The NaN checker object (default: NaNChecker).

property tendencies: ModuleContainer#

The module container for all tendencies.

property diagnostics: ModuleContainer#

The module container for all diagnostics.

property restart_module: RestartModule#

The restart module.

property timer: TimingModule#

The timing module.

property raise_error_when_something_goes_wrong: bool#

Raise an error when something goes wrong.

property is_setup: bool#

Return whether the model settings are set up.

property halo: int#

Return the halo size of the model.

property custom_state_fields: list[FieldMetadata]#

List of custom state fields.

property custom_diagnostic_fields: list[FieldMetadata]#

List of custom diagnostic fields.