Jump to content

Newtonian Gravitation Simulation Help!


Recommended Posts

Dear scienceforums.net, 

This would be my second posting and thought this would be the proper section to put this in. I've been trying to construct a generalized python simulation for any arbitrary n-bodies with predefined randomly assigned momentum and velocity. So far it was going well and even the initial run through went smoothly without many errors to be fixed but when graphing the data it seemed to me to be incomplete. Either I was shifting through the data wrongly, the initial conditions were off enough to not allow for a smooth nearly closed n-body system, or i've been wrong about the whole program apparatus to begin with. I should note that I use something called Jupyter Notebook to perform this. 

First was the introductory modules needed and after that the number "n" of bodies included. Then I randomly selected a random number from a triangular distribution which picked a number between 0 and 1 to then multiply the max mass to be included with this set being denoted "m". Then in another cell created a cell "s" where I which would be a single set that would include the x,y, and z positions followed by the momentum in those respective directions then the positions of second object with its accompanying momentum until we've gone through all the way to "n". It take the form of, [ x_1, y_1, z_1, p_x1, p_y1, p_z1, x_2, y_2, z_2, p_x2, p_y2, p_z2, ..., x_n, y_n, z_n, p_xn, p_yn, p_zn ]. The last nth bodies position and momentum are different because I wanted to set the center of mass and momentum at the origin so the momentum of the final object as to equal the combined negative momentum of the rest of the objects considered as is the position except we divide that value by the nth mass. 

The cell after this is the meat of the program which cycles on through "N" number of years at an hour a time as the units of the t's are seconds so this should explain the numbers used. I added up the number of gravitational forces "i" acting on the "jth" object not including itself without repetition then recalculated the momentum followed by the positions in the x,y, or z directions then append it to set "s" with the same order as before Rince and Repeat. 

Hopefully you can make sense of my program and check my work. Did I do this right? What are your opinions on my work?  

Sincerely, The victorious truther

Multi-body Gravitational Simulation.pdf

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.