Matlab Astrodynamics Library – CR3BP

Introduction to the Library

As I’m doing research I end up writing a lot of code. Most of the time it’s one-off scripts and functions for a specific task, but sometimes I do something enough that I add it to my permanent in-house library. I’ve decided to collect several of these functions related to astrodynamics, remove some functionality, make them more user-friendly, and host them on a Github Repo. The main page for this project can be found here

This post will go over the functions relating to the Circular Restricted 3 Body Problem (CR3BP)

CR3BP Background

An introduction on the CR3BP can be found here and a full series of posts on the CR3BP can be found here. In short, the CR3BP deals with 3 body systems where one mass is much smaller than the other two and the two larger masses are in circular orbits about their combined barycenter. Three examples of this type of system would be an Earth-Moon-Spacecraft system, a Sun-Earth-Moon system, or a Sun-Jupiter-Asteroid system.

Note: Here are some good books on astrodynamics in general (Book 1Book 2Book 3Book 4).

Functions List & Description

celestialLookUp – takes in the name of a celestial object and returns a cell array of pertinent information

jacobiValueDiff – Calculates the Jacobi value difference in the CR3BP

jacobiValue3D – Calculates the Jacobi value of a state in the CR3BP

lagrangePoints – Calculates the positions of the Lagrange points in the rotating frame using the hill radius approximation.

plotOther – Function for plotting other general system points of interest.

rotFrame3D – CR3BP rotating frame dynamics function, to be used with Matlab ODE suite

rotFrame3dSTM- CR3BP rotating frame  dynamics and State Transition matrix function to be used with Matlab ODE suite

stats2Body – takes in the name of a celestial object and returns a cell array of pertinent information.

ExampleScript – Not a function, this script is designed to provide an example of how to use different functions in the Matlab Astrodynamics Library CR3BP

Change in Jacobi Value and ODE45

You’ll notice that in the ExampleScript I use ODE45 to propagate the spacecraft’s trajectory forward.

trajProp.png

We know that the Jacobi value should be constant over our trajectory, so let’s plot it alongside our trajectory

trajPropJacobi

What gives? Why isn’t it constant. It seems to meander in a semi-regular fashion? This is because I am using ODE45, which is a Runge-Kutta integrator. It is not Symplectic! you’ll notice that I set the tolerance for ODE45 to be very tight so the change in Jacobi value is on the order of machine precision, but had I not done that the Jacobi value would vary greatly over the trajectory. This is something you have to always keep in mind with numerical simulations non-symplectic integrators like ODE45! Now that we know why it’s varying, what’s causing the pattern to appear? I’ve plotted the absolute normalized change in Jacobian along with the normalized distance from the primary below.

jacobiPos.png

We can see that whenever the spacecraft gets closest to the primary we can see a spike in the Jacobi value. This means the closer we get to a major body, the more careful we have to be about our Jacobi value varying.

Want more Gereshes

If you want to receive the weekly Gereshes blog post directly to your email every Monday morning, you can sign up for the newsletter here! Don’t want another email? That’s ok, Gereshes also has a twitter account and subreddit!