Windsim Manual
Windsim Manual
Contents:
1 General 1.1 Call .m files 1.2 Trics 2 Survey MATLAB programs 2.1 Run files 2.2 Subroutines 2.3 Applied MATLAB subroutines 2.4 Graphical overview 3. Some examples 1 1 2 4 4 5 6 7 8
1 General
When MATLAB is running, the MATLAB command window, will appear. In this window it is possible to give commands. First check if you are working in the right directory in MATLAB. Use cd to see which directory is active. If you use the command dir all the files in the directory will be shown. The .m files you see are those which will be used for the assignments. They can be opened in the command window.
The input windturbine requires the name of the file with the parameters of a wind turbine, e.g. the Lagerwey 50/750. The parameters from this wind turbine are stated in the .m file LW50.m. Lambda is a vector of different tip speed ratios, theta is the pitch angle of the blade. Both are free to choose. The file cplambda.m is called from the command window as follows. >> [Cdax1, Cp1, a1] = cplambda(LW50, 0.5 : 0.1 :1.5, 1) LW50 is put between quotation marks because it is a string. A vector lambda is created as a second parameter that runs from 0.5 to 1.5 in steps of 0.1. (It is possible to see that on line 27 in cplambda.m the length of lambda is taken. Thus for lambda a vector of a random length can be chosen.) For theta the value 1 is used in this case. The outputs (results) of cplambda.m are saved in the variables left from the = sign: after the call, Cdax1 equals the thrust coefficient Cdax (for theta is 1 and lambda runs from 0.5 to 1.5 on steps of 0.1). The values of Cdax1 appears on the screen through: >> Cdax1 If you call the function again with different values for the inputs, it is possible to save the outputs of the function in new variables:
Windsim manual
>> [Cdax2, Cp2, a2] = Cplambda(LW50, .5:.1:1.5, .2) In this way you can calculate Cdax, for different values of theta, and compare them. As mentioned before, there is no need to change the given .m files, but in some assignments you may need parameters of a different wind turbine then the given ones. Just save for example LW50.m as a new .m file (e.g. LW70). In this file you can put the changes. With >> [Cdax71, Cp71, a71] = cplambda(LW70, .5:.1:1.5, .1) the same calculations are carried out, but for the new wind turbine. Now you can put all the gathered data in a graph. For the layout of the graphs use the general help of Matlab.
1.2 Trics
By using the command help, the inputs and outputs of an .m file are shown immediately. For example for cplambda.m: >> help cplambda The program gives you the syntax and comments of cplambda.m. By using copy (ctrl+c) from the syntax and paste (ctrl+v), minimizes the chance of mistakes in the order of the parameters if you call a certain file. Furthermore, there is an explanation of all the inputs and outputs. In this way you can easily see which to use. In case you deal with an unknown command in the .m files, help can provide information about the command. For example the command plot to make graphs: >> help plot The way to insert the parameters is obvious now as well as the possibilities to show graphs. An example of a plot will be given at the end of this manual together with an example of a script file. A script file is created by making a new .m file. Instead of typing several commands in the command window, you can place them together in a script file and call this file. On the other hand you can also call a function more then once with a script file by placing the function in a for loop. Table 1 presents some useful information concerning the command window. In table 2, there are examples of the syntax of MATLAB. Key/ command Arrow up close all Help <subject> Who Clear Action Shows former command Closes the figure windows. In case you want to know more about a MATLAB subject. Gives all the variables defined in MATLAB at that instant Erases the memory
Table 1: Special keys and commands in command window.
Windsim manual
Syntaxes a./b % in front of a line ; behind a line x(2) M(2,:) M(:,2) for i=1:6 length(vector) max(vector)
Shows First element of a divided by first element of b etc. Also .* .^ This line will be ignored by MATLAB: comments. MATLAB wont show the result from the line on the screen. 2nd element of vector x. 2nd row of matrix M 2nd column of matrix M Repeats for the values i=1,2,3,4,5,6 Gives the length of the vector. Gives the largest element of a vector.
Table 2: Some syntax examples from MATLAB
Subroutines What does it From .m file is it called Which functions are called
Windsim manual
Powercurve2
[Dax, Mbeta, Mr, P, Cdax, Cp, a]=Powercurve1(windturbine, V, omr) Similar to powercurve1, but here you deal with a wind turbine with stall control and constant rpm. Furthermore the blade angle is constant. Assignment: Rotor Called subroutines: LW50 bem
Cplambda
[Cdax, Cp, a]=Cplambda(windturbine, lambda, theta) Similar to powercurve1, but here you can insert a vector with different tip speed ratios . Graphs can be created with Cdax, Cp and the induction factor a against . Assignment: Rotor Called subroutines: LW50 bem
Transfer
[sys_tf,sys_ss]=Transfer(windturbine,V0) Determination of the transfer functions of the wind turbine. Called subroutines: LW50 bem equi gener dynmod
2.2 Subroutines
LW50
Gives all the necessary parameters from the Lagerwey 50/750. Called in powercurve1, powercurve2, Cplambda, transfer.
Dowec
Gives all the necessary parameters from the Dowec turbine. Called in powercurve1, powercurve2, Cplambda, transfer.
V66
Gives all the necessary parameters from the Vestas V66. Called in powercurve1, powercurve2, Cplambda, transfer.
Bem
Bem stands for blade element momentum theorem. In fun_bem is for a given induction factor a the difference calculated between Dax found using the blade element method and Dax found with the momentum theorem Dax=4a(1-a)). In bem.m the a is determined with fzero for which the function fun_bem reaches a zero. The output from bem.m are the forces and torque following from this value of a. Called subroutines: fun_bem Aero Aero2
Windsim manual
Fun_bem
In fun_bem the difference is calculated between Dax found using the blade element method and Dax found using the momentum theorem; Dax=4a(1-a) Called subroutines: Aero
Aero
Given the parameters (induction factor, wind speed, rpm, flap velocity, tower top velocity and turbine characteristics), the forces per annulus are calculated and the sum is taken. Called in Bem. Called subroutines: Lift Table Cl Drag Table Cd
Aero2
Similar to aero, but a faster version because vectors are used in stead of for-loops.
Equi
Determination of the steady state; the operating point is the rpm where equilibrium between rotor torque and generator torque is established. Called in Transfer Called subroutines: bem fun_equi fun_power
Fun_power
Determines the difference between the nominal power and power based on given input parameters. Called in powercurve1, equi.
Fun_equi
Determines the difference between the moment according to bem and the generator characteristic. Called in equi.
Dynmod
Determination of the differential equations forming the equations of motion of the system. Called in transfer. Called subroutines: aero2 gener
Gener
Torque rpm characteristic of generator. Called in dynmod.
Gust1
Smooth wind gust. Called in dynmod.
Windsim manual
Gust2
A sinusoidal gust with a frequency equal to the rpm of the rotor (1P); this represents the variations in the wind speed felt by a blade element as a result of wind shear, yawed flow, tower shadow and rotational sampling of turbulence. The output of this routine can be used as input for the simulation via step and lsim.
Lift
Table with data of CL for different angles of attack ; the first column is the angle of attack and the second the lift coefficient CL. When called with a certain , the corresponding value for CL is given as output. Called in Aero.
Drag
Table with Cd against the angle of attack; the first column is the angle of attack and the second the Cd. When called with a certain , the corresponding value for CD is calculated as output.
Turbulence.mat
In this file there are sequential values of turbulent wind; the variables u (turbulence in m/s) and t (time in s) become available via load turbulence. The turbulent wind can be used as an input for the simulation of the wind turbine via step en lsim.
step
step(sys,Tend) This a standard routine in MATLAB, similar to lsim, for the simulation of a dynamical system specified in sys. The routine calculates and plots the response of the system of a step shaped variation of all the inputs (in our case the pitch angle of the blade and the undisturbed wind speed). [systf,sys]=transfer(LW50,14); step(sys, 20);
fzero
Searches the zero of a function. Different options can be given like an initial value or an interval in which the zero has to be searched.
Windsim manual
aero2
Cplambda.m
Transfer
bem
Windsim manual
3 Some examples
Example of a script file
% In a for-loop, we call for different thetas cplambda and % plot Cpmax against the corresponding theta. clear; thet=-1.5:.1:.5 n=length(thet); lambda=.5:.1:1.5; for i=1:n theta=thet(i); [Cdax,Cp,a]=Cplambda(LW50, lambda, theta); Cpmax(i)=max(Cp); end plot(thet, Cpmax);
x=0:1:10; y=x.^2 plot(x,y, r*-); shg; title(The graph of y against x); xlabel(x); ylabel(y); pause
% Another graph: In blue the lift curve is drawn. alpha=-90:90 Cl=lift(alpha); plot(alpha,Cl, b); title(The lift curve for the given blade profile.); xlabel(alpha); ylabel(Cl);