Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

I Particle/planetary simulation with spacecraft

  1. Dec 13, 2016 #1
    I am building a spacecraft simulator in a realistic planetary environment. At the moment it uses very simple newtonian equations of motion. Each object has displacement, velocity and acceleration vectors. Each time the computer does a loop: 0.1 seconds pass and in each loop each object (planet, spacecraft, moon etc) moves along it's displacement vector (in 3D space) by exactly 0.1 seconds. The velocity vector adds the acceleration vector to it self multiplied by the time 0.1 seconds. The acceleration vector is then adjusted for all objects according to the new Center of Gravity of the entire simulation.

    The problem with this is that its not too accurate especially when you accelerate time in which case 0.1 seconds per time loop can be as large as 1 hour! Then errors will show up because the center of gravity changes every hour in a dynamic system and therefore the acceleration vector for each object should also change during that 1 hour time frame. The redisplacement of objects will also be in a straight line and they should be in a curve!

    I played with Newton's Gm1m2/rsquared force equation and extracted the acceleration equation Gm2/rsquared equation for m1's acceleration toward m2 assuming m2 is a larger body like Earth. Now I did some calculus and integrated that equation to find a way to extract the change in velocity (average acceleration) by substituting different values of "r" (distance between m1 and m2). In this case I can have an equation that tells me the change in velocity in a straight line between the rocket and earth if the rocket was falling to the earth vertically. This is a start but not useful enough for a dynamic simulator where the rocket might have a path beyond just falling straight down. Also this equation gives the change in velocity per unit distance and I need it per unit time. It also does not give me the gradual change in the acceleration vector in a dynamic situation such as a space craft flying pass a planet at high speed in which case it will be attracted toward the planet's center that will constantly change relative position to it.

    Is there a formula I can use in my computer simulator to calculate position, velocities and acceleration of N body problem with the passage of accelerated time without losing accuracy of the simulation? Or do I just have to run many 0.1 second loops more quickly in order to accelerate time or predict the future paths of all objects?

    The problem is that each of my computer loops displaces the objects linearly by assuming the accleration vector does not change in strength nor direction during that straight line transition. A more realistic loop should displace the object via a curve that anticipates the change in acceleration's magntitude and direction pull on the object during the transition from time zero to time 0.1s.

    However the simulation is reasonably accurate as long as each iteration is about 0.1 seconds, meaning that many many inferior discrete linear predictions over a short time simulates curve paths over many seconds. But that still leaves me with the problem of predicting future paths or time acceleration in my simulation.
    Last edited: Dec 13, 2016
  2. jcsd
  3. Dec 14, 2016 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    You could use ##s = vt + \frac12 at^2## instead of ##s = vt## for the displacement in a time interval. If acceleration is large, but the rate of change of acceleration is not, then that should improve the model. Especially if ##t## is not "small".
    Last edited: Dec 14, 2016
  4. Dec 14, 2016 #3


    User Avatar
    Science Advisor
    Gold Member

    This is called Euler integration. There are higher order numerical integration methods:
  5. Dec 14, 2016 #4
    Hi thanks for this, I was about to make the changes as you proposed and it turned out I was already using what you proposed. It's old code from over ten years ago so I guess I forgot that I already used the half acceleration time squared function.

    But thanks for reminding me that this is how my program indeed works, that it does use AT SQUARED. As you correctly pointed out this is only good in an environment where the acceleration doesnt change much, what would you suggest I do to compensate for changing direction and magnitude of the acceleration vector?
  6. Dec 14, 2016 #5
    I think youre on to something here, could you help me make sense of the material in the link provided? I have to brush up on my maths. So for example displacement(t)= vt * at^2, how could I improve upon that using the wisdom provided in the link? Do I integrate the function and then substitute?
  7. Dec 14, 2016 #6


    User Avatar
    Science Advisor
    Gold Member

    Google for code examples in your preferred language.
  8. Jan 31, 2017 #7
    Is Runge Kutta more or less computationally expensive per iteration compared to Euler?

    In otherwords, is it worth doing it? Or maybe its easier to just do more iterations of Euler
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Discussions: Particle/planetary simulation with spacecraft