Annealed transient time motion
Annealed transient time motion.
- Class:
AnnealedTransientTimeMotionSystem - Import:
from skcomplex.systems.physics.soft_matter import AnnealedTransientTimeMotionSystem - Field:
physics/soft_matter - Topics:
anomalous diffusion,renewal process,heterogeneity,sde - References:
- Argun et al. 2021
- Massignan et al. 2014
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 AnnealedTransientTimeMotionSystem
trajectory = AnnealedTransientTimeMotionSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_walkers |
500 |
sigma |
0.5 |
gamma |
1.0 |
n_dim |
2 |
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 | continuous |
| Laws | jump, noise |
| Randomness | stochastic |
| Domains | real, vector |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class AnnealedTransientTimeMotionSystem(BaseSystem):
"""Annealed transient time motion.
The diffusion coefficient of Brownian walkers changes at random times.
Every walker diffuses with a coefficient `D` of density `sigma D^(sigma - 1)` on `(0, 1)` and keeps it for an
exponential time of mean `D^(-gamma)`, so slow walkers stay slow for long. For `sigma < gamma` the ensemble mean
squared displacement grows as `t^(sigma / gamma)`. The system has the positions `walkers.x`, the coefficients
`walkers.D`, and the change count `changes.renewals`.
Args:
n_walkers:
The number of independent walkers.
sigma:
The exponent of the density of diffusion coefficients near zero.
gamma:
The exponent of the mean waiting time `D^(-gamma)`.
n_dim:
The number of dimensions.
random_state:
The seed or generator of the first diffusion coefficients.
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 AnnealedTransientTimeMotionSystem
>>> AnnealedTransientTimeMotionSystem(10, gamma=2.0).prepare().system_.interactions[0].gamma
2.0
"""
field = 'physics/soft_matter'
topics = ('anomalous diffusion', 'renewal process', 'heterogeneity', 'sde')
references = ('Argun et al. 2021', 'Massignan et al. 2014')
until = 500.0
dt = 2.5
def __init__(
self,
n_walkers: int = 500,
*,
sigma: float = 0.5,
gamma: float = 1.0,
n_dim: int = 2,
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_walkers = n_walkers
self.sigma = sigma
self.gamma = gamma
self.n_dim = n_dim
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of walkers whose diffusion coefficient changes at random times.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
coefficients = np.random.default_rng(self.random_state).beta(self.sigma, 1.0, self.n_walkers)
walkers = TransientWalkerElement(
'walkers',
x=np.zeros((self.n_walkers, self.n_dim)),
D=coefficients,
size=self.n_walkers,
)
changes = TransientDiffusionInteraction('changes', target='walkers', sigma=self.sigma, gamma=self.gamma)
self.system_ = System(
self.label,
elements=[walkers],
interactions=[changes],
space=ContinuousSpace(n_dim=self.n_dim),
solver=EulerMaruyamaSolver(dt=0.5),
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
TransientWalkerElement, fromElement
Interactions:
TransientDiffusionInteraction, fromInteraction
class TransientWalkerElement(Element):
"""Brownian walkers at the positions `x` with the diffusion coefficients `D`.
Args:
label:
The label of the walkers.
x:
The initial position, one row per walker or shared.
D:
The initial diffusion coefficient, one per walker or shared.
size:
The number of walkers, or `None` for one.
Examples:
>>> from skcomplex.systems.physics.soft_matter import TransientWalkerElement
>>> TransientWalkerElement('walkers', D=0.2, size=10).D
0.2
"""
def __init__(self, label: str, *, x: object = (0.0, 0.0), D: object = 0.5, size: int | None = None) -> None:
super().__init__(label, size=size)
self.x = x
self.D = D
class TransientDiffusionInteraction(Interaction):
"""Brownian motion whose diffusion coefficient `D` is redrawn at random times.
The position `x` diffuses with `D`, and after an exponential waiting time of mean `D^(-gamma)` the coefficient is
redrawn from the density `sigma D^(sigma - 1)` on `(0, 1)`, the beta distribution `B(sigma, 1)`, so slow walkers
wait long before they change. It is a protein that binds and unbinds in a cell membrane, or a tracer in a
heterogeneous gel.
Args:
label:
The label of the interaction.
target:
The path of the walkers.
sigma:
The exponent of the density of diffusion coefficients near zero.
gamma:
The exponent of the mean waiting time `D^(-gamma)`.
Examples:
>>> from skcomplex.systems.physics.soft_matter import TransientDiffusionInteraction
>>> TransientDiffusionInteraction('changes', target='walkers', gamma=2.0).gamma
2.0
"""
law_classes = (NoiseLaw, JumpLaw)
def __init__(
self,
label: str,
*,
target: Role,
sigma: Annotated[float, RealSet.open(0, oo)] = 0.5,
gamma: Annotated[float, RealSet.open(0, oo)] = 1.0,
) -> None:
super().__init__(label)
self.target = target
self.sigma = sigma
self.gamma = gamma
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the noise of the positions of the target and the changes of their diffusion coefficients.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
s = context
x, D = s.target.x, s.target.D
waiting = draw('wait', 'expon', scale=D ** (-s.gamma))
reset = {D: draw('coefficient', 'beta', a=s.sigma, b=1)}
self.laws_ = [NoiseLaw(x, sqrt(2 * D)), JumpLaw(waiting=waiting, reset=reset, label=self.label)]