diff --git a/processall.m b/processall.m index 0356a4bf6793327f463167dc055b9fa64ef78201..5e20280f64467cf77d64c0611941a6356168ba94 100644 --- a/processall.m +++ b/processall.m @@ -62,6 +62,14 @@ function ExpData = processall(idFile) if ~isempty(ExpData(iTest).arduFile) % Not for static tests (no ardu data) [arduShort, ~] = loadardu(ExpData(iTest).arduFile); + + % DEBUG + figure; + hold on; + plot(tunnelData(:, 1)); + plot(tunnelData(:, 3)); + grid on; + [arduShort, tunnelData, ExpData(iTest).arduStart, ExpData(iTest).tunnelStart] = ... syncdata(arduShort, tunnelData); diff --git a/utils/analysis/plotcf.m b/utils/analysis/plotcf.m index e3571c3a0df7994a893ff232d457749ea37167ca..2e6d6630841fd11f4c4f55835f918ba70aad17f4 100644 --- a/utils/analysis/plotcf.m +++ b/utils/analysis/plotcf.m @@ -14,10 +14,14 @@ function plotcf(ResData) % One figure per dx % Plot airspeeds in different colors + set(0, 'defaulttextinterpreter', 'latex'); + ONLY_ERR_BARS = true; + ERR_CAPSIZE = 3; OFFSET_STEPS = 20; - + CHORD = 0.05; INTERESTING_PLOTS = [ + 0.03, 2, 7.7 0.03, 2, 7.7 0.03, 3, 2.5 0.03, 3, 4.6 @@ -25,7 +29,7 @@ function plotcf(ResData) 0.03, 3.5, 4.6 0.03, 3.5, 7.7 - 0.05, 1.25, 4.6 + % 0.05, 1.25, 4.6 % DRIFT ON INERTIA 0.05, 2, 7.7 0.05, 3, 7.7 0.05, 3.5, 2.5 @@ -38,14 +42,22 @@ function plotcf(ResData) 0.10, 3.5, 7.7 ]; + SAVE_TIKZ_PARAM = [0, 0, 0]; % Points to save ([0,0,0] to make sur nothing is save) + for i = 1:size(ResData, 1) for j = 1:size(ResData, 2) if isinteresting(ResData(i, j), INTERESTING_PLOTS) - expParam = sprintf('d = %0.2f, f = %0.2f, V = %0.1f', ... + + trueF = ResData(i, j).Front.trueFreq; + + redFreq = redfreq(trueF, CHORD, ResData(i, j).Testcase.airspeed); + + expParam = sprintf('d = %0.2f, f = %0.2f, V = %0.1f (k = %0.02f)', ... ResData(i, j).Testcase.dx, ... ResData(i, j).Testcase.freq, ... - ResData(i, j).Testcase.airspeed); + ResData(i, j).Testcase.airspeed, ... + redFreq); offsets = ResData(i, j).AllPhases.offsets; cleanOffsets = -175:OFFSET_STEPS:175; @@ -72,40 +84,170 @@ function plotcf(ResData) xpos = cleanOffsets - meanOffset + stdOffset; figure('Name', 'myfig'); - subplot(211); + ax1 = subplot(211); + setcolormap(); hold on; if ~ONLY_ERR_BARS plot(ResData(i, j).AllPhases.offsets, ... ResData(i, j).AllPhases.Front.cF(:, [1, 3]), 'o'); end - errorbar(cleanOffsets, meanF(:, 1), ynegF(:, 1), yposF(:, 1), xneg, xpos, 'o'); - errorbar(cleanOffsets, meanF(:, 3), ynegF(:, 3), yposF(:, 3), xneg, xpos, 'o'); + errorbar(cleanOffsets, meanF(:, 3), yposF(:, 3), 'o', 'Capsize', ERR_CAPSIZE); + errorbar(cleanOffsets, meanF(:, 1), yposF(:, 1), 'o', 'Capsize', ERR_CAPSIZE); hold off; - title(['Front module -- ', expParam]); - - setgca(); - - subplot(212); + setgca('XTickLabel', [], ... + 'XLabel', []); + legend({'\cl', '\cd'}, 'Location', 'SouthWest'); + legend('boxoff'); + ax1.Position(3) = 1.25 * ax1.Position(3); + title('Front'); + + ax2 = subplot(212); + setcolormap(); hold on; if ~ONLY_ERR_BARS plot(ResData(i, j).AllPhases.offsets, ... ResData(i, j).AllPhases.Aft.cF(:, [1, 3]), 'o'); end - errorbar(cleanOffsets, meanA(:, 1), ynegA(:, 1), yposA(:, 1), xneg, xpos, 'o'); - errorbar(cleanOffsets, meanA(:, 3), ynegA(:, 3), yposA(:, 3), xneg, xpos, 'o'); + errorbar(cleanOffsets, meanA(:, 3), yposA(:, 3), 'o', 'Capsize', ERR_CAPSIZE); + errorbar(cleanOffsets, meanA(:, 1), yposA(:, 1), 'o', 'Capsize', ERR_CAPSIZE); hold off; - title(['Aft module -- ', expParam]); + title(ax2, 'Aft'); + setgca(); - legend('Location', 'bestoutside', 'orientation', 'horizontal', 'Fx', 'Fz'); + linkaxes([ax1 ax2], 'xy'); + ax2.Position(3) = ax1.Position(3); + title('Aft'); + + if isinteresting(ResData(i, j), SAVE_TIKZ_PARAM) + figdir = 'figures/results/'; + filename = sprintf('flapWindOn-Dx%0.2f_F%0.2f_V%0.1f.tex', ... + ResData(i, j).Testcase.dx, ... + ResData(i, j).Testcase.freq, ... + ResData(i, j).Testcase.airspeed); + save2tikz([figdir, filename], '\small'); + end + % Update titles after having saved + title(ax1, ['Front - ', expParam]); + title(ax2, ['Aft - ', expParam]); + + % Save interesting stuff for other types of plots + Tmp(i, j).cleanOffsets = cleanOffsets; + Tmp(i, j).meanF = meanF; + Tmp(i, j).stdF = stdF; + Tmp(i, j).meanA = meanA; + Tmp(i, j).stdA = stdA; end end end + % Plot aft wings only for different spacing conditions + for j = 26 + + figure('Name', 'Dx'); + ax1 = subplot(211); + setcolormap(); + hold on; + errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + hold off; + setgca('XTickLabel', [], ... + 'XLabel', []); + title('$\dx = 0.03 \unit{\m}$'); + legend({'\cl', '\cd'}, 'Location', 'NorthEast'); + legend('boxoff'); + ax1.Position(3) = 1.25 * ax1.Position(3); + + ax2 = subplot(212); + setcolormap(); + hold on; + errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + hold off; + setgca(); + title('$\dx = 0.10 \unit{\m}$'); + linkaxes([ax1 ax2], 'xy'); + ax2.Position(3) = ax1.Position(3); + + figdir = 'figures/results/'; + filename = sprintf('flapWindOn-DxCompa-F%0.2f_V%0.1f.tex', ... + ResData(i, j).Testcase.freq, ... + ResData(i, j).Testcase.airspeed); + save2tikz([figdir, filename], '\small'); + + end + + % Plot aft wings only for diff frequencies + j = 20; + figure('Name', 'K'); + ax1 = subplot(211); + setcolormap(); + hold on; + errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + hold off; + setgca('XTickLabel', [], ... + 'XLabel', []); + title('$\redFreq = 0.05$'); + legend({'\cl', '\cd'}, 'Location', 'NorthEast'); + legend('boxoff'); + ax1.Position(3) = 1.25 * ax1.Position(3); + + j = 28; + ax2 = subplot(212); + setcolormap(); + hold on; + errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + hold off; + setgca(); + title('$\redFreq = 0.07$'); + linkaxes([ax1 ax2], 'x'); + ax2.Position(3) = ax1.Position(3); + + figdir = 'figures/results/'; + filename = sprintf('flapWindOn-kCompa-Dx%0.2f_V%0.1f.tex', ... + ResData(i, j).Testcase.dx, ... + ResData(i, j).Testcase.airspeed); + save2tikz([figdir, filename], '\small'); + end -function setgca() - % SETGCA Sets the axes parameters +function setgca(varargin) + xlim([-180, 180]); - grid on; + + xlabel('Phase offset [deg]'); + ylabel('\cl and \cd [-]'); + xticks([-180:90:180]); + + set(gca, ... + 'Box', 'off', ... + 'TickDir', 'out', ... + 'TickLength', [.02 .02], ... + 'XMinorTick', 'off', ... + 'YMinorTick', 'off', ... + 'YGrid', 'on', ... + 'XGrid', 'on', ... + 'XColor', 'k', ... + 'YColor', 'k', ... + 'GridLineStyle', ':', ... + 'GridColor', 'k', ... + 'GridAlpha', 0.25, ... + 'LineWidth', 1, ... + 'FontName', 'Helvetica', ... + 'Fontsize', 14); + + if nargin > 0 + set(gca, varargin{:}); + end + end diff --git a/utils/redfreq.m b/utils/redfreq.m new file mode 100644 index 0000000000000000000000000000000000000000..b32168418ee163909bff237adcd369cdada09e5e --- /dev/null +++ b/utils/redfreq.m @@ -0,0 +1,13 @@ +function redFreq = redfreq(freq, chord, speed) + % REFREQ Calculate the reduced frequency + % Todo + + % ---------------------------------------------------------------------------------------------- + % (c) Copyright 2022 University of Liege + % Author: Thomas Lambert <t.lambert@uliege.be> + % ULiege - Aeroelasticity and Experimental Aerodynamics + % MIT License + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + redFreq = pi * freq * chord / speed; +end diff --git a/utils/syncdata.m b/utils/syncdata.m index 05dccc01a29b372bd84d074347b83e1bcd47c716..9003ff9164f2e30ade66ee4d0cb0e0e56e81b3e2 100644 --- a/utils/syncdata.m +++ b/utils/syncdata.m @@ -71,7 +71,7 @@ function [arduSynced, tunnelSynced, arduStartTime, tunnelStartTime] = ... end function [startIdx, startTime] = getstartardu(arduData) - % GETSTARTARDU Get the starting point for the arduino dataset and the flapping direction at + % GETSTARTARDU Get the starting po int for the arduino dataset and the flapping direction at % start ANGLE_IDX = [2, 3]; % Indexes of the front and aft angles in arduData file