PDA

View Full Version : orbital elements within a gravity simulator problem


CrLf
Mar30-11, 09:59 PM
hey everyone

i hope to find the answer to my troubles here :)

basically i have written a gravity simulator, it loads bodies from a file containing information on each body. using the orbital elements on each body taken from nasa's HORIZON system, i calculate the position and velocity of each body to be loaded in the simulator (currently i have data for about 30 bodies, the main planets, moons of jupiter, dwarf planets etc)

and while this system works fine, the positions/velocities are worked out ok, i have trouble converting them back accurately in certain scenarios

the equations i have work properly given the data i feed them (position/velocity) and when for example i work with a 2 body situation of sun and earth, the elements reproduce as expected, a slight change in inclination/perihelion/eccentricity/semimajoraxis as the days tick bye, but this could be attributed to rounding errors, or the fact the initial data was given based on a full-body simulation, not just 2

however my problem comes when i add the moon in. While the interactions between the two are accurate, when i come to recalculate the orbital elements of the earth, they go a little haywire

i know that the moon changes the path of the earth, and as a result it will effect the elements, but unfortunately it changes them too much for me to be able to note over time the gradual change.

the swing happens on all the elements over a period of about 20 days simulator time and is quite annoying :(

i know i could use the earth-moon barycentre to calculate the orbital elements, and that these would remain somewhat more constant, but it isnt a true reflection of the earth orbit (not to mention the oribtal elements on the horizon site are different for earth/moon barycentre) and then i have the issue of the moons elements with respect to earth, and if i use the earth-moon barycentre this will get annoying when it comes to tracking the movement of the moon away from the earth once i include tidal forces

the end goal doesnt involve earth/moon but jupiter and its moons which given the greater number of bodies will compound the problem more

how do i fix this??
should the orbital elements be calculated with respect to the bodies primary body (ie earth-sun, moon-earth) rather than the barycentre of the system, ie earth-sun system barycentre instead of the sun's position

CrLf
Apr1-11, 06:34 PM
come on guys, over 80 views, someone must have an idea :(

Drakkith
Apr1-11, 09:09 PM
I think you have run into the problem that has plagued astronmers for centuries!! Put simply, you would have to calculate the forces acting on every object from every other object at every point in time to be accurate, and that simply isn't really possible. You can only be accurate to a certain degree.

IsometricPion
Apr1-11, 10:16 PM
2 body situation of sun and earth, the elements reproduce as expected, a slight change in inclination/perihelion/eccentricity/semimajoraxis as the days tick byeI obviously don't know the specifics of how you programmed this simulation, but none of the four properties you mentioned should change when there are only two bodies being simulated (assuming you are referring to a slight change in the values your simulation produces rather than those values as compared to the ones on the HORIZON site). (except due to rounding error of course)i know i could use the earth-moon barycentre to calculate the orbital elements, and that these would remain somewhat more constant, but it isnt a true reflection of the earth orbit (not to mention the oribtal elements on the horizon site are different for earth/moon barycentre) and then i have the issue of the moons elements with respect to earth, and if i use the earth-moon barycentre this will get annoying when it comes to tracking the movement of the moon away from the earth once i include tidal forcesPerhaps you could average the values over the course of a month (as determined by the Moon's orbit). Or do a fourier transform on the output data and subtract the component with the the offending periodicity.the swing happens on all the elements over a period of about 20 days simulator time and is quite annoying :(Have you tried changing the time step/accuracy? If changing the time step (perhaps by 50% or a factor of 2) does not change the phenomenon, it probably is not due to rounding error. In the past I have calculated the total energy of the system at each time step. A periodicity in this (assuming it is not affected by changes in the time step) might indicate an error in the code (of course this is not likely to be practical for large numbers of objects, but for the 2 or 3 you have been modelling so far it shouldn't be too much trouble/require too many computations). Alternatively, the system's total angular momentum should be conserved and easily computable (especially for the 2-body system), so it could be used in a similar way to the energy.

tony873004
Apr1-11, 11:55 PM
...using the orbital elements on each body taken from nasa's HORIZON system, i calculate the position and velocity of each body...

Horizons will give you position and velocity if you ask properly. So no conversion is needed.
If you need to do the conversion, here's a calculator I made to convert between orbital elements and position & velocity.
http://orbitsimulator.com/formulas/OrbitalElements.html

It's a javascript, so you can see the formulas if you view the source.

CrLf
Apr2-11, 04:01 AM
hey guys

thx for the responses so far, but none of them combat the issues...

i already work out the forces between each object every iteration, there is no error in the coding or lack of accuracy
the timestep i am currently using is 1 second between calculations (no need for it to run quickly yet) so as you can imagine its pretty accurate

older versions of the sim using the same math ran just as accurately with a timestep of uip to 10000 seconds, but in this one there is more to be added which is more sensitive to the timestep

the initial; position/velocity is fine from the orbital elements, and as i said, with just 2 bodies the program works fine, and reversing the process is correct also

adding the moon changes the orbit of the earth (as expected) but also reeks havoc on the calculations for the orbital elements, which is my problem here
taking an average wont work, simply because the values i get over a period of ~20 days simply wont give me a real average, nor could i take the specific position at the start of say every year as they dont match up with initial ones as the moons orbit still has the effect

Drakkith
Apr2-11, 04:06 AM
I don't know much about this, but perhaps steps under a second are more accurate even though from 1-1000 don't change much? I would think that this would become more and more pronounced with the addition of more objects to calculate.

CrLf
Apr2-11, 03:33 PM
dude there is no problem with the accuracy of my sim, and dont concern yourself with the timestep, 1second is super accurate, regardless of how many bodies there are

the problem is converting xyz to orbital elements for the earth when the moon is affecting its orbit, and hence changing the elements from what they should be and are without the moon included.
obviously they calculate it in some manner on nasa site for example and i need to know how