Brownian motion of Janus, ellipsoidal, and chiral particles in three dimensions
Overdamped axisymmetric Brownian particles in three dimensions.
- Class:
AnisotropicBrownianParticlesSystem - Import:
from skcomplex.systems.physics.soft_matter import AnisotropicBrownianParticlesSystem - Field:
physics/soft_matter - Topics:
brownian motion,sde,rotational diffusion,three dimensions,anisotropy,chirality - References:
- Perrin 1934
- Han et al. 2006
- 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 AnisotropicBrownianParticlesSystem
trajectory = AnisotropicBrownianParticlesSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_particles |
200 |
D_par |
1.0 |
D_perp |
1.0 |
D_r |
0.75 |
D_spin |
0.75 |
D_c |
0.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 | any |
| Space | none |
| Laws | noise, rate, update |
| Randomness | stochastic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class AnisotropicBrownianParticlesSystem(BaseSystem):
"""Overdamped axisymmetric Brownian particles in three dimensions.
The particles translate and rotate.
Every particle diffuses with `D_par` along its axis `u` and with `D_perp` across it, its axis diffuses on the unit
sphere with `D_r`, so that `<u(t) . u(0)> = exp(-2 D_r t)`, and it spins about its axis with `D_spin`. The defaults
are a Janus sphere of unit radius, `D_par = D_perp = D_t` and `D_r = 3 D_t / 4`, whose orientation is visible
although its diffusion is isotropic. A prolate ellipsoid has `D_par > D_perp` from Perrin's factors, so its
displacement over times shorter than `1 / D_r` is elongated along its axis. A chiral body, such as a spiral, has a
coupling `D_c` of the translation along its axis and the rotation about it, `<dr_par dpsi> = 2 D_c dt`. These are
Challenges 5.1 to 5.3 of Argun et al. The axis is held as a unit vector and rescaled to unit length after every
step, and the particles start at the origin with axes drawn uniformly on the sphere. The system has the positions
`particles.x`, `particles.y`, `particles.z`, the axes `particles.ux`, `particles.uy`, `particles.uz`, and the spins
`particles.psi`.
Args:
n_particles:
The number of particles.
D_par:
The translational diffusion coefficient along the axis.
D_perp:
The translational diffusion coefficient across the axis.
D_r:
The rotational diffusion coefficient of the axis.
D_spin:
The rotational diffusion coefficient about the axis.
D_c:
The coupling of the translation along the axis and the rotation about it.
random_state:
The seed or generator of the initial axes.
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.
Raises:
ParameterError:
The coupling exceeds `sqrt(D_par D_spin)`.
Examples:
>>> from skcomplex.systems.physics.soft_matter import AnisotropicBrownianParticlesSystem
>>> AnisotropicBrownianParticlesSystem(5, D_par=1.5, D_perp=0.8).prepare().system_.interactions[0].D_perp
0.8
"""
field = 'physics/soft_matter'
topics = ('brownian motion', 'sde', 'rotational diffusion', 'three dimensions', 'anisotropy', 'chirality')
references = ('Perrin 1934', 'Han et al. 2006', 'Argun et al. 2021')
until = 10.0
dt = 0.05
def __init__(
self,
n_particles: int = 200,
*,
D_par: float = 1.0,
D_perp: float = 1.0,
D_r: float = 0.75,
D_spin: float = 0.75,
D_c: float = 0.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_particles = n_particles
self.D_par = D_par
self.D_perp = D_perp
self.D_r = D_r
self.D_spin = D_spin
self.D_c = D_c
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of overdamped axisymmetric Brownian particles in three dimensions.
Args:
context:
The observables to compile with the problem, or `None` for none.
Raises:
ParameterError:
The coupling exceeds `sqrt(D_par D_spin)`.
"""
super()._prepare(context)
if self.D_c**2 > self.D_par * self.D_spin:
error_msg = (
f'The coupling {self.D_c!r} exceeds sqrt(D_par D_spin), so the diffusion tensor is not positive.'
)
raise ParameterError(error_msg)
axes = np.random.default_rng(self.random_state).normal(size=(self.n_particles, 3))
axes /= np.linalg.norm(axes, axis=1, keepdims=True)
particles = AnisotropicParticleElement(
'particles',
ux=axes[:, 0],
uy=axes[:, 1],
uz=axes[:, 2],
size=self.n_particles,
)
diffusion = AnisotropicDiffusionInteraction(
'diffusion',
target='particles',
D_par=self.D_par,
D_perp=self.D_perp,
D_r=self.D_r,
D_spin=self.D_spin,
D_c=self.D_c,
)
self.system_ = System(
self.label,
elements=[particles],
interactions=[diffusion],
solver=EulerMaruyamaSolver(dt=0.001),
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
AnisotropicParticleElement, fromElement
Interactions:
AnisotropicDiffusionInteraction, fromInteraction
class AnisotropicParticleElement(Element):
"""Axisymmetric particles in three dimensions, with a position, a unit axis, and a spin about the axis.
Args:
label:
The label of the particles.
x:
The initial first coordinate, one per particle or shared.
y:
The initial second coordinate, one per particle or shared.
z:
The initial third coordinate, one per particle or shared.
ux:
The initial first component of the axis, one per particle or shared.
uy:
The initial second component of the axis, one per particle or shared.
uz:
The initial third component of the axis, one per particle or shared.
psi:
The initial spin angle about the axis, one per particle or shared.
size:
The number of particles, or `None` for one.
Examples:
>>> from skcomplex.systems.physics.soft_matter import AnisotropicParticleElement
>>> AnisotropicParticleElement('janus').uz
1.0
"""
def __init__(
self,
label: str,
*,
x: object = 0.0,
y: object = 0.0,
z: object = 0.0,
ux: object = 0.0,
uy: object = 0.0,
uz: object = 1.0,
psi: object = 0.0,
size: int | None = None,
) -> None:
super().__init__(label, size=size)
self.x = x
self.y = y
self.z = z
self.ux = ux
self.uy = uy
self.uz = uz
self.psi = psi
class AnisotropicDiffusionInteraction(Interaction):
"""Diffusion of axisymmetric particles whose diffusion tensor turns with their axis.
The position `r = (x, y, z)` diffuses with `D_par` along the unit axis `u = (ux, uy, uz)` and with `D_perp` across
it, `dr = (sqrt(2 D_par) u u + sqrt(2 D_perp) (I - u u)) dW`. The axis diffuses on the unit sphere,
`du = -2 D_r u dt + sqrt(2 D_r) (I - u u) dW_r` in the Itô form, and a boundary rescales it to unit length after
every step against the drift of the discrete steps. The spin `psi` about the axis diffuses with `D_spin`, and its
noise is correlated with the displacement along the axis through the coupling `D_c` of a chiral body, so that
`<dr_par dpsi> = 2 D_c dt`, which needs `D_c² <= D_par D_spin`. It is a Janus colloid, an ellipsoid, or a
bacterium shaped as a spiral.
Args:
label:
The label of the interaction.
target:
The path of the particles.
D_par:
The translational diffusion coefficient along the axis.
D_perp:
The translational diffusion coefficient across the axis.
D_r:
The rotational diffusion coefficient of the axis.
D_spin:
The rotational diffusion coefficient about the axis.
D_c:
The coupling of the translation along the axis and the rotation about it.
Examples:
>>> from skcomplex.systems.physics.soft_matter import AnisotropicDiffusionInteraction
>>> AnisotropicDiffusionInteraction('diffusion', target='particles', D_perp=0.5).D_perp
0.5
"""
law_classes = (UpdateLaw, NoiseLaw, RateLaw)
def __init__(
self,
label: str,
*,
target: Role,
D_par: Annotated[float, RealSet.open(0, oo)] = 1.0,
D_perp: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
D_r: Annotated[float, RealSet.closed_open(0, oo)] = 0.75,
D_spin: Annotated[float, RealSet.closed_open(0, oo)] = 0.75,
D_c: float = 0.0,
) -> None:
super().__init__(label)
self.target = target
self.D_par = D_par
self.D_perp = D_perp
self.D_r = D_r
self.D_spin = D_spin
self.D_c = D_c
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the translation and the rotation with their correlated noises, and the boundary of the axis.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
s, t = context, context.t
axis = [getattr(s.target, name) for name in DIRECTIONS]
position = [getattr(s.target, name) for name in AXES]
length = sqrt(sum(component**2 for component in axis))
laws: list[BaseLaw] = []
for i, (coordinate, component) in enumerate(zip(position, axis, strict=True)):
laws.append(RateLaw(component.diff(t), -2 * s.D_r * component))
for j, other in enumerate(axis):
projector = (1 if i == j else 0) - component * other
laws.append(NoiseLaw(coordinate, sqrt(2 * s.D_perp) * projector, process=f'translation_{j}'))
laws.append(NoiseLaw(coordinate, sqrt(2 * s.D_par) * component * other, process=f'translation_{j}'))
laws.append(NoiseLaw(component, sqrt(2 * s.D_r) * projector, process=f'rotation_{j}'))
laws.append(UpdateLaw(component, component / length))
coupling = s.D_c / sqrt(s.D_par)
for j, other in enumerate(axis):
laws.append(NoiseLaw(s.target.psi, sqrt(2) * coupling * other, process=f'translation_{j}'))
laws.append(NoiseLaw(s.target.psi, sqrt(2 * (s.D_spin - coupling**2)), process='spin'))
self.laws_ = laws
Equations
The equations are those that symbolic returns for the system with its default parameters.
particles.x[i]: diff(x_particles(t), t) == 0
particles.y[i]: diff(y_particles(t), t) == 0
particles.z[i]: diff(z_particles(t), t) == 0
particles.ux[i]: diff(ux_particles(t), t) == -2*D_r_diffusion*ux_particles(t)
particles.uy[i]: diff(uy_particles(t), t) == -2*D_r_diffusion*uy_particles(t)
particles.uz[i]: diff(uz_particles(t), t) == -2*D_r_diffusion*uz_particles(t)
particles.psi[i]: diff(psi_particles(t), t) == 0