# How to scale down solar system data to simulatable values

Okay, I am seriously ashamed for asking this especialy when I geniualy study on physics but there is something that bugs me with the simulation I am working on.

I am re-creating the solar system in an n-body simulation that i programmed before. And I've a problem with scaling down the solar data. So even if I use kg and km for the metric units, the values are far bigger than the variables can hold in programming. Also as some of you know, bigger the value is, bigger the floating point error it makes. (error noise in data) Also it makes it slower to process.

I decided to scale down the data with a reference point, and for that, I took the earth's radius as 1 unit. And scaled down every other distance and radius according to it. (So a unit is 6371 km just to be clear)

But I am not sure whether if I should scale down the mass or not. My common sense says that I should scale down the mass so density of each body should remain same. So I took the density, and calculated a new mass value for each body, with the new scaled down radius. But I am somehow couldn't conviced myself about If it's true or not. So here I am, asking to you :) Should I also scale down the mass?

PS.1: I used using $$F = GMm/r^2$$ equation for the calculactions as usual. (Iterating it through each body pairs)

If there are other programmers like me interested in making a simulation like this, how did you accomplish this data size problem? Are there any better solutions than scaling down the values?

PS. I have created an excel file that does the scale conversion. So I am sharing the sheet in OneDrive. (http://1drv.ms/1NIekGo) If you can check my calculations and values, that I'd also be really helpful to me. Thanks for any help.

• Don't scale down anything, but do what NASA does: ilrs.gsfc.nasa.gov/docs/2014/196C.pdf, and use distances in astronomical units (AU), time in seconds, and masses in relative proportion to each other, not in kg.
– user21
Sep 22, 2015 at 1:47
• @barrycarter So which G constant format should I use in the F = GMM/r^2 equation? I mean if I use mass in relative proportions and lengths in AU, usual G consant units become obsolete. I need to convert it, but how do I do it with relative mass values? Sep 23, 2015 at 19:24
• Are you clear on how unit conversion works? For example, if you're given the value of the gravitational constant in units of meters^3 / (kilograms * seconds^2), would you know how to convert that to the value of the gravitation constant in units of AU^3 / (Earth masses * years^2)? Apr 14, 2016 at 17:20

As barrycarter mentioned in his comment, you should be more concerned with units and less with scale.

Generally, it's best to stick to conventional units that people recognize. (It will keep your head on straight and make it easier for others to review your work.) In astronomy, these are a little different than the standard SI units, since things are—shall we say—big, and numbers get out of hand quickly (as you have noted). Here are some units suggested in the Astronomical system of units Wikipedia page:

• Time: Day. This is probably not too important, so feel free to use seconds here. (After all, it's only a 5 order of magnitude difference.)
• Mass: There are several conventions, but the one I've personally seen most is solar masses. Since you're modeling our solar system, it makes a convenient reference.
• Length: I would definitely use astronomical units. (What an appropriate name!)

If you stick to these units, you should be able to limit error due to rounding and reduce the computational load of large numbers.

• Thanks for the answer. Yes, using au makes much more sense. But there is still something that bugs me. In the wiki page you linked, 1 solar mass is 1.988*E30 and GM☉ is 1.327 × E20 kg m3s−2 So it's in meters and kilogram format. As I'm using equation F=GMm/r^2; Shouldn't I convert G format to au and solar mass If I am using au in r (distance) and solar mass in body masses? I mean It's basicly same problem with the scale problem I mentioned in the main question. There is something that I can't convice myself about it, and don't know why. Sep 23, 2015 at 19:14
• To make it more clear: If you checked my excell sheet, as I am scaling down the lengths, I am also scaling down the masses, so the body densities remain same. Is this really necessary? Length and mass are two independent units, It shouldn't effect the one another when I scale the one down. But on the otherhand, density should remain same. So they are dependent to each other by density afterall? Sep 23, 2015 at 19:19
• You don't need to be concerned with density at all. Just convert your units until they have manageable scales. Sep 24, 2015 at 13:57

Consider a nearly circular orbit. On average, $v = 2 \pi r / T$, and the gravitational force balances the centrifugal force: $${G M m \over r^2} = {m v^2 \over r} = {4 \pi^2 m r \over T^2}$$ Solve for $G$ and substitute values for Earth's orbit around the Sun: $$G = {4 \pi^2 r^3 \over M T^2 } = 4 \pi^2 {\mathrm{AU}^3 \over M_{\odot} \ \mathrm{y}^2}$$ If you want day units instead, use a conversion factor to cancel the years: $$G = 39.5 {\mathrm{AU}^3 \over M_{\odot} \ \mathrm{y}^2} \left( {1 \ \mathrm{y} \over 365.25 \ \mathrm{d}} \right)^2 = 2.96 \times 10^{-4} {\mathrm{AU}^3 \over M_{\odot} \ \mathrm{d}^2}$$ The factor-label method also works if you start with the MKS value: $$G = 6.67 \times 10^{-11} \mathrm{m^3 \over kg \ s^2} \left( {1 \ \mathrm{AU} \over 1.496 \times 10^{11} \ \mathrm{m}} \right)^3 \left( {1.99 \times 10^{30} \ \mathrm{kg} \over 1 \ M_{\odot}} \right) \left( {86400 \ \mathrm{s} \over 1 \ \mathrm{d}} \right)^2 = {2.96 \times 10^{-4} {\mathrm{AU}^3 \over M_{\odot} \ \mathrm{d}^2}}$$ Validation tests will tell whether your simulation works correctly. Set up a variety of simple systems where you have a clear idea of what should happen, and then check what actually does happen.

I programmed one by myself some time ago. I used full SI units in combination with doubles (64-bit floating numbers). They work great for the scale of our solar system and are still extremly precise.

        var sun = new Star();
sun.Position = new Vector3D(0,0,0);
sun.Velocity = new Vector3D(0,0,0);
sun.Mass = 1.998855e30;

var earth = new Planet();
earth.Mass = 5.9722e24;
earth.Position = new Vector3D(0, 149.6e9, 0);
earth.Velocity = new Vector3D(29780,0,0);


The simulation itself is in the subfolder Simulation.Testing