Gravity Simulation: Consistent Rotation Pattern?

In summary, the conversation discusses a simple gravity simulator written in Processing, with a second degree modified Euler integration scheme implemented on particles in three dimensions. The direction of rotation in the simulation is always the same, leading to a discussion on the possibility of a physics or numerical reason for this tendency. The issue is determined to be a programming or numerical error, and the suggestion is made to post the code in a programming sub-forum for further assistance. It is also mentioned that setting the random seed may affect the results of the simulation.
  • #1
funkpun
4
0
Hi all. I've been playing around with a simple gravity simulator I wrote in Processing. I have a version that impliments a second degree modified Euler integration scheme on particles in three dimensions. Attached is a screen strip of screen captures showing the first few moments of the simulation.

What I find interesting/weird is that the direction of rotation as the sheet collapses is always the same -- the top falls forward, the bottom falls back (particles become more and more cyan as they move forward).

I don't believe this is a programming issue, as the documentation for the randomize function says: "Each time the random() function is called, it returns an unexpected value within the specified range..."

I'm curious if there might be a physics or numerical reason for this tendency.

I'm happy to share my code, if you want to see it -- although it's still extremely messy and gnarly and such.

Cheers,
Fp.
 

Attachments

  • strip.jpg
    strip.jpg
    5.4 KB · Views: 375
Physics news on Phys.org
  • #2
If you seed the random number generator with the same seed each time then it will give exactly the same results each time. Try seeding with a different number.
 
  • #3
"If you seed the random number generator with the same seed each time then it will give exactly the same results each time. Try seeding with a different number."

I'm *not* using a seed. It's randomizing properly.

Fp
 
  • #4
All random number generators use a seed. If you are not explicitly setting it then it is probably using the same default seed each time resulting in the exact same simulation each time.

Set the seed explicitly and then change it and see what happens.
 
  • #5
It's not the random seed -- randomize is working correcly. There's also no bias in the way the sheet is constructed:

for (int i = 0; i <= bodies.length-1; i++) {
bodies = new Objects(random(w), random(h),random(0, 50), random(0,200));
}

create a particle w. random x,y and z between 0 and 50, with mass of 0 to 200.

Fp
 
  • #6
I didn't know I signed up for a coding forum ;]
 
  • #7

1. What is gravity simulation and why is it important?

Gravity simulation is the process of creating a computer model that mimics the effects of gravity on a system. It is important because it allows scientists to study and understand the behavior of objects in space, such as planets, stars, and galaxies, without actually having to physically observe them.

2. How does gravity simulation work?

Gravity simulation works by using mathematical equations and algorithms to calculate the gravitational forces between objects in a system. These calculations take into account the mass, distance, and velocity of each object to determine their trajectories and interactions with each other.

3. What is a consistent rotation pattern in gravity simulation?

A consistent rotation pattern in gravity simulation refers to the predictable and stable rotation of objects in a system due to the gravitational forces acting upon them. This means that the objects will rotate in the same direction and at a constant speed, without any sudden changes or disruptions.

4. How is a consistent rotation pattern achieved in gravity simulation?

A consistent rotation pattern is achieved through accurate and precise calculations of the gravitational forces between objects in a system. This requires a complex and detailed simulation model, as well as powerful computing resources to handle the vast amount of data and calculations involved.

5. What are the applications of gravity simulation in science?

Gravity simulation has numerous applications in science, including in the study of planetary and celestial motion, the formation of galaxies and solar systems, and the effects of gravity on space exploration missions. It also has practical uses in fields such as astrophysics, aerospace engineering, and astronomy.

Similar threads

  • Programming and Computer Science
Replies
4
Views
10K
  • Beyond the Standard Models
Replies
1
Views
2K
  • Cosmology
Replies
2
Views
6K
  • Astronomy and Astrophysics
Replies
7
Views
3K
  • Beyond the Standard Models
Replies
2
Views
11K
Back
Top