A Computer Program For Interplanetary Gravity-Assist Trajectory Design and Optimization (Fortran)
A Computer Program For Interplanetary Gravity-Assist Trajectory Design and Optimization (Fortran)
This document describes a Windows compatible Fortran computer program called flyby_ftn
that can be used to design and optimize interplanetary trajectories that include a single gravity
assist maneuver. The user specifies the launch, flyby and destination planets, and the desired
flyby altitude. The algorithm also requires initial guesses for the launch, flyby and arrival
calendar dates along with lower and upper search bounds about these dates. This script searches
for a patched-conic gravity-assist trajectory that satisfies the flyby mission constraints (V
matching and user-defined flyby altitude) and minimizes the launch, arrival or total impulsive
delta-v for the mission. The type of delta-v optimization is specified by the user.
The planet positions and velocities are modeled using the JPL DE 421 ephemeris. The trajectory
optimization is performed with a nonlinear programming (NLP) algorithm.
Program execution
An input file created by the user can be run from the command line or a simple batch file with a
statement similar to the following:
flyby_ftn evm.in
If the software is executed without an input file on the command line, the computer program will
display the following prompt:
***********************************
* program flyby_ftn *
* *
* gravity-assist trajectory *
* design & optimization *
* *
* July 9, 2011 *
***********************************
At this point the user should input the name of a valid input file, including the filename
extension.
This section describes a typical input data file for the software. In the following discussion the
actual input file contents are in courier font and all explanations are in times italic font.
Each data item within an input file is preceded by one or more lines of annotation text. Do not
delete any of these annotation lines or increase or decrease the number of lines reserved for each
comment. However, you may change them to reflect your own explanation. The annotation line
also includes the correct units and when appropriate, the valid range of the input.
page 1
The time scale for all calculations is Barycentric Dynamical Time (TDB). The heliocentric
trajectory characteristics and impulsive delta-v maneuvers are displayed in the Earth mean
equator and equinox of J2000 (EME2000) coordinate system.
The software allows the user to specify an initial guess for the launch, flyby and arrival calendar
dates, and lower and upper bounds on the actual launch, flyby and arrival calendar dates found
during the optimization process. For any guess for launch time tL and user-defined launch time
lower and upper bounds tl and tu , the launch time t is constrained as follows:
tL tl t tL tu
Likewise, for any guess for arrival time t A and user-defined arrival time bounds tl and tu , the
arrival time t is constrained as follows:
t A tl t t A tu
For fixed launch, flyby or arrival times, the lower and upper bounds should be set to 1.0d-4.
The first six lines of any input file are reserved for user comments. These lines are ignored by the
software. However the input file must begin with six and only six initial text lines.
*****************************************************
gravity-assist interplanetary trajectory optimization
patched-conic heliocentric motion
Earth-to-Venus-to-Mars - evm.in
July 7, 2011
*****************************************************
The first numeric input for the program is an integer that specifies the type of optimization.
*******************
* simulation type *
*******************
1 = minimize launch delta-v
2 = minimize arrival delta-v
3 = minimize total delta-v
4 = no optimization
--------------------
3
The next input is the user’s guess for the departure calendar date. Please be sure to include all
four digits of the calendar year.
launch calendar date initial guess (month, day, year)
2,1,2009
The next two inputs are the lower and upper bounds, in days, for the departure date search.
launch calendar date search boundary (days)
-30, +30
page 2
The next input is the user’s guess for the flyby calendar date. Please be sure to include all four
digits of the calendar year.
flyby calendar date initial guess (month, day, year)
6,1,2009
The next two inputs are the lower and upper bounds, in days, for the flyby date search.
flyby calendar date search boundary (days)
-30, +30
The next input is the user’s guess for the arrival calendar date. Please be sure to include all four
digits of the calendar year.
arrival calendar date initial guess (month, day, year)
2,1,2010
The next two inputs are the lower and upper bounds, in days, for the arrival date search.
arrival calendar date search boundary (days)
-30, +30
page 3
The next input is an integer that specifies the arrival planet.
******************
* arrival planet *
******************
1 = Mercury
2 = Venus
3 = Earth
4 = Mars
5 = Jupiter
6 = Saturn
7 = Uranus
8 = Neptune
9 = Pluto
----------
4
The final input is the flyby altitude in kilometers relative to a spherical flyby planet.
flyby altitude (kilometers)
500.0
This section summarizes the program output for this example. The software provides the
heliocentric orbital elements of each leg of the transfer trajectory in the Earth mean equator and
equinox of J2000 (EME2000) coordinate system. These numerical results also include the
characteristics of the hyperbolic flyby trajectory with respect to the flyby planet. The time scale
is Barycentric Dynamical Time (TDB).
program flyby_ftn - gravity assist mission design
-------------------------------------------------
page 4
calendar date January 26, 2009
page 5
TDB time 08:16:39.211
page 6
TDB Julian date 2455210.64657182
FLYBY CONDITIONS
================
page 7
actual turn angle 56.2025772021421 degrees
The flyby_ftn computer program will also produce a comma-separated-variable (CSV) data
file named flyby.csv that contains important trajectory characteristics. An explanation of the
screen display and data file contents can be found in Appendix A.
The following graphs were produced using the contents of the flyby.csv data file for this
gravity assist example. The first plot is a north ecliptic view of the planetary orbits and the
heliocentric transfer trajectory in the EME2000 system.
page 8
This next plot illustrates the effect of the gravity assist on the heliocentric distance and orbital
inclination of the spacecraft’s trajectory.
This next plot illustrates the effect of the gravity assist on the heliocentric speed and semimajor
axis of the spacecraft’s trajectory.
page 9
Technical discussion
The computational steps used to create an initial guess for the spacecraft state, and the launch
and arrival delta-v characteristics are as follows:
(1) compute the state vector of the departure planet at the departure date initial guess
(2) compute the state vector of the flyby planet at the flyby date initial guess
(3) compute the state vector of the arrival planet at the arrival date initial guess
(4) solve Lambert's problem for the departure-to-flyby leg and determine the initial velocity
vector of this leg
(5) compute the launch delta-v vector from the launch planet’s velocity vector and the initial
velocity vector of the first leg of the transfer trajectory
(6) solve Lambert's problem for the second heliocentric leg and determine the initial and final
velocity vectors of the second leg
(7) compute the arrival delta-v vector from the arrival planet’s velocity vector and the final
velocity vector of the second leg of the transfer trajectory
(8) estimate the flyby incoming v-infinity vector from the flyby planet’s velocity vector and
the final velocity vector of the first leg of the transfer trajectory
Lambert’s Problem
Lambert’s problem is concerned with the determination of an orbit that passes between two
positions within a specified time-of-flight. This classic astrodynamic problem is also known as
the orbital two-point boundary value problem (TPBVP).
The time to traverse a trajectory depends only upon the length of the semimajor axis a of the
transfer trajectory, the sum ri rf of the distances of the initial and final positions relative to a
central body, and the length c of the chord joining these two positions. This relationship can be
stated as follows:
tof tof ri rf , c, a
a3
t t0 E e sin E
we can write
page 10
a3
t E E0 e sin E sin E0
where E is the eccentric anomaly associated with radius r, E0 is the eccentric anomaly at r0 , and
t 0 when r r0 .
At this point we need to introduce the following trigonometric sun and difference identities:
a
sin sin 2sin cos
2 2
a
cos cos 2sin sin
2 2
a
cos cos 2 cos cos
2 2
If we let E and E0 and substitute the first trig identity into the second equation above,
we have the following equation:
a3 E E0 E E0
t E E0 2sin e cos
2 2
E E0
e cos cos
2 2
E E0
sin sin
2 2
a3
t 2sin cos
2 2
r a 1 e cos E
x a cos E e
y a sin E 1 e 2
page 11
and some more manipulation, we have the following equations:
r r0 c r r0 c s
cos 1 1 1
2a 2a 2a a
r r0 c r r0 c sc
sin 1 1 1
2 a 2a 2a a
This part of the derivation makes use of the following three relationships:
r r0
cos cos 1
2 2 2
E E0 E E0
2
sin sin sin 1 e cos
2 2 2 2
x x0 y y0 c
2 2 2 2
sin sin
2 2 2a 2a 2a
s sc
sin sin
2 2a 2 2a
and several additional substitutions, we have the time-of-flight form of Lambert’s theorem
a3
t sin sin
A discussion about the angles and can be found in “Geometrical Interpretation of the
Angles and in Lambert’s Problem” by J. E. Prussing, AIAA Journal of Guidance and
Control, Volume 2, Number 5, Sept.-Oct. 1979, pages 442-443.
The algorithm used in this Fortran computer program is based on the method described in “A
Procedure for the Solution of Lambert’s Orbital Boundary-Value Problem” by R. H. Gooding,
Celestial Mechanics and Dynamical Astronomy 48: 145-165, 1990. This iterative solution is
valid for elliptic, parabolic and hyperbolic transfer orbits which may be either posigrade or
retrograde, and involve one or more revolutions about the central body.
page 12
Gravity-assist flight mechanics
The vector relationships between the incoming v-infinity vector v , the outgoing v-infinity
vector v and the two legs of the heliocentric transfer orbit are as follows:
v v f b v to1
v v to2 v f b
where
The turn angle of the planet-centered trajectory during the flyby is determined from
1 1 v v
1
sin 2sin 1
1 rp v /
2 2 v v
2
where rp is the periapsis radius of the flyby hyperbola, v is the magnitude of the incoming (or
outgoing) v-infinity vector and is the gravitational constant of the flyby planet.
The maximum turn angle possible during a gravity assist flyby occurs when the spacecraft just
gazes the planet’s surface. It is given by
1
max 2sin 1
1 rs v /
2
where rs is the radius of the flyby planet. The semimajor axis and orbital eccentricity of the
flyby hyperbola are given by
a / v / v
2 2
rp rp v2
e 1/ cos 1 1
a
where is the true anomaly at infinity which is determined from the following expression:
page 13
1 1 v v
sin
2 2 v v
The periapsis radius of the flyby hyperbola is determined from the expression r a 1 e and
the flyby altitude is h r rp .
The heliocentric speed gained during the flyby and the heliocentric delta-v vector caused by the
close encounter can be determined from the following two equations:
v fb 2v / e
v fb v h v h
In the second equation v h is the heliocentric velocity vector of the spacecraft prior to the flyby
and v h is the heliocentric velocity vector after the flyby. For any planet it can be shown that the
maximum heliocentric delta-v possible is given by the expression
vmax
rs
This corresponds to a “grazing” flyby at the planet’s surface and is equal to the “local circular
velocity” for the flyby planet at the surface.
During the optimization analysis, the software enforces the following two nonlinear equality
point constraints:
v v 0
h f b ht 0
The first equation is the v-infinity matching constraint and the second equation is the (positive)
flyby altitude constraint. In the second expression h f b is the actual flyby altitude and ht is the
user-defined or “targeted” flyby altitude.
The B-plane
The derivation of B-plane coordinates is described in the classic JPL reports, “A Method of
Describing Miss Distances for Lunar and Interplanetary Trajectories” and “Some Orbital
Elements Useful in Space Trajectory Calculations”, both by William Kizner. The following
diagram illustrates the fundamental geometry of the B-plane coordinate system.
page 14
The arrival asymptote unit vector Ŝ is given by
cos cos
ˆS cos sin
sin
where and are the declination and right ascension of the asymptote of the incoming or
outgoing hyperbola.
The following computational steps summarize the calculation of the B-plane vector from a
planet-centered position vector r and velocity vector v at closest approach to the flyby planet.
radius rate
r v
r
r
semiparameter
h2
p
page 15
semimajor axis
r
a
r v2
2
orbital eccentricity
e 1 p a
true anomaly
pr r h
cos sin
er e
B-plane magnitude
B pa
fundamental vectors
r v r r
zˆ
h
pˆ cos rˆ sin zˆ
qˆ sin rˆ cos zˆ
S vector
a b
S pˆ qˆ
a 2 b2 a 2 b2
B vector
b2 ab
B pˆ qˆ
a b
2 2
a b2
2
T vector
S , S x2 ,0
2 T
T
y
S x2 S y2
R vector
R S T S zTy , S zTx , S xTy S yTx
T
page 16
References and bibliography
“Gravity-Assist Trajectory Design with MATLAB”, C. David Eagle, AAS 99-138, AAS/AIAA
Space Flight Mechanics Meeting, Breckenridge, CO, February 7-10, 1999.
“Optimal Interplanetary Orbit Transfers by Direct Transcription”, John T. Betts, The Journal of
the Astronautical Sciences, Vol. 42, No. 3, July-September 1994, pp. 247-268.
“Modern Astrodynamics”, Victor R. Bond and Mark C. Allman, Princeton University Press,
1996.
“Automated Design of Gravity-Assist Trajectories to Mars and the Outer Planets”, J.M.
Longuski and S.N. Williams, Celestial Mechanics and Dynamical Astronomy, 52: 207-220,
1991.
“Notes for the Gravitational Assisted Trajectories Lectures”, E. Barrabes, G. Gomez, and J.
Rodriquez-Canabal, Advanced Topics in Astrodynamics Summer Course, Barcelona, July 2004.
page 17
APPENDIX A
Contents of the Simulation Summary and CSV Data File
This appendix is a brief summary of the information contained in the simulation summary screen
displays and the comma-separated-variable (csv) data file produced by the flyby_ftn software.
TDB julian date = julian date of trajectory event on TDB time scale
page 18
theta = orientation of the b-plane vector in degrees
page 19
rs2p2-y (au) = y-component of the flyby planet’s heliocentric position vector
in astronomical units
vs2p2-mag (au) = flyby planet heliocentric speed in astronomical units per day
page 20