-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeo_Setup_Explicit.m
168 lines (152 loc) · 6.19 KB
/
Geo_Setup_Explicit.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
function[AnchorXu,AnchorYu,AnchLineConnect,...
LineConnect,TurbLineConnect,TurbAnchConnect,NAnchs,NLines,...
AnchTurbConnect,LineFail,AnchorFail,TurbFail,AnchAnchConnect,...
LineAnchConnect,LineLineConnect,LAC,ALC] =...
Geo_Setup_Explicit(TurbX,TurbY,TADistance,NTurbs)
Angles = [180 300 420]; %Line angles
rotorDiameter = 126;
minTurbDist = rotorDiameter*10;
minAnchDist = TADistance/2;
eps = 1e-9; %Machine epsilon to account for rounding errors
%Preallocation of anchor and turbine coordinates
AnchorX = zeros((NTurbs),3);
AnchorY = zeros((NTurbs),3);
%Randomly create TurbX and TurbY positions, which determine turbine
%coordinates on the given site size. If statement is included to constrain
%layout so avoid conflicts as specified.
for j = 1:NTurbs
% Anchor positions are generated in identical configurations for each
% turbine, based on the turbine placement
AnchorX(j,:) = TurbX(j) + TADistance*cosd(Angles);
AnchorY(j,:) = TurbY(j) + TADistance*sind(Angles);
% After the first iteration, turbine placements need to be compared to
% existing turbine locations to prevent turbines or anchors from being
% too close to each other (10 rotor diameters for turbines, 500 meters
% for anchors by default)
if j > 1
[TurbDists,AnchDists] = ComponentDistance(TurbX(j),TurbX(1:j-1),...
TurbY(j),TurbY(1:j-1),AnchorX(j,:),AnchorX(1:j-1,:),...
AnchorY(j,:),AnchorY(1:j-1,:));
% If turbines are too close, move the current turbine to a random
% other location until all conflicts resolve
if any(TurbDists < minTurbDist & TurbDists > eps)
warning(['Turbine #',num2str(j),' is less than seven rotor',...
' diameters from other turbines, making wake effects',...
' non-negligible. Increasing turbine distances is suggested.'])
end
if any(AnchDists(:) < minAnchDist & AnchDists(:) > eps)
warning(['Turbine #',num2str(j),' has anchors less than ',...
num2str(minAnchDist),'m from other anchors.',...
'Relocating the turbine to increase anchor distances is suggested.'])
end
end
end
% Rearrange anchors into a vector form, and if anchors are in identical
% coordinates, delete redundant anchors (this is only relevant for
% multiline configurations)
AnchorYr = reshape(AnchorY',[],1);
AnchorXr = reshape(AnchorX',[],1);
XY = [AnchorXr,AnchorYr];
XY = round(XY*1000000)/1000000;
[~,ind] = unique(XY,'rows','first');
XYu = XY(sort(ind),:);
AnchorXu = XYu(:,1);
AnchorYu = XYu(:,2);
NAnchs = length(AnchorXu); %Total number of anchors
%% Now map the connections between the floaters and the anchors
% This gives us connectivity matrices that can be used as lookup tables
% later on
AList = 1:length(AnchorXu); %List of anchor numbers
NLines = NTurbs*3; %Total number of lines
LineConnect = zeros(NLines,2); %Turbine/line connectivity
TurbLineConnect = zeros(NTurbs,3); %Line/turbine connectivity
TurbAnchConnect = zeros(3,NTurbs); %Turbine anchor connectivity
%% Turbine anchor and line connectivity
for i = 1:NTurbs
Ax = round((TurbX(i) + TADistance*cosd(Angles))*1000000)/1000000;
Ay = round((TurbY(i) + TADistance*sind(Angles))*1000000)/1000000;
TurbAnchConnect(1,i) = AList(AnchorXu == Ax(1) & AnchorYu == Ay(1));
TurbAnchConnect(2,i) = AList(AnchorXu == Ax(2) & AnchorYu == Ay(2));
TurbAnchConnect(3,i) = AList(AnchorXu == Ax(3) & AnchorYu == Ay(3));
LineConnect(3*i-2:3*i,1) = i;
LineConnect(3*i-2,2) = TurbAnchConnect(1,i);
LineConnect(3*i-1,2) = TurbAnchConnect(2,i);
LineConnect(3*i,2) = TurbAnchConnect(3,i);
TurbLineConnect(i,1) = 3*i-2;
TurbLineConnect(i,2) = 3*i-1;
TurbLineConnect(i,3) = 3*i;
end
%% Anchor connectivity
AnchTurbConnect = zeros(3,NAnchs);
for i = 1:NAnchs
[a,b] = find(TurbAnchConnect == i);
ind = [];
if i == 12
6;
end
for j = 1:length(a)
if a(j) == 1
ind(j) = 2;
elseif a(j) == 2
ind(j) = 3;
elseif a(j) == 3
ind(j) = 1;
end
end
AnchTurbConnect(ind,i) = b;
end
%% Anchor line connections
AnchLineConnect = zeros(NAnchs,9); %All lines associated with given anchor
for i = 1:NAnchs
[r,c] = find(TurbAnchConnect == i); %Find turbines directly connected to this anchor
for j = 1:length(r)
if r(j) == 1 %Upwind line
AnchLineConnect(i,1:3) = TurbLineConnect(c(j),:);
elseif r(j) == 2 %bottom right line
AnchLineConnect(i,4:6) = TurbLineConnect(c(j),:);
elseif r(j) == 3 %top right line
AnchLineConnect(i,7:9) = TurbLineConnect(c(j),:);
end
end
end
%% Develop anchor to anchor connections (Anchor associated with all other anchors)
AnchAnchConnect = zeros(NAnchs,9); %All anchors associated with given anchor
for i = 1:NAnchs
[r,c] = find(TurbAnchConnect == i); %Find turbines directly connected to this anchor
for j = 1:length(r)
if r(j) == 1 %Upwind line
AnchAnchConnect(i,1:3) = TurbAnchConnect(:,c(j));
elseif r(j) == 2 %Bottom right line
AnchAnchConnect(i,4:6) = TurbAnchConnect(:,c(j));
elseif r(j) == 3 %Top right line
AnchAnchConnect(i,7:9) = TurbAnchConnect(:,c(j));
end
end
end
%% Develop line and anchor connections
LineAnchConnect = zeros(NLines,3); %All anchors associated with a given line
LineLineConnect = zeros(NLines,3); %All lines associated with a given line
for i = 1:NLines
TurbNum = LineConnect(i,1);
Anums = TurbAnchConnect(:,TurbNum);
LineAnchConnect(i,:) = Anums;
LineNums = TurbLineConnect(TurbNum,:);
LineLineConnect(i,:) = LineNums;
end
LineFail = zeros(NTurbs*3,6); %Preallocated line failures
AnchorFail = zeros(NAnchs,1); %Preallocated anchor failures
TurbFail = zeros(NTurbs,1); %Preallocated turbine failures
%% Make a list showing which line is directly connected to which anchor
LAC = zeros(NLines,1);
for i = 1:NTurbs
LineNums = TurbLineConnect(i,:);
AnchNums = TurbAnchConnect(:,i);
LAC(LineNums) = AnchNums;
end
%% Make a list that goes from anchor to lines
ALC = zeros(NAnchs,3);
LineList = 1:NLines;
for i = 1:NAnchs
ac = LineList(LAC==i);
ALC(i,1:length(ac)) = ac;
end