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

fix(extpol): incorrect cd_ext when multiple polars

parent 4d49475f
No related branches found
No related tags found
No related merge requests found
Pipeline #7094 passed
......@@ -214,7 +214,7 @@ function [alpha_ext, c_l_ext, c_d_ext] = viterna(limit, alpha, c_l, c_d)
% 1. Extend Cl/Cd to ]limit, 90]
alpha_1 = (alpha_l + alpha_step:alpha_step:pi / 2)';
[cl1, cd1] = viternaeq(VitCoeffs, alpha_1, 1);
[c_l_1, c_d_1] = viternaeq(VitCoeffs, alpha_1, 1);
% 2. Extend to ]90, 180-limit]
alpha_2 = (pi / 2 + alpha_step:alpha_step:pi - alpha_l)';
......@@ -251,12 +251,13 @@ function [alpha_ext, c_l_ext, c_d_ext] = viterna(limit, alpha, c_l, c_d)
% Concatenate everything to get the full extended polars
alpha_ext(:, i) = [alpha_6; alpha_5; alpha_4; trimmedAlpha; alpha_1; alpha_2; alpha_3];
c_l_ext(:, i) = [c_l_6; c_l_5; c_l_4; trimmedCl; cl1; c_l_2; c_l_3];
c_d_ext(:, i) = [c_d_6; c_d_5; c_d_4; trimmedCd; cd1; c_d_2; c_d_3];
c_l_ext(:, i) = [c_l_6; c_l_5; c_l_4; trimmedCl; c_l_1; c_l_2; c_l_3];
c_d_ext(:, i) = [c_d_6; c_d_5; c_d_4; trimmedCd; c_d_1; c_d_2; c_d_3];
% Trim negatives cd to cdmin
c_d_min = min(trimmedCd);
c_d_ext(c_d_ext <= c_d_min, i) = c_d_min;
c_d_ext(c_d_ext(:, i) <= c_d_min, i) = c_d_min;
end
end
......
......@@ -199,7 +199,7 @@ end
%% Test if function returns expected outputs
function test_correctAlphaSize(testCase)
function test_correctAlphaSizeSinglePolar(testCase)
% Verify if the output alpha has the correct size
% Should not re-expand polar that already covers the full range
......@@ -216,4 +216,29 @@ function test_correctAlphaSize(testCase)
verifyEqual(testCase, clExt2, clExt);
verifyEqual(testCase, cdExt2, cdExt);
verifyEqual(testCase, size(clExt2), size(alphaExt));
verifyEqual(testCase, size(cdExt2), size(alphaExt));
end
function test_correctAlphaSizeDoublePolar(testCase)
% Verify if the output alpha has the correct size
% Should not re-expand polar that already covers the full range
Polar = dummydoublepolar();
stepAlpha = min(diff(Polar.alpha));
fullRange = (-pi:stepAlpha:pi)';
[alphaExt, clExt, cdExt] = af_tools.extendpolar(Polar);
[alphaExt2, clExt2, cdExt2] = af_tools.extendpolar(alphaExt, clExt, cdExt);
verifyEqual(testCase, alphaExt(:, 1), fullRange, 'AbsTol', 1e-9);
verifyEqual(testCase, alphaExt2, alphaExt);
verifyEqual(testCase, clExt2, clExt);
verifyEqual(testCase, cdExt2, cdExt);
verifyEqual(testCase, size(clExt2), size(alphaExt));
verifyEqual(testCase, size(cdExt2), size(alphaExt));
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