# Setting up a planetary orbit

One of the crucial questions with regard to exoplanets is the so-called 'habitability zone' - is the planet in a temperature range that permits liquid water as a pre-requisite for life?

The temperatures reached on the planet are determined not only by the question how much energy is emitted by the central star, but also by how far from the star the planet orbits, and also how much radiation that reaches the star is absorbed and how much is reflected.

The worldbuilder has a planar n-body solver with optional general-relativity corrections for orbital dynamics to determine when a planet is how close to a central star.

This tutorial assumes that you have a basic familiarity with orbital dynamics and e.g. know what orbital elements are. If that is not the case, you should familiarize yourself elsewhere with these concepts.

## Defining planet and orbit

The keywords mass and radius following a planet block describe the coarse properties of a planet. Both are in units of Earth mass and radius. Its orbit is determined by semimajor_au (the semimajor axis in astronomical units) and eccentricity (the orbital eccentricity). In short, the first parameter determines how far on average the planet orbits, the second how large the difference between closest point (periapsis) and fartherst point (apoapsis) is.

As for the other orbital elements, in a planar problem, the orbital inclination is zero by definition, and so is the longitude of the ascending node. For a two body problem, the argument of the periapsis can always be rotated to be at zero degrees, and the simulation is by default initiated with the mean anomaly zero, thus for most test cases, two elements are actually enough to set up the simulation.

The rotation of the planet around its own axis is determined by the keyword sid_rot_period_d (sidereal rotation period in days). Note that this inputs the time for a planet to rotate by 360 degrees around its axis in an absolute frame, not relative to the central body - the day to day position of the central star varies as the planet moves around its orbit, hence the perceived length of a day is different from the sidereal day.

The rotation axis of a planet can (and often is) tilted against the orbital plane. The keyword for this angle is axis_tilt (in degrees). Finally, the mean_albedo of a planet (the amount of radiation that is reflected) is a useful parameter to get a first impression of the temperature range that is found during an orbit. A real-life example of a planet definition (together with the central star is

 input star name Sun mass 1.0 T_surf 5778.0 planet name Mars mass 0.107 radius 0.532 semimajor_au 1.523 eccentricity 0.0934 axis_tilt 25.19 sid_rot_period_d 1.0259 mean_albedo 0.25 end

Running the example results in a number of data being produced:

 Mars ------ Mass [m_earth]: 0.107 Radius [R_earth]: 0.532 Mean density [g/cm^3]: 3.91818 Surface gravity [g]: 0.378439 Semimajor axis [Mkm]: 227.838 Eccentricity 0.0934 Periapsis [Mkm]: 206.558 Apoapsis [Mkm]: 249.118 Period [days]: 686.514 Rotation period [s]: 88770.4 Sid. rot. period [s]: 88637.8 Inclination [deg] 0 Thermal properties ------------------ Max. irrad. [W/m^2]: 717.327 Min. irrad. [W/m^2]: 493.163 Albedo: 0.25 T_rad periapsis [K]: 220.691 T_rad apoapsis [K]: 200.957

In particular, the code determines the rotation period (or otherwise the length of a day) as well as the radiative equilibrium temperatures at periapsis and apoapsis, which allow a first quick estimate on habitability zones.

Likewise, from the mass and radius, the surface gravity can be obtained.

## Visualizing orbits

To visualize the orbit that has just been defined, the plot_orbit keyword is used. This uses the orbital solver for a full orbital period (which has been computed from the specified elements) for a specified number of points and writes the result into a file with optionally specified name. The following definition can be used to obtain the orbit of Mars:

 plot_orbit file orbit_mars.dat npoints 10000

Here are visualized orbits for Mercury, Earth and Mars:

 Orbits of Mercury, Earth and Mars