Skip to content

Hasselmann stochastic climate

Hasselmann's stochastic climate.

  • Class: HasselmannSystem
  • Import: from skcomplex.systems.physics.climate import HasselmannSystem
  • Field: physics/climate
  • Topics: sde, Ornstein-Uhlenbeck, red noise, stochastic climate
  • References:
    • Hasselmann 1976
    • Ghil and Lucarini 2020

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.physics.climate import HasselmannSystem

trajectory = HasselmannSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
T 0.0
lam 0.5
sigma 0.3
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time continuous
Space none
Laws noise, rate
Randomness stochastic
Domains real
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class HasselmannSystem(BaseSystem):
    """Hasselmann's stochastic climate.

    Fast weather noise drives a slow, damped temperature anomaly.

    The anomaly follows `dT = -lam T dt + sigma dW`, an Ornstein-Uhlenbeck process whose red spectrum integrates white
    weather noise, with the stationary variance `sigma^2 / (2 lam)`. The system runs with `EulerMaruyamaSolver(dt=0.01)`
    and has the anomaly `ocean.T`.

    Args:
        T:
            The initial temperature anomaly.

        lam:
            The feedback rate that damps the anomaly.

        sigma:
            The amplitude of the weather noise.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Examples:
        >>> from skcomplex.systems.physics.climate import HasselmannSystem
        >>> HasselmannSystem(lam=0.1).prepare().system_.interactions[0].lam
        0.1
    """

    field = 'physics/climate'
    topics = ('sde', 'Ornstein-Uhlenbeck', 'red noise', 'stochastic climate')
    references = ('Hasselmann 1976', 'Ghil and Lucarini 2020')
    until = 100.0
    dt = 0.1

    def __init__(
        self,
        T: float = 0.0,
        *,
        lam: float = 0.5,
        sigma: float = 0.3,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.T = T
        self.lam = lam
        self.sigma = sigma

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of the anomaly damped by its feedback under weather noise.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        self.system_ = System(
            self.label,
            elements=[ClimateAnomalyElement('ocean', T=self.T)],
            interactions=[ClimateFeedbackInteraction('feedback', target='ocean', lam=self.lam, sigma=self.sigma)],
            solver=EulerMaruyamaSolver(dt=0.01),
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

  • ClimateAnomalyElement, from Element

Interactions:

  • ClimateFeedbackInteraction, from Interaction
class ClimateAnomalyElement(Element):
    """Slow temperature anomaly of Hasselmann's stochastic climate.

    The feedback of `HasselmannSystem` damps the anomaly and weather noise drives it.

    Args:
        label:
            The label of the anomaly.

        T:
            The initial temperature anomaly.

    Examples:
        >>> from skcomplex.systems.physics.climate import ClimateAnomalyElement
        >>> ClimateAnomalyElement('ocean', T=0.5).T
        0.5
    """

    def __init__(self, label: str, *, T: float = 0.0) -> None:
        super().__init__(label)
        self.T = T

class ClimateFeedbackInteraction(Interaction):
    """Feedback that damps a temperature anomaly under weather noise.

    The anomaly `T` of the target follows `dT = -lam T dt + sigma dW`, the relaxation to zero over the time `1 / lam`
    with white weather noise of amplitude `sigma`.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the anomaly.

        lam:
            The feedback rate that damps the anomaly.

        sigma:
            The amplitude of the weather noise.

    Examples:
        >>> from skcomplex.systems.physics.climate import ClimateFeedbackInteraction
        >>> ClimateFeedbackInteraction('feedback', target='ocean').lam
        0.5
    """

    law_classes = (RateLaw, NoiseLaw)

    def __init__(
        self,
        label: str,
        *,
        target: Role,
        lam: Annotated[float, RealSet.open(0, oo)] = 0.5,
        sigma: Annotated[float, RealSet.closed_open(0, oo)] = 0.3,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.lam = lam
        self.sigma = sigma

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the relaxation of the anomaly and its weather noise.

        Args:
            context:
                The namespace of the anomaly, the time `t`, and the parameters.
        """
        super()._prepare(context)
        T = context.target.T
        self.laws_ = [RateLaw(T.diff(context.t), (0.0 - T) / (1 / context.lam)), NoiseLaw(T, context.sigma)]

Equations

The equations are those that symbolic returns for the system with its default parameters.

ocean.T: diff(T_ocean(t), t) == -lam_feedback*T_ocean(t)