Potential & Stimulus Operators
All stimulus operators take a destination field and an options table; most support scale_by_dt (bool) to scale writes by the simulation timestep.
🧭 Shared Coordinate Mapping
Section titled “🧭 Shared Coordinate Mapping”Most spatial stimuli support alternate coordinate mappings (2D, angle, radial). Applies to: stimulus_sine, stimulus_standing, stimulus_chirp, stimulus_gaussian_pulse, stimulus_spectral_lines, stimulus_checkerboard, stimulus_gabor, stimulus_digamma_square, digamma_square_warp.
| Parameter | Type | Default | Description |
|---|---|---|---|
coord_mode | enum | "axis" | Coordinate mode: axis, angle, radial, separable |
coord_axis | enum | "x" | Axis for coord_mode = "axis" |
coord_combine | enum | "multiply" | Separable combine rule: multiply, add |
coord_angle | double | 0.0 | Angle for coord_mode = "angle" (radians) |
origin_x, origin_y | double | 0.0 | Coordinate origin for 2D mappings |
spacing_x, spacing_y | double | 1.0 | Coordinate spacing for 2D mappings |
coord_center_x, coord_center_y | double | 0.0 | Radial coordinate center (units) |
coord_velocity_x, coord_velocity_y | double | 0.0 | Radial center velocity (units/s) |
Wavevector overrides (for stimulus_sine, stimulus_chirp, stimulus_spectral_lines, stimulus_gabor):
| Parameter | Type | Default | Description |
|---|---|---|---|
kx, ky | double | 0.0 | Wavevector components (rad/unit) |
use_wavevector | boolean | false | Use kx/ky instead of wavenumber + coordinate mapping |
⏱️ Shared Timing & Phase Controls
Section titled “⏱️ Shared Timing & Phase Controls”| Parameter | Type | Default | Description |
|---|---|---|---|
amplitude | double | Peak output amplitude (before dt scaling) | |
wavenumber | double | Spatial wavenumber k (rad/unit) | |
omega | double | Angular frequency (rad/s) | |
phase | double | 0.0 | Phase offset (radians) |
time_offset | double | 0.0 | Shift time by constant before evaluation |
nominal_dt | double | 0.0 | Fixed timestep for fixed_clock = true |
fixed_clock | boolean | false | Lock evolution to nominal_dt |
scale_by_dt | boolean | true | Multiply write by dt |
rotation | double | 0.0 | Complex phase rotation on output (radians) |
〰️ Sine
Section titled “〰️ Sine”sim_add_stimulus_operator(ctx, field, opts)
Generate a travelling sinusoidal wave. Fundamental building block for wave propagation, oscillating forcing, and harmonic analysis.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_sine".
Mathematical Formulation
Section titled “Mathematical Formulation”where:
- is the amplitude
- is the wavenumber
- is the angular frequency
- is the phase offset
Phase velocity:
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_sine" |
amplitude | double | unbounded | Peak amplitude (required) | |
wavenumber | double | unbounded | Spatial wavenumber k (required) | |
omega | double | unbounded | Angular frequency (required) | |
phase | double | 0.0 | unbounded | Phase offset (radians) |
time_offset | double | 0.0 | unbounded | Temporal shift |
rotation | double | 0.0 | unbounded | Complex phase rotation |
nominal_dt | double | 0.0 | ≥0 | Fixed timestep |
fixed_clock | boolean | false | — | Use nominal_dt |
scale_by_dt | boolean | true | — | Scale by dt |
Plus all shared coordinate mapping parameters.
Examples
Section titled “Examples”-- Basic travelling waveooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_sine", amplitude = 0.3, wavenumber = 1.0, omega = 0.6})
-- Standing-like behavior (omega = 0)ooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_sine", amplitude = 0.5, wavenumber = 2.0, omega = 0.0, phase = math.pi / 4})
-- 2D wavevector specificationooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_sine", amplitude = 0.4, use_wavevector = true, kx = 0.5, ky = 0.5, omega = 1.0})🌊 Standing Wave
Section titled “🌊 Standing Wave”sim_add_stimulus_operator(ctx, field, opts)
Generate a standing-wave sinusoid with fixed nodes and antinodes. Models resonant cavity modes and stationary vibration patterns.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_standing".
Mathematical Formulation
Section titled “Mathematical Formulation”Equivalently, this is the superposition of two counter-propagating waves:
- Nodes: Points where (always zero)
- Antinodes: Points where (maximum oscillation)
Parameters
Section titled “Parameters”Same as stimulus_sine:
| Parameter | Type | Default | Description |
|---|---|---|---|
type | string | — | Must be "stimulus_standing" |
amplitude | double | Peak amplitude (required) | |
wavenumber | double | Spatial wavenumber (required) | |
omega | double | Angular frequency (required) | |
phase | double | 0.0 | Controls node/antinode placement |
Plus timing and coordinate parameters.
Examples
Section titled “Examples”-- Basic standing waveooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_standing", amplitude = 0.4, wavenumber = 0.8, omega = 0.8, phase = 0.25})
-- Half-wavelength shifted nodesooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_standing", amplitude = 0.5, wavenumber = 1.0, omega = 1.0, phase = math.pi / 2})🐦 Chirp
Section titled “🐦 Chirp”sim_add_stimulus_operator(ctx, field, opts)
Generate a sinusoid with time-varying frequency and/or wavenumber. Models frequency sweeps, dispersive waves, and time-frequency analysis signals.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_chirp".
Mathematical Formulation
Section titled “Mathematical Formulation”where:
- is the initial wavenumber
- is
kdot(wavenumber rate) - is the initial angular frequency
- is
wdot(frequency rate)
Instantaneous frequency:
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_chirp" |
amplitude | double | unbounded | Peak amplitude (required) | |
wavenumber | double | unbounded | Initial wavenumber (required) | |
omega | double | unbounded | Initial angular frequency (required) | |
kdot | double | 0.0 | unbounded | Wavenumber rate (rad/unit/s) |
wdot | double | 0.0 | unbounded | Frequency rate (rad/s²) |
phase | double | 0.0 | unbounded | Phase offset |
rotation | double | 0.0 | unbounded | Complex phase rotation |
time_offset | double | 0.0 | unbounded | Temporal shift |
Plus timing and coordinate parameters.
Examples
Section titled “Examples”-- Linear frequency chirpooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_chirp", amplitude = 0.5, wavenumber = 1.0, omega = 0.3, kdot = 0.1, wdot = 0.2})
-- Spatial chirp onlyooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_chirp", amplitude = 0.4, wavenumber = 0.5, omega = 1.0, kdot = 0.5, wdot = 0.0})💥 Gaussian Pulse
Section titled “💥 Gaussian Pulse”sim_add_stimulus_operator(ctx, field, opts)
Generate a pure Gaussian envelope without carrier oscillation. Models localized pulses, initial conditions, and smooth spatial masks.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_gaussian_pulse".
Mathematical Formulation
Section titled “Mathematical Formulation”1D:
2D separable:
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_gaussian_pulse" |
amplitude | double | unbounded | Peak amplitude (required) | |
center_x, center_y | double | 0.0 | unbounded | 1D/2D center position |
sigma_x, sigma_y | double | 1.0 | >0 | 1D/2D standard deviations |
velocity_x, velocity_y | double | 0.0 | unbounded | 1D/2D velocities |
time_offset | double | 0.0 | unbounded | Temporal shift |
rotation | double | 0.0 | unbounded | Complex phase rotation |
Plus timing parameters.
Examples
Section titled “Examples”-- Static 1D Gaussianooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_gaussian_pulse", coord_center_x = 128, sigma_x = 30, amplitude = 1.0})
-- Moving pulseooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_gaussian_pulse", coord_center_x = 0, sigma_x = 10, amplitude = 0.5, velocity_x = 2.0})
-- 2D elliptical Gaussianooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_gaussian_pulse", amplitude = 0.8, coord_mode = "separable", coord_center_x = 128, coord_center_y = 128, sigma_x = 20, sigma_y = 40})🌈 Spectral Lines
Section titled “🌈 Spectral Lines”sim_add_stimulus_operator(ctx, field, opts)
Generate harmonic series with configurable power weighting. Models multi-tone signals, harmonic oscillators, and comb-like spectra.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_spectral_lines".
Mathematical Formulation
Section titled “Mathematical Formulation”where:
- is
harmonic_count - is
harmonic_power - Higher reduces high-frequency content
Special cases:
- : Equal amplitude harmonics
- : amplitude decay (approaching square wave)
- : amplitude decay (faster rolloff)
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_spectral_lines" |
amplitude | double | unbounded | Peak amplitude (required) | |
wavenumber | double | unbounded | Fundamental wavenumber | |
omega | double | unbounded | Fundamental frequency | |
phase | double | 0.0 | unbounded | Phase offset |
harmonic_count | integer | 1 | ≥1 | Number of harmonics |
harmonic_power | double | 0.0 | ≥0 | Power weighting exponent |
Plus timing and coordinate parameters.
Examples
Section titled “Examples”-- Single fundamentalooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_spectral_lines", amplitude = 1.0, wavenumber = 0.5, harmonic_count = 1})
-- Rich harmonic contentooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_spectral_lines", amplitude = 0.2, harmonic_count = 4, harmonic_power = 0.9, fixed_clock = true})
-- Square-wave approximation (odd harmonics with 1/n decay)ooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_spectral_lines", amplitude = 0.5, wavenumber = 1.0, omega = 1.0, harmonic_count = 8, harmonic_power = 1.0})🎛️ Fourier Waveform
Section titled “🎛️ Fourier Waveform”sim_add_stimulus_operator(ctx, field, opts)
Generate bandlimited waveforms using BLIT, PolyBLEP, or miniBLEP synthesis. Produces alias-free sawtooth, square, and triangle waves.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_fourier".
Mathematical Formulation
Section titled “Mathematical Formulation”Sawtooth (ideal):
Square (ideal):
Triangle (ideal):
The method parameter selects the anti-aliasing technique:
- blit: Band-Limited Impulse Train
- polyblep: Polynomial BLEP correction
- miniblep: Minimum-phase BLEP
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_fourier" |
amplitude | double | unbounded | Waveform amplitude (required) | |
frequency | double | >0 | Fundamental frequency in Hz (required) | |
shape | enum | "saw" | see below | Waveform shape |
method | enum | "polyblep" | see below | Anti-aliasing method |
duty | double | 0.5 | [0, 1] | Duty cycle for square/triangle |
phase | double | 0.0 | [0, 1) | Initial phase in cycles |
rotation | double | 0.0 | unbounded | Complex phase rotation |
Shape options: saw, square, triangle
Method options: blit, polyblep, miniblep
Plus timing parameters.
Examples
Section titled “Examples”-- Bandlimited sawtooth at 440 Hzooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_fourier", amplitude = 0.8, frequency = 440.0, shape = "saw", method = "polyblep"})
-- Square wave with 25% duty cycleooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_fourier", amplitude = 0.5, frequency = 220.0, shape = "square", duty = 0.25})
-- Triangle waveooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_fourier", amplitude = 0.6, frequency = 110.0, shape = "triangle"})🏁 Checkerboard
Section titled “🏁 Checkerboard”sim_add_stimulus_operator(ctx, field, opts)
Generate checker or stripe patterns. Works on complex fields with configurable periods and phase.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_checkerboard".
Mathematical Formulation
Section titled “Mathematical Formulation”where:
- , are the periods
- is the complex phase rotation
Setting one period to infinity produces stripes along that axis.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_checkerboard" |
amplitude | double | unbounded | Pattern amplitude (required) | |
period_x | double | 8.0 | >0 | X-axis period (samples) |
period_y | double | 8.0 | >0 | Y-axis period (samples) |
phase | double | 0.0 | unbounded | Scalar phase offset |
complex_phase | double | 0.0 | unbounded | Complex rotation (radians) |
scale_by_dt | boolean | true | — | Scale by dt |
Examples
Section titled “Examples”-- Standard checkerboardooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_checkerboard", amplitude = 1.0, period_x = 8, period_y = 8})
-- Rectangular cells with complex phaseooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_checkerboard", amplitude = 0.5, period_x = 12, period_y = 6, complex_phase = 0.75})
-- Vertical stripes (large period_y)ooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_checkerboard", amplitude = 0.8, period_x = 16, period_y = 1000})📦 Gabor Kernel
Section titled “📦 Gabor Kernel”sim_add_stimulus_operator(ctx, field, opts)
Generate a Gaussian-windowed sinusoid (Gabor function). Optimal for joint time-frequency localization and models neural receptive fields.
Method Signature
Section titled “Method Signature”sim_add_stimulus_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Note: Requires type = "stimulus_gabor".
Mathematical Formulation
Section titled “Mathematical Formulation”1D:
2D with envelope rotation:
where are coordinates rotated by envelope_angle.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
type | string | — | — | Must be "stimulus_gabor" |
amplitude | double | unbounded | Peak amplitude (required) | |
wavenumber | double | unbounded | Carrier wavenumber | |
omega | double | 0.0 | unbounded | Carrier frequency |
phase | double | 0.0 | unbounded | Carrier phase |
center_x, center_y | double | 0.0 | unbounded | 1D/2D center |
sigma_x, sigma_y | double | 1.0 | >0 | 1D/2D envelope widths |
velocity_x, velocity_y | double | 0.0 | unbounded | 1D/2D velocities |
envelope_angle | double | 0.0 | unbounded | Envelope rotation (radians) |
rotation | double | 0.0 | unbounded | Complex output rotation |
time_offset | double | 0.0 | unbounded | Temporal shift |
Plus timing parameters.
Examples
Section titled “Examples”-- 1D Gabor waveletooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_gabor", amplitude = 0.4, sigma_x = 12.0, wavenumber = 0.5})
-- Moving Gabor pulseooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_gabor", amplitude = 0.2, omega = 0.5, rotation = 0.3, coord_center_x = 64, sigma_x = 20, velocity_x = 1.0})
-- 2D oriented Gabor (receptive field model)ooc.sim_add_stimulus_operator(ctx, field, { type = "stimulus_gabor", amplitude = 0.5, coord_mode = "separable", coord_center_x = 128, coord_center_y = 128, sigma_x = 15, sigma_y = 30, wavenumber = 0.3, envelope_angle = math.pi / 4})📐 Digamma Square Wave
Section titled “📐 Digamma Square Wave”sim_add_digamma_square_operator(ctx, field, opts)
Generate a digamma-based square wave driver. Uses the digamma function to produce bandlimited waveforms with reduced aliasing and controllable harmonics.
Method Signature
Section titled “Method Signature”sim_add_digamma_square_operator(ctx, field, [options]) -> operatorReturns: Operator handle (userdata)
Mathematical Formulation
Section titled “Mathematical Formulation”The digamma square wave approximates:
where is the digamma function and is the harmonics parameter controlling bandwidth.
Shape variants:
default: Standard square wave approximationsawtooth: Asymmetric rising/fallingtriangle: Linear interpolation between extrema
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
amplitude | double | unbounded | Peak amplitude (required) | |
wavenumber | double | unbounded | Spatial wavenumber (required) | |
omega | double | unbounded | Angular frequency (required) | |
phase | double | 0.0 | unbounded | Phase offset |
time_offset | double | 0.0 | unbounded | Temporal shift |
harmonics | double | 4.0 | [0.25, 12] | Harmonic content control |
shape | enum | "default" | see below | Waveform shape |
backend | enum | "12_tail" | see below | Digamma computation method |
tolerance | double | 1e-12 | ≥0 | Tolerance for adaptive backend |
rotation | double | 0.0 | unbounded | Complex phase rotation |
Shape options: default, sawtooth, triangle
Backend options: 5_tail, 7_tail, 12_tail, adaptive, mortici
Plus timing parameters.
Examples
Section titled “Examples”-- Basic digamma square waveooc.sim_add_digamma_square_operator(ctx, field, { amplitude = 0.3, wavenumber = 1.0, omega = 0.6, harmonics = 6.0})
-- Sawtooth variantooc.sim_add_digamma_square_operator(ctx, field, { amplitude = 0.5, wavenumber = 0.8, omega = 1.0, shape = "sawtooth", harmonics = 8.0})
-- High-precision adaptive backendooc.sim_add_digamma_square_operator(ctx, field, { amplitude = 0.4, wavenumber = 1.0, omega = 0.5, backend = "adaptive", tolerance = 1e-14})🌀 Digamma Square (Warp)
Section titled “🌀 Digamma Square (Warp)”sim_add_digamma_square_warp_operator(ctx, field, warp, opts)
Generate a digamma square wave modulated by an external warp field. Enables complex pattern generation through field-driven modulation.
Method Signature
Section titled “Method Signature”sim_add_digamma_square_warp_operator(ctx, field, warp, [options]) -> operatorReturns: Operator handle (userdata)
Mathematical Formulation
Section titled “Mathematical Formulation”The warp field modulates the base digamma square wave:
where:
- is the warp field value
- is
warp_mix - is
warp_bias - is the mixing function determined by
warp_mode
Warp modes:
- sum:
- multiply:
- crossfade:
Parameters
Section titled “Parameters”| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
amplitude | double | unbounded | Peak amplitude (required) | |
wavenumber | double | unbounded | Spatial wavenumber (required) | |
omega | double | unbounded | Angular frequency (required) | |
phase | double | 0.0 | unbounded | Phase offset |
time_offset | double | 0.0 | unbounded | Temporal shift |
harmonics | double | 4.0 | [0.25, 12] | Harmonic content |
warp_mix | double | 1.0 | unbounded | Warp mixing factor |
warp_bias | double | 0.0 | unbounded | Warp bias |
warp_mode | enum | "sum" | see below | Mixing strategy |
shape | enum | "default" | see below | Waveform shape |
backend | enum | "12_tail" | see below | Digamma backend |
tolerance | double | 1e-12 | ≥0 | Adaptive tolerance |
rotation | double | 0.0 | unbounded | Complex rotation |
Warp mode options: sum, multiply, crossfade
Shape options: default, sawtooth, triangle
Backend options: 5_tail, 7_tail, 12_tail, adaptive, mortici
Plus timing parameters.
Examples
Section titled “Examples”-- Crossfade between digamma square and warp fieldooc.sim_add_digamma_square_warp_operator(ctx, field, warp, { amplitude = 0.3, wavenumber = 1.0, omega = 0.6, warp_mode = "crossfade", warp_mix = 0.5, harmonics = 8.0})
-- Additive warp modulationooc.sim_add_digamma_square_warp_operator(ctx, field, warp, { amplitude = 0.4, wavenumber = 0.8, omega = 1.0, warp_mode = "sum", warp_mix = 0.3, warp_bias = 0.1})
-- Multiplicative warp (AM-like)ooc.sim_add_digamma_square_warp_operator(ctx, field, warp, { amplitude = 0.5, wavenumber = 1.0, omega = 0.5, warp_mode = "multiply", warp_mix = 2.0})