Open deardanielxd opened 8 years ago
SmarterEveryDay's recent video on Laminar Flow got me thinking again about this. I'd love to do a simulation like this one:
https://physics.weber.edu/schroeder/fluids/
Here's another reference.
http://physics.weber.edu/schroeder/javacourse/LatticeBoltzmann.pdf
This is a great reference from @anuraghazra http://neuroid.co.uk/lab/fluid/
Yay! finally, I'm so excited about this, hoping that people are also excited about fluid dynamics. :heart:
I have managed to break it. "The simulation has become unstable due to excessive fluid speeds." This will be a fun coding challenge.
На вт, 29.01.2019 г. в 16:59 ч. Anurag Hazra notifications@github.com написа:
Yay! finally, I'm so excited about this, hoping that people are also excited about fluid dynamics. ❤️
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CodingTrain/Rainbow-Topics/issues/178#issuecomment-458571104, or mute the thread https://github.com/notifications/unsubscribe-auth/AfXI-9rpu6vBgvSJ4rDvrH8XFfalnlMLks5vIGG4gaJpZM4JsNR9 .
Ok, wow, just read both of the papers above. My head hurts. Amazing stuff. Some more useful references.
https://www.memo.tv/msafluid/ http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf https://mikeash.com/pyblog/fluid-simulation-for-dummies.html
So I spent an hour or so porting the paper linked above but didn't have any luck. Recorded:
https://youtu.be/tNLtVVkuiYo code: https://github.com/shiffman/CFD
(With a successful implementation from @StanLepunK) https://github.com/shiffman/CFD/issues/1
I think I probably have to postpone doing this as a coding challenge until next week as I'm not sure I have time to go through all the papers and try other methods before tomorrow! Any advice or thoughts welcome!
And success . . . https://twitter.com/shiffman/status/1091175798000754689
thx for the citation :)
Wow I did not notice that 3Blue1Brown has a video on Turbulence.
I made a 2D fluids solver in Processing around 9 years ago called Lily Pad. https://github.com/weymouth/lily-pad. Actually the simulations in the 3Blue1Brown turbulence video at minute 9:20 were done using this code.
Stam's approach is really fun (and you should do it in the live code) but there are a couple issues. First is that it is very diffusive - this makes it hard to simulate things like turbulence which only happen when the diffusion is small. Second, there are no bodies, which makes it hard to use for engineering applications and teaching!
LilyPad uses a similar approach for the fluid, but it is a bit more careful about limiting diffusion. It also includes the method I developed for including solid bodies. I wrote a paper a few years ago with an overview and some examples. https://arxiv.org/abs/1510.06886. I also use it for teaching.
Enjoy!
Oh, maybe I should mention these fluid p5 apps as well. https://weymouth.github.io/fluid-dynamics/
These are much faster and easier to code since they solve the potential flow equations. The flows are very pretty as well.
there's a couple of things that trouble me about the 'fluid-simulation-for-dummies' code (and the Jos Stam paper on which it's based). and that's the fact both the diffuse()
and project()
functions perform 2d/3d array convolutions whose result depends on the order of iteration of the array indices.
for example, the original diffuse()
function looks like this:
for ( i=1 ; i<=N ; i++ ) {
for ( j=1 ; j<=N ; j++ ) {
x[IX(i,j)] = (x0[IX(i,j)] + a*(x[IX(i-1,j)]+x[IX(i+1,j)]+
x[IX(i,j-1)]+x[IX(i,j+1)]))/(1+4*a);
}
}
i hope it's obvious that this is overwriting x[]
elements before they're read. which means that if you iterated i
& j
backwards (eg for (j = N; j >= 1; --j)
), you'd get different results. which means that the whole simulation isn't horizontally or vertically symmetrical.
another thing that bothers me is that whenever diffuse()
is called, the x
parameter is always equal to the XXX_prev
source array, which effectively means that the source array is getting added twice (once in add_source()
and again here in buffer()
).
neither of these effects are mentioned in the original paper, so i wonder if they're intentional?
Yes, I remember being very confused trying to trace out the actual operations being applied. But remember that the goal in that paper was to make the update as fast and stable as possible so it could be used robustly for graphics. And in that, it is a great success.
indeed. i understand that it's faster to implement without double-buffering (although adding a single additional line of buffer wouldn't complicate this significantly). usually, though, when such an optimization is made, the authors usually call it out.
I tried to implement Daniel Shiffman's fluid simulation code in openframeworks using GLSL! It's in working progress and It's only using diffusion and advection without the boundary functions at the moment. It has an error where the fluid flow toward the top left corner. Here are links which leads to an instargram posting showing the recorded video, and a github repository containing the files in the aforesaid project.
video link: https://www.instagram.com/p/B9VKMB4H1pm/?utm_source=ig_web_copy_link repository link: https://github.com/hlp-pls/coding_train_cpu_fluid_simulation
I was watching this video which was explaining Jos Stam's explanation, it really got into the details of its implementation, not sure if it helps! https://www.youtube.com/watch?v=qsYE1wMEMPA
Wow, I just came across this issue and the entire thread is incredibly motivating! Fluid dynamics is such a fascinating and complex area, and the amount of collaboration and enthusiasm here is truly inspiring. Seeing people work through challenges, share resources, and build on each other's ideas is a perfect example of how powerful and valuable the developer community can be. This thread alone has motivated me to dive deeper into simulations. Huge thanks to everyone involved for contributing to such a rich learning experience! 🚀🔥
I am wondering could you do a tutorial of 2d (or even 3d?) fluid simulation tutorial? It would be a very challenging topic. Since this project could be very complicated, I think doing a simple one is already ok. For example, use processing to make a constant flow of fluid and place a circular obstacle inside it. If you have time, you can also treat the fluid as a field of vectors and place particles to observe their movements. Hope you can accept this challenge XD. BTW, you performed very well during the previous challenges. Keep on the good work.
You may have a look at this pdf for reference: (found from the internet) http://www.cims.nyu.edu/~billbao/report930.pdf