Jump to content
• Advertisement

# Looking for help with Smoothed Particle Hydrodynamics

## Recommended Posts

Hello,

I'm trying to add a very basic incompressible fluid simulation to my game; all i want to do is determine "given an pipe outputting pressure P at location X, what spaces are occupied by water?" I'm not too concerned with the other parts of flow.  So if anyone knows of any kernel functions that trade accuracy for speed/stability, that would be appreciated.

This is what I have so far:

Spoiler

The rectangles have 3 purposes: they are the containers for the liquid, determine if it is on screen, and they are the units used to divide it between threads.

I based it on this code: https://github.com/tizian/SPH-Water-Simulation

So these are the issues i'm having:

The first is that i'm not sure if my pressure values are good, I'm rendering the pressure with:

	void main()
{
float pressure = clamp(log2(v_pressure/800)/20.0, 0, 1);

vec2 p = gl_PointCoord.st * 2 - 1;
float c = min(length(p), 1);
fragColor = vec4(pressure, 1-pressure, 0, (1-c));
});

And I'm not sure if i should need to take a logarithm to see what the pressure is; is this normal?

Next is that i'm noticing that i have this straight line of particles at the bottom, and from what i can tell 1/3rd of the particles i spawn consistently form a straight line at the edges, is this normal?

I'm also not too sure of what the smoothing parameter used by the kernels is--it took me a while just to figure out it needs to be in meters--my best guess is that it's the sum of the radii of the 2 particles interacting. Is that right?

And finally, just that i can't figure out how to make it incompressible; i looked at a few papers like this one http://mmacklin.com/pbf_sig_preprint.pdf, where I couldn't really follow how the changes made helped solve the problem--to me it looks like they just didn't account for viscosity/gravity on alternating ticks--and this one: https://www.gdcvault.com/play/1012447/Go-With-the-Flow-Fluid Where I didn't understand how the repulsion force is any different from pressure, and it seems to me that will just make it more inclined to blow up. I'm hoping someone can ELI5 why either of these should work.

Advertisement

## 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

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5
• Advertisement

• 14
• 9
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632625
• Total Posts
3007508
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!