Rigid Brownian and active dimers
Colloidal molecules.
- Class:
RigidDimersSystem - Import:
from skcomplex.systems.physics.soft_matter import RigidDimersSystem - Field:
physics/soft_matter - Topics:
brownian motion,sde,colloidal molecule,rotational diffusion,active matter - References:
- Argun et al. 2021
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 RigidDimersSystem
trajectory = RigidDimersSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_dimers |
100 |
L |
1.0 |
v0 |
0.0 |
D_t |
0.1 |
D_r |
1.0 |
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 | noise, rate |
| Randomness | stochastic |
| Domains | real, vector |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class RigidDimersSystem(BaseSystem):
"""Colloidal molecules.
Pairs of Brownian or active spheres are joined by rigid rods, free in the plane.
Each sphere diffuses with `D_t`, and an active sphere also swims at the speed `v0` along its own orientation, which
diffuses with `D_r`. The rod keeps the spheres at the distance `L`. Diffusing both spheres freely and then restoring
their distance, the scheme of Problem 5.1 of Argun et al., gives in the limit of small steps a centre that diffuses
with `D_t / 2` and a rod angle that diffuses with `2 D_t / L²`, so the rotational diffusion of the molecule falls as
`L^-2` in this free-draining model. Active spheres, Problem 9.3, swim together along the mean of their orientations
and turn the rod with the part of their difference across it, which raises the long-time diffusion of the centre to
`D_t / 2 + v0² / (4 D_r)`. The dimers start at the origin with random rod angles and orientations. The system has
the centres `dimers.c`, the rod angles `dimers.phi`, and the orientations `dimers.theta1` and `dimers.theta2`. The
spheres sit at `c ± (L / 2) (cos phi, sin phi)`.
Args:
n_dimers:
The number of dimers.
L:
The length of the rod.
v0:
The swimming speed of each sphere, 0 for Brownian spheres.
D_t:
The translational diffusion coefficient of each sphere.
D_r:
The rotational diffusion coefficient of the orientation of each sphere.
random_state:
The seed or generator of the initial angles and orientations.
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 RigidDimersSystem
>>> RigidDimersSystem(5, L=2.0).prepare().system_.interactions[0].L
2.0
"""
field = 'physics/soft_matter'
topics = ('brownian motion', 'sde', 'colloidal molecule', 'rotational diffusion', 'active matter')
references = ('Argun et al. 2021',)
until = 20.0
dt = 0.1
def __init__(
self,
n_dimers: int = 100,
*,
L: float = 1.0,
v0: float = 0.0,
D_t: float = 0.1,
D_r: float = 1.0,
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_dimers = n_dimers
self.L = L
self.v0 = v0
self.D_t = D_t
self.D_r = D_r
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of pairs of Brownian or active spheres joined by rigid rods.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
rng = np.random.default_rng(self.random_state)
angles = rng.uniform(0.0, 2 * np.pi, (3, self.n_dimers))
dimers = DimerElement(
'dimers',
c=np.zeros((self.n_dimers, 2)),
phi=angles[0],
theta1=angles[1],
theta2=angles[2],
size=self.n_dimers,
)
rod = RigidRodInteraction('rod', target='dimers', L=self.L, v0=self.v0, D_t=self.D_t, D_r=self.D_r)
self.system_ = System(
self.label,
elements=[dimers],
interactions=[rod],
space=ContinuousSpace(n_dim=2),
solver=EulerMaruyamaSolver(dt=0.005),
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
DimerElement, fromElement
Interactions:
RigidRodInteraction, fromInteraction
class DimerElement(Element):
"""Dimers of two spheres joined by a rigid rod, described by the centre `c` and the angle `phi` of the rod.
The spheres have the orientations `theta1` and `theta2`, along which active spheres swim, and which wrap around the
circle.
Args:
label:
The label of the dimers.
c:
The initial centre, one row per dimer or shared.
phi:
The initial angle of the rod, one per dimer or shared.
theta1:
The initial orientation of the first sphere, one per dimer or shared.
theta2:
The initial orientation of the second sphere, one per dimer or shared.
size:
The number of dimers, or `None` for one.
Examples:
>>> from skcomplex.systems.physics.soft_matter import DimerElement
>>> DimerElement('molecule', phi=1.0).phi
1.0
"""
def __init__(
self,
label: str,
*,
c: object = (0.0, 0.0),
phi: object = 0.0,
theta1: Annotated[object, Period(2 * math.pi)] = 0.0,
theta2: Annotated[object, Period(2 * math.pi)] = 0.0,
size: int | None = None,
) -> None:
super().__init__(label, size=size)
self.c = c
self.phi = phi
self.theta1 = theta1
self.theta2 = theta2
class RigidRodInteraction(Interaction):
"""Motion of two Brownian or active spheres joined by a rigid rod of length `L`.
Each sphere diffuses with `D_t` and swims at the speed `v0` along its own orientation, `theta1` or `theta2`, which
diffuse with `D_r`, and the rod keeps them at the distance `L`. Moving both spheres freely and then restoring
their distance moves the centre `c` by the mean of their displacements and turns the rod by the part of their
relative displacement across it, so in the limit of small steps `dc = v0 (n1 + n2) / 2 dt + sqrt(D_t) dW` and
`dphi = v0 (n1 - n2) . e / L dt + 2 sqrt(D_t) / L dW`, with `e = (-sin phi, cos phi)` across the rod. It is a
colloidal molecule, or a pair of swimming bacteria stuck together.
Args:
label:
The label of the interaction.
target:
The path of the dimers.
L:
The length of the rod.
v0:
The swimming speed of each sphere, 0 for Brownian spheres.
D_t:
The translational diffusion coefficient of each sphere.
D_r:
The rotational diffusion coefficient of the orientation of each sphere.
Examples:
>>> from skcomplex.systems.physics.soft_matter import RigidRodInteraction
>>> RigidRodInteraction('rod', target='dimers', L=2.0).L
2.0
"""
law_classes = (NoiseLaw, RateLaw)
def __init__(
self,
label: str,
*,
target: Role,
L: Annotated[float, RealSet.open(0, oo)] = 1.0,
v0: Annotated[float, RealSet.closed_open(0, oo)] = 0.0,
D_t: Annotated[float, RealSet.closed_open(0, oo)] = 0.1,
D_r: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
) -> None:
super().__init__(label)
self.target = target
self.L = L
self.v0 = v0
self.D_t = D_t
self.D_r = D_r
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the motion of the centre, the turning of the rod, and the diffusion of the orientations.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
s, t = context, context.t
c, phi, theta1, theta2 = s.target.c, s.target.phi, s.target.theta1, s.target.theta2
first = vector(SR, [cos(theta1), sin(theta1)])
second = vector(SR, [cos(theta2), sin(theta2)])
across = vector(SR, [-sin(phi), cos(phi)])
self.laws_ = [
RateLaw(c, s.v0 * (first + second) / 2),
NoiseLaw(c, sqrt(s.D_t)),
RateLaw(phi.diff(t), s.v0 * (first - second).dot_product(across) / s.L),
NoiseLaw(phi, 2 * sqrt(s.D_t) / s.L),
NoiseLaw(theta1, sqrt(2 * s.D_r)),
NoiseLaw(theta2, sqrt(2 * s.D_r)),
]