-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualization_gridded.m
More file actions
227 lines (189 loc) · 9.05 KB
/
Visualization_gridded.m
File metadata and controls
227 lines (189 loc) · 9.05 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
function[AnchorReliability] =...
Visualization_gridded(AnchorsOverstrengthened, OverstrengthFactor,...
NRows, NCols, DefaultTurbSpacing, DesignType, NSims, theta)
% Reliability_Compute determines the reliability of a multiline FOWT system
% Spencer Hallowell, UMASS Amherst, 3/8/2018
% Inputs:
% AnchorsOverstrengthened: List of anchors (can range from 1-120) that have
% OnverstrengthFactor applied to their strength
% OverstrengthFactor: Factor to multiply the strength of each anchor in
% AnchorsOverstrengthed
Z3 = zeros(1,3); %Preallocated vector of zeros
%% Some geometry and other initialization variables
TADistance = DefaultTurbSpacing*(sqrt(3)/3); %Spacing of turbines
NTurbs = NRows * NCols;
SiteX = sqrt(NTurbs*2)*DefaultTurbSpacing;
SiteY = sqrt(NTurbs*2)*DefaultTurbSpacing;
NLineSegments = 6; %number of failure points in each mooring line
SegNum = 1:NLineSegments; %Line segment numbers
%% Load in results of FAST analyses. These matrices will have distribution
% Parameters (LN and Normal distributions) for anchor and line forces.
R = load(['ReliabilityResultsLN_Final,',num2str(theta),'deg.mat']);
Res = R.Res;
%% Load in displacements of turbines in failed configurations
load(['Surge_',num2str(theta),'deg.mat'])
% Allocate displacements in a matrix.
D(1,1) = Displacements(1).Surge;
D(1,2) = Displacements(1).Sway;
D(2,1) = (.5*TADistance) + Displacements(2).Surge;
D(2,2) = Displacements(2).Sway;
D(3,1) = (-.25*TADistance) + Displacements(3).Surge;
D(3,2) = (.25*DefaultTurbSpacing) + Displacements(3).Sway;
D(4,1) = (-.25*TADistance) + Displacements(4).Surge;
D(4,2) = (-.25*DefaultTurbSpacing) + Displacements(4).Sway;
D(5,1) = (.5*TADistance) + Displacements(5).Surge;
D(5,2) = (.5*DefaultTurbSpacing) + Displacements(5).Sway;
D(6,1) = (.5*TADistance) + Displacements(6).Surge;
D(6,2) = (-.5*DefaultTurbSpacing) + Displacements(6).Sway;
D(7,1) = -TADistance + Displacements(6).Surge;
D(7,2) = Displacements(6).Sway;
%% Precompute line standard deviations
[Res] = LineStdev(Res,SegNum); %Standard deviations of line forces assumed constant along length
%% Create geometry and connectivity
[TurbX,TurbY,AnchorX,AnchorY,AnchLineConnect,...
LineConnect,TurbLineConnect,TurbAnchConnect,NAnchs,NLines,...
AnchorTurbConnect,~,~,~,AnchAnchConnect,...
LineAnchConnect,LineLineConnect,~,ALC] =...
Geo_Setup_gridded(NRows,NCols,SiteX,SiteY,TADistance,NTurbs);
ZNTurbs_3 = zeros(NAnchs,3); %Preallocated matrix of zeros
TurbXOriginal = TurbX; %Original location of the turbines
TurbYOriginal = TurbY;
% Designate between anchors with only 1 or two connected lines vs. one line
At = sum(AnchLineConnect==0,2); %Anchors with 2 lines
Asingle = find(At~=0); %Anchors with 1 line
Amulti = find(At==0); %Anchors with 3 lines
%% Compile structures to use for demand distributions.
R1 = Res(1);
R2 = Res(2);
R3 = Res(3);
R4 = Res(4);
R6 = Res(6);
R7 = Res(7);
R10 = Res(10);
LD1 = R1.LP1(SegNum,1)';
LD2 = R1.LP2(SegNum,1)';
LD3 = R1.LP3(SegNum,1)';
LD1(2,:) = mean(R1.L1stdev);
LD2(2,:) = mean(R1.L2stdev);
LD3(2,:) = mean(R1.L3stdev);
LD_mu = zeros(NTurbs*3,length(SegNum));
LD_sigma = zeros(NTurbs*3,length(SegNum));
LD_mu(1:3:end,:) = repmat(LD1(1,:),NTurbs,1);
LD_mu(2:3:end,:) = repmat(LD2(1,:),NTurbs,1);
LD_mu(3:3:end,:) = repmat(LD3(1,:),NTurbs,1);
LD_sigma(1:3:end,:) = repmat(LD1(2,:),NTurbs,1);
LD_sigma(2:3:end,:) = repmat(LD2(2,:),NTurbs,1);
LD_sigma(3:3:end,:) = repmat(LD3(2,:),NTurbs,1);
%% More input stuff
TurbList = 1:NTurbs; %List of turbine numbers
TACx = AnchorX(TurbAnchConnect); %Rearrance connectivity
TACy = AnchorY(TurbAnchConnect);
tt = repmat(1:NTurbs,3,1); %Lists of vectors
% CS = load('OriginalCosines.mat'); %Precomputed cosines and sines
% C1 = CS.C1;
% C2 = CS.C2;
% C3 = CS.C3;
% S1 = CS.S1;
% S2 = CS.S2;
% S3 = CS.S3;
C1 = cosd(theta-120).*ones(size(ZNTurbs_3));
C2 = cosd(theta).*ones(size(ZNTurbs_3));
C3 = cosd(theta+120).*ones(size(ZNTurbs_3));
S1 = sind(theta-120).*ones(size(ZNTurbs_3));
S2 = sind(theta).*ones(size(ZNTurbs_3));
S3 = sind(theta+120).*ones(size(ZNTurbs_3));
ra = AnchorsOverstrengthened; %This gives the layout of the overstrengthened anchors (list form, with anchor #)
LinesImpactedTemp = zeros(NLines,1);
AnchorsImpactedTemp = zeros(NAnchs,1);
timesStrengthened = zeros(NAnchs,1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
maxc = zeros(NSims,1);
naf = zeros(NAnchs,1);
nlf = zeros(NLines,1);
for nn = 1:1:NSims %This can be run in parallel using parfor
TurbX_New = TurbX; %New orientation of turbines
TurbY_New = TurbY;
LinesImpacted = ones(NLines,1); %List of lines impacted
AnchorsImpacted = ones(NAnchs,1); %List of anchors impacted
LineFailState = zeros(NLines,1); %Line failure state (binary)
AnchorImpactedCount = zeros(NAnchs,1); %Number of anchors impacted.
% rng(nn) %%%%% Random number generator can be fixed
%% Generate line and anchor capacities
[LineStrengths,AnchorStrengths] =...
Capacity_Setup_Full_Line(NTurbs,NAnchs,1,SegNum,Res,DesignType,Asingle,Amulti);
%% Amplify strength of anchors of interest by overstrength factor.
AnchorStrengths(ra) = OverstrengthFactor*AnchorStrengths(ra);
%% Run through simulation:
% Capacities of lines are assumed to remain constant
% Capacities of anchors can change if there is torsion on the anchor
% (caused by large turbine drift)
% Demands on lines and anchors can change if there is turbine drift
% (caused by anchor or line failure)
% Simulation ends if Capacity > Demand for every component
AnchorFail = zeros(size(AnchorStrengths)); %Anchor Failure state
TurbFail = zeros(NTurbs,1); %Turbine failures
TurbFailState = zeros(NTurbs,3); %Turbine line states
nf1 = 0; %Counting variables for progressive failure checks.
nf2 = -1;
count = 1;
while nf1 ~= nf2
if count > 1
nf1 = nf2;
end
%% Generate demands on anchors and lines. These are randomly sampled from the probability distributions.
[AnchorDemands,LineDemands] = DemandsLN_FullLine3(Res,NAnchs,...
AnchorFail,AnchorTurbConnect,...
NTurbs,TurbFailState,TurbAnchConnect,AnchorStrengths,...
LinesImpacted,AnchorsImpacted,SegNum,LD_mu,LD_sigma,...
R1,R2,R3,R4,R6,R7,R10,TurbX_New,TurbY_New,Z3,...
tt,TACx,TACy,C1,C2,C3,S1,S2,S3,ZNTurbs_3);
% Is this the first step in the simulation?
if count == 1
LinesImpactedOld = LinesImpacted*0;
AnchorsImpactedOld = AnchorsImpacted*0;
else
LinesImpactedOld = LinesImpacted+LinesImpactedOld;
AnchorsImpactedOld = AnchorsImpacted+AnchorsImpactedOld;
LinesImpactedOld(LinesImpactedOld>1) = 1;
AnchorsImpactedOld(AnchorsImpactedOld>1) = 1;
end
% Determine failure states. Remember to include surge and sway
% offsets (7.5 and 0.1, respectively)
[LineFail,AnchorFail,~,LineStrengths,AnchorStrengths,TurbFailState,TurbX_New,TurbY_New] =...
Failures_FullLine2(AnchorStrengths,AnchorDemands,LineStrengths,...
LineDemands,TurbFail,TurbXOriginal+7.4998,...
TurbYOriginal+0.1063,TurbList,ALC,D);
LineFailState = any(LineFail,2); %Check to see if any lines have failed
%% Determine which parts of the system have changed
[LinesImpacted,AnchorsImpacted] = DetectChangedElements(LinesImpactedOld,...
AnchorsImpactedOld,LineFail,AnchorFail,...
AnchAnchConnect,LineLineConnect,...
AnchLineConnect,LineAnchConnect,LineConnect,...
TurbLineConnect,TurbAnchConnect,AnchorTurbConnect,nn,LinesImpactedTemp,AnchorsImpactedTemp);
AnchorImpactedCount = AnchorImpactedCount + AnchorsImpacted;
%% Reduce the strength of anchors who are under torsion due to a failure
AnchorStrengths(AnchorImpactedCount==1) = AnchorStrengths(AnchorImpactedCount==1)*0.8;
AnchorImpactedCount = AnchorImpactedCount + AnchorImpactedCount;
%% Update number of failures
na = sum(AnchorFail); %Number of anchor failures
lftemp = sum(LineFail,2);
lftemp(lftemp>1) = 1;
nl = sum(sum(lftemp)); %Number of line failures
nf2 = na + nl; %Total number of failures
count = count + 1;
end %Simulation ends after this
maxc(nn) = count; %Total number of iterations
nlf = nlf + LineFailState; %Total number of lines failed (out of all simulations)
naf = naf + AnchorFail; %Total number of anchors failed (out of all simulations)
end
TurbNAF = naf(TurbAnchConnect); %Turbines impacted by anchor failures
TurbnafT = sum(TurbNAF,2)/100/NSims; %Failure rate of turbines.
ar = -norminv(1-(1-TurbnafT(1))*(1-TurbnafT(2))*(1-TurbnafT(3)));
for j = 1:NAnchs
if ismember(j,AnchorsOverstrengthened)
timesStrengthened(j) = 1;
end
end
% HeatMap(TurbX,TurbY,AnchorX,AnchorY,LineConnect,timesStrengthened)
PaintLines(TurbX,TurbY,AnchorX,AnchorY,LineFail,LineConnect,AnchorFail,TurbFail,TurbAnchConnect)
AnchorReliability = ar;
6;