Post · 6 min read· pp. 206–210

Example: Universal Variables

An Earth-centered trajectory has initial velocity of 10 km/s, initial radius of 10,000 km, and initial true anomaly of 30°. Determine the true anomaly 1 hr later, using the universal anomaly.

Solution

The general solution procedure is as follows.

  1. Determine the type of orbit
  2. Determine which eccentric anomaly is appropriate, depending on the type of orbit
  3. Determine the value of χ\chi at the later time
  4. Determine the value of the eccentric anomaly from χ\chi
  5. Determine ν\nu from the eccentric anomaly

To start, we need to identify the type of orbit. In the universal formulation, we know that if the semimajor axis is positive, the orbit is elliptical; if the semimajor axis is negative, the orbit is a hyperbola. We can find the semimajor axis from the energy equation:

a=(2r0−v02μ)−1a = \left(\frac{2}{r_0} - \frac{v_0^2}{\mu}\right)^{-1}

(294)

python
import numpy as np
from scipy.optimize import newton
import matplotlib.pyplot as plt

nu_0 = np.radians(30)
r_0 = 10_000  # km
v_0 = 10  # km/s
mu = 3.986004418E5  # km**3/s**2

a = 1 / (2 / r_0 - v_0**2 / mu)
python
from pint import UnitRegistry
import matplotlib.pyplot as plt
import numpy as np

ureg = UnitRegistry()
ureg.setup_matplotlib()
ureg.formatter.default_format = "~H"
Q_ = ureg.Quantity
a_val = Q_(round(a, 3), "km")

This gives a=a= -19654.94 km. Since the semimajor axis is negative, we know the orbit is a hyperbola. Therefore, we can solve for the eccentricity using the orbit equation for a hyperbola, in terms of the semimajor axis:

r0=ae2−11+ecos⁡ν0r_0 = a\frac{e^2 - 1}{1 + e\cos\nu_0}

(295)

Solving this equation for ee, we find:

0=e2−r0acos⁡ν0e−(1+r0a)0 = e^2 - \frac{r_0}{a}\cos\nu_0 e - \left(1 + \frac{r_0}{a}\right)

(296)

This equation is quadratic in ee, so we can use the quadratic formula to solve it. Notice that the signs of the second and third term are negative. In addition, we need to take the absolute value of the semimajor axis, because the orbit formula was developed assuming that aa was positive.

python
e = (r_0/np.abs(a) * np.cos(nu_0) + np.sqrt((-r_0 / np.abs(a) * np.cos(nu_0))**2 + 4 * (1 + r_0/np.abs(a)))) / 2
python
e_val = Q_(round(e, 5), "dimensionless")

As expected, the eccentricity e=e= 1.46823 is larger than 1 for a hyperbola.

Next, to find the universal anomaly at t0t_0 + 1 hr, we need the initial radial velocity. From Ch. 2, we know that:

vr=μhesin⁡νv_r = \frac{\mu}{h} e \sin\nu

(297)

The only unknown in this equation is hh, since we are interested in the initial radial velocity, that is, when ν=ν0\nu = \nu_0. For a hyperbola, we can find the orbital angular momentum from the hyperbolic excess velocity:

h=μv∞e2−1h = \frac{\mu}{v_{\infty}} \sqrt{e^2 - 1}

(298)

and the hyperbolic excess velocity in terms of the semimajor axis:

v∞=μav_{\infty} = \sqrt{\frac{\mu}{a}}

(299)

Note again that this formula was derived under the assumption that aa is positive, so we need to take the absolute value.

python
v_infty = np.sqrt(mu / np.abs(a))
h = mu / v_infty * np.sqrt(e**2 - 1)
v_r0 = mu / h * e * np.sin(nu_0)
python
v_r0_val = Q_(round(v_r0, 3), "km/s")

The initial radial velocity is thus vr,0=v_{r,0}= 3.075 km/s. Now we have enough information to find the universal anomaly from Kepler’s equation:

f(χ)=0=r0vr,0μχ2C(z)+(1−αr0)χ3S(z)+r0χ−μΔtf(\chi) = 0 = \frac{r_0 v_{r,0}}{\sqrt{\mu}}\chi^2 C(z) + \left(1 - \alpha r_0\right) \chi^3 S(z)+ r_0 \chi - \sqrt{\mu}\Delta t

(300)

where z=αχ2z = \alpha\chi^2. The derivative of this function is:

f′(χ)=r0vr,0μχ(1−zS(z))+(1−αr0)χ2C(z)+r0f'(\chi) = \frac{r_0v_{r,0}}{\sqrt{\mu}} \chi\left(1 - z S(z)\right) + \left(1 - \alpha r_0\right) \chi^2 C(z) + r_0

(301)

The Stumpff functions C(z)=c2(z)C(z) = c_2(z) and S(z)=c3(z)S(z) = c_3(z) are:

