💦 Water sprinkler
🧠 Original idea and code by Rhett Allain
🐍 A VPython demo is available as well, see water_sprinkler.py
👉 The outflow velocity is given by:
👉 and .
Live demo
Section titled “Live demo”Model and implementation
Section titled “Model and implementation”The sprinkler consists of a rotating arm with two outlets at opposite ends. Water droplets are released periodically from these outlets and then move freely with constant velocity.
The sprinkler rotates about the -axis with angular velocity
If denotes the current rotation angle, the position of an outlet relative to the center is
where is the length of the sprinkler arm.
The velocity of an outlet due to the rotation of the sprinkler is the tangential velocity
When a droplet leaves the sprinkler, it also receives a radial velocity component. Its magnitude is controlled by the water velocity parameter:
where is the water velocity and
The initial velocity of a released droplet is therefore
and the droplet subsequently moves with constant velocity:
No forces are applied to the droplets after they leave the sprinkler. In particular, gravity is not included in this model. The simulation therefore represents the kinematics of the rotating sprinkler and the emitted water rather than a complete model of a physical water sprinkler.
Droplet management
Section titled “Droplet management”The simulation uses a fixed pool of droplets rather than continuously creating new objects.
Each WaterBeam owns a pool of reusable droplets. When a droplet leaves the visible region,
it becomes inactive and can be reused for a subsequent emission.
This avoids continuously allocating and discarding objects while the simulation is running. The views remain bound to the droplets throughout the simulation; an inactive droplet is simply hidden.
Time stepping
Section titled “Time stepping”The physical timestep used to update the sprinkler and the droplets is independent
of the rendering/update interval specified by Simulation.runsEvery().
At every simulation step, the droplets are first advanced using their constant velocities, new droplets are released according to the emission frequency, and the sprinkler angle is advanced according to
The fixed physical timestep allows the same model to evolve consistently on different devices,
while Simulation.runsEvery() controls how frequently the simulation is visually updated.