Skip to content

Commit fd2e1c5

Browse files
committed
added LEO preset
1 parent bf483e4 commit fd2e1c5

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
problem = otp.cr3bp.presets.LowEarthOrbit;
2+
3+
y0 = problem.Y0;
4+
tend = problem.TimeSpan(2);
5+
f = problem.RHS.F;
6+
mu = problem.Parameters.Mu;
7+
8+
v0 = -7;
9+
10+
J = @(v0) cost(v0, y0, f, tend, mu);
11+
opts = optimoptions("fmincon", "Algorithm","interior-point", ...
12+
"FunctionTolerance", 1e-14, "ConstraintTolerance", 1e-14, 'Display','off');
13+
[v0, fev] = fmincon(J, v0, [], [], [], [], [], [], [], opts);
14+
15+
v0
16+
17+
% find period
18+
19+
J = @(tend) cost2(v0, y0, f, tend, mu);
20+
opts = optimoptions("fmincon", "Algorithm","interior-point", ...
21+
"FunctionTolerance", 1e-14, "ConstraintTolerance", 1e-14, 'Display','off');
22+
[tend, fev] = fmincon(J, tend, [], [], [], [], 0.13, 0.15, [], opts);
23+
24+
tend
25+
26+
27+
function c = cost(v0, y0, f, tend, mu)
28+
29+
y0(5) = v0;
30+
31+
sol = ode45(f, [0, tend], y0, ...
32+
odeset('AbsTol', 1e-14, 'RelTol', 100*eps));
33+
34+
yend = sol.y(:, :);
35+
36+
earth = [-mu; 0; 0];
37+
38+
dy0 = norm(y0(1:3) - earth);
39+
dyend = vecnorm(yend(1:3, :) - earth);
40+
41+
c = sum((dy0 - dyend).^2);
42+
43+
end
44+
45+
function c = cost2(v0, y0, f, tend, ~)
46+
47+
y0(5) = v0;
48+
49+
sol = ode45(f, [0, tend], y0, ...
50+
odeset('AbsTol', 1e-14, 'RelTol', 100*eps));
51+
52+
c = sum((y0 - sol.y(:, end)).^2);
53+
54+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
classdef LowEarthOrbit < otp.cr3bp.CR3BPProblem
2+
% A trivial preset with a stable oscillating orbit around a lagrange point.
3+
methods
4+
function obj = LowEarthOrbit(varargin)
5+
% Create the Canonical CR3BP problem object.
6+
7+
8+
equatorialRadius = 6378;
9+
earthMoonDist = 385000;
10+
11+
delta = equatorialRadius/earthMoonDist;
12+
13+
mE = otp.utils.PhysicalConstants.EarthMass;
14+
mL = otp.utils.PhysicalConstants.MoonMass;
15+
G = otp.utils.PhysicalConstants.GravitationalConstant;
16+
17+
% derive mu
18+
muE = G*mE;
19+
muL = G*mL;
20+
mu = muL/(muE + muL);
21+
22+
x0 = -mu + delta;
23+
y0 = -7.717617954315369e+00;
24+
25+
y0 = [x0; 0; 0; 0; y0; 0];
26+
tspan = [0, 1.348715080895850e-01];
27+
params = otp.cr3bp.CR3BPParameters('Mu', mu, 'SoftFactor', 1e-3, varargin{:});
28+
obj = obj@otp.cr3bp.CR3BPProblem(tspan, y0, params);
29+
end
30+
end
31+
end

toolbox/+otp/+cr3bp/CR3BPProblem.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ function onSettingsChanged(obj)
125125
fig = internalPlotPhaseSpace@otp.Problem(obj, t, y, ...
126126
'Vars', 1:3, varargin{:});
127127
hold on;
128-
scatter3([mu, 1 - mu], [0, 0], [0, 0]);
128+
scatter3([-mu, 1 - mu], [0, 0], [0, 0]);
129+
axis equal
129130
end
130131

131132
end

0 commit comments

Comments
 (0)