-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTrimF16.m
More file actions
174 lines (134 loc) · 6.21 KB
/
TrimF16.m
File metadata and controls
174 lines (134 loc) · 6.21 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
%% Search for a specified operating point for the model - F16.
%
% This MATLAB script is the command line equivalent of the specification
% tab in the Steady State Manager with current specifications and options.
% It produces the exact same operating points as hitting the Trim button.
% MATLAB(R) file generated by MATLAB(R) 24.2 and Simulink Control Design (TM) 24.2.
%
% Generated on: 13-Feb-2025 21:04:29
%% Specify the model name
model = 'F16';
%% Create the operating point specification object.
opspec = operspec(model);
%% Limits
control.lb = [1000*lbf2N -25*d2r -21.5*d2r -30*d2r 0];
control.ub = [19000*lbf2N 25*d2r 21.5*d2r 30*d2r 25*d2r];
%% Set the constraints on the states in the model.
% - The defaults for all states are Known = false, SteadyState = true,
% Min = -Inf, Max = Inf, dxMin = -Inf, and dxMax = Inf.
% State (1) - F16/Nonlinear F16 Model/6DOF (Quaternion)/Calculate DCM & Euler Angles/phi theta psi
% - Default model initial conditions are used to initialize optimization.
opspec.States(1).Known = [true;true;true];
% State (2) - F16/Nonlinear F16 Model/6DOF (Quaternion)/p,q,r
% - Default model initial conditions are used to initialize optimization.
opspec.States(2).Known = true;
% State (3) - F16/Nonlinear F16 Model/6DOF (Quaternion)/p,q,r
% - Default model initial conditions are used to initialize optimization.
opspec.States(3).Known = true;
% State (4) - F16/Nonlinear F16 Model/6DOF (Quaternion)/p,q,r
% - Default model initial conditions are used to initialize optimization.
opspec.States(4).Known = true;
% State (5) - F16/Nonlinear F16 Model/6DOF (Quaternion)/ub,vb,wb
% - Default model initial conditions are used to initialize optimization.
opspec.States(5).Known = true;
% State (6) - F16/Nonlinear F16 Model/6DOF (Quaternion)/ub,vb,wb
% - Default model initial conditions are used to initialize optimization.
opspec.States(6).Known = true;
% State (7) - F16/Nonlinear F16 Model/6DOF (Quaternion)/ub,vb,wb
% - Default model initial conditions are used to initialize optimization.
opspec.States(7).Known = true;
% State (8) - F16/Nonlinear F16 Model/6DOF (Quaternion)/xe,ye,ze
% - Default model initial conditions are used to initialize optimization.
opspec.States(8).Known = true;
opspec.States(8).SteadyState = false;
% State (9) - F16/Nonlinear F16 Model/6DOF (Quaternion)/xe,ye,ze
% - Default model initial conditions are used to initialize optimization.
opspec.States(9).Known = true;
opspec.States(9).SteadyState = false;
% State (10) - F16/Nonlinear F16 Model/6DOF (Quaternion)/xe,ye,ze
% - Default model initial conditions are used to initialize optimization.
opspec.States(10).Known = true;
%% Set the constraints on the inputs in the model.
% - The defaults for all inputs are Known = false, Min = -Inf, and
% Max = Inf.
% Input (1) - F16/Thrust
% - Default model initial conditions are used to initialize optimization.
opspec.Inputs(1).Known = false;
opspec.Inputs(1).Min = control.lb(1);
opspec.Inputs(1).Max = control.ub(1);
% Input (2) - F16/ele
% - Default model initial conditions are used to initialize optimization.
opspec.Inputs(2).Known = false;
opspec.Inputs(2).Min = control.lb(2);
opspec.Inputs(2).Max = control.ub(2);
% Input (3) - F16/ail
% - Default model initial conditions are used to initialize optimization.
opspec.Inputs(3).Known = true;
opspec.Inputs(3).u = 0;
% Input (4) - F16/rud
% - Default model initial conditions are used to initialize optimization.
opspec.Inputs(4).Known = true;
opspec.Inputs(4).u = 0;
% Input (5) - F16/lef
% - Default model initial conditions are used to initialize optimization.
opspec.Inputs(5).Known = false;
opspec.Inputs(5).Min = control.lb(5);
opspec.Inputs(5).Max = control.ub(5);
% Input (6) - F16/gust
% - Default model initial conditions are used to initialize optimization.
opspec.Inputs(6).Known = [true;true;true];
opspec.Inputs(6).u = [0;0;0];
%% Set the constraints on the outputs in the model.
% - The defaults for all outputs are Known = false, Min = -Inf, and
% Max = Inf.
% Output (1) - F16/X,Y, Z in inertial
% - Default model initial conditions are used to initialize optimization.
% Output (2) - F16/Xd,Yd, Zd in inertial
% - Default model initial conditions are used to initialize optimization.
% Output (3) - F16/total velocity
opspec.Outputs(3).y = Vt0;
opspec.Outputs(3).Known = true;
% Output (4) - F16/angle of attack
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(4).Known = false;
opspec.Outputs(4).y = 0;
opspec.Outputs(4).Min = -20*d2r;
opspec.Outputs(4).Max = 45*d2r;
% Output (5) - F16/side slip angle
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(5).Known = true;
opspec.Outputs(5).y = 0;
% Output (6) - F16/euler angles
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(6).Known = [true;false;true];
opspec.Outputs(6).y = [0;0;0];
% Output (7) - F16/flight path angle
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(7).Known = true;
opspec.Outputs(7).y = 0;
% Output (8) - F16/angular velocity vector (expressed in body)
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(8).Known = [true;true;true];
opspec.Outputs(8).y = [0;0;0];
% Output (9) - F16/linear acceleration vector (expressed in body)
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(9).Known = [true;true;true];
opspec.Outputs(9).y = [0;0;0];
% Output (10) - F16/angular acceleration vector
% - Default model initial conditions are used to initialize optimization.
opspec.Outputs(10).Known = [true;true;true];
opspec.Outputs(10).y = [0;0;0];
% Output (11) - F16/Mach
% - Default model initial conditions are used to initialize optimization.
% Output (12) - F16/Faero
% - Default model initial conditions are used to initialize optimization.
% Output (13) - F16/Maero
% - Default model initial conditions are used to initialize optimization.
%% Create the options
opt = findopOptions('OptimizerType','graddescent',...
'DisplayReport','iter');
opt.OptimizationOptions.Algorithm = 'active-set';
opt.OptimizationOptions.MaxFunEvals = 4000;
opt.OptimizationOptions.MaxIter = 2000;
%% Perform the operating point search.
[op,opreport] = findop(model,opspec,opt);