Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Gavity sorting?

  1. Sep 28, 2009 #1
    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.
     

    Attached Files:

  2. jcsd
  3. Sep 28, 2009 #2

    Dale

    Staff: Mentor

    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.
     
  4. Sep 28, 2009 #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
     
  5. Sep 28, 2009 #4

    Dale

    Staff: Mentor

    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.
     
  6. Sep 29, 2009 #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
     
  7. Sep 29, 2009 #6
    I didn't know I signed up for a coding forum ;]
     
  8. Sep 29, 2009 #7

    Dale

    Staff: Mentor

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Gavity sorting?
  1. Riddle of Sorts (Replies: 6)

Loading...