# of the Lagrange points for given values of m1, m2 # # Matlab-Monkey.com 10/10/2013 # -------------- Parameters and Initialization ----------------- # M1 = 1 # mass 1 M2 = 0.1 # mass 2 M = M1 + M2 # total mass # P = 2*math.pi * math.sqrt(R**3 / mu) # period from Kepler's 3rd law # omega0 = 2*math.pi/P # angular velocity of massive bodies # find Lagrange points and the pseudo-potential LP = lpoints(M2 / (M1 + M2)) LP1_level = potential(mu1, mu2, LP[0, 0], LP[0, 1]) LP2_level = potential(mu1, mu2, LP[1, 0], LP[1, 1]) LP3_level = potential(mu1, mu2, LP[2, 0], LP[2, 1]) # ------------------- Plotting ----------------------- # # plot zero-velocity curves that run through L1, L2, L3 plt.contour(X, Y, U, [LP1_level, LP2_level, LP3_level]) plt.hold(True) # plot m1 (yellow dot) and m2 (green dot) plt.plot(-M2 / (M1 + M2), 0, "ko", "MarkerSize", 7, "MarkerFaceColor", "y") plt.plot(M1 / (M1 + M2), 0, "ko", "MarkerSize", 5, "MarkerFaceColor", "g") # plot Lagrange points and labels
R = 1 # distance between M1 and M2 set to 1 ############# Orbital properties of two massive bodies ############# mu = G * M mu1 = G * M1 mu2 = G * M2 R10 = ([-M2 / M], [0]) # initial position of M1 R20 = ([M1 / M], [0]) # initial position of M2 P = 2 * math.pi * math.sqrt(R ** 3 / mu) # period from Kepler's 3rd law omega0 = 2 * math.pi / P # angular velocity of massive bodies (X, Y) = np.meshgrid(np.linspace(-2, 2, 100)) U = potential(mu1, mu2, X, Y) U0 = potential(mu1, mu2, 0, 1) m = 2 #map = scipy.ones(m, 3) * 8 level = [-2 - 1.96 - 1.9 - 1.7 - 1.68 - 1.64] for j in range(0, 5): plt.subplot(2, 3, j) # contourf(X,Y,U,[-5:.5:-1]) # added to level[j] in original code [0, -0.0001]
R = 1 # distance between M1 and M2 set to 1 ############# Orbital properties of two massive bodies ############# mu = G * M mu1 = G * M1 mu2 = G * M2 R10 = ([-M2 / M], [0]) # initial position of M1 R20 = ([M1 / M], [0]) # initial position of M2 P = 2 * math.pi * math.sqrt(R**3 / mu) # period from Kepler's 3rd law omega0 = 2 * math.pi / P # angular velocity of massive bodies (X, Y) = np.meshgrid(np.linspace(-2, 2, 100)) U = potential(mu1, mu2, X, Y) U0 = potential(mu1, mu2, 0, 1) m = 2 #map = scipy.ones(m, 3) * 8 level = [-2 - 1.96 - 1.9 - 1.7 - 1.68 - 1.64] for j in range(0, 5): plt.subplot(2, 3, j) # contourf(X,Y,U,[-5:.5:-1]) # added to level[j] in original code [0, -0.0001] plt.contourf(X, Y, U, level[j]) plt.hold(True)
""" ############## Parameters and Initialization ########### M1 = 1 # mass 1 M2 = 0.1 # mass 2 M = M1 + M2 # total mass P = 2*math.pi*(1 / M)**.5 # period from Kepler's 3rd law omega0 = 2*math.pi/P # angular velocity of massive bodies x = np.arange(-1.5, 1.5, .05) y = np.arange(-1.5, 1.5, .05) X,Y = np.meshgrid(x,y) # grid of (x,y) coordinates U = potential(M1, M2, X, Y) # calculate potential on grid points # define a custom, green color map to render surface plot map = np.ones(2, 3)*.7 fig = plt.figure() ax = plt.axes(projection='3d') norm = plt.Normalize() color = plt.cm.ScalarMappable(norm(map)) surf = ax.plot_surface(X, Y, U,linewidth = 0.3, rstride=1, cstride=1, facecolors= color, antialiased=True, alpha = 0) x = 0.3 #m = cm.ScalarMappable(norm=norm, cmap=)
Matlab-Monkey.com 10/10/2013 """ ############## Parameters and Initialization ########### M1 = 1 # mass 1 M2 = 0.1 # mass 2 M = M1 + M2 # total mass P = 2 * math.pi * (1 / M)**.5 # period from Kepler's 3rd law omega0 = 2 * math.pi / P # angular velocity of massive bodies x = np.arange(-1.5, 1.5, .05) y = np.arange(-1.5, 1.5, .05) X, Y = np.meshgrid(x, y) # grid of (x,y) coordinates U = potential(M1, M2, X, Y) # calculate potential on grid points # define a custom, green color map to render surface plot map = np.ones(2, 3) * .7 fig = plt.figure() ax = plt.axes(projection='3d') norm = plt.Normalize() color = plt.cm.ScalarMappable(norm(map)) surf = ax.plot_surface(X, Y, U, linewidth=0.3, rstride=1, cstride=1,
# of the Lagrange points for given values of m1, m2 # # Matlab-Monkey.com 10/10/2013 # -------------- Parameters and Initialization ----------------- # M1 = 1 # mass 1 M2 = 0.1 # mass 2 M = M1 + M2 # total mass # P = 2*math.pi * math.sqrt(R**3 / mu) # period from Kepler's 3rd law # omega0 = 2*math.pi/P # angular velocity of massive bodies # find Lagrange points and the pseudo-potential LP = lpoints(M2 / (M1 + M2)) LP1_level = potential(mu1, mu2, LP[0, 0], LP[0, 1]) LP2_level = potential(mu1, mu2, LP[1, 0], LP[1, 1]) LP3_level = potential(mu1, mu2, LP[2, 0], LP[2, 1]) # ------------------- Plotting ----------------------- # # plot zero-velocity curves that run through L1, L2, L3 plt.contour(X, Y, U, [LP1_level, LP2_level, LP3_level]) plt.hold(True) # plot m1 (yellow dot) and m2 (green dot) plt.plot(-M2 / (M1 + M2), 0, 'ko', 'MarkerSize', 7, 'MarkerFaceColor', 'y') plt.plot(M1 / (M1 + M2), 0, 'ko', 'MarkerSize', 5, 'MarkerFaceColor', 'g') # plot Lagrange points and labels plt.plot(LP[:, 0], LP[:, 1], 'k+')