What is Orbiter Space Flight Simulator?

In summary, Runge-Kutta (RK) methods are more accurate than the Euler method, but more complex to implement.
  • #36
tony873004 said:
You should start with Euler's method because it is simple and you understand it. Then if you like, you can upgrade your method later.

Definitely good advice here. Get something working so you can start having fun with it. Then worry about what is the "best" method.
 
Computer science news on Phys.org
  • #37
lzkelley said:
...I've been using Cartesian coordinates for all of my work so far, and for the actual calculations i plan to continue - but i need to be able to use keplerian orbital elements instead of state vectors for initial conditions. I was wondering if anyone out there had experience or direction on how to convert between orbital elements and state vectors besides drowning myself in geometry. Thanks!

Why do you need to use Keplerian orbital elements as your initial conditions? From JPL Horizons, you can get state vectors.

I've got code for converting both directions from state vectors to orbital elements and back again. Send me a PM if you want a copy.
 
  • #38
One thing that needs to be asked is why does accuracy matter? Are you trying to predict solar eclipses far into the future? Are you trying to pilot a spacecraft to Mars where missing by just a few kilometers will doom your mission? Or are you simply trying to demonstrate a gravity assist, Kozai mechanism, precession of nodes, etc.? For most of these accuracy isn't really that important. I'll show a few examples of tests I've performed:

This is an animation of the Moon's orbit around the Earth. It was made with Gravity Simulator's 1st order Euler's method. The time step was 16000 seconds. At this time step, the simulation is very innacurate. This would be evident if you look at the Moon's position at a known future date. For example, on August 12, 2045 there will be a total eclipse of the Sun across America. So if I paused the simulation there, I should see the Moon directly between the Earth and Sun. But with the errors introduced by the numerical method, the Moon will likely be elsewhere in its orbit at this time. However, despite the error, many features of the Moon's orbit remain accurate: Its semi-major axis has held constant. Its eccentricity and inclination remained constant as well. And its nodes still precess at their 18 year cycle known as the saros cycle, as evident in this animation. In fact, the saros cycle remains consistent no matter how large of a time step I take as long as it is slow enough that the Moon remains in its orbit.
saros.GIF
 
Last edited by a moderator:
  • #39
tony873004 said:
In the real universe, there are lots of other forces besides Newtonian gravity from point-mass sources: radiation pressure, relativity, non-spherical objects, etc. I'm guessing that errors caused by ignoring these overwhelm the errors caused by Euler's method.
No, they don't. Moreover, if your orbit simulator maintains the Moon's semimajor axis, then you are not using the basic Euler method. You are most likely using the Euler-Cromer method instead. The two methods:

Euler method
[tex]\begin{aligned}
\mathbf x(t+\Delta t) &= \mathbf x(t) + \mathbf v(t)\Delta t \\
\mathbf v(t+\Delta t) &= \mathbf v(t) + \mathbf a(\mathbf x(t))\Delta t
\end{aligned}[/tex]

Euler-Cromer method
[tex]\begin{aligned}
\mathbf v(t+\Delta t) &= \mathbf v(t) + \mathbf a(\mathbf x(t))\Delta t \\
\mathbf x(t+\Delta t) &= \mathbf x(t) + \mathbf v(t+\Delta t)\Delta t
\end{aligned}[/tex]

The two methods differ only in the calculation of the updated position vector. In the basic Euler method, the pre-update velocity is used while in Euler-Cromer, the position is updated using the post-update velocity. This slight change makes a big difference. Euler-Cromer is a symplectic integrator, meaning that it more-or-less conserves energy in situations with a time-independent Hamiltonian (e.g., gravity). The degree to which it fails to conserve energy is a function of step size and numerical errors inherent in using finite-precision arithmetic. The basic Euler method is not symplectic; orbits spiral out.
 
  • #40
Thanks for that, DH. My method updates velocity and then position. I never knew that was called Euler-Cromer. I actually made it up myself. (can we call it Euler-Cromer-Tony? :) ).

I had always heard that Euler should cause the orbits to spiral out, so I wondered why mine never did.
 
  • #41
