Active matter
Active matter: self-propelled particles, flocking, polar fluids, chemotaxis, squirmers, and Active System B+.
ActiveBeadElement(label, visual=None, *, x=0.0, y=0.0, theta=0.0, v0=1.0, k=10.0, D_t=0.1, D_r=1.0)
Bases: Element
Bead of an active polymer, an active Brownian particle bonded to its neighbours along a chain by springs.
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 Rouse chain. The beads at the ends have one neighbour.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the bead or the chain. |
required |
visual
|
VisualSpec | None
|
How the bead is drawn, or |
None
|
x
|
Annotated[float, StateSpec()]
|
The initial first coordinate. |
0.0
|
y
|
Annotated[float, StateSpec()]
|
The initial second coordinate. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi)]
|
The initial orientation. |
0.0
|
v0
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The self-propulsion speed. |
1.0
|
k
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The stiffness of the bonds. |
10.0
|
D_t
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The translational diffusion coefficient. |
0.1
|
D_r
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rotational diffusion coefficient. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the bead when it sets none. |
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveBeadElement
>>> ActiveBeadElement('bead').k
10.0
Source code in src/skcomplex/systems/physics/active_matter/_polymers.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
ActiveParticleElement(label, visual=POINTS, *, x=0.0, theta=0.0, D_t=0.1, D_r=1.0, omega=0.0)
Bases: Element
Active particle in the plane, whose position diffuses, dx = sqrt(2 D_t) dW, and whose orientation turns.
The orientation turns at the angular velocity omega and diffuses, dtheta = omega dt + sqrt(2 D_r) dW. A
SelfPropulsionInteraction adds the drift v (cos theta, sin theta) of the position. With omega = 0 it is an
active Brownian particle, and otherwise a chiral active particle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
POINTS
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction)]
|
The initial orientation. |
0.0
|
D_t
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The translational diffusion coefficient. |
0.1
|
D_r
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rotational diffusion coefficient. |
1.0
|
omega
|
Annotated[float, ParameterSpec()]
|
The angular velocity of a chiral particle. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.common.particles import ActiveParticleElement
>>> ActiveParticleElement('swimmer', D_r=2.0).D_r
2.0
Source code in src/skcomplex/systems/physics/common/particles/_active_particle.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
ActiveScalarElement(label, visual=None, *, phi=0.0, kappa=1.0, lam=1.0, zeta=4.0, D=0.05)
Bases: Element
Site of Active System B+, a conserved scalar field phi that phase separates with active currents.
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
phi
|
Annotated[float, StateSpec()]
|
The initial field. |
0.0
|
kappa
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The stiffness of the interfaces. |
1.0
|
lam
|
Annotated[float, ParameterSpec()]
|
The active term of the chemical potential. |
1.0
|
zeta
|
Annotated[float, ParameterSpec()]
|
The active current. |
4.0
|
D
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the conserved noise. |
0.05
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the element when it sets none. |
Examples:
>>> from skcomplex.systems.physics.active_matter import ActiveScalarElement
>>> ActiveScalarElement('site').zeta
4.0
Source code in src/skcomplex/systems/physics/active_matter/_system_b.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
AngularAlignmentInteraction(label, *, candidate, field, angles=32, frequency=1.0, noise=0.5, state='f')
Bases: EncounterInteraction
Pairs of self-propelled 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 parts of its system. |
required |
candidate
|
Annotated[str, RoleSpec()]
|
The path of the field on a phase space with a periodic orientation axis. |
required |
field
|
Annotated[str, RoleSpec()]
|
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. |
'f'
|
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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
AngularDiffusionInteraction(label, *, candidate, angles=32, tumbling=1.0, noise=0.5, state='f')
Bases: EncounterInteraction
Self-propelled particles change their angle at a rate by a wrapped normal noise, a linear redistribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
candidate
|
Annotated[str, RoleSpec()]
|
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. |
'f'
|
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
136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
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 binary collisions of self-propelled particles, 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
|
Annotated[str, RoleSpec()]
|
The path of the group of particles. |
required |
speed
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The self-propulsion speed. |
1.0
|
lam
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of self-diffusion events. |
1.0
|
sigma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The standard deviation of the angular noise of both kinds of events. |
0.3
|
d0
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The collision distance. |
0.5
|
substeps
|
Annotated[float, ParameterSpec(domain=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
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
fly(system)
Move the particles for one unit of time, with self-diffusion and collisions in every substep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/physics/active_matter/_collisions.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
ChemotaxisElement(label, visual=None, *, rho=1.0, c=1.0, D=1.0, chi=5.0, Dc=1.0, k=1.0)
Bases: Element
Site of the Keller-Segel system, cells of density rho that climb the gradient of a chemical c 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
rho
|
Annotated[float, StateSpec()]
|
The initial density of cells. |
1.0
|
c
|
Annotated[float, StateSpec()]
|
The initial concentration of the chemical. |
1.0
|
D
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The diffusion coefficient of the cells. |
1.0
|
chi
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The chemotactic sensitivity. |
5.0
|
Dc
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The diffusion coefficient of the chemical. |
1.0
|
k
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The decay rate of the chemical. |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the element when it sets none. |
Examples:
>>> from skcomplex.systems.physics.active_matter import ChemotaxisElement
>>> ChemotaxisElement('site').chi
5.0
Source code in src/skcomplex/systems/physics/active_matter/_chemotaxis.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
CohesiveParticleElement(label, visual=None, *, x=0.0, theta=0.0, eta=0.1, alpha=1.0, beta=1.0, r_c=CLOSE, r_e=0.5, r_a=0.8)
Bases: Element
Particle of a Grégoire-Chaté flock, which aligns, repels close neighbours, and attracts distant ones.
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. A propulsion step moves the
particle along its heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn, or |
None
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction)]
|
The initial heading. |
0.0
|
eta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the vectorial noise. |
0.1
|
alpha
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the alignment. |
1.0
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the cohesion. |
1.0
|
r_c
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The distance below which the neighbours repel strongly. |
CLOSE
|
r_e
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The preferred distance. |
0.5
|
r_a
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The distance of the strongest attraction. |
0.8
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the particle when it sets none. |
Examples:
>>> from skcomplex.systems.physics.active_matter import CohesiveParticleElement
>>> CohesiveParticleElement('bird').r_e
0.5
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
ContractileGelSiteElement(label, visual=None, *, 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)
Bases: Element
Site of a one-dimensional active viscoelastic gel, the density of contractile cells and the gel displacement.
The 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 site or the gel. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
c
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial density of the cells. |
1.0
|
u
|
Annotated[float, StateSpec()]
|
The initial displacement of the gel. |
0.0
|
D
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The diffusion coefficient of the cells. |
0.1
|
gamma
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The friction of the gel with the substrate. |
1.0
|
eta
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The viscosity of the gel. |
1.0
|
E
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The stiffness of the gel. |
0.1
|
T0
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The largest active stress of the cells. |
4.0
|
c_sat
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The density at which the active stress is half its largest value. |
1.0
|
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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
CuckerSmaleAlignmentInteraction(label, first, second, cutoff=1.0, position='x', *, K=1.0, beta=0.25, period=None, n_agents=1)
Bases: PairCouplingInteraction
Cucker-Smale alignment, x_i'' += K / N psi(r_ij) (x_j' - x_i') with psi(r) = (1 + r^2)^(-beta).
Every pair of members within the cutoff pulls their velocities, the first derivatives of their positions of order 2, towards each other with a weight that decays with their distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
first
|
str
|
The path of the group or particle of the first members. |
required |
second
|
str
|
The path of the group or particle of the second members. |
required |
cutoff
|
float
|
The distance beyond which pairs do not align, large for the all-to-all system. |
1.0
|
position
|
str
|
The name of the vector state of order 2 that holds the positions of the members. |
'x'
|
K
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the alignment. |
1.0
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The decay exponent of the weight. |
0.25
|
period
|
float | None
|
The side of a periodic box, for minimum image distances, or |
None
|
n_agents
|
int
|
The number of agents |
1
|
Examples:
>>> from skcomplex.systems.physics.active_matter import CuckerSmaleAlignmentInteraction
>>> CuckerSmaleAlignmentInteraction('align', first='birds', second='birds', beta=0.25).beta
0.25
Source code in src/skcomplex/systems/physics/active_matter/_collective.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 265 266 | |
DeformableParticleElement(label, visual=POINTS, *, x=0.0, v=0.0, S=0.0, gamma=1.0, a=1.0, b=1.0, kappa=0.5, noise=0.0)
Bases: Element
Deformable self-propelled particle, whose velocity and traceless deformation tensor drive each other.
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 model of Ohta and Ohkuma. 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn. |
POINTS
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
v
|
Annotated[ArrayLike, StateSpec(vector=True, role=velocity)]
|
The initial velocity. |
0.0
|
S
|
Annotated[ArrayLike, StateSpec(tensor=traceless)]
|
The initial deformation, given by its two independent components. |
0.0
|
gamma
|
Annotated[float, ParameterSpec()]
|
The distance from the onset of self-propulsion. |
1.0
|
a
|
Annotated[float, ParameterSpec()]
|
The coupling of the velocity to the deformation. |
1.0
|
b
|
Annotated[float, ParameterSpec()]
|
The coupling of the deformation to the velocity. |
1.0
|
kappa
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The relaxation rate of the deformation. |
0.5
|
noise
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The amplitude of the noise of the velocity. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DeformableParticleElement
>>> DeformableParticleElement('cell').kappa
0.5
Source code in src/skcomplex/systems/physics/active_matter/_deformable.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
DelayedVicsekParticleElement(label, visual=None, *, x=0.0, theta=0.0, eta=0.1)
Bases: Element
Particle of a delayed Vicsek flock, which keeps its past headings for the delayed or predicted alignment.
The heading keeps its last 25 values, theta_lag1 to theta_lag25, which a delayed alignment reads, and which
hold the initial heading before the start. A propulsion step moves the particle along its current heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn, or |
None
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction, lags=MEMORY)]
|
The initial heading, also its value before the start. |
0.0
|
eta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The amplitude of the noise, as a fraction of |
0.1
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the particle when it sets none. |
Examples:
>>> from skcomplex.systems.physics.active_matter import DelayedVicsekParticleElement
>>> DelayedVicsekParticleElement('bird').eta
0.1
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
185 186 187 188 189 190 191 192 193 194 195 196 197 | |
DepotParticleElement(label, visual=POINTS, *, x=0.0, v=0.0, e=0.0, gamma=20.0, q=10.0, c=1.0, d=10.0, D=0.01)
Bases: Element
Brownian particle pumped by an internal energy depot, as in 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).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
POINTS
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
v
|
Annotated[ArrayLike, StateSpec(vector=True, role=velocity)]
|
The initial velocity. |
0.0
|
e
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial energy of the depot. |
0.0
|
gamma
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The friction coefficient. |
20.0
|
q
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of energy intake. |
10.0
|
c
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of internal energy loss. |
1.0
|
d
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of conversion of depot energy into motion. |
10.0
|
D
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The intensity of the velocity noise. |
0.01
|
Examples:
>>> from skcomplex.systems.physics.active_matter import DepotParticleElement
>>> DepotParticleElement('walker').q
10.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
FlockerElement(label, visual=VisualSpec('agents', {'color_by': 'theta', 'color_range': (0.0, 2 * math.pi)}), *, theta=0.0)
Bases: Element
Self-propelled point particle with a heading theta, in a periodic square.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
VisualSpec('agents', {'color_by': 'theta', 'color_range': (0.0, 2 * pi)})
|
theta
|
Annotated[float, StateSpec(role=direction)]
|
The initial heading. |
0.0
|
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
59 60 61 62 63 64 65 66 67 | |
FlockerView(agent, stepper)
Bases: AgentView
Flocker as rules see it, with its heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
The Mesa agent. |
required |
stepper
|
MesaSolver
|
The stepper that runs the system. |
required |
Source code in src/skcomplex/core/engine/solvers/_mesa.py
559 560 561 | |
FlockingAgentElement(label, x=0.0, x_d1=0.0, visual=None, *, active=ACTIVE_AGENT)
Bases: PointElement
Agent of a crowd, a point with a mark that tells whether it is active or passive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or the group. |
required |
x
|
Annotated[ArrayLike, StateSpec(vector=True, order=2, role=position)]
|
The initial position. |
0.0
|
x_d1
|
ArrayLike
|
The initial velocity. |
0.0
|
visual
|
VisualSpec | None
|
How the agent is drawn, or |
None
|
active
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([PASSIVE_AGENT, ACTIVE_AGENT]))]
|
The mark, 1 for an active agent or 0 for a passive one. |
ACTIVE_AGENT
|
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
61 62 63 64 65 66 67 68 69 70 71 | |
HeadingAlignmentInteraction(label, *, target, nematic=False, neighborhood=None, latency=0, memory=5)
Bases: CouplingInteraction
Vicsek alignment, the turn of every particle 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. It is the map form of coupling with the circular mean over a radius. 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. A latent alignment needs
particles that keep enough past headings, such as DelayedVicsekParticleElement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
target
|
Annotated[str, RoleSpec()]
|
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).reduce
'circular-mean'
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
InertialActiveParticleElement(label, visual=POINTS, *, x=0.0, x_d1=0.0, theta=0.0, theta_d1=0.0, speed=1.0, mass=0.5, moment=0.1, D_t=0.1, D_r=1.0)
Bases: Element
Active Brownian particle with mass and moment of inertia, whose velocity and spin 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn. |
POINTS
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, order=2, role=position)]
|
The initial position. |
0.0
|
x_d1
|
ArrayLike
|
The initial velocity. |
0.0
|
theta
|
Annotated[float, StateSpec(order=2, role=direction)]
|
The initial orientation. |
0.0
|
theta_d1
|
float
|
The initial angular velocity. |
0.0
|
speed
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The self-propulsion speed |
1.0
|
mass
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mass |
0.5
|
moment
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The moment of inertia |
0.1
|
D_t
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The translational diffusion coefficient. |
0.1
|
D_r
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rotational diffusion coefficient. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import InertialActiveParticleElement
>>> InertialActiveParticleElement('swimmer').mass
0.5
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
LandauDeGennesEnergyInteraction(label, *, target, state='Q', a=-1.0, c=2.0, K=1.0, gamma=1.0, quadratic=None)
Bases: GradientInteraction
Gradient flow of a symmetric traceless tensor Q in the Landau-de Gennes free energy.
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 parts of its system. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the field. |
required |
state
|
str
|
The name of the state of the field that holds the tensor. |
'Q'
|
a
|
Annotated[float, ParameterSpec()]
|
The coefficient of |
-1.0
|
c
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The coefficient of |
2.0
|
K
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The elastic constant. |
1.0
|
gamma
|
Annotated[float, ParameterSpec(domain=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 sage.all__sagemath_symbolics import SR, matrix, var
>>> from skcomplex.systems.physics.active_matter import LandauDeGennesEnergyInteraction
>>> q, a, c = var('q, a, c')
>>> tensor = matrix(SR, [[q, 0], [0, -q]])
>>> LandauDeGennesEnergyInteraction._molecular_field(tensor, a, c, 0)[0, 0].factor()
-(2*c*q^2 + a)*q
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
MotileCellElement(label, visual=None, *, x=0.0, theta=0.0, 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: Element
Motile cell of a tissue, with its position, the heading of its motility, and its force and motility parameters.
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. 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cell or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction)]
|
The initial heading. |
0.0
|
v0
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The speed of the motility. |
1.0
|
mu
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The mobility. |
1.0
|
tau
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The relaxation time of the heading. |
1.0
|
eta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the angular noise, whose variance per unit time is |
0.6
|
R_eq
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The equilibrium distance of a pair. |
5.0 / 6.0
|
R_0
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The distance beyond which a pair exerts no force. |
1.0
|
F_rep
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The largest repulsive force. |
30.0
|
F_adh
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The largest adhesive force. |
0.75
|
Examples:
>>> from skcomplex.systems.physics.active_matter import MotileCellElement
>>> MotileCellElement('cell').F_rep
30.0
Source code in src/skcomplex/systems/physics/active_matter/_cells.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
NematicDensitySiteElement(label, visual=None, *, rho=1.0, Q=0.0, beta=0.5)
Bases: Element
Site of a dry active nematic, whose alignment tensor grows with the traceless curvature of the density.
The rate of the tensor from the density is beta (partial_i partial_j rho - delta_ij laplacian(rho) / 2). The
Landau-de Gennes energy and the current of the density are interactions of the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
rho
|
Annotated[ArrayLike, StateSpec()]
|
The initial density. |
1.0
|
Q
|
Annotated[ArrayLike, StateSpec(tensor=traceless)]
|
The initial alignment tensor, its independent components |
0.0
|
beta
|
Annotated[float, ParameterSpec()]
|
The coupling of the tensor to the curvature of the density. |
0.5
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the element when it sets none. |
Examples:
>>> from skcomplex.systems.physics.active_matter import NematicDensitySiteElement
>>> NematicDensitySiteElement('site').beta
0.5
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
72 73 74 75 76 77 78 79 80 81 82 83 84 | |
NematicGelSiteElement(label, visual=None, *, Q=0.0, a=-1.0, c=2.0, K=1.0, xi=0.0, gamma=1.0, eta=1.0, zeta=0.5)
Bases: Element
Site of an active nematic gel, a symmetric traceless tensor Q carried by an overdamped Stokes flow.
The tensor follows Q_t = -corotational(Q, u, xi) + H / gamma, with 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
Q
|
Annotated[ArrayLike, StateSpec(tensor=traceless)]
|
The initial tensor, its independent components |
0.0
|
a
|
Annotated[float, ParameterSpec()]
|
The coefficient of |
-1.0
|
c
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The coefficient of |
2.0
|
K
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The elastic constant. |
1.0
|
xi
|
Annotated[float, ParameterSpec()]
|
The flow-alignment parameter. |
0.0
|
gamma
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The rotational viscosity. |
1.0
|
eta
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The viscosity of the flow. |
1.0
|
zeta
|
Annotated[float, ParameterSpec()]
|
The activity. |
0.5
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the element when it sets 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
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
NematicParticleElement(label, visual=None, *, x=0.0, theta=0.0, eta=0.1)
Bases: Element
Polar particle with nematic alignment, which aligns with the axis of every neighbour on its nearer side.
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 particle or the group. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn, or |
None
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction)]
|
The initial heading. |
0.0
|
eta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The amplitude of the noise, as a fraction of |
0.1
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the particle when it sets 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
233 234 235 236 237 238 239 240 241 242 243 244 245 | |
NonreciprocalMoverElement(label, visual=SPECIES, *, x=0.0, theta=0.0, species=0.0, eta=0.3, J_aa=1.0, J_ab=1.0, J_ba=1.0, J_bb=1.0, radius=1.0)
Bases: Element
Vicsek mover of species A (0) or B (1), which aligns with the neighbours within radius by species couplings.
Every step the heading becomes the direction of sum_j J(species_i, species_j) exp(i theta_j) over the movers
within the radius, itself included, plus uniform noise of width eta. A propulsion step moves the mover along it.
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the mover. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
SPECIES
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction)]
|
The heading. |
0.0
|
species
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]
|
The species, 0 for A or 1 for B. |
0.0
|
eta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The width of the uniform noise of the heading. |
0.3
|
J_aa
|
Annotated[float, ParameterSpec()]
|
The alignment of A with A. |
1.0
|
J_ab
|
Annotated[float, ParameterSpec()]
|
The alignment of A with B. |
1.0
|
J_ba
|
Annotated[float, ParameterSpec()]
|
The alignment of B with A. |
1.0
|
J_bb
|
Annotated[float, ParameterSpec()]
|
The alignment of B with B. |
1.0
|
radius
|
float
|
The radius of the neighbourhood. |
1.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import NonreciprocalMoverElement
>>> NonreciprocalMoverElement('mover', J_ba=-1.0).J_ba
-1.0
Source code in src/skcomplex/systems/physics/active_matter/_nonreciprocal.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
OrnsteinUhlenbeckParticleElement(label, visual=POINTS, *, x=0.0, u=0.0, tau=1.0, D=1.0, D_t=0.0)
Bases: Element
Active Ornstein-Uhlenbeck particle, whose propulsion velocity u is 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
POINTS
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
u
|
Annotated[ArrayLike, StateSpec(vector=True)]
|
The initial propulsion velocity. |
0.0
|
tau
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The persistence time. |
1.0
|
D
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The active diffusion coefficient. |
1.0
|
D_t
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The translational diffusion coefficient. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import OrnsteinUhlenbeckParticleElement
>>> OrnsteinUhlenbeckParticleElement('swimmer').tau
1.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
PhoreticAttractionInteraction(label, first, second, cutoff=1.0, position='x', *, v0=20.0, R=1.0, period=None)
Bases: PairCouplingInteraction
Phoretic attraction between active colloids, the pair potential -v0 R^2 / r of an overdamped position.
Every member of a pair drifts towards the other at the speed v0 R^2 / r^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
first
|
str
|
The path of the group or particle of the first members. |
required |
second
|
str
|
The path of the group or particle of the second members. |
required |
cutoff
|
float
|
The distance beyond which the attraction is neglected. |
1.0
|
position
|
str
|
The name of the vector state that holds the positions of the members. |
'x'
|
v0
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The drift speed at the distance |
20.0
|
R
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The particle radius. |
1.0
|
period
|
float | None
|
The side of a periodic box, for minimum image distances, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PhoreticAttractionInteraction
>>> PhoreticAttractionInteraction('phoresis', first='colloids', second='colloids', v0=20.0).v0
20.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
PolarAlignmentInteraction(label, first, second, cutoff=1.0, position='x', *, gamma=1.0, period=None)
Bases: PairCouplingInteraction
Alignment torque between two particles closer than the cutoff, theta_i' += gamma sin(theta_j - theta_i).
Summed over every neighbour j within the interaction range d0, the cutoff, the torque turns each particle
towards the headings of its neighbours.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
first
|
str
|
The path of the group or particle of the first members. |
required |
second
|
str
|
The path of the group or particle of the second members. |
required |
cutoff
|
float
|
The interaction range |
1.0
|
position
|
str
|
The name of the vector state that holds the positions of the members. |
'x'
|
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the alignment. |
1.0
|
period
|
float | None
|
The side of a periodic box, for minimum image distances, or |
None
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PolarAlignmentInteraction
>>> PolarAlignmentInteraction('align', first='swimmers', second='swimmers', gamma=0.5).gamma
0.5
Source code in src/skcomplex/systems/physics/active_matter/_alignment.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
PolarFluidElement(label, visual=None, *, rho=1.0, vx=0.0, vy=0.0, a=1.0, rho_c=0.5, beta=1.0, lam=1.0, sigma=0.5, D=0.5, noise=0.0)
Bases: Element
Site of the Toner-Tu polar active fluid, with a density rho and a velocity (vx, vy).
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).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
rho
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial density. |
1.0
|
vx
|
Annotated[float, StateSpec()]
|
The initial velocity along the first axis. |
0.0
|
vy
|
Annotated[float, StateSpec()]
|
The initial velocity along the second axis. |
0.0
|
a
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of the ordering instability per unit density. |
1.0
|
rho_c
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The critical density of the ordering transition. |
0.5
|
beta
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The saturation of the speed. |
1.0
|
lam
|
Annotated[float, ParameterSpec()]
|
The strength of the self-advection. |
1.0
|
sigma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The pressure per unit density. |
0.5
|
D
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The viscosity of the velocity. |
0.5
|
noise
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The intensity of the velocity noise. |
0.0
|
Examples:
>>> from skcomplex.systems.physics.active_matter import PolarFluidElement
>>> PolarFluidElement('site').rho_c
0.5
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
PolarGelSiteElement(label, visual=None, *, p=0.0, a=-1.0, c=1.0, K=1.0, xi=0.0, gamma=1.0, eta=1.0, zeta=-0.5)
Bases: Element
Site of an active polar gel, a polarisation p carried by an overdamped Stokes flow.
The polarisation follows p_t = -corotational(p, u, xi) + h / gamma, with 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
p
|
Annotated[ArrayLike, StateSpec(vector=True)]
|
The initial polarisation. |
0.0
|
a
|
Annotated[float, ParameterSpec()]
|
The coefficient of |
-1.0
|
c
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The coefficient of |
1.0
|
K
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The elastic constant. |
1.0
|
xi
|
Annotated[float, ParameterSpec()]
|
The flow-alignment parameter. |
0.0
|
gamma
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The rotational viscosity. |
1.0
|
eta
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The viscosity of the flow. |
1.0
|
zeta
|
Annotated[float, ParameterSpec()]
|
The activity. |
-0.5
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the element when it sets 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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
PropulsionStepInteraction(label, *, target, speed=1.0, state='x', heading='theta')
Bases: MapInteraction
Step x(t + 1) = x + speed (cos theta, sin theta) of a position in the plane 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 parts of its system. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the particle or the group whose positions move. |
required |
speed
|
Annotated[float, ParameterSpec(domain=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
>>> step = PropulsionStepInteraction('propulsion', target='flock').prepare()
>>> target = SimpleNamespace(x=vector([var('x1'), var('x2')]), theta=var('theta'))
>>> [law.value for law in step.run(SimpleNamespace(target=target, speed=var('v'))).laws_]
[(v*cos(theta) + x1, v*sin(theta) + x2)]
Source code in src/skcomplex/systems/physics/common/particles/_propulsion_step.py
48 49 50 51 52 53 54 55 56 57 58 59 | |
SelfPropulsionInteraction(label, *, target, speed=1.0, state='x', heading='theta')
Bases: RateInteraction
Self-propulsion x' += speed (cos theta, sin theta) of a position in the plane along a heading theta.
The heading is a state of the same target, which other laws turn and diffuse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the particle or the group whose positions move. |
required |
speed
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The self-propulsion speed. |
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 SelfPropulsionInteraction
>>> propulsion = SelfPropulsionInteraction('propulsion', target='swimmers').prepare()
>>> target = SimpleNamespace(x=vector([var('x1'), var('x2')]), theta=var('theta'))
>>> [law.value for law in propulsion.run(SimpleNamespace(target=target, speed=var('v'))).laws_]
[(v*cos(theta), v*sin(theta))]
Source code in src/skcomplex/systems/physics/common/particles/_self_propulsion.py
48 49 50 51 52 53 54 55 56 57 58 59 | |
SquirmerElement(label, visual=POINTS, *, x=0.0, p=0.0)
Bases: Element
Spherical squirmer, a microswimmer at the position x that swims along the unit orientation 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 squirmer or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
POINTS
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
p
|
Annotated[ArrayLike, StateSpec(vector=True)]
|
The initial orientation, a unit vector. |
0.0
|
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
52 53 54 55 56 57 58 59 60 61 62 | |
SquirmerSlipInteraction(label, *, target, B1=1.0, B2=0.0, epsilon=1.0, radius=1.0, viscosity=1.0)
Bases: MobilityInteraction
Slip of spherical squirmers, the B1 and B2 modes that 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 MobilityInteraction. 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
|
Annotated[str, RoleSpec()]
|
The path of the group of squirmers. |
required |
B1
|
Annotated[float, ParameterSpec()]
|
The first slip mode, which sets the swimming speed |
1.0
|
B2
|
Annotated[float, ParameterSpec()]
|
The second slip mode, negative for pushers and positive for pullers. |
0.0
|
epsilon
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The strength of the repulsion between spheres closer than |
1.0
|
radius
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The radius of the squirmers. |
1.0
|
viscosity
|
Annotated[float, ParameterSpec(domain=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
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
TumblerElement(label, visual=VisualSpec('agents', {'color_by': 'theta'}), *, theta=0.0, speed=0.1, tumble_rate=0.1, width=10.0)
Bases: Element
Run-and-tumble agent in a periodic square, which runs straight and tumbles to a random direction.
Every step the agent moves speed along its direction, then tumbles with probability 1 - exp(-tumble_rate)
to a direction drawn uniformly, as bacteria such as E. coli do.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
VisualSpec('agents', {'color_by': 'theta'})
|
theta
|
Annotated[float, StateSpec(role=direction)]
|
The initial direction. |
0.0
|
speed
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The distance run per step. |
0.1
|
tumble_rate
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of tumbles per step. |
0.1
|
width
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The side of the periodic square. |
10.0
|
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
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
run_and_tumble(agent, system)
Run one step along the direction, then tumble at random.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
TumblerView
|
The agent. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
TumblerView(agent, stepper)
Bases: AgentView
Run-and-tumble agent as rules see it, with its direction and the parameters of its group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
The Mesa agent. |
required |
stepper
|
MesaSolver
|
The stepper that runs the system. |
required |
Source code in src/skcomplex/core/engine/solvers/_mesa.py
559 560 561 | |
VicsekParticleElement(label, visual=None, *, x=0.0, theta=0.0, eta=0.1)
Bases: Element
Particle of a Vicsek flock, whose heading becomes the mean heading of its neighbours plus noise every step.
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the particle or the group. |
required |
visual
|
VisualSpec | None
|
How the particle is drawn, or |
None
|
x
|
Annotated[ArrayLike, StateSpec(vector=True, role=position)]
|
The initial position. |
0.0
|
theta
|
Annotated[float, StateSpec(period=2 * pi, role=direction)]
|
The initial heading. |
0.0
|
eta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The amplitude of the noise, as a fraction of |
0.1
|
Attributes:
| Name | Type | Description |
|---|---|---|
default_visual_ |
The visual of the particle when it sets 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
281 282 283 284 285 286 287 288 289 290 291 292 293 | |
active_brownian_particles(n_particles=200, *, speed=3.0, D_t=0.1, D_r=1.0, size=50.0, random_state=0)
Return active Brownian particles in the plane, which 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).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import active_brownian_particles
>>> active_brownian_particles(10).elements[0].prepare().size_
10
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
active_gels(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)
Return an active gel, a nematic tensor or a polarisation 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the field |
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 active_gels
>>> active_gels((8, 8), order='polar').elements[0].values['zeta']
-0.5
>>> active_gels(order='polar').elements[0].space.shape
(32, 32)
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
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 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 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 | |
active_ornstein_uhlenbeck_particles(n_particles=200, *, tau=1.0, D=1.0, D_t=0.0, size=50.0, random_state=0)
Return active Ornstein-Uhlenbeck particles in the plane, driven by exponentially correlated propulsion.
The propulsion starts in its stationary distribution, normal with variance D / tau per component.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import active_ornstein_uhlenbeck_particles
>>> active_ornstein_uhlenbeck_particles(10, tau=0.5).elements[0].values['tau']
0.5
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
active_passive_flocking(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)
Return the active and passive agents of Charbonneau (2017, section 10.4) in a periodic box.
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).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the group |
Raises:
| Type | Description |
|---|---|
ValidationError
|
The number of active agents is not between 1 and |
Examples:
>>> from skcomplex.systems.physics.active_matter import active_passive_flocking
>>> [element.label for element in active_passive_flocking(114).elements]
['agents']
Source code in src/skcomplex/systems/physics/active_matter/_active_passive.py
155 156 157 158 159 160 161 162 163 164 165 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 193 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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
active_polymer(n_beads=20, *, v0=1.0, k=10.0, D_t=0.1, D_r=1.0, random_state=0)
Return an active polymer, a Rouse chain of active Brownian beads that each swim along their 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the coordinates |
Examples:
>>> from skcomplex.systems.physics.active_matter import active_polymer
>>> active_polymer(5).elements[0].prepare().size_
5
Source code in src/skcomplex/systems/physics/active_matter/_polymers.py
110 111 112 113 114 115 116 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
active_system_b(shape=(64, 64), *, mean=0.4, kappa=1.0, lam=1.0, zeta=4.0, D=0.05, random_state=0)
Return 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the field |
Examples:
>>> from skcomplex.systems.physics.active_matter import active_system_b
>>> active_system_b((8, 8), zeta=0.0).elements[0].values['zeta']
0.0
Source code in src/skcomplex/systems/physics/active_matter/_system_b.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
active_viscoelastic_gel(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)
Return a one-dimensional active viscoelastic gel, where 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the density |
Examples:
>>> from skcomplex.systems.physics.active_matter import active_viscoelastic_gel
>>> active_viscoelastic_gel(16).elements[0].values['eta']
1.0
Source code in src/skcomplex/systems/physics/active_matter/_gels.py
115 116 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
aligning_active_brownian_particles(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)
Return active Brownian particles in a periodic box whose headings align with the 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import aligning_active_brownian_particles
>>> aligning_active_brownian_particles(10, gamma=0.5).interactions[0].gamma
0.5
Source code in src/skcomplex/systems/physics/active_matter/_alignment.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 | |
bertin_droz_gregoire(positions=4, angles=16, *, density=1.0, speed=1.0, interaction_range=0.5, tumbling=1.0, noise=0.5, perturbation=0.01)
Return the kinetic theory of flocking, whose 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)).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the density |
Examples:
>>> from skcomplex.systems.physics.active_matter import bertin_droz_gregoire
>>> bertin_droz_gregoire(2, 8).elements[0].prepare().size_
32
Source code in src/skcomplex/systems/physics/active_matter/_kinetic_flocks.py
163 164 165 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 193 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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
binary_collision_flocking(n_particles=400, *, size=20.0, speed=1.0, lam=1.0, sigma=0.3, d0=0.5, substeps=10, random_state=0)
Return self-propelled particles that flock through aligning binary collisions, 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the agent group |
Examples:
>>> from skcomplex.systems.physics.active_matter import binary_collision_flocking
>>> binary_collision_flocking(10).interactions[0].sigma
0.3
Source code in src/skcomplex/systems/physics/active_matter/_collisions.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
chiral_active_particles(n_particles=200, *, speed=3.0, omega=2.0, D_t=0.1, D_r=0.1, size=50.0, random_state=0)
Return chiral active particles, which 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)).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import chiral_active_particles
>>> chiral_active_particles(10, omega=1.0).elements[0].values['omega']
1.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
cucker_smale_flocking(n_agents=50, *, K=1.0, beta=0.25, size=10.0, random_state=0)
Return Cucker-Smale flocking, where 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import cucker_smale_flocking
>>> cucker_smale_flocking(5).interactions[0].n_agents
5
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
deformable_active_particles(n_particles=20, *, gamma=1.0, a=1.0, b=1.0, kappa=0.5, noise=0.0, random_state=0)
Return deformable self-propelled particles of Ohta and Ohkuma, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import deformable_active_particles
>>> deformable_active_particles(5).elements[0].prepare().size_
5
Source code in src/skcomplex/systems/physics/active_matter/_deformable.py
114 115 116 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
depot_brownian_particles(n_particles=50, *, gamma=20.0, q=10.0, c=1.0, d=10.0, D=0.01, random_state=0)
Return Brownian particles with energy depots, which start at rest and take up the speed sqrt(q/gamma - c/d).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import depot_brownian_particles
>>> depot_brownian_particles(5).elements[0].values['q']
10.0
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 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 669 670 671 672 673 674 675 676 677 | |
dry_active_nematics(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)
Return a dry active nematic, a conserved density 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the fields |
Examples:
>>> from skcomplex.systems.physics.active_matter import dry_active_nematics
>>> dry_active_nematics((8, 8)).elements[0].values['beta']
0.5
Source code in src/skcomplex/systems/physics/active_matter/_nematics.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
ginelli_nematics(n_particles=400, *, size=10.0, v0=0.3, eta=0.08, seed=0)
Return polar particles with nematic alignment, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import ginelli_nematics
>>> ginelli_nematics(10).elements[0].values['eta']
0.08
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 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
gregoire_chate(n_particles=200, *, size=5.0, v0=0.05, eta=0.1, alpha=1.0, beta=0.5, seed=0)
Return the Grégoire-Chaté system: aligning particles that 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import gregoire_chate
>>> gregoire_chate(10, beta=2.0).elements[0].values['beta']
2.0
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
inertial_active_brownian_particles(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)
Return active Brownian particles with inertia, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import inertial_active_brownian_particles
>>> inertial_active_brownian_particles(10).elements[0].prepare().size_
10
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
keller_segel(shape=(32, 32), *, length=32.0, D=1.0, chi=5.0, Dc=1.0, k=1.0, density=1.0, random_state=0)
Return the Keller-Segel system of cells that diffuse and climb the gradient of a chemical they secrete.
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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the cell density |
Examples:
>>> from skcomplex.systems.physics.active_matter import keller_segel
>>> keller_segel((8, 8), chi=0.5).elements[0].values['chi']
0.5
Source code in src/skcomplex/systems/physics/active_matter/_chemotaxis.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
living_crystals(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)
Return active colloids of radius 1 with phoretic attraction, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import living_crystals
>>> living_crystals(16).interactions[2].v0
20.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
motility_induced_phase_separation(n_particles=400, *, packing_fraction=0.5, speed=1.0, D_r=0.01, k=50.0, random_state=0)
Return repulsive active Brownian disks of unit diameter, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import motility_induced_phase_separation
>>> motility_induced_phase_separation(16).interactions[1].k
50.0
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
nonreciprocal_vicsek(n_movers=400, *, size=5.0, J_ab=1.0, J_ba=-1.0, eta=0.3, random_state=1)
Return two species of Vicsek movers in a periodic box whose alignment with each other is nonreciprocal.
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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the mean headings |
Examples:
>>> from skcomplex.systems.physics.active_matter import nonreciprocal_vicsek
>>> nonreciprocal_vicsek(20).elements[0].prepare().size_
20
Source code in src/skcomplex/systems/physics/active_matter/_nonreciprocal.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
run_and_tumble(n_agents=100, *, speed=0.1, tumble_rate=0.1, size=10.0, random_state=0)
Return run-and-tumble agents in a periodic square, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the agent group |
Examples:
>>> from skcomplex.systems.physics.active_matter import run_and_tumble
>>> run_and_tumble(10).elements[0].prepare().size_
10
Source code in src/skcomplex/systems/physics/active_matter/_particles.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
squirmers(n_squirmers=27, *, B1=1.5, beta=-3.0, radius=1.0, viscosity=1.0, spacing=5.0, random_state=0)
Return spherical squirmers that swim at 2 B1 / 3 and 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import squirmers
>>> squirmers(8, beta=2.0).interactions[0].B2
3.0
Source code in src/skcomplex/systems/physics/active_matter/_squirmers.py
156 157 158 159 160 161 162 163 164 165 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 193 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 224 225 226 227 228 229 230 231 232 233 234 | |
szabo_cells(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)
Return the cells of Szabó et al. (2006) in a periodic box, which 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.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Examples:
>>> from skcomplex.systems.physics.active_matter import szabo_cells
>>> szabo_cells(16, density=0.5).space.extent
(5.656854249492381, 5.656854249492381)
Source code in src/skcomplex/systems/physics/active_matter/_cells.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 193 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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
toner_tu(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)
Return the Toner-Tu hydrodynamics of a polar flock on a periodic lattice, 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).
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the fields |
Examples:
>>> from skcomplex.systems.physics.active_matter import toner_tu
>>> toner_tu((8, 8)).elements[0].prepare().size_
64
Source code in src/skcomplex/systems/physics/active_matter/_collective.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
vicsek(n_particles=400, *, size=10.0, v0=0.5, eta=0.1, seed=0, neighbors=None, vision=None, delay=0, memory=5)
Return the Vicsek system: particles that 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. Every particle then keeps its last 25 headings, so the delay lies in [-25, 25], and before the start
they equal the initial heading.
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
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the positions |
Raises:
| Type | Description |
|---|---|
ParameterError
|
Both |
Examples:
>>> from skcomplex.systems.physics.active_matter import vicsek
>>> vicsek(10).elements[0].size
10
>>> type(vicsek(10, neighbors=4).interactions[1].neighborhood).__name__
'NearestNeighborhood'
Source code in src/skcomplex/systems/physics/active_matter/_flocks.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 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 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |