# SPH and liquid similation

This topic is 3874 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Iam trying to implement 2D liquid simulation using Smoothed Particle Hydrodynamics(SPH). But I dont understand it well, mainly because my math is not high enough(Iam still at high school) and engish is not my language. I understand SPH well(at least basic concept). But i dont understand how Navier-Strokes equations are applied in it (because I dont understand Navier-Strokes equations(wtf is divergence and Laplacian?)). I found some material on it (Particle-Based Fluid Simulation for Interactive Applications paper), but this requies math knowledge i dont have. I also found some source code, but it was far away from learning material. Does anybody know about some better source on this topic or more materials? Sorry for bad english.

##### Share on other sites
Divergence of a vector field is a scalar field.

Roughly speaking Divergence can be thought of as the extent to which the field explodes, or diverges, at some point. I would suggest you read up a text on Vector Analysis.

Suppose we have a vector field F = F1i + F2j + F3k,The divergence of F is a scalar field, denoted div F, defined bydiv F = partial derivative of F1 with respect to X + partial derivative of F2 with respect to Y + partial derivative of F3 with respect to Z.

Argghh! This is annoying way of writing math... Hmm I suggest you do some research on this.

Laplacian of a scalar field f is defined to be div (grad f).

How about this, try reading over the following pages on divergence and laplacian. If you have any questions ask here. If I have time I will try to explain this properly. Sorry if I'm not very helpful :(

http://mathworld.wolfram.com/Divergence.html

http://en.wikipedia.org/wiki/Divergence

http://mathworld.wolfram.com/Laplacian.html

http://en.wikipedia.org/wiki/Laplacian

##### Share on other sites
A good book on vector analysis is: Introduction TO Vector Analaysis by Harry F. Davis.

Man I'm not being very helpful... telling you to read up on Vector Analysis :(

##### Share on other sites
John Anderson's book, "Computational Fluid Dynamics" is a pretty good starting point to understanding the nature of fluids and the math behind the Navier-Stokes (and related) equations. The subject gets deep pretty fast, but Anderson does present things in an extremely intuitive way. It is just a damned good book if you want to really begin to understand fluids and how we the human race currently use math to model fluids. The fact that you are in high school will not make it more difficult for you to learn a lot from the beginning sections of this book. Even if your math isn't advanced.

Computational Fluid Dynamics

The SPH technique, as far as I understand it (I've studied CFD, theoretical, and experimental fluids quite extensively, but not the SPH technique specifically) implements Navier-Stokes by choosing kernel functions that happen to satisfy the Navier-Stokes and other governing equations when plugged in. So it is simply the smart design of those kernel functions that enables SPH to model fluids correctly. You don't necessarily have to fully understand fluids to implement this.

By the way, strictly speaking, the "Navier-Stokes" equations are a representation of the conservation of momentum, nothing else. But, in fact, there are three conservation laws for fluids: 1) conservation of momentum (Navier-Stokes); 2) conservation of mass (aka "continuity"); and, 3) conservation of energy. There also various weird conditions or constraints that show up from time-to-time to fixup some messy bits (a closing equation such as the ideal gas law to enable satisfaction of conservation of energy, the Kutta condition to deal with circulatory flows around sharp corners, Rankine-Hugoniot jump conditions to satisfy the 2nd law of thermodynamics and compute physically "correct" compression-only shock waves, etc.). Anyway, this won't mean much...its just a side note.

With SPH, the kernel functions must be chosen to satisfy Navier-Stokes and energy, but continuity is satisfied simply by keeping a fixed # of particles each with a constant mass. (The local density of fluid varies as particles move around, and it is the density that fits into the various governing equations, but the mass carried by a single particle stays constant.)