Simulation Programming: Spawning particles at random position

In summary, the conversation discusses creating a program using the simulation software Breve to spawn spherical particles with random radii in a designated zone. The issue is that the particles cannot overlap, and a brute force method of checking the distance between each particle is suggested. However, this method is time-consuming and sometimes causes the program to crash. The individual suggests a different approach of randomly selecting a position and if it overlaps with another particle, choosing a different position until it does not overlap. This may help make the program faster.
  • #1
PythagoreLove
19
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
  • #2
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.
 
  • #3
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.
 

1. What is simulation programming?

Simulation programming involves using computer software to create models that mimic real-world systems or processes. It is commonly used in scientific research, engineering, and other fields to study complex phenomena and predict outcomes.

2. How does spawning particles at random position work in simulation programming?

In simulation programming, spawning particles at random positions involves generating random coordinates within a defined range and assigning them to individual particles. This allows for a more realistic simulation of particle movement and behavior.

3. Why is spawning particles at random position important in simulation programming?

Spawning particles at random positions allows for a more diverse and dynamic simulation. It prevents the particles from following a predetermined pattern, making the simulation more realistic and accurate.

4. Can spawning particles at random position be used in different types of simulations?

Yes, spawning particles at random positions can be used in various types of simulations, such as physics simulations, fluid dynamics simulations, and weather simulations. It is a common technique used to improve the accuracy and complexity of simulations.

5. Are there any limitations to spawning particles at random position in simulation programming?

Yes, there can be limitations to spawning particles at random positions, such as computational resources and accuracy. Depending on the specific simulation, other techniques may need to be used in conjunction with random spawning to achieve the desired results.

Similar threads

  • Programming and Computer Science
Replies
19
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
29
Views
5K
  • Classical Physics
Replies
2
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
Back
Top