1
$\begingroup$

I realized an usual way to scale an N-body problem for an N-body simulation is by choosing units such that gravitational constant $G = 1$, but I'm probably doing it the wrong way. Suppose I simply have a planet moving around the Sun (which I consider as the center of my reference frame). For example I choose

\begin{equation} M_s = M_{sun} + M_1 \tag{1} \end{equation}

\begin{equation} D_s = D_1 \tag{2} \end{equation} as my mass and distance scaling units. Than I should choose $T_s$ in such a way that my new $G$, which I call $G'$, is equal $1$. So \begin{equation} G' = 1 = \frac{1}{G} \frac{D_s^{3}}{M_sT_s^2} \tag{3} \end{equation} brings me to \begin{equation} T_s = \sqrt{\frac{D_s^3}{GM_s}} \tag{4} \end{equation}

After that, I divide masses and distances by $M_s$ and $D_s$, and velocities by $D_s/T_s$. This is what I understood from what I found about this scaling. Am i doing something wrong? I even tried different way to set $D_s$ and $M_s$, different starting units, but I always get wrong outputs.

Edit 1

This is the function I'm using (C++), with x as the vector containing velocity and position of the body moving aroun the Sun and y position vector of the Sun (considering the above example).

d = sqrt(pow((x[0] - y[0]),2) + pow((x[2] - y[1]),2) + pow((x[4] - y[2]),2));

//x system
p[0] = x[1];
p[1] = -G*m*(x[0] - y[0])/pow(d,3);
//y system
p[2] = x[3];
p[3] = -G*m*(x[2] - y[1])/pow(d,3);
//z system
p[4] = x[5];
p[5] = -G*m*(x[4] - y[2])/pow(d,3);

The equations are specific for the choosen planet, so there's only the Sun mass on the right hand side. The $G$ is equal $1$ in this case. The original dimensions are astronomic units for distances, kilograms for masses and days for times, so $[G] = \frac{AU^3}{kg\,days^2}$.

$\endgroup$
3
  • $\begingroup$ This looks all correct, up to the point where the formula is for $\frac1{G'}$ which does nothing here as $G'=1$. For more one would have to see some of the code, with the original quantities and the de-scaling process. $\endgroup$ – Lutz Lehmann Jan 10 at 16:11
  • $\begingroup$ I meant the translation of the initial data, what are the original initial position and velocity, what are the translated values? And what is the meaning of "I always get wrong outputs", what do you compare against and how far away is it? In the edit I only find the use of two index schemes slightly confusing, why not use x[0..2] also for the positions as in y[0..2], and then x[3..5] for the velocities? Apart from that it looks standard and correct. $\endgroup$ – Lutz Lehmann Jan 10 at 17:41
  • $\begingroup$ @LutzLehmann Sorry, I forgot to modify some index properly while posting the function. What I used to get was empty 3d plots or straight lines, but I just realized the problem was actually inside the de-scaling function, which was embedded in a write-on-file function. Thank you :-) $\endgroup$ – Martrin Jan 10 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.