Fractional Brownian motion
Fractional Brownian motion, dx = sqrt(2 D) dB_H.
- Class:
FractionalBrownianMotionSystem - Import:
from skcomplex.systems.physics.soft_matter import FractionalBrownianMotionSystem - Field:
physics/soft_matter - Topics:
anomalous diffusion,fractional noise,long memory,sde - References:
- Argun et al. 2021
- Mandelbrot and Van Ness 1968
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 FractionalBrownianMotionSystem
trajectory = FractionalBrownianMotionSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_walkers |
500 |
H |
0.3 |
D |
1.0 |
n_dim |
2 |
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 |
| Randomness | stochastic |
| Domains | vector |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class FractionalBrownianMotionSystem(BaseSystem):
"""Fractional Brownian motion, `dx = sqrt(2 D) dB_H`.
Along every axis `<x^2> = 2 D t^(2 H)`.
The increments are correlated over the whole run: they anticorrelate for `H < 1/2`, which makes the walkers
subdiffusive, and correlate for `H > 1/2`, which makes them superdiffusive. The system has the positions
`walkers.x`.
Args:
n_walkers:
The number of independent walkers.
H:
The Hurst index.
D:
The diffusion coefficient.
n_dim:
The number of dimensions.
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 FractionalBrownianMotionSystem
>>> FractionalBrownianMotionSystem(10, H=0.7).prepare().system_.interactions[0].H
0.7
"""
field = 'physics/soft_matter'
topics = ('anomalous diffusion', 'fractional noise', 'long memory', 'sde')
references = ('Argun et al. 2021', 'Mandelbrot and Van Ness 1968')
until = 10.0
dt = 0.05
def __init__(
self,
n_walkers: int = 500,
*,
H: float = 0.3,
D: float = 1.0,
n_dim: int = 2,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n_walkers = n_walkers
self.H = H
self.D = D
self.n_dim = n_dim
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of walkers driven by fractional Brownian motion.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
walkers = FractionalWalkerElement('walkers', x=np.zeros((self.n_walkers, self.n_dim)), size=self.n_walkers)
self.system_ = System(
self.label,
elements=[walkers],
interactions=[FractionalNoiseInteraction('noise', target='walkers', D=self.D, H=self.H)],
space=ContinuousSpace(n_dim=self.n_dim),
solver=FractionalEulerMaruyamaSolver(dt=0.01),
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
FractionalWalkerElement, fromElement
Interactions:
FractionalNoiseInteraction, fromInteraction
class FractionalWalkerElement(Element):
"""Walkers at the positions `x`, driven by fractional Brownian motion.
Args:
label:
The label of the walkers.
x:
The initial position, one row per walker or shared.
size:
The number of walkers, or `None` for one.
Examples:
>>> from skcomplex.systems.physics.soft_matter import FractionalWalkerElement
>>> FractionalWalkerElement('walkers', x=(1.0, 0.0), size=10).x
(1.0, 0.0)
"""
def __init__(self, label: str, *, x: object = (0.0, 0.0), size: int | None = None) -> None:
super().__init__(label, size=size)
self.x = x
class FractionalNoiseInteraction(Interaction):
"""Fractional Brownian noise, `dx = sqrt(2 D) dB_H`, whose increments are correlated in time.
The increments of the position `x` anticorrelate for a Hurst index `H < 1/2` and correlate for `H > 1/2`. It is a
monomer of a long polymer, a tracer in a viscoelastic gel, or the level of a river over the years.
Args:
label:
The label of the interaction.
target:
The path of the walkers.
D:
The diffusion coefficient.
H:
The Hurst index of the driving fractional Brownian motion.
Examples:
>>> from skcomplex.systems.physics.soft_matter import FractionalNoiseInteraction
>>> FractionalNoiseInteraction('noise', target='walkers', H=0.7).H
0.7
"""
law_classes = (NoiseLaw,)
def __init__(
self,
label: str,
*,
target: Role,
D: Annotated[float, RealSet.open(0, oo)] = 1.0,
H: Annotated[float, RealSet.open(0, 1)] = 0.3,
) -> None:
super().__init__(label)
self.target = target
self.D = D
self.H = H
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the fractional noise of the positions of the target.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
self.laws_ = [NoiseLaw(context.target.x, sqrt(2 * context.D), hurst=context.H)]