Do you have
any plans to include the ability to simulate solar systems, and be
able to play with them by moving planets around to observe the
effect?
I think Gravit has alot of potential but hasn't be updated
for over 6 years - do you have plans to enhance it?
make a few changes to 'configure' and lua.c in order to get to compile
and work under Fedora 14. If I start working with the github version
are you interested in feedback/diffs required to get it working on
this platform?
--
You received this message because you are subscribed to the Google Groups "Gravit mailing list" group.
To post to this group, send email to gra...@googlegroups.com.
To unsubscribe from this group, send email to gravit+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gravit?hl=en.
I once tried to understand your
physics algorithm, and saw that the accelerations you compute (between
two particles) are wrongly dependant on the mass of _both_ particles.
The result is, that two particles will always try to spin around their
geometric center.
I'm just getting into all this, and don't know the maths involved, but
I do know that the Moon does have an effect on the Earth's orbit
(making it appear to hop around its orbit, rather than move smoothly)
so surely the mass of the Moon plays a part when calculating the
Earth's acceleration?
The calculations should resemble how the N-body problem is solved:
http://en.wikipedia.org/wiki/N-body_problem
Basically, for each iteration of time,
the influence on all the N number of bodies are calculated by
choosing each body in succession,
determining the individual influence (force) of each of the remaining
bodies on it individually,
then adding the individual force vectors into one force vector.
Once all the force vectors have been calculated for the N bodies,
the force vector for body 1 is applied to body 1.. the force vector for
body 2 is applied to body 2 etc..
and then the time interval is iterated.
Importantly, the new position of each body is not applied, until all the
bodies new positions have been calculated. Another way to say this,
each calculation within an interval uses the same body parameters
(position, mass and other values) of the same interval, before applying
the influences.
The 2-body solution is the n-body solution for 2 bodies.
Since there are only 2 bodies, calculating the influence of one body on
the other N-1 objects is the same as calculating the influence of the
other body.
The 3-body solution is the n-body solution for 3 bodies.
Since there are only 3 bodies, calculating the influence of one body on
the other N-1 objects consists of 2 sets of calculations on the one
body. That is, one set of calculations for each of the 2 remaining bodies.
A 12-body solution is the n-body solution for 12 bodies.
Since there are 12 bodies, calculating the influence of one body on the
other N-1 objects consists of 11 sets of calculations on the one body.
That is, one set of calculations for each of the 11 remaining bodies.
As the number of bodies increase, the number of calculations increase
exponentially:
body count, calculations
1 , 0
2 , 1
3 , 3 iterations, 1 for each body * 2 other bodies = 6
12 , 12 iterations, 1 for each body * 11 other bodies = 132
100 , 100 iterations, 1 for each body * 99 other bodies = 9900
N, N * (N - 1 )
Which makes the entire calculation process slow down considerably with
many bodies.
So, there are numerical shortcuts that can be made to give best
approximations.
One method is to calculate the center of gravity (and combined mass) for
all bodies, and then subtract the influence of the object that is
currently being calculated for each body, before calculating the forces
on the body.
So for a N body system, for each iteration of time, the center of
gravity of the system is calculated first (that's a set of N calculations)
Then the influence for each of the N bodies is calculated separately, by:
iterating through each of the N bodies. Call it P for following example.
first subtracting P's influence on the center of gravity of N, which
becomes the center of gravity of a particular set of (N-1) bodies. Maybe
call them N-P to indicate their uniqueness?
then calculating the influence of the center of gravity of the N-P on P.
Once the iterations are complete for determining the influences on all N
bodies, then the positions are updated for the N bodies.
This process makes the numerical calculations increase almost linearly
with the number of bodies:
1 , 0
2 , 1 + 1 + 1
3 , 2 + 1 + 1
12, 11 + 1 + 1
100, 99 + 1 + 1
N, N-1 + 1 set for (N-P) + P or N + 1 sets of calculations.
If you carefully track your calculations, you will see patterns that
will allow you to remove redundant calculations and ones that are not
significant.
cheers,
Benjamin
Gerald Kaszuba wrote:
> If you want to take a look, the code in question is at
> https://github.com/gak/gravit/blob/master/frame-pp.c#L66
>
> More specifically, line 55 to 70.
>
> Gerald
>
> On 22 April 2011 19:05, trojanfoe <troj...@gmail.com
> <mailto:troj...@gmail.com>> wrote:
>
> I'm just getting into all this, and don't know the maths involved, but
> I do know that the Moon does have an effect on the Earth's orbit
> (making it appear to hop around its orbit, rather than move smoothly)
> so surely the mass of the Moon plays a part when calculating the
> Earth's acceleration?
>
>
> --
> Gerald Kaszuba
> http://geraldkaszuba.com/
> http://twitter.com/gakman/
>
You're right.
The single center of gravity short-cut doesn't work for local bodies
with significant influence. Local bodies with significant influence
have to be calculated separately also, so instead of N-1, it's N-M,
where M is the number of bodies that have a significant influence on the
body in question. My post was quick, and working from a sad excuse for
a memory.
The center of gravity short-cut is a physical representation of caching
calculations. I'm glad to see Barnes-Hut has it all worked out:
http://en.wikipedia.org/wiki/Barnes%E2%80%93Hut_simulation
Looks like the External links section already has some C++
implementations that might be able to be adapted (with copyright vetting
and compliance.)
Anyway, there are various techniques one can employ to reduce the
overall calculation load for an N-body.
Whether sorting by proximity, or force, or a function dependent on force
and the net change of force over the last S iterations etc, the process
amounts to smartly adapting the iteration calculations to reduce the
overall calculation load.
Using some rounding, depending on significance needed to achieve
accuracy in the simulation (and not more accuracy than needed), a
programmer could add caching to a function by building a matrix or hash
of values, or even simplifying the equation in some cases, for example
by pre-mapping some parts of the calculation that are repeated more
frequently.
Hopefully, this helps inspire a smartly adapted solution for gravit.
cheers,
Benjamin