#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!
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!
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.
@@aravindkarthik5120 Hey Aravind, it took me a couple days to remember some of the first resources I used. Ferziger's Computational Methods for Fluid Dynamics does a great job of breaking down some of the numerical methods you can use, and I think some of the older editions had the fortran code (which is what I played with to figure out what was going on). I believe some of the classical papers listed in that book are also good resources for learning. I'm sure there are other modern equivalents of that book, but I found Ferziger referenced in many papers of interest to me and I can see why. Writing codes is fun, but if you want to do any actual DNS of fluid simulation it becomes very expensive to do so.. It quickly goes from understanding the discretization of the DE to figuring out how to manage memory when you're implementing higher-order schemes.. which is something that I found isn't talked a lot about... This is something I wish someone told me from the start. You can solve a 100x100 grid pretty simply, and it will make pretty pictures, but trying to resolve turbulence requires a lot of computational power on top of the software development component of figuring out how to implement it. So don't be discouraged if it takes some time to figure out, and trying to build something yourself from nothing will teach you to appreciate a lot of the commercial tools and all the struggles they must have put up with to deliver what they can. Good luck.
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
@@TheCodingTrain believe me when i tell you lots of people probably did, your videos are awesome to watch, even more so when coding with you or when you are interested in the topic. at least i watched it all. Thank you for the awesome series!
I quite literally started processing like last week (never been very good with Java) to use as part of a design project. Came across this channel, absolutely loving it even though I have almost 0 idea what’s going on!
This is crazy, I am two days into this tutorial and searching for a typing error which gave me a different result than in 43:35. Finally I have found the error and watching you after 43:35 means so much more to me. (P.S: me the dumbass missed one i in the 99 th line of the source code in Functions so that it was float i0i = int(0) instead of int(i0).) If it is frustrating to get error, it is so much more to get none but get the wrong result. Anyways, you are one of my heroes.
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.
yea it would be, and it would be cool to see it with processing java rather than processing or p5 since ik js doesn't have threading and processing idk if it has threads like the original java
Nvidia has a very nice demo of this using shaders to compute the different steps using a 3d texture. It even goes the extra mile and accounts for moving obstacles within the fluid.
no? this isnt the type of thing video compression struggles with, its actually the opposite. you should know this, your literally watching a video on coding.
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
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
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.
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.
As long as you COULD implement it without the help of AI if you ever needed to, they yeah, it is an amazing tool to make small snippets of reusable modular code
#TeamTurbulence Some ideas for a potential part 2 of the video: (1) how to change the bound function to fit a more complex shape (vector) with obstacles (islands?); (2) how two fluid sources can mix and accumulate when they meet; (3) how to add "current" to the whole simulation.
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.
this is Dan's example coded to p5JS , but still not working as the original in processing , if you find bugs , please let me know: gnkarn.github.io/p5js-course/p5jsProy_fluid_sim , code here : github.com/gnkarn/p5js-course/tree/gh-pages/p5jsProy_fluid_sim
@The Coding Train I think your videos are awesome and it would be really cool to see a simulation of Theo Jansen's Strandbeest... Theyre are a life like creation and would fit great in your set of videos as it is supposed to be a natural smooth movement (ie nature of code kinda thing). Idk just a suggestion but I think it'd be a lot of fun 👍😁 #teamTurbulence
Very nice video! Do you have any plans on continuing this video series or do more on fluid simulations? This topic is very interesting and there aren’t a lot of videos explaining it so it would be really awesome.
Hi Daniel and the Coding Train, Fantastic job and cool video! I thought I’d give myself a treat on Saturday afternoon and do this nice coding challenge. However, I got stuck trying to understand where exactly the Gauss-Seidel iteration is inside the lin_solve method at 20:35. I have a strong impression that it is not there, but a close relative is doing the job. I think the sources mix up the Gauss-Seidel method and the Jacobi method, leading to some confusion here. If one applies the Jacobi method, everything turns out to be straightforward: The diffusion step involves numerical differentiation, which leads to this matrix en.wikipedia.org/wiki/Discrete_Poisson_equation applying the Jacobi method en.wikipedia.org/wiki/Jacobi_method directly leads to the lin_solve routine. Mystery solved. Hope that helps :)
Is it in program any further video on the topic? I was hoping to have a second part explaining a bit the formulas used and another part to simplify them out. It would be so great... :-)
I'm not sure how much I'll use the fluid simulation part, but the stuff about diffusion really clarified my thinking about an old hobby project i had, which I may well try to resurrect...
His code is based on code written in C,and in C passing arrays of more than 1 dimension into functions is a pain in the ass because of pointers etc, so the creator just used that function to "simplify" it
Got to give it to you this was a great way of procrastinating from doing coursework, I'm supposed to be writing test plans and stuff for a program i've written. But design documentation is boring this was way more time. Don't think i've ever left a comment or made it live but long time sub as i find your videos a good way to learn some stuff when i'm supposed to be doing other things.
That's so GREAT ..... I don't speak english, yeat, but i can understand you.... Crazy no?!?! hahahahaaaaaa..... I'll try make something like this, but on or in C# ..... So, thank's so much!!!! OBS: I'm a brazilian guy that love all of it.
#TeamTurbulence After taking a peek into that lin_solve( ) function in the Mike Ash's page, I recognized the use of a relaxation type of solver for the problem, which I met by solving electrostatic problems. Indeed, after visiting the wikipedia page en.wikipedia.org/wiki/Relaxation_(iterative_method) my hypothesis was confirmed, and there references to the Gauss-Seidel method also appear (en.wikipedia.org/wiki/Gauss%E2%80%93Seidel_method).
It’s so satisfying for me to actually see and understand the mathematical topics that were forced to study as part of my engineering degree, reminds me that they don’t make us take maths modules because they enjoy watching us suffer🙃
FYI: `struct FluidCube` is C not C++. The typedef gives it away, which is not required in C++. Also the calloc etc used below that for memory initialization is C.
मसीह यीशु पापियों का उद्धार करने के लिये जगत में आया . . . (1 तीमुथियुस 1:15) यदि तू अपने मुँह से यीशु को प्रभु जानकर अंगीकार करे और अपने मन से विश्वास करे, कि परमेश्वर ने उसे मरे हुओं में से जिलाया, तो तू निश्चय उद्धार पाएगा। (रोमियों 10:9) “क्योंकि परमेश्वर ने जगत से ऐसा प्रेम रखा कि उसने अपना एकलौता पुत्र दे दिया, ताकि जो कोई उस पर विश्वास करे, वह नाश न हो, परन्तु अनन्त जीवन पाए। (यूहन्ना 3:16)
i dont understand the renderD() funtion? how does that work also I'm getting out of bound exception and program crashing i was trying to write in c++ with sfml. Do u know how to add constraint in c++ like in java
This is great. I've been trying to write my own fluid simulators in P3 but they aren't exactly intuitive or easy to get started with. I would love to see a video on the Lily Pad project.
I found this video while trying to find out how simulate a river. Whether or not this is what i'm looking for, I made it to the end, and learned a lot.
Love the idea of this series! Sadly this video was a bit lacking, not much 'why', mostly just 'do', which i do not find very interesting or educational. Looking forward to the next episode! :)
Thank you for this feedback. I think you hit on something here and I agree. When I started out I had hoped to have this more an explanation of the algorithm itself and how it worked but it ended up being more about porting C++ to Java. Hopefully I can return to this topic more in the future and get at the "why" and "how".
@@TheCodingTrain Looking forward to it! It does seem like an interesting topic and something i want to take a closer look at myself actually, maybe even recreate it! Thank you for revealing it to me, your future videos on this will definitely help in further understanding and exploring the concept. :)