Universe SandboxGeneral CategoryAstronomy & Science2D 3-body Gravitational Simulator
Pages: 1
PrintPrint
Author Topic: 2D 3-body Gravitational Simulator  (Read 793 times)
atomic7732
Beta Team

*****
Posts: 2651


Like a scientific expert. With magic.


WWW
« 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. Tongue
Logged
atomic7732
Beta Team

*****
Posts: 2651


Like a scientific expert. With magic.


WWW
« Reply #1 on: April 10, 2011, 06:37:30 PM »

I finished it... and tested it... It wrote the file... but it only said:

Code:
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"
« Last Edit: April 10, 2011, 06:47:29 PM by NeutronStar » Logged
atomic7732
Beta Team

*****
Posts: 2651


Like a scientific expert. With magic.


WWW
« Reply #2 on: April 10, 2011, 06:53:45 PM »

I think I fixed it but then all I got was:

Code:
2.45230724281467e+024 1.63605369640936e+024 2.39322572687155e+026 -1.6524812430857e+027 -4.25878464967556e+030 -7.94160599526426e+031
Logged
atomic7732
Beta Team

*****
Posts: 2651


Like a scientific expert. With magic.


WWW
« Reply #3 on: April 10, 2011, 07:28:40 PM »

Fixed it, but now it just gives the same number repetitively, for each one.
Logged
atomic7732
Beta Team

*****
Posts: 2651


Like a scientific expert. With magic.


WWW
« Reply #4 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. Tongue

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.


* planetsim output.PNG (17.83 KB, 616x359 - viewed 195 times.)

* planetsim with star.PNG (14.04 KB, 630x359 - viewed 189 times.)
« Last Edit: April 12, 2011, 10:04:02 PM by NeutronStar » Logged
Dan Dixon
Creator of
Universe Sandbox

*****
Posts: 2407



WWW
« Reply #5 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
Logged
atomic7732
Beta Team

*****
Posts: 2651


Like a scientific expert. With magic.


WWW
« Reply #6 on: April 14, 2011, 07:54:01 PM »

Yeah, I have.  Smiley
Logged
Pages: 1
PrintPrint
Jump to: