Complex Ginzburg-Landau
The complex Ginzburg-Landau equation.
- Class:
ComplexGinzburgLandauSystem - Import:
from skcomplex.systems.physics.pattern_formation import ComplexGinzburgLandauSystem - Field:
physics/pattern_formation - Topics:
field,chaos,spirals,spectral,pde - References:
- Aranson and Kramer 2002
- Gros 2015
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.physics.pattern_formation import ComplexGinzburgLandauSystem
trajectory = ComplexGinzburgLandauSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
shape |
(64, 64) |
length |
64.0 |
b |
1.0 |
c |
-1.5 |
random_state |
0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | lattice |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class ComplexGinzburgLandauSystem(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`.
Args:
shape:
The number of sites along both axes of the periodic lattice.
length:
The side of the square.
b:
The linear dispersion.
c:
The nonlinear dispersion.
random_state:
The seed or generator of the small random initial amplitude.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for exponential steps of 0.1.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.physics.pattern_formation import ComplexGinzburgLandauSystem
>>> ComplexGinzburgLandauSystem((8, 8)).prepare().system_.interactions[0].c
-1.5
"""
field = 'physics/pattern_formation'
topics = ('field', 'chaos', 'spirals', 'spectral', 'pde')
references = ('Aranson and Kramer 2002', 'Gros 2015')
until = 50.0
dt = 1.0
@staticmethod
def _get_noise(shape: tuple[int, ...], scale: float, random_state: int | np.random.Generator | None) -> Array:
"""Return small uniform noise of a shape."""
return scale * np.random.default_rng(random_state).uniform(-1.0, 1.0, size=shape)
def __init__(
self,
shape: Sequence[int] = (64, 64),
*,
length: float = 64.0,
b: float = 1.0,
c: float = -1.5,
random_state: int | np.random.Generator | None = 0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.shape = shape
self.length = length
self.b = b
self.c = c
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the complex Ginzburg-Landau equation from a small random amplitude.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
shape = tuple(self.shape)
rng = np.random.default_rng(self.random_state)
u = ComplexGinzburgLandauSystem._get_noise(shape, 0.01, rng)
v = ComplexGinzburgLandauSystem._get_noise(shape, 0.01, rng)
space = LatticeSpace(shape, spacing=self.length / shape[0], discretization='spectral')
medium = GinzburgLandauElement('medium', u=u.ravel(), v=v.ravel(), space=space)
dynamics = GinzburgLandauInteraction('dynamics', target='medium', b=self.b, c=self.c)
self.system_ = System(self.label, elements=[medium], interactions=[dynamics], solver=ETDRK4Solver(dt=0.1))
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
GinzburgLandauElement, fromElement
Interactions:
GinzburgLandauInteraction, fromInteraction
class GinzburgLandauElement(Element):
"""Sites of a complex amplitude `A = u + i v`, held as its real part `u` and its imaginary part `v`.
Args:
label:
The label of the field.
u:
The initial real part of the amplitude, one value per site or one for all.
v:
The initial imaginary part of the amplitude, one value per site or one for all.
space:
The lattice of the sites, or `None` for one site.
Examples:
>>> from skcomplex.systems.physics.pattern_formation import GinzburgLandauElement
>>> GinzburgLandauElement('site', u=0.5).u
0.5
"""
def __init__(self, label: str, *, u: object = 0.0, v: object = 0.0, space: BaseSpace | None = None) -> None:
super().__init__(label, space=space)
self.u = u
self.v = v
class GinzburgLandauInteraction(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.
Args:
label:
The label of the interaction.
target:
The path of the field, with the real part `u` and the imaginary part `v`.
b:
The linear dispersion.
c:
The nonlinear frequency shift.
Examples:
>>> from skcomplex.systems.physics.pattern_formation import GinzburgLandauInteraction
>>> GinzburgLandauInteraction('dynamics', target='medium').c
-1.5
"""
law_classes = (RateLaw,)
def __init__(self, label: str, *, target: Role, b: float = 1.0, c: float = -1.5) -> None:
super().__init__(label)
self.target = target
self.b = b
self.c = c
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the rates of the real and imaginary parts of the amplitude of the target.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
s, t = context, context.t
u, v = s.target.u, s.target.v
square = u**2 + v**2
self.laws_ = [
RateLaw(u.diff(t), u + laplacian(u) - s.b * laplacian(v) - square * (u - s.c * v)),
RateLaw(v.diff(t), v + s.b * laplacian(u) + laplacian(v) - square * (s.c * u + v)),
]