Skip to content

Commit

Permalink
Third version
Browse files Browse the repository at this point in the history
  • Loading branch information
dciliberti committed Aug 23, 2019
1 parent 05d57d9 commit 3181dbc
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 76 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.asv
.DS_Store
Thumbs.db
Binary file removed example/operativePointsContour_scale1_22.png
Binary file not shown.
Binary file removed example/operativePointsContour_scale1_25.png
Binary file not shown.
Binary file removed example/operativePointsSurface_scale1_22.png
Binary file not shown.
Binary file removed example/operativePointsSurface_scale1_25.png
Binary file not shown.
Binary file added example/shaftPowerContourPlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/shaftPowerSurfacePlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
163 changes: 87 additions & 76 deletions performanceCharts.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
% Calculate the Lehner 2280-40 electric motor map from performance data
% issued by the manufacturer. Plot propeller operating points on the map.
% Version 2. Current calculated from RPM and shaft power assigned by the
% user, which has only to provide the desired propeller advance ratio J,
% the expected shaft power in Watt and the RPM.
% Version 3. Same as Version 2, but with X and Y axes swapped. Some
% variables have been renamed.
close all; clearvars; clc

% Operative points: J, Power (W), RPM
Expand Down Expand Up @@ -31,123 +30,135 @@

% Current Input power RPM Momentum Output power Efficiency
% A W /min Ncm W %
x = [V1(:,1); V2(:,1); V3(:,1); V4(:,1); V5(:,1); V6(:,1); V7(:,1); ...
c = [V1(:,1); V2(:,1); V3(:,1); V4(:,1); V5(:,1); V6(:,1); V7(:,1); ...
V8(:,1); V9(:,1); V10(:,1); V11(:,1); V12(:,1)]; % Current
y = [V1(:,3); V2(:,3); V3(:,3); V4(:,3); V5(:,3); V6(:,3); V7(:,3); ...
e = [V1(:,2); V2(:,2); V3(:,2); V4(:,2); V5(:,2); V6(:,2); V7(:,2); ...
V8(:,2); V9(:,2); V10(:,2); V11(:,2); V12(:,2)]; % Input (electric) power
r = [V1(:,3); V2(:,3); V3(:,3); V4(:,3); V5(:,3); V6(:,3); V7(:,3); ...
V8(:,3); V9(:,3); V10(:,3); V11(:,3); V12(:,3)]; % RPM
z = [V1(:,5); V2(:,5); V3(:,5); V4(:,5); V5(:,5); V6(:,5); V7(:,5); ...
V8(:,5); V9(:,5); V10(:,5); V11(:,5); V12(:,5)]; % Output power
t = [V1(:,4); V2(:,4); V3(:,4); V4(:,4); V5(:,4); V6(:,4); V7(:,4); ...
V8(:,4); V9(:,4); V10(:,4); V11(:,4); V12(:,4)]; % Momentum (torque)
s = [V1(:,5); V2(:,5); V3(:,5); V4(:,5); V5(:,5); V6(:,5); V7(:,5); ...
V8(:,5); V9(:,5); V10(:,5); V11(:,5); V12(:,5)]; % Output (shaft) power
h = [V1(:,6); V2(:,6); V3(:,6); V4(:,6); V5(:,6); V6(:,6); V7(:,6); ...
V8(:,6); V9(:,6); V10(:,6); V11(:,6); V12(:,6)]; % Efficiency

% Limit curves from data
limCur = [V1(end,1); V2(end,1); V3(end,1); V4(end,1); V5(end,1); V6(end,1); V7(end,1); ...
V8(end,1); V9(end,1); V10(end,1); V11(end,1); V12(end,1)];
limInp = [V1(end,2); V2(end,2); V3(end,2); V4(end,2); V5(end,2); V6(end,2); V7(end,2); ...
V8(end,2); V9(end,2); V10(end,2); V11(end,2); V12(end,2)];
limRPM = [V1(end,3); V2(end,3); V3(end,3); V4(end,3); V5(end,3); V6(end,3); V7(end,3); ...
V8(end,3); V9(end,3); V10(end,3); V11(end,3); V12(end,3)];
limMom = [V1(end,4); V2(end,4); V3(end,4); V4(end,4); V5(end,4); V6(end,4); V7(end,4); ...
V8(end,4); V9(end,4); V10(end,4); V11(end,4); V12(end,4)];
limPow = [V1(end,5); V2(end,5); V3(end,5); V4(end,5); V5(end,5); V6(end,5); V7(end,5); ...
V8(end,5); V9(end,5); V10(end,5); V11(end,5); V12(end,5)];
limEta = [V1(end,6); V2(end,6); V3(end,6); V4(end,6); V5(end,6); V6(end,6); V7(end,6); ...
V8(end,6); V9(end,6); V10(end,6); V11(end,6); V12(end,6)];

[xq, yq] = meshgrid(0:0.1:15, 0:10:11000);
zq = griddata(x,y,z,xq,yq);
[xa, ya] = meshgrid(0:10:11000, 0:0.1:15); % x: RPM, y: Ampere
za = griddata(r,c,s,xa,ya);

% Calculate current from expected output power and RPM (propeller data)
MXCL(:,4) = griddata(z,y,x,MXCL(:,2),MXCL(:,3));
MXCR(:,4) = griddata(z,y,x,MXCR(:,2),MXCR(:,3));
MXCL(:,4) = griddata(s,r,c,MXCL(:,2),MXCL(:,3));
MXCR(:,4) = griddata(s,r,c,MXCR(:,2),MXCR(:,3));

%% Plot section
figure(1)
figure
hold on
surf(xq,yq,zq,'FaceColor','interp','LineStyle','none')
plot3(V1(:,1),V1(:,3),V1(:,5),'k--')
plot3(V2(:,1),V2(:,3),V2(:,5),'k--')
plot3(V3(:,1),V3(:,3),V3(:,5),'k--')
plot3(V4(:,1),V4(:,3),V4(:,5),'k--')
plot3(V5(:,1),V5(:,3),V5(:,5),'k--')
plot3(V6(:,1),V6(:,3),V6(:,5),'k--')
plot3(V7(:,1),V7(:,3),V7(:,5),'k--')
plot3(V8(:,1),V8(:,3),V8(:,5),'k--')
plot3(V9(:,1),V9(:,3),V9(:,5),'k--')
plot3(V10(:,1),V10(:,3),V10(:,5),'k--')
plot3(V11(:,1),V11(:,3),V11(:,5),'k--')
plot3(V12(:,1),V12(:,3),V12(:,5),'k--')
plot3(limCur,limRPM,limPow,'k-','LineWidth',2)
climb = plot3(MXCL(:,4),MXCL(:,3),MXCL(:,2)+20,'or-','LineWidth',1.5);
cruise = plot3(MXCR(:,4),MXCR(:,3),MXCR(:,2)+20,'oy-','LineWidth',1.5);
hold off, grid on, view(-50,30)
xlabel('Current, A'), ylabel('RPM'), zlabel('Output power, W')
surf(xa,ya,za,'FaceColor','interp','LineStyle','none')
plot3(V1(:,3),V1(:,1),V1(:,5),'k--')
plot3(V2(:,3),V2(:,1),V2(:,5),'k--')
plot3(V3(:,3),V3(:,1),V3(:,5),'k--')
plot3(V4(:,3),V4(:,1),V4(:,5),'k--')
plot3(V5(:,3),V5(:,1),V5(:,5),'k--')
plot3(V6(:,3),V6(:,1),V6(:,5),'k--')
plot3(V7(:,3),V7(:,1),V7(:,5),'k--')
plot3(V8(:,3),V8(:,1),V8(:,5),'k--')
plot3(V9(:,3),V9(:,1),V9(:,5),'k--')
plot3(V10(:,3),V10(:,1),V10(:,5),'k--')
plot3(V11(:,3),V11(:,1),V11(:,5),'k--')
plot3(V12(:,3),V12(:,1),V12(:,5),'k--')
plot3(limRPM,limCur,limPow,'k-','LineWidth',2)
climb = plot3(MXCL(:,3),MXCL(:,4),MXCL(:,2)+20,'or-','LineWidth',1.5);
cruise = plot3(MXCR(:,3),MXCR(:,4),MXCR(:,2)+20,'oy-','LineWidth',1.5);
hold off, grid on, view(-20,30)
xlabel('RPM'), ylabel('Current, A'), zlabel('Output power, W')
legend([climb,cruise], 'MXCL', 'MXCR','Location','Best','Color','cyan')

% Annotations on surf
text(V1(end,1),V1(end,3),V1(end,5),'\leftarrow 5 V')
text(V2(end,1),V2(end,3),V2(end,5),'\leftarrow 10 V')
text(V3(end,1),V3(end,3),V3(end,5),'\leftarrow 15 V')
text(V4(end,1),V4(end,3),V4(end,5),'\leftarrow 20 V')
text(V5(end,1),V5(end,3),V5(end,5),'\leftarrow 25 V')
text(V6(end,1),V6(end,3),V6(end,5),'\leftarrow 30 V')
text(V7(end,1),V7(end,3),V7(end,5),'\leftarrow 35 V')
text(V8(end,1),V8(end,3),V8(end,5),'\leftarrow 40 V')
text(V9(end,1),V9(end,3),V9(end,5),'\leftarrow 45 V')
text(V10(end,1),V10(end,3),V10(end,5),'\leftarrow 50 V')
text(V11(end,1),V11(end,3),V11(end,5),'\leftarrow 55 V')
text(V12(end,1),V12(end,3),V12(end,5),'\leftarrow 60 V')
text(V1(end,3),V1(end,1),V1(end,5),'5 V \rightarrow', 'HorizontalAlignment', 'right')
text(V2(end,3),V2(end,1),V2(end,5),'10 V \rightarrow', 'HorizontalAlignment', 'right')
text(V3(end,3),V3(end,1),V3(end,5),'15 V \rightarrow', 'HorizontalAlignment', 'right')
text(V4(end,3),V4(end,1),V4(end,5),'20 V \rightarrow', 'HorizontalAlignment', 'right')
text(V5(end,3),V5(end,1),V5(end,5),'25 V \rightarrow', 'HorizontalAlignment', 'right')
text(V6(end,3),V6(end,1),V6(end,5),'30 V \rightarrow', 'HorizontalAlignment', 'right')
text(V7(end,3),V7(end,1),V7(end,5),'35 V \rightarrow', 'HorizontalAlignment', 'right')
text(V8(end,3),V8(end,1),V8(end,5),'40 V \rightarrow', 'HorizontalAlignment', 'right')
text(V9(end,3),V9(end,1),V9(end,5),'45 V \rightarrow', 'HorizontalAlignment', 'right')
text(V10(end,3),V10(end,1),V10(end,5),'50 V \rightarrow', 'HorizontalAlignment', 'right')
text(V11(end,3),V11(end,1),V11(end,5),'55 V \rightarrow', 'HorizontalAlignment', 'right')
text(V12(end,3),V12(end,1),V12(end,5),'60 V \rightarrow', 'HorizontalAlignment', 'right')

for i = 1:size(MXCL,1)
text(MXCL(i,4),MXCL(i,3),MXCL(i,2)+20,...
text(MXCL(i,3),MXCL(i,4),MXCL(i,2)+20,...
['J = ',num2str(MXCL(i,1)), ' \rightarrow'], ...
'HorizontalAlignment','right')
end

for i = 1:size(MXCR,1)
text(MXCR(i,4),MXCR(i,3),MXCR(i,2)+20,...
text(MXCR(i,3),MXCR(i,4),MXCR(i,2)+20,...
['J = ',num2str(MXCR(i,1)), ' \rightarrow'], ...
'HorizontalAlignment','right')
end

% Contour plot
figure(2)
figure
hold on
[C,H] = contourf(xq,yq,zq,0:50:700);
plot(V1(:,1),V1(:,3),'k--')
plot(V2(:,1),V2(:,3),'k--')
plot(V3(:,1),V3(:,3),'k--')
plot(V4(:,1),V4(:,3),'k--')
plot(V5(:,1),V5(:,3),'k--')
plot(V6(:,1),V6(:,3),'k--')
plot(V7(:,1),V7(:,3),'k--')
plot(V8(:,1),V8(:,3),'k--')
plot(V9(:,1),V9(:,3),'k--')
plot(V10(:,1),V10(:,3),'k--')
plot(V11(:,1),V11(:,3),'k--')
plot(V12(:,1),V12(:,3),'k--')
plot(limCur,limRPM,'k-','LineWidth',2)
climb = plot(MXCL(:,4),MXCL(:,3),'or-','LineWidth',1.5);
cruise = plot(MXCR(:,4),MXCR(:,3),'oy-','LineWidth',1.5);
[C,H] = contourf(xa,ya,za,0:50:700);
plot(V1(:,3),V1(:,1),'k--')
plot(V2(:,3),V2(:,1),'k--')
plot(V3(:,3),V3(:,1),'k--')
plot(V4(:,3),V4(:,1),'k--')
plot(V5(:,3),V5(:,1),'k--')
plot(V6(:,3),V6(:,1),'k--')
plot(V7(:,3),V7(:,1),'k--')
plot(V8(:,3),V8(:,1),'k--')
plot(V9(:,3),V9(:,1),'k--')
plot(V10(:,3),V10(:,1),'k--')
plot(V11(:,3),V11(:,1),'k--')
plot(V12(:,3),V12(:,1),'k--')
plot(limRPM,limCur,'k-','LineWidth',2)
climb = plot(MXCL(:,3),MXCL(:,4),'or-','LineWidth',1.5);
cruise = plot(MXCR(:,3),MXCR(:,4),'oy-','LineWidth',1.5);
hold off
clabel(C,H,'FontSize',15,'Color','white')
xlabel('Current, A'), ylabel('RPM'), title('Output power contour, W')
xlabel('RPM'), ylabel('Current, A'), title('Output power contour, W')
legend([climb,cruise], 'MXCL', 'MXCR','Location','Best','Color','cyan')

% Annotations on contour
text(V1(end,1),V1(end,3),'\leftarrow 5 V')
text(V2(end,1),V2(end,3),'\leftarrow 10 V')
text(V3(end,1),V3(end,3),'\leftarrow 15 V')
text(V4(end,1),V4(end,3),'\leftarrow 20 V')
text(V5(end,1),V5(end,3),'\leftarrow 25 V')
text(V6(end,1),V6(end,3),'\leftarrow 30 V')
text(V7(end,1),V7(end,3),'\leftarrow 35 V')
text(V8(end,1),V8(end,3),'\leftarrow 40 V')
text(V9(end,1),V9(end,3),'\leftarrow 45 V')
text(V10(end,1),V10(end,3),'\leftarrow 50 V')
text(V11(end,1),V11(end,3),'\leftarrow 55 V')
text(V12(end,1),V12(end,3),'\leftarrow 60 V')
text(V1(end,3),V1(end,1),'5 V \rightarrow', 'HorizontalAlignment', 'right')
text(V2(end,3),V2(end,1),'10 V \rightarrow', 'HorizontalAlignment', 'right')
text(V3(end,3),V3(end,1),'15 V \rightarrow', 'HorizontalAlignment', 'right')
text(V4(end,3),V4(end,1),'20 V \rightarrow', 'HorizontalAlignment', 'right')
text(V5(end,3),V5(end,1),'25 V \rightarrow', 'HorizontalAlignment', 'right')
text(V6(end,3),V6(end,1),'30 V \rightarrow', 'HorizontalAlignment', 'right')
text(V7(end,3),V7(end,1),'35 V \rightarrow', 'HorizontalAlignment', 'right')
text(V8(end,3),V8(end,1),'40 V \rightarrow', 'HorizontalAlignment', 'right')
text(V9(end,3),V9(end,1),'45 V \rightarrow', 'HorizontalAlignment', 'right')
text(V10(end,3),V10(end,1),'50 V \rightarrow', 'HorizontalAlignment', 'right')
text(V11(end,3),V11(end,1),'55 V \rightarrow', 'HorizontalAlignment', 'right')
text(V12(end,3),V12(end,1),'60 V \rightarrow', 'HorizontalAlignment', 'right')

for i = 1:size(MXCL,1)
text(MXCL(i,4),MXCL(i,3),...
text(MXCL(i,3),MXCL(i,4),...
['J = ',num2str(MXCL(i,1)), ' \rightarrow'], ...
'HorizontalAlignment','right')
end

for i = 1:size(MXCR,1)
text(MXCR(i,4),MXCR(i,3),...
text(MXCR(i,3),MXCR(i,4),...
['J = ',num2str(MXCR(i,1)), ' \rightarrow'], ...
'HorizontalAlignment','right')
end

0 comments on commit 3181dbc

Please sign in to comment.