Stochastic resonance
A particle in a double well.
- Class:
StochasticResonanceSystem - Import:
from skcomplex.systems.physics.soft_matter import StochasticResonanceSystem - Field:
physics/soft_matter - Topics:
noise,sde,forcing,resonance - References:
- Benzi, Sutera, and Vulpiani 1981
- Gammaitoni et al. 1998
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 StochasticResonanceSystem
trajectory = StochasticResonanceSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
x |
-1.0 |
amplitude |
0.1 |
frequency |
0.01 |
D |
0.12 |
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 StochasticResonanceSystem(BaseSystem):
"""A particle in a double well.
The particle follows `dx = (x - x^3 + A cos(2 pi f t)) dt + sqrt(2 D) dW`.
The forcing alone is too weak to move the particle between the wells, but noise of the right intensity makes the
hops follow the forcing. The system has the position `particle.x`.
Args:
x:
The initial position.
amplitude:
The amplitude of the periodic forcing.
frequency:
The frequency of the forcing.
D:
The noise intensity.
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 StochasticResonanceSystem
>>> StochasticResonanceSystem(D=0.2).prepare().system_.interactions[0].D
0.2
"""
field = 'physics/soft_matter'
topics = ('noise', 'sde', 'forcing', 'resonance')
references = ('Benzi, Sutera, and Vulpiani 1981', 'Gammaitoni et al. 1998')
until = 500.0
dt = 0.5
def __init__(
self,
x: float = -1.0,
*,
amplitude: float = 0.1,
frequency: float = 0.01,
D: float = 0.12,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.x = x
self.amplitude = amplitude
self.frequency = frequency
self.D = D
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of a particle in a double well.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
well = DoubleWellInteraction(
'well',
target='particle',
amplitude=self.amplitude,
frequency=self.frequency,
D=self.D,
)
self.system_ = System(self.label, elements=[DoubleWellElement('particle', x=self.x)], interactions=[well])
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
DoubleWellElement, fromElement
Interactions:
DoubleWellInteraction, fromInteraction
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.
particle.x: diff(x_particle(t), t) == -x_particle(t)^3 + amplitude_well*cos(6.283185307179586*frequency_well*t) + x_particle(t)