• 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
Finalspace

Wrong result for ported SPH Simulation

6 posts in this topic

Hi there,

 

i am currently trying to port a working SPH - Smoothed Particle Hydrodynamics 2D implementation to Javascript with the simplest methods possible. Original code see here: http://www.opentk.com/node/377

 

After some days i got some results which moves particles but behaves really weird - Particles just pushes other particles away and does not behave correctly. The main problem is - SPH is based on heavy maths and i dont understand the details at all - Therefore fixing issues is really hard. Dont get me wrong, i have some experience with vector maths, collisions and response, see this demo: http://root.xenorate.com/final/physics/circles.html (Circle/Plane Collision with TOI handling and collision response)

Therefore i understand vector arithmetic a little, but SPH is just a little to hard to figure out myself. Also i made a fully working 3D Fluid Simulation in the past, but using PhysX as a Physics Engine: See this demo i made: http://www.youtube.com/watch?v=eUbwxTE38TY

Now i wanted to try to make this myself, without using a physics engine at all.

Please have a look at my javascript SPH port: http://jsfiddle.net/gRUKg/1/

 

Currently my implementation does not handle every aspect from the original source, i use a diffent spatial grid technique and the viscosity and adjust distance code is disabled (Not required to get this working)

 

It would be really great if you can help me to get this thing working. I really want to understand the details behind it, for tuning the properties and improve it. Of course i read several SPH papers, but i cannot understand this at all.

 

Thanks in regards,

Final

Edited by Finalspace
0

Share this post


Link to post
Share on other sites


Currently my implementation does not handle every aspect from the original source, i use a diffent spatial grid technique and the viscosity and adjust distance code is disabled (Not required to get this working)

A pedantically faithful port would be easier to write. You admit being out of your depth with this project, so you should avoid imprudent attempts to be clever like messing with the basic grid structure or deciding that some parts of the algorithm aren't "required". I was going to suggest a careful review of your code and the original to find subtle differences in calculations, but deliberately doing something else in a different way makes this approach impossible.
0

Share this post


Link to post
Share on other sites

Can you show an animation from your current implementation?

 

I suspect you are getting this behavior because you have not included viscosity. The SPH algorithm has artificial viscosity terms for damping (dissipating energy), this is required even when modelling an inviscid fluid.

 

You may want to check your simulation parameters as well. Incorrect choice of time step or integration kernel range will lead to unstable solutions.

0

Share this post


Link to post
Share on other sites

Can you show an animation from your current implementation?

 

I suspect you are getting this behavior because you have not included viscosity. The SPH algorithm has artificial viscosity terms for damping (dissipating energy), this is required even when modelling an inviscid fluid.

 

You may want to check your simulation parameters as well. Incorrect choice of time step or integration kernel range will lead to unstable solutions.

 

You can see the animation if you click on the jsfiddle link in my post.

 

Also i modified the original source (c#) and disabled the viscosity and distance adjust part just to make sure, what the basics are.

And it works just fine without viscosity force, of course it is a lot more stable with viscosity. Thats for sure.

 

 

 

Currently my implementation does not handle every aspect from the original source, i use a diffent spatial grid technique and the viscosity and adjust distance code is disabled (Not required to get this working)

A pedantically faithful port would be easier to write. You admit being out of your depth with this project, so you should avoid imprudent attempts to be clever like messing with the basic grid structure or deciding that some parts of the algorithm aren't "required". I was going to suggest a careful review of your code and the original to find subtle differences in calculations, but deliberately doing something else in a different way makes this approach impossible.

 

 

Yeah i know, but i think i wont learn not much from that - normally i would break down an implementation to see what happens if i modifiy/disable several parts, like disabling the global force or viscosity force or distance adjust stuff. Thats my normal way of doing things, but i think porting it directly without changes at all is a better approach right now. I will post again if i finished the port.
 

0

Share this post


Link to post
Share on other sites

So I just had a look at your JSFiddle. I reduced the particle mass to 1, from that it appears that the motion of the particles is just to acheive an equilibrium configuration. This is more obvious when you add lots of particles, and turn off the boundaries, notice how the packing becomes very regular. This is normal behaviour as particles are not initialised in their equilibrium configuration.

 

With a reduced mass, the body force implementation appears to be working as well.

 

Your boundary collision however is not conserving momentum, and is causing a very unstable solution.

0

Share this post


Link to post
Share on other sites

Ok i ported it successfully and it works fine so far.

There was some things which had troubled me while porting and some things i learned:

 

- Javascript does weird things with arrays like this: var arr = [,];

- yield return idx; is a really shit shortage for a concatination of an interation in C# :(

- domain resolution should be left in a smaller range, otherwise it is too slow or somehow unstable.

 

Here is the result:

http://jsfiddle.net/Qy9SX/1/

 

Now the next step is to change the spatial grid technique to a dynamic one and implement basic collisions to simulate the boundary.

 

Thanks for your help so far.

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