-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarsEDLPowered_Continuous.m
executable file
·131 lines (92 loc) · 3.61 KB
/
MarsEDLPowered_Continuous.m
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
% MarsEDLPowered_Continuous.m %
function phaseout = MarsEDLPowered_Continuous(input)
% save
%% PHASE 1 - Freefall
ip = 1;
% ---------------------------------------------------%
% ------------- Components of the State ------------ %
% ---------------------------------------------------%
h = input.phase(ip).state(:,1);
v = input.phase(ip).state(:,2);
fpa = input.phase(ip).state(:,3);
s = input.phase(ip).state(:,4);
% m = input.phase(ip).state(:,5);
cbank = input.phase(ip).control(:,1);
% ---------------------------------------------------%
% ---------- Compute relevant quantities ----------- %
% ---------------------------------------------------%
% Mars Parameters
rho0 = input.auxdata.rho0;
H = input.auxdata.H;
mu = input.auxdata.mu;
g0 = input.auxdata.g0;
Re = input.auxdata.Re;
k = input.auxdata.k;
% Entry Vehicle Parameters
beta = input.auxdata.beta;
LD = input.auxdata.LD;
rn = input.auxdata.rn;
% Constants
r = h + Re; % Radius (m)
rho = rho0.*exp(-h./H); % Atmospheric Density (kg/m^3)
g = mu./r.^2; % Gravitational acceleration (m/s^2)
% ---------------------------------------------------%
% ------------- Dynamics --------------------------- %
% ---------------------------------------------------%
hdot = v.*sin(fpa);
vdot = -(rho.*v.^2)/(2*beta)-g.*sin(fpa);
fpadot = (v.*cos(fpa))./r - (g.*cos(fpa))./v + ((rho.*v)/(2*beta)).* (LD*cbank);
sdot = v.*sin(fpa);
phaseout(ip).dynamics = [hdot, vdot, fpadot, sdot];
% Path constraints
gE = 9.807;
n = sqrt(LD.^2+1).*0.5.*rho.*v.^2./(beta.*gE);
q = k.*sqrt(rho./rn).*v.^3;
phaseout(ip).path = [n, q];
%% PHASE 2 - Powered Descent
ip = 2;
% ---------------------------------------------------%
% ------------- Components of the State ------------ %
% ---------------------------------------------------%
h = input.phase(ip).state(:,1);
v = input.phase(ip).state(:,2);
fpa = input.phase(ip).state(:,3);
s = input.phase(ip).state(:,4);
m = input.phase(ip).state(:,5);
u = input.phase(ip).control(:,1);
% ---------------------------------------------------%
% ---------- Compute relevant quantities ----------- %
% ---------------------------------------------------%
% Mars Parameters
rho0 = input.auxdata.rho0;
H = input.auxdata.H;
mu = input.auxdata.mu;
g0 = input.auxdata.g0;
Re = input.auxdata.Re;
k = input.auxdata.k;
% Entry Vehicle Parameters
beta = input.auxdata.beta;
LD = input.auxdata.LD;
rn = input.auxdata.rn;
T = input.auxdata.T;
isp = input.auxdata.isp;
% Constants
r = h + Re; % Radius (m)
rho = rho0.*exp(-h./H); % Atmospheric Density (kg/m^3)
g = mu./r.^2; % Gravitational acceleration (m/s^2)
gE = 9.807;
cbank = 1;
% ---------------------------------------------------%
% ------------- Dynamics --------------------------- %
% ---------------------------------------------------%
hdot = v.*sin(fpa);
vdot = -(rho.*v.^2)/(2*beta)-g.*sin(fpa) - T.*u./m;
fpadot = (v.*cos(fpa))./r - (g.*cos(fpa))./v + ((rho.*v)/(2*beta)).* (LD*cbank);
sdot = v.*sin(fpa);
mdot = -T.*u./(gE.*isp); % Mass
phaseout(ip).dynamics = [hdot, vdot, fpadot, sdot, mdot];
phaseout(ip).integrand = 0.1*u;
% Path constraints
n = sqrt(LD.^2+1).*0.5.*rho.*v.^2./(beta.*gE) + T.*u./(m.*gE);
q = k.*sqrt(rho./rn).*v.^3;
phaseout(ip).path = [n, q];