← f_ notebook · docs/f-reference/f_cgl.md

f_cgl ​

Type: Generator (no texture inlet, color out plus a vecfield out) — temporal / has memoryStatus: Built and benched on the GPU (Claude ran, Matt's go, 2026-11-27); first live look passed (Matt, 2026-11-27, "look passes" in chat, T025; the settings looked at were not recorded); T034 (views) and T042 (outlet 2) are still open. README marks it ⚠ Unverified.

Reference written 2026-11-27 (Claude, offline) from src/f_cgl/ (definition and codeboxes), .specify/f_cgl/{spec,tasks}.md, ideas/f_cgl.md "Spike result" and tests/modules/cgl/. Where the spec and the shipped module differ, this doc follows the shipped module. Bench figures are quoted from tasks.md (T026, T027), not re-run here.


What it does ​

A complex Ginzburg-Landau generator on the GPU: dA/dt = A + (1 + i c1) lap A - (1 + i c3)|A|² A, a complex field A (two floats per texel) on a periodic grid, evolving forever with no forcing. Spiral waves, defects that nucleate and annihilate, and, in a narrow band, a smooth phase turbulence that is the KS-like look. Phase becomes hue and amplitude becomes luma, so unlike f_ks (luma only) the main outlet is color.

Two outlets: 1 the look (view menu), 2 A itself as a vecfield (R, G = Re A, Im A, B = 0.5, A = 1). The solver is a fixed 256 × 256 float32 grid; only the two encode stages follow the render size.

Overlap: nothing else in the library is a complex-field oscillator medium (module-inventory.md). f_ks is real-valued, f_wc is a driven neural field.


Signal Flow ​

One control inlet (messages and the draw bang, no texture), two outlets. Same stage shape as f_ks.

hold -> pass (in 1)        seed -> pass (in 2)
pass -> fx -> fy -> spec -> iy -> ix -> nl       (nl -> hold: the feedback edge)
                                         nl -> enc  (render size) -> outlet 1
                                         nl -> encv (render size) -> outlet 2
StageJob
holdIdentity; one-frame delay, the loop break
seedTwo hash noises (R and G), changed by salt
passHolds last state, or reseeds (Noise or Uniform) when reseed = 1; also reseeds any texel that is exactly (0, 0) (self-heal)
fx fy iy ixSeparable complex DFT (gen_dft.py); ix keeps the complex result
specComplex per-bin step, exact for the linear part (dt, L, c1, eps); the k = 0 bin is multiplied, not zeroed
nlExact cubic step per texel, plus containment
encPeriodic upsample, readout gain, the four views, bypass gate
encvPeriodic upsample, readout gain, A as a vecfield, bypass gate

Parameters ​

NameTypeRangeDefaultDescription
c1float0.5–42Diffusive dispersion: how much the waves twist. Low = calm, high = spiral-rich
epsfloat−1.5–0.5−1Distance past the Benjamin-Feir line, eps = 1 + c1·c3. c3 is never a control: c3 = clamp((eps − 1) / c1, −3, 2)
scalefloat50–200200Domain size L; bigger = finer grain, more spirals across the frame
ratefloat0–0.20.1dt per frame
seedmenuNoise, UniformNoiseNoise: many defects from the start. Uniform: defect-free start (needed for phase turbulence)
viewmenuHue+Luma, Phase, Amplitude, GradientHue+LumaGradient is Im(conj(A) grad A), central differences with dx = L / N on the 256 texels, then upsampled
twistint1–41Hue cycles faster: the phase is multiplied by this (repeated complex multiplication, no atan2)
gainfloat0–205Gradient view contrast
resetbutton / message——Reseeds from the selected seed with a new salt; fires once on load (200 ms)
bypasstoggle0/10Outlet 1 black with alpha 1; outlet 2 the neutral vector (0.5, 0.5, 0.5, 1); the solver keeps running

Internal: reseed, salt, bypass_gate. Dial ranges and defaults were set by the spec and the Phase 0 spike; the first look (T025) and Matt's use may change them.


Algorithm and regimes ​

Strang split step in the frame co-rotating with the uniform state (D14), one step per frame. The carried state is offset by exp(−dt/2) from the true field, so both encode stages scale A by exp(dt/2) (D15a). Hue is a cosine palette from cos φ = Re/|A| and sin φ = Im/|A| by angle addition, rgb_j = 0.5 + 0.5 cos(φ − 2πj/3), not atan2 (checked on the GPU against an independent atan2 route, 1.5e-6 to 1.9e-6).

Regime map in (c1, eps), from the NumPy spike (observed, N = 128, L = 100, dt 0.1, T up to 2000, two seeds; ideas/f_cgl.md "Spike result"). The GPU module uses 256², so this is the map of the equation, not a measurement of the module:

  • eps ≥ 0 from a smooth start: stays uniform (confirmed at c1 1 to 4). From a noise start, defects can persist inside this region (bistable), so Noise seed plus eps > 0 is not "dead".
  • Phase turbulence: a narrow band just past the line, up to about eps = −c1/3 (a fit through four columns, observed, not theory). Zero defects, |A| 0.97 to 1.00, phase-gradient rms 0.01 to 0.14, so it is nearly flat in Amplitude and Hue and visible in Gradient. Growth is slow near eps = 0 (eps −0.1 stayed uniform to T = 2000). Only from the Uniform seed.
  • Defect turbulence: below the band, spiral cores nucleate and annihilate (up to 174 defects at once; more defects at stronger |c3|). Confirmed to T = 600, "forever" not tested.
  • Frozen or slow spirals: at large c1 with c3 near 0 or slightly negative; seed-dependent.
  • Dead zone: positive c3 with c1 ≥ 1 is mostly uniform from white noise.

Seed dependence: the same dials give phase turbulence from Uniform and defects from Noise. Not tested in the spike: other N, other L (the scale dial), dt above 0.2, the ranges outside c1 0.5 to 4.

KS link: a defect-free CGLE run matches the f_ks form to about 10 to 20 percent at five points (hand-derived mapping, inferred), so the calm end looks like f_ks in color.


Notes ​

  • The c3 clamp to [−3, 2] only bites when c1 is small and eps is far from 1; the dial pair is (c1, eps) so the Benjamin-Feir line sits at one end.
  • Outlet 2 is A itself: zero exactly at a defect core, |A| about 1 elsewhere, smooth, not a gradient. Whether that drives f_vf_warp or f_vf_advect usefully is the open live look (T042; revert D10 if not).
  • A = 0 is still a fixed point of the equation (an unstable one: the linear term grows it), so a frozen zero state is possible; pass self-heals exact (0, 0) texels (also after a GL context rebuild).
  • Containment: non-finite becomes 0 and values are clamped (500 clamps to 4 in the bench).
  • Mean mode is never zeroed; |A| stayed bounded in all 308 spike runs.
  • Bypass matches f_ks (solver running, releasing resumes a warm field); outlet 2 is the neutral vecfield. The native bypass 1 message has no effect (param-bypass module; the jsui sets bypass_gate).
  • Cost (observed, GPU, 2026-11-27, slow rows): about 3.47 ms per frame, an upper bound (four of eight stages unresolved), DFT passes 2.13 ms for four; f_ks is 2.39 ms. Bypassed cost, 512² and 1080p encodes: not measured (T053). The cost target (D20) is still a gate.
  • Chaos limits verification: 30 frames against the mirror 1.1e-5, 100 frames 2.1e-4 (float32 rounding growing about 2× per 25 to 30 frames); long runs compare statistics (mean |A| 0.75126 on both).

Known issues / open ​

  • Open live looks: T034 (each view on PT and DT), T042 (outlet 2 into a consumer), render-size following in a real Vsynth render.
  • Not v1, unbuilt: Texture seed (User Story 6), real GL (D22). A defect-marks outlet was dropped 2026-11-29 (Matt): the separate f_cores module reads outlet 2 and marks the cores (f_cores.md).
  • Menu category (Patterns, beside f_ks) is provisional (G-menu).

Verification ​

  • tests/modules/cgl/test_cgl.py — NumPy mirror, 26 fast tests plus slow tests 30/30 (tests/logs/20261127-152150-offline.log, per the docs).
  • tests/modules/cgl/bench_cgl.py — GPU against mirror (8/8 and 10/10 with --slow on 2026-11-27; the view and encv rows were added after and are recorded in tasks.md T032 and T041).
  • tests/modules/cgl/bench_cgl_module.py — the real patcher; contract bench bypass row for both outlets.

References ​

  • ideas/f_cgl.md (concept note and spike result), ideas/f_cgl_spike.py, docs/f-reference/pattern_formation_orientation.md, f_ks.md (same solver architecture), f_vecfield_type.md (outlet 2 contract).
  • Benjamin-Feir threshold and the GL equation checked against Wikipedia (2026-11-27); everything else from the spike or memory.

Source Files ​

src/f_cgl/definition.py, src/f_cgl/codebox_{seed,pass,dft_fx,dft_fy,dft_iy,dft_ix,spec,nl,enc,encv}.gen, src/f_cgl/gen_dft.py, package/patchers/f_cgl.maxpat, .specify/f_cgl/{spec,tasks}.md.