Universe Sandbox

General Category => Astronomy & Science => Topic started by: atomic7732 on April 10, 2011, 12:55:08 PM

Title: 2D 3-body Gravitational Simulator
Post by: atomic7732 on April 10, 2011, 12:55:08 PM
Right now, I'm working on a Perl gravitational simulator. It takes 3 bodies characteristics and creates an output file. The visual output is your favorite graphing program! Excel, Google Docs, or whatever. The output file just outputs the locations. I'll probably change it to include acceleration or other data. Collisions aren't in the program yet. It should be easy by simply adding radii to the objects. It's conventionally a Star-Planet-Moon simulator, but with a little calculation you can make a 2 planet system. :P
Title: Re: 2D 3-body Gravitational Simulator
Post by: atomic7732 on April 10, 2011, 06:37:30 PM
I finished it... and tested it... It wrote the file... but it only said:

Code: [Select]
StarX StarY PlanetX PlanetY MoonX MoonY
when it should have had that AND a bunch of data

It said "Illegal division by zero at line 164"
Title: Re: 2D 3-body Gravitational Simulator
Post by: atomic7732 on April 10, 2011, 06:53:45 PM
I think I fixed it but then all I got was:

Code: [Select]
2.45230724281467e+024 1.63605369640936e+024 2.39322572687155e+026 -1.6524812430857e+027 -4.25878464967556e+030 -7.94160599526426e+031
Title: Re: 2D 3-body Gravitational Simulator
Post by: atomic7732 on April 10, 2011, 07:28:40 PM
Fixed it, but now it just gives the same number repetitively, for each one.
Title: Re: 2D 3-body Gravitational Simulator
Post by: atomic7732 on April 12, 2011, 09:59:35 PM
I got it to work! I can't tell if the sun is working... it's the only one giving the same numbers. Anyhow... Here's a chart. 48 iterations 6 hours each. Due to the way the numbers output and google reads it... You should view it upside down. :P

The star is located... not at 0 for whatever reason. I have no clue. I tell it that it is located there, but it doesn't seem to care.
Title: Re: 2D 3-body Gravitational Simulator
Post by: Dan Dixon on April 14, 2011, 12:43:12 PM
Very cool.

You've seen my early gravity simulation work, right?
http://dandixon.us/programming/planets.htm
Title: Re: 2D 3-body Gravitational Simulator
Post by: atomic7732 on April 14, 2011, 07:54:01 PM
Yeah, I have.  :)