Inertial active Brownian particles
Active Brownian particles with inertia.
- Class:
InertialActiveBrownianParticlesSystem - Import:
from skcomplex.systems.physics.active_matter import InertialActiveBrownianParticlesSystem - Field:
physics/active_matter - Topics:
active matter,sde,self-propulsion,inertia,second order - References:
- Löwen 2020
- Scholz et al. 2018
- Bechinger et al. 2016
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.active_matter import InertialActiveBrownianParticlesSystem
trajectory = InertialActiveBrownianParticlesSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_particles |
200 |
speed |
3.0 |
mass |
0.5 |
moment |
0.1 |
D_t |
0.1 |
D_r |
1.0 |
size |
50.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 InertialActiveBrownianParticlesSystem(BaseSystem):
"""Active Brownian particles with inertia.
The particles lag behind their orientation as they speed up and turn.
With unit friction, every particle follows `m x'' = -x' + v0 n + sqrt(2 D_t) xi` and `J theta'' = -theta' + sqrt(2
D_r) xi_r`, the inertial active Brownian particles of macroscopic swimmers, flyers, and vibrated grains. The
velocity relaxes over the time `m`, so it trails the orientation, and the mean projection of the velocity on the
orientation falls below `v0`. With rotational inertia alone, the orientation correlation is `exp(-D_r (t - J (1 -
exp(-t / J))))`, which gives the steady projection `v0 / m ∫ exp(-t / m) exp(-D_r (t - J (1 - exp(-t / J)))) dt`,
and `v0 / (1 + m D_r)` without rotational inertia. The particles start at rest at uniform positions and
orientations. The system has the positions `swimmers.x`, the velocities `swimmers.x'`, the orientations
`swimmers.theta`, and the angular velocities `swimmers.theta'`.
Args:
n_particles:
The number of particles.
speed:
The self-propulsion speed `v0`.
mass:
The mass `m`, in units of the friction.
moment:
The moment of inertia `J`, in units of the rotational friction.
D_t:
The translational diffusion coefficient.
D_r:
The rotational diffusion coefficient.
size:
The side of the square in which the particles start.
random_state:
The seed or generator of the initial positions 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.active_matter import InertialActiveBrownianParticlesSystem
>>> InertialActiveBrownianParticlesSystem(10).prepare().system_.elements[0].size
10
"""
field = 'physics/active_matter'
topics = ('active matter', 'sde', 'self-propulsion', 'inertia', 'second order')
references = ('Löwen 2020', 'Scholz et al. 2018', 'Bechinger et al. 2016')
until = 20.0
dt = 0.5
def __init__(
self,
n_particles: int = 200,
*,
speed: float = 3.0,
mass: float = 0.5,
moment: float = 0.1,
D_t: float = 0.1,
D_r: float = 1.0,
size: float = 50.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.speed = speed
self.mass = mass
self.moment = moment
self.D_t = D_t
self.D_r = D_r
self.size = size
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of active Brownian particles with inertia.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
positions, angles = ActiveBrownianParticlesSystem._get_swimmers(self.n_particles, self.size, self.random_state)
swimmers = InertialActiveParticleElement(
'swimmers',
x=positions,
theta=angles,
size=self.n_particles,
space=ContinuousSpace(n_dim=2),
)
propulsion = InertialPropulsionInteraction(
'propulsion',
target='swimmers',
speed=self.speed,
mass=self.mass,
moment=self.moment,
D_t=self.D_t,
D_r=self.D_r,
)
self.system_ = System(
self.label,
elements=[swimmers],
interactions=[propulsion],
solver=EulerMaruyamaSolver(dt=0.005),
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
InertialActiveParticleElement, fromElement
Interactions:
InertialPropulsionInteraction, fromInteraction
class InertialActiveParticleElement(Element):
"""Active particles with the positions `x` and the orientations `theta`, both of order 2.
Args:
label:
The label of the particles.
x:
The initial positions, one row per particle or shared.
theta:
The initial orientations, one per particle or shared.
size:
The number of particles, or `None` for one.
space:
The continuous space of the particles, or `None` for none.
values:
Further values by name, such as the initial velocities `x'` and angular velocities `theta'`, or `None`.
Examples:
>>> from skcomplex.systems.physics.active_matter import InertialActiveParticleElement
>>> InertialActiveParticleElement('swimmer', theta=1.0).theta
1.0
"""
visual = POINTS
def __init__(
self,
label: str,
*,
x: object = (0.0, 0.0),
theta: object = 0.0,
size: int | None = None,
space: BaseSpace | None = None,
values: Mapping[str, object] | None = None,
) -> None:
super().__init__(label, values=values, size=size, space=space)
self.x = x
self.theta = theta
class InertialPropulsionInteraction(Interaction):
"""Self-propulsion of active particles with mass and moment of inertia.
Their velocities and spins relax with friction.
With unit friction, the position follows `m x'' = -x' + v0 n + sqrt(2 D_t) xi` along the orientation
`n = (cos theta, sin theta)`, and the orientation follows `J theta'' = -theta' + sqrt(2 D_r) xi_r`. The velocity
relaxes over the time `m` and the angular velocity over the time `J`, and both vanish to give the overdamped
active Brownian particle. It is a vibrated grain, a flying insect, or a macroscopic robot.
Args:
label:
The label of the interaction.
target:
The path of the particles, with the positions `x` and the orientations `theta`.
speed:
The self-propulsion speed `v0`.
mass:
The mass `m`, in units of the friction.
moment:
The moment of inertia `J`, in units of the rotational friction.
D_t:
The translational diffusion coefficient.
D_r:
The rotational diffusion coefficient.
Examples:
>>> from skcomplex.systems.physics.active_matter import InertialPropulsionInteraction
>>> InertialPropulsionInteraction('propulsion', target='swimmers').mass
0.5
"""
law_classes = (NoiseLaw, RateLaw)
def __init__(
self,
label: str,
*,
target: Role,
speed: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
mass: Annotated[float, RealSet.open(0, oo)] = 0.5,
moment: Annotated[float, RealSet.open(0, oo)] = 0.1,
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.speed = speed
self.mass = mass
self.moment = moment
self.D_t = D_t
self.D_r = D_r
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the accelerations of the position and the orientation of the target, and their noises.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
s, t = context, context.t
x, theta = s.target.x, s.target.theta
heading = vector(SR, [cos(theta), sin(theta)])
self.laws_ = [
RateLaw(x.diff(t, 2), (s.speed * heading - x.diff(t)) / s.mass),
NoiseLaw(x.diff(t, 2), sqrt(2 * s.D_t) / s.mass),
RateLaw(theta.diff(t, 2), -theta.diff(t) / s.moment),
NoiseLaw(theta.diff(t, 2), sqrt(2 * s.D_r) / s.moment),
]