diff --git a/+af_tools/@Polar/Polar.m b/+af_tools/@Polar/Polar.m index d9461b54cc4451533cac79968e0a0d827fdea90a..dd99a43618286d7d05993660bd72c7c022f98ba1 100644 --- a/+af_tools/@Polar/Polar.m +++ b/+af_tools/@Polar/Polar.m @@ -153,4 +153,10 @@ classdef Polar methods (Static) self = loadpolar(polarFile) % Load polar from file end + + % ---------------------------------------------------------------------------------------------- + + methods (Static) + self = polypolar(polyCl, polyCd) % Create polar using polynomial coefficients + end end diff --git a/+af_tools/@Polar/loadpolar.m b/+af_tools/@Polar/loadpolar.m index ea695286b3a03a88370b8038b39fc2e2e95e934d..f5b7779b7efcae88540932720a0887c851764002 100644 --- a/+af_tools/@Polar/loadpolar.m +++ b/+af_tools/@Polar/loadpolar.m @@ -1,7 +1,7 @@ function obj = loadpolar(polarFile) % LOADPOLAR Load a polar object from a file % 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 + % When this method 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. % ----- % diff --git a/+af_tools/@Polar/polypolar.m b/+af_tools/@Polar/polypolar.m new file mode 100644 index 0000000000000000000000000000000000000000..cd0b9cfb51d531e5a4981963d3814bdebf66c460 --- /dev/null +++ b/+af_tools/@Polar/polypolar.m @@ -0,0 +1,54 @@ +function Obj = polypolar(polyCl, polyCd) + % POLYPOLAR Create a polar object using polynomial coefficients for cl and cd + % This static method can be used in place of a normal constructor. + % This will create a Polar object based on the polynomial coefficients given as input. + % The polar created will cover the full range of angles of attack ([-pi, pi] rad), with a step + % of 0.5 deg between two points. + % ----- + % + % Usage: + % Polar.polypolar(polyCl,polyCd) returns a polar object with values equal to the coefficients. + % + % Inputs: + % polyCl : polynomial coefficients for cl (see polyval function for formatting), [1/deg] + % polyCd : polynomial coefficients for cd (see polyval function for formatting), [1/deg] + % + % Output: + % Obj: Polar object polynomial values for aoa, cl and cd an default values otherwise. + % + % Example: + % NewPolar = af_tools.Polar.polypolar([0.001, 2*pi, 0], [0.1, 0, 0.002]); + % + % See also: af_tools.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 + + % ---------------------------------------------------------------------------------------------- + + % Defaults and constants + DEF.AOA_STEP = 0.5; + DEF.AIRFOIL = {'Polynomial'}; + DEF.REYNOLDS = 1e6; + DEF.MACH = 0; + + % --------------------------------------- + % Construct empty object first + Obj = af_tools.Polar(); + + % Get lift and drag values + aoa_deg = (-180:DEF.AOA_STEP:180)'; + Obj.aoa = deg2rad(aoa_deg); + Obj.cl = polyval(polyCl, aoa_deg); + Obj.cd = polyval(polyCd, aoa_deg); + + % Set other properties to default values + Obj.airfoil = DEF.AIRFOIL; + Obj.reynolds = DEF.REYNOLDS; + Obj.mach = DEF.MACH; + +end diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b27383cd38590458b0dea76fc8b065cf4e3aa6a..4998329a4e27654cdaeffc7e39c738fe2a798451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **Polar**: add polypolar method + ### Changed ### Deprecated