Skip to content

Depot-pumped Brownian particles

Brownian particles with energy depots.

  • Class: DepotBrownianParticlesSystem
  • Import: from skcomplex.systems.physics.active_matter import DepotBrownianParticlesSystem
  • Field: physics/active_matter
  • Topics: active matter, sde, energy depot, self-propulsion
  • References:
    • Schweitzer, Ebeling, and Tilch 1998
    • Helbing 2001

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 DepotBrownianParticlesSystem

trajectory = DepotBrownianParticlesSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
n_particles 50
gamma 20.0
q 10.0
c 1.0
d 10.0
D 0.01
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 DepotBrownianParticlesSystem(BaseSystem):
    """Brownian particles with energy depots.

    The particles start at rest and take up the speed `sqrt(q/gamma - c/d)`.

    The system has the positions `walkers.x`, velocities `walkers.v`, and depots `walkers.e`.

    Args:
        n_particles:
            The number of particles.

        gamma:
            The friction coefficient.

        q:
            The rate of energy intake.

        c:
            The rate of internal energy loss.

        d:
            The rate of conversion of depot energy into motion.

        D:
            The intensity of the velocity noise.

        random_state:
            The seed or generator of the small initial velocities.

        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 DepotBrownianParticlesSystem
        >>> DepotBrownianParticlesSystem(5).prepare().system_.interactions[0].q
        10.0
    """

    field = 'physics/active_matter'
    topics = ('active matter', 'sde', 'energy depot', 'self-propulsion')
    references = ('Schweitzer, Ebeling, and Tilch 1998', 'Helbing 2001')
    until = 10.0
    dt = 0.1

    def __init__(
        self,
        n_particles: int = 50,
        *,
        gamma: float = 20.0,
        q: float = 10.0,
        c: float = 1.0,
        d: float = 10.0,
        D: float = 0.01,
        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.gamma = gamma
        self.q = q
        self.c = c
        self.d = d
        self.D = D
        self.random_state = random_state

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of Brownian particles with energy depots.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        velocities = np.random.default_rng(self.random_state).normal(0.0, 0.01, (self.n_particles, 2))
        walkers = DepotParticleElement(
            'walkers',
            x=np.zeros((self.n_particles, 2)),
            v=velocities,
            size=self.n_particles,
            space=ContinuousSpace(n_dim=2),
        )
        pumping = DepotPumpingInteraction(
            'pumping',
            target='walkers',
            gamma=self.gamma,
            q=self.q,
            c=self.c,
            d=self.d,
            D=self.D,
        )
        self.system_ = System(
            self.label,
            elements=[walkers],
            interactions=[pumping],
            solver=EulerMaruyamaSolver(dt=0.001),
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

  • DepotParticleElement, from Element

Interactions:

  • DepotPumpingInteraction, from Interaction
class DepotParticleElement(Element):
    """Particles with the positions `x`, the velocities `v`, and the energy depots `e`.

    Args:
        label:
            The label of the particles.

        x:
            The initial positions, one row per particle or shared.

        v:
            The initial velocities, one row per particle or shared.

        e:
            The initial energy of the depots.

        size:
            The number of particles, or `None` for one.

        space:
            The continuous space of the particles, or `None` for none.

    Examples:
        >>> from skcomplex.systems.physics.active_matter import DepotParticleElement
        >>> DepotParticleElement('walker', e=1.0).e
        1.0
    """

    visual = POINTS

    def __init__(
        self,
        label: str,
        *,
        x: object = (0.0, 0.0),
        v: object = (0.0, 0.0),
        e: object = 0.0,
        size: int | None = None,
        space: BaseSpace | None = None,
    ) -> None:
        super().__init__(label, size=size, space=space)
        self.x = x
        self.v = v
        self.e = e

class DepotPumpingInteraction(Interaction):
    """Brownian motion pumped by an internal energy depot.

    The particle follows the system of Schweitzer, Ebeling, and Tilch.

    The depot takes energy at the rate `q`, loses it at the rate `c e`, and converts it into motion at the rate
    `d e |v|^2`, so `de/dt = q - c e - d e |v|^2` and `dv = (-gamma v + d e v) dt + sqrt(2 D) dW`. Above
    `q d = c gamma` the particle moves at the speed `sqrt(q / gamma - c / d)`. It is a swimming cell that burns food, or
    a walker that spends stored energy.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the particles, with the positions `x`, the velocities `v`, and the depots `e`.

        gamma:
            The friction coefficient.

        q:
            The rate of energy intake.

        c:
            The rate of internal energy loss.

        d:
            The rate of conversion of depot energy into motion.

        D:
            The intensity of the velocity noise.

    Examples:
        >>> from skcomplex.systems.physics.active_matter import DepotPumpingInteraction
        >>> DepotPumpingInteraction('pumping', target='walkers').q
        10.0
    """

    law_classes = (NoiseLaw, RateLaw)

    def __init__(
        self,
        label: str,
        *,
        target: Role,
        gamma: Annotated[float, RealSet.open(0, oo)] = 20.0,
        q: Annotated[float, RealSet.closed_open(0, oo)] = 10.0,
        c: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
        d: Annotated[float, RealSet.closed_open(0, oo)] = 10.0,
        D: Annotated[float, RealSet.closed_open(0, oo)] = 0.01,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.gamma = gamma
        self.q = q
        self.c = c
        self.d = d
        self.D = D

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the motion, the pumped friction and the noise of the velocity, and the depot balance of the target.

        Args:
            context:
                The namespace of the target, the time `t`, and the parameters.
        """
        super()._prepare(context)
        s = context
        x, v, e = s.target.x, s.target.v, s.target.e
        self.laws_ = [
            RateLaw(x, v),
            RateLaw(v, (-s.gamma + s.d * e) * v),
            NoiseLaw(v, sqrt(2 * s.D)),
            RateLaw(e.diff(s.t), s.q - s.c * e - s.d * e * v.dot_product(v)),
        ]