Pattern formation
Pattern formation systems.
The package covers amplitude equations, rolls, phase ordering, and nonreciprocal conserved fields.
AllenCahnSystem(shape=(128, 128), *, length=128.0, mean=0.0, kappa=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Allen-Cahn equation, System A.
It is the non-conserved relaxation of an order parameter in a double well.
The order parameter follows phi_t = phi - phi^3 + kappa laplacian(phi), the gradient descent of the free energy
density -phi^2 / 2 + phi^4 / 4 + kappa |grad(phi)|^2 / 2. From small noise, domains of phi = 1 and phi = -1
form and coarsen as their walls move by curvature, so their size grows as t^(1/2). The mean of phi is not
conserved, and a domain shrinks away instead of exchanging material with its neighbours. The system has the field
mixture.phi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every axis of the periodic lattice. |
(128, 128)
|
length
|
float
|
The side of the domain. |
128.0
|
mean
|
float
|
The mean of the initial noise. |
0.0
|
kappa
|
float
|
The stiffness of the domain walls. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial noise of amplitude 0.05. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import AllenCahnSystem
>>> AllenCahnSystem((8, 8), kappa=2.0).prepare().system_.interactions[0].kappa
2.0
Source code in src/skcomplex/systems/physics/pattern_formation/_ordering.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
CahnHilliardSystem(shape=(64, 64), *, length=64.0, mean=0.0, kappa=1.0, temperature=0.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Cahn-Hilliard equation, System B.
It is the conserved relaxation of an order parameter in a double well.
The order parameter follows phi_t = laplacian(-phi + phi^3 - kappa laplacian(phi)), a diffusion down the
gradient of the chemical potential of the same free energy as the Allen-Cahn equation. Inside the spinodal,
|mean| < 1 / sqrt(3), small noise decomposes into domains of phi near 1 and -1, which coarsen by diffusion
through the bulk so that their size grows as t^(1/3), while the mean of phi stays fixed.
A positive temperature adds the thermal noise of System B, div(sqrt(2 temperature) eta), which conserves the mean
of phi as well. The field then uses finite differences, and an SDE solver such as EulerMaruyamaSolver integrates
it, with a step below spacing^4 / (32 kappa). The system has the field mixture.phi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every axis of the periodic lattice. |
(64, 64)
|
length
|
float
|
The side of the domain. |
64.0
|
mean
|
float
|
The mean of the order parameter, which the dynamics conserve. |
0.0
|
kappa
|
float
|
The stiffness of the interfaces. |
1.0
|
temperature
|
float
|
The temperature of the conserved thermal noise, or 0 for the deterministic equation. |
0.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial noise of amplitude 0.05. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import CahnHilliardSystem
>>> CahnHilliardSystem((8, 8), mean=0.3).prepare().system_.interactions[0].conserved
True
>>> system = CahnHilliardSystem((8, 8), temperature=0.1).prepare().system_
>>> [interaction.label for interaction in system.interactions]
['energy', 'noise']
Source code in src/skcomplex/systems/physics/pattern_formation/_ordering.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
ComplexGinzburgLandauSystem(shape=(64, 64), *, length=64.0, b=1.0, c=-1.5, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The complex Ginzburg-Landau equation.
The equation is A_t = A + (1 + i b) laplacian(A) - (1 + i c) |A|^2 A.
The amplitude A = u + i v is held as its real and imaginary parts, and the linear part couples them per Fourier
mode. With 1 + b c < 0 the uniform oscillation is unstable and spiral defects turn into turbulence. The system has
the real part medium.u and the imaginary part medium.v.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along both axes of the periodic lattice. |
(64, 64)
|
length
|
float
|
The side of the square. |
64.0
|
b
|
float
|
The linear dispersion. |
1.0
|
c
|
float
|
The nonlinear dispersion. |
-1.5
|
random_state
|
int | Generator | None
|
The seed or generator of the small random initial amplitude. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import ComplexGinzburgLandauSystem
>>> ComplexGinzburgLandauSystem((8, 8)).prepare().system_.interactions[0].c
-1.5
Source code in src/skcomplex/systems/physics/pattern_formation/_patterns.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
GinzburgLandauElement(label, *, u=0.0, v=0.0, space=None)
Bases: Element
Sites of a complex amplitude A = u + i v, held as its real part u and its imaginary part v.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the field. |
required |
u
|
object
|
The initial real part of the amplitude, one value per site or one for all. |
0.0
|
v
|
object
|
The initial imaginary part of the amplitude, one value per site or one for all. |
0.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import GinzburgLandauElement
>>> GinzburgLandauElement('site', u=0.5).u
0.5
Source code in src/skcomplex/systems/physics/pattern_formation/_patterns.py
51 52 53 54 | |
GinzburgLandauInteraction(label, *, target, b=1.0, c=-1.5)
Bases: Interaction
The complex Ginzburg-Landau dynamics A_t = A + (1 + i b) laplacian(A) - (1 - i c) |A|^2 A of an amplitude.
The amplitude A = u + i v of the target is held as its real and imaginary parts. Without the Laplacian every site
is a Stuart-Landau oscillator, and the dispersion b and the nonlinear frequency shift c set whether plane waves
are stable or break into spiral defect chaos.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the field, with the real part |
required |
b
|
float
|
The linear dispersion. |
1.0
|
c
|
float
|
The nonlinear frequency shift. |
-1.5
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import GinzburgLandauInteraction
>>> GinzburgLandauInteraction('dynamics', target='medium').c
-1.5
Source code in src/skcomplex/systems/physics/pattern_formation/_patterns.py
85 86 87 88 89 | |
NonreciprocalCahnHilliardInteraction(label, *, target, chi=0.0, alpha=0.3, D=0.1, kappa=1.0)
Bases: Interaction
Cross-diffusion of two conserved fields that couples them nonreciprocally.
The fields follow phi_t = laplacian(-phi + phi^3 - kappa laplacian(phi) + (chi + alpha) psi) and
psi_t = laplacian(D psi + (chi - alpha) phi). The reciprocal coupling chi derives from a free energy, and the
nonreciprocal coupling alpha does not, so above a threshold the demixed domains travel. It is a mixture of active
colloids, two chemical species that chase each other, or predator and prey that diffuse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the mixture. |
required |
chi
|
float
|
The reciprocal coupling. |
0.0
|
alpha
|
float
|
The nonreciprocal coupling. |
0.3
|
D
|
float
|
The diffusion coefficient of |
0.1
|
kappa
|
float
|
The stiffness of the interfaces of |
1.0
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import NonreciprocalCahnHilliardInteraction
>>> NonreciprocalCahnHilliardInteraction('coupling', target='mixture').alpha
0.3
Source code in src/skcomplex/systems/physics/pattern_formation/_conserved.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
NonreciprocalCahnHilliardSystem(shape=(128,), *, length=40.0, chi=0.0, alpha=0.3, D=0.1, kappa=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The nonreciprocal Cahn-Hilliard equations.
A demixing field is coupled to a diffusing one.
The conserved field phi phase separates and the conserved field psi diffuses, and they are coupled through
cross-diffusion, phi_t = laplacian(-phi + phi^3 - kappa laplacian(phi) + (chi + alpha) psi) and psi_t =
laplacian(D psi + (chi - alpha) phi), the minimal system of Brauns and Marchetti. The coupling chi is reciprocal
and alpha is not. When alpha^2 - chi^2 exceeds D^2, the unstable band of the dispersion relation of the mixed
state reaches the propagating modes, and the demixed domains travel instead of coarsening. The system has the
demixing field mixture.phi and the diffusing field mixture.psi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every axis of the periodic lattice. |
(128,)
|
length
|
float
|
The side of the domain. |
40.0
|
chi
|
float
|
The reciprocal part of the cross-diffusion. |
0.0
|
alpha
|
float
|
The nonreciprocal part of the cross-diffusion. |
0.3
|
D
|
float
|
The diffusivity of |
0.1
|
kappa
|
float
|
The stiffness of the interfaces of |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the small random initial fields around the mixed state. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import NonreciprocalCahnHilliardSystem
>>> NonreciprocalCahnHilliardSystem((16,), alpha=0.5).prepare().system_.interactions[0].alpha
0.5
Source code in src/skcomplex/systems/physics/pattern_formation/_conserved.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
NonreciprocalMixtureElement(label, *, phi=0.0, psi=0.0, space=None)
Bases: Element
Site of a mixture with a demixing field phi and a diffusing field psi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site or the field. |
required |
phi
|
object
|
The initial demixing field. |
0.0
|
psi
|
object
|
The initial diffusing field. |
0.0
|
space
|
BaseSpace | None
|
The lattice whose sites hold one site each, or |
None
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import NonreciprocalMixtureElement
>>> NonreciprocalMixtureElement('site', phi=0.1).phi
0.1
Source code in src/skcomplex/systems/physics/pattern_formation/_conserved.py
48 49 50 51 52 53 54 55 56 57 58 | |
PatternFieldElement(label, *, u=0.0, space=None)
Bases: Element
Sites of a real field u whose patterns a free energy selects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the field. |
required |
u
|
object
|
The initial value of the field, one value per site or one for all. |
0.0
|
space
|
BaseSpace | None
|
The lattice of the sites, or |
None
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import PatternFieldElement
>>> PatternFieldElement('site', u=0.1).u
0.1
Source code in src/skcomplex/systems/physics/pattern_formation/_patterns.py
127 128 129 | |
SwiftHohenbergSystem(shape=(64, 64), *, length=16 * math.pi, r=0.3, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Swift-Hohenberg equation u_t = r u - (1 + laplacian)^2 u - u^3.
The equation forms rolls of length 2 pi.
Above onset, r > 0, small noise grows into rolls whose wavenumber is near 1, the fastest growing one. The system
has the field cells.u.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every axis of the periodic lattice. |
(64, 64)
|
length
|
float
|
The side of the domain. |
16 * pi
|
r
|
float
|
The distance above onset. |
0.3
|
random_state
|
int | Generator | None
|
The seed or generator of the noise. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.physics.pattern_formation import SwiftHohenbergSystem
>>> SwiftHohenbergSystem((8, 8), r=0.1).prepare().system_.interactions[0].r
0.1
Source code in src/skcomplex/systems/physics/pattern_formation/_patterns.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |