-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSizing_VaryParams.m
141 lines (112 loc) · 3.89 KB
/
Sizing_VaryParams.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
%% Varying parameters in sizing optimization
% Including variable weights on multiobjective
% Optimizing w.r.t n_s, n_w, Eb_init
%% Varying DG rated power
rng default % For reproducibility of results (needed for random algorithm)
options = optimoptions('particleswarm', 'UseParallel', true, ...
'UseVectorized', false);
nvars = 3;
lb = [0,0,0];
ub = [100,30,200];
% Use opt. x solutions later to calculate 5 individual objectives, DE hours & BS cycles!
DE_rating = 0:1:20; % in kW
x = zeros(size(DE_rating,2),3);
fval = zeros(size(DE_rating,2),1);
tic
for i = 1:1:size(DE_rating,2)
P_DE_rated = DE_rating(i);
Objective = @(x) Objective_LI_DE_v9_1h_ind_VaryParams(x,P_DE_rated);
[x(i,:),fval(i)] = particleswarm(Objective,nvars,lb,ub,options);
end
param_time = toc;
% Normalized LCOE and emissions values for lower ratings may be artificially inflated
% slightly, since these are now being considered relative to a smaller size
% DG that may not satisfy all load in base case
%% Varying fuel (diesel price)
% Can also account for effect of carbon tax or fossil fuel subsidies
% Range of global diesel prices - https://www.globalpetrolprices.com/diesel_prices/
rng default % For reproducibility of results (needed for random algorithm)
options = optimoptions('particleswarm', 'UseParallel', true, ...
'UseVectorized', false);
nvars = 3;
lb = [0,0,0];
ub = [100,30,200];
C_DE = linspace(0.2,12,20); % in $/gal
x = zeros(size(C_DE,2),3);
fval = zeros(size(C_DE,2),1);
tic
for i = 1:1:size(C_DE,2)
DE_price = C_DE(i);
Objective = @(x) Objective_LI_DE_v9_1h_ind_VaryParams(x,DE_price);
[x(i,:),fval(i)] = particleswarm(Objective,nvars,lb,ub,options);
end
param_time = toc;
%% Varying nominal interest/discount rate
rng default % For reproducibility of results (needed for random algorithm)
options = optimoptions('particleswarm', 'UseParallel', true, ...
'UseVectorized', false);
nvars = 3;
lb = [0,0,0];
ub = [100,30,200];
inflation = linspace(0,0.2,20); % in (%)
x = zeros(size(inflation,2),3);
fval = zeros(size(inflation,2),1);
tic
for i = 1:1:size(inflation,2)
interest_rate = inflation(i);
Objective = @(x) Objective_LI_DE_v9_1h_ind_VaryParams(x,interest_rate);
[x(i,:),fval(i)] = particleswarm(Objective,nvars,lb,ub,options);
end
param_time = toc;
%% Varying inflation rate
rng default % For reproducibility of results (needed for random algorithm)
options = optimoptions('particleswarm', 'UseParallel', true, ...
'UseVectorized', false);
nvars = 3;
lb = [0,0,0];
ub = [100,30,200];
inflation = linspace(0,0.15,20); % in (%)
x = zeros(size(inflation,2),3);
fval = zeros(size(inflation,2),1);
tic
for i = 1:1:size(inflation,2)
inflation_rate = inflation(i);
Objective = @(x) Objective_LI_DE_v9_1h_ind_VaryParams(x,inflation_rate);
[x(i,:),fval(i)] = particleswarm(Objective,nvars,lb,ub,options);
end
param_time = toc;
%% Vary LI BS price
rng default % For reproducibility of results (needed for random algorithm)
options = optimoptions('particleswarm', 'UseParallel', true, ...
'UseVectorized', false);
nvars = 3;
lb = [0,0,0];
ub = [100,30,200];
BS_price = linspace(50,300,20); % in ($/kWh)
x = zeros(size(BS_price,2),3);
fval = zeros(size(BS_price,2),1);
tic
for i = 1:1:size(BS_price,2)
BS = BS_price(i);
Objective = @(x) Objective_LI_DE_v9_1h_ind_VaryParams(x,BS);
[x(i,:),fval(i)] = particleswarm(Objective,nvars,lb,ub,options);
end
param_time = toc;
%% Varying relative values of weights
rng default % For reproducibility of results (needed for random algorithm)
options = optimoptions('particleswarm', 'UseParallel', true, ...
'UseVectorized', false);
nvars = 3;
lb = [0,0,0];
ub = [100,30,200];
w3 = linspace(0,1,11);
dim = size(w3,2);
x = zeros(dim,3);
fval = zeros(dim,1);
tic
for i = 1:1:dim
w = w3(i);
Objective = @(x) Objective_LI_DE_v9_1h_ind_VaryParams(x,w);
[x(i,:),fval(i)] = particleswarm(Objective,nvars,lb,ub,options);
end
param_time = toc;