Skip to content

Kramers escape

Particles that escape over the barrier of U = x^4 / 4 - x^2 / 2 by noise.

  • Class: KramersEscapeSystem
  • Import: from skcomplex.systems.physics.soft_matter import KramersEscapeSystem
  • Field: physics/soft_matter
  • Topics: noise, sde, escape, double well, rates
  • References:
    • Kramers 1940
    • Hänggi, Talkner, and Borkovec 1990
    • Gros 2015

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.soft_matter import KramersEscapeSystem

trajectory = KramersEscapeSystem().prepare().simulate()

Parameters

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

Parameter Default
n_particles 200
D 0.1
random_state 0
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 KramersEscapeSystem(BaseSystem):
    """Particles that escape over the barrier of `U = x^4 / 4 - x^2 / 2` by noise.

    The noise is thermal with the intensity `D`.

    The particles start in the left well, and they hop between the wells at the Kramers rate `sqrt(U''(-1) |U''(0)|) /
    (2 pi) exp(-1 / (4 D))`, which is `sqrt(2) / (2 pi) exp(-1 / (4 D))`. The system has the positions `particles.x`.

    Args:
        n_particles:
            The number of independent particles.

        D:
            The noise intensity.

        random_state:
            The seed or generator of the small initial spread in the left well.

        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.soft_matter import KramersEscapeSystem
        >>> KramersEscapeSystem(10, D=0.2).prepare().system_.interactions[0].D
        0.2
    """

    field = 'physics/soft_matter'
    topics = ('noise', 'sde', 'escape', 'double well', 'rates')
    references = ('Kramers 1940', 'Hänggi, Talkner, and Borkovec 1990', 'Gros 2015')
    until = 100.0
    dt = 1.0

    def __init__(
        self,
        n_particles: int = 200,
        *,
        D: float = 0.1,
        random_state: int | np.random.Generator | None = 0,
        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.D = D
        self.random_state = random_state

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of particles in a double well that start in the left well.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        positions = -1.0 + np.random.default_rng(self.random_state).normal(0.0, 0.1, self.n_particles)
        self.system_ = System(
            self.label,
            elements=[DoubleWellElement('particles', x=positions, size=self.n_particles)],
            interactions=[DoubleWellInteraction('well', target='particles', amplitude=0.0, D=self.D)],
            solver=EulerMaruyamaSolver(dt=0.01),
        )

Components

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

Elements:

Interactions:

  • DoubleWellInteraction, from Interaction
class DoubleWellElement(Element):
    """Particles at the positions `x` in a double well.

    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.

    Examples:
        >>> from skcomplex.systems.physics.common.particles import DoubleWellElement
        >>> DoubleWellElement('particle', x=1.0).x
        1.0
    """

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

class DoubleWellInteraction(Interaction):
    """Overdamped motion in the double well `x^4 / 4 - x^2 / 2`, forced periodically and by noise.

    The position follows `dx = (x - x^3 + amplitude cos(2 pi frequency t)) dt + sqrt(2 D) dW`. It is a particle that
    hops between two wells, a bistable switch, or the climate between two states.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the particles.

        amplitude:
            The amplitude of the periodic forcing.

        frequency:
            The frequency of the forcing.

        D:
            The noise intensity.

    Examples:
        >>> from skcomplex.core.systems import System
        >>> from skcomplex.systems.physics.common.particles import DoubleWellElement, DoubleWellInteraction
        >>> well = DoubleWellInteraction('well', target='particle', amplitude=0.0, D=0.0)
        >>> system = System(elements=[DoubleWellElement('particle', x=0.5)], interactions=[well]).prepare()
        >>> round(float(system.simulate(until=20.0, dt=1.0).get_values('particle.x')[-1]), 3)
        1.0
    """

    law_classes = (RateLaw, NoiseLaw)

    def __init__(
        self,
        label: str,
        *,
        target: Role,
        amplitude: float = 0.1,
        frequency: float = 0.01,
        D: Annotated[float, RealSet.closed_open(0, oo)] = 0.12,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.amplitude = amplitude
        self.frequency = frequency
        self.D = D

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the drift and the noise of the position of the target.

        Args:
            context:
                The namespace of the target, the time `t`, and the parameters.
        """
        super()._prepare(context)
        s, t = context, context.t
        x = s.target.x
        drive = s.amplitude * cos(2 * math.pi * s.frequency * t)
        self.laws_ = [RateLaw(x.diff(t), x - x**3 + drive), NoiseLaw(x, sqrt(2 * s.D))]

Equations

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

particles.x[i]: diff(x_particles(t), t) == -x_particles(t)^3 + amplitude_well*cos(6.283185307179586*frequency_well*t) + x_particles(t)