Gravity Simulation: Consistent Rotation Pattern?

AI Thread Summary
The discussion revolves around a gravity simulator created in Processing that exhibits a consistent rotation pattern during particle collapse, with the top falling forward and the bottom back. The creator, Fp, questions whether this behavior is due to a programming issue or a physics phenomenon. Other participants suggest that the consistent results may stem from the random number generator using a default seed, which could lead to identical simulations if not explicitly changed. They recommend posting the code in a programming forum for further analysis. Ultimately, the consensus is that the observed behavior is likely a programming or numerical error rather than a physics-related issue.
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: 420
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 ;]
 
Back
Top