• Create Account

# How to simulate pressure with particles?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1Beeeph  Members   -  Reputation: 125

Like
0Likes
Like

Posted 20 July 2012 - 06:21 PM

I'm trying to simulate pressure with a collection of spherical particles in a Unity game I'm building. A couple notes about the problem:

- The goal is to fill a constantly changing 2d space/void with small, frictionless spheres. The game is trying to simulate the ever-growing pressure of more objects being shoved into this space.

- The level itself is constantly scrolling from left to right, meaning if the space's dimensions are not changed by

the user it will automatically get smaller (the leftmost part of the space will continually scroll off-screen).
I'm wondering what some approaches are that I can take to tackling these problems...

1. Knowing when to detect when there is space to fill and then add spheres to the space.
2. Removing spheres from the space when it is shrinking.
3. Strategies to simulate pressure on the spheres such that they "explode outwards" when more space is created.

The current approach I am contemplating is using a constantly moving wall, that is off screen and moves with the screen, as the attached image illustrates.

This moving wall will push and trap the spheres into the space. As for adding new spheres, I was going to have either (1) spheres replicate themselves upon detecting free space, OR (2) spawn them at the left side of the space (where the wall is) - pushing the rest of the spheres to fill the space. I foresee problems with idea #1 because this likely wouldn't really create/simulate pressure; idea #2 seems more promising, but raises the question of how to provide a location for these new sphere particles to spawn (and the ramifications of spawning them when there IS no space).

### #2Lars-Kristian  Members   -  Reputation: 158

Like
0Likes
Like

Posted 20 July 2012 - 07:21 PM

Take a look at http://en.wikipedia.org/wiki/Coulomb_law (coulomb's law). It is used in http://en.wikipedia....ce-based_layout (Force-based graph drawing).

You can use coulomb's law between all the particles, and then they will repel each other.
More particles will give more tension or pressure.

Edited by Lars-Kristian, 20 July 2012 - 07:23 PM.

### #3Postie  Members   -  Reputation: 681

Like
1Likes
Like

Posted 20 July 2012 - 07:47 PM

Pressure can be seen as the sum total of all the particles colliding with the container's walls over a period of time. If you're looking to go the realistic route you could give all your particles an initial kinetic energy based on the temperature of the fluid you're simulating, and if you use elastic collisions you should find that as you decrease the volume there are more particle collisions per second.
Currently working on an open world survival RPG - For info check out my Development blog:

### #4Kyall  Members   -  Reputation: 287

Like
0Likes
Like

Posted 23 July 2012 - 02:34 AM

I would go woth a dynamic vector.fiekd where its a vector field that details pressure differential with direction and magnitude. the origins of each vector would be laid out as a grid.

To calculate the vector flow fiekd id have the same sort of grid but this one would be a scalar field that sources its values from the scene. Then calculate the flow vectors.'technically a tensor field' and it's done

typos phone and some body probably already said this.
I say Code! You say Build! Code! Build! Code! Build! Can I get a woop-woop? Woop! Woop!

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS