Skip to main content
Tried to adjust the wording to focus in on the issues that are common with this site's on-topicness
Source Link
uhoh
  • 151k
  • 56
  • 505
  • 1.6k

I am working on java applications for interaction between objects. Fortrying to understand how to calculate the space objects (sun, planets and their moons)orbits of solar system bodies in an n-body framework, it worksbased on the pair-wise gravitational attractioninteraction between themthe objects. At present, I am considering 44 objects (sun, planets, major moons and major asteroids).

Say I startam starting with Positionthe state vectors (position and velocity vectors) of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775 (JPL Horizons). as on 01/-Jan/-2017 at 00:00h. Let00 UTC and would like to let the objects interact with each othersystem evolve for 4344h (i.e till 01/07/, 01-July-2017 at 00:00h).

BasicallyI have written a program to do this in Java, and so far the results do not seem to be even reasonably close to what they should be, comparing with the state vectors obtained from Horizons. After every 2 second time step, the net gravitational force inforces on each objectbody from all of the others is calculated, and thethen in one shot update all the velocities and positions caused byare updated based on the resultant acceleration of each objectaccelerations from those net forces. Then I compare the final updated position vectors from the application with data obtained from Horizons after correcting for the Sun's updated position.

In my application, I am not differentiating between the Sun, planets and moons an still, so I am not sure why should there should be so much more error for the moons? I. I have tried even smaller calculations steps (e.g.decreasing the step size, from 2 seconds down to 0.25 seconds), still nobut there is not significant improvement.

I know, it is difficult to comment without looking atWhat might be the actual code.

I just want to know as to whether I am missing out on something.problems that I even tried to introduce a time delay for the gravitational force based on distance with noshould investigate here? Are there things that clearly need improvement (Laterright away? Or perhaps there are tests I read -without understanding - thatcan to do help diagagnose the speedprimary sources of gravity does not matter in such calculations!).error?

 

EDIT:

  Here is the gist of the calculation method as requested in comments:

I am working on java applications for interaction between objects. For the space objects (sun, planets and their moons), it works on the gravitational attraction between them. At present, I am considering 44 objects (sun, planets, major moons and major asteroids).

Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775 (JPL Horizons). as on 01/Jan/2017 at 00:00h. Let the objects interact with each other for 4344h (i.e till 01/07/2017 at 00:00h).

Basically, every 2 second step, the net gravitational force in each object is calculated and the in one shot update all the velocities and positions caused by the resultant acceleration of each object. Then I compare the final updated position vectors from the application with data obtained from Horizons after correcting for the Sun's updated position.

In my application, I am not differentiating between the Sun, planets and moons an still why should there be so much error for the moons? I have tried even smaller calculations steps (e.g. 0.25 seconds), still no improvement.

I know, it is difficult to comment without looking at the actual code.

I just want to know as to whether I am missing out on something. I even tried to introduce a time delay for the gravitational force based on distance with no improvement (Later I read -without understanding - that the speed of gravity does not matter in such calculations!).

EDIT:

  Here is the gist of the calculation method as requested in comments:

I am trying to understand how to calculate the orbits of solar system bodies in an n-body framework, based on the pair-wise gravitational interaction between the objects. At present, I am considering 44 objects (sun, planets, major moons and major asteroids).

I am starting with the state vectors (position and velocity) of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775 (JPL Horizons) 01-Jan-2017 at 00:00 UTC and would like to let the system evolve for 4344h, 01-July-2017 at 00:00h.

I have written a program to do this in Java, and so far the results do not seem to be even reasonably close to what they should be, comparing with the state vectors obtained from Horizons. After every 2 second time step the net gravitational forces on each body from all of the others is calculated, and then in one shot all the velocities and positions are updated based on the accelerations from those net forces. Then I compare the final updated position vectors from the application with data obtained from Horizons after correcting for the Sun's updated position.

In my application, I am not differentiating between the Sun, planets and moons, so I am not sure why there should be so much more error for the moons. I have tried decreasing the step size, from 2 seconds down to 0.25 seconds, but there is not significant improvement.

What might be the problems that I should investigate here? Are there things that clearly need improvement right away? Or perhaps there are tests I can to do help diagagnose the primary sources of error?

 

