Tuesday, February 4, 2014

Solar System Simulation

Creating a realistic simulation of a solar system has proven to be an interesting project. It seemed simple enough at first, just find out the orbital distance and speed of each planet, apply those to a particle, add the force of gravity from another particle acting as the sun, and you'll have a good simulation, right? Not quite.

First of all, what kind of units do you use? If you are getting your data from most places, you will be finding kilometers and kilograms are the standard units of measurement for nearly all aspects, and they get big fast. It gets hard to deal with every unit being either a magnitude of 20 above or below zero. How to solve the unit issue? Find one that balances all the planets, and the sun, so that nothing is too large or too small. Gigameters was a good solution for distance, being a magnitude of 6 larger than kilometers, it significantly increased the readability of numbers, bringing orbital distances into the 100s of Gms, rather than the hundred millions of Kms. Mass, on the other hand, is a much larger beast. The order of magnitude difference between the sun and the lowest mass planet, mercury, is 7. To solve this, I found that Yottagrams (e24 grams) is a viable unit for mass. While it means that the sun is still measured in the hundreds of millions, every other body in the system has a much smaller magnitude.

So, we have our units, Gigameters and Yottagrams. We put in all the data using the correct units and our planets are instantly pulled to the center.


Why would that happen? We used all the correct units for our planets, we used the actual gravitational constant, everything should work! Wait, the Gravitational Constant has units. We never converted the G from Km^3/(Kg s^2) to our new units of Gm^3/(Yg s^2). That would be our problem! The magnitude of the G is off by a few digits. Wolfram Alpha is very useful for things like this, meaning we don't need to worry about making a conversion mistake, as long as we ask for the correct units(Check it out).

With that out of the way, now we have all our units in accord, our gravity should work and lets see how it turns out.

After a little more playing around, I found that the moon does orbit the earth properly, but only when the "warp" is extremely high.

No comments:

Post a Comment