Fluid Engine banner

Fluid Engine

1 devlog
6h 26m 45s

A fluid engine written entirely from scratch, in JavaScript.
This was a experiment/research project to try see if global fluid behavior generally described by complex differential equations like the Navier-Stokes' can emerge from local rules of c…

A fluid engine written entirely from scratch, in JavaScript.
This was a experiment/research project to try see if global fluid behavior generally described by complex differential equations like the Navier-Stokes’ can emerge from local rules of collisions.
The rules of collisions was also written by scratch, and should be a project in itself.

In the simulations, the faster moving particles are colored red, and the slower moving ones are colored blue. Just by analyzing these, one can draw out the effects of pressure, temperature, velocity fields, energy distributions and EVEN FLUID VORTICES. It is a very important aspect of this project, that you note none of these properties were programmed, and no physics formulas were used to calculate them; all these properties have directly emerged from local vector math for particle collisions.

So did the experiment work? Go see for yourself!

Demo Repository

Loading README...

void

Shipped this project!

I’m a hardcore physics nerd and yeah I wanted to build this (a fluid simulation engine emerging from statistical Newtonian laws for collisions) for quite a while now, to better understand the emergence of statistical mechanics.
It was more of a research experiment and I’m glad this was a success.

The hard part here was the collisions, which took a real long while to figure out. And one more thing that would have been a mess was state-management and memory, however I could avoid that because I had well defined classes, methods and functions from the start itself.

Besides that, creating and testing experiments was a fun thing in itself, and hope you’ll enjoy it too!

Best,
void

void

Ahhhh forgot to devlog and made the whole thing itself.
Either way, I got a few videos for you to enjoy from my tests, or try them out yourself.

Changelog

Sooo what i did was create and fix the collision engine and optimised it, and then I tried out a few experiments, and then i just got lost in playing with it.
The collision engine took some math on paper behind the scenes, and some wikipedia reading, but yeah I figured it out.

I created a few more experiments, tried high density experiments, and made the GUI interfacc and added logic to customize the code.

I’ve used OOP mixed with functional programming heavily in this project, cause im insane.

But yeah, ranting aside, feel free to write your own particle generators and explore new physics!
Do reach out to me if you made something cool with this.

Best,
Void

Attachment
Attachment
Attachment
Attachment
0