-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments for post 2010-12-15-why-my-fluids-dont-flow #3
Comments
comment imported from WordPress Hey, I'm the guy that just left a comment on one of your videos. I fully implemented the viscoelastics paper a few weeks ago in flash - http://niallmeister.deviantart.com/art/Viscoelastic-Fluid-Sim-174243339 - albeit with a few small changes. I've since redone it quite a bit, switched to Leapfrog integration and completely changed the spring algorithm to suit (hey, that whole bit isn't even slightly physically accurate anyway, as long as it's stable right?). The particle clumping effect you're describing is pretty well known, referred to as a tensile instability. There have been various efforts to reduce / eliminate the effect, a good paper on it is "SPH Without a Tensile Instability" by J.J. Monaghan. I agree though, the results you get from double density relaxation are far nicer looking and more stable in general. There's a common, very annoying issue specifically with the "Müller-esque" formulation of SPH. In 2 fluids of a high density contrast a gap tends to form between them, it's detailed and a fix is proposed in the paper Density Contrast SPH Interfaces http://www.ifi.uzh.ch/arvo/vmml/admin/upload/Solenthaler_sca08.pdf |
comment imported from WordPress Sorry, wrong link, that's an even older version, here's the correct one http://niallmeister.deviantart.com/art/Viscoelastic-Jelly-183686746 Also sorry for inadvertently plugging my stuff, haha. |
comment imported from WordPress Hi Niall, it's great to hear from people working on the same stuff. I'd definitely noticed both the problems you mentioned, but hadn't come across either of those papers, to thanks for the links. I'm looking forward to checking them out. Congrats on the Flash simulations, I'm impressed that the performance is so good. You've motivated me to try and implement the full viscoelastic sim. The kNear and kNearNorm variables are the normalization constants for the two kernel functions. They're the scaling values required to ensure that the kernels integrate to 1. If I remember correctly, the normalization constants are folded directly into the stiffness and rest pressure constants in the viscoelastic paper. I guess that's in keeping with the tone of that paper (keeping things simple), but I felt like it was hiding important details about the SPH method in general, so reinserted them explicitly back into my code. When analytically integrating the kernel functions in 2D, you have to add an extra 2*pi*r term to account for the fact that the functions are specified in a circular coordinate system. Given the kernel function: Integrating from 0 to h in circular coordinates becomes: Which evaluates to: Dividing by this constant ensures the kernel is normalized. kNearNorm is similarly derived. Since most of the papers talk about SPH in 3D, they're working in a spherical coordinate system, so the integration is different. That caught me out for the longest time. |
comment imported from WordPress Thanks for the speedy elaboration! I'm only 13 so the maths side of this stuff is still pretty new to me and I haven't fully dived into integrals yet, I somewhat understand though. |
comment imported from WordPress You're right, I apparently forgot to account for mass in the viscosity force calculation. As for surface tension and pressure relaxation, I actually calculate the acceleration directly (rather than the force), which is where the division by pi.m comes from in lines 275, 276, 281 and 282. That being said, it's entirely possible that I've made a mistake somewhere as my maths isn't terribly good either :/ By the way, there were a couple of mistakes in my previous reply, which I've now corrected. Most notably, the extra integration term should be 2*pi*r, not pi*r. |
comment imported from WordPress Hey, I've implemented your method of doing things myself in flash. I haven't experimented with it much as I'm posting this comment about 10 minutes after getting a working build because I've noticed an issue. The mass/density contrast, aargh! Here's a demo with a timestep of .1, with 2 fluids of mass 1 and 30 respectively - http://www.fileize.com/view/c82523d7-915/ - mouse to interact, sorry that it's a bit like watching paint dry at the moment. Do you think I might've coded this wrong or have you experienced the same thing? |
comment imported from WordPress Beautiful videos! I got all scared of SPH when I faced it the first time, I might give it a try. I tried your code to see if I could make a video generator out of it, for the sake of entertainmient, but particle radius below 0.04f makes it crash. How do you make the videos then, if it crashes for small radius? With a huge rendering area? |
comment imported from WordPress I never got any hard crashes when running it locally. Then again, the code I posted is a much simplified version of what I actually use at home, so it's possible I introduced a bug somewhere. In the posted videos, the particle radius is unchanged at 0.05 and kViewWidth is increased to something like 80 or more if I remember correctly, which zooms the camera out. I hope this helps; I'd love to see your videos if you come up with anything cool. |
comment imported from WordPress With crash I mean unconsistent behaviour. All particles explode and go crazy. Anyways I think you might've introduced a bug, everything tends to splash a lot, even sudden splashes out of nowhere at the bottom of the field. Particles tend to flow like marbles or sand too. I'll play with constants and see if I can fix it. I guess the part you simplified is the drawing part, right? I can clearly see the spaces between adjacent particles, so I guess the real code does some smoothing. |
comment imported from WordPress Ah that's not a bug, it's what I meant by "Unfortunately, SPH simulations have a tendency to explode if the time step is too large" - it's caused by forces in the simulation being too large for the integration method. You could replace the simple forward Euler with some more complicated integration scheme, but the simplest thing to do is to increase the number of substeps per frame. For some of the videos, I was using around 20 substeps. Alternatively, if you don't mind your fluid being a little uh, compressible, you could also reduce the stiffness constants. |
comment imported from WordPress Nice, got it to work and had some fun tweaking constants, but it takes so long per frame after a large number of particles is spawned, and re-running it from the beggining after each tweak is a bit time consuming. I'm planning on doing this realtime or at least a bit faster, implementing a quadtree for the neighbor check and Leapfrog integration to reduce substeps. If I succeed in doing so I will let you know :) By the way, was I right when I guessed that the simplified part is the drawing one? A big number of particles would make it look continous like in your videos, or it had some kind of near-deformation to make it look liquid? |
comment imported from WordPress I'm looking forward to seeing what you come up with :) The rendering code is actually more or less unchanged - you could always increase the size of the constant in glPointSize if you feel the points are too small. The major simplification in the code I posted is the removal of multi-threading. The code as posted is set up to run on multiple threads; if you're only running on one thread, you could rearrange it and probably speed it up by around 30%. For example, applying forces to both particles involved in an interaction at the same time. |
comment imported from WordPress Hi Mikhall, I'm afraid I don't have Skype (or much free time these days). I've dropped you a mail. |
comment imported from WordPress Hi there, i was lookin gat your code above and i can't seem to find where do u implement the Tait's equation of state to calculate pressure (as it was done in 2007 paper by Becker et. al ). I am having an sph algorithm where i firstly calculate my densities based on neighbour search and then i try to use Tait's EOS so as to calculate pressure but it's explodes. i see you use the simple gas law as i did. Any ideas to share would be great! Cheers |
comment imported from WordPress My code is based mostly on the Particle-based Viscoelastic Fluid Simulation paper by Clavet et al, which IIRC doesn't use Tait's equation. Instead they opted for more a approximate model that tends to explode less. |
comment imported from WordPress Hi, |
comment imported from WordPress For the most part, the videos are rendered using many more particles than in the demo. To improve upon simple circles for rendering the particles, one common technique is to render gaussian splats for each particle into a off-screen accumulation buffer and then perform a per-pixel thresholding operation when rendering the accumulation buffer to the back buffer. Another technique that was used PixelJunk Shooter to hide some of the large gaps (especially when the fluid was falling) was to decay the accumulation buffer by some amount each frame, rather than clearing it. I don't have any references to hand for either of these techniques, but hopefully that should give you pointers. |
comment imported from WordPress This may sound awfully retarded, but what exactly is the gradient of the kernel function in the very first equation here (e. g. nabla W)? I mean, W is not a scalar field, just a simple function of one argument (the distance). Must be some gap in my math, have read several papers on SPH, it's used everywhere and I totally don't get it. Could you, please, explain how to compute that? |
comment imported from WordPress Oh dear, I'm afraid it's been a bit too long since I wrote this post and I've forgotten all the details :( The the thing to remember is that although W might be defined in terms of distance from particle i, it still forms a scalar field. Think about a particle i in 2D space: W(r_i, r_j, h) forms a non-zero scalar field in the region of space described by a circle of radius h centered at r_i. I hope this helps at least a little. |
comment imported from WordPress Hi Tom, I just wanted to say thanks for sharing your code. It helped me a lot getting my own SPH working. http://softologyblog.wordpress.com/2013/09/17/multiphase-smoothed-particle-hydrodynamics/ Regards, |
comment imported from WordPress No worries, I'm glad you found it some help. |
comment imported from WordPress Pretty cool stuff! |
comment imported from WordPress No, the simulation makes several approximations in order to provide more stability at larger time steps. This is why you can see some compressibility in the videos. |
comment imported from WordPress recently im trying to develop my own version of this in python. somehow this code doesnt make use of the standard formulas used in most of the papers. i have a few questions - maybe someone who is interested in sph can contact me so we can solve it together. probably the author of this isnt working on sph for a few years now :D
2.How can you convert pseudo densities and pressures to real-life quantities? I wonder how you can compute a real density by adding weighted masses together??
|
comment imported from WordPress Hey Tom! Thanks a lot for your code posted here. I used your basic layout to get my implementation started. Still fighting with some surface tension issues for varying particle sizes, but the first results were really good: http://crococode.wordpress.com/2014/04/11/smoothed-particle-hydrodynamics-even-more/ |
comment imported from WordPress Hi |
comment imported from WordPress Hi Tom |
Comments for blog post 2010-12-15-why-my-fluids-dont-flow
The text was updated successfully, but these errors were encountered: