Join/Login

Business Software

Open Source Software

For Vendors

Blog

About

More

Articles

Create

SourceForge Podcast

Site Documentation

Subscribe to our Newsletter

Support Request

For Vendors Help Create Join Login

Business Software

Open Source Software

SourceForge Podcast

Resources

Articles

Case Studies

Blog

Menu

Help

Create

Join

Login

Home

Browse

Matlab wind turbine model

Code

Matlab wind turbine model Code

Generic Matlab model of a wind turbine drive train.

Status: Alpha
Brought to you by: crobarcro, mcmullenjoe

Summary

Reviews

Support

Code

Menu ▾ ▴

Browse Commits

Browse Files

[r22]: / wturbineode.m  Maximize  Restore  History

Download this file

210 lines (163 with data), 7.7 kB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

function [dydt, shaft_torque] = wturbineode(t,y,u,R,density,B)

% Calculates the acceleration and velocity of a wind or tidal turbine

%

% This function is intended for use with the Matlab/Octave ode integrators

% to perform a time series simulation of the turbine

%

% Syntax

%

% dydt = wturbineode(t,y,u,R,density,B)

% This is defined in the script wturbinemodel which calls on this function

%

% Input

%

% t - the current time step

%

% y - the values of the integrated quantities at the previous time step,

% these quantites are:

%

% y(1): angular position

% y(2): angular velocity

%

% u - the wind speed

%

% R - the radius of the rotor in metres

%

% density - the density of the fluid the turbine operates in

%

% B - the pitch angle of the blade, only input if the turbine is fixed

% pitch

%

% Output

%

% dydt - the derivatives of the turbine quantities at the current time

% step:

%

% dydt(1): angular velocity

% dydt(2): angular acceleration

%

%-----------------------------------------------------------------------------

%-----------------------------------------------------------------------------

%

% Description

%

% This function uses a range of inputs to calculate the shaft torque on a wind

% turbine. This is the difference in the torque generated by the rotor and the

% torque generated by the generator.

%

% The inputs to the function are the wind speed, the raadius of the rotor, the

% density of the fluid the turbine is operating in and the pitch angle of the

% blades (only neccesary if the turbine is fixed pitch).

%

% The first step is the calculation of lambda (the tip speed ratio). This is the

% ratio of the speed of the blade tip and the wind speed. This is calculated using

% lambda = (angular speed*rotor radius)/wind speed. Included in the function which

% calculates this an if statement that applies in the case of angular velocity of

% the rotor being equal to zero. This is because when the rotor is staionary an

% infinate torque is developed on the rotor. To resolve this issue an approximation

% is used sets the angular velocity equal to a very small finite value.

%

% After this a function is used to detect whether or not the input is for a fixed

% or variable speed turbine. In the event that it is fixed pitch this function is

% bypassed. However if the turbine is variable pitch this function calculates the

% pitch angle. It does this by optimising the pitch angle to maximise the

% coefficient of performance. The numerical expression used to calculate the

% coefficient of performance is given in [Lei].

%

% The values of tip speed ratio and the pitch angle are then used to calculate the

% coefficient of performance. This value is the proportion of energy in the wind that

% is converted into energy by the rotor. This is calcuated using the same expression

% that is used to find the pitch angle and is given by [Lei].

%

% The three functions discussed above constitute a model of the rotor of the

% turbine. The output from this is used as an input to the shaft model. This is a

% model of the interation of torques on the shaft of the wind turbine. The shaft

% being the point of interation of the rotor and generator torques. The net torque

% on the shaft as a result of this interaction is the output of this model.

%

% The rotor torque is calculated using a well known equation given for example in

% [Bekker]. It uses the density of the surounding fluid, the rotor radius, the wind

% speed and the coefficient of performance to calculate the output torque. A value

% for the generator torque of 0.9*rotor torque is used. The shaft torque is then

% simply the difference between the two.

%

% The interia of the rotor is calculated using an expression found in [Rodriguez].

% It is an empirical relationship dependant on the length of the blade.

%

% The input into the ode45 is the shaft torque/ inertia. This is equal to the

% change in rotor speed as shown in [Neammanee]. The ode45 solve the equations for

% each timestep and outputs the angular position and velocity of the rotor.

%

%-----------------------------------------------------------------------------

%-----------------------------------------------------------------------------

% Set the differential of position from ode45 equal to angular velocity

% of the rotor

ang_vel = y(2);

% Call upon the function lambda_calc, this calculates the tip speed ratio

lambda = lambda_calc(R,u,ang_vel);

% Call upon the function pitch_calc, this calculates the blade pitch

B = pitch_calc(lambda);

% Call upon the function cp_calc, this calculates the coefficent of

% performance

cp = cp_calc(lambda, B);

% Call upon the function torque_calc, this calculates the rotor torque and

% assigns a value to the generator torque. It then calculates the difference

% which is the shaft torque.

shaft_torque = torque_calc(density, R, u, cp, lambda);

% Call upon the function inertia_calc, this calculates the inertia of the

% rotor.

inertia = inertia_calc(R);

% Set up the ode

dydt = [y(2); shaft_torque/inertia];

end

%-----------------------------------------------------------------------------

%-----------------------------------------------------------------------------

% Below are a series of local functions that are called upon above.

% They combine to calcuate the inputs to the ode.

% A function to calculate the tip speed ratio of the rotor blades.

% This includes an statement that sets angular velocity equal to

% 0.0000001 this is to eliminate a division by infinity error that

% occurs at a later stage. The inputs are rotor radius, wind speed and

% angular velocity. The output is the tip speed ratio of the turbine.

function lambda = lambda_calc(R, u, ang_vel)

if ang_vel == 0

lambda = 0.0000001 * R/u;

else

lambda = ang_vel * R/u;

end

end

% A function to detect the number of arguments to determine if there

% is a defined pitch angle, if not pitch angle is calculated by

% maximising cp. Input is tip speed ratio, th output is pitch angle.

function B = pitch_calc(lambda)

if nargin < 6

[B fval] = fminbnd(@(B)(-(0.5176.*(116./(1./((1./(lambda + 0.08.*B))-(0.035./(B.^3+1)))) - 0.4.*B - 5).*exp(-21./(1./((1./(lambda +0.08.*B))-(0.035./(B.^3+1)))))) + 0.0068* lambda),0,90);

end

end

% A function to calculate Cp, the coefficient of performance.

% The tip speed ratio and the pitch angle are input, coefficent

% of performance is output.

function cp = cp_calc(lambda, B)

lambda_i = (1/((1/(lambda+0.08*B))-(0.035/(B^3+1))));

cp = 0.5176 .* (116/lambda_i - 0.4 * B - 5) * exp(-21/lambda_i) + 0.0068 * lambda;

end

% A function to calculate the rotor torque, set the generator torque

% to a multiple of the rotor torque and then work out the difference

% between them. The inputs are density, rotor radius, wind speed,

% coefficient of performance and tip speed ratio. The output is the

% shaft torque.

function shaft_torque = torque_calc(density, R, u, cp, lambda)

% Compute rotor torque

rotor_torque = 0.5 * pi * density * R^3 * u^2 * cp / lambda;

% Set a value of generator torque a constant value is used as an

% initial simplification

gen_torque = 500;

% Output the shaft torque

shaft_torque = rotor_torque - gen_torque;

end

% A function to calculate the inertia of the rotor. The input is

% rotor radius and the output is the rotor inertia

function inertia = inertia_calc(R)

% Define inertia

inertia = 0.212 * (2.95 * R^2.13) * R^2;

end

SourceForge

Create a Project

Open Source Software

Business Software

Top Downloaded Projects

Company

About

Team

SourceForge Headquarters
225 Broadway Suite 1600
San Diego, CA 92101
+1 (858) 422-6466

Resources

Support

Site Documentation

Site Status

SourceForge Reviews

© 2025 Slashdot Media. All Rights Reserved.

Terms Privacy Opt Out Advertise

×
Want the latest updates on software, tech news, and AI?

Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.

Submit