Orbital Mechanics Perturbations in Julia
While I wrote up my Python orbital mechanics library port, I found a good explanation of J2 perturbations in a Stack Exchange question, J2 perturbations and orbits. This post turns that idea into Julia code you can run.
Why orbits drift
A two-body orbit is a fixed ellipse. The real Earth is not a perfect sphere. It bulges at the equator, and that extra mass pulls on a satellite. The size of the bulge is the coefficient J2, about 1.08263e-3. Two effects follow, averaged over each orbit:
- Nodal regression: the orbit plane rotates around the Earth’s axis, so the right ascension of the ascending node, written Ω, drifts.
- Apsidal rotation: the ellipse rotates within its plane, so the argument of periapsis, written ω, drifts.
The formulas
For a mean orbit with semi-major axis a, eccentricity e and inclination i, let p = a(1 − e²) and let n = sqrt(μ / a³) be the mean motion. The secular rates are:
- Ω̇ = −(3/2) J2 (Re / p)² n cos i
- ω̇ = (3/4) J2 (Re / p)² n (5 cos² i − 1)
Re is the Earth’s equatorial radius and μ is its gravitational parameter. I use μ = 398600.4418 km³/s², Re = 6378.137 km and J2 = 1.08263e-3. You can find the derivation in the perturbation chapters of Curtis, Orbital Mechanics for Engineering Students, and Vallado, Fundamentals of Astrodynamics and Applications.
The Julia code
const mu = 398600.4418 # km^3/s^2
const Re = 6378.137 # km
const J2 = 1.08263e-3
# a in km, e unitless, i in radians. Returns (Omega_dot, omega_dot) in rad/s.
function j2_rates(a, e, i)
p = a * (1 - e^2)
n = sqrt(mu / a^3)
k = J2 * (Re / p)^2 * n
return (-1.5 * k * cos(i), 0.75 * k * (5 * cos(i)^2 - 1))
end
const day = 86400 * 180 / pi # converts rad/s to degrees per dayA low Earth orbit
Take a circular orbit at a = 6778 km, which is roughly the height of the International Space Station, inclined at 51.6 degrees:
j2_rates(6778.0, 0.0, deg2rad(51.6)) .* dayI ran this on Julia 1.13.3. The output was:
(-5.002691566845427, 3.741553191838286)So the node regresses about 5.00 degrees per day, and the periapsis rotates about 3.74 degrees per day. The mean motion for this orbit is 0.0011314 rad/s, which is a period of about 92.6 minutes.
Sun-synchronous orbits
For a retrograde orbit, cos i is negative and the node moves east. Choose the inclination so that the node moves 360 degrees per year, which is 360 / 365.2422 = 0.9856 degrees per day. The orbit plane then keeps a fixed angle to the Sun. I solved for it by bisection at an altitude of 700 km:
SSO inclination at 700 km: 98.187956351951 degreesThat is the familiar inclination of about 98 degrees for sun-synchronous satellites.
The critical inclination
The apsidal rate is zero when 5 cos² i = 1. That gives two inclinations:
critical inclination: 63.43494882292201 and 116.56505117707799 degreesMolniya-type orbits use this inclination so the perigee stays in the same place. I checked it with a = 26560 km, e = 0.74 and i = 63.4 degrees:
(-0.1479330581694391, 0.00040323597419252856)The apsidal rate is 0.0004 degrees per day. It is not exactly zero because 63.4 is slightly below 63.435.
Limits
These formulas give the secular, orbit-averaged drift and nothing else:
- Short-period J2 oscillations are not included.
- J2 second-order terms are not included.
- Drag, solar radiation pressure and the pull of the Sun and Moon are not included.
- The elements are mean elements. Osculating elements, which describe the orbit at one instant, differ from them.
A mission design needs a numerical propagator. For a quick estimate of how fast a node or periapsis moves, these two formulas are enough.