EDIT: Here is the gist of the calculation method as requested in comments:

edited body
Source Link
uhoh
  • 151k
  • 56
  • 505
  • 1.6k

Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775telnet ssd.jpl.nasa.gov 6775 (HorizonsJPL Horizons). as on 01/Jan/2017 at 00:00h. Let the objects interact with each other for 4344h (i.e till 01/07/2017 at 00:00h).

allItemLinksallItemLinks is collections of ItemLinkItemLink - links between objects. in this case Gravity link between all object pairs. For n objects, there will be n.(n+1)/2 links

Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775(Horizons). as on 01/Jan/2017 at 00:00h. Let the objects interact with each other for 4344h (i.e till 01/07/2017 at 00:00h).

allItemLinks is collections of ItemLink - links between objects. in this case Gravity link between all object pairs. For n objects, there will be n.(n+1)/2 links

Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775 (JPL Horizons). as on 01/Jan/2017 at 00:00h. Let the objects interact with each other for 4344h (i.e till 01/07/2017 at 00:00h).

allItemLinks is collections of ItemLink - links between objects. in this case Gravity link between all object pairs. For n objects, there will be n.(n+1)/2 links

Moved the code from the erroneously posted answer back into the question
Source Link
uhoh
  • 151k
  • 56
  • 505
  • 1.6k

I am working on java applications for interaction between objects. For the space objects (sun, planets and their moons), it works on the gravitational attraction between them. At present, I am considering 44 objects (sun, planets, major moons and major asteroids) Say.

Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775(Horizons). as on 01/Jan/2017 at 00:00h. Let Let the objects interact with each other for 4344h (iei.e till 01/07/2017 at 00:00h). Basically

Basically, every 2s2 second step, the net gravitational force in each object is calculated and the in one shot update all the velocities and positions caused by the resultant acceleration of each object. Then Then I compare the final updated position vectors from the application with data obtained from Horizons after correcting for the Sun's updated position. The

The comparison shows that the positions of Earth and the outer planets are have position error of less than 50km (In fact, the farther planets it is less then 10km). Where as for Mercury the error is 250km. And And the moons of Jupiter and Saturn are off by 50,000 to 300,000 km! In

In my application, I am not differentiating between the Sun, planets and moons an still why should there be so much error for the moons? I have tried even smaller calculations steps (0e.25sg. 0.25 seconds), still no improvement.

if any more info required from meEDIT:

Here is the gist of the calculation method as requested in comments:

while (nowT < endT) {
    doOneStep(step, nowT)
    nowT += stepT
}

allItemLinks is collections of ItemLink - links between objects. in this case Gravity link between all object pairs. For n objects, there will be gladn.(n+1)/2 links

doOneStep(double deltaT, double nowT){
    initForces fo all items to 0,0,0
    for each ItemLink **allItemLinks**)
        inf.evalForce(deltaT, false)
    updatePosAndVel(deltaT, nowT, true)
}

In ItemLink:

evalForce(double deltaT, boolean bFinal) {
    addGravityEffect(deltaT);
}

boolean addGravityEffect(double deltaT) {
    rVector = item2.pos - item1.pos
    double gF = G.mq.m2/r2
    fVector = gF in rVector direction
    item1.addForce(fVector)
    similarly for item2 to item1
}

allItems is a collection of Item objects (Sun, planets and moons)

void updatePosAndVel(double deltaT, double nowT) {
    for each Item of **allItems** updatePandV(deltaT, nowT);
}

In Item:

netForce, nowAcc, effectiveAcc, deltaV, newPos etc. are all Vector3d

updatePAndV(double deltaT, double nowT, boolean bFinal){
        nowAcc = netForce / mass
        effectiveAcc = mean of lastAcc and nowAcc
        deltaV = effectiveAcc * deltaT
        meanV ...
        newPos = oldPos + meanV * deltaT
}

Not working on gravitation fields but with direct forces due to supplyinter-object gravity.

With the above code, I am able to get stable orbits. Even the orbit times of the moons are good. Get nice Saturn set with the Cycloidal motions of moons and the Uranus set with helical motion of the moons around Uranus. I do not know as to how to send files or images for this discussion

I am working on java applications for interaction between objects. For the space objects (sun, planets and their moons), it works on the gravitational attraction between them. At present, I am considering 44 objects (sun, planets, major moons and major asteroids) Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775(Horizons). as on 01/Jan/2017 at 00:00h. Let the objects interact with each other for 4344h (ie till 01/07/2017 at 00:00h). Basically, every 2s step, the net gravitational force in each object is calculated and the in one shot update all the velocities and positions caused by the resultant acceleration of each object. Then I compare the final updated position vectors from the application with data obtained from Horizons after correcting for the Sun's updated position. The comparison shows that the positions of Earth and the outer planets are have position error of less than 50km (In fact, the farther planets it is less then 10km). Where as for Mercury the error is 250km. And the moons of Jupiter and Saturn are off by 50,000 to 300,000 km! In my application, I am not differentiating between the Sun, planets and moons an still why should there be so much error for the moons? I have tried even smaller calculations steps (0.25s), still no improvement.

if any more info required from me, will be glad to supply.

I am working on java applications for interaction between objects. For the space objects (sun, planets and their moons), it works on the gravitational attraction between them. At present, I am considering 44 objects (sun, planets, major moons and major asteroids).

Say I start with Position and velocity vectors of each of the objects with Sun as centre obtained from telnet ssd.jpl.nasa.gov 6775(Horizons). as on 01/Jan/2017 at 00:00h. Let the objects interact with each other for 4344h (i.e till 01/07/2017 at 00:00h).

Basically, every 2 second step, the net gravitational force in each object is calculated and the in one shot update all the velocities and positions caused by the resultant acceleration of each object. Then I compare the final updated position vectors from the application with data obtained from Horizons after correcting for the Sun's updated position.

The comparison shows that the positions of Earth and the outer planets are have position error of less than 50km (In fact, the farther planets it is less then 10km). Where as for Mercury the error is 250km. And the moons of Jupiter and Saturn are off by 50,000 to 300,000 km!

In my application, I am not differentiating between the Sun, planets and moons an still why should there be so much error for the moons? I have tried even smaller calculations steps (e.g. 0.25 seconds), still no improvement.

EDIT:

Here is the gist of the calculation method as requested in comments:

while (nowT < endT) {
    doOneStep(step, nowT)
    nowT += stepT
}

allItemLinks is collections of ItemLink - links between objects. in this case Gravity link between all object pairs. For n objects, there will be n.(n+1)/2 links

doOneStep(double deltaT, double nowT){
    initForces fo all items to 0,0,0
    for each ItemLink **allItemLinks**)
        inf.evalForce(deltaT, false)
    updatePosAndVel(deltaT, nowT, true)
}

In ItemLink:

evalForce(double deltaT, boolean bFinal) {
    addGravityEffect(deltaT);
}

boolean addGravityEffect(double deltaT) {
    rVector = item2.pos - item1.pos
    double gF = G.mq.m2/r2
    fVector = gF in rVector direction
    item1.addForce(fVector)
    similarly for item2 to item1
}

allItems is a collection of Item objects (Sun, planets and moons)

void updatePosAndVel(double deltaT, double nowT) {
    for each Item of **allItems** updatePandV(deltaT, nowT);
}

In Item:

netForce, nowAcc, effectiveAcc, deltaV, newPos etc. are all Vector3d

updatePAndV(double deltaT, double nowT, boolean bFinal){
        nowAcc = netForce / mass
        effectiveAcc = mean of lastAcc and nowAcc
        deltaV = effectiveAcc * deltaT
        meanV ...
        newPos = oldPos + meanV * deltaT
}

Not working on gravitation fields but with direct forces due to inter-object gravity.

With the above code, I am able to get stable orbits. Even the orbit times of the moons are good. Get nice Saturn set with the Cycloidal motions of moons and the Uranus set with helical motion of the moons around Uranus. I do not know as to how to send files or images for this discussion

edited tags
Link
uhoh
  • 151k
  • 56
  • 505
  • 1.6k
Loading
Source Link
vishu
  • 69
  • 4
Loading