I should add the more important problem with Euler variants is not accuracy. It is stability. For example a mass attached to a spring without any damping should oscillate forever (that's the analytical solution), but with Euler it oscillates with an increasing amplitude. No matter how small you make the integration step, the amplitude of oscillation is increasing.

4th order Runge Kutta is not so unstable. So its 3 steps are better than 3 normal steps of Euler.
 
  • #42
Ulysees said:
I should add the more important problem with Euler variants is not accuracy. It is stability. For example a mass attached to a spring without any damping should oscillate forever (that's the analytical solution), but with Euler it oscillates with an increasing amplitude. No matter how small you make the integration step, the amplitude of oscillation is increasing.
That is always a problem with the basic Euler method. It is not so much a problem with the Euler-Cromer method, which like RK4, exhibits conditionally stable (but the stability region is considerably smaller with Euler-Cromer than RK4). The simple act of updating the position with the already-updated velocity makes Euler-Cromer conditionally stable and symplectic. RK4 is considerably more stable and considerably more accurate than Euler-Cromer, but it is not symplectic.
 
  • #43
And what's the benefit of symplectic-ness?
 
  • #44
Ulysees said:
And what's the benefit of symplectic-ness?

Ignoring errors resulting from the use of finite-precision arithmetic, a symplectic integrator comes very close to conserving energy. How close depends on the order of the integrator and the product of the integrator step size and the largest critical frequency of the system. When applied to a two body system, orbits will remain at more-or-less the size and shape with a symplectic integrator.

This is not the case for non-symplectic integrators such as basic Euler or the RK methods. With Euler the deviation is immediate. Orbits spiral out quickly. With RK4 the degradation is much, much slower, but still occurs. An RK4-based integrator will be closer to truth than the simplest symplectic integrator, Euler-Cromer, when used over just a few orbits. On the other hand, using an RK4 integrator to propagate over hundreds of orbits is a bad idea. At some point the energy will have changed enough to make all results garbage. Euler-Cromer suffers from reduced accuracy but benefits from increased global stability.

Just as RK4 is much better than RK1 (i.e., Euler's method), higher-order symplectic integrators are a lot better than Euler-Cromer. Higher-order methods include Verlet methods, Forest-Ruth, and Chin. Chin's Algorithm C is the new gold standard.
 
  • #45
Your replies to my posts and Ulysees posts are very facinating. Do you have any links describing Forest-Ruth, Verlet or Chin?

Something I wanted to work on this summer was a higher order integrator for Gravity Simulator. I thought I wanted to do RK4, but you may have discouraged me from that.

Why would anybody want to use Euler's method for anything, being that if you just solve for v before you solve for x, it becomes much nicer? Didn't Euler realize this?
 
  • #46
tony873004 said:
Your replies to my posts and Ulysees posts are very facinating. Do you have any links describing Forest-Ruth, Verlet or Chin?

Something I wanted to work on this summer was a higher order integrator for Gravity Simulator. I thought I wanted to do RK4, but you may have discouraged me from that.

Why would anybody want to use Euler's method for anything, being that if you just solve for v before you solve for x, it becomes much nicer? Didn't Euler realize this?

RK4 is a very, very good single-step integrator. (All of these techniques are single-step integrators which means that they don't keep a history. The three internal steps in RK4 are all part of the same step.) RK4 is typically more accurate than all the techniques mentioned but Chin's Algorithm C. That RK4 is not symplectic only becomes a significant factor when the integration is performed over a very long time span.

Ideally your simulator should be constructed so that the propagation technique is completely independent of the rest of the simulation. You should be able to switch propagators without changing any code. This is a completely achievable task and how easily it can be done is a good test of the quality of your code. (Chin's Algorithm C is an exception as it requires the gradient of the acceleration for one internal step.)

Euler died 225 years ago. Give him a break. He predates the concept of a Hamiltonian by 100 years and predates the concept of a vector by even more than that. The simple act of using the post-update velocity to update the position looks like a dumb mistake from a mathematical perspective -- unless one looks at things from the perspective of a Hamiltonian.

As far as references,
 
Last edited by a moderator:
  • #47
Have you done any long-term simulations like the formation of a solar system? I was looking for a simulator suitable for testing Titius-Bode law.

Also, there are some who say that if a planet is hit by a large enough object or otherwise explodes, the entire solar system will collapse eventually. Any thoughts on this?
 
  • #48
D H said:
Euler died 225 years ago. Give him a break.
Fair enough. I'll cut his some slack! Thanks for the links.

Ulysees said:
Have you done any long-term simulations like the formation of a solar system? I was looking for a simulator suitable for testing Titius-Bode law.
The formation of the solar system is too complicated to simulate with point-mass n-body code. When the primordial particles are small, gravity does not play a roll. Once they're large enough for gravity to play a role, certain collisions cause them to stick together, while others break them apart. And there's millions of them. My simulator does not do very well with even hundreds of particles.

However, if you're willing to make some assumptions, there's a few simulations you can run. Check this one out. It's called "moonbuilder": http://www.orbitsimulator.com/gravity/articles/moonbuilder.html . It begins with 100 particles each with 1/50 the mass of the real moon. All collisions cause them to merge together. It only takes a few weeks for the hundred to merge together into 2 moons, one that remains in orbit, and one that gets ejected. And different starting conditions will yield different results, so if you try it again and again, you may get systems with 2 or 3 moons. The more you try it, the more you should see some trends develop.

I've tried the same thing, except placing 100 particles at 1 AU from the Sun to form a planet. Sometimes I get trojans or horseshoe objects. Again, every run is different, but long-term trends can be spotted. So if you're clever, and willing to make some simplifications and assumptions, there are definitely some things you can try.

I don't think it would do to well trying to confirm or reject Titus-Bode. You'd be trying to build multiple planets at the same time, which would require lots of particles. You could play around with "Moonbuilder", perhaps spacing the initial particles further apart, and trying to find the ideal conditions that lead to 2 or 3 stable moons, and see if there's any kind of trend to the spacing. But I'd be careful about the conclusions you draw with such a simplified model.


Ulysees said:
Also, there are some who say that if a planet is hit by a large enough object or otherwise explodes, the entire solar system will collapse eventually. Any thoughts on this?
I've heard things like Earth's presence supresses a long-term resonance between Venus and Jupiter, and without Earth, Venus would not be stable. Maybe that's what you're referring to? I'm not sure how accurate that statement is. When I heard it, the first thing I tried to do was simulate the solar system without Earth. Venus stayed put, although I only simulated for a few million years. It's possible that it takes longer than this for Venus to get ejected, and its also possible that my time step was high enough that numerical errors dominated, and I won't get an ejection no matter how long I simulate. It takes a pretty big time step to get millions of years into the future.
 
  • #49
Ιsn't it reasonable that Titius-Bode would be close to being satisfied with just 1000 particles? Why do you believe the statistics would only converge to an analytical pattern such as Titius Bode only with zillions of particles? We don't need to poll millions of voters in order to predict the outcome of an election, just a 1000 voters converge to a pattern too.
 
  • #50
That was the point I was trying to make: set up what you feel would be a representative system using fewer particles. But you need to understand how your model differs from reality. The newly-formed planets interact with the intermediate belts of trillions of lefover particles. This causes their orbits to circularize and to migrate to their final positions. That would have to be modeled too.
 
  • #51
That would have to be modeled too.

And what's stopping you from imagining a handful of planets made up from 100 particles each, rotating in a cloud of 500 other particles, and this occurring automatically starting from an initial cloud. I only want to test Titius Bode as a mathematical property that should originate from the inverse square law in any scale, atomic or galactic. Not confine it to the actual masses, distances, etc of a solar system.
 
Last edited:
  • #52
Ulysees said:
And what's stopping you...
A lack of interest in Titus-Bode prevents me from trying to verify it through simulations. But if it interests you, that doesn't need to stop you. Anyone with a Windows computer can run my simulator.

Ulysees said:
...I only want to test Titius Bode as a mathematical property that should originate from the inverse square law in any scale, atomic or galactic...

There are 6 opportunities in our solar system for Titus-Bode to be revealed: the planetary system, and 5 moon systems (>2 moons: Jupiter, Saturn, Uranus, Neptune, Pluto), none of which demonstrate Titus-Bode. The planetary system fails because there's no major planet between Mars and Jupiter, and Neptune is out of place.
 
  • #53
Modeling the formation of planetary system is a vastly more complex task than a simple orbital simulator. Planetary growth is a complex and not yet fully understood process. I assume Tony's simulator treats the planets as point masses. This is a good assumption for a stabilized system with only a small number of orbiting objects. It is not a good assumption for modeling planet growth. Tony's simulator runs on a single off-the-shelf computer. Modeling protoplanetary systems requires a lot of coupled, high powered computers because one needs to model millions of tiny particles. These little particles collide (point masses don't collide), have angular momentum due to rotation (point masses don't have angular momentum due to rotation) and exchange angular momentum with the Sun and each other. Once again, point masses don't do this.
 
  • #54
D H said:
...I assume Tony's simulator treats the planets as point masses...These little particles collide (point masses don't collide),..

They're treated as point masses for the sake of computing acceleration, but they do have size, so they can collide and stick. But every collision simply combines their mass and momentum into a new object if their distance is less than their combined radii. But the points you make are what I was getting at a few posts ago (#48). The real system has lots of stuff going on besides point mass interactions. There are more types of collisions than the simple one my code models. And the real system has gas that behaves differently than solid matter. So I can only agree with you that this type of a simulator is too simple for task. It doesn't mean than you can't make some assumptions and generate simplified models to explore various aspects. But to build a solar system from scratch, which you can draw confident conclusions about, is well beyond its capabilities.
 
  • #55
D H said:
I assume Tony's simulator treats the planets as point masses. This is a good assumption for a stabilized system with only a small number of orbiting objects. It is not a good assumption for modeling planet growth.

Well don't forget Newton's law of gravity only makes sense for point masses. Everything else is approximated by point masses, for the purposes of this law. Conglomerates of point masses can have angular momentum but there is no need to introduce angular momentum in the model. Just point masses connected with breakable and rejoinable spring-damper links, should be enough to model just about anything we might be interested in gravity-wise, and I think Tony is not far from this. The difficulty is with the estimation of suitable parameters for something that matches the real thing, but then we are not always interested in matching the real thing but just want to explore possibilities.

Regarding Titius-Bode that I am interested in testing, there is no reason to assume it applies exclusively to the scale of our solar system. I would expect it to also apply to much bigger and much smaller systems, because it seems to be a statistical result, like Gaussian distributions that appear in nature.

By the way, Titius-Bode -like equations predict a planet between Mars and Jupiter, and indeed there is the asteroid belt there, ie a planet that failed to form or a planet that formed and was later broken apart somehow, perhaps in a collision with a large object like the one that hit the Earth when the moon was formed.

Modeling protoplanetary systems requires a lot of coupled, high powered computers because one needs to model millions of tiny particles.

There's a simulation of the collision of the Mars sized object with the Earth when the moon was formed. Judging from the number of particles, it seems able to run on todays pc's. It ends up with the moon at the right distance from earth, and the right masses for the Earth and moon.
 
Last edited:
  • #56
Ulysees said:
Well don't forget Newton's law of gravity only makes sense for point masses.
Wrong. It is an trivial matter to compute the gravitational influence of a non-point mass body that has spherical shape and a uniform density on some object. An ellipsoidal body is not too much harder. We use complex mathematical models such spherical harmonics to describe real body such as the Earth. Some spherical harmonics models of the Earth's gravity field include http://cddis.nasa.gov/926/egm96/egm96.html" and more recent ones based on Lunar Prospector data. JPL has developed spherical harmonics models for Venus, Mars, and even some asteroids.

Regarding Titius-Bode that I am interested in testing, there is no reason to assume it applies exclusively to the scale of our solar system.
One of the cornerstones of the scientific method is the concept of falsification. Neptune falsifies the Titus-Bode law. Most astronomers view the Titus-Bode law as mere numerology. I suggest you post your concepts on this law in the scepticism and debunking forum at PF.
 
Last edited by a moderator:
  • #57
Newtons law of gravity does not apply to ellipsoid shapes last time I checked, only spherical shells are equivalent to point masses, and only on the outside (shell theorem).

But if you have proof that ellipsoid shapes are equivalent to point masses too, as required by Newton's law, I'd like to see it.

Or if you have proof that ALL spherical harmonics are equivalent to point masses for Newton's law to apply, I'd like to see it.

Cause what I have seen from my numerical calculations (in thread
Numerical integration of gravity at surface of an object
), Newton's law of gravity only matches spherical shells. And therefore it can only be used exactly for spherically symmetrical distributions of matter like an onion, everything else is by appoximation.
 
  • #58
I never said ellipsoidal shapes are equivalent to point masses. I said one can compute the gravitational attraction toward an ellipsoidal body. The gravitational attraction at some point [itex]\mathbf x[/itex] outside some body is volume integral

[tex]
\mathbf a(\mathbf x) = G\int_V \frac{\rho(\mathbf {\xi})}{||\mathbf {\xi}-\mathbf x||^3}(\mathbf {\xi}-\mathbf x)\,d{\mathbf {\xi}
[/tex]

where the integration is taken over the massive body in question.
 
  • #59
Newton's Laws: (from memory)
1. An object at rest remains at rest, or an object in motion stays in linear constant motion unless acted upon by a force.

2. F=ma
3. For every action, there is an equal but opposite reaction.

There's nothing here that excludes ellipsoids. Newton spent a lot of time developing Calculus simply so he could mathamatically justify his assumption that a sphere simplifies into a point mass. He did this by integrating the volume of a sphere. Now we can save a lot of time by using this nice shortcut. But there's no reason you can't integrate an ellipsoid, or any other shape, without going beyond Newton's laws. And if you wanted to do it numerically, if I created an ellipsoid from a collection of 1 million point masses, and then simulated a particle orbiting the ellipsoid, using Newton's laws, I imagine it would work quite nicely, showing the proper orbital precession that gives us "walking" orbits and "sun synchronous" orbits.
 
  • #60
D H said:
I never said ellipsoidal shapes are equivalent to point masses.

You said "wrong" below this:

Well don't forget Newton's law of gravity only makes sense for point masses.

Wrong.
 
  • #61
tony873004 said:
Newton's Laws: (from memory)
1. An object at rest remains at rest, or an object in motion stays in linear constant motion unless acted upon by a force.

2. F=ma
3. For every action, there is an equal but opposite reaction.

We're talking about Newton's law of gravity, not Newton's laws of motion.

But there's no reason you can't integrate an ellipsoid, or any other shape, without going beyond Newton's laws.

I've done this for a living. It's another thing we're talking about here (whether Newton's law can be used exactly in anything but point masses and equivalent spherical shells)
 
Last edited:
  • #62
Ulysees said:
You said "wrong" below this:
Ulysees said:
Well don't forget Newton's law of gravity only makes sense for point masses.
D H said:
Wrong.
That is because what you wrote is wrong.

Ulysees said:
I've done this for a living. It's another thing we're talking about here (whether Newton's law can be used exactly in anything but point masses and equivalent spherical shells)
I gave the exact answer in post #58. Whether that integral is computable in closed form or has to be approximated numerically is a different question. The integral is the exact answer to the acceleration due to gravity. BTW, this is exactly what I do for a living (one of the things I do for a living). Moreover, NASA has many people at JPL and Goddard working on developing high-precision gravity models. Until recently they used ephemeris data from satellites that had some other primary objective as the basis for these gravity models. NASA and ESA together are now flying an expensive pair of satellites whose sole objective is developing even higher-precision gravity models of the Earth. Do you think they would this just for fun?
 
  • #63
If you're referring to F=GMm/d^2, then yes, this works only for point masses. But throw a double integral symbol in front of it, with the limits of integration describing your desired shape, and you can do any shape you want. You're still applying the point mass formula GMm / d^2 (or one M for acceleration) to each differential element. And if you want something that is not uniform in density, and you have your density function, then write it the way DH did.
 
  • #64
D H said:
NASA and ESA together are now flying an expensive pair of satellites whose sole objective is developing even higher-precision gravity models of the Earth. Do you think they would this just for fun?

Certainly not, but we were talking about the formation of a solar system from dust, and you are introducing ellipsoids. Don't you think they're from another application?
 
  • #65
tony873004 said:
throw a double integral symbol in front of it, with the limits of integration describing your desired shape, and you can do any shape you want.

Not in the context of dust forming proto-planets in order to test Titius bode.

Even if an analytical formula came out from integration, you still can't use it in this context.
 
  • #66
Ulysees said:
Not in the context of dust forming proto-planets in order to test Titius bode.

I agree with you. You're not going to be using Newton's laws of gravity for dust. Objects need to be a few km wide before their gravity is significant enough to consider. I don't think it's fully understood yet, what happens prior to this point.

And that's one of many reasons why my program will have a difficult time helping you verify TB. My program is GM/d^2 inserted into an endless loop.
 
  • #67
Why don't you post a copy of your program in case anyone wants to play with it. Or have you already?
 
  • #68
Objects need to be a few km wide before their gravity is significant enough to consider.

Well you'd start with thick "dust" then, wouldn't you. Like that simulation of the formation of the moon from a collision of a large object with Earth: both objects turn into thick "dust" at places.
 
  • #69
Ulysses, please stop with the Titus-Bode law. It is numerology. No causal mechanism, and debunked by Neptune.
 
  • #70
Red cars cost more to insure in the UK. Insurance companies do not seek a cause why red cars have higher statistics for accidents. They just use the result and charge more.

So if you do not know a cause for an observed statistical trend, that does not mean no cause exists. It just means you don't know a cause yet. In trials of new drugs they give a license if the drug gives results that are "statistically significant", and they have equations for deciding if a result is

a. statistically significant (and therefore caused by the drug) or

b. not significant (and therefore just chance), and the drug is rejected.

So refusing to even simulate the formation of planets roughly in search of ANY statistical pattern (if it exists it should appear after many repeats), refusing to even test is not a scientific approach, it is dogmatic thinking that has no place in science.
 
Last edited:

Similar threads

  • Classical Physics
Replies
7
Views
825
  • Classical Physics
Replies
2
Views
1K
Replies
2
Views
770
  • Introductory Physics Homework Help
Replies
18
Views
1K
  • Programming and Computer Science
Replies
19
Views
2K
  • Science Fiction and Fantasy Media
Replies
4
Views
2K
Replies
25
Views
2K
  • Astronomy and Astrophysics
Replies
7
Views
4K
Replies
13
Views
2K
Replies
10
Views
954
Back
Top