# Creating a Gravitational 2 body simulation

• Arman777
In summary, the conversation discusses the creation of a simulation for a gravitational 2 body problem and the difficulty in defining the equations to solve numerically. The use of position vectors and the reduced mass is mentioned, as well as the importance of using numerical methods for solving differential equations. The conversation also touches on the conservation of energy in modeling physical systems.

#### Arman777

Gold Member
I am trying to create a simulation for a gravitational 2 body problem.
But I am kind of having trouble to define the equations that can be solve numerically. From an inertial frame I defined the position of the two objects as the ##\vec{r_1}## and ##\vec{r_2}## with masses ##m_1## and ##m_2##.

Let the ##\vec{R}_{CM}## be the position of the CM of the objects. Now from the perspective of the CM, we can write position vectors of the objects in terms of ##\vec{r'}_1## and ##\vec{r'}_2##.

$$\vec{r'}_1 = \frac{-m_2}{m_1 + m_2} \vec{r}~~(1)$$

and $$\vec{r'}_2 = \frac{m_1}{m_1 + m_2} \vec{r}~~(2)$$where

##\vec{r}= \vec{r'}_2 - \vec{r'}_1##

Now in this case we can use the reduced mass and define the force on this mass. So we have,

##\vec{F} = \mu \ddot{\hat{r}} = -\frac{Gm_1m_2}{r^2} \hat{r}##Now I need to solve this equation and put back into the (1) and (2) right ?

Last edited:
If you want to keep track of both position vectors separately then using the real gravitational force is more useful. The reduced mass is great if you want to treat it as one-body problem.

mfb said:
If you want to keep track of both position vectors separately then using the real gravitational force is more useful.
$$m_1\ddot{\mathbf{r}}_1=-\frac{Gm_1m_2(\mathbf{r}_1-\mathbf{r}_2)}{|\mathbf{r}_1-\mathbf{r}_2|^3}\tag{1}$$

$$m_2\ddot{\mathbf{r}}_2=-\frac{Gm_1m_2(\mathbf{r}_2-\mathbf{r}_1)}{|\mathbf{r}_2-\mathbf{r}_1|^3}\tag{2}.$$

I am new at this topic and in the above equations the left side has ##r1## but right has ##r2## and ##r1##, so It seemed harder for me to solve it in this way. Thats kind of why I tried to use reduced mass.

Arman777 said:
I am new at this topic and in the above equations the left side has ##r1## but right has ##r2## and ##r1##, so It seemed harder for me to solve it in this way.

It seems but it isn't. Even using the reduced mass you actually have three equations - one for each component of the displacement vector. In each of these equations you have one component on the left side but all three components on the right side. With separate positions you have 6 instead of three equations but the basic principle doesn't change.

Arman777
DrStupid said:
It seems but it isn't. Even using the reduced mass you actually have three equations - one for each component of the displacement vector. In each of these equations you have one component on the left side but all three components on the right side. With separate positions you have 6 instead of three equations but the basic principle doesn't change.
I see...I guess before jumping into these topics I should focus on the computational physics part, solving DE equations on computer.

I see you are a university undergraduate: can you take a course in numerical methods for solving ordinary differential equations? Or take a book in that subject out of the library? I wouldn't advise finding your way through this topic yourself. As a last resort, use a search engine with that topic , but be careful where you go from there; this one looks OK, although it doesn't seem to go far enough to cover the importance of simplectic methods (e.g. Verlet) in modelling physical systems (TL;DR the methods you cover earlier do not conserve energy, which is obviously quite important for modelling gravitational dynamics).

DEvens
pbuk said:
I see you are a university undergraduate: can you take a course in numerical methods for solving ordinary differential equations? Or take a book in that subject out of the library? I wouldn't advise finding your way through this topic yourself. As a last resort, use a search engine with that topic , but be careful where you go from there; this one looks OK, although it doesn't seem to go far enough to cover the importance of simplectic methods (e.g. Verlet) in modelling physical systems (TL;DR the methods you cover earlier do not conserve energy, which is obviously quite important for modelling gravitational dynamics).
Thanks for your thought. I ll look into them. I am studying Mark Newman Compt physics, which seems good enough for me

## 1. How does a gravitational 2 body simulation work?

A gravitational 2 body simulation is a computer model that simulates the motion of two objects, such as planets or stars, under the influence of gravity. The simulation calculates the gravitational forces between the two objects and uses this information to predict their positions and velocities over time.

## 2. What are the key factors that affect the accuracy of a gravitational 2 body simulation?

There are several key factors that can affect the accuracy of a gravitational 2 body simulation, including the precision of the initial conditions, the time step used in the simulation, and the numerical methods used to calculate the forces and positions of the objects.

## 3. Can a gravitational 2 body simulation account for other forces besides gravity?

No, a gravitational 2 body simulation only takes into account the gravitational force between the two objects. Other forces, such as electromagnetic or nuclear forces, are not included in the simulation.

## 4. How can a gravitational 2 body simulation be used in scientific research?

A gravitational 2 body simulation can be used to study the motion of celestial bodies, such as planets and their moons, and to predict their future positions and interactions. It can also be used to test theories of gravity and planetary motion.

## 5. What are some real-world applications of gravitational 2 body simulations?

Gravitational 2 body simulations have many practical applications, such as in space missions to plan trajectories and orbital maneuvers, in astrophysics to study the formation and evolution of galaxies, and in engineering to simulate the motion of satellites and other objects in space.