# Binary Star System

## Homework Statement

I have to write a computer program to simulate a binary star system and I can not assume that the larger mass is stationary. I am given their respective masses, and the period of the system. I am just wondering how to find the write combination of initial velocity and distance that would result in a stable, closed orbit.

## Homework Equations

Not sure because I don't believe the equation for a circular orbit applies here because both masses are moving.

## The Attempt at a Solution

Don't even know where to start.

Any help with this would be greatly appreciated!

## Answers and Replies

ehild
Homework Helper
It is a two-body system, you can google it. The stars interact and there is no external force. Both stars orbit around their common centre of mass which you can consider fixed. It can be show that the problem can be reduced to a single point mass

m=(m1*m2)/(m1+m2)

orbiting around the central mass of M=m1+m2. The distance between this central mass and the orbiting one is equal to the distance between the stars.

ehild

How do I work the period into it though? The equation for orbital period is T = (2pi)sqrt(r^2/(G(M+m))) Wouldn't that mean that I get the exact same distance from the center of mass for both bodies?

ehild
Homework Helper
You have two bodies with masses m1 and m2 and, rotating around the common CM, like a dumbbell. The centre of mass is between them. How far are m1 and m2 from the CM, if the distance between the bodies is r?

There is a mistake in the period you wrote: r is on the third power.

ehild

Let's see, so I should calculate m=(m1*m2)/(m1+m2) and use that as my central mass, and then solve the the period expression for both of them, treating them each as a simple orbit around a stationary mass (m)? Then the r I would get out of each of the period expressions would be that objects distance from m? Then I can just use that in v=sqrt((G*m)/r) to get the initial velocity?

ehild
Homework Helper
The central mass is M=m1+m2. The orbiting mass is m= (m1*m2)/(m1+m2). r is the distance between the stars, r=D. The distance of m1 from the common centre of mass is r1=m2*D/(m1+m2) and that of m2 is r2=m1*D/(m1+m2). The stars are at opposite sides of the CM. The angular velocity is the same for both stars, their velocity is w*r1 and w*r2, respectively.

#### Attachments

• 5.5 KB Views: 428
Thanks for the reply! I think I almost have it but something isn't quite right.

Here is what I get when I try to run this:

And here is the code: http://pastebin.com/JBxTjqmy Even if you don't know programming, you should be able to see what I'm doing. Let me know if needs any clarification. Everything after line 28 I know already works from other programs, so I don't think the problem is there. Everything you told me is on lines 18-23

The center of mass is right in the middle and it looks like they are orbiting it, but I think the initial velocity is too small.

Last edited:
ehild
Homework Helper
Plese, give the problem.Do you need to show the motion of the stars for fixed angular velocities?

ehild

Here is the assignment:

"1. A binary star. A binary star consists of one star with a mass of 2×1030 kg and the other with
a mass of 1×1030 kg. The orbital period (time to return to the same spot) of the stars is 15 days.
Your task is to simulate the binary-star system numerically. Your code will be very similar to
that used for the moon orbiting the earth, with one important difference: now you cannot make
the approximation that the more massive star does not accelerate due to the force placed on it by
the other star. Why can you not make this assumption?"

My problem was that it needs to be a closed orbit for the period to make any sense, right?

ehild
Homework Helper
You can use the same program as in the case of the moon orbiting around a fixed earth, and calculate the separate positions of the stars by the formula for vec(r1) = m2/(m1+m2)*vec(r) and vec(r2)=-m1/(m1+m2)*vec(r). This will keep the CM at the origin.

You assumed constant angular velocity, w=2pi/T. That means the orbits are circular. For the single-body problem (like Moon orbiting around a fixed Earth) you can not assume arbitrary distance between the central star and the planet in this case. The centripetal force equals the force of gravity which means that
m r w^2 = gmM/r^2. You can choose either the period or the separation, but not both.
If you have arbitrary initial velocity and position, the orbit will not be circular and the angular velocity will change along the orbit, so that r^2*w= constant. And you have closed orbit if the total energy is negative: 1/2 mv^2-GmM/r^2<0.

ehild

Cool, thanks! That really helped.