Repository navigation
Expand file tree
/
Copy pathEscapeAnalysis.m
More file actions
337 lines (321 loc) · 11.8 KB
/
Copy pathEscapeAnalysis.m
File metadata and controls
337 lines (321 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
%%% EscapeAnalysis.jl
%%% Jonathan LeFevre Richmond
%%% C: 22 September 2025
%%% U: 24 October 2025
clear
load('../PhDScripts/Output/EscapeAnalysis.mat')
%% Earth-Moon Data
gmE = 3.9860043543609593E5; % Earth gravitational parameter [km^3/s^2]
mE = gmE/6.67384E-20; % Earth mass [kg]
RE = 6.371008366666666E3; % Earth radius [km]
gmm = 4.9028000661637961E3; % Moon gravitational parameter [km^3/s^2]
mm = gmm/6.67384E-20; % Moon mass [kg]
Rm = 1.7374000000000003E3; % Moon radius [km]
mu = gmm/(gmE+gmm); % Mass ratio
mstar = (gmE+gmm)/6.67384E-20; % Characteristic mass [kg]
lstar = 3.8474799201129237E5; % Characteristic length [km]
tstar = sqrt(lstar^3/(gmE+gmm)); % Characteristic time [s]
% RH = 1.496557260502363E6; % Hills radius [km]
RH = 750000; % Escape radius [km]
%% Sun-B1 Data
gmS = 1.327124400419393E11; % Sun gravitational parameter [km^3/s^2]
mS = gmS/6.67384E-20; % Sun mass [kg]
RS = 6.96E5; % Sun radius [km]
gmB1 = gmE+gmm; % B1 gravitational parameter [km^3/s^2]
mB1 = gmB1/6.67384E-20; % B1 mass [kg]
muSB1 = gmB1/(gmS+gmB1); % Mass ratio
mstarSB1 = (gmS+gmB1)/6.67384E-20; % Characteristic mass [kg]
lstarSB1 = 1.4959789401764473E8; % Characteristic length [km]
tstarSB1 = sqrt(lstarSB1^3/(gmS+gmB1)); % Characteristic time [s]
%% Earth-Moon Trajectory Plot
fig1 = figure("Position", [200 100 1200 750]);
hold on
Earth = plot3DBody("Earth", RE/lstar, [-mu, 0, 0]);
set(Earth, 'DisplayName', "Earth")
Moon = plot3DBody("Moon", Rm/lstar, [1-mu, 0, 0]);
set(Moon, 'DisplayName', "Moon")
trajs = [Trajectory1, Trajectory2, Trajectory3, Trajectory4, Trajectory5, Trajectory6, Trajectory7];
for j = 1:length(trajs)
plot3(trajs(j).x(1:end-100), trajs(j).y(1:end-100), trajs(j).z(1:end-100), 'DisplayName', "Escape Traj. "+num2str(j))
end
% plot3(BCR4BPManifold.orbit.x, BCR4BPManifold.orbit.y, BCR4BPManifold.orbit.z, 'b', 'DisplayName', "BCR4BP Orbit")
plot3(CR3BPCompOrbit.x, CR3BPCompOrbit.y, CR3BPCompOrbit.z, 'r', 'DisplayName', "CR3BP Orbit")
plot3(RH/lstar*cos(linspace(0, 2*pi, 101)), RH/lstar*sin(linspace(0, 2*pi, 101)), zeros(1, 101), 'w:', 'DisplayName', "Hills Radius")
axis equal
grid on
xlabel("$x$ [EM ndim]", 'Interpreter', 'latex')
ylabel("$y$ [EM ndim]", 'Interpreter', 'latex')
zlabel("$z$ [EM ndim]", 'Interpreter', 'latex')
title("Earth-Moon Rot.", 'Interpreter', 'latex')
leg1 = legend('Location', 'bestoutside', 'Interpreter', 'latex');
set(gca, 'Color', 'k');
view(2)
hold off
% exportgraphics(fig1, 'EscapeAnalysis_1.png', 'BackgroundColor', 'k')
%% Osculating Orbital Elements
fig2 = figure("Position", [200 100 1200 750]);
t2 = tiledlayout(3,1);
t2.TileSpacing = 'compact';
t2.Padding = 'compact';
ax1 = nexttile;
hold on
ps = gobjects(size(d, 1), 1);
for j = 1:size(d, 1)
ps(j) = plot(d{j}, a_osc_S{j}, 'DisplayName', "$v_{E}="+num2str(v_esc(j))+"$");
end
xline(RH, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax1, [1.3 1.7]*1E8)
grid on
ylabel("$a_{S}$ [km]", 'Interpreter', 'latex')
title("Osculating Elements")
hold off
ax2 = nexttile;
hold on
for j = 1:size(d, 1)
plot(d{j}, e_osc_S{j}, 'HandleVisibility', 'off')
end
xline(RH, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax2, [0 0.2])
grid on
ylabel("$e_{S}$", 'Interpreter', 'latex')
hold off
ax3 = nexttile;
hold on
for j = 1:size(d, 1)
plot(d{j}, e_osc_E{j}, 'HandleVisibility', 'off')
end
xline(RH, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
yline(1, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax3, [0 10])
grid on
ylabel("$e_{E}$", 'Interpreter', 'latex')
hold off
xlabel("Earth Distance [km]", 'Interpreter', 'latex')
linkaxes([ax1, ax2, ax3], 'x')
leg2 = legend(ps);
leg2.Layout.Tile = 'east';
leg2.Interpreter = 'latex';
% exportgraphics(fig2, 'EscapeAnalysis_2.png', 'BackgroundColor', 'k')
fig3 = figure("Position", [200 100 1200 750]);
t3 = tiledlayout(3,1);
t3.TileSpacing = 'compact';
t3.Padding = 'compact';
ax1 = nexttile;
hold on
ps = gobjects(size(t, 1), 1);
for j = 1:size(t, 1)
ps(j) = plot(t{j}, a_osc_S{j}, 'DisplayName', "$v_{E}="+num2str(v_esc(j))+"$");
end
ylim(ax1, [1.3 1.7]*1E8)
grid on
ylabel("$a_{S}$ [km]", 'Interpreter', 'latex')
title("Osculating Elements")
hold off
ax2 = nexttile;
hold on
for j = 1:size(t, 1)
plot(t{j}, e_osc_S{j}, 'HandleVisibility', 'off')
end
ylim(ax2, [0 0.2])
grid on
ylabel("$e_{S}$", 'Interpreter', 'latex')
hold off
ax3 = nexttile;
hold on
for j = 1:size(t, 1)
plot(t{j}, e_osc_E{j}, 'HandleVisibility', 'off')
end
yline(1, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax3, [0 10])
grid on
ylabel("$e_{E}$", 'Interpreter', 'latex')
hold off
xlabel("$t$ [EM ndim]", 'Interpreter', 'latex')
linkaxes([ax1, ax2, ax3], 'x')
leg3 = legend(ps);
leg3.Layout.Tile = 'east';
leg3.Interpreter = 'latex';
% exportgraphics(fig3, 'EscapeAnalysis_3.png', 'BackgroundColor', 'k')
fig4 = figure("Position", [200 100 1200 750]);
hold on
for j = 1:size(d, 1)
plot(a_osc_E{j}, e_osc_E{j}, 'DisplayName', "$v_{E}="+num2str(v_esc(j))+"$")
end
axis([-1E8 1E8 0 2])
grid on
xlabel("$a_{E}$ [km]", 'Interpreter', 'latex')
ylabel("$e_{E}$", 'Interpreter', 'latex')
title("Earth-Moon Rot.", 'Interpreter', 'latex')
leg4 = legend('Location', 'bestoutside', 'Interpreter', 'latex');
set(gca, 'Color', 'k');
hold off
% exportgraphics(fig4, 'EscapeAnalysis_4.png', 'BackgroundColor', 'k')
%% Sun-B1 Trajectory Plot
fig5 = figure("Position", [200 100 1200 750]);
hold on
ax = gca;
colors = ax.ColorOrder;
nColors = size(colors, 1);
% Sun = plot3DBody("Sun", RS/lstarSB1, [-muSB1, 0, 0]);
% set(Sun, 'DisplayName', "Sun")
B1 = plot3DBody("Earth", RE/lstarSB1, [1-muSB1, 0, 0]);
set(B1, 'DisplayName', "Earth")
SB1Trajs = [SB1Trajectory1, SB1Trajectory2, SB1Trajectory3, SB1Trajectory4, SB1Trajectory5, SB1Trajectory6, SB1Trajectory7];
for j = 1:length(SB1Trajs)
color = colors(mod(j-1, nColors)+1,:);
plot3(SB1Trajs(j).x(1:end-50), SB1Trajs(j).y(1:end-50), SB1Trajs(j).z(1:end-50), 'Color', color, 'DisplayName', "Escape Traj. "+num2str(j))
dot_SB1 = zeros(length(SB1Trajs(j).x(1:end-50)), 1);
for k = 1:length(dot_SB1)
dot_SB1(k) = dot([SB1Trajs(j).x(k)-1+muSB1, SB1Trajs(j).y(k) SB1Trajs(j).z(k)], [SB1Trajs(j).xdot(k), SB1Trajs(j).ydot(k), SB1Trajs(j).zdot(k)]);
end
apse = find((dot_SB1(1:end-1) < 0) & (dot_SB1(2:end) >= 0))+1;
for k = 1:length(apse)
scatter3(SB1Trajs(j).x(apse(k)), SB1Trajs(j).y(apse(k)), SB1Trajs(j).z(apse(k)), 50, 'w', '*', 'HandleVisibility', 'off')
end
end
% plot3(RH/lstarSB1*cos(linspace(0, 2*pi, 101))+1-muSB1, RH/lstarSB1*sin(linspace(0, 2*pi, 101)), zeros(1, 101), 'w:', 'DisplayName', "Hills Radius")
plot3(RH/lstarSB1*cos(linspace(0, 2*pi, 101))+1-muSB1, RH/lstarSB1*sin(linspace(0, 2*pi, 101)), zeros(1, 101), 'w:', 'DisplayName', "Escape Radius")
% for j = 1:length(L1StableMan.arcs)
% plot3(L1StableMan.arcs{j}.x, L1StableMan.arcs{j}.y, L1StableMan.arcs{j}.z, 'b', 'LineWidth', 0.5, 'HandleVisibility', 'off')
% end
% for j = 1:length(L2StableMan.arcs)
% plot3(L2StableMan.arcs{j}.x, L2StableMan.arcs{j}.y, L2StableMan.arcs{j}.z, 'c', 'LineWidth', 0.5, 'HandleVisibility', 'off')
% end
axis equal
grid on
xlabel("$x$ [S$B_{1}$ ndim]", 'Interpreter', 'latex')
ylabel("$y$ [S$B_{1}$ ndim]", 'Interpreter', 'latex')
zlabel("$z$ [S$B_{1}$ ndim]", 'Interpreter', 'latex')
title("Sun-$B_{1}$ Rot.", 'Interpreter', 'latex')
leg5 = legend('Location', 'bestoutside', 'Interpreter', 'latex');
set(gca, 'Color', 'k');
view(2)
hold off
% exportgraphics(fig5, 'EscapeAnalysis_5.png', 'BackgroundColor', 'k')
%% Sun-B1 Hamiltonian
fig6 = figure("Position", [200 100 1200 750]);
t6 = tiledlayout(2,1);
t6.TileSpacing = 'compact';
t6.Padding = 'compact';
ax1 = nexttile;
hold on
ps = gobjects(size(t, 1), 1);
for j = 1:size(t, 1)
color = colors(mod(j-1, nColors)+1,:);
ps(j) = plot(SB1Trajs(j).t, SB1Trajs(j).H, 'Color', color, 'DisplayName', "$v_{E}="+num2str(v_esc(j))+"$");
end
yline(H_E2, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
grid on
ylabel("$H_{SB_{1}}$ [S$B_{1}$ ndim]", 'Interpreter', 'latex')
title("Sun-$B_{1}$ Hamiltonian", 'Interpreter', 'latex')
hold off
ax2 = nexttile;
hold on
for j = 1:size(t, 1)
change = [1; find(diff(quad_SB1{j}) ~= 0)+1; length(quad_SB1{j})];
color = colors(mod(j-1, nColors)+1,:);
for k = 1:numel(change)-1
range = change(k):change(k+1);
quad = quad_SB1{j}(range(1));
if (quad == 1) || (quad == 3)
plot(SB1Trajs(j).t(range), e_osc_E{j}(range), 'Color', color, 'HandleVisibility', 'off')
else
plot(SB1Trajs(j).t(range), e_osc_E{j}(range), 'LineStyle', ':', 'Color', color, 'HandleVisibility', 'off')
end
end
dot_SB1 = zeros(length(SB1Trajs(j).x(1:end-10)), 1);
for k = 1:length(dot_SB1)
dot_SB1(k) = dot([SB1Trajs(j).x(k)-1+muSB1, SB1Trajs(j).y(k) SB1Trajs(j).z(k)], [SB1Trajs(j).xdot(k), SB1Trajs(j).ydot(k), SB1Trajs(j).zdot(k)]);
end
apse = find((dot_SB1(1:end-1) < 0) & (dot_SB1(2:end) >= 0))+1;
for k = 1:length(apse)
scatter(SB1Trajs(j).t(apse(k)), e_osc_E{j}(apse(k)), 50, 'w', '*', 'HandleVisibility', 'off')
end
end
yline(1, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax2, [0 10])
grid on
ylabel("$e_{E}$", 'Interpreter', 'latex')
hold off
xlabel("$t$ [S$B_{1}$ ndim]", 'Interpreter', 'latex')
linkaxes([ax1, ax2], 'x')
leg6 = legend(ps);
leg6.Layout.Tile = 'east';
leg6.Interpreter = 'latex';
% exportgraphics(fig6, 'EscapeAnalysis_6.png', 'BackgroundColor', 'k')
%% Jacobi Constants and Hamiltonians
fig7 = figure("Position", [200 100 1200 750]);
t7 = tiledlayout(2,1);
t7.TileSpacing = 'compact';
t7.Padding = 'compact';
ax1 = nexttile;
hold on
ps = gobjects(size(t, 1), 1);
for j = 1:size(t, 1)
color = colors(mod(j-1, nColors)+1,:);
ps(j) = plot(t{j}, JC_EM{j}, 'Color', color, 'DisplayName', "$h_{z}="+num2str(h_z(j))+"$");
dot_SB1 = zeros(length(SB1Trajs(j).x(1:end-10)), 1);
for k = 1:length(dot_SB1)
dot_SB1(k) = dot([SB1Trajs(j).x(k)-1+muSB1, SB1Trajs(j).y(k) SB1Trajs(j).z(k)], [SB1Trajs(j).xdot(k), SB1Trajs(j).ydot(k), SB1Trajs(j).zdot(k)]);
end
apse = find((dot_SB1(1:end-1) < 0) & (dot_SB1(2:end) >= 0))+1;
for k = 1:length(apse)
scatter(t{j}(apse(k)), JC_EM{j}(apse(k)), 50, 'w', '*', 'HandleVisibility', 'off')
end
end
yline(JC_EM_L2, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax1, [0 4])
grid on
ylabel("JC [EM ndim]", 'Interpreter', 'latex')
title("Jacobi Constants", 'Interpreter', 'latex')
hold off
ax2 = nexttile;
hold on
for j = 1:size(t, 1)
color = colors(mod(j-1, nColors)+1,:);
plot(t{j}, JC_SB1{j}, 'Color', color, 'HandleVisibility', 'off')
end
yline(JC_SB1_L2, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax2, [3.0 3.003])
grid on
ylabel("JC [S$B_{1}$ ndim]", 'Interpreter', 'latex')
hold off
xlabel("$t$ [EM ndim]", 'Interpreter', 'latex')
linkaxes([ax1, ax2], 'x')
leg7 = legend(ps);
leg7.Layout.Tile = 'east';
leg7.Interpreter = 'latex';
% exportgraphics(fig7, 'EscapeAnalysis_7.png', 'BackgroundColor', 'k')
fig8 = figure("Position", [200 100 1200 750]);
t8 = tiledlayout(2,1);
t8.TileSpacing = 'compact';
t8.Padding = 'compact';
ax1 = nexttile;
hold on
ps = gobjects(size(t, 1), 1);
for j = 1:size(t, 1)
color = colors(mod(j-1, nColors)+1,:);
ps(j) = plot(t{j}, H_EM{j}, 'Color', color, 'DisplayName', "$h_{z}="+num2str(h_z(j))+"$");
end
ylim(ax1, [1692 1696])
grid on
ylabel("$H_{EM}$ [EM ndim]", 'Interpreter', 'latex')
title("Hamiltonians", 'Interpreter', 'latex')
hold off
ax2 = nexttile;
hold on
for j = 1:size(t, 1)
color = colors(mod(j-1, nColors)+1,:);
plot(t{j}, SB1Trajs(j).H, 'Color', color, 'HandleVisibility', 'off')
end
yline(H_E2, 'w:', 'LineWidth', 1, 'HandleVisibility', 'off')
ylim(ax2, [3.0 3.004])
grid on
ylabel("$H_{SB_{1}}$ [S$B_{1}$ ndim]", 'Interpreter', 'latex')
hold off
xlabel("$t$ [EM ndim]", 'Interpreter', 'latex')
linkaxes([ax1, ax2], 'x')
leg8 = legend(ps);
leg8.Layout.Tile = 'east';
leg8.Interpreter = 'latex';
% exportgraphics(fig8, 'EscapeAnalysis_8.png', 'BackgroundColor', 'k')