Skip to content
Snippets Groups Projects
Unverified Commit 4c2bae32 authored by Thomas Lambert's avatar Thomas Lambert
Browse files

refact(Polar): early return when interp between same polars

parent fbf8ebf7
No related branches found
No related tags found
No related merge requests found
...@@ -181,7 +181,7 @@ classdef Polar < handle ...@@ -181,7 +181,7 @@ classdef Polar < handle
self = polypolar(polyCl, polyCd) % Create polar using polynomial coefficients self = polypolar(polyCl, polyCd) % Create polar using polynomial coefficients
% Create a polar by interpolating between two different polar objects % Create a polar by interpolating between two different polar objects
self = interppolar(Polar1, Polar2, position) self = interppolar(Polar1, Polar2, weightPolar2)
end end
end end
function self = interppolar(Polar1, Polar2, weightPolar2) function self = interppolar(Polar1, Polar2, weightPolar2)
% INTERPPOLAR Create a new polar object by interpolation of two other polars. % INTERPPOLAR Create a new polar object by interpolation of two other polars.
% This static method can be used in place of a normal constructor. % This static method can be used in place of a normal constructor for the Polar class.
% This method can be used when the user wants to interpolate the polars bewteen two known % This method can be used when the user wants to interpolate the polars bewteen two known
% airfoils. Consider that the airfoil at x=0 is a NACA 0012, and the one at x=1 is a CLARY-Y. % airfoils. Consider that the airfoil at x=0 is a NACA 0012, and the one at x=1 is a CLARY-Y.
% Rather than assuming that all segments in [0,1] are NACA 0012 and all segments after 1 are % Rather than assuming that all segments in [0,1] are NACA 0012 and all segments after 1 are
...@@ -8,7 +8,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) ...@@ -8,7 +8,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
% the two bounds. If we are at 0.1, the newly created Polar object, will then be 90% of NACA % the two bounds. If we are at 0.1, the newly created Polar object, will then be 90% of NACA
% 0012 and 10% of CLARK-Y. % 0012 and 10% of CLARK-Y.
% Note: % Note:
% The two input Polars should have the same range of AOA, Reynolds, Mach, and nCrit. % The two input Polars should have the same range of Reynolds, Mach, and nCrit.
% ----- % -----
% %
% Usage: % Usage:
...@@ -27,7 +27,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) ...@@ -27,7 +27,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
% Example: % Example:
% MixedPolar = af_tools.interppolar(PolarNACA0012, PolarClarkY, 0.6); Creates an interpolated % MixedPolar = af_tools.interppolar(PolarNACA0012, PolarClarkY, 0.6); Creates an interpolated
% Polar object MixedPolar that results from the interpolation of PolarNACA0012 % Polar object MixedPolar that results from the interpolation of PolarNACA0012
% and PolarClarkY, asusming that the MixedPolar is made of 60% ClarkY and 40% % and PolarClarkY, assuming that the MixedPolar is made of 60% ClarkY and 40%
% NACA0012. % NACA0012.
% %
% See also: af_tools.Polar. % See also: af_tools.Polar.
...@@ -45,7 +45,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) ...@@ -45,7 +45,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
% ---------------------------------------------------------------------------------------------- % ----------------------------------------------------------------------------------------------
% --- Defaults and constants % --- Defaults and constants
DEBUG = true; DEBUG = false;
% --- Input checks % --- Input checks
% Check if both Polars are Polars objects and weightPolar2 is in [0,1] % Check if both Polars are Polars objects and weightPolar2 is in [0,1]
...@@ -54,8 +54,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) ...@@ -54,8 +54,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
validateattributes(weightPolar2, {'double'}, {'scalar', 'nonnegative', '<=', 1}, ... validateattributes(weightPolar2, {'double'}, {'scalar', 'nonnegative', '<=', 1}, ...
mfilename(), 'weightPolar2', 3); mfilename(), 'weightPolar2', 3);
% Check that both Polars have the same AOA, Reynolds, Mach and nCrit % Check that both Polars have the Reynolds, Mach and nCrit
equalfieldscheck(Polar1, Polar2, 'aoa');
equalfieldscheck(Polar1, Polar2, 'reynolds'); equalfieldscheck(Polar1, Polar2, 'reynolds');
equalfieldscheck(Polar1, Polar2, 'mach'); equalfieldscheck(Polar1, Polar2, 'mach');
equalfieldscheck(Polar1, Polar2, 'nCrit'); equalfieldscheck(Polar1, Polar2, 'nCrit');
...@@ -64,6 +63,25 @@ function self = interppolar(Polar1, Polar2, weightPolar2) ...@@ -64,6 +63,25 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
self = af_tools.Polar; self = af_tools.Polar;
if Polar1 == Polar2
self.properties = self.properties;
self.airfoil = self.airfoil;
self.reynolds = self.reynolds;
self.mach = self.mach;
self.nCrit = self.nCrit;
self.aoa = self.aoa;
self.cl = self. cl;
self.cd = self.cd;
self.cm = self.cm;
self.Ext = self.Ext;
self.Stall = self.Stall;
self.Zero = self.Zero;
self.Lin = self.Lin;
self.extrapMethod = self.extrapMethod;
return
end
wPol2 = weightPolar2; wPol2 = weightPolar2;
wPol1 = 1 - wPol2; wPol1 = 1 - wPol2;
nPolars = numel(Polar1.reynolds); nPolars = numel(Polar1.reynolds);
...@@ -118,8 +136,10 @@ function self = interppolar(Polar1, Polar2, weightPolar2) ...@@ -118,8 +136,10 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
plot(Polar1.aoa(:, j), Polar1.cl(:, j)); plot(Polar1.aoa(:, j), Polar1.cl(:, j));
plot(Polar2.aoa(:, j), Polar2.cl(:, j)); plot(Polar2.aoa(:, j), Polar2.cl(:, j));
plot(self.aoa(:, j), self.cl(:, j)); plot(self.aoa(:, j), self.cl(:, j));
hold off;
legend(Polar1.airfoil{1}, Polar2.airfoil{1}, self.airfoil{1}, 'Location', 'NorthWest'); legend(Polar1.airfoil{1}, Polar2.airfoil{1}, self.airfoil{1}, 'Location', 'NorthWest');
grid on; grid on;
pause;
end end
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