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

add(polar): add polar class

parent e043099f
No related branches found
No related tags found
No related merge requests found
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
%
% 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
% - ...
%
% <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.
%
% 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).
%
% Pol = AIRFOIL(reynolds, aoa, c_l, c_d) initiates a polar object with only the lift and drag
% coefficient curves for the coresponding Reynolds.
%
% 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.
%
% -----
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% Apache 2.0 License
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% ----------------------------------------------------------------------------------------------
properties
airfoil
reynolds
mach
nCrit
aoa
cl
cd
cm
Ext = struct('aoa', [], 'cl', [], 'cd', [], 'cm', [])
Stall = struct('aoa', [], 'cl', [], 'cd', [])
Zero = struct('aoa', [], 'cd', [])
Lin = struct('slope', [], 'aoaRange', [], 'clRange', [])
origin
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.
if nargin > 0
narginchk(3, 5);
obj.reynolds = reynolds;
obj.aoa = aoa;
obj.cl = c_l;
if nargin >= 4
obj.cd = c_d;
if nargin >= 5
obj.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);
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);
end
function obj = findzerolift(obj)
% FINDZEROLIFT Find the zero-lift angle and associated cd
[obj.Zero.aoa, obj.Zero.cd] = af_tools.findzerolift(obj);
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);
end
function obj = analyse(obj)
% ANALYSE Analyse all polars to retreive the useful informations
obj = findstall(obj);
obj = findzerolift(obj);
obj = findlinrange(obj);
end
end
methods (Static)
% Load polar from file
obj = loadpolar(polarFile)
end
end
function obj = loadpolar(polarFile)
% LOADPOLAR Load a polar object from a file
% This static method can replace 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.
%
% Inputs:
% polarFile : MAT-File containing a polar object.
%
% Output:
% NewPolar : Copy of the polar object contained in polarFile.
%
% Example:
% NewPolar = af_tools.Polar.loadpolar('oldpolar.mat');
%
% See also: POLAR.
%
% -----
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% Apache 2.0 License
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% ----------------------------------------------------------------------------------------------
tmp = load(polarFile);
polarName = fieldnames(tmp);
if isempty(polarName)
error('POLAR:loadpolar:emptyPolarFile', ...
['The Polar file specified as input does not contain anything!\n'...
'See <help af_tools.Polar.loadpolar> for details about this method.']);
elseif length(polarName) > 1
error('POLAR:loadpolar:tooManyVarInPolarFile', ...
['The Polar file specified as input should only contain '...
'one polar object and nothing else.\n'...
'Found %d different variables instead!\n'...
'See <help af_tools.Polar.loadpolar> for details about this method.'], ...
length(polarName));
else
obj = tmp.(polarName{1});
end
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