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

feat(plots): add new plots, improve plot style

parent 8820a868
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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
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
......@@ -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
......
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