Skip to content

How I create computer programs

January 12, 2012

In this blog I will talk about how I create different computer programs using MATLAB, Fortran and Numerit Pro.

Most of these computer programs rely on a suite of subroutines (Fortran) or functions (MATLAB and Numerit Pro).  These are typically short utility routines that perform a single type of calculation (coordinate transformation, evaluate a system of differential equations, etc.).  The collection of Fortran routines I call the “Orbital Mechanics with Fortran” toolbox. Likewise, for MATLAB the suite is called “Orbital Mechanics with MATLAB”.

These support routines have been used for many years and are for all practical purposes, “bullet proof”.  This means that they will always work correctly provided I give them the right information in the correct units.  This is very important when developing new applications.  If the application or main program crashes, it’s likely something in the call to these routines and not the routines themselves.  This approach makes creating complex scientific simulations much easier.

An excellent example is the computer program that solves the n-body, integrated Earth-to-Mars flight mechanics problem. This is a fairly complicated trajectory optimization problem.

The solution is achieved using the following major computational steps;

(1) solve the two-body, patched-conic interplanetary Lambert problem for the energy (C3), declination (DLA) and asymptote (RLA) of the outgoing hyperbola

(2) compute the orbital elements of the geocentric launch hyperbola and the components of the interplanetary injection delta-v vector

(3) perform geocentric orbit propagation from perigee of the geocentric launch hyperbola to the Earth’s sphere-of-influence (SOI)

(4) perform an n-body heliocentric orbit propagation from the Earth’s SOI to the B-plane at Mars encounter

(5) target to the user-defined B-plane coordinates by minimizing a heliocentric trajectory correction maneuver (TCM) at the Earth’s sphere-of-influence

The analysis results at the conclusion of each step can be displayed and checked for accuracy before going on to the next step. Of course, it is the responsibility of the programmer/analyst to determine is the results from each step are correct.

You might think of this programming approach as “divide and conquer”.

Finally, remember that numbers computed by computers are not always the right numbers.  They simply do what you tell them.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: