Skip to content
Snippets Groups Projects
Verified Commit 6db656c4 authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

fix,refactor,test: Finish xf2mat

parent 1ad1fbe8
No related branches found
No related tags found
No related merge requests found
function Polar = xf2mat(autosave, trimAoas, inputDir, inputFiles)
function Polar = xf2mat(varargin)
% XF2MAT Aggregates multiple XFOIL or XFLR5 polar results into a single structure.
% This function aggregates different airfoil polars obtained with XFOIL or
% XFLR5 (saved as textfiles) into a single structure for easier handling in
......@@ -6,46 +6,44 @@ function Polar = xf2mat(autosave, trimAoas, inputDir, inputFiles)
%
% This function can be run without arguments, in this case it will prompt the
% user for the input.
% Up to four input arguments can also be provided to automate the process.
% In this case, the user should provide (in this order) if they want the
% results to be saved automatically, if they want the polars to be trimmed to
% the same angles of attacks, the directory with the input files and the
% specific files to aggregate.
% Otherwile, the function asks for two main arguments:
% 1. inputDir: the directory where to look for the files
% 2. inputFiles: the files to load
%
% The function also comes with options to save automatically the resulting
% Polar structure and to trim all results to the same range of angles of
% attack.
%
% Note:
% If multiple textfiles are selected as input, the function will ask if the
% output Polar strcture should trim the various polars so they all have the same
% values for the angles of attack. If so, some data are discarded so all
% polars are fully defined on the range of angles of attack (i.e. output has
% the largest common range of angles of attack). If the polars should not be
% trimmed, the ouput values will still have the same angles of attack, but some
% polars may have NaN values at the extremes of their range (i.e. output has the
% range of the polar with the largest range).
% If multiple textfiles are selected as input, by default, the function will
% extend every polar to the maximum range of angles of attack found. Polars
% with fewer data will be assigned NaN values at the missing angles of attack.
% If the 'trimAoas' is set to true, the function will find the largest common
% range of angles of attack accross the various input polars and trim
% everything to that range. This prevents NaN values in the polars, but
% removes some data from the most complete inputs.
%
% <a href="https://gitlab.uliege.be/thlamb/airfoil_toolbox">Documentation (README)</a>
% <a href="https://gitlab.uliege.be/thlamb/airfoil_toolbox/-/issues">Report an issue</a>
% -----
%
% Synopsis:
% POLAR = XF2MAT prompts the user for all inputs.
% Usage:
% POLAR = XF2MAT prompts the user for all inputs, then aggregate and convert
% the polar in a single POLAR structure.
%
% POLAR = XF2MAT(AUTOSAVE) Prompts the user for input files, but will save
% automatically the results without further interaction if AUTOSAVE = true.
% POLAR = XF2MAT(INPUTDIR) aggregates all polars found in INPUTDIR into a
% single Polar structure.
%
% POLAR = XF2MAT(AUTOSAVE, TRIMAOAS) Prompts the user for the input files,
% automatically saves the results (or not) and trim the XFOIL results so all
% polars have the exact same range of angles of attack if TRIMAOAS = true.
% POLAR = XF2MAT(INPUTDIR, INPUTFILES) aggregates only the polars specified by
% INPUTFILES found in INPUTDIR into a single Polar structure.
%
% POLAR = XF2MAT(AUTOSAVE, TRIMAOAS, INPUTDIR) Aggregate all polars found
% in INPUTDIR into a single Polar structure.
% POLAR = XF2MAT(..., 'autosave', true) saves the resulting POLAR structure
% automatically in a MAT-file.
%
% POLAR = XF2MAT(AUTOSAVE, TRIMAOAS, INPUTDIR, INPUTFILES) Aggregate only
% the polars specified by INPUTFILES found in INPUTDIR into a single Polar
% structure.
% POLAR = XF2MAT(..., 'trimAoas', true) trims all input polars to the largest
% common range of angles of attack to prevent NaN values in the ouput.
%
% Inputs:
% autosave : Automatically save results (true / false(default))
% trimAoas : Trim all polars to the same range of AOAs (true (default) / false)
% inputDir : Path of the directory with the XFOIL/XFLR5 data
% inputFiles : Files to select (ex: '*' (default), '*0012*', {'file1','file2'}, etc)
%
......@@ -59,14 +57,15 @@ function Polar = xf2mat(autosave, trimAoas, inputDir, inputFiles)
% - Polar.cl : Lift coefficient [-]
% - Polar.cd : Drag coefficient [-]
% - Polar.cm : Moment coefficient [-]
% - Polar.origin : XFOIL / XFLR5
%
% Example:
% XF2MAT
% XF2MAT(true)
% XF2MAT(true, true)
% XF2MAT(true, true, 'test_data')
% XF2MAT(true, true, 'test_data', '*0012*')
% XF2MAT(true, true, 'test_data', {'0012_re1e5', '0012_re1e6'})
% XF2MAT)
% XF2MAT('test_data')
% XF2MAT('test_data', '*0012*')
% XF2MAT('test_data', {'0012_re1e5', '0012_re1e6'})
% XF2MAT('test_data', 'autosave', true)
% XF2MAT('test_data', '*', 'trimAoas', true)
%
% See also: EXTENDPOLAR, PLOTPOLARS.
......@@ -80,109 +79,23 @@ function Polar = xf2mat(autosave, trimAoas, inputDir, inputFiles)
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% ------------------------------------------------------------------------------
narginchk(0,6);
%% Import other functions from this package
% Import other functions from this package
import af_tools.utils.*
%% Constants and defaults
DEFAULT_INPUTFILES = '*'; % If not specified, all files of the dir are included by default
DEFAULT_AUTOSAVE = false; % Do not autosave by default
DEFAULT_TRIMAOAS = false; % Do not trim AOAs by default
% Constants and defaults
AUTONAME = true; % Name saved file automatically
PREVENT_OVERWRITING = true; % Prevents overwriting of the files during autosave
%% Check inputs and assign defaults
if nargin >= 1
validateattributes(autosave, {'logical'},{'scalar'}, mfilename(), ...
'autosave', 1)
if nargin >= 2
validateattributes(trimAoas, {'logical'},{'scalar'}, mfilename(), ...
'trimAoas', 2)
if nargin >= 3
validateattributes(inputDir, {'char','string'},{'nonempty','vector'}, ...
mfilename(), 'inputDir', 3)
if ~exist(inputDir, 'dir')
error('MATLAB:xf2mat:dirNotFound', ['The directory '...
'specified as inputDir (%s) can not be found!\n'], inputDir);
end
if nargin == 4
validateattributes(inputFiles, {'char','cell'},{'nonempty','vector'}, ...
mfilename(), 'inputFiles', 4)
if iscell(inputFiles)
if ~iscellstr(inputFiles)
error('MATLAB:xf2mat:wrongInputFiles', ...
['If inpuFiles is given as a cell array, it must '...
'contain only character vectors!\n']);
end
end
else
inputFiles = DEFAULT_INPUTFILES;
end
end
else
trimAoas = DEFAULT_TRIMAOAS;
end
else
trimAoas = DEFAULT_TRIMAOAS;
autosave = DEFAULT_AUTOSAVE;
end
%% Look for the files
if nargin <= 2
% Prompt user for the files to read
[allFileNames, fullpath] = uigetfile('*.txt', ['Select all XFOIL files'...
'to aggregate'], 'MultiSelect', 'on','textFiles');
else
% Get absolute path
fullpath = fullfile(pwd, inputDir);
% Convert inputFiles to string for simpler handling
inputFiles = string(inputFiles);
% Get all files
allFiles = [];
for i = 1:length(inputFiles)
inputFiles(i) = appendextension(inputFiles(i),'.txt'); % Add extension
dummy = dir(fullfile(fullpath,inputFiles(i)));
if isempty(dummy)
warning('MATLAB:xf2mat:FileNotFound', ...
'Could not find file %s.', fullfile(fullpath,inputFiles(i)));
end
allFiles = [allFiles; dummy];
end
if isempty(allFiles)
error('MATLAB:xf2mat:noFilesFound', ['Impossible to find ANY '...
'file matching the input arguments.']);
end
allFileNames = cell(1,length(allFiles));
for i = 1:length(allFiles)
allFileNames{i} = allFiles(i).name;
end
end
% Parse inputs
[allFileNames, fullpath, autosave, trimAoas] = parseinputs(varargin{:});
% Convert filenames to string array
allFileNames = string(allFileNames);
%% Process XFoil/XFLR5 results
% -------------------------------------
% Process XFoil/XFLR5 results
% Number of files found
nbFiles=length(allFileNames);
......@@ -224,7 +137,7 @@ for i=1:nbFiles
end
end
Polar.origin{1,i} = progName;
% Parse the rest of the results
tmpAirfoil = textscan(fileID,'%s %s', 1, 'Delimiter','\n:','HeaderLines',1);
tmpParam = textscan(fileID, '%s %s %f %s %s %f %s %f %s %s %f %*[^\n]', 1, 'HeaderLines', 4); % ! HeaderLines is a cursor. This will read line 9
......@@ -262,6 +175,7 @@ clear Tmp
% Sort everything by increasing Reynolds
[Polar.reynolds, indSort] = sort(Polar.reynolds);
Polar.origin(:) = Polar.origin(indSort);
Polar.airfoil(:) = Polar.airfoil(indSort);
Polar.mach(:) = Polar.mach(indSort);
Polar.nCrit(:) = Polar.nCrit(indSort);
......@@ -270,8 +184,8 @@ Polar.cd(:,:) = Polar.cd(:,indSort);
Polar.cm(:,:) = Polar.cm(:,indSort);
%% Save results automatically
% -------------------------------------
% Save results automatically
if nargin == 0 % Prompt only if user input is to be expected
prompt = 'Save the resulting polar? Y/N [Y]: ';
......@@ -319,8 +233,111 @@ end
end
%% HELPERS
% ------------------------------------------------------------------------------
function [allFileNames, fullpath, autosave, trimAoas] = parseinputs(varargin)
% PARSEINPUTS Parse inputs and return the list of files and options
import af_tools.utils.*
% Constants and defaults
DEFAULT_INPUTFILES = '*'; % If not specified, all files of the dir are included by default
DEFAULT_AUTOSAVE = false; % Do not autosave by default
DEFAULT_TRIMAOAS = false; % Do not trim AOAs by default
OPTION_LIST = {'autosave','trimAoas'};
% Parse main inputs
hasNoInput = isempty(varargin) || isoption(OPTION_LIST, varargin{1});
if hasNoInput
% Prompt user for the files to read
[allFileNames, fullpath] = uigetfile('*.txt', ['Select all XFOIL files to aggregate'], 'MultiSelect', 'on','textFiles');
idxOpts = 1;
else
inputDir = varargin{1};
idxOpts = 2;
if nargin >= 2 && ~isoption(OPTION_LIST, varargin{2})
idxOpts = 3;
inputFiles = varargin{2};
else
inputFiles = DEFAULT_INPUTFILES;
end
% Validate inputDir
validateattributes(inputDir, {'char','string'},{'nonempty','vector'}, mfilename(), 'inputDir')
if ~exist(inputDir, 'dir')
error('MATLAB:xf2mat:dirNotFound', ['The directory specified as inputDir (%s) can not be found!\n'], inputDir);
end
% Validate inputFiles
validateattributes(inputFiles, {'char','cell'},{'nonempty','vector'}, mfilename(), 'inputFiles', 4)
if iscell(inputFiles) && ~iscellstr(inputFiles)
error('MATLAB:xf2mat:wrongInputFiles', ['If inpuFiles is given as a cell array, it must '...
'contain only character vectors!\n']);
end
% ------------------------------------------------------
% Look for files
% Get absolute path
if contains(inputDir, pwd)
fullpath = inputDir;
else
fullpath = fullfile(pwd, inputDir);
end
% Convert inputFiles to string for simpler handling
inputFiles = string(inputFiles);
% Get all files
AllFiles = [];
for i = 1:length(inputFiles)
inputFiles(i) = appendextension(inputFiles(i),'.txt'); % Add extension
dummy = dir(fullfile(fullpath,inputFiles(i)));
if isempty(dummy)
warning('MATLAB:xf2mat:FileNotFound', 'Could not find file %s.', fullfile(fullpath,inputFiles(i)));
end
AllFiles = [AllFiles; dummy];
end
if isempty(AllFiles)
error('MATLAB:xf2mat:noFilesFound', 'Impossible to find ANY file matching the input arguments.');
end
allFileNames = cell(1,length(AllFiles));
for i = 1:length(AllFiles)
allFileNames{i} = AllFiles(i).name;
end
end
% Option validator
validLogical = @(x) validateattributes(x, {'logical'},{'scalar'}, mfilename());
% Parse options
p = inputParser;
addParameter(p,'autosave', DEFAULT_AUTOSAVE, validLogical);
addParameter(p,'trimAoas', DEFAULT_TRIMAOAS, validLogical);
parse(p,varargin{idxOpts:end});
autosave = p.Results.autosave;
trimAoas = p.Results.trimAoas;
end
% ------------------------------------------------------------------------------
function bool = isoption(optList, var)
% ISOPTION Returns true if var is contained in option list
bool = any(strcmpi(var,optList));
end
% ------------------------------------------------------------------------------
function aoaRange = findcommonrange(aoaRange, resArray)
% FINDCOMMONRANGE Find the best common range accors all polars
......@@ -341,6 +358,7 @@ aoaRange = aoaRange(1):aoa_step:aoaRange(end);
end
% ------------------------------------------------------------------------------
function aoaRange = findmaxrange(aoaRange, resArray)
% FINDMAXRANGE Find the max range between all polars
......
......@@ -108,7 +108,7 @@ function test_invalidOptions(testCase)
% Error if invalid option name or missing parameter value
wrongName = 'testspacing';
verifyError(testCase, @() af_tools.nacaairfoil('0012', 100, wrongName), 'MATLAB:InputParser:ParamMissingValue')
verifyError(testCase, @() af_tools.nacaairfoil('0012', 100, wrongName, false), 'MATLAB:InputParser:UnmatchedParameter')
verifyError(testCase, @() af_tools.nacaairfoil('0012', 100, 'spacing', 'cosine', wrongName), 'MATLAB:InputParser:ParamMissingValue')
......
xflr5 v6.53
Calculated polar for: NACA 2412
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.000 Re = 1.000 e 6 Ncrit = 9.000
alpha CL CD CDp Cm Top Xtr Bot Xtr Cpmin Chinge XCp
------- -------- --------- --------- -------- ------- ------- -------- --------- ---------
-20.000 -0.6802 0.24103 0.23917 0.0388 1.0000 0.0120 -1.7548 0.0000 0.2855
-19.500 -0.6652 0.23372 0.23186 0.0349 1.0000 0.0120 -1.7910 0.0000 0.2814
-19.000 -0.6508 0.22622 0.22436 0.0310 1.0000 0.0120 -1.8365 0.0000 0.2771
-18.500 -0.6371 0.21850 0.21664 0.0272 1.0000 0.0120 -1.8951 0.0000 0.2727
-18.000 -0.6243 0.21045 0.20860 0.0234 1.0000 0.0121 -1.9767 0.0000 0.2680
-16.000 -0.5770 0.18052 0.17867 0.0089 1.0000 0.0186 -2.1746 0.0000 0.2481
-15.500 -0.5671 0.17225 0.17040 0.0053 1.0000 0.0187 -2.2318 0.0000 0.2424
-15.000 -1.0096 0.06453 0.06191 -0.0451 1.0000 0.0121 -8.5893 0.0000 0.1859
-14.500 -1.0742 0.04367 0.04058 -0.0622 1.0000 0.0121 -9.1624 0.0000 0.1742
-14.000 -1.0909 0.03479 0.03138 -0.0683 1.0000 0.0121 -9.1271 0.0000 0.1707
-13.000 -1.1358 0.02337 0.01900 -0.0584 1.0000 0.0132 -9.0609 0.0000 0.1838
-12.500 -1.1143 0.02126 0.01672 -0.0541 1.0000 0.0147 -8.6945 0.0000 0.1875
-12.000 -1.0806 0.02033 0.01574 -0.0508 1.0000 0.0157 -8.2382 0.0000 0.1897
-11.500 -1.0482 0.01940 0.01473 -0.0471 1.0000 0.0167 -7.8091 0.0000 0.1924
-11.000 -1.0161 0.01845 0.01367 -0.0433 1.0000 0.0175 -7.3942 0.0000 0.1954
-10.500 -0.9731 0.01752 0.01263 -0.0416 0.9993 0.0182 -6.9306 0.0000 0.1959
-10.000 -0.9097 0.01660 0.01159 -0.0440 0.9967 0.0187 -6.3770 0.0000 0.1908
-9.500 -0.8483 0.01487 0.00964 -0.0463 0.9939 0.0197 -5.8974 0.0000 0.1850
-9.000 -0.7875 0.01336 0.00799 -0.0482 0.9905 0.0224 -5.4337 0.0000 0.1788
-8.500 -0.7229 0.01262 0.00721 -0.0505 0.9863 0.0250 -4.9305 0.0000 0.1706
-8.000 -0.6541 0.01207 0.00661 -0.0535 0.9833 0.0267 -4.4197 0.0000 0.1590
-7.500 -0.5855 0.01102 0.00551 -0.0566 0.9805 0.0315 -3.9517 0.0000 0.1442
-7.000 -0.5262 0.01049 0.00495 -0.0574 0.9713 0.0355 -3.5133 0.0000 0.1321
-6.500 -0.4662 0.00981 0.00425 -0.0583 0.9628 0.0416 -3.1237 0.0000 0.1163
-6.000 -0.4129 0.00940 0.00382 -0.0576 0.9502 0.0469 -2.8034 0.0000 0.1020
-5.500 -0.3592 0.00887 0.00332 -0.0570 0.9366 0.0575 -2.4965 0.0000 0.0827
-5.000 -0.3052 0.00846 0.00290 -0.0564 0.9209 0.0710 -2.1948 0.0000 0.0564
-4.500 -0.2511 0.00809 0.00255 -0.0559 0.9036 0.0880 -1.9069 0.0000 0.0183
-4.000 -0.1968 0.00770 0.00224 -0.0554 0.8835 0.1139 -1.6376 0.0000 -0.0414
-3.500 -0.1421 0.00736 0.00197 -0.0550 0.8621 0.1482 -1.4120 0.0000 -0.1485
-3.000 -0.0874 0.00707 0.00174 -0.0547 0.8374 0.1871 -1.1971 0.0000 -0.3906
-2.500 -0.0326 0.00679 0.00156 -0.0543 0.8112 0.2376 -0.9999 0.0000 -1.4485
-2.000 0.0222 0.00656 0.00142 -0.0540 0.7818 0.2940 -0.8325 0.0000 2.7197
-1.500 0.0767 0.00633 0.00130 -0.0536 0.7506 0.3622 -0.6806 0.0000 0.9559
-1.000 0.1305 0.00606 0.00122 -0.0532 0.7178 0.4592 -0.5494 0.0000 0.6595
-0.500 0.1838 0.00580 0.00120 -0.0526 0.6834 0.5752 -0.5235 0.0000 0.5363
0.000 0.2373 0.00562 0.00122 -0.0520 0.6504 0.6782 -0.5673 0.0000 0.4680
0.500 0.2902 0.00550 0.00128 -0.0512 0.6174 0.7720 -0.6143 0.0000 0.4243
1.000 0.3418 0.00544 0.00139 -0.0499 0.5852 0.8587 -0.6650 0.0000 0.3933
1.500 0.3930 0.00553 0.00152 -0.0484 0.5545 0.9262 -0.7213 0.0000 0.3699
2.000 0.4506 0.00574 0.00167 -0.0484 0.5245 0.9662 -0.7900 0.0000 0.3537
2.500 0.5189 0.00600 0.00181 -0.0510 0.4945 0.9850 -0.8829 0.0000 0.3442
3.000 0.5922 0.00629 0.00196 -0.0548 0.4631 0.9941 -1.0123 0.0000 0.3381
3.500 0.6674 0.00662 0.00213 -0.0592 0.4284 1.0000 -1.1803 0.0000 0.3339
4.000 0.7151 0.00692 0.00230 -0.0575 0.3948 1.0000 -1.3421 0.0000 0.3252
4.500 0.7631 0.00724 0.00250 -0.0559 0.3589 1.0000 -1.5288 0.0000 0.3176
5.000 0.8097 0.00773 0.00277 -0.0542 0.3126 1.0000 -1.7292 0.0000 0.3108
5.500 0.8559 0.00833 0.00315 -0.0524 0.2618 1.0000 -1.9510 0.0000 0.3046
6.000 0.9022 0.00902 0.00359 -0.0507 0.2101 1.0000 -2.2035 0.0000 0.2991
7.000 0.9942 0.01069 0.00475 -0.0475 0.1152 1.0000 -2.7314 0.0000 0.2896
7.500 1.0408 0.01151 0.00542 -0.0461 0.0853 1.0000 -3.0424 0.0000 0.2855
8.000 1.0875 0.01230 0.00609 -0.0447 0.0655 1.0000 -3.3844 0.0000 0.2817
8.500 1.1334 0.01313 0.00683 -0.0432 0.0505 1.0000 -3.7350 0.0000 0.2781
9.000 1.1795 0.01389 0.00757 -0.0418 0.0418 1.0000 -4.0984 0.0000 0.2747
9.500 1.2240 0.01474 0.00845 -0.0401 0.0351 1.0000 -4.4621 0.0000 0.2714
10.000 1.2670 0.01563 0.00933 -0.0383 0.0305 1.0000 -4.8356 0.0000 0.2681
10.500 1.3063 0.01672 0.01049 -0.0359 0.0265 1.0000 -5.1941 0.0000 0.2647
11.000 1.3470 0.01758 0.01142 -0.0337 0.0245 1.0000 -5.5791 0.0000 0.2615
11.500 1.3794 0.01870 0.01258 -0.0303 0.0220 1.0000 -5.9580 0.0000 0.2577
12.000 1.3959 0.02071 0.01476 -0.0248 0.0189 1.0000 -6.2818 0.0000 0.2527
12.500 1.4277 0.02187 0.01600 -0.0220 0.0185 1.0000 -6.7230 0.0000 0.2494
13.000 1.4559 0.02333 0.01756 -0.0190 0.0178 1.0000 -7.1520 0.0000 0.2463
13.500 1.4801 0.02514 0.01950 -0.0161 0.0168 1.0000 -7.5660 0.0000 0.2431
14.000 1.5006 0.02739 0.02185 -0.0133 0.0157 1.0000 -7.9628 0.0000 0.2402
14.500 1.5149 0.03033 0.02490 -0.0107 0.0146 1.0000 -8.3219 0.0000 0.2374
15.000 1.5143 0.03496 0.02973 -0.0083 0.0133 1.0000 -8.5663 0.0000 0.2348
15.500 1.4938 0.04222 0.03731 -0.0069 0.0125 1.0000 -8.6514 0.0000 0.2328
16.000 1.4693 0.05072 0.04614 -0.0071 0.0121 1.0000 -8.6992 0.0000 0.2319
16.500 1.4650 0.05744 0.05305 -0.0082 0.0121 1.0000 -8.9115 0.0000 0.2315
17.000 1.4555 0.06528 0.06109 -0.0102 0.0120 1.0000 -9.0767 0.0000 0.2318
17.500 1.4414 0.07397 0.07000 -0.0128 0.0119 1.0000 -9.1967 0.0000 0.2325
18.000 1.4228 0.08371 0.07996 -0.0162 0.0119 1.0000 -9.2676 0.0000 0.2337
18.500 1.4004 0.09443 0.09090 -0.0203 0.0118 1.0000 -9.2904 0.0000 0.2357
19.000 1.3755 0.10578 0.10247 -0.0250 0.0117 1.0000 -9.2719 0.0000 0.2382
19.500 1.3473 0.11807 0.11499 -0.0305 0.0117 1.0000 -9.1986 0.0000 0.2415
20.000 1.3192 0.13086 0.12799 -0.0366 0.0116 1.0000 -9.0930 0.0000 0.2455
XFOIL Version 6.99
Calculated polar for: NACA 2412
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.100 Re = 0.100 e 6 Ncrit = 9.000
alpha CL CD CDp CM Top_Xtr Bot_Xtr
------ -------- --------- --------- -------- -------- --------
-20.000 -0.4459 0.20477 0.19964 0.0047 1.0000 0.0602
-19.000 -0.4227 0.19304 0.18788 0.0010 1.0000 0.0640
-18.500 -0.4140 0.18851 0.18332 -0.0012 1.0000 0.0678
-18.000 -0.4279 0.18991 0.18472 -0.0060 1.0000 0.0704
-17.500 -0.3987 0.17901 0.17380 -0.0058 1.0000 0.0734
-17.000 -0.3891 0.17447 0.16924 -0.0077 1.0000 0.0776
-16.500 -0.4010 0.17438 0.16915 -0.0118 1.0000 0.0813
-16.000 -0.3801 0.16570 0.16047 -0.0124 1.0000 0.0836
-15.500 -0.3680 0.16102 0.15577 -0.0135 1.0000 0.0895
-15.000 -0.3952 0.16319 0.15795 -0.0177 1.0000 0.0935
-14.500 -0.3621 0.15246 0.14720 -0.0174 1.0000 0.0969
-14.000 -0.3554 0.14836 0.14309 -0.0184 1.0000 0.1027
-13.500 -0.3960 0.14988 0.14464 -0.0232 1.0000 0.1068
-13.000 -0.3508 0.13936 0.13408 -0.0210 1.0000 0.1133
-12.500 -0.3747 0.13660 0.13137 -0.0249 1.0000 0.1204
-12.000 -0.4887 0.13828 0.13269 -0.0133 1.0000 0.1194
-11.500 -0.4836 0.13005 0.12451 -0.0159 1.0000 0.1233
-11.000 -0.4668 0.12341 0.11787 -0.0165 1.0000 0.1312
-10.500 -0.4730 0.11559 0.11013 -0.0206 1.0000 0.1382
-10.000 -0.4792 0.10934 0.10396 -0.0247 1.0000 0.1497
-9.500 -0.4614 0.10130 0.09595 -0.0241 1.0000 0.1549
-9.000 -0.5226 0.09345 0.08837 -0.0355 1.0000 0.1660
-8.500 -0.4473 0.06532 0.06052 -0.0429 1.0000 0.1240
-8.000 -0.6065 0.04016 0.03476 -0.0446 1.0000 0.0902
-7.500 -0.6265 0.03138 0.02533 -0.0393 1.0000 0.0898
-7.000 -0.6248 0.02441 0.01740 -0.0344 1.0000 0.0924
-6.500 -0.6028 0.01918 0.01157 -0.0308 1.0000 0.0966
-6.000 -0.5705 0.01603 0.00795 -0.0279 1.0000 0.1048
-5.500 -0.5339 0.01311 0.00478 -0.0256 1.0000 0.1150
-5.000 -0.4934 0.01076 0.00219 -0.0237 1.0000 0.1290
-4.500 -0.4519 0.00904 0.00030 -0.0220 1.0000 0.1485
-4.000 -0.4111 0.00764 -0.00096 -0.0206 1.0000 0.1740
-3.500 -0.3466 0.00650 -0.00192 -0.0236 0.9933 0.2216
-3.000 -0.2623 0.00557 -0.00246 -0.0303 0.9764 0.3099
-2.500 -0.1806 0.00469 -0.00263 -0.0362 0.9589 0.4414
-1.500 -0.0474 0.00386 -0.00204 -0.0376 0.9172 0.8147
-1.000 0.0580 0.00394 -0.00200 -0.0441 0.9015 0.9424
-0.500 0.2410 0.00360 -0.00263 -0.0673 0.8955 0.9929
0.000 0.3133 0.00335 -0.00306 -0.0716 0.8683 1.0000
0.500 0.3637 0.00325 -0.00333 -0.0707 0.8399 1.0000
1.000 0.4128 0.00323 -0.00353 -0.0690 0.8122 1.0000
1.500 0.4564 0.00336 -0.00353 -0.0663 0.7812 1.0000
2.000 0.5010 0.00356 -0.00346 -0.0637 0.7506 1.0000
2.500 0.5467 0.00381 -0.00332 -0.0613 0.7203 1.0000
3.000 0.5932 0.00411 -0.00313 -0.0589 0.6901 1.0000
3.500 0.6401 0.00444 -0.00290 -0.0566 0.6596 1.0000
4.000 0.6871 0.00482 -0.00260 -0.0542 0.6278 1.0000
4.500 0.7332 0.00524 -0.00224 -0.0518 0.5937 1.0000
5.000 0.7786 0.00570 -0.00182 -0.0493 0.5571 1.0000
5.500 0.8244 0.00616 -0.00143 -0.0467 0.5181 1.0000
6.000 0.8668 0.00671 -0.00091 -0.0437 0.4747 1.0000
6.500 0.9071 0.00731 -0.00035 -0.0404 0.4266 1.0000
7.000 0.9428 0.00801 0.00025 -0.0365 0.3711 1.0000
7.500 0.9711 0.00908 0.00113 -0.0318 0.3036 1.0000
8.000 0.9917 0.01093 0.00262 -0.0264 0.2320 1.0000
8.500 1.0110 0.01355 0.00490 -0.0213 0.1785 1.0000
9.000 1.0882 0.02792 0.01854 -0.0235 0.1421 1.0000
9.500 1.1221 0.03089 0.02148 -0.0205 0.1190 1.0000
10.000 1.1598 0.03405 0.02465 -0.0183 0.1031 1.0000
10.500 1.1973 0.03767 0.02847 -0.0161 0.0916 1.0000
11.000 1.2322 0.04209 0.03317 -0.0140 0.0836 1.0000
11.500 1.2606 0.04628 0.03762 -0.0113 0.0772 1.0000
12.000 1.2653 0.05213 0.04410 -0.0065 0.0739 1.0000
12.500 1.2422 0.05766 0.05030 0.0003 0.0718 1.0000
13.000 1.2104 0.06457 0.05777 0.0047 0.0705 1.0000
13.500 1.1612 0.07422 0.06797 0.0054 0.0705 1.0000
14.000 1.0883 0.08908 0.08337 -0.0001 0.0721 1.0000
14.500 1.0109 0.10954 0.10413 -0.0117 0.0746 1.0000
15.000 0.8279 0.17920 0.17376 -0.0550 0.1417 1.0000
15.500 0.8213 0.18776 0.18227 -0.0613 0.1340 1.0000
16.000 0.8589 0.19541 0.19001 -0.0593 0.1265 1.0000
16.500 0.8427 0.20279 0.19731 -0.0686 0.1197 1.0000
17.500 0.8680 0.21716 0.21169 -0.0762 0.1059 1.0000
18.000 0.8944 0.22456 0.21915 -0.0766 0.1005 1.0000
18.500 0.8964 0.23154 0.22608 -0.0840 0.0958 1.0000
19.000 0.9158 0.23799 0.23256 -0.0865 0.0890 1.0000
19.500 0.9369 0.24759 0.24219 -0.0886 0.0866 1.0000
20.000 0.9403 0.25189 0.24645 -0.0970 0.0805 1.0000
20.500 0.9670 0.26021 0.25485 -0.0970 0.0763 1.0000
21.000 0.9713 0.26538 0.25998 -0.1055 0.0730 1.0000
21.500 0.9872 0.27158 0.26619 -0.1100 0.0684 1.0000
22.000 1.0133 0.28130 0.27599 -0.1100 0.0656 1.0000
22.500 1.0183 0.28500 0.27965 -0.1191 0.0635 1.0000
23.000 1.0338 0.29085 0.28553 -0.1241 0.0588 1.0000
23.500 1.0566 0.29996 0.29470 -0.1248 0.0563 1.0000
24.000 1.0655 0.30411 0.29882 -0.1330 0.0550 1.0000
24.500 1.0800 0.30973 0.30446 -0.1389 0.0515 1.0000
25.000 1.0969 0.31577 0.31055 -0.1425 0.0489 1.0000
25.500 1.1136 0.32394 0.31873 -0.1460 0.0476 1.0000
26.000 1.1256 0.32778 0.32259 -0.1539 0.0450 1.0000
26.500 1.1409 0.33344 0.32829 -0.1586 0.0426 1.0000
27.000 1.1576 0.34055 0.33545 -0.1615 0.0411 1.0000
27.500 1.1705 0.34579 0.34069 -0.1680 0.0402 1.0000
28.000 1.1843 0.35071 0.34565 -0.1744 0.0377 1.0000
28.500 1.1988 0.35607 0.35105 -0.1792 0.0357 1.0000
29.500 1.2260 0.36744 0.36247 -0.1896 0.0340 1.0000
30.000 1.2394 0.37245 0.36753 -0.1957 0.0322 1.0000
30.500 1.2525 0.37747 0.37258 -0.2008 0.0305 1.0000
31.000 1.2656 0.38410 0.37928 -0.2041 0.0294 1.0000
31.500 1.2775 0.38803 0.38321 -0.2112 0.0288 1.0000
32.000 1.2900 0.39281 0.38804 -0.2174 0.0275 1.0000
32.500 1.3019 0.39756 0.39283 -0.2229 0.0262 1.0000
33.000 1.3131 0.40213 0.39745 -0.2278 0.0252 1.0000
34.000 1.3354 0.41105 0.40644 -0.2396 0.0238 1.0000
34.500 1.3462 0.41514 0.41058 -0.2454 0.0226 1.0000
35.000 1.3563 0.41899 0.41448 -0.2509 0.0216 1.0000
35.500 1.3655 0.42293 0.41847 -0.2559 0.0209 1.0000
36.500 1.3844 0.43046 0.42609 -0.2680 0.0201 1.0000
37.000 1.3934 0.43410 0.42977 -0.2740 0.0191 1.0000
37.500 1.4016 0.43749 0.43321 -0.2797 0.0181 1.0000
38.000 1.4087 0.44075 0.43653 -0.2850 0.0175 1.0000
39.000 1.4231 0.44767 0.44354 -0.2969 0.0169 1.0000
39.500 1.4302 0.45105 0.44698 -0.3030 0.0163 1.0000
XFOIL Version 6.99
Calculated polar for: NACA 2412
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.100 Re = 1.000 e 6 Ncrit = 9.000
alpha CL CD CDp CM Top_Xtr Bot_Xtr
------ -------- --------- --------- -------- -------- --------
-20.000 -0.4490 0.19678 0.19513 0.0070 1.0000 0.0129
-19.000 -0.4374 0.18509 0.18343 0.0015 1.0000 0.0138
-18.500 -0.4262 0.18123 0.17957 -0.0006 1.0000 0.0144
-16.500 -0.9821 0.09468 0.09219 -0.0288 1.0000 0.0144
-16.000 -1.0670 0.07296 0.07016 -0.0415 1.0000 0.0142
-15.500 -1.1313 0.05388 0.05074 -0.0544 1.0000 0.0141
-15.000 -1.1610 0.04018 0.03670 -0.0659 1.0000 0.0142
-14.500 -1.1686 0.03296 0.02922 -0.0703 1.0000 0.0145
-14.000 -1.1657 0.02908 0.02513 -0.0689 1.0000 0.0148
-13.500 -1.1551 0.02658 0.02243 -0.0649 1.0000 0.0152
-13.000 -1.1317 0.02448 0.02013 -0.0616 1.0000 0.0157
-12.500 -1.1046 0.02280 0.01826 -0.0579 1.0000 0.0162
-12.000 -1.0843 0.02074 0.01601 -0.0530 1.0000 0.0169
-11.500 -1.0561 0.01942 0.01460 -0.0487 1.0000 0.0177
-11.000 -1.0251 0.01833 0.01340 -0.0446 1.0000 0.0185
-10.500 -0.9837 0.01727 0.01220 -0.0424 0.9994 0.0194
-10.000 -0.9224 0.01569 0.01048 -0.0445 0.9965 0.0208
-9.500 -0.8561 0.01475 0.00947 -0.0472 0.9942 0.0224
-9.000 -0.7932 0.01370 0.00831 -0.0491 0.9904 0.0242
-8.500 -0.7269 0.01284 0.00740 -0.0516 0.9868 0.0265
-8.000 -0.6578 0.01193 0.00643 -0.0546 0.9843 0.0293
-7.500 -0.5914 0.01132 0.00578 -0.0569 0.9795 0.0325
-7.000 -0.5276 0.01054 0.00499 -0.0586 0.9726 0.0370
-6.500 -0.4708 0.00993 0.00438 -0.0586 0.9619 0.0425
-6.000 -0.4157 0.00940 0.00384 -0.0582 0.9502 0.0492
-5.500 -0.3615 0.00893 0.00337 -0.0576 0.9364 0.0584
-5.000 -0.3073 0.00852 0.00296 -0.0569 0.9210 0.0702
-4.500 -0.2530 0.00810 0.00258 -0.0563 0.9030 0.0889
-4.000 -0.1983 0.00774 0.00226 -0.0558 0.8831 0.1137
-3.000 -0.0883 0.00711 0.00176 -0.0550 0.8367 0.1866
-2.500 -0.0333 0.00686 0.00157 -0.0546 0.8100 0.2353
-2.000 0.0218 0.00662 0.00143 -0.0542 0.7806 0.2927
-1.500 0.0768 0.00640 0.00131 -0.0539 0.7493 0.3601
-1.000 0.1310 0.00612 0.00123 -0.0534 0.7165 0.4566
-0.500 0.1848 0.00586 0.00121 -0.0529 0.6827 0.5721
0.000 0.2384 0.00569 0.00123 -0.0522 0.6488 0.6752
0.500 0.2916 0.00558 0.00129 -0.0514 0.6152 0.7697
1.000 0.3435 0.00552 0.00140 -0.0501 0.5831 0.8570
1.500 0.3947 0.00559 0.00154 -0.0485 0.5526 0.9249
2.000 0.4524 0.00580 0.00168 -0.0484 0.5229 0.9662
2.500 0.5206 0.00607 0.00183 -0.0508 0.4932 0.9853
3.000 0.5949 0.00637 0.00200 -0.0548 0.4618 0.9944
3.500 0.6708 0.00668 0.00217 -0.0592 0.4280 1.0000
4.000 0.7190 0.00696 0.00233 -0.0575 0.3955 1.0000
4.500 0.7666 0.00733 0.00255 -0.0558 0.3562 1.0000
5.000 0.8139 0.00780 0.00283 -0.0540 0.3114 1.0000
5.500 0.8603 0.00841 0.00320 -0.0521 0.2610 1.0000
6.000 0.9069 0.00912 0.00367 -0.0504 0.2078 1.0000
6.500 0.9531 0.00995 0.00423 -0.0487 0.1561 1.0000
7.000 0.9995 0.01081 0.00486 -0.0471 0.1139 1.0000
7.500 1.0465 0.01162 0.00552 -0.0456 0.0843 1.0000
8.000 1.0932 0.01245 0.00624 -0.0441 0.0640 1.0000
8.500 1.1397 0.01326 0.00699 -0.0425 0.0510 1.0000
9.000 1.1850 0.01412 0.00782 -0.0408 0.0420 1.0000
9.500 1.2296 0.01499 0.00869 -0.0391 0.0360 1.0000
10.000 1.2728 0.01589 0.00962 -0.0371 0.0316 1.0000
10.500 1.3126 0.01694 0.01073 -0.0346 0.0282 1.0000
11.000 1.3495 0.01803 0.01186 -0.0318 0.0255 1.0000
11.500 1.3802 0.01920 0.01312 -0.0279 0.0235 1.0000
12.000 1.4093 0.02052 0.01452 -0.0242 0.0217 1.0000
12.500 1.4310 0.02239 0.01650 -0.0200 0.0203 1.0000
13.000 1.4563 0.02414 0.01838 -0.0168 0.0192 1.0000
13.500 1.4769 0.02637 0.02071 -0.0137 0.0181 1.0000
14.000 1.4844 0.02986 0.02436 -0.0104 0.0170 1.0000
14.500 1.5008 0.03296 0.02763 -0.0084 0.0164 1.0000
15.000 1.5113 0.03688 0.03172 -0.0070 0.0157 1.0000
15.500 1.5166 0.04167 0.03667 -0.0063 0.0152 1.0000
16.000 1.5121 0.04794 0.04312 -0.0065 0.0147 1.0000
16.500 1.4914 0.05666 0.05206 -0.0080 0.0142 1.0000
17.000 1.4764 0.06523 0.06086 -0.0101 0.0140 1.0000
17.500 1.4621 0.07412 0.06997 -0.0128 0.0137 1.0000
18.000 1.4418 0.08415 0.08022 -0.0163 0.0135 1.0000
18.500 1.4189 0.09495 0.09124 -0.0204 0.0133 1.0000
19.000 1.3933 0.10651 0.10302 -0.0252 0.0130 1.0000
19.500 1.3681 0.11834 0.11504 -0.0305 0.0128 1.0000
20.000 1.3433 0.13044 0.12733 -0.0364 0.0126 1.0000
20.500 1.3208 0.14254 0.13961 -0.0428 0.0124 1.0000
21.000 1.2998 0.15469 0.15191 -0.0498 0.0122 1.0000
21.500 1.2814 0.16673 0.16410 -0.0571 0.0120 1.0000
22.000 1.2657 0.17848 0.17598 -0.0648 0.0117 1.0000
22.500 1.2454 0.19168 0.18936 -0.0737 0.0114 1.0000
23.000 1.2233 0.20661 0.20450 -0.0842 0.0113 1.0000
25.000 0.7014 0.26443 0.26300 -0.0793 0.0096 1.0000
25.500 0.7086 0.26903 0.26762 -0.0816 0.0093 1.0000
26.000 0.7156 0.27406 0.27266 -0.0837 0.0091 1.0000
26.500 0.7151 0.28442 0.28303 -0.0872 0.0079 1.0000
27.000 0.7208 0.28979 0.28842 -0.0897 0.0074 1.0000
27.500 0.7271 0.29442 0.29307 -0.0921 0.0072 1.0000
28.000 0.7316 0.30071 0.29937 -0.0945 0.0070 1.0000
28.500 0.7333 0.31026 0.30893 -0.0975 0.0061 1.0000
29.000 0.7381 0.31575 0.31444 -0.1001 0.0056 1.0000
29.500 0.7431 0.32064 0.31934 -0.1026 0.0054 1.0000
30.000 0.7474 0.32622 0.32493 -0.1049 0.0053 1.0000
30.500 0.7490 0.33616 0.33489 -0.1078 0.0048 1.0000
31.000 0.7527 0.34226 0.34101 -0.1104 0.0043 1.0000
31.500 0.7564 0.34751 0.34627 -0.1130 0.0040 1.0000
32.000 0.7600 0.35209 0.35087 -0.1155 0.0039 1.0000
32.500 0.7620 0.35970 0.35849 -0.1181 0.0038 1.0000
33.000 0.7643 0.36821 0.36702 -0.1206 0.0033 1.0000
33.500 0.7669 0.37422 0.37304 -0.1232 0.0030 1.0000
34.000 0.7692 0.37959 0.37843 -0.1258 0.0027 1.0000
34.500 0.7712 0.38434 0.38320 -0.1284 0.0026 1.0000
35.000 0.7725 0.39092 0.38979 -0.1309 0.0026 1.0000
35.500 0.7739 0.39926 0.39814 -0.1333 0.0024 1.0000
36.000 0.7753 0.40557 0.40448 -0.1358 0.0021 1.0000
36.500 0.7763 0.41110 0.41002 -0.1384 0.0018 1.0000
37.000 0.7771 0.41606 0.41500 -0.1410 0.0017 1.0000
37.500 0.7773 0.42037 0.41933 -0.1436 0.0016 1.0000
38.000 0.7773 0.42742 0.42640 -0.1461 0.0016 1.0000
38.500 0.7776 0.43492 0.43391 -0.1484 0.0015 1.0000
39.000 0.7775 0.44081 0.43982 -0.1508 0.0012 1.0000
39.500 0.7770 0.44601 0.44504 -0.1533 0.0011 1.0000
40.000 0.7762 0.45066 0.44971 -0.1558 0.0009 1.0000
40.500 0.7750 0.45470 0.45376 -0.1585 0.0009 1.0000
41.500 0.7723 0.46668 0.46577 -0.1631 0.0008 1.0000
42.000 0.7709 0.47254 0.47166 -0.1654 0.0007 1.0000
42.500 0.7690 0.47740 0.47653 -0.1677 0.0006 1.0000
43.000 0.7668 0.48172 0.48087 -0.1702 0.0005 1.0000
43.500 0.7643 0.48547 0.48463 -0.1726 0.0004 1.0000
44.000 0.7612 0.48854 0.48772 -0.1752 0.0003 1.0000
45.000 0.7555 0.49885 0.49806 -0.1796 0.0003 1.0000
% TEST_XF2MAT Unitary tests for the xf2mat function
% Note:
% Matlab package functionality is not very test-framework friendly.
% Either the whole package has to be imported in EVERY SINGLE TEST or the
% functions must be called as <package>.function() everytime.
% The second option is preferred for the tests as it has the smaller scope.
% -----
% Copyright 2022 Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% Apache 2.0 License
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% ------------------------------------------------------------------------------
%% Main test function
function tests = test_xf2mat
tests = functiontests(localfunctions);
end
%% Setup and teardown
function setupOnce(testCase)
addpath('../.'); % Add repository to Matlab Path
addpath('./test_utils'); % Add utils to Matlab Path
% Set random number generator settings.
testCase.TestData.currentRNG = rng;
end
function teardownOnce(testCase)
rmpath('../.'); % Remove repository from Matlab Path
rmpath('./test_utils'); % Remove utils from Matlab Path
% Restore the random number generator settings.
s = testCase.TestData.currentRNG;
rng(s)
end
function teardown(~)
close all; % Close all figures that would have been openend
end
%% Arguments and errors tests
function test_nargin(testCase)
% Error if too many arguments
dummy = (1:10)';
verifyError(testCase, @() af_tools.xf2mat(dummy, dummy, dummy, 'autosave',true,'trimAoas',false), 'MATLAB:narginchk:tooManyInputs')
end
function test_invalidInputsType(testCase)
% Error if base inputs are of the wrong type
empty = [];
scal = 0;
logi = true;
Struct = struct;
% 1. InputDir (char vector or string)
verifyError(testCase, @() af_tools.xf2mat(empty), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(scal), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(logi), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(Struct), 'MATLAB:xf2mat:invalidType')
% 2. cl (numeric)
verifyError(testCase, @() af_tools.xf2mat(scal, empty), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(scal, scal), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(scal, logi), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(scal, Struct), 'MATLAB:xf2mat:invalidType')
end
function test_invalidOptions(testCase)
% Error if invalid option name or missing parameter value
wrongName = 'wrongOption';
testdir = [pwd,'/test_utils'];
verifyError(testCase, @() af_tools.xf2mat(testdir, '*', wrongName), 'MATLAB:InputParser:ParamMissingValue')
verifyError(testCase, @() af_tools.xf2mat(testdir, '*', wrongName, true), 'MATLAB:InputParser:UnmatchedParameter')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', true, wrongName), 'MATLAB:InputParser:ParamMissingValue')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', true, wrongName, true), 'MATLAB:InputParser:UnmatchedParameter')
end
function test_invalidOptionsVal(testCase)
% Error if valid option name but invalid value
empty = [];
scal = 0;
char = 'test';
Struct = struct;
vect = 1:10;
testdir = [pwd,'/test_utils'];
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', empty), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', scal), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', char), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', Struct), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', vect), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'trimAoas', empty), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'trimAoas', scal), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'trimAoas', char), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'trimAoas', Struct), 'MATLAB:xf2mat:invalidType')
verifyError(testCase, @() af_tools.xf2mat(testdir, 'trimAoas', vect), 'MATLAB:xf2mat:invalidType')
end
% -------------------------------------
function test_dirNotFound(testCase)
% Error if valid inputDir not found
verifyError(testCase, @() af_tools.xf2mat('missingdir'), 'MATLAB:xf2mat:dirNotFound')
end
function test_fileNotFound(testCase)
% Error if valid inputDir not found
testdir = [pwd,'/test_utils'];
verifyWarning(testCase, @() af_tools.xf2mat(testdir, {'xflr*','randomFile'}), 'MATLAB:xf2mat:FileNotFound')
warning('off','MATLAB:xf2mat:FileNotFound') % remove warning first warning about FileNotFound before it throws the error
verifyError(testCase, @() af_tools.xf2mat(testdir, 'randomFile'), 'MATLAB:xf2mat:noFilesFound')
warning on % Reactivate warnings
end
%% Test if function returns expected outputs
function test_correctNbOfPolars(testCase)
% Verify if the output has the correct number of polars (columns in arrays)
testdir = [pwd,'/test_utils'];
Polar = af_tools.xf2mat(testdir, '*');
verifyEqual(testCase, size(Polar.alpha,2), 3)
verifyEqual(testCase, size(Polar.alpha,2), 3)
verifyEqual(testCase, size(Polar.alpha,2), 3)
verifyEqual(testCase, size(Polar.alpha,2), 3)
verifyEqual(testCase, size(Polar.alpha,2), size(Polar.cl,2))
verifyEqual(testCase, size(Polar.alpha,2), size(Polar.cl,2))
verifyEqual(testCase, size(Polar.alpha,2), size(Polar.cl,2))
end
function test_correctDimensions(testCase)
% Verify if the output has the correct number of polars (columns in arrays)
testdir = [pwd,'/test_utils'];
Polar = af_tools.xf2mat(testdir, '*');
verifyEqual(testCase, size(Polar.alpha,1), size(Polar.cl,1))
verifyEqual(testCase, size(Polar.alpha,1), size(Polar.cd,1))
verifyEqual(testCase, size(Polar.alpha,1), size(Polar.cm,1))
end
function test_correctPolarOrder(testCase)
% Verify if the output is properly ordered by Reynolds
testdir = [pwd,'/test_utils'];
Polar = af_tools.xf2mat(testdir, 'xfoil*');
import matlab.unittest.constraints.IsLessThanOrEqualTo
verifyThat(testCase,Polar.reynolds(1), IsLessThanOrEqualTo(Polar.reynolds(2)));
end
function test_correctOutputValues(testCase)
% Verify if the output has the correct values
testdir = [pwd,'/test_utils'];
Polar = af_tools.xf2mat(testdir, 'xfoil-naca2412_re1e6');
verifyEqual(testCase,Polar.alpha(1), deg2rad(-20));
verifyEqual(testCase,Polar.cl(1), -0.4490);
verifyEqual(testCase,Polar.cd(1), 0.19678);
verifyEqual(testCase,Polar.cm(1), 0.0070);
verifyEqual(testCase,Polar.reynolds, 1e6);
verifyEqual(testCase,Polar.mach, 0.1);
verifyEqual(testCase,Polar.nCrit, 9);
verifyEqual(testCase,Polar.origin, {'XFOIL'});
verifyEqual(testCase,Polar.airfoil, {'NACA_2412'});
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment