Kenny Peng's Raspberry Pi Fluid Simulation Puts an Ocean in the Palm of Your Hand
Embedded developer Kenny Peng has transformed a Raspberry Pi single-board computer into an interactive toy featuring a live fluid simulator. This playful creation utilizes an SSD1306 OLED module and a TDK InvenSense MPU6050 accelerometer, all powered by a Raspberry Pi 4. The fluid simulation mimics an ocean of water and responds to movement, creating a virtual sloshing effect displayed on a compact OLED panel.
The simulation employs a “smoothed-particle hydrodynamics” (SPH) technique, enabling the virtual fluid dynamics to be processed on the Raspberry Pi’s CPU without the need for specialized graphics processing or hardware acceleration. The SPH approach utilizes a mesh-free simulation method to realistically simulate complex boundary dynamics while maintaining real-time performance on the Raspberry Pi 4’s CPU. The workload is optimized by distributing computations across the four CPU cores using OpenMP.
Peng’s creation packs a surprising level of physics simulation within its concise codebase of around 750 lines of C. The simulated physics includes features such as artificial viscosity, ordinary advection, and surface tension effects.
The source code for this project has been shared on GitHub under the permissive MIT license, allowing others to explore and build upon Peng’s innovative work in fluid simulation using a Raspberry Pi.
PiShop Grocery list:
OLED Displays:
- Yellow blue double colour 128X64 OLED LCD Display Module For Arduino 0.96″ I2C IIC SPI Serial
- 128×32 2.23inch OLED display HAT for Raspberry Pi
Reaspberry Pis:
Read More: Kenny Peng’s Raspberry Pi Fluid Simulation Puts an Ocean in the Palm of Your Hand