Simulation · Published v2
Resonance Chamber
A full 16 × 16 × 16 acoustic volume. Opposite pulses start at different heights and travel through a double-aperture reflector; the outer layer absorbs energy. In Studio, open View options and choose Single layer or Cutaway on X, Y or Z to reveal the interior. Paint Crest or Trough into empty cells to add a pulse, or recompile to restore the initial scene. This is a stylized scalar wave model, not a fluid solver.
No preview
Inside this simulation
Every named building block is public and reusable. These are the exact versions published with this simulation.
Source
// A scalar wave field occupies a complete 16 x 16 x 16 volume.
// The separate acceleration and integration phases use consistent neighbor states.
property Acoustic { displacement: Float<0.0>; velocity: Float<0.0>; damping: Float<0.998>; }
property Pulse { started: Float<0.0>; }
property Solid { density: Float<1.0>; }
model Absorber : Acoustic { damping<0.90>; };
model Barrier : Solid;
model Crest : Acoustic { displacement<0.9>; };
model Medium : Acoustic;
model Trough : Acoustic { displacement<0.9>; }, Pulse;
world { dimensions 3; cell Cube; neighborhood VonNeumann; }
// Six-neighbor coupling propagates along X, Y and Z. Solid cells are excluded,
// producing reflective interfaces; the outer absorbing layer dissipates energy.
behavior AcousticAcceleration for Acoustic {
update {
let curvature = sum n in neighbors[Acoustic] { n.displacement - self.displacement };
set self.velocity = clamp((self.velocity + curvature * 0.12) * self.damping, -0.6, 0.6);
}
}
behavior AcousticIntegration for Acoustic {
update { set self.displacement = clamp(self.displacement + self.velocity, -1.0, 1.0); }
}
// Negative declaration defaults are not supported by the current parser.
// Reverse this source once, before either wave propagation phase runs.
behavior ReversePulse for Acoustic + Pulse {
update when self.started < 0.5 {
set self.displacement = -self.displacement;
set self.started = 1.0;
}
}
phase excitation { run ReversePulse on Trough; }
phase acceleration {
run AcousticAcceleration on Absorber;
run AcousticAcceleration on Crest;
run AcousticAcceleration on Medium;
run AcousticAcceleration on Trough;
}
phase integration {
run AcousticIntegration on Absorber;
run AcousticIntegration on Crest;
run AcousticIntegration on Medium;
run AcousticIntegration on Trough;
}
// Cyan and coral show opposite displacement; quiet material remains translucent.
// Use View options > Single layer, or Cutaway, to reveal the interior wavefronts.
visual PressureLight for Acoustic {
color {
let positive = clamp(self.displacement * 5.0, 0.0, 1.0);
let negative = clamp(-self.displacement * 5.0, 0.0, 1.0);
rgba(0.10 + positive * 0.88, 0.18 + negative * 0.72, 0.35 + negative * 0.60, 0.14 + clamp(abs(self.displacement) * 4.0, 0.0, 0.72))
}
}
visual ReflectorLight for Solid { color { rgba(0.62, 0.54, 0.30, 0.88) } }
visualize Absorber with PressureLight;
visualize Barrier with ReflectorLight;
visualize Crest with PressureLight;
visualize Medium with PressureLight;
visualize Trough with PressureLight;