Active matter
Active matter systems.
The package covers self-propelled particles, flocking, polar fluids, chemotaxis, squirmers, and Active System B+.
ActiveBeadElement(label, *, x=0.0, y=0.0, theta=0.0, space=None)
Bases: Element
Beads of a chain with the coordinates x and y and the orientations theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the chain. |
required |
x
|
object
|
The initial first coordinates, one per bead or shared. |
0.0
|
y
|
object
|
The initial second coordinates, one per bead or shared. |
0.0
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial orientations, one per bead or shared. |
0.0
|
space
|
BaseSpace | None
|
The lattice of the beads along the chain, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveBeadElement
>>> ActiveBeadElement('bead', theta=1.0).theta
1.0
Source code in src/skcomplex/systems/physics/active_matter/_polymers.py
55 56 57 58 59 60 61 62 63 64 65 66 67 | |
ActiveBrownianParticlesSystem(n_particles=200, *, speed=3.0, D_t=0.1, D_r=1.0, size=50.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Active Brownian particles in the plane.
The particles swim at a constant speed in a diffusing direction.
Their mean squared displacement is ballistic below the persistence time 1 / D_r and diffusive above it, with the
effective diffusion coefficient D_t + v^2 / (2 D_r). The system has the positions swimmers.x and orientations
swimmers.theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
200
|
speed
|
float
|
The self-propulsion speed. |
3.0
|
D_t
|
float
|
The translational diffusion coefficient. |
0.1
|
D_r
|
float
|
The rotational diffusion coefficient. |
1.0
|
size
|
float
|
The side of the square in which the particles start. |
50.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveBrownianParticlesSystem
>>> ActiveBrownianParticlesSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |
ActiveCahnHilliardInteraction(label, *, target, kappa=1.0, lam=1.0, zeta=4.0, D=0.05)
Bases: Interaction
Cahn-Hilliard dynamics of a conserved field with active currents, Active System B+.
The field follows phi_t = laplacian(mu) - div(zeta laplacian(phi) grad phi) + div(sqrt(2 D) eta), with the
chemical potential mu = -phi + phi^3 - kappa laplacian(phi) + lam |grad phi|^2. The active terms lam and zeta
break the detailed balance of the Cahn-Hilliard equation, and a large zeta reverses Ostwald ripening. It is the
density of swimming bacteria or of self-propelled colloids that cluster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the field |
required |
kappa
|
Annotated[float, open(0, oo)]
|
The stiffness of the interfaces. |
1.0
|
lam
|
float
|
The active term of the chemical potential. |
1.0
|
zeta
|
float
|
The active current. |
4.0
|
D
|
Annotated[float, closed_open(0, oo)]
|
The strength of the conserved noise. |
0.05
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveCahnHilliardInteraction
>>> ActiveCahnHilliardInteraction('currents', target='fluid').zeta
4.0
Source code in src/skcomplex/systems/physics/active_matter/_system_b.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
ActiveCurrentInteraction(label, *, target, D=0.5, current=0.5)
Bases: Interaction
Conserved current of a density, by diffusion and along the divergence of an alignment tensor.
The density follows rho_t = -div(J) with J = -D grad(rho) - current div(Q). The current along div(Q) is the
active current of a nematic, which no free energy gives, as bacteria or cells move along the bend of their order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the field, whose values are the density |
required |
D
|
Annotated[float, closed_open(0, oo)]
|
The diffusion coefficient of the density. |
0.5
|
current
|
float
|
The coefficient of the active current along |
0.5
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveCurrentInteraction
>>> ActiveCurrentInteraction('transport', target='nematic', D=0.1).D
0.1
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
155 156 157 158 159 160 161 162 163 164 165 166 | |
ActiveDiffusionInteraction(label, *, target, D_t=0.1, D_r=1.0, omega=0.0)
Bases: Interaction
Diffusion of the position and the orientation of active particles.
The position follows dx = sqrt(2 D_t) dW and the orientation dtheta = omega dt + sqrt(2 D_r) dW. With omega =
0 it is an active Brownian particle, and otherwise a chiral one. It is a bacterium, a Janus colloid, or a robot
that loses its heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, whose position is |
required |
D_t
|
Annotated[float, closed_open(0, oo)]
|
The translational diffusion coefficient. |
0.1
|
D_r
|
Annotated[float, closed_open(0, oo)]
|
The rotational diffusion coefficient. |
1.0
|
omega
|
float
|
The angular velocity of a chiral particle. |
0.0
|
Examples:
>>> import numpy as np
>>> from skcomplex.core.components.spaces import ContinuousSpace
>>> from skcomplex.core.engine.solvers import EulerMaruyamaSolver
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.common.particles import ActiveDiffusionInteraction, ActiveParticleElement
>>> plane = ContinuousSpace(n_dim=2)
>>> swimmers = ActiveParticleElement('swimmers', x=np.zeros((4000, 2)), size=4000, space=plane)
>>> diffusion = ActiveDiffusionInteraction('diffusion', target='swimmers', D_r=0.5)
>>> system = System(elements=[swimmers], interactions=[diffusion], solver=EulerMaruyamaSolver(dt=0.1))
>>> angles = system.prepare().simulate(until=2.0, dt=2.0, random_state=0).get_values('swimmers.theta')[-1]
>>> round(float((angles**2).mean()), 1)
2.0
Source code in src/skcomplex/systems/physics/common/particles/_active_diffusion.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
ActiveGelsSystem(shape=None, *, order='nematic', spacing=None, a=None, c=None, K=1.0, xi=None, gamma=1.0, eta=1.0, zeta=None, film=False, perturbation=None, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
An active gel.
A nematic tensor or a polarisation is transported in the Stokes flow of its own stresses.
On a periodic lattice with spectral operators, the order parameter follows its co-rotational derivative in the flow,
Section III of Marchetti et al. The flow solves the overdamped Stokes equation of the elastic stress and the active
stress, -zeta Q for the nematic and -zeta p p for the polar gel, and the elastic energy relaxes the order. An
extensile nematic, zeta > 0, is unstable to bend, and a contractile polar gel, zeta < 0, is unstable to splay
above a threshold.
The defaults of the nematic are the chaotic state of Giomi et al. 2012, cited by Marchetti et al., whose free energy
has the same form: a box of side 10, the critical density 3 pi / 2, the density twice that, which give a and
c, the activity 3 times the squared density, and the flow alignment 0.1, in units of the elastic constant, the
rotational viscosity, and the viscosity. The density stays uniform here. At these defaults pairs of +1/2 and
-1/2 defects move in a chaotic flow, active turbulence.
The nematic starts from the tensor along the first axis at the order sqrt(-2 a / c), and the polar gel from the
polarisation along the first axis at the length sqrt(-a / c), both with noise. With film=True the polarisation
along the second axis is odd about the sites 0 and shape[1] / 2 of the second axis, and the other one even, which
holds the polarisation along the first axis at these two walls, with stress-free flow there. The system has the
field gel.Q or gel.p. The tuned run is that of the nematic, and the polar gel, whose flow is slow, runs with
RK4 at the step 0.05 and is best simulated for 200 time units with frames every time unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int] | None
|
The number of sites along every axis of the periodic lattice, in two dimensions, or |
None
|
order
|
str
|
|
'nematic'
|
spacing
|
float | None
|
The distance between neighbouring sites, or |
None
|
a
|
float | None
|
The coefficient of the quadratic energy, negative in the ordered phase, or |
None
|
c
|
float | None
|
The coefficient of the quartic energy, or |
None
|
K
|
float
|
The elastic constant. |
1.0
|
xi
|
float | None
|
The flow-alignment parameter, or |
None
|
gamma
|
float
|
The rotational viscosity. |
1.0
|
eta
|
float
|
The viscosity of the flow. |
1.0
|
zeta
|
float | None
|
The activity, or |
None
|
film
|
bool
|
Whether the polar gel lies between walls of fixed polarisation. |
False
|
perturbation
|
float | None
|
The standard deviation of the initial noise of the order parameter, or |
None
|
random_state
|
int | Generator | None
|
The seed or generator of the initial noise. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The order is unknown, or a nematic is asked to lie in a film. |
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveGelsSystem
>>> ActiveGelsSystem((8, 8), order='polar').prepare().system_.elements[0].zeta
-0.5
>>> ActiveGelsSystem(order='polar').prepare().system_.elements[0].space.shape
(32, 32)
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | |
ActiveOrnsteinUhlenbeckParticlesSystem(n_particles=200, *, tau=1.0, D=1.0, D_t=0.0, size=50.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Active Ornstein-Uhlenbeck particles in the plane.
The particles are driven by exponentially correlated propulsion.
The propulsion starts in its stationary distribution, normal with variance D / tau per component. The system has
the positions swimmers.x and propulsions swimmers.u.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
200
|
tau
|
float
|
The persistence time. |
1.0
|
D
|
float
|
The active diffusion coefficient. |
1.0
|
D_t
|
float
|
The translational diffusion coefficient. |
0.0
|
size
|
float
|
The side of the square in which the particles start. |
50.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and propulsions. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveOrnsteinUhlenbeckParticlesSystem
>>> ActiveOrnsteinUhlenbeckParticlesSystem(10, tau=0.5).prepare().system_.interactions[0].tau
0.5
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | |
ActiveParticleElement(label, *, x=(0.0, 0.0), theta=0.0, size=None, space=None)
Bases: Element
Active particle in the plane with the position x and the orientation theta.
A SelfPropulsionInteraction moves the position along the orientation, and an ActiveDiffusionInteraction makes
both diffuse and the orientation turn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
x
|
object
|
The initial position, one row per particle or shared. |
(0.0, 0.0)
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial orientation, one per particle or shared. |
0.0
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.common.particles import ActiveParticleElement
>>> ActiveParticleElement('swimmer', theta=1.0).theta
1.0
Source code in src/skcomplex/systems/physics/common/particles/_active_particle.py
48 49 50 51 52 53 54 55 56 57 58 59 | |
ActivePassiveFlockingSystem(n_agents=342, *, n_active=45, size=1.0, radius=0.025, epsilon=25.0, exponent=1.5, flocking_radius=0.1, alpha=1.0, v0=0.02, mu=10.0, eta=0.1, time_step=TIME_STEP, initial_speed=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The active and passive agents of Charbonneau (2017) in a periodic box.
The system is that of section 10.4.
All agents repel each other within 2 r_0 with the force epsilon (1 - r / (2 r_0))^exponent, and all feel the
force mu (v_t - |v|) v / |v|, with the target speed v_t = v0 for an active agent and 0 for a passive one. An
active agent also feels the flocking force alpha V / |V|, with V the sum of the velocities of the agents of both
kinds within the flocking radius, itself excluded, and a random force. Agents start at uniform random positions with
velocity components uniform up to initial_speed. The defaults are those of figure 10.7 at the compactness C = pi
N r_0^2 / size^2 = 0.672. The values exponent=2.5, epsilon=100, mu=0.05, radius=1, flocking_radius=4, and
v0=1 are those of Silverberg et al. (2013). The system has the group agents that holds the active agents first,
the positions agents.x, the velocities agents.x', the marks agents.active, and the observables
polarization, active_distance, and passive_distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_agents
|
int
|
The number of agents. |
342
|
n_active
|
int
|
The number of active agents. |
45
|
size
|
float
|
The side of the periodic box. |
1.0
|
radius
|
float
|
The radius |
0.025
|
epsilon
|
float
|
The strength of the repulsion. |
25.0
|
exponent
|
float
|
The exponent of the repulsion. |
1.5
|
flocking_radius
|
float
|
The radius within which an active agent reads the velocities of the others. |
0.1
|
alpha
|
float
|
The size of the flocking force on an active agent, 0 for no flocking. |
1.0
|
v0
|
float
|
The target speed of the active agents. |
0.02
|
mu
|
float
|
The strength of the propulsion. |
10.0
|
eta
|
float
|
The half-width of the uniform random force per step of the book. The noise is a Wiener process with the
same variance per step, of amplitude |
0.1
|
time_step
|
float
|
The step of the solver that |
TIME_STEP
|
initial_speed
|
float
|
The largest size of a component of an initial velocity. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and velocities. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The number of active agents is not between 1 and |
Examples:
>>> from skcomplex.systems.physics.active_matter import ActivePassiveFlockingSystem
>>> [element.label for element in ActivePassiveFlockingSystem(114).prepare().system_.elements]
['agents']
Source code in src/skcomplex/systems/physics/active_matter/_active_passive.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
ActivePolymerSystem(n_beads=20, *, v0=1.0, k=10.0, D_t=0.1, D_r=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
An active polymer, a Rouse chain of active Brownian beads.
Each bead swims along its own orientation.
Bead i follows r_i' = v0 n_i + k (r_{i+1} + r_{i-1} - 2 r_i) + sqrt(2 D_t) xi_i, with its orientation n_i =
(cos theta_i, sin theta_i) diffusing with D_r, and the end beads bonded to one neighbour. The bonds cancel in the
motion of the centre of mass, whose mean squared displacement is (4 D_t t + 2 v0² (D_r t - 1 + exp(-D_r t)) / D_r²)
/ N, that of an active Brownian particle divided by N. The activity swells the chain: a passive chain has the
mean squared end-to-end distance 2 D_t (N - 1) / k in the plane, and self-propulsion of persistence time 1 / D_r
adds to the bond fluctuations and stretches it further. The beads start on a straight line with unit spacing and
random orientations. The system has the coordinates chain.x and chain.y and the orientations chain.theta of
the beads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_beads
|
int
|
The number of beads. |
20
|
v0
|
float
|
The self-propulsion speed of every bead. |
1.0
|
k
|
float
|
The stiffness of the bonds. |
10.0
|
D_t
|
float
|
The translational diffusion coefficient. |
0.1
|
D_r
|
float
|
The rotational diffusion coefficient. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActivePolymerSystem
>>> ActivePolymerSystem(5).prepare().simulate(until=1.0).get_values('chain.x').shape[-1]
5
Source code in src/skcomplex/systems/physics/active_matter/_polymers.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
ActiveRouseInteraction(label, *, target, v0=1.0, k=10.0, D_t=0.1, D_r=1.0)
Bases: Interaction
Rouse chain of active Brownian beads.
The bead at (x, y) swims at the speed v0 along its orientation theta, which diffuses with D_r, its position
diffuses with D_t, and harmonic springs of stiffness k and zero rest length pull it towards its neighbours
along the chain, k (r_{i+1} + r_{i-1} - 2 r_i). The beads at the ends have one neighbour. It is a chain of
self-propelled colloids, a filament driven by molecular motors, or a worm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the chain, with the coordinates |
required |
v0
|
Annotated[float, closed_open(0, oo)]
|
The self-propulsion speed. |
1.0
|
k
|
Annotated[float, closed_open(0, oo)]
|
The stiffness of the bonds. |
10.0
|
D_t
|
Annotated[float, closed_open(0, oo)]
|
The translational diffusion coefficient. |
0.1
|
D_r
|
Annotated[float, closed_open(0, oo)]
|
The rotational diffusion coefficient. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveRouseInteraction
>>> ActiveRouseInteraction('rouse', target='chain').k
10.0
Source code in src/skcomplex/systems/physics/active_matter/_polymers.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
ActiveScalarElement(label, *, phi=0.0, space=None)
Bases: Element
Sites of a conserved scalar field phi, such as the density of active particles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the field. |
required |
phi
|
object
|
The initial field, one value per site or shared. |
0.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveScalarElement
>>> ActiveScalarElement('site', phi=0.5).phi
0.5
Source code in src/skcomplex/systems/physics/active_matter/_system_b.py
48 49 50 | |
ActiveSystemBSystem(shape=(64, 64), *, mean=0.4, kappa=1.0, lam=1.0, zeta=4.0, D=0.05, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Active System B+, the conserved field theory of the density of active particles.
The density phi follows phi_t = laplacian(mu) - div(zeta laplacian(phi) grad(phi)) + div(sqrt(2 D) eta), with
the chemical potential mu = -phi + phi^3 - kappa laplacian(phi) + lam |grad(phi)|^2 and a conserved white noise
eta, Equation 4 of Fodor, Jack, and Cates with unit mobility. The terms lam and zeta are the lowest-order
active currents that no free energy gives. With zeta = 0 it is Active System B, where lam shifts the coexisting
densities and the phases still coarsen. With lam = 1, zeta = 4, and a majority of the dense phase, the Ostwald
ripening of the dilute bubbles reverses, so they stop growing at a finite size, a microphase separation. The noise
conserves the total of phi, so its mean stays fixed. The lattice has unit spacing, and an explicit step must stay
below about 1/32. The system has the field fluid.phi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every axis of the periodic lattice. |
(64, 64)
|
mean
|
float
|
The mean of |
0.4
|
kappa
|
float
|
The stiffness of the interfaces. |
1.0
|
lam
|
float
|
The active term |
1.0
|
zeta
|
float
|
The active current |
4.0
|
D
|
float
|
The temperature of the conserved noise. |
0.05
|
random_state
|
int | Generator | None
|
The seed or generator of the initial noise of amplitude 0.05 around the mean. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveSystemBSystem
>>> ActiveSystemBSystem((8, 8), zeta=0.0).prepare().system_.interactions[0].zeta
0.0
Source code in src/skcomplex/systems/physics/active_matter/_system_b.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
ActiveViscoelasticGelSystem(n_sites=128, *, length=10.0, density=1.0, perturbation=0.01, D=0.1, gamma=1.0, eta=1.0, E=0.1, T0=4.0, c_sat=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A one-dimensional active viscoelastic gel.
Contractile cells concentrate by dragging the gel.
On a periodic line, the density c of the cells and the displacement u of a Kelvin-Voigt gel follow
c_t + (v c)_x = D c_xx, u_t = v, (gamma - eta d_xx) v = d_x (E u_x + Ta(c)),
with the active stress Ta(c) = T0 c / (c + c_sat). The force balance holds at every step, as the modified
Helmholtz inversion of the stress gradient with the screening sqrt(gamma / eta). Without stiffness the uniform
state loses stability at long wavelengths above the contractile threshold c Ta'(c) > gamma D, and the density
concentrates into peaks. The source leaves the active stress open, and the saturating one keeps the peaks finite.
The catalog entry streams the velocity as the observable v. The system has the density gel.c and the
displacement gel.u.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_sites
|
int
|
The number of sites. |
128
|
length
|
float
|
The length of the line. |
10.0
|
density
|
float
|
The mean density of the cells. |
1.0
|
perturbation
|
float
|
The standard deviation of the initial density around its mean. |
0.01
|
D
|
float
|
The diffusion coefficient of the cells. |
0.1
|
gamma
|
float
|
The friction of the gel with the substrate. |
1.0
|
eta
|
float
|
The viscosity of the gel. |
1.0
|
E
|
float
|
The stiffness of the gel. |
0.1
|
T0
|
float
|
The largest active stress of the cells. |
4.0
|
c_sat
|
float
|
The density at which the active stress is half its largest value. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial density. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveViscoelasticGelSystem
>>> ActiveViscoelasticGelSystem(16).prepare().system_.elements[0].eta
1.0
Source code in src/skcomplex/systems/physics/active_matter/_gels.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
AligningActiveBrownianParticlesSystem(n_particles=200, *, size=20.0, speed=1.0, gamma=1.0, D_r=0.1, d0=1.0, D_t=0.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Active Brownian particles in a periodic box whose headings align.
A particle aligns with its neighbours within d0.
The heading of particle i follows dtheta_i = gamma sum_{|x_j - x_i| < d0} sin(theta_j - theta_i) dt + sqrt(2 D_r)
dW, and the particle swims at the constant speed along it. In the mean-field approximation of the Fokker-Planck
equation, the disordered state is unstable above the density rho_c = 2 D_r / (gamma pi d0^2), so at a fixed
density rho the particles move together when gamma exceeds 2 D_r / (pi d0^2 rho). The polarization |<exp(i
theta)>| is near 0 in the disordered state and near 1 in the ordered one. The system has the positions
swimmers.x, the headings swimmers.theta, and the observables mean_heading and polarization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
200
|
size
|
float
|
The side of the periodic box. |
20.0
|
speed
|
float
|
The self-propulsion speed. |
1.0
|
gamma
|
float
|
The strength of the alignment. |
1.0
|
D_r
|
float
|
The rotational diffusion coefficient. |
0.1
|
d0
|
float
|
The interaction range. |
1.0
|
D_t
|
float
|
The translational diffusion coefficient. |
0.0
|
random_state
|
int | Generator | None
|
The seed or generator of the uniform initial positions and headings. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import AligningActiveBrownianParticlesSystem
>>> AligningActiveBrownianParticlesSystem(10, gamma=0.5).prepare().system_.interactions[0].gamma
0.5
Source code in src/skcomplex/systems/physics/active_matter/_alignment.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
AngularAlignmentInteraction(label, *, candidate, field, angles=32, frequency=1.0, noise=0.5, state='x')
Bases: EncounterInteraction
Binary collisions of self-propelled particles.
Pairs of particles leave a collision at their mean angle plus a wrapped normal noise.
A pair of angles meets at the rate 4 d0 v0 |sin((a - b) / 2)|, the frequency of Bertin, Droz, and Grégoire, with
d0 the interaction range and v0 the speed. A pair of opposite angles leaves at either of its two mean angles
with equal probability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
candidate
|
Role
|
The path of the field on a phase space with a periodic orientation axis. |
required |
field
|
Role
|
The path of the field the candidate meets, usually the candidate itself. |
required |
angles
|
int
|
The number of cells of the orientation axis on |
32
|
frequency
|
float
|
The product |
1.0
|
noise
|
float
|
The standard deviation of the noise of the outcome. |
0.5
|
state
|
str
|
The name of the state of the density. |
'x'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import AngularAlignmentInteraction
>>> align = AngularAlignmentInteraction('align', candidate='flock', field='flock', frequency=0.5, noise=0.5)
>>> align.outcome
'conservative'
Source code in src/skcomplex/systems/physics/active_matter/_kinetic_flocks.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
AngularDiffusionInteraction(label, *, candidate, angles=32, tumbling=1.0, noise=0.5, state='x')
Bases: EncounterInteraction
Self-diffusion of self-propelled particles, a linear redistribution.
The particles change their angle at a rate by a wrapped normal noise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
candidate
|
Role
|
The path of the field on a phase space with a periodic orientation axis. |
required |
angles
|
int
|
The number of cells of the orientation axis on |
32
|
tumbling
|
float
|
The rate of the events. |
1.0
|
noise
|
float
|
The standard deviation of the noise of an event. |
0.5
|
state
|
str
|
The name of the state of the density. |
'x'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import AngularDiffusionInteraction
>>> AngularDiffusionInteraction('tumble', candidate='flock', angles=8, tumbling=1.0, noise=0.5).field
Source code in src/skcomplex/systems/physics/active_matter/_kinetic_flocks.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
BertinDrozGregoireSystem(positions=4, angles=16, *, density=1.0, speed=1.0, interaction_range=0.5, tumbling=1.0, noise=0.5, perturbation=0.01, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The kinetic theory of flocking.
Its polar order grows above a transition density.
Particles stream along their orientation, tumble at a rate by a wrapped normal noise, and align in binary collisions
at their mean angle with the same noise. A homogeneous disordered state is unstable above the density pi tumbling
(1 - exp(-noise^2 / 2)) / (8 interaction_range speed (exp(-noise^2 / 2) - 2 / 3)). The system has the density
flock.x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
int
|
The number of positions along each of the two periodic position axes of unit spacing. |
4
|
angles
|
int
|
The number of cells of the orientation axis. |
16
|
density
|
float
|
The density of the homogeneous state. |
1.0
|
speed
|
float
|
The speed of the particles. |
1.0
|
interaction_range
|
float
|
The interaction range. |
0.5
|
tumbling
|
float
|
The rate of the tumbling events. |
1.0
|
noise
|
float
|
The standard deviation of the noise of tumbling and alignment. |
0.5
|
perturbation
|
float
|
The relative amplitude of the initial polar perturbation. |
0.01
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import BertinDrozGregoireSystem
>>> BertinDrozGregoireSystem(2, 8).prepare().system_.elements[0].space.prepare().size_
32
Source code in src/skcomplex/systems/physics/active_matter/_kinetic_flocks.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
BinaryCollisionFlockingSystem(n_particles=400, *, size=20.0, speed=1.0, lam=1.0, sigma=0.3, d0=0.5, substeps=10, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Self-propelled particles that flock through aligning binary collisions.
This is the Bertin-Droz-Grégoire system.
Particles fly straight at a constant speed. Their headings jump by Gaussian angles in self-diffusion events at the
rate lam, and two particles that come closer than d0 both take their mean heading plus Gaussian noise. The
hydrodynamic equations derived from the Boltzmann equation predict collective motion above the density rho_t = pi
lam (1 - exp(-sigma^2 / 2)) / (4 (exp(-sigma^2 / 2) - 2/3)), for speed = 1 and d0 = 1/2, so collective motion
needs sigma < sqrt(2 ln(3/2)), about 0.90, at any density. The system has the agent group birds and the
observables mean_cos, mean_sin, and polarization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
400
|
size
|
float
|
The side of the periodic square. |
20.0
|
speed
|
float
|
The self-propulsion speed. |
1.0
|
lam
|
float
|
The rate of self-diffusion events. |
1.0
|
sigma
|
float
|
The standard deviation of the angular noise. |
0.3
|
d0
|
float
|
The collision distance. |
0.5
|
substeps
|
int
|
The number of substeps per unit of time. |
10
|
random_state
|
int | Generator | None
|
The seed or generator of the uniform initial positions and headings. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import BinaryCollisionFlockingSystem
>>> BinaryCollisionFlockingSystem(10).prepare().system_.interactions[0].sigma
0.3
Source code in src/skcomplex/systems/physics/active_matter/_collisions.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
BinaryCollisionsInteraction(label, *, target, speed=1.0, lam=1.0, sigma=0.3, d0=0.5, substeps=10.0)
Bases: Interaction
Motion, self-diffusion, and aligning collisions of self-propelled particles.
The collisions are binary, and the particles move in steps of 1 / substeps.
In every substep of length tau each particle moves speed * tau along its heading, and with probability
1 - exp(-lam * tau) its heading jumps by a Gaussian angle of standard deviation sigma. Two particles collide
when their distance falls below d0 during the substep, and both headings become the mean heading
arg(exp(i theta_1) + exp(i theta_2)) plus independent Gaussian angles of standard deviation sigma.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of particles. |
required |
speed
|
Annotated[float, closed_open(0, oo)]
|
The self-propulsion speed. |
1.0
|
lam
|
Annotated[float, closed_open(0, oo)]
|
The rate of self-diffusion events. |
1.0
|
sigma
|
Annotated[float, closed_open(0, oo)]
|
The standard deviation of the angular noise of both kinds of events. |
0.3
|
d0
|
Annotated[float, open(0, oo)]
|
The collision distance. |
0.5
|
substeps
|
Annotated[float, open(0, oo)]
|
The number of substeps per unit of time. |
10.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import BinaryCollisionsInteraction
>>> BinaryCollisionsInteraction('collisions', target='birds').d0
0.5
Source code in src/skcomplex/systems/physics/active_matter/_collisions.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
fly(system)
Move the particles for one unit of time.
Every substep has self-diffusion and collisions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/physics/active_matter/_collisions.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
BirdElement(label, x=0.0, *, values=None, size=None, space=None)
Bases: PointElement
Point drawn at its position and coloured by its velocity.
Examples:
>>> from skcomplex.systems.physics.active_matter import BirdElement
>>> BirdElement('bird', x=[0.0, 1.0]).x
[0.0, 1.0]
Source code in src/skcomplex/systems/general/elements/_point.py
59 60 61 62 63 64 65 66 67 68 69 | |
CellMotilityInteraction(label, *, target, v0=1.0, mu=1.0, tau=1.0, eta=0.6, R_eq=5.0 / 6.0, R_0=1.0, F_rep=30.0, F_adh=0.75)
Bases: Interaction
Motility of cells that push and pull their neighbours and turn towards their velocity, as Szabó et al. (2006).
The position follows x' = v0 n + mu F, where n is the unit vector of the heading and F the sum of the pair
forces of the neighbours within R_0. A pair force is F_rep (d - R_eq) / R_eq towards the neighbour below the
distance R_eq, and F_adh (d - R_eq) / (R_0 - R_eq) towards it up to the distance R_0, the cell diameter. The
heading turns towards the velocity, theta' = arcsin((n x v / |v|) . e_z) / tau + xi, with angular noise of
variance eta^2 / 12 per unit time. It is a keratocyte in a wound, or a cell of an epithelium that migrates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the cells, with the positions |
required |
v0
|
Annotated[float, closed_open(0, oo)]
|
The speed of the motility. |
1.0
|
mu
|
Annotated[float, open(0, oo)]
|
The mobility. |
1.0
|
tau
|
Annotated[float, open(0, oo)]
|
The relaxation time of the heading. |
1.0
|
eta
|
Annotated[float, closed_open(0, oo)]
|
The strength of the angular noise. |
0.6
|
R_eq
|
Annotated[float, open(0, oo)]
|
The equilibrium distance of a pair. |
5.0 / 6.0
|
R_0
|
Annotated[float, open(0, oo)]
|
The distance beyond which a pair exerts no force. |
1.0
|
F_rep
|
Annotated[float, closed_open(0, oo)]
|
The largest repulsive force. |
30.0
|
F_adh
|
Annotated[float, closed_open(0, oo)]
|
The largest adhesive force. |
0.75
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CellMotilityInteraction
>>> CellMotilityInteraction('motility', target='cells').F_rep
30.0
Source code in src/skcomplex/systems/physics/active_matter/_cells.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
ChemotaxisElement(label, *, rho=1.0, c=1.0, space=None)
Bases: Element
Sites with the density rho of cells and the concentration c of a chemical.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the sites. |
required |
rho
|
object
|
The initial density of cells, one per site or shared. |
1.0
|
c
|
object
|
The initial concentration of the chemical, one per site or shared. |
1.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ChemotaxisElement
>>> ChemotaxisElement('site', c=2.0).c
2.0
Source code in src/skcomplex/systems/physics/active_matter/_chemotaxis.py
51 52 53 54 | |
ChemotaxisInteraction(label, *, target, D=1.0, chi=5.0, Dc=1.0, k=1.0)
Bases: Interaction
Keller-Segel chemotaxis of cells that climb the gradient of a chemical they secrete.
The cells diffuse and drift up the chemical, rho_t = D laplacian(rho) - chi div(rho grad c), and the chemical
diffuses, is secreted by the cells, and decays, c_t = Dc laplacian(c) + rho - k c. Above a critical mass the cells
aggregate and the density blows up in finite time. It is a colony of slime mould amoebae or of bacteria that
gather.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the sites, with the density |
required |
D
|
Annotated[float, open(0, oo)]
|
The diffusion coefficient of the cells. |
1.0
|
chi
|
Annotated[float, closed_open(0, oo)]
|
The chemotactic sensitivity. |
5.0
|
Dc
|
Annotated[float, open(0, oo)]
|
The diffusion coefficient of the chemical. |
1.0
|
k
|
Annotated[float, open(0, oo)]
|
The decay rate of the chemical. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ChemotaxisInteraction
>>> ChemotaxisInteraction('chemotaxis', target='colony').chi
5.0
Source code in src/skcomplex/systems/physics/active_matter/_chemotaxis.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
ChiralActiveParticlesSystem(n_particles=200, *, speed=3.0, omega=2.0, D_t=0.1, D_r=0.1, size=50.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Chiral active particles.
The particles swim along circles of radius v / omega that drift by diffusion.
Their effective diffusion coefficient at long times is D_t + v^2 D_r / (2 (D_r^2 + omega^2)). The system has the
positions swimmers.x and orientations swimmers.theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
200
|
speed
|
float
|
The self-propulsion speed. |
3.0
|
omega
|
float
|
The angular velocity. |
2.0
|
D_t
|
float
|
The translational diffusion coefficient. |
0.1
|
D_r
|
float
|
The rotational diffusion coefficient. |
0.1
|
size
|
float
|
The side of the square in which the particles start. |
50.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ChiralActiveParticlesSystem
>>> ChiralActiveParticlesSystem(10, omega=1.0).prepare().system_.interactions[0].omega
1.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
CohesiveAlignmentInteraction(label, *, target, eta=0.1, alpha=1.0, beta=1.0, r_c=CLOSE, r_e=0.5, r_a=0.8)
Bases: Interaction
Alignment with cohesion of a Grégoire-Chaté flock.
The particles align, repel close neighbours, and attract distant ones.
Every step the new heading is the direction of alpha sum_j exp(i theta_j) + beta sum_j f(r_ij) e_ij + eta n_i xi
over the n_i particles within the unit distance, where e_ij points from i to j, xi is a random unit
vector, and the force f is a strong repulsion below r_c, zero at r_e, and attractive up to r_a. It is a
school of fish or a flock of birds that stays together.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, with the positions |
required |
eta
|
Annotated[float, closed_open(0, oo)]
|
The strength of the vectorial noise. |
0.1
|
alpha
|
Annotated[float, closed_open(0, oo)]
|
The strength of the alignment. |
1.0
|
beta
|
Annotated[float, closed_open(0, oo)]
|
The strength of the cohesion. |
1.0
|
r_c
|
Annotated[float, open(0, oo)]
|
The distance below which the neighbours repel strongly. |
CLOSE
|
r_e
|
Annotated[float, open(0, oo)]
|
The preferred distance. |
0.5
|
r_a
|
Annotated[float, open(0, oo)]
|
The distance of the strongest attraction. |
0.8
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CohesiveAlignmentInteraction
>>> CohesiveAlignmentInteraction('cohesion', target='flock').r_e
0.5
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
CohesiveParticleElement(label, *, x=(0.0, 0.0), theta=0.0, size=None, space=None)
Bases: Element
Particles of a Grégoire-Chaté flock with the positions x and the headings theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial headings, one per particle or shared. |
0.0
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CohesiveParticleElement
>>> CohesiveParticleElement('bird', theta=1.0).theta
1.0
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
77 78 79 80 81 82 83 84 85 86 87 88 | |
ContractileGelSiteElement(label, *, c=1.0, u=0.0, D=0.1, gamma=1.0, eta=1.0, E=0.1, T0=4.0, c_sat=1.0, space=None)
Bases: Element
Sites of a one-dimensional active viscoelastic gel.
Every site has the density of contractile cells and the gel displacement.
A site holds the density c of the cells and the displacement u of a Kelvin-Voigt gel of stiffness E and
viscosity eta, with friction gamma against a rigid substrate. The cells diffuse with the coefficient D and
exert the active stress T0 c / (c + c_sat).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the gel. |
required |
c
|
Annotated[object, closed_open(0, oo)]
|
The initial density of the cells, one value per site or one for all. |
1.0
|
u
|
object
|
The initial displacement of the gel, one value per site or one for all. |
0.0
|
D
|
Annotated[float, open(0, oo)]
|
The diffusion coefficient of the cells. |
0.1
|
gamma
|
Annotated[float, open(0, oo)]
|
The friction of the gel with the substrate. |
1.0
|
eta
|
Annotated[float, open(0, oo)]
|
The viscosity of the gel. |
1.0
|
E
|
Annotated[float, closed_open(0, oo)]
|
The stiffness of the gel. |
0.1
|
T0
|
Annotated[float, closed_open(0, oo)]
|
The largest active stress of the cells. |
4.0
|
c_sat
|
Annotated[float, open(0, oo)]
|
The density at which the active stress is half its largest value. |
1.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ContractileGelSiteElement
>>> ContractileGelSiteElement('site').T0
4.0
Source code in src/skcomplex/systems/physics/active_matter/_gels.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
CuckerSmaleAlignmentInteraction(label, *, target, cutoff=1.0, K=1.0, beta=0.25, n_agents=1)
Bases: Interaction
Cucker-Smale alignment, x_i'' += K / N sum_j psi(r_ij) (x_j' - x_i') with psi(r) = (1 + r^2)^(-beta).
Every member pulls its velocity x' towards those of the members within the cutoff, with a weight that decays with
their distance. It is a flock of birds, a school of fish, or a fleet of drones that agree on a heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of agents. |
required |
cutoff
|
float
|
The distance beyond which pairs do not align, large for the all-to-all system. |
1.0
|
K
|
Annotated[float, closed_open(0, oo)]
|
The strength of the alignment. |
1.0
|
beta
|
Annotated[float, closed_open(0, oo)]
|
The decay exponent of the weight. |
0.25
|
n_agents
|
int
|
The number of agents |
1
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CuckerSmaleAlignmentInteraction
>>> CuckerSmaleAlignmentInteraction('align', target='birds', beta=0.25).beta
0.25
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
CuckerSmaleFlockingSystem(n_agents=50, *, K=1.0, beta=0.25, size=10.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Cucker-Smale flocking.
Every agent aligns its velocity with all others, weighted by distance.
The mean velocity is conserved, and for beta <= 1/2 the velocities converge to it from any start. The system has
the positions birds.x and velocities birds.x'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_agents
|
int
|
The number of agents. |
50
|
K
|
float
|
The coupling strength. |
1.0
|
beta
|
float
|
The decay exponent of the communication weight. |
0.25
|
size
|
float
|
The side of the square in which the agents start. |
10.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and velocities. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CuckerSmaleFlockingSystem
>>> CuckerSmaleFlockingSystem(5).prepare().system_.interactions[0].n_agents
5
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
CurvatureAlignmentInteraction(label, *, target, beta=0.5)
Bases: Interaction
Growth of an alignment tensor with the traceless curvature of a density.
The rate of the tensor is beta (partial_i partial_j rho - delta_ij laplacian(rho) / 2), so rods align along the
ridges of the density. It is the coupling of the order of a dry active nematic, of a bacterial colony, or of a
layer of cells to the variations of their density.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the field, whose values are the density |
required |
beta
|
float
|
The coupling of the tensor to the curvature of the density. |
0.5
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CurvatureAlignmentInteraction
>>> CurvatureAlignmentInteraction('alignment', target='nematic', beta=0.25).beta
0.25
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
111 112 113 114 | |
DeformableActiveParticlesSystem(n_particles=20, *, gamma=1.0, a=1.0, b=1.0, kappa=0.5, noise=0.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Deformable self-propelled particles of Ohta and Ohkuma.
The particles move straight or along circles.
Every particle follows x' = v, v' = gamma v - |v|² v - a S v, and S' = -kappa S + b (v v - |v|² I / 2), with
the traceless symmetric deformation tensor S. A fast relaxing shape, large kappa, gives straight motion at the
speed sqrt(gamma / (1 + a b / (2 kappa))). For a b (gamma - kappa / 2) > kappa² a circular motion exists, at the
speed sqrt(gamma - kappa / 2) with the angular velocity sqrt(a b (gamma - kappa / 2) - kappa²) / 2, its
elongation turning with its velocity. For the defaults it exists below kappa ≈ 0.78, and particles started from
small velocities reach it for kappa <= 0.5, while closer to the threshold straight motion stays stable too. The
particles do not interact, and they start at random positions, small random velocities, and no deformation. The
system has the positions cells.x, the velocities cells.v, and the deformations cells.S.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
20
|
gamma
|
float
|
The distance from the onset of self-propulsion. |
1.0
|
a
|
float
|
The coupling of the velocity to the deformation. |
1.0
|
b
|
float
|
The coupling of the deformation to the velocity. |
1.0
|
kappa
|
float
|
The relaxation rate of the deformation. |
0.5
|
noise
|
float
|
The amplitude of the noise of the velocity. |
0.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and velocities. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DeformableActiveParticlesSystem
>>> DeformableActiveParticlesSystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/physics/active_matter/_deformable.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
DeformableParticleElement(label, *, x=(0.0, 0.0), v=(0.0, 0.0), S=(0.0, 0.0), size=None, space=None)
Bases: Element
Particles with the positions x, the velocities v, and the deformations S.
The deformation is a traceless symmetric tensor [[S_xx, S_xy], [S_xy, -S_xx]], given by its two independent
components (S_xx, S_xy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
v
|
object
|
The initial velocities, one row per particle or shared. |
(0.0, 0.0)
|
S
|
object
|
The initial deformations, given by their two independent components, one row per particle or shared. |
(0.0, 0.0)
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DeformableParticleElement
>>> DeformableParticleElement('cell', v=(1.0, 0.0)).v
(1.0, 0.0)
Source code in src/skcomplex/systems/physics/active_matter/_deformable.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
DepotBrownianParticlesSystem(n_particles=50, *, gamma=20.0, q=10.0, c=1.0, d=10.0, D=0.01, random_state=0, label='system', solver='auto', backend='auto')
Bases: 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
50
|
gamma
|
float
|
The friction coefficient. |
20.0
|
q
|
float
|
The rate of energy intake. |
10.0
|
c
|
float
|
The rate of internal energy loss. |
1.0
|
d
|
float
|
The rate of conversion of depot energy into motion. |
10.0
|
D
|
float
|
The intensity of the velocity noise. |
0.01
|
random_state
|
int | Generator | None
|
The seed or generator of the small initial velocities. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DepotBrownianParticlesSystem
>>> DepotBrownianParticlesSystem(5).prepare().system_.interactions[0].q
10.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
DepotParticleElement(label, *, x=(0.0, 0.0), v=(0.0, 0.0), e=0.0, size=None, space=None)
Bases: Element
Particles with the positions x, the velocities v, and the energy depots e.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
v
|
object
|
The initial velocities, one row per particle or shared. |
(0.0, 0.0)
|
e
|
object
|
The initial energy of the depots. |
0.0
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DepotParticleElement
>>> DepotParticleElement('walker', e=1.0).e
1.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
DepotPumpingInteraction(label, *, target, gamma=20.0, q=10.0, c=1.0, d=10.0, D=0.01)
Bases: 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, with the positions |
required |
gamma
|
Annotated[float, open(0, oo)]
|
The friction coefficient. |
20.0
|
q
|
Annotated[float, closed_open(0, oo)]
|
The rate of energy intake. |
10.0
|
c
|
Annotated[float, closed_open(0, oo)]
|
The rate of internal energy loss. |
1.0
|
d
|
Annotated[float, closed_open(0, oo)]
|
The rate of conversion of depot energy into motion. |
10.0
|
D
|
Annotated[float, closed_open(0, oo)]
|
The intensity of the velocity noise. |
0.01
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DepotPumpingInteraction
>>> DepotPumpingInteraction('pumping', target='walkers').q
10.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
DryActiveNematicsSystem(shape=(64, 64), *, density=1.5, critical_density=1.0, a=1.0, c=2.0, K=1.0, gamma=1.0, D=0.5, current=0.5, beta=0.5, perturbation=0.01, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A dry active nematic.
A conserved density is coupled to a symmetric traceless alignment tensor.
On a periodic lattice the density and the tensor follow Section II.2 of Marchetti et al.,
rho_t = -div(J), J = -D grad(rho) - current div(Q),
Q_t = H / gamma + beta (partial_i partial_j rho - delta_ij laplacian(rho) / 2),
with the molecular field H of the Landau-de Gennes energy, whose coefficient a (1 - rho / rho_c) turns negative
above the critical density rho_c. The current along div(Q) is the active current, which no free energy gives.
The system has the fields nematic.rho and nematic.Q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every axis of the periodic lattice. |
(64, 64)
|
density
|
float
|
The mean density, which the dynamics conserve. |
1.5
|
critical_density
|
float
|
The density at which the isotropic state loses stability. |
1.0
|
a
|
float
|
The scale of the coefficient of |
1.0
|
c
|
float
|
The coefficient of |
2.0
|
K
|
float
|
The elastic constant. |
1.0
|
gamma
|
float
|
The rotational viscosity. |
1.0
|
D
|
float
|
The diffusion coefficient of the density. |
0.5
|
current
|
float
|
The coefficient of the active current along |
0.5
|
beta
|
float
|
The coupling of the tensor to the curvature of the density. |
0.5
|
perturbation
|
float
|
The standard deviation of the initial noise of the density and the tensor. |
0.01
|
random_state
|
int | Generator | None
|
The seed or generator of the initial noise. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DryActiveNematicsSystem
>>> DryActiveNematicsSystem((8, 8)).prepare().system_.interactions[0].beta
0.5
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
FlockerElement(label, *, x=0.0, y=0.0, theta=0.0, size=None, space=None)
Bases: Element
Self-propelled point particles at the points x and y of a periodic square, with the headings theta.
The heading wraps around the circle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
x
|
object
|
The initial first coordinate, one per particle or shared. |
0.0
|
y
|
object
|
The initial second coordinate, one per particle or shared. |
0.0
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial heading, one per particle or shared. |
0.0
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import FlockerElement
>>> FlockerElement('bird', theta=1.0).theta
1.0
Source code in src/skcomplex/systems/physics/active_matter/_collisions.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
FlockerView
Bases: AgentViewProtocol, Protocol
Flocker as rules see it, with its heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
The Mesa agent. |
required | |
stepper
|
The stepper that runs the system. |
required |
FlockingAgentElement(label, x=0.0, *, active=ACTIVE_AGENT, radius=1.0, values=None, size=None, space=None)
Bases: PointElement
Agent of a crowd, a point with a mark that says whether it is active or passive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or the group. |
required |
x
|
ArrayLike
|
The initial position. |
0.0
|
active
|
Annotated[object, FiniteEnumeratedSet([PASSIVE_AGENT, ACTIVE_AGENT])]
|
The mark, 1 for an active agent or 0 for a passive one. |
ACTIVE_AGENT
|
radius
|
Annotated[float, open(0, oo)]
|
The radius |
1.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the starting velocity |
None
|
size
|
int | None
|
The number of agents, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the agents, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import FlockingAgentElement
>>> FlockingAgentElement('agent', active=0.0).active
0.0
Source code in src/skcomplex/systems/physics/active_matter/_active_passive.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
GinelliNematicsSystem(n_particles=400, *, size=10.0, v0=0.3, eta=0.08, seed=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Polar particles with nematic alignment.
The particles order along a common axis but move both ways along it.
At every step particle i takes the direction of sum_j sign(cos(theta_j - theta_i)) exp(i theta_j) over the
particles within the unit distance, itself included, so it aligns with the axis of every neighbour on the side
nearer its own heading, plus a uniform angle in [-eta pi, eta pi], and moves v0 along it. At low noise the
particles share an axis, with as many moving one way as the other: the nematic order parameter |<exp(2 i theta)>|
grows towards 1 while the polar order parameter stays small. The system has the positions flock.x, the headings
flock.theta, and the observables polarization and nematic_order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
400
|
size
|
float
|
The side of the periodic box, in units of the interaction radius. |
10.0
|
v0
|
float
|
The distance a particle moves in one step. |
0.3
|
eta
|
float
|
The amplitude of the noise, as a fraction of |
0.08
|
seed
|
int
|
The seed of the uniform initial positions and headings. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import GinelliNematicsSystem
>>> GinelliNematicsSystem(10).prepare().system_.elements[0].eta
0.08
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | |
GregoireChateSystem(n_particles=200, *, size=5.0, v0=0.05, eta=0.1, alpha=1.0, beta=0.5, seed=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Grégoire-Chaté system.
Aligning particles also attract and repel, forming cohesive flocks.
At every step particle i takes the direction of alpha sum_j exp(i theta_j) + beta sum_j f(r_ij) e_ij + eta n_i
xi, over the n_i particles within the unit distance, where e_ij points from i to j, xi is a random unit
vector, and the force f is a strong repulsion below r_c = 0.2, zero at the preferred distance r_e = 0.5, and
attractive up to r_a = 0.8. The particle then moves v0 along the new heading. At low noise and moderate cohesion
the particles gather into cohesive, aligned flocks, and the polar order parameter grows towards 1. A strong cohesion
locks them in place, and the order is lost. The system has the positions flock.x, the headings flock.theta, and
the observables polarization and nematic_order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
200
|
size
|
float
|
The side of the periodic box, in units of the interaction radius. |
5.0
|
v0
|
float
|
The distance a particle moves in one step. |
0.05
|
eta
|
float
|
The strength of the vectorial noise. |
0.1
|
alpha
|
float
|
The strength of the alignment. |
1.0
|
beta
|
float
|
The strength of the cohesion. |
0.5
|
seed
|
int
|
The seed of the uniform initial positions and headings. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import GregoireChateSystem
>>> GregoireChateSystem(10, beta=2.0).prepare().system_.interactions[1].beta
2.0
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
HeadingAlignmentInteraction(label, *, target, nematic=False, neighborhood=None, latency=0, memory=5)
Bases: Interaction
Vicsek alignment.
Every particle turns to the circular mean heading of its neighbours plus noise.
Every step the heading theta of every particle becomes the circular mean of the headings within the unit
distance, itself included, plus a uniform angle in [-eta pi, eta pi] with the parameter eta of the particle.
With nematic, every heading is flipped to the side nearer the particle's own heading first, as for particles
with an axis rather than a direction. Another neighbourhood, such as the k nearest particles or a vision cone,
replaces the unit disk.
With a positive latency h, every particle reads the headings of its neighbours h steps ago. With a negative
latency it reads their headings predicted |h| steps ahead, by a least-squares line through their last memory
headings, unwrapped by taking every change between two steps as the smallest angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of particles. |
required |
nematic
|
bool
|
Whether every heading is flipped to the side nearer the particle's own heading. |
False
|
neighborhood
|
BaseNeighborhood | None
|
The neighbourhood of every particle, itself included, or |
None
|
latency
|
int
|
The number of steps by which the headings of the neighbours are read late, or predicted ahead when negative. |
0
|
memory
|
int
|
The number of past headings a prediction fits, at least 2. |
5
|
Examples:
>>> from skcomplex.systems.physics.active_matter import HeadingAlignmentInteraction
>>> HeadingAlignmentInteraction('alignment', target='flock', nematic=True).nematic
True
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
InertialActiveBrownianParticlesSystem(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, label='system', solver='auto', backend='auto')
Bases: 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'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
200
|
speed
|
float
|
The self-propulsion speed |
3.0
|
mass
|
float
|
The mass |
0.5
|
moment
|
float
|
The moment of inertia |
0.1
|
D_t
|
float
|
The translational diffusion coefficient. |
0.1
|
D_r
|
float
|
The rotational diffusion coefficient. |
1.0
|
size
|
float
|
The side of the square in which the particles start. |
50.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import InertialActiveBrownianParticlesSystem
>>> InertialActiveBrownianParticlesSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
InertialActiveParticleElement(label, *, x=(0.0, 0.0), theta=0.0, size=None, space=None, values=None)
Bases: Element
Active particles with the positions x and the orientations theta, both of order 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
theta
|
object
|
The initial orientations, one per particle or shared. |
0.0
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the initial velocities |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import InertialActiveParticleElement
>>> InertialActiveParticleElement('swimmer', theta=1.0).theta
1.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
184 185 186 187 188 189 190 191 192 193 194 195 196 | |
InertialPropulsionInteraction(label, *, target, speed=1.0, mass=0.5, moment=0.1, D_t=0.1, D_r=1.0)
Bases: 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, with the positions |
required |
speed
|
Annotated[float, closed_open(0, oo)]
|
The self-propulsion speed |
1.0
|
mass
|
Annotated[float, open(0, oo)]
|
The mass |
0.5
|
moment
|
Annotated[float, open(0, oo)]
|
The moment of inertia |
0.1
|
D_t
|
Annotated[float, closed_open(0, oo)]
|
The translational diffusion coefficient. |
0.1
|
D_r
|
Annotated[float, closed_open(0, oo)]
|
The rotational diffusion coefficient. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import InertialPropulsionInteraction
>>> InertialPropulsionInteraction('propulsion', target='swimmers').mass
0.5
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
KellerSegelSystem(shape=(32, 32), *, length=32.0, D=1.0, chi=5.0, Dc=1.0, k=1.0, density=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Keller-Segel system of diffusing cells that climb a chemical gradient.
The cells secrete the chemical.
The cell density follows rho_t = D laplacian(rho) - chi div(rho grad(c)) and the chemical c_t = Dc laplacian(c) +
rho - k c, on a periodic square. The total number of cells is conserved. The uniform state of density rho_0 is
unstable when the chemotactic drive chi rho_0 exceeds D (k + Dc q^2) for the longest wave q = 2 pi / length.
The cells then aggregate into dense spots, which in two dimensions collapse in finite time, so a run above the
threshold ends before the density blows up. The system has the cell density colony.rho and the chemical
colony.c.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along both axes of the periodic lattice. |
(32, 32)
|
length
|
float
|
The side of the square. |
32.0
|
D
|
float
|
The diffusivity of the cells. |
1.0
|
chi
|
float
|
The chemotactic sensitivity. |
5.0
|
Dc
|
float
|
The diffusivity of the chemical. |
1.0
|
k
|
float
|
The decay rate of the chemical. |
1.0
|
density
|
float
|
The mean cell density |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the noise. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import KellerSegelSystem
>>> KellerSegelSystem((8, 8), chi=0.5).prepare().system_.interactions[0].chi
0.5
Source code in src/skcomplex/systems/physics/active_matter/_chemotaxis.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
LandauDeGennesEnergyInteraction(label, *, target, state='Q', a=-1.0, c=2.0, K=1.0, gamma=1.0, quadratic=None)
Bases: GradientInteraction
Landau-de Gennes free energy gradient flow of a symmetric traceless tensor Q.
The free energy is F = integral a tr(Q^2) / 2 + c tr(Q^2)^2 / 4 + K |grad Q|^2 / 2. Its negative functional
derivative among symmetric traceless tensors is the molecular field H = -a Q - c tr(Q^2) Q + K laplacian(Q), and
the tensor relaxes as Q_t = H / gamma. A uniform tensor S (n n - I / 2) in two dimensions with a < 0 relaxes
to the scalar order S = sqrt(-2 a / c).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the field. |
required |
state
|
str
|
The name of the value of the field that holds the tensor. |
'Q'
|
a
|
float
|
The coefficient of |
-1.0
|
c
|
Annotated[float, open(0, oo)]
|
The coefficient of |
2.0
|
K
|
Annotated[float, closed_open(0, oo)]
|
The elastic constant. |
1.0
|
gamma
|
Annotated[float, open(0, oo)]
|
The rotational viscosity, which divides the molecular field. |
1.0
|
quadratic
|
Callable[[SimpleNamespace], object] | None
|
A function of the namespace that returns the coefficient of |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import LandauDeGennesEnergyInteraction
>>> LandauDeGennesEnergyInteraction('energy', target='nematic', a=-1.0).a
-1.0
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
LivingCrystalsSystem(n_particles=100, *, size=50.0, speed=3.0, D_r=1.0, v0=20.0, cutoff=10.0, k=200.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Active colloids of radius 1 with phoretic attraction.
The colloids gather into clusters that slowly coarsen.
The colloids swim as active Brownian particles, drift towards each other at the speed v0 / r^2 within the cutoff,
and a stiff soft repulsion stands in for the hard-sphere correction at contact. The system has the positions
swimmers.x and orientations swimmers.theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of colloids. |
100
|
size
|
float
|
The side of the periodic box. |
50.0
|
speed
|
float
|
The self-propulsion speed. |
3.0
|
D_r
|
float
|
The rotational diffusion coefficient. |
1.0
|
v0
|
float
|
The phoretic drift speed at the distance of one radius. |
20.0
|
cutoff
|
float
|
The distance beyond which the attraction is neglected. |
10.0
|
k
|
float
|
The stiffness of the repulsion times the mobility. |
200.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import LivingCrystalsSystem
>>> LivingCrystalsSystem(16).prepare().system_.interactions[3].v0
20.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
MotileCellElement(label, *, x=(0.0, 0.0), theta=0.0, size=None, space=None)
Bases: Element
Motile cells of a tissue with the positions x and the headings theta of their motility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cells. |
required |
x
|
object
|
The initial positions, one row per cell or shared. |
(0.0, 0.0)
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial headings, one per cell or shared. |
0.0
|
size
|
int | None
|
The number of cells, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the cells, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import MotileCellElement
>>> MotileCellElement('cell', theta=1.0).theta
1.0
Source code in src/skcomplex/systems/physics/active_matter/_cells.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
MotilityInducedPhaseSeparationSystem(n_particles=400, *, packing_fraction=0.5, speed=1.0, D_r=0.01, k=50.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Repulsive active Brownian disks of unit diameter.
The disks phase separate into clusters at high speed.
Disks that collide head on block each other until their orientations diffuse away, so fast swimmers with slow
rotational diffusion, a large Péclet number v / D_r, accumulate where they are slow and form dense clusters in a
dilute gas. The system has the positions swimmers.x and orientations swimmers.theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of disks. |
400
|
packing_fraction
|
float
|
The fraction of the periodic box the disks cover. |
0.5
|
speed
|
float
|
The self-propulsion speed. |
1.0
|
D_r
|
float
|
The rotational diffusion coefficient. |
0.01
|
k
|
float
|
The stiffness of the repulsion times the mobility. |
50.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import MotilityInducedPhaseSeparationSystem
>>> MotilityInducedPhaseSeparationSystem(16).prepare().system_.interactions[2].k
50.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
NematicDensitySiteElement(label, *, rho=1.0, Q=0.0, space=None)
Bases: Element
Sites of a dry active nematic, with a density and a symmetric traceless alignment tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
rho
|
object
|
The initial density, or one density per site. |
1.0
|
Q
|
Annotated[object, Tensor(traceless)]
|
The initial alignment tensor, its independent components |
0.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NematicDensitySiteElement
>>> NematicDensitySiteElement('site', rho=2.0).rho
2.0
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
75 76 77 78 79 80 81 82 83 84 85 | |
NematicGelFlowInteraction(label, *, target)
Bases: Interaction
Transport and relaxation of the tensor of an active nematic gel in the Stokes flow of its stresses.
The tensor follows Q_t = -C(Q, u, xi) + H / gamma, with the corotational transport C of Beris and Edwards
and the molecular field H of the Landau-de Gennes energy. The velocity solves
eta laplacian(u) - grad(P) + div(sigma) = 0, div(u) = 0, with the stress sigma = -xi H + Q H - H Q - zeta Q.
An activity zeta > 0 is extensile and an activity zeta < 0 contractile. It is the active turbulence of
microtubule bundles, of dense bacteria, or of a monolayer of cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the gel, whose values are the tensor |
required |
Examples:
>>> from skcomplex.systems.physics.active_matter import NematicGelFlowInteraction
>>> NematicGelFlowInteraction('flow', target='gel').target
'gel'
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
446 447 448 | |
NematicGelSiteElement(label, *, Q=0.0, a=-1.0, c=2.0, K=1.0, xi=0.0, gamma=1.0, eta=1.0, zeta=0.5, space=None)
Bases: Element
Sites of an active nematic gel, with a symmetric traceless tensor and the constants of the gel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
Q
|
Annotated[object, Tensor(traceless)]
|
The initial tensor, its independent components |
0.0
|
a
|
float
|
The coefficient of |
-1.0
|
c
|
Annotated[float, open(0, oo)]
|
The coefficient of |
2.0
|
K
|
Annotated[float, closed_open(0, oo)]
|
The elastic constant. |
1.0
|
xi
|
float
|
The flow-alignment parameter. |
0.0
|
gamma
|
Annotated[float, open(0, oo)]
|
The rotational viscosity. |
1.0
|
eta
|
Annotated[float, open(0, oo)]
|
The viscosity of the flow. |
1.0
|
zeta
|
float
|
The activity. |
0.5
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NematicGelSiteElement
>>> NematicGelSiteElement('site').zeta
0.5
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
NematicParticleElement(label, *, x=(0.0, 0.0), theta=0.0, eta=0.1, size=None, space=None)
Bases: Element
Polar particles with the positions x, the headings theta, and the noise amplitudes eta.
HeadingAlignmentInteraction with nematic=True sets the new heading to the circular mean of the headings within
the unit distance, itself included, each flipped to the side nearer the particle's own heading, plus a uniform
angle in [-eta pi, eta pi]. A propulsion step moves the particle along its heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial headings, one per particle or shared. |
0.0
|
eta
|
object
|
The amplitude of the noise, as a fraction of |
0.1
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NematicParticleElement
>>> NematicParticleElement('rod', eta=0.2).eta
0.2
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
NonreciprocalAlignmentInteraction(label, *, target, eta=0.3, J_aa=1.0, J_ab=1.0, J_ba=1.0, J_bb=1.0, radius=1.0)
Bases: Interaction
Vicsek alignment of two species whose couplings to each other differ.
Every step the heading becomes the direction of sum_j J(species_i, species_j) exp(i theta_j) over the movers
within radius, itself included, plus uniform noise of width eta. J_aa and J_bb align a species with itself,
and J_ab and J_ba align A with B and B with A, so J_ab != J_ba makes the alignment nonreciprocal. It is a
pair of bird species, or two kinds of robots, that chase each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the movers, with the positions |
required |
eta
|
Annotated[float, closed_open(0, oo)]
|
The width of the uniform noise of the heading. |
0.3
|
J_aa
|
float
|
The alignment of A with A. |
1.0
|
J_ab
|
float
|
The alignment of A with B. |
1.0
|
J_ba
|
float
|
The alignment of B with A. |
1.0
|
J_bb
|
float
|
The alignment of B with B. |
1.0
|
radius
|
Annotated[float, open(0, oo)]
|
The radius of the neighbourhood. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NonreciprocalAlignmentInteraction
>>> NonreciprocalAlignmentInteraction('align', target='movers', J_ba=-1.0).J_ba
-1.0
Source code in src/skcomplex/systems/physics/active_matter/_nonreciprocal.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
NonreciprocalMoverElement(label, *, x=(0.0, 0.0), theta=0.0, species=0.0, size=None, space=None)
Bases: Element
Movers of species A (0) or B (1) with the positions x and the headings theta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the movers. |
required |
x
|
object
|
The positions, one row per mover or shared. |
(0.0, 0.0)
|
theta
|
object
|
The headings, one per mover or shared. |
0.0
|
species
|
object
|
The species, 0 for A or 1 for B, one per mover or shared. |
0.0
|
size
|
int | None
|
The number of movers, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the movers, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NonreciprocalMoverElement
>>> NonreciprocalMoverElement('mover', species=1.0).species
1.0
Source code in src/skcomplex/systems/physics/active_matter/_nonreciprocal.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
NonreciprocalVicsekSystem(n_movers=400, *, size=5.0, J_ab=1.0, J_ba=-1.0, eta=0.3, random_state=1, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Two species of Vicsek movers in a periodic box with nonreciprocal alignment.
The alignment of each species with the other differs between the two.
Half the movers are species A and half species B, each aligning with its own species. With J_ab = J_ba the two
species flock together. With J_ab = -J_ba, A aligns with B while B antialigns with A, so neither settles: the mean
headings of the species lock at a quarter turn from each other and rotate together, the chiral phase of Fruchart et
al. (2021), which breaks the time-reversal symmetry that reciprocal alignment keeps. The system has the mean
headings heading_a and heading_b of the two species.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_movers
|
int
|
The number of movers, an even number. |
400
|
size
|
float
|
The side of the periodic box. |
5.0
|
J_ab
|
float
|
The alignment of A with B. |
1.0
|
J_ba
|
float
|
The alignment of B with A. |
-1.0
|
eta
|
float
|
The width of the uniform noise of the headings. |
0.3
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and headings. |
1
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NonreciprocalVicsekSystem
>>> NonreciprocalVicsekSystem(20).prepare().system_.elements[0].size
20
Source code in src/skcomplex/systems/physics/active_matter/_nonreciprocal.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
OrnsteinUhlenbeckParticleElement(label, *, x=(0.0, 0.0), u=(0.0, 0.0), size=None, space=None)
Bases: Element
Active particles with the positions x and the propulsion velocities u.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
u
|
object
|
The initial propulsion velocities, one row per particle or shared. |
(0.0, 0.0)
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import OrnsteinUhlenbeckParticleElement
>>> OrnsteinUhlenbeckParticleElement('swimmer', u=(1.0, 0.0)).u
(1.0, 0.0)
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
304 305 306 307 308 309 310 311 312 313 314 315 | |
OrnsteinUhlenbeckPropulsionInteraction(label, *, target, tau=1.0, D=1.0, D_t=0.0)
Bases: Interaction
Propulsion of active particles by an Ornstein-Uhlenbeck process.
The laws are dx = u dt + sqrt(2 D_t) dW and tau du = -u dt + sqrt(2 D) dW, so the propulsion keeps its
direction for the persistence time tau and the particle diffuses with D + D_t at long times. It is a bacterium
or a colloid whose swimming direction forgets itself smoothly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, with the positions |
required |
tau
|
Annotated[float, open(0, oo)]
|
The persistence time. |
1.0
|
D
|
Annotated[float, closed_open(0, oo)]
|
The active diffusion coefficient. |
1.0
|
D_t
|
Annotated[float, closed_open(0, oo)]
|
The translational diffusion coefficient. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import OrnsteinUhlenbeckPropulsionInteraction
>>> OrnsteinUhlenbeckPropulsionInteraction('propulsion', target='swimmers').tau
1.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
PhoreticAttractionInteraction(label, *, target, v0=20.0, R=1.0, cutoff=1.0)
Bases: Interaction
Phoretic attraction between active colloids, the pair potential -v0 R^2 / r.
Every member of a pair closer than the cutoff drifts towards the other at the speed v0 R^2 / r^2. It is a
light-activated colloid that gathers others by the chemicals it releases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the colloids, with the positions |
required |
v0
|
Annotated[float, closed_open(0, oo)]
|
The drift speed at the distance |
20.0
|
R
|
Annotated[float, open(0, oo)]
|
The particle radius. |
1.0
|
cutoff
|
Annotated[float, open(0, oo)]
|
The distance beyond which the attraction is neglected. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PhoreticAttractionInteraction
>>> PhoreticAttractionInteraction('phoresis', target='colloids', v0=20.0).v0
20.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
PolarAlignmentInteraction(label, *, target, gamma=1.0, cutoff=1.0)
Bases: Interaction
Alignment torque theta_i' += gamma sum_j sin(theta_j - theta_i) between close particles.
The sum runs over every neighbour j within the interaction range cutoff, so the torque turns each particle
towards the headings of its neighbours. It is a bird turning with its flock, or a bacterium aligning with others
in a swarm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, with the positions |
required |
gamma
|
Annotated[float, closed_open(0, oo)]
|
The strength of the alignment. |
1.0
|
cutoff
|
Annotated[float, open(0, oo)]
|
The interaction range. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PolarAlignmentInteraction
>>> PolarAlignmentInteraction('align', target='swimmers', gamma=0.5).gamma
0.5
Source code in src/skcomplex/systems/physics/active_matter/_alignment.py
64 65 66 67 68 69 70 71 72 73 74 75 | |
PolarFluidElement(label, *, rho=1.0, vx=0.0, vy=0.0, space=None)
Bases: Element
Sites of a polar active fluid with the density rho and the velocity (vx, vy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the fluid. |
required |
rho
|
object
|
The initial density, one per site or shared. |
1.0
|
vx
|
object
|
The initial velocity along the first axis, one per site or shared. |
0.0
|
vy
|
object
|
The initial velocity along the second axis, one per site or shared. |
0.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PolarFluidElement
>>> PolarFluidElement('site', rho=2.0).rho
2.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
57 58 59 60 61 62 63 64 65 66 67 68 69 | |
PolarGelFlowInteraction(label, *, target)
Bases: Interaction
Transport and relaxation of the polarisation of an active polar gel in the Stokes flow of its stresses.
The polarisation follows p_t = -C(p, u, xi) + h / gamma, with the corotational transport C of Beris and
Edwards and the molecular field h = -a p - c |p|^2 p + K laplacian(p). The velocity solves
eta laplacian(u) - grad(P) + div(sigma) = 0, div(u) = 0, with the stress
sigma = -xi (p h + h p) / 2 + (p h - h p) / 2 - zeta p p, as in Kruse et al. It is the flow of the actin cortex
of a cell, of a layer of motile bacteria, or of a film of microtubules and motors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the gel, whose values are the polarisation |
required |
Examples:
>>> from skcomplex.systems.physics.active_matter import PolarGelFlowInteraction
>>> PolarGelFlowInteraction('flow', target='gel').target
'gel'
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
269 270 271 | |
PolarGelSiteElement(label, *, p=0.0, a=-1.0, c=1.0, K=1.0, xi=0.0, gamma=1.0, eta=1.0, zeta=-0.5, space=None)
Bases: Element
Sites of an active polar gel, with a polarisation and the constants of the gel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
p
|
object
|
The initial polarisation, or one polarisation per site. |
0.0
|
a
|
float
|
The coefficient of |
-1.0
|
c
|
Annotated[float, open(0, oo)]
|
The coefficient of |
1.0
|
K
|
Annotated[float, closed_open(0, oo)]
|
The elastic constant. |
1.0
|
xi
|
float
|
The flow-alignment parameter. |
0.0
|
gamma
|
Annotated[float, open(0, oo)]
|
The rotational viscosity. |
1.0
|
eta
|
Annotated[float, open(0, oo)]
|
The viscosity of the flow. |
1.0
|
zeta
|
float
|
The activity. |
-0.5
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PolarGelSiteElement
>>> PolarGelSiteElement('site').xi
0.0
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
PropulsionStepInteraction(label, *, target, speed=1.0, state='x', heading='theta')
Bases: Interaction
Step x(t + 1) = x + speed (cos theta, sin theta) of a position in the plane.
The step is along a heading, in discrete time.
The step reads the heading at the start of the step, as every map of the step does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the particle or the group whose positions move. |
required |
speed
|
Annotated[float, closed_open(0, oo)]
|
The distance moved in one step. |
1.0
|
state
|
str
|
The name of the vector state that holds the position. |
'x'
|
heading
|
str
|
The name of the state that holds the heading. |
'theta'
|
Examples:
>>> from types import SimpleNamespace
>>> from sage.all__sagemath_symbolics import var, vector
>>> from skcomplex.systems.physics.common.particles import PropulsionStepInteraction
>>> target = SimpleNamespace(x=vector([var('x1'), var('x2')]), theta=var('theta'))
>>> step = PropulsionStepInteraction('propulsion', target='flock')
>>> [law.value for law in step.prepare(SimpleNamespace(target=target, speed=var('v'), t=var('t'))).laws_]
[(v*cos(theta) + x1, v*sin(theta) + x2)]
Source code in src/skcomplex/systems/physics/common/particles/_propulsion_step.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
RunAndTumbleInteraction(label, *, target)
Bases: Interaction
Run of every agent along its direction, then a tumble to a random direction.
Every step the agent moves speed along its direction in a periodic square, then tumbles with probability
1 - exp(-tumble_rate) to a direction drawn uniformly, as bacteria swim and robots search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The agents, with the points |
required |
Examples:
>>> from skcomplex.systems.physics.active_matter import RunAndTumbleInteraction
>>> RunAndTumbleInteraction('run', target='bacteria').target
'bacteria'
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
489 490 491 | |
RunAndTumbleSystem(n_agents=100, *, speed=0.1, tumble_rate=0.1, size=10.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Run-and-tumble agents in a periodic square.
The agents diffuse with v^2 (1 + q) / (4 (1 - q)) per step.
The persistence q = exp(-tumble_rate) is the probability that an agent keeps its direction for one step. The
system has the agent group bacteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_agents
|
int
|
The number of agents. |
100
|
speed
|
float
|
The distance run per step. |
0.1
|
tumble_rate
|
float
|
The rate of tumbles per step. |
0.1
|
size
|
float
|
The side of the periodic square. |
10.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and directions. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import RunAndTumbleSystem
>>> RunAndTumbleSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | |
SelfPropulsionInteraction(label, *, target, speed=1.0, state='x', heading='theta')
Bases: Interaction
Self-propulsion x' += speed (cos theta, sin theta) of a position in the plane.
The position drifts along a heading theta, which other laws turn and diffuse. It is a swimming bacterium, a
Janus colloid, or a walking robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particle or the group whose positions move. |
required |
speed
|
Annotated[float, closed_open(0, oo)]
|
The self-propulsion speed. |
1.0
|
state
|
str
|
The name of the vector value that holds the position. |
'x'
|
heading
|
str
|
The name of the value that holds the heading. |
'theta'
|
Examples:
>>> import math
>>> from skcomplex.core.components.spaces import ContinuousSpace
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.common.particles import ActiveParticleElement, SelfPropulsionInteraction
>>> swimmer = ActiveParticleElement('swimmer', theta=math.pi / 2)
>>> propulsion = SelfPropulsionInteraction('propulsion', target='swimmer', speed=2.0)
>>> system = System(elements=[swimmer], interactions=[propulsion], space=ContinuousSpace(n_dim=2))
>>> trajectory = system.prepare().simulate(until=1.0, dt=1.0)
>>> trajectory.get_values('swimmer.x')[-1].round(6).tolist()
[0.0, 2.0]
Source code in src/skcomplex/systems/physics/common/particles/_self_propulsion.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
ShapeVelocityCouplingInteraction(label, *, target, gamma=1.0, a=1.0, b=1.0, kappa=0.5, noise=0.0)
Bases: Interaction
Coupling of the velocity and the deformation of self-propelled particles, the model of Ohta and Ohkuma.
The particle moves with its velocity v, which follows v' = gamma v - |v|² v - a S v, and its deformation, the
traceless symmetric tensor S, follows S' = -kappa S + b (v v - |v|² I / 2). The motion stretches the particle
along the velocity for b > 0, and the deformation turns the velocity back. Noise of amplitude noise may kick
the velocity. It is a crawling cell, a droplet, or a camphor boat that changes shape as it moves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the particles, with the positions |
required |
gamma
|
float
|
The distance from the onset of self-propulsion. |
1.0
|
a
|
float
|
The coupling of the velocity to the deformation. |
1.0
|
b
|
float
|
The coupling of the deformation to the velocity. |
1.0
|
kappa
|
Annotated[float, open(0, oo)]
|
The relaxation rate of the deformation. |
0.5
|
noise
|
Annotated[float, closed_open(0, oo)]
|
The amplitude of the noise of the velocity. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import ShapeVelocityCouplingInteraction
>>> ShapeVelocityCouplingInteraction('coupling', target='cells').kappa
0.5
Source code in src/skcomplex/systems/physics/active_matter/_deformable.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
SquirmerElement(label, *, x=(0.0, 0.0, 0.0), p=(0.0, 0.0, 1.0), size=None, space=None)
Bases: Element
Spherical squirmers at the positions x that swim along the unit orientations p.
The slip of its surface sets how it swims and stirs the fluid, and SquirmerSlipInteraction turns the slip of
every squirmer into the motion of all of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the squirmers. |
required |
x
|
object
|
The initial positions, one row per squirmer or shared. |
(0.0, 0.0, 0.0)
|
p
|
object
|
The initial orientations, unit vectors, one row per squirmer or shared. |
(0.0, 0.0, 1.0)
|
size
|
int | None
|
The number of squirmers, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the squirmers, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import SquirmerElement
>>> SquirmerElement('swimmer', p=[0.0, 0.0, 1.0]).p
[0.0, 0.0, 1.0]
Source code in src/skcomplex/systems/physics/active_matter/_squirmers.py
62 63 64 65 66 67 68 69 70 71 72 73 | |
SquirmerSlipInteraction(label, *, target, B1=1.0, B2=0.0, epsilon=1.0, radius=1.0, viscosity=1.0)
Bases: StokesianMobilityInteraction
Slip of spherical squirmers.
The B1 and B2 modes make them swim and stir each other through the mobility.
A squirmer of radius a with the tangential surface slip B1 sin(theta) + B2 sin(theta) cos(theta) about its
orientation p (Lighthill 1952, Blake 1971) swims at 2 B1 / 3 along p. Far from it, the slip stirs the fluid as
the stresslet 4 pi eta a^2 B2 (p p - I / 3) and the potential dipole B1 a^3 p / 3 (Ishikawa, Simmonds, and
Pedley 2006). So beta = B2 / B1 < 0 makes a pusher, which pushes fluid out along its axis, and beta > 0 a
puller, which draws it in. The flows of the other squirmers move every squirmer and turn it by half their vorticity,
through StokesianMobilityInteraction. A Weeks-Chandler-Andersen repulsion of strength epsilon keeps the spheres
apart, within 2^(1/6) diameters of the current radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of squirmers. |
required |
B1
|
float
|
The first slip mode, which sets the swimming speed |
1.0
|
B2
|
float
|
The second slip mode, negative for pushers and positive for pullers. |
0.0
|
epsilon
|
Annotated[float, closed_open(0, oo)]
|
The strength of the repulsion between spheres closer than |
1.0
|
radius
|
Annotated[float, open(0, oo)]
|
The radius of the squirmers. |
1.0
|
viscosity
|
Annotated[float, open(0, oo)]
|
The viscosity of the fluid. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import SquirmerSlipInteraction
>>> SquirmerSlipInteraction('slip', target='squirmers', B2=-5.0).B2
-5.0
Source code in src/skcomplex/systems/physics/active_matter/_squirmers.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
SquirmersSystem(n_squirmers=27, *, B1=1.5, beta=-3.0, radius=1.0, viscosity=1.0, spacing=5.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Spherical squirmers that swim at 2 B1 / 3.
The squirmers stir each other as pushers or pullers.
The squirmers start on a jittered cubic lattice of the spacing in an unbounded fluid, with random orientations.
beta = B2 / B1 sets the stresslet: pushers (beta < 0) draw their neighbours in from the sides and pullers (`beta
0
) push them away. The system has the positionssquirmers.xand orientationssquirmers.p`.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_squirmers
|
int
|
The number of squirmers. |
27
|
B1
|
float
|
The first slip mode. |
1.5
|
beta
|
float
|
The ratio |
-3.0
|
radius
|
float
|
The radius of the squirmers. |
1.0
|
viscosity
|
float
|
The viscosity of the fluid. |
1.0
|
spacing
|
float
|
The spacing of the starting lattice. |
5.0
|
random_state
|
int | Generator | None
|
The seed or generator of the starting jitter and orientations. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import SquirmersSystem
>>> SquirmersSystem(8, beta=2.0).prepare().system_.interactions[0].B2
3.0
Source code in src/skcomplex/systems/physics/active_matter/_squirmers.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
SzaboCellsSystem(n_cells=200, *, density=1.0, eta=0.6, v0=1.0, mu=1.0, tau=1.0, R_eq=5.0 / 6.0, R_0=1.0, F_rep=30.0, F_adh=0.75, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The cells of Szabó et al. (2006) in a periodic box.
The cells move together above a critical density.
A cell moves at x' = v0 n + mu F, where F sums the pair forces of the neighbours within R_0, the diameter of a
cell, and its heading turns towards its velocity, theta' = arcsin((n x v / |v|) . e_z) / tau + xi. No cell reads
the headings of the others, and adhesion alone orders them. With eta = 0.6 the transition lies at the number
density rho_c = 0.18 / R_0^2. The system has the positions cells.x, the headings cells.theta, and the
observables mean_heading and polarization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_cells
|
int
|
The number of cells. |
200
|
density
|
float
|
The number of cells per unit area. |
1.0
|
eta
|
float
|
The strength of the angular noise. |
0.6
|
v0
|
float
|
The speed of the motility. |
1.0
|
mu
|
float
|
The mobility. |
1.0
|
tau
|
float
|
The relaxation time of the heading. |
1.0
|
R_eq
|
float
|
The equilibrium distance of a pair. |
5.0 / 6.0
|
R_0
|
float
|
The distance beyond which a pair exerts no force. |
1.0
|
F_rep
|
float
|
The largest repulsive force. |
30.0
|
F_adh
|
float
|
The largest adhesive force. |
0.75
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and headings. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import SzaboCellsSystem
>>> SzaboCellsSystem(16, density=0.5).prepare().system_.elements[0].space.extent
(5.656854249492381, 5.656854249492381)
Source code in src/skcomplex/systems/physics/active_matter/_cells.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
TargetSpeedInteraction(label, *, target, mu=10.0, v0=0.02, eta=0.0)
Bases: Interaction
Propulsion towards a target speed with a random force, which only active agents feel at full strength.
Every agent feels mu (active v0 - |v|) v / |v| on its velocity v = x', so active agents speed up to v0 and
passive ones slow to rest, and a random force of amplitude active eta. It is a self-propelled bacterium among
dead ones, a walking pedestrian among standing ones, or a running fan in a crowd.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the agents, whose values are |
required |
mu
|
float
|
The strength of the propulsion. |
10.0
|
v0
|
float
|
The target speed of the active agents. |
0.02
|
eta
|
float
|
The amplitude of the random force on an active agent. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import TargetSpeedInteraction
>>> TargetSpeedInteraction('propulsion', target='agents', v0=0.5).v0
0.5
Source code in src/skcomplex/systems/physics/active_matter/_active_passive.py
123 124 125 126 127 128 | |
TonerTuInteraction(label, *, target, a=1.0, rho_c=0.5, beta=1.0, lam=1.0, sigma=0.5, D=0.5, noise=0.0)
Bases: Interaction
Toner-Tu hydrodynamics of a polar active fluid.
The density is conserved, drho/dt + div(rho v) = 0, and the velocity follows
dv/dt + lam (v . grad) v = a (rho - rho_c) v - beta |v|^2 v - sigma grad(rho) + D laplacian(v) with additive
noise of intensity noise. Above the critical density the fluid moves with the speed
sqrt(a (rho - rho_c) / beta). It is a flock of birds, a school of fish, or a swarm of bacteria seen from afar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the fluid, with the density |
required |
a
|
Annotated[float, closed_open(0, oo)]
|
The rate of the ordering instability per unit density. |
1.0
|
rho_c
|
Annotated[float, closed_open(0, oo)]
|
The critical density of the ordering transition. |
0.5
|
beta
|
Annotated[float, open(0, oo)]
|
The saturation of the speed. |
1.0
|
lam
|
float
|
The strength of the self-advection. |
1.0
|
sigma
|
Annotated[float, closed_open(0, oo)]
|
The pressure per unit density. |
0.5
|
D
|
Annotated[float, closed_open(0, oo)]
|
The viscosity of the velocity. |
0.5
|
noise
|
Annotated[float, closed_open(0, oo)]
|
The intensity of the velocity noise. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import TonerTuInteraction
>>> TonerTuInteraction('flow', target='flock').rho_c
0.5
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
TonerTuSystem(shape=(32, 32), *, rho0=1.0, rho_c=0.5, a=1.0, beta=1.0, lam=1.0, sigma=0.5, D=0.5, spacing=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Toner-Tu hydrodynamics of a polar flock on a periodic lattice.
The flock starts from a disordered velocity field.
Above the critical density the velocity grows and aligns until the whole fluid moves together with the speed sqrt(a
(rho0 - rho_c) / beta). The system has the fields flock.rho, flock.vx, and flock.vy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along each axis. |
(32, 32)
|
rho0
|
float
|
The mean density. |
1.0
|
rho_c
|
float
|
The critical density of the ordering transition. |
0.5
|
a
|
float
|
The rate of the ordering instability per unit density. |
1.0
|
beta
|
float
|
The saturation of the speed. |
1.0
|
lam
|
float
|
The strength of the self-advection. |
1.0
|
sigma
|
float
|
The pressure per unit density. |
0.5
|
D
|
float
|
The viscosity of the velocity. |
0.5
|
spacing
|
float
|
The distance between sites. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial velocities. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.active_matter import TonerTuSystem
>>> TonerTuSystem((8, 8)).prepare().simulate(until=1.0).get_values('flock.rho').shape
(3, 64)
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
TumblerElement(label, *, x=0.0, y=0.0, theta=0.0, speed=0.1, tumble_rate=0.1, width=10.0, size=None, space=None)
Bases: Element
Run-and-tumble agents at the points x and y of a periodic square, each with its direction theta.
RunAndTumbleInteraction runs every agent straight and tumbles it to a random direction, as bacteria such as E.
coli do. The direction wraps around the circle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
x
|
object
|
The initial first coordinate, one per agent or shared. |
0.0
|
y
|
object
|
The initial second coordinate, one per agent or shared. |
0.0
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial direction, one per agent or shared. |
0.0
|
speed
|
Annotated[float, closed_open(0, oo)]
|
The distance run per step. |
0.1
|
tumble_rate
|
Annotated[float, closed_open(0, oo)]
|
The rate of tumbles per step. |
0.1
|
width
|
Annotated[float, open(0, oo)]
|
The side of the periodic square. |
10.0
|
size
|
int | None
|
The number of agents, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the agents, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import TumblerElement
>>> TumblerElement('bacterium').speed
0.1
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
TumblerView
Bases: AgentViewProtocol, Protocol
Run-and-tumble agent as rules see it.
The agent has its direction and the parameters of its group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
The Mesa agent. |
required | |
stepper
|
The stepper that runs the system. |
required |
VelocityFlockingInteraction(label, *, target, alpha=1.0, reach=0.1)
Bases: Interaction
Flocking force of size alpha along the summed velocities of the neighbours, felt by active agents.
The force is active alpha V / |V|, with V the sum of the velocities x' of the other agents within reach. It
is the alignment of birds in a flock, of fish in a school, or of marching locusts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the agents, whose values are |
required |
alpha
|
float
|
The size of the flocking force. |
1.0
|
reach
|
float
|
The radius within which an agent reads the velocities of the others. |
0.1
|
Examples:
>>> from skcomplex.systems.physics.active_matter import VelocityFlockingInteraction
>>> VelocityFlockingInteraction('flocking', target='agents', reach=0.2).reach
0.2
Source code in src/skcomplex/systems/physics/active_matter/_active_passive.py
175 176 177 178 179 | |
VicsekParticleElement(label, *, x=(0.0, 0.0), theta=0.0, eta=0.1, size=None, space=None)
Bases: Element
Particles of a Vicsek flock with the positions x, the headings theta, and the noise amplitudes eta.
HeadingAlignmentInteraction sets the new heading to the circular mean of the headings within the unit distance,
itself included, plus a uniform angle in [-eta pi, eta pi]. A propulsion step moves the particle along its
heading, which wraps around the circle. A delayed alignment reads past headings, which hold the initial heading
before the start.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particles. |
required |
x
|
object
|
The initial positions, one row per particle or shared. |
(0.0, 0.0)
|
theta
|
Annotated[object, Period(2 * pi)]
|
The initial headings, one per particle or shared. |
0.0
|
eta
|
Annotated[object, closed_open(0, oo)]
|
The amplitude of the noise, as a fraction of |
0.1
|
size
|
int | None
|
The number of particles, or |
None
|
space
|
BaseSpace | None
|
The continuous space of the particles, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import VicsekParticleElement
>>> VicsekParticleElement('bird').eta
0.1
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
VicsekSystem(n_particles=400, *, size=10.0, v0=0.5, eta=0.1, seed=0, neighbors=None, vision=None, delay=0, memory=5, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Vicsek system.
Particles move at a constant speed along the mean heading of their neighbours.
At every step particle i takes the direction of the sum of the headings of the particles within the unit
distance, itself included, plus a uniform angle in [-eta pi, eta pi], and moves v0 along it in a periodic box.
At low noise and high density the particles align into a flock, and the polar order parameter
|<exp(i theta)>| grows from about 1 / sqrt(N) to near 1. Raising the noise or lowering the density destroys
the order.
Two variants of Argun et al. (2021, Section 8.3) make the interaction non-metric or non-reciprocal. With
neighbors, a particle aligns with its neighbors nearest particles and itself at any distance, a topological
interaction that need not be reciprocal, and the clusters grow with neighbors. With vision, a particle sees only
the particles within the unit distance whose direction from it makes an angle of at most vision with its heading,
a vision cone that breaks reciprocity. The two variants do not combine, since the nearest neighbourhood of the core
has no cone.
With a positive delay h, the sensory delay of Section 8.2, a particle aligns with the headings its neighbours
had h steps ago, theta_j(n + 1) = <theta_k(n - h)> + noise. Argun et al. report that a short delay stabilizes
the clusters, and a long delay hinders them. A negative delay is a prediction: the headings of the neighbours |h|
steps ahead are extrapolated by a least-squares line through their last memory headings, and it hinders
clustering. The delay lies in [-25, 25], and before the start the past headings equal the initial heading. The
system has the positions flock.x, the headings flock.theta, and the observables polarization and
nematic_order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_particles
|
int
|
The number of particles. |
400
|
size
|
float
|
The side of the periodic box, in units of the interaction radius. |
10.0
|
v0
|
float
|
The distance a particle moves in one step. |
0.5
|
eta
|
float
|
The amplitude of the noise, as a fraction of |
0.1
|
seed
|
int
|
The seed of the uniform initial positions and headings. |
0
|
neighbors
|
int | None
|
The number of nearest particles a particle aligns with, or |
None
|
vision
|
float | None
|
The half-angle of the vision cone in |
None
|
delay
|
int
|
The delay of the alignment in steps, negative for a prediction. |
0
|
memory
|
int
|
The number of past headings a prediction fits, from 2 to 26. |
5
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Raises:
| Type | Description |
|---|---|
ParameterError
|
Both |
Examples:
>>> from skcomplex.systems.physics.active_matter import VicsekSystem
>>> VicsekSystem(10).prepare().system_.elements[0].size
10
>>> type(VicsekSystem(10, neighbors=4).prepare().system_.interactions[1].neighborhood).__name__
'NearestNeighborhood'
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |