diff --git a/+af_tools/@Polar/Polar.m b/+af_tools/@Polar/Polar.m index 69fbc62174ccb2da4668d25048bc98d86d3b849d..524377a009195f817daaf2be28d254e93ec1e4ee 100644 --- a/+af_tools/@Polar/Polar.m +++ b/+af_tools/@Polar/Polar.m @@ -181,7 +181,7 @@ classdef Polar < handle self = polypolar(polyCl, polyCd) % Create polar using polynomial coefficients % Create a polar by interpolating between two different polar objects - self = interppolar(Polar1, Polar2, position) + self = interppolar(Polar1, Polar2, weightPolar2) end end diff --git a/+af_tools/@Polar/interppolar.m b/+af_tools/@Polar/interppolar.m index 054ff051bdb04b7375390b3ed01511f95281be13..3b8d661f68fdc8ee70bd179e4fac68e201eed4dc 100644 --- a/+af_tools/@Polar/interppolar.m +++ b/+af_tools/@Polar/interppolar.m @@ -1,6 +1,6 @@ function self = interppolar(Polar1, Polar2, weightPolar2) % 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 % 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 @@ -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 % 0012 and 10% of CLARK-Y. % 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: @@ -27,7 +27,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) % Example: % MixedPolar = af_tools.interppolar(PolarNACA0012, PolarClarkY, 0.6); Creates an interpolated % 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. % % See also: af_tools.Polar. @@ -45,7 +45,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) % ---------------------------------------------------------------------------------------------- % --- Defaults and constants - DEBUG = true; + DEBUG = false; % --- Input checks % Check if both Polars are Polars objects and weightPolar2 is in [0,1] @@ -54,8 +54,7 @@ function self = interppolar(Polar1, Polar2, weightPolar2) validateattributes(weightPolar2, {'double'}, {'scalar', 'nonnegative', '<=', 1}, ... mfilename(), 'weightPolar2', 3); - % Check that both Polars have the same AOA, Reynolds, Mach and nCrit - equalfieldscheck(Polar1, Polar2, 'aoa'); + % Check that both Polars have the Reynolds, Mach and nCrit equalfieldscheck(Polar1, Polar2, 'reynolds'); equalfieldscheck(Polar1, Polar2, 'mach'); equalfieldscheck(Polar1, Polar2, 'nCrit'); @@ -64,6 +63,25 @@ function self = interppolar(Polar1, Polar2, weightPolar2) 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; wPol1 = 1 - wPol2; nPolars = numel(Polar1.reynolds); @@ -118,8 +136,10 @@ function self = interppolar(Polar1, Polar2, weightPolar2) plot(Polar1.aoa(:, j), Polar1.cl(:, j)); plot(Polar2.aoa(:, j), Polar2.cl(:, j)); plot(self.aoa(:, j), self.cl(:, j)); + hold off; legend(Polar1.airfoil{1}, Polar2.airfoil{1}, self.airfoil{1}, 'Location', 'NorthWest'); grid on; + pause; end end