[ODE] Gravity

Chris Klein cdkode at ennui.dnsalias.net
Fri Jan 17 07:26:02 2003


[I hope this doesn't show up twice, I forgot to wear the right outgoing
email address when I replied the first time]

On Fri, 17 Jan 2003, Martin C. Martin wrote:

> > > Keep in mind though, that energy won't be conserved, so the planets will
> > > slowly spiral in toward the stars.
> >
> > Energy not conserved?  Can you elaborate?
[elided]
> down over time.  Now that I think about it, that may only be during
> collisions, so maybe your planets would spiral out rather than in.  But
> either way, don't expect quantities to be exactly conserved over long
> periods of time.
>
> A higher order integrator can reduce the error but not eliminate it.  One
> thing you can do is compute the energy before the timestep, then again at
> the end of the timestep, and adjust the resulting velocities to make them
> equal.  Same with any other property that you might want conserved.
>
> Keep in mind that preserving momentum and center of mass are easier than
> preserving energy, so maybe ODE conserves those.  (All you need is "equal
> and opposite reactions," which may or may not be a property of the
> solver.)

That's pretty interesting.  Back when I was a wee pup, I wrote a simple
force-based solar system simulator (doesn't everyone? :) ) and it was my
observation that the gravitational model (which was very simple -
accumulate forces, calculate delta-v, move, repeat) was rock-solid for
thousands of orbits in systems with several bodies in them.

Most anyone around here's going to have to be aware of the realities of
numerical inaccuracy.  I wouldn't be surprised if a bouncing-ball
simulation would see the ball come to a rest even in absence of all
friction and loss of energy.. but if the collider comes into play, then
the sim should be very stable and I would be disappointed if it were not.

That said, I wouldn't be suggesting that you use to figure out whether
that asteroid is gonna hit us in a thousand years or not!

Cheers,
--Chris