# Celestia/Tutorials/Star Systems

A large fraction of stars are found in star systems. In star systems, stars orbit each other.
This tutorial assumes you have read the previous page: Stars. It is also highly recommended that you have a basic understanding of Keplerian orbital elements and what they mean. These are the sub-parameters given in the EllipticalOrbit parameters.

## Introduction

When it is said that stars orbit each other, they technically orbit their common center of mass. This is called a "barycenter". Different pairs of stars may orbit each other in different ways:
    Various schematics of binary stars
* Two bodies with the same mass orbiting a common barycenter.
* Two bodies with a difference in mass orbiting a common barycenter external to both bodies.
* Two bodies with an extreme difference in mass orbiting a common barycenter internal to one body.
* Two bodies with the same mass orbiting a common barycenter, external to both bodies, with eccentric elliptical orbits.
A pair of stars orbiting their barycenter is called a "binary". The more massive or brighter star is called the "primary", and the less massive or less bright star is called the "secondary". Both stars orbit on opposite sides of the barycenter, although the more massive star has a smaller orbit around the barycenter. For a binary star whose stars have masses of A and B, the ratio of the semimajor axes (of the star orbiting the binary) is B to A.
However, in real life the barycenter is invisible so astronomers often treat the system as if the secondary orbits the primary, instead of both the primary and secondary orbiting the barycenter. So instead of two different semimajor axis values (for each star), astronomers will often give a single semimajor axis value, which is the sum of those two values. The individual values can be found using the component masses, using the ratio mentioned above.
The orbital period, the total semimajor axis, and the total mass are all related to each other (and can be calculated if two are known) using Kepler's third law:
    $T^{2}={\frac {4\pi ^{_{2}}}{GM}}a^{3}$
where $T$ is the period, $G$ is the gravitational constant, $M$ is the sum of the masses, and $a$ is the sum of the semimajor axes. Make sure that when doing a calculation, all your units are compatible with each other.

### Multiple star systems

While two-body systems are stable, generally systems with three or more bodies tend to be chaotic. A three-body system is generally stable if there is a close binary pair, and a third star that orbits further out. The close binary pair can be approximated as a single object.
This "hierarchical" arrangement can be extended to create multiple star systems with even more stars. However, in real life you will typically only see systems with up to six or seven stars. This is because the more stars, the more likely the system is to fall apart from internal perturbations.

## Basic definition

The basic definition looks like this:

## List of parameters

Most of the parameters are described in Stars, however the new ones are described below.

### Name

Putting Barycenter in front of the name will turn the object into a barycenter. In the case that the object has a HIP/TYC index number, then Barycenter will go before the index, like this:

### OrbitBarycenter

This tells Celestia to put the object in orbit around "Name". The orbit must be defined using the EllipticalOrbit block.
By putting a barycenter in orbit around another barycenter, it is possible to create hierarchical systems in Celestia.

### EllipticalOrbit

This is the orbital definition. Note that the Period must be in years, and the SemiMajorAxis must be in astronomical units.
Within a binary star system, most of the two stars' orbital parameters will be identical. The exceptions are SemiMajorAxis and ArgOfPericenter. Recall that the semimajor axes of the stars' orbits around the barycenter depend on the masses. To put the stars on opposite sides of the barycenter, the ArgOfPericenter values must be 180 degrees apart.

#### Reference frames

A common mistake is to simply input the Inclination, AscendingNode, and ArgOfPericenter values from the literature directly into the EllipticalOrbit block. This results in the orbit being oriented incorrectly in 3D space. Why is this?
This is because Celestia uses the EclipticJ2000 system for all its orbits, whereas astronomers use the plane-of-sky as a reference frame. In the ecliptic system, an orbit with an inclination of 0 would be in the same plane as the ecliptic. In the plane-of-sky system, an orbit with the inclination of 0 would appear face-on from Earth's perspective.
To convert from the plane-of-sky to the ecliptic, it is necessary to use a tool such as Grant Hutchison's star orbit translation spreadsheet. This spreadsheet has several features such that it may not fit every binary system perfectly. Therefore, the different use cases are described below.

## Visual binaries

In a visual binary, the positions of the two stars is measured over time. This is usually in terms of the separation (in some angular unit like arcseconds), and the position angle of the secondary relative to the primary. The position angle is measured east of north, so think of it as degrees counterclockwise from north. (Imagine you're looking up at the sky, which is why it's reversed.)
In any case, with a visual orbit you will get the following parameters:
* The period, typically in units of days or years;
* The semimajor axis (technically the sum of the two semimajor axes), typically in angular units like arcseconds, milliarcseconds, or in some physical value like astronomical units);
* The eccentricity;
* The inclination, which is typically in degrees;
* The ascending node, which is typically in degrees;
* The argument of pericenter, which is typically in degrees and applies to the secondary;
* The epoch of periastron - a reference time in which the periastron occurred, either in Julian date or Besselian years.
Grant Hutchison's spreadsheet uses the system's distance and the angular semimajor axis to get the true semimajor axis. It also uses the period and the epoch of periastron (in fractional years) to calculate the MeanAnomaly parameter. However, if you have the periastron epoch (in Julian date) and don't want to convert that to fractional years for the spreadsheet, you can also just use that as the Epoch parameter and not specify a MeanAnomaly parameter.
Grant Hutchison's spreadsheet gives the sum of the two semimajor axes. To find the individual semimajor axes for each star, use the component masses. Also, the spreadsheet only gives one ArgOfPericenter value, which is the secondary's. To find the primary's, add 180 degrees (or subtract 180 degrees, if it gives you a value outside of the typical 0 to 360 degree range).

## Astrometric binaries

In an astrometric binary, the secondary is typically not visible. However, it is detectable in the form of the primary orbiting around its barycenter.
So for an astrometric orbit you will get the following parameters:
* The period, typically in units of days or years;
* The semimajor axis of the primary's orbit around the barycenter, typically in angular units like arcseconds, milliarcseconds, or in some physical value like astronomical units);
* The eccentricity;
* The inclination, which is typically in degrees;
* The ascending node, which is typically in degrees;
* The argument of pericenter, which is typically in degrees and applies to the primary;
* The epoch of periastron - a reference time in which the periastron occurred, either in Julian date or Besselian years.
To use Grant Hutchison's spreadsheet, use it the same way you would use it for a visual binary. But you would calculate the primary's semimajor axis using the distance, and calculate the secondary's semimajor axis using the component masses. To find the secondary's ArgOfPericenter, add 180 degrees (or subtract 180 degrees, if it gives you a value outside of the typical 0 to 360 degree range).

## Spectroscopic (and eclipsing) binaries

In these binaries, the two objects are not resolved. Instead, the primary's orbit around the barycenter is detected from the object's spectrum periodically red-shifting or blue-shifting because of the Doppler effect.
Note the difference between single-lined and double-lined spectroscopic binaries. In a single-lined binary, only the primary's spectrum can be detected. In a double-lined binary, both the primary and secondary's spectra can be detected. Typically a single-lined binary will not have enough information to be accurately rendered in Celestia, though.
For a double-lined spectroscopic orbit you will typically get the following parameters:
* The period, typically in units of days or years;
* The eccentricity;
* The argument of pericenter, which is typically in degrees and applies to the secondary;
* The epoch of periastron - a reference time in which the periastron occurred, either in Julian date or Besselian years.
You may sometimes also get $a\sin i$, which is the semi-major axis multiplied by the sine of the (plane-of-sky) inclination.
For eclipsing binaries, the inclination value can be known because one star passes in front of the other, blocking its light. If the inclination is not given but you know the masses, you can sometimes calculate the inclination:
* Use the period and the masses to calculate the true semimajor axis using Kepler's third law. This can either be the total semimajor axis or one of the components' semimajor axes, just make sure you're being consistent.
* Divide the $a\sin i$ value by the true semimajor axis - make sure you're being consistent with units and you are using the same semimajor axis value. This gives you the sine of the inclination.
* Take the arcsine (or inverse sine) of the inclination. Make sure the value is in degrees.
Then, just use Grant Hutchison's star spreadsheet like before, with the inclination value you got. With spectroscopic binaries, it is impossible to know the longitude of the ascending node without resolving it. It is customary to enter in 0 for that value.

### Short-period binaries

For some binaries, notably eclipsing binaries with short periods, the eccentricity is 0 so there is no periastron. In that case, the reference epoch may instead be $T_{min}$, which is the epoch of the primary minimum. This is the time at which the dimmer star is directly in front of the brighter star (from Earth's viewpoint), so it is blocking the most light (hence the term minimum). In Celestia, you would set the Epoch values for both stars to be $T_{min}$, and then set the MeanAnomaly to be 90. To test that the eclipse timings are accurate, travel to the system from Earth (or anywhere within the Solar System) and set the time to your $T_{min}$. If the dimmer star is in front of the brighter star, then that is the primary minimum and your code is correct.

## Testing your code

It is recommended to test your star system code in Celestia to see if it works. For example, for visual orbits to test that the orientation is correct, travel from the Solar System to your system and with the left and right arrow keys, turn the system around so that it points the same way as a diagram of the system. Be careful of the direction that the diagram itself in; sometimes, north will point down. If it's oriented the same way, then the code should be correct in this aspect. This test does not apply for systems that have not been spatially resolved.
Next, set the time in Celestia to a certain reference time, such as the epoch. If the stars are in the correct position, then the code should be correct in this aspect. For visual binaries, the diagram will often show the orbit of the secondary relative to the primary. For eclipsing binaries, you can set the time to a predicted eclipse, and see if that eclipse happens.

### Fixing the radial velocities in Celestia

Finally, for systems whose orbital solutions use radial velocity measurements, you will need to fix the radial velocities within Celestia. The issue is that for a given orbit, there are two solutions that appear correct from Earth, but in one of them the periastron is pointing towards us and the in the other the periastron is pointing away from Earth. Unfortunately, astronomical conventions have been ambiguous, so even if you did everything right, you still have to check if the objects are approaching or receding at the correct times and correct them if they aren't. This is done by examining radial velocity graphs.
On the right is a radial velocity graph. The curve shows whether the object is receding or approaching us. The higher the radial velocity, the more it is receding, and the lower the radial velocity, the more it is approaching.
In the graph on the right, we can see that the graph is above the average (shown here with the dotted line) when the orbital phase = 0. Conventionally, the periastron is where the phase is 0. So in this example, the primary star is receding away from us when it is at periastron.
Now, open Celestia and travel to your system from the Solar System. Set the time to the reference time. Slowly speed up the time in Celestia until you can see the distance from the object changing (in the top left corner). If the object is receding from/approaching towards you when it should be, then that means the radial velocities are already fixed. But if it isn't, then invert the input inclination value (i.e. the value you input into Grant Hutchison's spreadsheet). For example, if the inclination was 45 degrees, input −45 degrees instead. Use the new values, and restart Celestia. You should see that the radial velocities should be fixed.