-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeo_Setup_gridded.m
160 lines (141 loc) · 5.36 KB
/
Geo_Setup_gridded.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
function[TurbX,TurbY,AnchorXu,AnchorYu,AnchLineConnect,...
LineConnect,TurbLineConnect,TurbAnchConnect,NAnchs,NLines,...
AnchTurbConnect,LineFail,AnchorFail,TurbFail,AnchAnchConnect,...
LineAnchConnect,LineLineConnect,LAC,ALC] =...
Geo_Setup(NRows,NCols,SiteX,SiteY,DefaultTurbSpacing,TADistance,NTurbs)
Angles = [180,300,420]; %Line angles
%Preallocation of anchor and turbine coordinates
TurbX = zeros(NTurbs,1);
TurbY = zeros(NTurbs,1);
AnchorX = zeros((NTurbs),3);
AnchorY = zeros((NTurbs),3);
%Set a uniform grid of turbines evenly spaced across the site. This is
%used as the basis for the random setup, as modifying this instead of doing
%a completely random layout is much more efficient than doing a true random
%setup with constraint corrections.
SpacingX = SiteX/NCols;
SpacingY = SiteY/NRows;
count = 1;
for j = 1:NRows
for k = 1:NCols
TurbX(count) = (k-1)*SpacingX + SpacingX/2;
TurbY(count) = (j-1)*SpacingY + SpacingY/2;
% Anchor positions are generated in identical configurations for each
% turbine, based on the turbine placement
AnchorX(count,:) = TurbX(count) + TADistance*cosd(Angles);
AnchorY(count,:) = TurbY(count) + TADistance*sind(Angles);
count = count + 1;
if count > NTurbs
break;
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