Preview and work in progress: A Fluid Simulation for FastLED

Hi everyone!

Since MCUs become more and more powerful I attempted to write a bunch of fluid simulations based on a numeric solver.

I'm fairly happy with my smoke.

This is my attempt to simulate fire.

It is all based on this model.

If you want to learn more about it, this is a good starting point.

Here the Navier Stokes solver is running on a 48x32 WS2812 matrix on an ESP32 with >30 fps.

Here on 22x22 LEDs

The code can be found here. There you'll find a lot of procedural realtime animations and advection effects.

Here a few videos showing the code from the Github repo in action on 48x32 LEDs:

Also my previous FlowFields work is now already available in FastLED. There the advection is not simulated but simply defined by noise fields.

You are welcome to use all of it and make your LED installations more beautiful. If you want to collaborate, just reach out! I welcome feedback, critique, inspiration and questions.
If you happen to have done similar work in the past yourself I'd love to see it! Just get in contact here or in the FastLED subreddit.

I hope you enjoy the creations and possibly even find them useful for your own projects.

Have a beautiful day, everyone!

P.S. If some of the videos remind you of old Winamp visualisations like Geiss and Milkdrop this is no coincidence. We found a lot of inspiration there and in the future wi'll make more of it available in FastLED.

Btw. all these simulation approaches exhibit interesting emergent behaviour.

Here I coincidentally stumbeld upon an emergent ring of fire. This was not intended or explicitly programmed into it, it just emerged based on the heat convection and fluid velocity.

It is really fun to play with numeric grid solvers!

Here is a longer write up about this very specific model.

Thanks for sharing!

Great work!

Thank you guys!

Over the weekend I build some basic obstacle handling and also improved the colormapping.

It is not perfect, but it is fast.

Yesterday I implemented a basic flow map logic which can be used to direct or even force the advection in any way you want.

Later this might come in handy for the artistic design of specific flows.

This is the latest version of a 128 × 128 LED simulation run. I improved the color contrast and the preservation of detail over time, and I also tweaked the color-emitter mechanics—the way the “dye” is injected.

In addition, I added an extra advection layer that introduces a small amount of randomness into the pure simulation layer. This creates a more unpredictable and, therefore, more interesting and visually striking look.

The additional computational cost is close to zero relative to the effort required to solve the Navier–Stokes equations for every frame, so I was very happy to get this visual improvement essentially for free. The frame rate is only 0.8% lower than that of the pure simulation without the extra swirl layer.