Gravity Simulation: Consistent Rotation Pattern?

Click For Summary

Discussion Overview

The discussion revolves around a gravity simulation created by a participant, focusing on the consistent rotation pattern observed during the simulation's execution. Participants explore potential reasons for this phenomenon, considering both programming aspects and underlying physics principles.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their gravity simulator using a modified Euler integration scheme and notes a consistent rotation pattern in the simulation.
  • Another participant suggests that if the random number generator is seeded with the same value, it will produce identical results, recommending the use of a different seed.
  • The original poster clarifies that they are not using a seed and believes the randomization is functioning correctly.
  • A subsequent reply asserts that all random number generators utilize a seed, implying that the default seed might be causing the same results to repeat.
  • The original poster defends their implementation, stating that the randomization process for particle creation does not introduce bias.
  • One participant humorously comments on the focus on coding rather than physics.
  • Another participant suggests posting the code in a programming sub-forum, asserting that there is no physics reason for the observed behavior and attributing it to a programming or numerical error.

Areas of Agreement / Disagreement

Participants express differing views on whether the consistent rotation pattern is due to programming issues or if it might have a physical explanation. There is no consensus on the cause of the phenomenon.

Contextual Notes

Participants have not resolved the assumptions regarding the random number generation process or the implications of the simulation's setup on the observed behavior.

funkpun
Messages
3
Reaction score
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: 437
Physics news on Phys.org
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.
 
"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
 
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.
 
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
 
I didn't know I signed up for a coding forum ;]
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
6K
Replies
4
Views
11K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
24
Views
8K
  • · Replies 1 ·
Replies
1
Views
12K