Skip to content

Ornstein-Uhlenbeck with weakening restoring force

Brownian particles held by a restoring force that weakens with distance.

  • Class: WeakeningOrnsteinUhlenbeckSystem
  • Import: from skcomplex.systems.mathematics.stochastic_processes import WeakeningOrnsteinUhlenbeckSystem
  • Field: mathematics/stochastic_processes
  • Topics: random walk, sde, heavy tails, power law
  • References:
    • Jensen 2023

Use this system

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

from skcomplex.systems.mathematics.stochastic_processes import WeakeningOrnsteinUhlenbeckSystem

trajectory = WeakeningOrnsteinUhlenbeckSystem().prepare().simulate()

Parameters

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

Parameter Default
n_particles 200
k 1.0
ell 1.0
D 0.25
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 continuous
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 WeakeningOrnsteinUhlenbeckSystem(BaseSystem):
    """Brownian particles held by a restoring force that weakens with distance.

    The particles follow `dx = -k x / (1 + x²/ℓ²) dt + √(2D) dW`. Near the origin the force is that of an
    Ornstein-Uhlenbeck process, and far from it the force decays as `1 / x`, so the stationary density `(1 + x²/ℓ²)^(-k
    ℓ² / 2D)` has power-law tails. The system has the positions `particles.x`.

    Args:
        n_particles:
            The number of independent particles, all started at the origin.

        k:
            The stiffness of the force near the origin.

        ell:
            The distance where the force starts to weaken.

        D:
            The diffusion coefficient.

        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.mathematics.stochastic_processes import WeakeningOrnsteinUhlenbeckSystem
        >>> WeakeningOrnsteinUhlenbeckSystem(10).prepare().system_.elements[0].size
        10
    """

    field = 'mathematics/stochastic_processes'
    topics = ('random walk', 'sde', 'heavy tails', 'power law')
    references = ('Jensen 2023',)
    until = 50.0
    dt = 0.05

    def __init__(
        self,
        n_particles: int = 200,
        *,
        k: float = 1.0,
        ell: float = 1.0,
        D: float = 0.25,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.n_particles = n_particles
        self.k = k
        self.ell = ell
        self.D = D

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of the particles on a line and the force that holds them."""
        super()._prepare(context)
        particles = WeakeningParticleElement('particles', size=self.n_particles, space=ContinuousSpace(n_dim=1))
        restoring = WeakeningForceInteraction('restoring', target='particles', k=self.k, ell=self.ell, D=self.D)
        self.system_ = System(self.label, elements=[particles], interactions=[restoring])

Components

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

Elements:

  • WeakeningParticleElement, from Element

Interactions:

  • WeakeningForceInteraction, from Interaction
class WeakeningParticleElement(Element):
    """Particles on the real line, each with its position `x`.

    Args:
        label:
            The label of the particles.

        x:
            The initial position, one per particle or shared.

        size:
            The number of particles, or `None` for one.

        space:
            The line the particles live on, whose axis `x` makes `x` their position, or `None`.

    Examples:
        >>> from skcomplex.systems.mathematics.stochastic_processes import WeakeningParticleElement
        >>> WeakeningParticleElement('particle', x=0.5).x
        0.5
    """

    def __init__(
        self,
        label: str,
        *,
        x: object = 0.0,
        size: int | None = None,
        space: BaseSpace | None = None,
    ) -> None:
        super().__init__(label, size=size, space=space)
        self.x = x

class WeakeningForceInteraction(Interaction):
    """Brownian motion in a restoring force that weakens with distance, `dx = -k x / (1 + x²/ℓ²) dt + √(2D) dW`.

    Args:
        label:
            The label of the interaction.

        target:
            The particles whose positions `x` the force and the noise move.

        k:
            The stiffness of the force near the origin.

        ell:
            The distance where the force starts to weaken.

        D:
            The diffusion coefficient.

    Examples:
        >>> from skcomplex.systems.mathematics.stochastic_processes import WeakeningForceInteraction
        >>> WeakeningForceInteraction('force', D=0.5).D
        0.5
    """

    law_classes = (RateLaw, NoiseLaw)

    def __init__(
        self,
        label: str,
        *,
        target: Role = 'particles',
        k: float = 1.0,
        ell: float = 1.0,
        D: float = 0.25,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.k = k
        self.ell = ell
        self.D = D

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the restoring force and the noise as the laws.

        Args:
            context:
                The namespace of the elements a binding of the roles names.
        """
        super()._prepare(context)
        x = context.target.x
        self.laws_: list[BaseLaw] = [
            RateLaw(x, -context.k * x / (1 + (x / context.ell) ** 2)),
            NoiseLaw(x, sqrt(2 * context.D)),
        ]