Too bad I found about this video after I did the same thing. It took me over a year to understand the theory and algorithms behind Stam's papers, but you explained it in 15 minutes! Great video anyway!
@@pinkyrng7104 just start one step at a time, try and get the basic system working so that you only need to learn one new concept at a time to eventually get it all working
Same for me. But it's not an easy subject though and contains many different algorithms and approaches. I also skipped the lerp part, because on the GPU you are able interpolate between pixels by default, with the filtering step. Overall very detailed and well made video! It helps a lot of curious people.
@@pinkyrng7104 You're making it sounds complicated more than it is. You just look at the N solver equation and implement an N loop for it. I did it in 1 time watching the video and just rewinding it to where the equations are.
Finally, I’ve been looking all over for information on health physics simulations in general work but literally every single one just tells you to get a library and doesn’t actually go over the math. Thank you for making this video
This video doesnt even come close to what really happens. Btw the book that has complete navier stokes solver as used in industry is by milovan peric. Google cfd and peric.
Wow! Awesome video, I always hated how science videos never went deep into how equations actually worked and how to implement/use them, but you did both! Thank you! Awesome video, subscribed and I hope to receive new notifications from you :)
Careful viewers! I might be wrong, but the equations shown for diffusion in the video are incorrect. If you look at the paper by Jos Stam, the simple, unstable equation for the next density is dn = dc + k(sc-4dc) (where sc means the sum of the densities in surrounding cells), which is not the same as the equation shown in the video, dn = dc + k(sc-vc), where sc is the average of densities in the surrounding cells. I saw that when implementing the method seen in the video, density was lost after diffusion even though it should just spread out.
Slight correction on the diffusion step, the equation according to original paper is x0[IX(i,j)] = x[IX(i,j)] - a*(x[IX(i-1,j)]+x[IX(i+1,j)]+x[IX(i,j-1)]+x[IX(i,j+1)] -4*x[IX(i,j)]), which would be d_n = d_c + k (s_c - 4 * d_c). Without doing 4 * d_c, the amount donated to the 4 surrounding cells would only be subtracted once from the original, resulting in a net increase in density/velocity from nowhere and breaking conservation of mass. Additionally, I believe the equation d_n = d_c + k (s_c - 4 * d_c) explains why its necessary to diffuse density reverse in time, because it blows up under certain scenarios, resulting in negative values. An example is if you have a really high value cell (say 100) surrounded by really small value cells (say 1). Let K=1. On the next iteration, the high value cell will have -396. While having negative velocity possible, having "negative density" is not and will cause the simulation to blow up.
Great job with all the videos. The level is very good and the explanations are great. Most of all the topic/topics are a good niche - they're not some sort of basic tutorial, but they're not at an advanced academic level either discussing the details of the respective topics they cover. They're very much the type of stuff I'd love to see if I just want to get an actual technical introduction to something I've never thought about before.
Great video! The part about subtracting the divergence was especially fascinating. Having never implemented any actual fluid dynamics, I sort of assumed you'd rely on the density to pull and push to even it out, close your eyes, and hope you don't have any rounding errors.
Really nice video, despite having read several papers about fluidsim recently, I still feel like I walked away with a clearer understanding of the fundamental implementation details.
7:35 I found when I restricted myself to the four square of sharing sides in the diffusion I would get horizontal and vertical line artifacts, especially at k = 1 from the original equation. Including the four corners at a 1/sqrt(2) ratio prevented those artifacts.
I just got this video in my recommended, and hot damn it's well done! You could probably make something like density functional theory or quantum hydrodynamics understandable to a kindergartner.
Please do a whole lot of videos on fluid (and other) simulations. It seems many places love to show them in math, but not in code or explained in a way that can be done in code. (without excessive math skills) I'd love to see one on the 2D FFT ocean simulation. I've been wanting to learn how to do this one for ages on the GPU but it seems like there are very scarce public resources for it and many leave out key parts or assume you're incredible with math. Thanks! you've got a new subscriber :)
The reason it is shown in a math heavy fashion is because it is as math dependent as it gets. Even if you're using an off the shelf CFD solver, you must know the math behind to judge if the simulation you have just run makes physical sense, since the computer will always spit an answer no matter if it physically has any meaning
@@JokerTheDank If they could express them in a code type of way, rather than a math type of way, it would probably be far easier to check that you're getting correct results since it's more about logical steps than crazy symbols and memorized random rules/formulas.
@@nk361 you haven't understood. Math is the reason you get certain results. You have a set PDEs, in a Continuum which are the real description of the fluid. You then have to feed them to a computer, but a computer cannot deal with continuums as they are by definition an infinite data set. So what do you do? You discretise the continuum PDEs in many many tiny ODEs. But what has happened then? You mathematically approximated a mathematically correct description with a mathematically incorrect description introducing a mathematical discretization error. So now exactly tell me where would the code tell you anything about the errors you're making in this approximation. Everything is mathematical
@@JokerTheDank I wrote a whole comment and then clicked one thing and youtube decided not to hold on to what I wrote. :/ Pretty much the gist is that summation for example turns into a for loop with either a function passed in or a hard coded function per use case. You have to know both how the math itself actually works and how the code actually works for you to write that in code and get the results you want. That's where the difficulty is, most programmers don't know enough math to translate it and most math savvy folks don't know enough programming to translate it. If math was explained in pieces of code in languages that don't rely on prewritten math libraries (like matlab, octave, etc) then I think there would be so many more amazing software projects made by single developers or very small teams. Saying people need to learn math on that level to use it is like saying you should learn assembly on an advanced level in order to write c++. You don't because it's abstracted and made far easier for the public to get the results they need.
So that's where the advance mathematics and CFD equations come to play in real life! Also I thought I'd never be seeing those iterative equation solving methods. You've no idea what this video is to an enthusiastic mechanical engineer! Thanks alot!
This kind of stuff if the stuff I want to make more of but don't know how. You just earned a sub :) keep up the good work and make more!! Things like this are hard to learn on your own but things like this make it possible. Thanks.
Thank you for the high quality video! I am really curious what you will cover next. If I can suggest something, I would like to see you taking care of the Lattice Boltzmann method! It is a really interesting method compared to the classical CFD approaches and is extremely accurate but still has a very simple algorithm. Keep up the great work! Subscribed :)
From where do you get the time derivative of the pressure with incompressible fluids? The time derivative of the pressure doesn't appear in Navier-Stokes equations.
You have a very clear narrative style! I like it. However, I am not sure if the relation between the differential operators and the discrete approximations will be understood by anyone who is not already familiar with the topic. Further, I would write an \approx instead of an equality in the cases where the left hand side is written as differential operator and the right hand side is a composition of central difference approximations.
I went back and forth on the last part of the last secion and there seems to be an almost deliberate omission in the expenation: What is that scalar p-value fiels? What does it represent? Why do we take the gradient of it and what does that gradient represent?
So diffusion sets the new density, but than the advection also calculates density. What do I do with these values? Do I average them? Add them together? I would like this to be clarified :)
I am currently writing a paper about fluid simulations. Do you allow me to use a screen from your video at 13:02 to illustrate an explanation of the Helmholtz décomposition?
at 6:12, can you please explain how it is linear? If k < 1, then you will never reach the desired density as you are always adding something less than the difference, and each time you are adding less and less. Also at 9:35, how can each square depend on the new value of every other square. That doesn't seem solvable.
ok after 4 days of suffering and having rewatched the video like 50 times, I managed to implement it with pygame, the problem was that I was generating list of divergences by simply appending calculated values, and turns out that it is generated but the order is wrong, so I had to do it like that : divergence = [0.] * len(self.cells) for x in range(self.size): for y in range(self.size): # get divergence in each cell diff_x = (self.cells[self.index(x + 1, y)].vel.x - self.cells[self.index(x - 1, y)].vel.x) diff_y = (self.cells[self.index(x, y + 1)].vel.y - self.cells[self.index(x, y - 1)].vel.y) divergence[self.index(x, y)] = (diff_y + diff_x) * 0.5 thanks man really helpfull video to understand how to implement it (plus it most likely will be usefull for my game)
Isn't the randomness 'always' related to the irrationality of pi, so that when we place radially symmetric equations onto a square (or any other rational) grid we always end up with a subtle round off error, and thus we see 'randomness'? The corollary is that reality has it's own problems when we get to molecular scales where again we see the rational counting problem (try counting out pi molecules to be distributed evenly over the uniform pi radians, or 4pi steradians;-). It's the axioms, as Gödel said;-)
Very interesting, a few questions though: Is this run on a CPU or GPU? I am currently working on a GPU-based fluid sim, I am just wondering about the performance. Also when a cell's new pressure / velocity is generated do you edit the values of the cells that you literally interpolate from?
That's a great video man! Looks nice and polished. But as a guy who's not that familiar with the mathematical notation I had really hard time to understand what's going on. I think if you will focus on more visualisations (yes I know that's not simple) and less equations you can grow your audience by magnitudes. Anyway, thanks for your hard work!
i know this is a late reply but: v(x,y) is just the velocity vector associated with the cell (x,y). we're using semi lagrangian advection (name drop so you can look it up) to approximate where the next "particle" would be that ends up just in the center of this cell. its by far not perfect since we're using the velocity of the target cell as the velocity vector of the "particle". we bascially infer that given a small enough timestep and a small enough grid the velocity vector of the "particle" is approximately the same as that of the target cell. then once we determined the position of the particle using semi lagragian advection (which is what is also shown in the video i.e. particleCoordinates = targetCellCoordinates - v(x,y)*timeStep), we linearly interpolate the densities of the 4 cells that surround the particles position and then copy paste that density value into our target cell. then later in another routine (if you look up jos stams real time fluid simulation for games (2003)) we advect the velocities with the exact same principles as we did with the densities.
My maths level is not yet at the kind of level to understand the idea of iterative solving, so for the diffusion equation i implemented this instead, it works practically the same to the original diffusion solver, is stable, and isn't a solver, so it requires no iteration: newVelX = currentVelX + (avgX - currentVelX) * (1 - exp(-viscosity)); I don't think this is physically accurate but it works, I guess
"There is no way to directly compute the divergence-free part" [1 second later] so we compute the curl-free part instead and subtract it from our vector field thereby computing the divergence-free part...
@@aprendiendoC Okay, let me ask you this: What would a direct computation of the divergence-free part look like (if it exists)? Probably a formula that looks like "divergence-free part (x) = some expression in x", right? Now write down the expressions for "divergence-free part (x) = vector field (x) minus curl-free part (x)". What'd you got? Oh right, an expression in x that DIRECTLY computes the divergence-free part. Mathematically speaking, an "indirect" computation or, more rigorously, an "implicit" function is a a function f that is the solution to an inverse problem F(f(x))=0. And mathematicians don't usually consider rearranging a simple equation an inverse problem. In this video the rearranged equation "divergence-free part = vector field minus curl-free part" is a DIRECT computation of the approximated divergence-free part of the real solution given implicitly by the real differential equations.
6:51 You mean, the sn - dn == sc - dc? But why? Edit: I guess your method is something which rely on a equation. I'm not gonna get any deeper on this detail. As I know, the easiest way to do this, is something like this: //step 1, new a buffer for the next frame. for (x = 0, x
I like your funny words magic man
man
😂😂😂 your comment cracked me up
Dumb cant
Says any competent programmer could do it..instantly loses me in math...been coding for 30 years..not the imposter I swear
@@forbiddenera relatable
Hey, I found this video via a Reddit post. This is really well-made, thank you!
What sub?
@Caleb Landry Wow you used a bot account to market some scam and reply to it using another bot account to make it seem reputable?? that's disgusting
Gonkee used to be SOOOO much better.
Too bad I found about this video after I did the same thing. It took me over a year to understand the theory and algorithms behind Stam's papers, but you explained it in 15 minutes! Great video anyway!
If it took you a year, I'm sure you won't forget it anytime soon! :)
@@Gonkee I still have no clue how to program that. Have to watch the video 5 more times :D
@@pinkyrng7104 just start one step at a time, try and get the basic system working so that you only need to learn one new concept at a time to eventually get it all working
Same for me. But it's not an easy subject though and contains many different algorithms and approaches. I also skipped the lerp part, because on the GPU you are able interpolate between pixels by default, with the filtering step.
Overall very detailed and well made video! It helps a lot of curious people.
@@pinkyrng7104 You're making it sounds complicated more than it is. You just look at the N solver equation and implement an N loop for it. I did it in 1 time watching the video and just rewinding it to where the equations are.
Finally, I’ve been looking all over for information on health physics simulations in general work but literally every single one just tells you to get a library and doesn’t actually go over the math. Thank you for making this video
This video doesnt even come close to what really happens.
Btw the book that has complete navier stokes solver as used in industry is by milovan peric. Google cfd and peric.
Under a minute in and ive never been this excited to watch a video by someone ive never heard of before
The craziest thing: this seems to be this guy's first video from what I can find
RUclips just recommended this video to me. Hope you get picked up by the algorithm!
i looked for this
Wow! Awesome video, I always hated how science videos never went deep into how equations actually worked and how to implement/use them, but you did both! Thank you! Awesome video, subscribed and I hope to receive new notifications from you :)
Careful viewers! I might be wrong, but the equations shown for diffusion in the video are incorrect. If you look at the paper by Jos Stam, the simple, unstable equation for the next density is dn = dc + k(sc-4dc) (where sc means the sum of the densities in surrounding cells), which is not the same as the equation shown in the video, dn = dc + k(sc-vc), where sc is the average of densities in the surrounding cells. I saw that when implementing the method seen in the video, density was lost after diffusion even though it should just spread out.
Thank you! :D
This is extremely high quality, well made and really drives my interest in modeling and simulations. Thank you
Slight correction on the diffusion step, the equation according to original paper is x0[IX(i,j)] = x[IX(i,j)] - a*(x[IX(i-1,j)]+x[IX(i+1,j)]+x[IX(i,j-1)]+x[IX(i,j+1)] -4*x[IX(i,j)]), which would be d_n = d_c + k (s_c - 4 * d_c).
Without doing 4 * d_c, the amount donated to the 4 surrounding cells would only be subtracted once from the original, resulting in a net increase in density/velocity from nowhere and breaking conservation of mass.
Additionally, I believe the equation d_n = d_c + k (s_c - 4 * d_c) explains why its necessary to diffuse density reverse in time, because it blows up under certain scenarios, resulting in negative values. An example is if you have a really high value cell (say 100) surrounded by really small value cells (say 1). Let K=1. On the next iteration, the high value cell will have -396. While having negative velocity possible, having "negative density" is not and will cause the simulation to blow up.
Where do I find the original paper? The link in the description is not working.
@@ClientSide5025 graphics.cs.cmu.edu/nsp/course/15-464/Fall09/papers/StamFluidforGames.pdf
@@ClientSide5025 just google the paper title: Jos Stam - Real Time Fluid Dynamics for Games (2003)
Great job with all the videos. The level is very good and the explanations are great. Most of all the topic/topics are a good niche - they're not some sort of basic tutorial, but they're not at an advanced academic level either discussing the details of the respective topics they cover. They're very much the type of stuff I'd love to see if I just want to get an actual technical introduction to something I've never thought about before.
Great editing and informative video, you deserve a lot more acknowledgement for the quality you put out!
Great video! The part about subtracting the divergence was especially fascinating.
Having never implemented any actual fluid dynamics, I sort of assumed you'd rely on the density to pull and push to even it out, close your eyes, and hope you don't have any rounding errors.
Probably the best explanation I have seen on the topic. Please can you do another one on the advanced topics
Thank you so much for your efforts in making this amazing video!
Really enjoyed it!
This is an amazing video with great information which I will promptly use in about 20 years.
Really nice video, despite having read several papers about fluidsim recently, I still feel like I walked away with a clearer understanding of the fundamental implementation details.
7:35 I found when I restricted myself to the four square of sharing sides in the diffusion I would get horizontal and vertical line artifacts, especially at k = 1 from the original equation. Including the four corners at a 1/sqrt(2) ratio prevented those artifacts.
Yeah i was wondering about that. I got those lines in some of my pps experiments before I debugged.
I thought you had 800k subs until I looked at the comments. This is next level, well done
Very happy to find a kind of beautiful genuine, well understand concept channel.
Amazing! Amazing source for research!
I just got this video in my recommended, and hot damn it's well done! You could probably make something like density functional theory or quantum hydrodynamics understandable to a kindergartner.
Hella underrated channel
Please do a whole lot of videos on fluid (and other) simulations. It seems many places love to show them in math, but not in code or explained in a way that can be done in code. (without excessive math skills) I'd love to see one on the 2D FFT ocean simulation. I've been wanting to learn how to do this one for ages on the GPU but it seems like there are very scarce public resources for it and many leave out key parts or assume you're incredible with math. Thanks! you've got a new subscriber :)
The reason it is shown in a math heavy fashion is because it is as math dependent as it gets. Even if you're using an off the shelf CFD solver, you must know the math behind to judge if the simulation you have just run makes physical sense, since the computer will always spit an answer no matter if it physically has any meaning
@@JokerTheDank If they could express them in a code type of way, rather than a math type of way, it would probably be far easier to check that you're getting correct results since it's more about logical steps than crazy symbols and memorized random rules/formulas.
@@nk361 you haven't understood. Math is the reason you get certain results.
You have a set PDEs, in a Continuum which are the real description of the fluid.
You then have to feed them to a computer, but a computer cannot deal with continuums as they are by definition an infinite data set. So what do you do? You discretise the continuum PDEs in many many tiny ODEs. But what has happened then? You mathematically approximated a mathematically correct description with a mathematically incorrect description introducing a mathematical discretization error.
So now exactly tell me where would the code tell you anything about the errors you're making in this approximation. Everything is mathematical
@@nk361 and please, do not think of CFD as "crazy symbols and random rules"
@@JokerTheDank I wrote a whole comment and then clicked one thing and youtube decided not to hold on to what I wrote. :/ Pretty much the gist is that summation for example turns into a for loop with either a function passed in or a hard coded function per use case. You have to know both how the math itself actually works and how the code actually works for you to write that in code and get the results you want. That's where the difficulty is, most programmers don't know enough math to translate it and most math savvy folks don't know enough programming to translate it. If math was explained in pieces of code in languages that don't rely on prewritten math libraries (like matlab, octave, etc) then I think there would be so many more amazing software projects made by single developers or very small teams. Saying people need to learn math on that level to use it is like saying you should learn assembly on an advanced level in order to write c++. You don't because it's abstracted and made far easier for the public to get the results they need.
Your explanations for these very complex are amazing
Great video, looking forward to more.
This is awesome. Thank you for making this.
i will need to rewatch this a couple times but it's extremely interesting
You're very underated but ik that you'll grow and I'll gladly say I've been here before 1k
I just came to revisit this video and yes I’d like to say the same. He has 3k subs now.
I*
So that's where the advance mathematics and CFD equations come to play in real life! Also I thought I'd never be seeing those iterative equation solving methods. You've no idea what this video is to an enthusiastic mechanical engineer! Thanks alot!
this is a hidden gem of a channel
7:44 The same procedure as every year, James.
This kind of stuff if the stuff I want to make more of but don't know how. You just earned a sub :) keep up the good work and make more!! Things like this are hard to learn on your own but things like this make it possible. Thanks.
I don't know why youtube has been recommending me some really interesting videos lately but I like it
This was extremely helpful and well made video.
This is really easy. Thanks for the good explanation and the paper.
Phenomenal. Amazing video.
Very cool explanation, thanks!
This work is underrated!
ive always been mystified by navier stokes so super looking forward to watching this series
I'm already a fan!
I don't understand anything!! But one day, I will! 😊😊. Thanks so much
Dude, thank you so much!
Please make more mathematical explanations, can you mathematicaly explain raycast
Awesome video! Thank you!
Great great video...but I am still waiting for the next ones of this series :(
Super informative video, really aided my understanding - thanks very much!!
this was best explained, I saw many but I was not able to understand the simulation, thx for tutorial
Here before your channel blows up!
Yoo, that first clip is my lock screen!
I used this same paper by Stam to implement a fluid simulation in high school. I didn't really understand the math tho xd
very very well made and informative video. thank you!
you're gonna be big in few months
Vicosity and friction of each fluid determined flow and settlement of foreign object
IMO it needs a better explanation for tracing backwards the velocity for advection.
Thank you for the high quality video! I am really curious what you will cover next. If I can suggest something, I would like to see you taking care of the Lattice Boltzmann method! It is a really interesting method compared to the classical CFD approaches and is extremely accurate but still has a very simple algorithm. Keep up the great work! Subscribed :)
"""""extremely accurate"""""
Amazing channel! How do you make these visualizations? Are you using Manim?
Great video, thank you
From where do you get the time derivative of the pressure with incompressible fluids? The time derivative of the pressure doesn't appear in Navier-Stokes equations.
This is... Strong Little Stephen.
Awesome explanation! Thanks
You have a very clear narrative style! I like it. However, I am not sure if the relation between the differential operators and the discrete approximations will be understood by anyone who is not already familiar with the topic. Further, I would write an \approx instead of an equality in the cases where the left hand side is written as differential operator and the right hand side is a composition of central difference approximations.
I went back and forth on the last part of the last secion and there seems to be an almost deliberate omission in the expenation:
What is that scalar p-value fiels? What does it represent? Why do we take the gradient of it and what does that gradient represent?
Where were you during my CFD classes :'(
love it, thx!
Amazing!
Great video! Thanks for sharing
What software did you use for the animations?
So diffusion sets the new density, but than the advection also calculates density.
What do I do with these values? Do I average them? Add them together? I would like this to be clarified :)
My guy I tried really hard but half of that explanation I didn't understand. :D Awesome video though
I am currently writing a paper about fluid simulations. Do you allow me to use a screen from your video at 13:02 to illustrate an explanation of the Helmholtz décomposition?
cool video! which library or plugin did you use for visualizing cool vector field visualization?
13:51 What does the p value mean? Anyone knows? Thanks.
Netflix: Squid Games
RUclips: Fluid Games
Excellent video. How did you make the animations..Which software did you use.?
It's a amazing video to me. Thanks a lot.
at 6:12, can you please explain how it is linear? If k < 1, then you will never reach the desired density as you are always adding something less than the difference, and each time you are adding less and less. Also at 9:35, how can each square depend on the new value of every other square. That doesn't seem solvable.
what are p values in clearing divergence step? Is it divergence of every other cell, or it is next divergence based on the previous one?
7:56 PGS aka THE BEST THING IN PHYSICS EVAR
ok after 4 days of suffering and having rewatched the video like 50 times, I managed to implement it with pygame, the problem was that I was generating list of divergences by simply appending calculated values, and turns out that it is generated but the order is wrong, so I had to do it like that :
divergence = [0.] * len(self.cells)
for x in range(self.size):
for y in range(self.size):
# get divergence in each cell
diff_x = (self.cells[self.index(x + 1, y)].vel.x - self.cells[self.index(x - 1, y)].vel.x)
diff_y = (self.cells[self.index(x, y + 1)].vel.y - self.cells[self.index(x, y - 1)].vel.y)
divergence[self.index(x, y)] = (diff_y + diff_x) * 0.5
thanks man really helpfull video to understand how to implement it (plus it most likely will be usefull for my game)
I’d like to see a second video covering particle simulation optimizations.
Or dynamic sizing methods.
excellent
Subbed! :D
Isn't the randomness 'always' related to the irrationality of pi, so that when we place radially symmetric equations onto a square (or any other rational) grid we always end up with a subtle round off error, and thus we see 'randomness'?
The corollary is that reality has it's own problems when we get to molecular scales where again we see the rational counting problem (try counting out pi molecules to be distributed evenly over the uniform pi radians, or 4pi steradians;-).
It's the axioms, as Gödel said;-)
bro make more vidios i beg you I BEG YOU I LOVE YOUR VIDIOS PLS MORE MORE MOORERREEE
Very interesting, a few questions though:
Is this run on a CPU or GPU? I am currently working on a GPU-based fluid sim, I am just wondering about the performance. Also when a cell's new pressure / velocity is generated do you edit the values of the cells that you literally interpolate from?
Amazing ❤️❤️❤️❤️
Can you tell me which software you are using?
That's a great video man! Looks nice and polished.
But as a guy who's not that familiar with the mathematical notation I had really hard time to understand what's going on. I think if you will focus on more visualisations (yes I know that's not simple) and less equations you can grow your audience by magnitudes.
Anyway, thanks for your hard work!
Great point about the math equations, thanks for the feedback!
My life would've been the exact same either I watched this vid or not, but I still did.
Good video! What do the different colors in that simulation at the beginning represent? I would like to try and recreate something like that.
That was some WebGL fluid simulation found on Google, I'm not sure how the colors were filled in.
10:44 what is the velocity? Is it calculate by density?
i know this is a late reply but:
v(x,y) is just the velocity vector associated with the cell (x,y). we're using semi lagrangian advection (name drop so you can look it up) to approximate where the next "particle" would be that ends up just in the center of this cell. its by far not perfect since we're using the velocity of the target cell as the velocity vector of the "particle". we bascially infer that given a small enough timestep and a small enough grid the velocity vector of the "particle" is approximately the same as that of the target cell. then once we determined the position of the particle using semi lagragian advection (which is what is also shown in the video i.e. particleCoordinates = targetCellCoordinates - v(x,y)*timeStep), we linearly interpolate the densities of the 4 cells that surround the particles position and then copy paste that density value into our target cell.
then later in another routine (if you look up jos stams real time fluid simulation for games (2003)) we advect the velocities with the exact same principles as we did with the densities.
@@glace848 Thank you so much! I am still working on it
@@shihyuehjan3835 same lmao. currently stuck on understanding the whole math behind the equations of the clearing divergence step.
@@glace848 I know, it's kinda chaos lol
@@shihyuehjan3835 just got done with it. i could explain them to you if you like
Why the simulation explodes on divergence step? like as long x and y are >0 everything goes ok, but as soon as it gets to 0 it just explodes
Great video, great animation, sub-1k subs (let's fix that). Something tells me you have prior experience in making videos.
your voice seems like gonkee's one
As a 9th grader I say he's speaking the language of the gods
As an engineering student, we learn about this next term! How's 11th?
My maths level is not yet at the kind of level to understand the idea of iterative solving, so for the diffusion equation i implemented this instead, it works practically the same to the original diffusion solver, is stable, and isn't a solver, so it requires no iteration:
newVelX = currentVelX + (avgX - currentVelX) * (1 - exp(-viscosity));
I don't think this is physically accurate but it works, I guess
Really nice
"There is no way to directly compute the divergence-free part"
[1 second later]
so we compute the curl-free part instead and subtract it from our vector field thereby computing the divergence-free part...
Well, by computing the curl-free part and substracting it, he's computing the divergence-free part indirectly, not directly
@@aprendiendoC Okay, let me ask you this: What would a direct computation of the divergence-free part look like (if it exists)? Probably a formula that looks like "divergence-free part (x) = some expression in x", right? Now write down the expressions for "divergence-free part (x) = vector field (x) minus curl-free part (x)". What'd you got? Oh right, an expression in x that DIRECTLY computes the divergence-free part.
Mathematically speaking, an "indirect" computation or, more rigorously, an "implicit" function is a a function f that is the solution to an inverse problem F(f(x))=0. And mathematicians don't usually consider rearranging a simple equation an inverse problem.
In this video the rearranged equation "divergence-free part = vector field minus curl-free part" is a DIRECT computation of the approximated divergence-free part of the real solution given implicitly by the real differential equations.
6:51 You mean, the sn - dn == sc - dc? But why?
Edit: I guess your method is something which rely on a equation. I'm not gonna get any deeper on this detail.
As I know, the easiest way to do this, is something like this:
//step 1, new a buffer for the next frame.
for (x = 0, x
can you show us how to code up all that math?