• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Peacekeeper

Simple SPH questions. Kernel interpolation - *(its starting to flow)

13 posts in this topic

thanks for the input! the idea with the "invMass" makes sense to me and i will try it. but it still doesnt answer how people can archieve physical values ?

 

regarding the volume of the kernel. i hacked it together in excel like this:

 

the idea was to multiply the surface below one side of the function with "2* PI * r" - (Rotational Symmetry)

 

1. i discretized my values from min (e.g. "0") to max (e.g. "1") into 50 points.

2. calculated W(r,h) with the formula at all points 1.JPG

3. simple little rectangles for the integral ( r0 * W(r0,h) + (r1-r0) * W(r1,h) + (r2-r1) * W(r1,h) + (r3-r2) .....)

 

4. multiplied the sum with the 2 * PI * r with r beeing equal to h.

 

 

i agree that the excel sheet is a bit unclear ^^ i attached a slightly improved version and here is a gif so you dont have to download it.

 

excel.gif

 

when you look at the red box for the volume it stays the same around ~4.6

Edited by Peacekeeper
0

Share this post


Link to post
Share on other sites

Concerning the integral, I have attached another excel page so that you can verify the Poly6 kernel in 2d.

 

As for how to use physical quantities in SPH well, I don't understand your question...

 

I told you how to adjust the mass of the particles so that SPH tries to conserve the correct density of the fluid via the state equation (and the forces that arise from there...) In that regard, the SPH is going to be correct.

 

The mass of the particles indeed is going to depend on the kernel. However, keep in mind that your particles are ultimately samples, not "physical balls". So for example, if you want to know the mass of a box of fluid of 1x1x1 meters a SPH, you don't actually add up the masses of the particles that are inside1. You get the particles that are inside, you get their densities, you average them (weighted by how much of their smoothing circle/sphere is inside of the box, if you want accuracy), and you multiply by your volume (1m^3). Since you are approximately conserving the density, your box will weight approximately 1000Kg.

 

Does that explanation help?

 

As for viscosity, that's a trickier one. The viscosity I used in the past was Monaghan's artificial viscosity, and it is called artificial for a reason (it has no physical meaning whatsoever). I found the proper values by tuning...

 

1 I had seen in some lecture notes that you actually add up the masses of the particles of SPH to find the mass inside a volume. That is correct (if not really accurate unless you take the smoothing volume into account) with some methods for initializing the particle's mass. However, with those methods what you don't get is a physical rest density value. Keep in mind that there is no problem with that. The simulation is going to be the same as long as the ratio between your rest density and mass is the same. You are actually free to choose how you want to proceed.

Edited by Javier Meseguer de Paz
1

Share this post


Link to post
Share on other sites

i really appreciate your detailed help. thanks alot for fixing the ecxel. i hope i dont annoy you with my frequent questions ;) i found my mistake in the excel sheet. obviously the functions where alright but my calcualation of the integrals wrong.

now its starting to flow! iam quite exited ^^

SPH_JPK_small.gif

note:

- no viscosity yet - instead iam simply dampening the velocity by -0.1 in every timestep

- walls just move the particle back to their surface if crossed

- very low stiffnes of the fluid. so its compressible

 

ok i think the next step is a closer look at what you wrote about calculating the rest density tomorrow. right now i choosed working random values. sorry that iam a bit slow here. can you give an example for a 0.1m x 0.1m space with 100 particles and water ? your method seems to need an additional first loop for initialising the simulation?

 

edit: i think thats indeed what lets my simulation require such a tiny timestep (t=0.0003) or it explodes. as initially the particles are too close or to far away from each other  HUGE accelerations are calculated. after it slowed down i quess i could change the timestep to be quicker.

Edited by Peacekeeper
0

Share this post


Link to post
Share on other sites

Glad to be of help!

 

About the rest density. Ok, what your SPH solver will do is to enforce your rest density via pressure forces. Indeed, whatever your state equation, it will give you pressures that depend on your current density and your rest density. 

 

Now, as said, SPH is unstable, and its unstable the higher the forces it generates (thus, the higher the timestep or the higher your current situation deviates from your target situation, in which the fluid is not compressed). So what you want, is to avoid compression as much as possible at all times. This begins with your initial state.

 

You want to initialize your simulation in a correct state. So you have two options: for a given mass and rest density, put the particles in the right positions (which can be hell to do) or given some particle positions and rest density, compute which has to be the mass of the particles. How to do this?

 

Before the simulation (we will discard the particles we are going to create):

