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

add,doc(polar): add checks and improve doc

parent a5bb97ba
No related branches found
No related tags found
No related merge requests found
Pipeline #7114 passed
classdef Polar
% POLAR Class for polars and their manipulations.
% This POLAR class is used to represent completely one or multiple polars related to an
% airfoil. It defines the following properties
% - reynolds
% - mach
% - angles of attack
% - lift, drag and moment coefficients
% POLAR Class for polars and their manipulations.
% The POLAR class is used to represent completely one or multiple polar curves related to a
% single airfoil.
%
% It also defines a few methods that can be used to manipulate easily a polar such as:
% - extend the values over all angles of attack from -180 to 180 deg,
% - find the zero lift angle and cd_0
% - find the stall angle
% - find the lift curve linear slope
% - ...
% The class also implements quick shortcuts for the more generic functions of af_tools, such
% as findcllinearrange, findstall or findzerolift.
%
% <a href="https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox">Documentation (README)</a>
% <a href="https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/issues">Report an issue</a>
% -----
%
% Usage:
% Pol = POLAR initiates an empty polar object.
% Properties:
% - airfoil : Airfoil name
% - reynolds : Rynolds number of each polar curve
% - mach : Mach number of each polar curve
% - nCrit : nCrit number of each polar curve
% - aoa : Angles of attack (one column per Reynolds)
% - cl : Lift coefficient (one row per aoa, one column per Reynolds)
% - cd : Drag coefficient (one row per aoa, one column per Reynolds)
% - cm : Moment coefficient (one row per aoa, one column per Reynolds)
%
% Pol = AIRFOIL(reynolds, aoa, c_l) initiates a polar object with only the lift coefficient
% curves corresponding to the Reynolds numbers 'reynolds'. The Reynolds number can be a vector
% if multiple curves (multiple columns for aoa and c_l).
% Private properties (set by running the methods below):
% - Ext : Struct with the data of the extended polars
% - Stall : Struct with the data of the stall point for each curve
% - Zero : Struct with the data of the zero-lift point for each curve
% - Lin : Struct with the data of the linear range each curve
%
% Pol = AIRFOIL(reynolds, aoa, c_l, c_d) initiates a polar object with only the lift and drag
% coefficient curves for the coresponding Reynolds.
% Methods (consult the help of each method with "help af_tools.Polar.<method>"):
% - loadpolar : Load a polar from the MAT-file
% - extendpolar : Extend polar curves over [-pi, pi]
% - findstall : Find stall point
% - findzerolift : Find zero-lift point
% - findcllinrange : Find lift curve linear range
% - analyse : Runs the above three functions
% - plotpolars : Plot the polars
%
% Pol = AIRFOIL(reynolds, aoa, c_l, c_d, c_m) initiates a polar object with the curves for the
% three coefficients (lift, drag and moment) for the coresponding Reynolds.
%
% Inputs:
% reynolds : Reynolds number of each data set (vector)
% aoa : Angles of attack for the polar (one column per reynolds), IN RADIANS
% c_l : Lift coefficient (one column per reynolds, one row per angle of attack)
% c_d : Drag coefficient (one column per reynolds, one row per angle of attack)
% c_m : Moment coefficient (one column per reynolds, one row per angle of attack)
%
% Example:
% Pol = POLAR
% Pol = POLAR(1e6,aoa, c_l)
% Pol = POLAR(1e6,aoa, c_l, c_d)
% Pol = POLAR(1e6,aoa, c_l, c_d, c_m)
%
% See also: XF2MAT, EXTENDPOLAR.
% See also: af_tools.xf2mat.
%
% -----
% (c) Copyright 2022 University of Liege
......@@ -56,74 +48,110 @@ classdef Polar
% ----------------------------------------------------------------------------------------------
properties
airfoil
reynolds
mach
nCrit
aoa
cl
cd
cm
Ext = struct('aoa', [], 'cl', [], 'cd', [], 'cm', [])
airfoil (1, :) cell
reynolds (1, :) double {mustBePositive}
mach (1, :) double {mustBePositive}
nCrit (1, :) double {mustBePositive}
aoa (:, :) double {mustBeReal}
cl (:, :) double {mustBeReal}
cd (:, :) double {mustBeReal}
cm (:, :) double {mustBeReal}
origin (1, :) cell
end
properties (SetAccess = private)
Ext = struct('aoa', [], 'cl', [], 'cd', [], 'cm', [])
Stall = struct('aoa', [], 'cl', [], 'cd', [])
Zero = struct('aoa', [], 'cd', [])
Lin = struct('slope', [], 'aoaRange', [], 'clRange', [])
origin
Zero = struct('aoa', [], 'cd', [])
Lin = struct('slope', [], 'aoaRange', [], 'clRange', [])
end
% ----------------------------------------------------------------------------------------------
methods
function obj = Polar(reynolds, aoa, c_l, c_d, c_m)
% POLAR Construct an instance of this class.
% Initiates the Polar object based on the various inputs.
function self = Polar(reynolds, aoa, c_l, c_d, c_m)
% POLAR Constructor for Polar object
% Create a polar object with basic information.
%
% See also: af_tools.Polar.loadpolar
if nargin > 0
narginchk(3, 5);
obj.reynolds = reynolds;
obj.aoa = aoa;
obj.cl = c_l;
self.reynolds = reynolds;
self.aoa = aoa;
self.cl = c_l;
if nargin >= 4
obj.cd = c_d;
self.cd = c_d;
if nargin >= 5
obj.cm = c_m;
self.cm = c_m;
end
end
end
end
function obj = extendpolar(obj)
% EXTENDPOLAR Extends the polar data over the full range of AOA ([-180, 180] deg).
[obj.Ext.aoa, obj.Ext.cl, obj.Ext.cd] = af_tools.extendpolar(obj);
% ---------------------------------------
function self = extendpolar(self)
% EXTENDPOLAR Extends the polar data over the full range of AOA ([-180, 180] deg)
%
% See also: af_tools.extendpolar.
[self.Ext.aoa, self.Ext.cl, self.Ext.cd] = af_tools.extendpolar(self);
end
% ---------------------------------------
function self = findstall(self)
% FINDSTALL Find the stall point of the polars
%
% See also: af_tools.findstall.
[self.Stall.aoa, self.Stall.cl, self.Stall.cd] = af_tools.findstall(self);
end
function obj = findstall(obj)
% FINDSTALL Find the stall point of the polars
[obj.Stall.aoa, obj.Stall.cl, obj.Stall.cd] = af_tools.findstall(obj);
% ---------------------------------------
function self = findzerolift(self)
% FINDZEROLIFT Find the zero-lift angle and associated cd
%
% See also: af_tools.findzerolift.
[self.Zero.aoa, self.Zero.cd] = af_tools.findzerolift(self);
end
function obj = findzerolift(obj)
% FINDZEROLIFT Find the zero-lift angle and associated cd
[obj.Zero.aoa, obj.Zero.cd] = af_tools.findzerolift(obj);
% ---------------------------------------
function self = findcllinrange(self)
% FINDZEROLIFT Find the linear range of the cl and its slope
%
% See also: af_tools.findcllinrange.
[self.Lin.clRange, self.Lin.aoaRange, self.Lin.slope] = ...
af_tools.findcllinearrange(self);
end
function obj = findlinrange(obj)
% FINDZEROLIFT Find the linear range of the cl and its slope
[obj.Lin.clRange, obj.Lin.aoaRange, obj.Lin.slope] = af_tools.findcllinearrange(obj);
% ---------------------------------------
function plotpolars(self)
% PLOTPOLARS Plot the polars
%
% See also: af_tools.plotpolars.
af_tools.plotpolars(self);
end
function obj = analyse(obj)
% ANALYSE Analyse all polars to retreive the useful informations
obj = findstall(obj);
obj = findzerolift(obj);
obj = findlinrange(obj);
% ---------------------------------------
function self = analyse(self)
% ANALYSE Get all useful information from the polar curves at once
%
% See also: af_tools.findstall, af_tools.findzerolift, af_tools.findcllinrange.
self = findstall(self);
self = findzerolift(self);
self = findcllinrange(self);
end
end
% ----------------------------------------------------------------------------------------------
methods (Static)
% Load polar from file
obj = loadpolar(polarFile)
self = loadpolar(polarFile) % Load polar from file
end
end
function obj = loadpolar(polarFile)
% LOADPOLAR Load a polar object from a file
% This static method can replace a normal constructor.
% This static method can be used in place of a normal constructor.
% When this function is used, the Polar object saved in the MAT-File will be imported. By
% assigning the output to something, it effectively duplicates the polar from the MAT-file.
% -----
%
% Usage:
% NewPolar.LOADPOLAR(polarFile) load the polar object stored in polarFile into the NewPolar.
% Polar.LOADPOLAR(polarFile) loads the polar object stored in polarFile into the NewPolar.
%
% Inputs:
% polarFile : MAT-File containing a polar object.
% polarFile : MAT-File containing only a single polar object.
%
% Output:
% NewPolar : Copy of the polar object contained in polarFile.
% Polar object contained in polarFile.
%
% Example:
% NewPolar = af_tools.Polar.loadpolar('oldpolar.mat');
%
% See also: POLAR.
% See also: af_tools.Polar.
%
% -----
% (c) Copyright 2022 University of Liege
......@@ -27,9 +27,14 @@ function obj = loadpolar(polarFile)
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% ----------------------------------------------------------------------------------------------
% Load the file
tmp = load(polarFile);
% Get name of variables in file (normally only polar object)
polarName = fieldnames(tmp);
% Check for issues and assign polar object
if isempty(polarName)
error('POLAR:loadpolar:emptyPolarFile', ...
['The Polar file specified as input does not contain anything!\n'...
......
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