-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateDesignResultsTable.m
197 lines (183 loc) · 7.2 KB
/
generateDesignResultsTable.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
% study_PTOsizing.m script m-file
% AUTHORS:
% Jeremy Simmons (email: [email protected])
% University of Minnesota
% Department of Mechanical Engineering
%
% CREATION DATE:
% December 31, 2021
%
% PURPOSE:
% The purpose of this script is to generate a table showing design
% parameters for each sea state given a specific maximum pump displacement
% and RO module membrane area. This is perfromed on data generated by the
% script "study_PTOsizing.m".
%
% FILE DEPENDENCIES:
%
% UPDATES
% 12/31/2021 - created.
%
% Copyright (C) 2022 Jeremy W. Simmons II
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
studyType = 4; % selection for the type of study that was perfromed
% 1 - 2D studies that index data variable with PTO type and
% membrane area
% 2 - 2D studies that index data variable with PTO type
% 3 - studies that only consider one design and are just run
% to find the optimal operating conditions. In this case
% 'D_wChoice' and 'S_roChoice' don't affect anything
SSsetType = 1; % selection for set of sea states to display
% 1-all in order by ID
% 2-all in random order
% 3-top 90% by yearly power in random order
% 4-top 80% by yearly power in random order
% 5-bottom 20% by yearly power in random order
% 6-bottom 10% by yearly power in random order
% 7-random selection of 10 based on randomized order
switch studyType
case [1 2]
iPTO = 1;
D_wChoice = .23;
S_roChoice = 3700;
case 3
iiPTO = iPTO;
iPTO = 1;
end
%% Specify sea states to include in the table
switch SSsetType
case 1 % all sea states
SSset = data(iPTO).par.SSset';
case 2
load("randSSset_all.mat","SSset")
case 3
load("randSSset_top90.mat","SSset")
case 4
load("randSSset_top80.mat","SSset")
case 5
load("randSSset_bottom20.mat","SSset")
case 6
load("randSSset_bottom10.mat","SSset")
case 7
load("randSSset_all.mat","SSset")
nSS = 10;
[~,iSSsort] = sortrows( ...
[par.Hs(SSset(1:nSS))',par.Tp(SSset(1:nSS))']);
SSset = SSset(iSSsort);
end
%% find design values for a given combination specified by max disp. and RO module size
switch studyType
case 1 % for studies that index data variable with PTO type and membrane area
iiS_ro = find(S_roArray <= S_roChoice, 1,'last');
iD_wChoice = find(data(iPTO,iiS_ro).D_w(:,1) <= D_wChoice, 1,'last');
iS_roChoice = 1;
case 2 % for studies that index data variable with PTO type
iD_wChoice = find(data(iPTO).D_w(:,1) <= D_wChoice, 1,'last');
iS_roChoice = find(data(iPTO).S_ro(1,:) <= S_roChoice, 1,'last');
case 3 % for studies that only consider one design and are just run to
% find the optimal operating conditions
iD_wChoice = numel(D_wArray);
iS_roChoice = numel(S_roArray);
case 4 % for studies that only consider one design and are just run to
% find the optimal operating conditions same as case 3 but with
% data trimmed to only include one design.
iD_wChoice = 1;
iS_roChoice = 1;
end
nSS = length(SSset);
Hs = zeros(nSS,1);
Tp = zeros(nSS,1);
D_wDesign = zeros(nSS,1);
S_roDesign = zeros(nSS,1);
P_iDesign = zeros(nSS,1);
q_perm_weighted = zeros(nSS,1);
q_perm = zeros(nSS,1);
PP_wDesign = zeros(nSS,1);
PP_genDesign = zeros(nSS,1);
PP_cDesign = zeros(nSS,1);
feasible = zeros(nSS,1);
for iSS = 1:nSS
Hs(iSS) = par.Hs(SSset(iSS));
Tp(iSS) = par.Tp(SSset(iSS));
q_perm_weighted(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).q_perm;
q_perm(iSS) = q_perm_weighted(iSS)/(par.weight(SSset(iSS))/100);
D_wDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).D_w;
S_roDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).S_ro;
P_iDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).p_i;
PP_wDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).PP_w;
PP_genDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).PP_gen;
PP_cDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).PP_c;
feasible(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).feasible;
if ~feasible(iSS)
D_wDesign(iSS) = nan;
S_roDesign(iSS) = nan;
P_iDesign(iSS) = nan;
end
end
if PTOarray(iiPTO(iPTO)) == 2 || PTOarray(iiPTO(iPTO)) == 4
dutyDesign = zeros(nSS,1);
for iSS = 1:nSS
dutyDesign(iSS) = data(iPTO).design(iD_wChoice,iS_roChoice,SSset(iSS)).duty;
if ~feasible(iSS)
dutyDesign(iSS) = nan;
end
end
end
%% make table
switch PTOarray(iiPTO(iPTO))
case {1 3}
varNames = {'Sea State','Hs (m)','Tp (s)', ...
'Displacement (m^3/rad)','S_ro(m^2)', ...
'P_i (MPa)', ...
'Permeate Prod. (m^3/day)','Weighted Permeate Prod. (m^3/day)', ...
'WEC Power Capture (kW)','Elec. Power Generation (kW)','Charge Pump Power Consumption (kW)', ...
'Feasible (T/F)'};
T_D = table(SSset,Hs,Tp, ...
D_wDesign,S_roDesign, ...
1e-6*P_iDesign, ...
24*3600*q_perm,24*3600*q_perm_weighted, ...
1e-3*PP_wDesign,1e-3*PP_genDesign,1e-3*PP_cDesign, ...
feasible, ...
'VariableNames',varNames)
case {2 4}
varNames = {'Sea State','Hs (m)','Tp (s)', ...
'Displacement (m^3/rad)','S_ro (m^2)', ...
'P_i (MPa)','duty', ...
'Permeate Prod. (m^3/day)','Weighted Permeate Prod. (m^3/day)', ...
'WEC Power Capture (kW)','Elec. Power Generation (kW)','Charge Pump Power Consumption (kW)', ...
'Feasible (T/F)'};
T_D = table(SSset,Hs,Tp, ...
D_wDesign,S_roDesign, ...
1e-6*P_iDesign,dutyDesign, ...
24*3600*q_perm,24*3600*q_perm_weighted, ...
1e-3*PP_wDesign,1e-3*PP_genDesign,1e-3*PP_cDesign, ...
feasible, ...
'VariableNames',varNames)
end
%% make water table
Hs_2D = unique(par.Hs);
nHs = length(Hs_2D);
Tp_2D = unique(par.Tp);
nTp = length(Tp_2D);
q_perm_2D = zeros(nHs,nTp);
q_perm_weighted_2D = zeros(nHs,nTp);
for j = 1:nHs
for k = 1:nTp
q_perm_2D(j,k) = sum(q_perm(:).*((par.Hs(SSset) == Hs_2D(j)) & (par.Tp(SSset) == Tp_2D(k)))');
q_perm_weighted_2D(j,k) = sum(q_perm_weighted(:).*((par.Hs(SSset) == Hs_2D(j)) & (par.Tp(SSset) == Tp_2D(k)))');
end
end