Orbital elements within a gravity simulator problem

AI Thread Summary
The gravity simulator successfully calculates positions and velocities for celestial bodies using orbital elements from NASA's HORIZON system, but struggles with accurately recalculating these elements when the Moon is included in the simulation. The interactions between the Earth and Moon complicate the orbital elements, causing significant fluctuations over a 20-day simulation period. While using the Earth-Moon barycenter could stabilize calculations, it does not reflect the true Earth orbit and complicates tracking the Moon's movement. Suggestions for resolving the issue include averaging values or adjusting the time step, but the primary challenge remains in accurately converting XYZ coordinates back to orbital elements under the influence of the Moon. The discussion emphasizes the need for a method to calculate these elements accurately despite the Moon's perturbations.
CrLf
Messages
4
Reaction score
0
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 isn't 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 doesn't 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
 
Astronomy news on Phys.org
come on guys, over 80 views, someone must have an idea :(
 
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.
 
CrLf said:
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
I 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)
CrLf said:
i know i could use the earth-moon barycentre to calculate the orbital elements, and that these would remain somewhat more constant, but it isn't 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
Perhaps 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.
CrLf said:
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.
 
CrLf said:
...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.
 
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 won't work, simply because the values i get over a period of ~20 days simply won't give me a real average, nor could i take the specific position at the start of say every year as they don't match up with initial ones as the moons orbit still has the effect
 
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.
 
dude there is no problem with the accuracy of my sim, and don't 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
 
Back
Top