walter said:
I would like to start a fun project to create a vb6 program to create a orbit simulator.
Is there anybody that's done this that could give me some tips?
Sorry for pulling up such an old thread, but I've only been a member of this facinating forum for about 2 weeks. But I did exactly what you described. I wrote an orbit simulator in VB 6.0. You can download it here:
www.gravitysimulator.com
It performs its calculations on a 3d universe. It uses Euler's method, a first-order method. I'm hoping to post a new version in about a month or two that will use a Runge-Kutta4 engine as well.
Walter, it doesn't look like you've posted since April, so I doubt you'll read this, but if you do, and you still want to tackle such a project, let me know and I'll be happy to help you.
enigma said:
Unless you go with either an extremely small timeslice or only a few orbits, there is a chance that using the Euler method (described by marcus) will not give you a closed orbit. Errors in the timestep cause the orbits to fall outwards. You may need to implement a runge-kutta method for long duration simulations.
Actually, the first order Euler method works remarkably well. With a timestep as large as 16767 seconds per time step, the solar system holds together for over a million years. Probably more, as I ended the simulation at 1 million years because it took my computer a month to do. I can speed this up to 65536 if I remove moons from the solar system. Faster than that causes Mercury to deviate from its orbit.
In fact, the Euler Method is accurate enough that if I use JPL's Horizons system to accurately place the planets in their January 1, 2003 position, Mars and Earth pass each other at exactly the right time and distance as the real Mars did August 2003 when it made its closest approach in 60000 years. Running the simulation further into the future, Mars also passed Earth at the correct time and distance for its next opposition (2005? I think). But the 2007 opposition came about 2 days early or late, but at the right distance, and the 2009 or 2010 opposition was about 7 days off its predicted date, but the correct distance. I'm not sure if Runge Kutta would give better results here. I might just need a more accurate value for G or for Sun mass.
In the post titled Sedna in this forum, check posts an article about the origin of Sedna's orbit. Doing a Google on the scientist's name in that article I located his paper at
http://www.boulder.swri.edu/~hal/PDF/CR105.pdf . I was able to use my program to reproduce his simulation of a 0.05 solar-mass brown dwarf with bodies orbiting in the 20-100 AU range, passing 200 AU from the Sun with a starting velocity of 1km/s. My simulation unfolded almost exactly like theirs did. 8 of the 20 test particles orbiting the brown dwarf entered solar orbits after the passage.
The new version I hope to release soon is over 10x faster because I've cleaned up the code and put the Euler engine in a C++ dll. It may be even faster still if I can get my RK4 engine working.