Coding Challenge #132: Fluid Simulation

preview_player
Показать описание


References:

Videos:

Related Coding Challenges:

Timestamps:
0:00 Introduction
0:59 Topic suggestion from deardanielxd
3:30 Mike Ash's "Fluid For Dummies" thesis
6:42 Incompressible fluid
8:45 Velocity field
9:12 Density of dye
11:14 Port the code to Processing
15:47 addDensity() function
19:34 Diffuse
23:35 Project
25:52 Advect
30:17 Set bounds
33:05 Mirror velocity in edge layers
36:19 Time set function
38:58 Render the density
44:10 Add fade
46:40 Add perlin noise
48:00 Add Pvector
50:35 Recap and next steps
52:22 Adjustments to code

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

#fluidsimulation #turbulentfluidflow #processing
Рекомендации по теме
Комментарии
Автор

I have a C++ exam in 30min. I should probably watch this later haha.

coolbrotherf
Автор

I love the scene at 43:38 when the code finally works. It's obvious how run down Daniel is after trying for so long and the joy / relieve that it all comes together is just tangible. As a coder myself I can fully get that, his mini celebration is hilarious to watch, brilliant as usual

DerSpielerMabuse
Автор

old video, but I thought I might comment lol. Its crazy to think about how far AI and GPT-4o has brought us. I am using GPT to follow along with this in python. The ability to say 'create a diffusion method, based on the pre-existing conditions' and it output it, perfectly, is absolutely mind blowing. I am a CS undergrad, who plans on going into Quantum Engineering, things like this make my goals seem a lot more achievable LOL.

tlace
Автор

No ... way! This is exactly what I was trying for the past 5 years!

kim
Автор

This guy always cracks me up. His enthusiasm is great.

bitterbob
Автор

This is the best channel ever. I never thought it would be so much fun watching someone else write code in real time, but you make it fun.

FractalWoman
Автор

#TeamTurbulance !
And it was very useful! I had no idea how to make a fluid simulator, but after this video, I still have no idea how to make it! But I at least know how it's supposed to work!

glitchedjson
Автор

It would be cool to see you get into those "tricks" to get better performance, a series of videos on optimizing and using things parallelization or whatever else would be really useful.

oBCHANo
Автор

Super! Another wonderful train ride through some intricate mathematical territory!

BTW, this brings back some memories, as my dad was one of the pioneers of doing fluid dynamics on computers, for the purpose of numerical weather prediction.
He dealt with the Navier-Stokes equation constantly! As well as mass & energy conservation, and others. And with sculpting code to run at maximum possible efficiency, with a multi-layer, lon-lat grid on limited computing capability. Especially on the computers of the early 1950's!

Of course, for the atmosphere, you've got a compressible fluid, and you also have to model evaporation & condensation of water, varying sunlight, radiated heat from ground & water, city "heat islands, " the effects of ice & snow cover, clouds with their own radiation and heat dynamics, etc.
Not to mention that your whole spherical grid is rotating, so there's the Coriolis effect to deal with . . .

But the essential setup is the same as what you have here, just with a spherical surface instead of a square, flat box; and a third dimension, which was typically only a handful of altitudes.

Fred

ffggddss
Автор

Learned the basics, built a few apps, then got bored of programming. Just going through your videos again and man it sparks that passion again. Thank you.

Just thinking about adding something a little extra into my portfolio website. I'm thinking about something recursive. Maybe mandelbrot? That would be pretty cool me thinks.

dominick
Автор

Where are parts 2 and 3? I can't find them! 😭

Grynjolf
Автор

I really appreciate your video style! There are a lot of dev content creators out there that I can't really bear to watch. You keep things succinct and interesting, and without fumbling around too much even when you're not entirely sure what's going on as you port this code. Great personality, great editing! Lucky me decided that I wanted to learn fluid sim today and found you in the process. Easy follow. Thank you for what you do. :)



#TeamLaminar btw

Gamekid
Автор

I have been going through Navier-Stroke's Equations for an entire day to write a simulation on my own. And I ended up here. I am so glad I ended up here!

prafulsrivastava
Автор

This video helped give me some insight into very opaque code provided by my professor last year. I have a slight correction which in my implementation improved the resulting simulation.


When changing from 3d to 2d the amount of neighbours each cell has changes from 6 to 4. In lin_solve() a weighted average is taken dependent on the amount of neighbours where c represents the total weight. So calls to lin_solve() should be changed such that c corresponds with the amount of neighbours. I.e. in project() it becomes "4" and in diffuse() "1 + 4 * a". Without the adjustment lin_solve() reduces, whatever you put into it, by 33% after each iteration.

vldelord
Автор

Having access to vectors, objects, and multidimensional arrays makes this all so much more pleasant to work with.

MarushiaDark
Автор

Love how you explain the coding! Even though I am a beginner and am only able to code in C++, you are doing a fantastic job. Keep it on!:)

laurenz
Автор

This was really nice to watch while I tried to copy what you did. My simulation is working perfectly, thanks

TheDetonadoBR
Автор

For anyone wondering you don't need to constrain the IX function, you simply need to go into the advect function and make it so that you use N-2 to get floatN. That fixed it for me at least and is what someone else suggested on Mike Ash's blog.

FrozenGale
Автор

This is a gteat example of a man who really love what he is doing.

juvusart
Автор

Oh neat I am working on my own hydro code. These particle-in-cell methods of simulating fluids are almost mystically powerful, you can go from simulating plasma physics to predicting traffic flow just by changing a few ( complicated ) terms. Thanks for the video, I hope this gets more people excited about questioning the world around them. There is a whole world moving every time you stir your coffee in the morning.

ThatChristopher