- Create a particle (let's call it P) and set its mass to 1 (or whatever value, for that matter).

- Create its neighboring particles. Use whatever algorithm you are going to use in your real simulation. If for example you create particles every N meters in X and Y uniformly, just do that. The closer P resembles any particle inside your final fluid volume the better.

- Now, using the same algorithms and kernels you are going to use in your simulation, compute the density of P.

 

Now you know, for your setup, whats the ratio between your density and your particle mass. Now, do you want to have a particular rest density (eg. water's)? Easy! The mass you have to use is currentMass * watersDensity / currentDensity. 

 

As for your timestep, there are formulas to compute it automatically. Basically you want a timesteps so that your particles don't move in one timestep more than a fraction of the smoothing length. Although it is a little more involved than that. I am sorry I don't recall the formula right now. I'll look for it if you are interested.

 

PS: You're not going slow, don't worry. SPH is a simple idea but it is filled with little details that make life... interesting.

0

Share this post


Link to post
Share on other sites

Hi!

i was rather busy the last days so my progress isnt that impressive, but i got your method to work today! works like charm.

 

3Gif.gif

 

its still rather slow due to python. in the future when everything is setup i might transfer everything to cython to speed it up. but thats not a problem right now. next comes the artificial viscosity.

 

i have a few general questions left here:

 

- all papers simulate water. but as sph is actually compressible what about an ideal gas? is that possible? actually ideal gas doesnt even have viscosity but probably that´d make the whole simulation quite unstable.

 

- i noticed that i use the spiky kernel for the pressure calculation AND the density calculation. as you can see above it works quite good. using the poly kernel for the density like its done in the literature results in clumping of the particles. yes, they clump together altough the spiky(-pressure) kernel should avoid that. i have no idea how this can happen.

 

poly6.gif

Edited by Peacekeeper
0

Share this post


Link to post
Share on other sites

Hi there Peacekeeper. To avoid clumping, it might be a good idea to apply a repulsive-only kernel between each interacting particle pair, where force is proportional to either distance or a local pressure value ony dependent on those two particles. As far as I know (I'm no expert but have some experience with sph) it's the only way to avoid clumping. In my experience it works best if the particle pair kernel is spikier than the pressure kernel, which means that repulsive force is usually weaker than pressure force, except when particles are very near each other.

 

Cheers Mike

Edited by h4tt3n
0

Share this post


Link to post
Share on other sites

yep and that should be the case here. as i can use the poly 6 kernel for calculating the density and pressure at each particle but for the pressure force (gradient) i use the spiky kernel. so if particles come close to each other there should still be a repulsive force

0

Share this post


Link to post
Share on other sites

Well okay, might just be a matter of fine-tuning then. What happens if you turn off pressure kernel, so the only forces influencing the particles are from the repulsive-only kernel?

0

Share this post


Link to post
Share on other sites

oh sry maybe i misunderstood you. right now the particles move only based on the pressure gradient that is calculated using the spiky kernel. there is no extra kernel for repulsive forces when the particles are close because - as you can see - it works well if the spiky kernel is used on both (density/pressure and pressure forces). i just wonder why it works pretty well that way, as in many papers people tell you to use the poly 6 kernel for the density as it should result in more physically realistic behavior.

 

so i cant figure out why particles that get too close to each other do not repulse each other as the spiky kernel should provide repulsive forces. the question is why they even start to get so close in the first place. must have something todo with the kernel i do not understand. as if the particles have to get really close to reach the desired density.

 

edit: what about the ideal gas btw :D?

Edited by Peacekeeper
0

Share this post


Link to post
Share on other sites

You are pretty much simulating a gas already (surprise!) but with the density of water and in the vacuum, so it ultimately behaves like water.

 

Actually very dense gases are not that different from liquids: https://www.youtube.com/watch?v=DzLX96VWTkc

 

EDIT: Well, the "in the vacuum" part is pretty bad explained. In the end if we have a gas we are not in the vacuum, sorry about that. What I meant here is that we only have one phase (just our simulated fluid, without air surrounding it). What really matters here is that for dense gases the action of gravity is stronger than the repulsion forces of pressure until the particles are quite close together.

Edited by Javier Meseguer de Paz
0

Share this post


Link to post
Share on other sites

oh sry maybe i misunderstood you. right now the particles move only based on the pressure gradient that is calculated using the spiky kernel. there is no extra kernel for repulsive forces when the particles are close because - as you can see - it works well if the spiky kernel is used on both (density/pressure and pressure forces). i just wonder why it works pretty well that way, as in many papers people tell you to use the poly 6 kernel for the density as it should result in more physically realistic behavior.

 

so i cant figure out why particles that get too close to each other do not repulse each other as the spiky kernel should provide repulsive forces. the question is why they even start to get so close in the first place. must have something todo with the kernel i do not understand. as if the particles have to get really close to reach the desired density.

 

edit: what about the ideal gas btw biggrin.png?

 

Ah okay, slight misunderstanding. I compute a local density for each interacting particle pair and use that value for a repulsive-only "local" pressure force. Then I sum up all local densities to a "global" density value, which is used in an attractive-repulsive pressure kernel. This is a fail-safe way to 100% avoid clumping. There are many, many different kernels for computing density, pressure, and viscosity, and you are completely free to invent your own. My kernels are self-invented for working without knowing the distance between particles. This way I don't need to normalize vectors and hence not use square-root, which makes the simulation much faster.

 

In my experience, clumping happens when two particles are pushed very close together, and the kernels aren't capable to separate them; they make each others density kernels reach a value higher than rest-density, resulting in a high pressure. Then the pressure kernel pushes all other particles away from the two, but it doesn't manage to separate the particles causing the high density.

Edited by h4tt3n
0

Share this post


Link to post
Share on other sites

ok thanks for the input :) i´ll stay with my working kernels for now.

 

do you have any further advice on vicsosity or rigid body collision? there are tony of possibilites aswell. which methods do you use? i´d prefer simple solutions. ;)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0