-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.m
212 lines (179 loc) · 6.04 KB
/
main.m
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
209
210
211
212
% LAC Assignment 1
% Group 0
% Aerodynamic redesign of DTU 10MW
%% Content of this script:
% - tip radius scaling (line 16 until 37)
% - read airfoil data and plot polars for 4 FFA-XXX airfoils (line 39 until 105)
% - set the shifts and calc design AoA for max(Cl)-shift
% - fit a polynomio for Cl vs c/t -> fit a polynomio to Cl/Cd vs c/t
% - Thickness scalling with rotor diameter relation
% ====================
clear all; close all; clc
set(0,'defaulttextInterpreter','latex');
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');
set(0,'defaultAxesFontSize',12);
set(0, 'DefaultLineLineWidth', 1);
set(0, 'DefaultFigureRenderer', 'painters');
set(0,'DefaultFigureWindowStyle','docked') % docked
%% Tip radius scaling
R1 = 178.3/2; % original radius
V1 = 11.4; % original rated speed
I1 = 0.16; % original turbulence intensity (class IA)
V1_max = V1*(1+2*I1); % max wind speed wit 2 stdev of TI.
I2 = 0.14; % target turbulence intensity (class IIIB)
R2_guess = 90; % new radius guess
dif = 1e12;
it = 0;
while dif>1e-6
V2 = (V1^3*R1^2/R2_guess^2)^(1/3); % new rated wind speeed
V2_max = V2*(1+2*I2); % new maximum wind speed
R2 = R1*V1_max/V2_max; % corrected radius
dif = abs(R2-R2_guess); % residual
R2_guess = R2; % update radius
it = it + 1;
end
%% Airfoil selection
% loading airfoil data
path = 'airfoil_data/';
fileinfo = dir(path);
filenames = {fileinfo.name};
filenames = filenames([fileinfo.bytes]>0);
%Airfoil models --> 24%, 30%, 36%, 48%, 60%, cylinder
polars = true; % set true to see polars
cl_des = zeros(1,length(filenames)-2); % exclude last 2 airfoils
cd_des = zeros(1,length(filenames)-2);
alpha_des = zeros(1,length(filenames)-2);
shift = [0.38, 0.32, 0.47, 0.2]; % shift cl
for i=1:length(filenames)-2 % loop through FFA-241,FFA-301-FFA-360-FFA-480
% open data
data = readtable(fullfile(path,filenames{i}));
data = table2array(data);
% restrict range of AoA
[~, idx_min] = min(abs(data(:,1)+15));
[~, idx_max] = min(abs(data(:,1)-30));
data = data(idx_min:idx_max,:);
% find cl max in expected range of AoA
[~, idx_min] = min(abs(data(:,1)+5));
[~, idx_max] = min(abs(data(:,1)-15));
[cl_max, idx] = max(data(idx_min:idx_max,2));
% apply shift to find design cl
cl_des(1,i) = cl_max - shift(i);
% Find interval
% Cl_curve = data(idx_min:idx_max,2);
% alpha_curve = data(idx_min:idx_max,1);
% Cd_curve = data(idx_min:idx_max,3);
Cl_curve = data(idx_min:(idx_min+idx-1),2);
alpha_curve = data(idx_min:(idx_min+idx-1),1);
Cd_curve = data(idx_min:(idx_min+idx-1),3);
alpha_des(i) = interp1(Cl_curve,alpha_curve,cl_des(1,i));
cd_des(i) = interp1(Cl_curve,Cd_curve,cl_des(1,i));
% plotting
if polars
figure;
subplot(1,2,2)
plot(data(:,1), data(:,2), '-O');hold on;
yline(cl_des(1,i), '--r'); hold on;
xline(alpha_des(i),'--r'); hold on;
scatter(alpha_des(i),cl_des(i),'xr','linewidth',1)
xlabel('$\alpha$ [deg]')
ylabel('$C_l$ [-]')
title(filenames{i}(1:end-4));
grid on
xlim([min(data(:,1)), max(data(:,1))])
% figure;
subplot(1,2,1)
plot(data(:,3), data(:,2), '-O');hold on;
yline(cl_des(1,i), '--r');hold on;
xline(cd_des(i),'--r');hold on;
scatter(cd_des(i),cl_des(i),'xr','linewidth',1)
xlabel('$C_d$ [-]')
ylabel('$C_l$ [-]')
title(filenames{i}(1:end-4));
grid on
end
end
tcratio = [24, 30, 36, 48, 100];
cl_des(1,end+1) = 0;
% Fitting first 4 points with polynomial
p1_cl = polyfit(tcratio(1:end-1), cl_des(1:end-1), 3);
x1 = linspace(tcratio(1), tcratio(end-1), 40);
y1 = polyval(p1_cl,x1);
% Fitting last 2 points with straight line
p2_cl = polyfit(tcratio(end-1:end), cl_des(end-1:end), 1);
x2 = linspace(tcratio(end-1), tcratio(end), 40);
y2 = polyval(p2_cl,x2);
figure
scatter(tcratio, cl_des)
hold on
plot(x2, y2,'--k')
plot(x1, y1,'--k')
grid on
xlabel('$t/c$ [\%]')
ylabel('Design $C_l$')
% Read corresponding design alpha and design cd
% Alpha design:
alpha_des(end+1)=0;
cd_des(end+1)=0.6;
% alpha_des = [9.3241, 9.2707, 6.0528, 3.7795, 0];
% cd_des = [0.01372, 0.01697, 0.02137, 0.03397, 0.6];
clcd_des = cl_des./cd_des;
% Fit curve to alpha design
% Fitting first 4 points with polynomial
p1_alpha = polyfit(tcratio(1:end-1), alpha_des(1:end-1), 2);
x1 = linspace(tcratio(1), tcratio(end-1), 40);
y1 = polyval(p1_alpha,x1);
% Fitting last 2 points with straight line
p2_alpha = polyfit(tcratio(end-1:end), alpha_des(end-1:end), 1);
x2 = linspace(tcratio(end-1), tcratio(end), 40);
y2 = polyval(p2_alpha,x2);
figure
scatter(tcratio, alpha_des)
hold on
plot(x2, y2,'--k')
plot(x1, y1,'--k')
grid on
xlabel('$t/c$ [\%]')
ylabel('Design $\alpha$')
% Fitting first 4 points with polynomial
p1_clcd = polyfit(tcratio(1:end-1), clcd_des(1:end-1), 3);
x1 = linspace(tcratio(1), tcratio(end-1), 40);
y1 = polyval(p1_clcd,x1);
% Fitting last 2 points with straight line
p2_clcd = polyfit(tcratio(end-1:end), clcd_des(end-1:end), 1);
x2 = linspace(tcratio(end-1), tcratio(end), 40);
y2 = polyval(p2_clcd,x2);
figure
scatter(tcratio, clcd_des)
hold on
plot(x2, y2,'--k')
plot(x1, y1,'--k')
grid on
xlabel('$t/c$ [\%]')
ylabel('Design $C_l/C_d$')
%% Thickness scaling
data = readtable('blade_original/DTU_10MW_RWT_ae', 'Filetype', 'text');
data = table2array(data(:,1:4));
t_dtu = data(:,3).*data(:,2)/100;
t = t_dtu*R2/R1;
r = linspace(0, R2 ,40);
p_t = polyfit(r, t, 6);
y = polyval(p_t, linspace(0, R2, 100));
figure;
plot(data(:,1)/R1, t_dtu, 'x', 'DisplayName', 'DTU 10MW')
hold on
plot(r/R2, t, 'x','DisplayName', 'New design')
plot(linspace(0, 1, 100), y, '--k', 'DisplayName', 'Fit')
xlabel('r/R [-]')
ylabel('t [m]')
grid on
legend
%% Save polynomials
curves.polynomials.t = p_t;
curves.polynomials.cl1 = p1_cl;
curves.polynomials.cl2 = p2_cl;
curves.polynomials.clcd1 = p1_clcd;
curves.polynomials.clcd2 = p2_clcd;
curves.polynomials.alpha1 = p1_alpha;
curves.polynomials.alpha2 = p2_alpha;
save('polynomials.mat','-struct','curves')