MATLAB Your task is to write a function that will show the rotational plane of t
ID: 3572573 • Letter: M
Question
MATLAB
Your task is to write a function that will show the rotational plane of the wind turbine blades.
The function you are writing is called CalculateBladeRotation. A call for this function is on line 23 of the script file:
[xc, yc, zc]=CalculateBladeRotation(R);
The following equations should be used:
xc=Rcos()
yc=Rsin()
zc=0
Where R is the radius of the blade and are angles ranging from 0 to 2.
Write a function file to compute the specified values.
Run the file for all 3 views.
SCRIPT:
%Wind Turbine Simulation
%Krista M. Kecskemety 4/20/2015
clear;
clc;
%this command loads the variables stored in MAT17Vars.mat
load Mat17Vars.mat rblade1 rblade2 Angle delta_psi Omega
%rblade1 is the trailed wake position of blade #1
%rblade2 is the trailed wake position of blade #2
%Angle is the angular position of the blades
%delta_psi and Omega are related to the time step and rotational speed
[Nj,Nk,d]=size(rblade1);
%Nj=Number of Timesteps of the Wind Turbine rotation
%Nk=Maximum Number of Points Plotted
%d=3, for the 3 positions of data x,y,z
%Radius of the Blade in meters
R=5.029;
% Calculate the swept circle outline of the blade rotation
[xc, yc, zc]=CalculateBladeRotation(R);
%Ask the user what view they want the plot to be in
answer2=input('What view would you like? 1=Front, 2=Bottom/Side, 3=Isometric ');
%Calculate the position of the tower for the wind turbine
x4=[0, -2*R];
y4=[0, 0];
z4=[0,0];
figure
%each j value is a timestep of the solution
for j=1:Nj
%This cuts off the wake after it travels 6 revolutions downstream
if j<Nk
CUTOFF=j;
else
CUTOFF=Nk;
end
%Calculate the positions of blade 1
x1=[0, R*cos(Angle(1,j))];
y1=[0, R*sin(Angle(1,j))];
z1=[0,0];
%Calculate the positions of blade 2
x2=[0, R*cos(Angle(2,j))];
y2=[0, R*sin(Angle(2,j))];
z2=[0,0];
%plot wake from blade 1
plot3(rblade1(j,1:CUTOFF,2)/R,rblade1(j, 1:CUTOFF,3)/R,rblade1(j, 1:CUTOFF,1)/R,'-*b');
hold on
%plot wake from blade 2
plot3(rblade2(j,1:CUTOFF,2)/R,rblade2(j, 1:CUTOFF,3)/R,rblade2(j, 1:CUTOFF,1)/R,'-og');
%plot the outline of the blade rotation
plot3(yc/R,zc/R,xc/R, ':r','LineWidth',2);
%plot blade 1 position
plot3(y1/R,z1/R,x1/R, 'k','LineWidth',3);
%plot blade 2 position
plot3(y2/R,z2/R,x2/R, 'k','LineWidth',3);
%plot the center post of the wind turbine
plot3(y4/R,z4/R,x4/R, 'k','LineWidth',5);
%write text to the screen that says t= value of time
time=delta_psi/Omega*(j-1);
text(1.3,0,-1/2, ['t=' num2str(time) ' s']);
hold off
%Changes the axis limits
axis([-1.5 1.5 -1 10 -1.5 1.5])
%Depending on the direction chosen, this code adjusts the view
if answer2==1
view(0,0)
else if answer2==2
view(90,90)
else
view(45,45)
end
end
%Adds title and axis labels
title('Free Vortex Wake Geometry - KMK 2015', 'FontSize',12)
xlabel('y/R', 'FontSize',12)
ylabel('z/R', 'FontSize',12)
zlabel('x/R', 'FontSize',12)
%pauses the script for .01 seconds. You can adjust this time to see how it
%works with other pause values.
pause(.01)
end
Explanation / Answer
Please find below the modified matlab code:
%Wind Turbine Simulation
%Krista M. Kecskemety 4/20/2015
clear;
clc;
%this command loads the variables stored in MAT17Vars.mat
load Mat17Vars.mat rblade1 rblade2 Angle delta_psi Omega
%rblade1 is the trailed wake position of blade #1
%rblade2 is the trailed wake position of blade #2
%Angle is the angular position of the blades
%delta_psi and Omega are related to the time step and rotational speed
[Nj,Nk,d]=size(rblade1);
%Nj=Number of Timesteps of the Wind Turbine rotation
%Nk=Maximum Number of Points Plotted
%d=3, for the 3 positions of data x,y,z
%Radius of the Blade in meters
R=5.029; %Radius
% Calculate the swept circle outline of the blade rotation
[xc, yc, zc]=CalculateBladeRotation(R);
xyz = randn(1,3); %Circle center
normalVec = randn(1,3); %Normal vector
RotationAxis = cross([0 0 1],normalVec);
if any(RotationAxis);
RotationAngle = 180/pi*acos([0 0 1]*normalVec'/norm(normalVec));
rotate(h,RotationAxis,RotationAngle,xyz);
end;
%Ask the user what view they want the plot to be in
answer2=input('What view would you like? 1=Front, 2=Bottom/Side, 3=Isometric ');
%Calculate the position of the tower for the wind turbine
x4=[0, -2*R];
y4=[0, 0];
z4=[0,0];
figure
%each j value is a timestep of the solution
for j=1:Nj
%This cuts off the wake after it travels 6 revolutions downstream
if j<Nk
CUTOFF=j;
else
CUTOFF=Nk;
end
%Calculate the positions of blade 1
x1=[0, R*cos(Angle(1,j))];
y1=[0, R*sin(Angle(1,j))];
z1=[0,0];
%Calculate the positions of blade 2
x2=[0, R*cos(Angle(2,j))];
y2=[0, R*sin(Angle(2,j))];
z2=[0,0];
%plot wake from blade 1
plot3(rblade1(j,1:CUTOFF,2)/R,rblade1(j, 1:CUTOFF,3)/R,rblade1(j, 1:CUTOFF,1)/R,'-*b');
hold on
%plot wake from blade 2
plot3(rblade2(j,1:CUTOFF,2)/R,rblade2(j, 1:CUTOFF,3)/R,rblade2(j, 1:CUTOFF,1)/R,'-og');
%plot the outline of the blade rotation
plot3(yc/R,zc/R,xc/R, ':r','LineWidth',2);
%plot blade 1 position
plot3(y1/R,z1/R,x1/R, 'k','LineWidth',3);
%plot blade 2 position
plot3(y2/R,z2/R,x2/R, 'k','LineWidth',3);
%plot the center post of the wind turbine
plot3(y4/R,z4/R,x4/R, 'k','LineWidth',5);
%write text to the screen that says t= value of time
time=delta_psi/Omega*(j-1);
text(1.3,0,-1/2, ['t=' num2str(time) ' s']);
hold off
%Changes the axis limits
axis([-1.5 1.5 -1 10 -1.5 1.5])
%Depending on the direction chosen, this code adjusts the view
if answer2==1
view(0,0)
else if answer2==2
view(90,90)
else
view(45,45)
end
end
%Adds title and axis labels
title('Free Vortex Wake Geometry - KMK 2015', 'FontSize',12)
xlabel('y/R', 'FontSize',12)
ylabel('z/R', 'FontSize',12)
zlabel('x/R', 'FontSize',12)
%pauses the script for .01 seconds. You can adjust this time to see how it
%works with other pause values.
pause(.01)
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.