2
votes

So I am working on a simulation of the solar system and ran into a roadblock...

In reality, the speed of the moon compared to the earth is much slower then that of the earth compared to the sun. However, the moon completes its orbit much quicker because it has to travel much less distance. The moon orbits the earth about 13 times in 1 year.

In my simulation however, the moon gets maybe 2 orbits in a year...

I've checked the speed with wikipedia and they are correct.

The only difference is that I scale everything, making me suspect that that's the cause.

All distances are devided by 100 000 and all speeds are devided by 1000

    this.angle += (speed * deltatime);

    this.x = this.semi_major_axis * Math.cos(this.angle) + this.parent.x + this.focalX;
    this.y = this.semi_minor_axis * Math.sin(this.angle) + this.parent.y + this.focalY;

Speed is the speed according to Wikipedia. (29.78 km/s for earth and 1.022 km/s for the moon)

Parent in this case means the object it is orbiting (in case of the earth, it's the sun. In case of the moon, it's the Earth)

focalX and focalY are the offset from the planet.

Speed and the 2 axis values are already scaled at this point.

Am I wrong in the manner of the scale? Am I completely missing something obvious? Am I just doing it completely the wrong way?

3
It looks like you’re using a linear speed in an angular calculation. Could that be where it’s going wrong?Brian Nixon
"Am I wrong in the manner of the scale? Am I completely missing something obvious? Am I just doing it completely the wrong way?" Yes, yes, and yes. Learn the physics.duffymo
@BrianNixon Unsure, it seemed like a good idea at the time... I got rid of all the scales and started using the original values. Now everything is moving insanely fast... So I think it does has something to do with the angular calculation.....Johan
You cannot just scale distances and expect everything to work out ok. You will have to scale Newton's gravitational constant G, and scale the masses, but not all scale linearly. To get the desired effects, maybe look at Kepler's laws and make sure the same relationships hold true as in real life.John Alexiou

3 Answers

4
votes

Since speed is distance/time (eg kilometres/second) when you scale speed by 1000 and distance by 100000 you have, whether you know it or not, scaled time by 100. Are you sure that you have taken this into account in the rest of your calculations ?

And yes, you are approaching this entirely the wrong way. If you were building a mechanical simulator you would want to scale distances quite early in the process, but in a numerical simulator why scale them at all ? Just work in the original units.

Since you don't have a computer screen which is several AU (astronomical units) across, you might have to scale the numbers for imaging but most graphics systems will do that for you at some point in the pipeline.

2
votes

I'd say you should go through the exercise of non-dimensionalizing the original equation of motion, similar to what people do with Navier-Stokes equation for fluids (it's a good example to look for). You'll see that non-dimensional groupings should turn up, like the Prandtl and Reynolds numbers for fluids, that will give you meaningful insight into the problem AND make your numerical solution more tractable.

0
votes

I don't think it'll be the scale, the simulation will do those distances 100 times quicker than is accurate (big drop in distance, small drop in speed), but it should be uniform across the board so the Earth and Moon will both speed up by the same amount, I'd look at the base speeds again and make sure they're correct and also your algorithm that calculates distance travelled.