Simulation Programming: Spawning particles at random position

Click For Summary
SUMMARY

The discussion focuses on using the simulation software Breve, which supports Python and its proprietary language, Steve, to spawn spherical particles at random positions without overlap. The proposed solution involves a brute force method that checks the distance between newly spawned particles and existing ones to ensure they do not intersect. However, this method is inefficient for large numbers of particles, leading to performance issues and potential program crashes. An alternative approach suggested is to initially select a random position and, if it overlaps, to find an unoccupied position, thereby improving efficiency.

PREREQUISITES
  • Understanding of Breve simulation software
  • Familiarity with Python programming
  • Knowledge of collision detection algorithms
  • Experience with random number generation techniques
NEXT STEPS
  • Explore advanced collision detection algorithms for particle systems
  • Learn about spatial partitioning techniques to optimize particle spawning
  • Investigate the use of Voronoi diagrams for efficient space management
  • Research performance optimization strategies in Python for simulation applications
USEFUL FOR

Game developers, simulation programmers, and anyone interested in optimizing particle systems in Breve or similar simulation environments.

PythagoreLove
Messages
19
Reaction score
0
Hi, I am making a program with the simulation software Breve. It codes in Python or in Steve (their own language). In my simulation, spherical particle with random radius are being spawned at random position into a little zone. My problem is that those particle cannot be superposed. I don't know how to program it in such a way that the particle will spawn at a position where they will touch no other particle.


Thanks
PytLove
 
Technology news on Phys.org
Simple brute force method:

For each new particle check to see the distance between the center of the particle and the center of each previous particle is greater than the sum of the radius of each of those two particles. If it isn't then throw the new one away and generate another particle.
 
Thank you that seems to work well. Unfortunately that takes a long time with a lot of sphere and sometimes the program crash because the loop verifying the sphere position run for too much time. I would like to at first take a random position, and if it touches another sphere choose a position where there is nothing. In that way one sphere could not be spawned more than two times. I don't know if it's possible but I think that could make my program faster.
 

Similar threads

  • · Replies 19 ·
Replies
19
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 29 ·
Replies
29
Views
8K
Replies
16
Views
3K
Replies
9
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K