Skip to content
Permalink
3ad1649002
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
87 lines (61 sloc) 1.93 KB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 28 11:50:24 2019
@author: nolte
Blog site: https://galileo-unbound.blog/2019/07/19/getting-armstrong-aldrin-and-collins-home-from-the-moon-apollo-11-and-the-three-body-problem/
"""
import numpy as np
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
from scipy import integrate
from matplotlib import pyplot as plt
from matplotlib import cm
import time
import os
plt.close('all')
womega = 1
R = 1
eps = 1e-6
M1 = 1
M2 = 1/10
chsi = M2/M1
x1 = -M2*R/(M1+M2)
x2 = x1 + R
def poten(y,c):
rp0 = np.sqrt(y**2 + c**2);
thetap0 = np.arctan(y/c);
rp1 = np.sqrt(x1**2 + rp0**2 - 2*np.abs(rp0*x1)*np.cos(np.pi-thetap0));
rp2 = np.sqrt(x2**2 + rp0**2 - 2*np.abs(rp0*x2)*np.cos(thetap0));
V = -M1/rp1 -M2/rp2 - E;
return [V]
def flow_deriv(x_y_z,tspan):
x, y, z, w = x_y_z
r1 = np.sqrt(x1**2 + x**2 - 2*np.abs(x*x1)*np.cos(np.pi-z));
r2 = np.sqrt(x2**2 + x**2 - 2*np.abs(x*x2)*np.cos(z));
yp = np.zeros(shape=(4,))
yp[0] = y
yp[1] = -womega**2*R**3*(np.abs(x)-np.abs(x1)*np.cos(np.pi-z))/(r1**3+eps) - womega**2*R**3*chsi*(np.abs(x)-abs(x2)*np.cos(z))/(r2**3+eps) + x*(w-womega)**2
yp[2] = w
yp[3] = 2*y*(womega-w)/x - womega**2*R**3*chsi*abs(x2)*np.sin(z)/(x*(r2**3+eps)) + womega**2*R**3*np.abs(x1)*np.sin(np.pi-z)/(x*(r1**3+eps))
return yp
r0 = 0.64
v0 = 0.3
theta0 = 0
vrfrac = 1
rp1 = np.sqrt(x1**2 + r0**2 - 2*np.abs(r0*x1)*np.cos(np.pi-theta0))
rp2 = np.sqrt(x2**2 + r0**2 - 2*np.abs(r0*x2)*np.cos(theta0))
V = -M1/rp1 - M2/rp2
T = 0.5*v0**2
E = T + V
vr = vrfrac*v0
W = (2*T - v0**2)/r0
y0 = [r0, vr, theta0, W]
tspan = np.linspace(1,2000,20000)
y = integrate.odeint(flow_deriv, y0, tspan)
xx = y[1:20000,0]*np.cos(y[1:20000,2]);
yy = y[1:20000,0]*np.sin(y[1:20000,2]);
plt.figure(1)
lines = plt.plot(xx,yy)
plt.setp(lines, linewidth=0.5)
plt.show()