Mercury's 3:2 Spin-Orbit Resonance

This animation page is created to visualize Mercury's 3:2 spin-orbit resonance. The animations are created using JavaScript. The Physics is explained in the animation page. This page provides information on the code used to generate the animations.

Animation Setup

The spin-orbit configurations are computed using a standard method in celestial mechanics. The numerical method is explained in detail in this pdf file. Since the spin-orbit configuration is periodic with a period = 3Prot = 2Porb = 175.938 days, we only need to calculate the configurations within this period.

As explained in the pdf file, the configuration can be constructed easily if we know the true anomaly θ(t) for -0.5Porb ≤ t < 1.5Porb. Here t=0 is defined as the time when Mercury passes perihelion. In the animation, however, time is shifted by 0.5Porb so t(animation)=0 is the same as t = -0.5Porb, corresponding to Mercury at aphelion. The reason for the shift is explained at the end of the pdf file.

The computation of θ(t) is done by a C++ code (in the cpp directory), which is a slightly modified version of a code I wrote in 2014. A python version of the code is also provided (in the python directory). The C++ code returns, among other things, an array of θ of size n equally spaced in t between -0.5Prot and 1.5Porb. The integer n is an input specified by the user. I use n=2400, which is sufficient to make smooth animations. The array is printed in the JavaScript format at the end of a data file. It is then copied and pasted to the JavaScript file mercury.js used for handling the activities in the animation page. The array is named theta_arr.

Update: the array theta_arr can now also be set up using a JavaScript function. I have ported the C++ code that computes θ(t) to a JavaScript function. It is placed at the end of mercury.js. It is currently not activated, but can be activated easily by commenting out two lines of code and uncommenting three lines of code near the beginning of mercury.js. This is useful in case one wants to change the value of n. It can now be done without re-running the C++ code. The C++ code is still useful for generating the plots in the pdf file.

Two arrays x_arr and y_arr of length n (=2400) are defined storing Mercury's x and y position for -0.5Porb ≤ t < 1.5Porb. They are computed using the equations x = r cosθ and y = r sinθ, where r = a(1 - e2)/(1 + e cosθ) is the distance between Mercury and the Sun. Here a = 0.3871 AU is Mercury's orbital semi-major axis and e = 0.2056 is Mercury's orbital eccentricity. In the code, a is set to 1 and so all distances are measured in units of a. The origin of the coordinates is placed at the position of the Sun. In this coordinate system, the center of Mercury's orbital ellipse is at x = -ae = -0.2056a and y=0. The radius of the Sun is R = 6.955×105km = 0.012a.

Animations are generated by drawing a spin-orbit configuration every 25ms. The time difference between two successive frames is set to Δt = (2/n)Porb for the default animation speed (1×). Five other animation speeds are provided on the animation page, and the time difference between two successive frames is equal to the default value multiplied by the specified factor.

Files

index.html: this html page.

mercury.html: the animation page.

mercury.js: JavaScript file for handling the activities in mercury.html

mercury.css: css file for index.html and mercury.html.

cpp/Kepler.h: provide a C++ function that solves Kepler's equation E - e sinE = M, where E is the eccentric anomaly, e is the orbital eccentricity, and M = 2πt/Porb is the mean anomaly.

cpp/Mercury-SpinOrbit.cpp: a C++ code that calculates Mercury's positions (x, y) evenly spaced in time from t = -0.5Porb to t=1.5Porb. The time resolution is Δt = (2/n)Porb, where n is an integer specified by the user. A point on Mercury's surface is chosen so that at t=0, the point is facing directly at the sun (the subsolar point). This is the magenta point P on the animation page. The phase angle phi, hour angle H and the rate of change of H as seen at point P are also calculated. The data are outputted to a file named "Mercury-SpinOrbit.dat". At the end of the file, an array of length n is printed containing the values of the true anomaly θ(t) for -0.5Porb ≤ t < 1.5Porb. The output is in the format of a JavaScript array, and so it can be directly copied and pasted to a JavaScript file.

python/Kepler.py, python/Mercury-SpinOrbit.py: python version of cpp/Kepler.h and cpp/Mercury-SpinOrbit.cpp.

docs directory: contains a LaTeX file, pdf and plots for this pdf file that explains the numerical method.