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| Stage | Job |
|---|---|
hold | Identity; one-frame delay, the loop break |
seed | Two hash noises (R and G), changed by salt |
pass | Holds last state, or reseeds (Noise or Uniform) when reseed = 1; also reseeds any texel that is exactly (0, 0) (self-heal) |
fx fy iy ix | Separable complex DFT (gen_dft.py); ix keeps the complex result |
spec | Complex per-bin step, exact for the linear part (dt, L, c1, eps); the k = 0 bin is multiplied, not zeroed |
nl | Exact cubic step per texel, plus containment |
enc | Periodic upsample, readout gain, the four views, bypass gate |
encv | Periodic upsample, readout gain, A as a vecfield, bypass gate |
Parameters
| Name | Type | Range | Default | Description |
|---|---|---|---|---|
c1 | float | 0.5–4 | 2 | Diffusive dispersion: how much the waves twist. Low = calm, high = spiral-rich |
eps | float | −1.5–0.5 | −1 | Distance past the Benjamin-Feir line, eps = 1 + c1·c3. c3 is never a control: c3 = clamp((eps − 1) / c1, −3, 2) |
scale | float | 50–200 | 200 | Domain size L; bigger = finer grain, more spirals across the frame |
rate | float | 0–0.2 | 0.1 | dt per frame |
seed | menu | Noise, Uniform | Noise | Noise: many defects from the start. Uniform: defect-free start (needed for phase turbulence) |
view | menu | Hue+Luma, Phase, Amplitude, Gradient | Hue+Luma | Gradient is Im(conj(A) grad A), central differences with dx = L / N on the 256 texels, then upsampled |
twist | int | 1–4 | 1 | Hue cycles faster: the phase is multiplied by this (repeated complex multiplication, no atan2) |
gain | float | 0–20 | 5 | Gradient view contrast |
reset | button / message | — | — | Reseeds from the selected seed with a new salt; fires once on load (200 ms) |
bypass | toggle | 0/1 | 0 | Outlet 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
c3clamp to [−3, 2] only bites whenc1is small andepsis far from 1; the dial pair is(c1, eps)so the Benjamin-Feir line sits at one end. - Outlet 2 is
Aitself: zero exactly at a defect core, |A| about 1 elsewhere, smooth, not a gradient. Whether that drivesf_vf_warporf_vf_advectusefully 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;
passself-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 nativebypass 1message has no effect (param-bypass module; the jsui setsbypass_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_ksis 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_coresmodule 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--slowon 2026-11-27; the view andencvrows were added after and are recorded intasks.mdT032 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.