forked from ideas-um/FAST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.m
More file actions
154 lines (117 loc) · 5.13 KB
/
Copy pathMain.m
File metadata and controls
154 lines (117 loc) · 5.13 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
function [Aircraft, MissionHistory] = Main(InputAircraft, ProfileFxn)
%
% [Aircraft, MissionHistory] = Main(InputAircraft, ProfileFxn)
% written by Paul Mokotoff, prmoko@umich.edu
% last updated: 11 dec 2024
%
% NOTE: please see README.m in the root directory for all
% disclaimers and how to run FAST.
%
% Perform on- and off-design analysis for a user-requested aircraft
% configuration by flying a user-requested mission profile.
%
% INPUTS:
% InputAircraft - function handle for the aircraft to be sized or an
% already existing aircraft struct. Since all aircraft
% are in the "AircraftSpecsPkg" folder, the function
% handle must be provided as
% "AircraftSpecsPkg.MyAircraft", where "MyAircraft" is
% the .m file in the "AircraftSpecsPkg" folder
% describing the aircraft's configuration.
% size/type/units: 1-by-1 / struct or function handle / []
%
% ProfileFxn - function handle for the mission profile to be flown.
% These typically reside in the "MissionProfilesPkg"
% folder.
% size/type/units: 1-by-1 / function handle / []
%
% OUTPUTS:
% Aircraft - a structure containing information about the
% aircraft after it has been sized and the mission
% profile that it flew during the analysis process.
% size/type/units: 1-by-1 / struct / []
%
% MissionHistory - a (possibly empty) table with the mission history
% after the aircraft flies the prescribed mission
% profile.
% size/type/units: 1-by-1 or 0-by-0 / table / []
%
%% USER-SPECIFIED AIRCRAFT CONFIGURATION %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% initial cleanup
clc, close all
% call user-specified input aircraft
Aircraft = InputAircraft;
% call pre-specprocessing, it will fill in unspecified fields with NaNs if the user forgets one
Aircraft = DataStructPkg.PreSpecProcessing(Aircraft);
% check that an analysis type was provided
if (isnan(Aircraft.Settings.Analysis.Type))
% assume on-design
warning("WARNING - Main: Analysis type not provided. Assuming on-design (+1).");
% set analysis type to be on-design
Aircraft.Settings.Analysis.Type = +1;
end
% if on-design, use regressions/projections to obtain more knowledge about the aircraft
if (Aircraft.Settings.Analysis.Type > 0)
Aircraft = DataStructPkg.SpecProcessing(Aircraft);
end
% create the propulsion architecture
Aircraft = PropulsionPkg.CreatePropArch(Aircraft);
% identify any parallel connections (for propulsion analysis)
Aircraft = PropulsionPkg.PropArchConnections(Aircraft);
%% USER-SPECIFIED MISSION PROFILE %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch nargin
case 1
warning("A user-specified mission was not provided. As a default, FAST will use a notional mission parameterized by the input aircraft specifications. Proceed (Y/N)?")
doc MissionProfilesPkg.NotionalMission00
proceedvar = input("",'s');
if strcmpi(proceedvar,"y")
ProfileFxn = @MissionProfilesPkg.NotionalMission00;
else
warning("Aircraft analysis canceled. For more information on specific mission profiles, please see documentation on the MissionProfilesPkg.")
doc MissionProfilesPkg.README
return;
end
end
% call the respective mission profile function
Aircraft = ProfileFxn(Aircraft);
% process the mission profile
Aircraft = MissionSegsPkg.ProcessProfile(Aircraft);
%% AIRCRAFT ANALYSIS %%
%%%%%%%%%%%%%%%%%%%%%%%
% set the analysis type, done from the aircraft specifications function
% +1: on -design analysis
% -1: off-design analysis
Type = Aircraft.Settings.Analysis.Type;
% maximum number of sizing iterations, done from the AircraftSpecsPkg file
MaxIter = Aircraft.Settings.Analysis.MaxIter;
% analyze the aircraft without any optimization
Aircraft = EAPAnalysis(Aircraft, Type, MaxIter);
%% MISSION PROFILE PLOTTING %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot the results, if desired (if 1, generate plots; if 0, no plotting)
if (Aircraft.Settings.Plotting == 1)
PlotPkg.PlotMission(Aircraft);
end
% assign mission profile to sized aircraft structure so it can be
% referenced in retrofitting
Aircraft.Mission.ProfileFxn = ProfileFxn;
% ----------------------------------------------------------
%% MISSION HISTORY TABLE %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% check if a second output argument exists
if ((nargout > 1) && (Aircraft.Settings.Table == 0))
% warn the user that an empty table is returned
warning("WARNING - Main: two output arguments were provided, but Aircraft.Settings.Table is 0. An empty table will be returned. Set Aircraft.Settings.Table to 1 for a table to be returned.");
end
% check if a table should be made
if (Aircraft.Settings.Table == 1)
% make the table
MissionHistory = MissionHistTable(Aircraft);
else
% return an empty table
MissionHistory = table();
end
% ----------------------------------------------------------
end