Source Code and Cool Things to Do

Drag to rearrange sections
Rich Text Content

The python source code is attached to this page because there is no indentation on these pages.

Open up the code and play, you can always get another copy here.

 

Things you can change with no modification, only putting in new numbers

     n, the number of particles

     vmax, the maximum possible velocity in any direction

     sun, is there our sun or not

     g, the universal gravitation constant

     deltat, the size of the timestep

 

Cool things i've done that require little modification to the code:

- Run 450 Bodies overnight with a 3 second timestep. About 50% of the time you end up with a stable system with orbits, and 50% of the time everything gets ejected

       Set sun = False (capital F is important, default True)

       Set N to 450 (default 50)

       Set deltat to 3 (default 20,000)

 

- Set g to a really big number and watch the ensuing chaos

       Set g to 1 (default 6.67e-11)

       Set N to 250

       Set deltat to a number between 5000 and 20000 based on your patience

 

- Just let it go on its own, ensuring stable orbits :D

      Make sure vmax = about 7e3

      Set n= a number between 20 and 50 based on how fast your CPU is (50 is nice on a core i7)

      deltat based on your patience again

 

 

Changes that require bigger modification (in size order)

Simulate a solar system with no angular momentum (a non spinning star that went nova, but idk if this exists!)

     For the position and velocity vectors, the numbers are the x, y and z components of the vector. Using this knowledge:

     Set the position z component to a random number between -1e5, 1e5 (np.random.randint(-1e5, 1e5))

     Do the same with velocity, but between -700, 700 (np.random.randint(-700,700))

     Generally N can get pretty big on this, idk why. (250 is comfy on my mac)

 

Simulate a solar system WITH angular momentum (I think, this hasn't been tested)

     Do the same as above

     Limit EITHER the y components OR the x components of VELOCITY in one direction so like np.random.randint(0, vmax)

     No promises here though

 

Simulate OUR solar system

      Get all the info about orbits off of wikipedia or a source of your choice

      remove the section of code that randomly generates objects

      fill object array by yourself with each planet and its radius, orbital info and a color of your choosing.

     Very interesting to see how cosmological scales look in reality. We blow images of the earth up wayyyy too big. (the sun is only a few pixels across in this simulation)

 

rich_text    
Drag to rearrange sections
Image/File Upload
attachment 32405838  
Drag to rearrange sections
Rich Text Content
rich_text    

Page Comments