Great program. I've been looking for a decent gravity simulator for ages and this is the first I've found that doesn't suck. Couple of questions from a novice user

1) How do I make the program view the system edge on? When I make a solar syatem and give the planets inclination 0, it looks at the system from the top. But in onlyplanets.gsim the planets have inclinations of about zero and I see the system edge on. How do I do that in my simulations?

2) When two bodies collide, how does the program work out the diameter of the merged object?

1. The scroll bar on the right side of the screen adjusts the view plane. When it is centered, you are viewing edge-on. When it is on the top, you are viewing top-down. When it is on the bottom, you are viewing bottom-up.

2. I'm going to re-do this code because there's a bug that sometimes shows up when objects of different densities merge. But for bodies of the same density it works fine. Basically it works like this: From the size and mass of a body it determines its density. When two bodies collide, it computes their combined average density. This will be the density of the new object. From its density and mass it computes its volume, and from volume it computes its radius.

3. I didn't document this part well enough. The Create Objects window works fine for circular and elliptical orbits, but not for hyperbolic. For hyperbolic orbits, there's a few games you can play. Let me make up an example and step you through it.

In the simulation Sedna.gsim which is included in the install package, I wanted to re-create an experiment performed by astronomers. The simulation called for a brown dwarf to make a hyperbolic pass of the Sun at a distance of 200 km. The brown dwarf was to have a velocity at infinity of 1 km / second.

Step 1: Use Create Objects to create an object in circular orbit around the Sun at 200 AU. Semi-major axis should be 200 AU. You can adjust the other numbers if you like. Or you can leave every value except Semi-major axis at their default values.

If your body has significant mass, set it during this step so Gravity Simulator can take its mass into account when computing a circular orbit. Otherwise, leave it as a massless test particle.

Step 2: Open a Distance & Velocity box from the View menu. Set it to Sun and your newly-created object. This will tell you your circular velocity. Velocity and Tangental velocity should be the same, and Radial velocity should be 0 if your orbit is circular. In this particular example, I get 2.158 km/s.

Step 3: Determine how much the object's velocity should be to give it your desired hyperbolic orbit. You can use the formula:

Sqrt((circularVelocity * Sqrt(2)) ^ 2 + additionalVelocity ^ 2)

Using this formula to compute a velocity which will yield 1 km / s of velocity at infinity I get:

sqrt((2.158 * sqrt(2)) ^ 2 + 1^2) = 3.212

You can also download this calculator which will do all the math for you:

Step 4: Using the View menu, open a Thrust Box and an Orbit Elements Box. Set the top object in the Thrust Box to your newly-created object, and the bottom object to the Sun. Do the same in the Orbital Elements Box.

Use the Prograde Boost buttons on the Thrust Box to increase the object's velocity to 3.212 km/s. If you overshoot your target velocity, use the Retrograde Boost buttons.

Look at the Orbital Elements Box as you are boosting your velocity. Notice that your eccentricity changes. Once it exceeds 1 you are in a hyperbolic orbit.

After following these steps, you will have an object in a hyperbolic orbit at its perihelion. I'd suggest you save the simulation at this point in case you make a mistake in the next few steps. Then you can go back to this starting point.

Step 5: In the case of the Sedna simulation I wanted the Brown Dwarf to approach the Sun rather than begin the simulation at closest approach. Using the Time Menu, set Time Backwards. Now increase the Time Step so you can see your object move. Zoom out using Screen Scale if it is not already in your view. Watch the Distance Box. Notice that the object's total velocity is decresaing. The number is slowly approaching 1 km/s.

When the object is at an acceptable distance from the Sun, set Time Forwards and save the simulation. In the Sedna simulation, it was at this point that I added the test particles orbiting Sedna. Now you can watch your object make a hyperbolic pass of the Sun.

Sorry for the confusing method. Next version may automate this for you.

I created a planetary system with a 3rd planet very much like Earth, except with 2 moons. I noticed that the point where the year changes from 1 to the next happens a little earlier with each trip around the sun. Is there any way to correct this, or am I misunderstanding how that works? I know very little about this kind of stuff and I'm terrible at math. I love the program though-it's fun to see what happens if...

What is the mass of your star? What is the mass of your planet? What is the semi-major axis of your planet? How massive are your moons? What time step are you using?

All these will affect your period. The Earth orbits the Sun in exactly 1 year... almost. There are small changes in the length of the year that make the actual orbital period differ from the calendar year. But thanks to the leap year system, which Gravity Simulator accounts for, it would take a few thousand years to add to anything significant.

If you create a planet with a semi-major axis of exactly 1 AU from a star with exactly 1 solar mass, you should get an orbit of exactly 1 year. But if you create a moon around the planet, things change. Now the important thing is the barycenter of the system. Adding the moon changes both the barycenter's position and velocity, which will affect the period. This should be negligable if your moons are not very massive, but it's fun to make binary and triple planets.

Also, the time step you use can have an effect. If you run the simulation too fast, things get out of wack quickly. If you keep your time step at or below 16384 you should get good results assuming your moons don't orbit too close to the planet. Otherwise, try a slower time step.

first - in the description of moonbuilder simulaton, it says "All collisions are elastic collisions, where the kinetic energy of the moonlets is conserved". how comes that? i though it's a classic example of non-elastic collision; energy is never conserved in such cases. momentum (m*v) should be conserved instead. or am i missing something?

second - i noticed that in simulations showcasing some saturn moons (dione for instance), you're just focusing on saturn; but scenario actually has a whole sol in it - including TPOs, asteroids, comets and stuff. for what hell are THOSE in there? they're just slowing down the simulation and good at that...

I used to get those terms mixed up when I took physics. I'll look into it. You might be right.

Feel free to delete any unnecessary objects from the simulation. It's easy to run the Saturn simulations too fast, so the extra objects slowing it down doesn't bother me. At a minimum, you should keep the Sun.

i just ran a couple of quick tests, and it seems like you are actually conserving the right thing, mistake being in moonbuilder's description

as for the scenario, well i'm just sort of suggesting that it would be better not to include unnecessary objects in the simulation from the beginning. why should i keep the sun though? i just deleted it and nothing special happened...

The Sun sets the Hill Sphere radius of the system. Notice that the outer moons act chaotically with the Sun in the simulation. That is to say that if you run the simulation long enough, they don't trace the same orbit over and over again. But if you eliminate the Sun, expanding Saturn's Hill Sphere to infinity, the outer moons, such as Phoebe, orbit in nice predictable ellipses, tracing the same orbit over and over again. In fact, there's no reason Saturn couldn't have a moon orbiting it from 1 light year away if its Hill Sphere is infinite. Try it at time step 1024. This timestep will destabalize your inner moons, but its fine for the outer moons.

2. I'm going to re-do this code because there's a bug that sometimes shows up when objects of different densities merge. But for bodies of the same density it works fine. Basically it works like this: From the size and mass of a body it determines its density. When two bodies collide, it computes their combined average density. This will be the density of the new object. From its density and mass it computes its volume, and from volume it computes its radius.

Sorry to dredge this thread up again, but I think I have a good solution to this problem: just add the volumes of the two objects together. Don't bother faffing about with densities.

Let me explain why by using an extreme example. Suppose you have two objects of equal mass: a big ball of whipped cream and a ball-bearing. If you drop the ball-bearing into the whipped cream you do not expect to end up with something smaller than the whipped-cream ball. It should be very slightly bigger.