C(z)={1−cos⁡zz(z>0)cosh⁡−z−1−z(z<0)12(z=0)C(z) = \begin{cases}\displaystyle \frac{1 - \cos\sqrt{z}}{z} & \left(z > 0\right)\\ \displaystyle\frac{\cosh\sqrt{-z} - 1}{-z} & \left(z < 0\right) \\ \displaystyle\frac{1}{2} & \left(z = 0\right)\end{cases}

(302)

and

S(z)={z−sin⁡z(z)3(z>0)sinh⁡−z−−z(−z)3(z<0)16(z=0)S(z) =\begin{cases}\displaystyle \frac{\sqrt{z} - \sin\sqrt{z}}{\left(\sqrt{z}\right)^3} & \left(z > 0\right)\\ \displaystyle \frac{\sinh\sqrt{-z} - \sqrt{-z}}{\left(\sqrt{-z}\right)^3} & \left(z < 0\right) \\ \displaystyle \frac{1}{6} & \left(z = 0\right)\end{cases}

(303)

python
def stumpff_2(z):
    """Solve the Stumpff function C(z) = c2(z). The input z should be
    a scalar value.
    """
    if z > 0:
        return (1 - np.cos(np.sqrt(z))) / z
    elif z < 0:
        return (np.cosh(np.sqrt(-z)) - 1) / (-z)
    else:
        return 1/2

def stumpff_3(z):
    """Solve the Stumpff function S(z) = c3(z). The input z should be
    a scalar value.
    """
    if z > 0:
        return (np.sqrt(z) - np.sin(np.sqrt(z))) / np.sqrt(z)**3
    elif z < 0:
        return (np.sinh(np.sqrt(-z)) - np.sqrt(-z)) / np.sqrt(-z)**3
    else:
        return 1/6

def universal_kepler(chi, r_0, v_r0, alpha, delta_t, mu):
    """Solve the universal Kepler equation in terms of the universal anomaly chi.

    This function is intended to be used with an iterative solution algorithm,
    such as Newton's algorithm.
    """
    z = alpha * chi**2
    first_term = r_0 * v_r0 / np.sqrt(mu) * chi**2 * stumpff_2(z)
    second_term = (1 - alpha * r_0) * chi**3 * stumpff_3(z)
    third_term = r_0 * chi
    fourth_term = np.sqrt(mu) * delta_t
    return first_term + second_term + third_term - fourth_term

def d_universal_d_chi(chi, r_0, v_r0, alpha, delta_t, mu):
    """The derivative of the universal Kepler equation in terms of the universal anomaly."""
    z = alpha * chi**2
    first_term = r_0 * v_r0 / np.sqrt(mu) * chi * (1 - z * stumpff_3(z))
    second_term = (1 - alpha * r_0) * chi**2 * stumpff_2(z)
    third_term = r_0
    return first_term + second_term + third_term

Finally, we need to define the rest of the values for this function. By definition,

α=1a\alpha = \frac{1}{a}

(304)

and the initial guess for χ\chi is given by:

χi=0=μ∣α∣Δt\chi_{i=0} = \sqrt{\mu} \left\lvert\alpha\right\rvert \Delta t

(305)

python
delta_t = 1 * 3600
alpha = 1 / a
chi_0 = np.sqrt(mu) * np.abs(alpha) * delta_t
chi = newton(
    func=universal_kepler,
    fprime=d_universal_d_chi,
    x0=chi_0,
    args=(r_0, v_r0, alpha, delta_t, mu)
)
python
chi_val = Q_(round(chi, 3), "dimensionless")

With χ=\chi= 128.511, we need to relate it back to the eccentric anomaly to determine the true anomaly. The appropriate eccentric anomaly is FF, for hyperbolic trajectories. The relationship between χ\chi and FF is:

χ=−a(F−F0)\chi = \sqrt{-a} \left(F - F_0\right)

(306)

where F0F_0 is the eccentric anomaly determined at the initial true anomaly:

F0=2tanh⁡−1(e−1e+1tan⁡ν02)F_0 = 2 \tanh^{-1}\left(\sqrt{\frac{e - 1}{e + 1}}\tan\frac{\nu_0}{2}\right)

(307)

python
F_0 = 2. * np.arctanh(np.sqrt((e - 1) / (e + 1)) * np.tan(nu_0 / 2))
python
F_0_val = Q_(round(F_0, 3), "dimensionless")

The initial eccentric anomaly is F0=F_0= 0.234. Then, we can solve for FF and relate that back to ν\nu:

F=χ−a+F0F = \frac{\chi}{\sqrt{-a}} + F_0

(308)

and

ν=2tan⁡−1(e+1e−1tanh⁡F2)\nu = 2 \tan^{-1} \left(\sqrt{\frac{e + 1}{e - 1}}\tanh\frac{F}{2}\right)

(309)

python
F = chi / np.sqrt(-a) + F_0
nu = 2 * np.arctan(np.sqrt((e + 1) / (e - 1)) * np.tanh(F / 2))

The true anomaly after one hour is ν=\nu= 100.04 deg.