-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatlabDispatch.m
464 lines (418 loc) · 27.7 KB
/
MatlabDispatch.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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
% setting: 1 generator(ac), 1 pv(dc), 1 battery(dc), 1 electric load(ac)
% see definition of variables here: https://www.homerenergy.com/products/pro/docs/latest/_listing_of_simulationstate.html
function [simulation_state, matlab_simulation_variables] = MatlabDispatch(simulation_parameters, simulation_state, matlab_simulation_variables)
%%
%initiate an zero array for storing the output parameters, 3 rows for three choices and 14 columns for 14 variables
% row: option1, option2 option3
option_1 = 1;
option_2 = 2;
option_3 = 3;
% column:
% 1 - simulation_state.generators(1).power_setpoint
generator_power_setpoint = 1;
% 2 - simulation_state.converters(1).inverter_power_input
inverter_power_input = 2;
% 3 - simulation_state.converters(1).inverter_power_output
inverter_power_output = 3;
% 4 - simulation_state.converters(1).rectifier_power_input
rectifier_power_input = 4;
% 5 - simulation_state.converters(1).rectifier_power_output
rectifier_power_output = 5;
% 6 - simulation_state.batteries(1).power_setpoint
battery_power_setpoint = 6;
% 7 - simulation_state.primary_loads(1).load_served
primary_load_served = 7;
% 8 - simulation_state.ac_bus.excess_electricity
ac_bus_excess_electricity = 8;
% 9 - simulation_state.ac_bus.load_served
ac_bus_load_served = 9;
% 10 - simulation_state.ac_bus.capacity_requested
ac_bus_capacity_requested = 10;
% 11 - simulation_state.ac_bus.operating_capacity_served
ac_bus_operating_capacity_served = 11;
% 12 - simulation_state.ac_bus.unmet_load
ac_bus_unmet_load = 12;
% 13 - simulation_state.ac_bus.capacity_shortage
ac_bus_capacity_shortage = 13;
% 14 - marginal cost ($/kWh)
marginal_cost = 14;
% the matrix
parameters = zeros(3,14);
% we don't have dc load in green case, set all related state variable to 0
simulation_state.dc_bus.capacity_shortage = 0;
simulation_state.dc_bus.excess_electricity = 0;
simulation_state.dc_bus.load_served = 0;
simulation_state.dc_bus.operating_capacity_served = 0;
simulation_state.dc_bus.unmet_load = 0;
% define intermediate variables that we do not want to see in model output
battery_max_discharge_power = 0; % AC
battery_max_charge_power = 0; % DC
generator_max_possible_output_from_load_and_battery = 0; % AC
% extract rectifier and inverter efficiency
if simulation_parameters.has_battery == true
%example code has the following two commands but I think they are
%redundant since these two are already defined with HOMER design
%interface
%simulation.converters(1).rectifier_efficiency = 90;
%simulation_parameters.converters(1).inverter_efficiency = 95;
rect_efficiency = simulation_parameters.converters(1).rectifier_efficiency;
inv_efficiency = simulation_parameters.converters(1).inverter_efficiency;
end
% extract generator minimum ouput in kW
if simulation_parameters.has_generator == true
min_load = simulation_parameters.generators(1).minimum_load;
end
%%
% step 1: use PV first
% extract available solar in kW
if simulation_parameters.has_pv == true
simulation_state.pvs(1).power_setpoint = simulation_state.pvs(1).power_available;
end
% actual power available after passing through the converters in kW
% min(inverter capacity, solar supply*inverter efficiency)
actual_inverted_power = min(simulation_parameters.converters(1).inverter_capacity, simulation_state.pvs(1).power_setpoint*inv_efficiency/100);
% calculate net load and excess solar in kW
matlab_simulation_variables.net_load = max(simulation_state.ac_bus.load_requested - actual_inverted_power, 0);
% in ac
excess_solar_step_one = max(actual_inverted_power - simulation_state.ac_bus.load_requested, 0);
% charge the battery with excess solar
% min(battery maximum charge power, excess solar)
simulation_state.batteries(1).power_setpoint = min(simulation_state.batteries(1).max_charge_power, excess_solar_step_one);
battery_max_discharge_power = simulation_state.batteries(1).max_discharge_power + simulation_state.batteries(1).power_setpoint*(inv_efficiency/100);
battery_max_charge_power = simulation_state.batteries(1).max_charge_power - simulation_state.batteries(1).power_setpoint;
generator_max_possible_output_from_load_and_battery = matlab_simulation_variables.net_load + battery_max_charge_power/(rect_efficiency/100);
%%
% step 2: decide how to meet net load with remaining solar, generator and battery by marginal cost in $/kWh
% marginal cost of each dispatch option
% option 1: discharge battery to meet the net load as much as possible, use the generator to fill the remaining
% marginal cost ($/kWh) = average cost of charging + battery wear cost + value of stored energy +(cost of using the generator + cost of unmet load)
% option 2: ramp up the generator to follow the net load, store the excess eletricity if net load is lower than minimum output
% marginal cost ($/kWh) = cost of using the generator + (average cost of charging + battery wear cost - value of stored energy + cost of unmet load)
% option 3: ramp up the generator as much as possible
% marginal cost ($/kWh) = cost of using the generator + average cost of charging + battery wear cost - value of stored energy
%%
% option 1
% if we have enough storage in the battery to serve the net load
if battery_max_discharge_power >= matlab_simulation_variables.net_load
% equals to - simulation_state.generators(1).power_setpoint = 0;
parameters(option_1,generator_power_setpoint) = 0;
% inverter output in ac bounds by net load and inverter capacity
parameters(option_1,inverter_power_output) = ...
min(matlab_simulation_variables.net_load, simulation_parameters.converters(1).inverter_capacity);
% inverter input in dc adjusted by inverter efficiency
parameters(option_1,inverter_power_input) = parameters(option_1,inverter_power_output)/(inv_efficiency/100);
% battery net charge
parameters(option_1,battery_power_setpoint) = ...
simulation_state.batteries(1).power_setpoint - parameters(option_1,inverter_power_input);
% rectifier input set to zero
parameters(option_1,rectifier_power_input) = 0;
% rectifier output set to zero
parameters(option_1,rectifier_power_output) = 0;
% primary load served
parameters(option_1,primary_load_served) = ...
parameters(option_1,inverter_power_output) + (simulation_state.ac_bus.load_requested - matlab_simulation_variables.net_load);
% ac bus excess electricity
parameters(option_1,ac_bus_excess_electricity) = excess_solar_step_one * inv_efficiency/100;
% ac bus load served
parameters(option_1,ac_bus_load_served) = parameters(option_1,primary_load_served);
% ac bus operating capacity requested: refelect requested load reserve
parameters(option_1,ac_bus_capacity_requested) = ...
parameters(option_1,primary_load_served) + ...
(simulation_parameters.operating_reserve.timestep_requirement/100) * parameters(option_1,primary_load_served);
% ac bus operating capacity served: maximum capacity in ac
parameters(option_1,ac_bus_operating_capacity_served) = ...
simulation_state.batteries(1).max_discharge_power + actual_inverted_power;
% ac bus unmet load
parameters(option_1,ac_bus_unmet_load) = ...
simulation_state.ac_bus.load_requested - parameters(option_1,primary_load_served);
% ac bus capacity shortage
parameters(option_1,ac_bus_capacity_shortage) = ...
parameters(option_1,ac_bus_capacity_requested) - parameters(option_1,ac_bus_operating_capacity_served);
else % battery is not enough to meet the load
% inverter output in ac
parameters(option_1,inverter_power_output) = ...
min(battery_max_discharge_power, simulation_parameters.converters(1).inverter_capacity);
% inverter input in dc
parameters(option_1,inverter_power_input) = parameters(option_1,inverter_power_output)/(inv_efficiency/100);
% battery net charge
parameters(option_1,battery_power_setpoint) = ...
simulation_state.batteries(1).power_setpoint - parameters(option_1,inverter_power_input);
% remaining load after battery discharge to the maximum level
remaining_load = matlab_simulation_variables.net_load - parameters(option_1,inverter_power_output);
if remaining_load > min_load % we run generator at either remaining load or full capacity
% generator output: minimum of remaining load and generator capacity
parameters(option_1,generator_power_setpoint) = ...
min(remaining_load, simulation_state.generators(1).power_available);
% rectifier input set to zero
parameters(option_1,rectifier_power_input) = 0;
% rectifier output set to zero
parameters(option_1,rectifier_power_output) = 0;
% primary load served
parameters(option_1,primary_load_served) = ...
parameters(option_1,inverter_power_output) + ...
(simulation_state.ac_bus.load_requested - matlab_simulation_variables.net_load) + ...
parameters(option_1,generator_power_setpoint);
% ac bus excess electricity
parameters(option_1,ac_bus_excess_electricity) = excess_solar_step_one * inv_efficiency/100;
% ac bus load served
parameters(option_1,ac_bus_load_served) = parameters(option_1,primary_load_served);
% ac bus operating capacity requested: reflect requested load reserve
parameters(option_1,ac_bus_capacity_requested) = ...
parameters(option_1,primary_load_served) + ...
(simulation_parameters.operating_reserve.timestep_requirement/100) * parameters(option_1,primary_load_served);
% ac bus operating capacity served: maximum capacity in ac
parameters(option_1,ac_bus_operating_capacity_served) = ...
simulation_state.batteries(1).max_discharge_power + actual_inverted_power + ...
simulation_state.generators(1).power_available;
% ac bus unmet load
parameters(option_1,ac_bus_unmet_load) = ...
simulation_state.ac_bus.load_requested - parameters(option_1,primary_load_served);
% ac bus capacity shortage
parameters(option_1,ac_bus_capacity_shortage) = ...
parameters(option_1,ac_bus_capacity_requested) - parameters(option_1,ac_bus_operating_capacity_served);
else % we run generator at min_load
% generator output: minimum load
parameters(option_1,generator_power_setpoint) = min_load;
% inverter output in ac
parameters(option_1,inverter_power_output) = ...
max(0, matlab_simulation_variables.net_load - parameters(option_1,generator_power_setpoint));
% inverter input in dc
parameters(option_1,inverter_power_input) = parameters(option_1,inverter_power_output)/(inv_efficiency/100);
% battery net charge
parameters(option_1,battery_power_setpoint) = ...
simulation_state.batteries(1).power_setpoint - parameters(option_1,inverter_power_input);
% rectifier input set to zero
parameters(option_1,rectifier_power_input) = 0;
% rectifier output set to zero
parameters(option_1,rectifier_power_output) = 0;
% primary load served
parameters(option_1,primary_load_served) = ...
parameters(option_1,inverter_power_output) + ...
(simulation_state.ac_bus.load_requested - matlab_simulation_variables.net_load) + ...
parameters(option_1,generator_power_setpoint);
% ac bus excess electricity
parameters(option_1,ac_bus_excess_electricity) = ...
excess_solar_step_one * inv_efficiency/100 + ...
(parameters(option_1,inverter_power_input)==0)*...
(parameters(option_1,generator_power_setpoint)-matlab_simulation_variables.net_load);
% ac bus load served
parameters(option_1,ac_bus_load_served) = parameters(option_1,primary_load_served);
% ac bus operating capacity requested: reflect requested load reserve
parameters(option_1,ac_bus_capacity_requested) = ...
parameters(option_1,primary_load_served) + ...
(simulation_parameters.operating_reserve.timestep_requirement/100) * parameters(option_1,primary_load_served);
% ac bus operating capacity served: maximum capacity in ac
parameters(option_1,ac_bus_operating_capacity_served) = ...
simulation_state.batteries(1).max_discharge_power + actual_inverted_power + ...
simulation_state.generators(1).power_available;
% ac bus unmet load
parameters(option_1,ac_bus_unmet_load) = simulation_state.ac_bus.load_requested - parameters(option_1,primary_load_served);
% ac bus capacity shortage
parameters(option_1,ac_bus_capacity_shortage) = ...
parameters(option_1,ac_bus_capacity_requested) - parameters(option_1,ac_bus_operating_capacity_served);
end
end
%%
% option 2
% if net load is lower than min load, we run generator at min load
if matlab_simulation_variables.net_load <= min_load
% generator output: minimum load
parameters(option_2,generator_power_setpoint) = min_load;
% use the remaining to charge battery
excess_generator_output = parameters(option_2,generator_power_setpoint) - matlab_simulation_variables.net_load;
% do we have enough place to store all excess electricity
if excess_generator_output >= battery_max_charge_power/(rect_efficiency/100)
% rectifier output: bound by remaining charging power and rectifier capacity
parameters(option_2,rectifier_power_output) = ...
min(battery_max_charge_power/(rect_efficiency/100), simulation_parameters.converters(1).rectifier_capacity);
else % we can actually store all excess power into battery if remaining charging power allows
% rectifier output: excess output and rectifier capacity
parameters(option_2,rectifier_power_output) = ...
min(excess_generator_output, simulation_parameters.converters(1).rectifier_capacity);
end
% rectifier input
parameters(option_2,rectifier_power_input) = parameters(option_2,rectifier_power_output)/(rect_efficiency/100);
% battery net charge
parameters(option_2,battery_power_setpoint) = ...
parameters(option_2,rectifier_power_output) + simulation_state.batteries(1).power_setpoint;
% inverter input set to 0
parameters(option_2,inverter_power_input) = 0;
% inverter output set to 0
parameters(option_2,inverter_power_output) = 0;
% primary load served
parameters(option_2,primary_load_served) = simulation_state.ac_bus.load_requested;
% ac bus excess electricity
parameters(option_2,ac_bus_excess_electricity) = ...
excess_solar_step_one * inv_efficiency/100 + excess_generator_output- parameters(option_2,rectifier_power_input);
% ac bus load served
parameters(option_2,ac_bus_load_served) = parameters(option_2,primary_load_served);
% ac bus operating capacity requested
parameters(option_2,ac_bus_capacity_requested) = ...
parameters(option_2,primary_load_served) + ...
(simulation_parameters.operating_reserve.timestep_requirement/100) * parameters(option_2,primary_load_served);
% ac bus operating capacity served
parameters(option_2,ac_bus_operating_capacity_served) = ...
simulation_state.batteries(1).max_discharge_power + actual_inverted_power + simulation_state.generators(1).power_available;
% as bus unmet load
parameters(option_2,ac_bus_unmet_load) = simulation_state.ac_bus.load_requested - parameters(option_2,primary_load_served);
% ac bus capacity shortage
parameters(option_2,ac_bus_capacity_shortage) = ...
parameters(option_2,ac_bus_capacity_requested) - parameters(option_2,ac_bus_operating_capacity_served);
else % if net load larger than min load, we run generator at either net load or full capacity
% generator output: minimum load
parameters(option_2,generator_power_setpoint) = ...
min(matlab_simulation_variables.net_load, simulation_state.generators(1).power_available);
% do we have unmet load here
unmet_load = max(0, matlab_simulation_variables.net_load - simulation_state.generators(1).power_available);
% discharge the battery to meet this unmet load if possible
% inverter output
parameters(option_2,inverter_power_output) = min(unmet_load, battery_max_discharge_power);
% inverter input
parameters(option_2,inverter_power_input) = parameters(option_2,inverter_power_output)/(inv_efficiency/100);
% rectifier output: 0
parameters(option_2,rectifier_power_output) = 0;
% rectifier input
parameters(option_2,rectifier_power_input) = 0;
% battery net charge
parameters(option_2,battery_power_setpoint) = ...
- parameters(option_2,inverter_power_input) + simulation_state.batteries(1).power_setpoint;
% primary load served
parameters(option_2,primary_load_served) = parameters(option_2,generator_power_setpoint) + parameters(option_2,inverter_power_output);
% ac bus excess electricity
parameters(option_2,ac_bus_excess_electricity) = excess_solar_step_one * inv_efficiency/100;
% ac bus load served
parameters(option_2,ac_bus_load_served) = parameters(option_2,primary_load_served);
% ac bus operating capacity requested
parameters(option_2,ac_bus_capacity_requested) = ...
parameters(option_2,primary_load_served) + ...
(simulation_parameters.operating_reserve.timestep_requirement/100) * parameters(option_2,primary_load_served);
% ac bus operating capacity served
parameters(option_2,ac_bus_operating_capacity_served) = ...
simulation_state.batteries(1).max_discharge_power + actual_inverted_power + ...
simulation_state.generators(1).power_available;
% as bus unmet load
parameters(option_2,ac_bus_unmet_load) = simulation_state.ac_bus.load_requested - parameters(option_2,primary_load_served);
% ac bus capacity shortage
parameters(option_2,ac_bus_capacity_shortage) = ...
parameters(option_2,ac_bus_capacity_requested) - parameters(option_2,ac_bus_operating_capacity_served);
end
%%
% option 3
if generator_max_possible_output_from_load_and_battery <= min_load
% inverter input: 0
parameters(option_3,inverter_power_input) = 0;
% inverter output: 0
parameters(option_3,inverter_power_output) = 0;
% generator output: minimum load
parameters(option_3,generator_power_setpoint) = min_load;
% use the remaining to charge battery
excess_generator_output = parameters(option_3,generator_power_setpoint) - matlab_simulation_variables.net_load;
% do we have enough space in battery
if excess_generator_output >= (battery_max_charge_power/(rect_efficiency/100))
% rectifier output
parameters(option_3,rectifier_power_output) = ...
min(battery_max_charge_power/(rect_efficiency/100), simulation_parameters.converters(1).rectifier_capacity);
else
% rectifier output
parameters(option_3,rectifier_power_output) = ...
min(excess_generator_output, simulation_parameters.converters(1).rectifier_capacity);
end
else % we run generator either at full capacity or maximum possible output considering battery
% generator output: minimum load
parameters(option_3,generator_power_setpoint) = ...
min(generator_max_possible_output_from_load_and_battery, simulation_state.generators(1).power_available);
% if we have unmet load, discharge battery to meet the remaining if possible
remain_load = max(0,matlab_simulation_variables.net_load - parameters(option_3,generator_power_setpoint));
if remain_load>0 % we run generator at full capacity with battery assistance, this is equal to option 2
% inverter output
parameters(option_3,inverter_power_output) = min(remain_load, battery_max_discharge_power);
% inverter input
parameters(option_3,inverter_power_input) = parameters(option_3,inverter_power_output)/(inv_efficiency/100);
% rectifier output: 0
parameters(option_3,rectifier_power_output) = 0;
% rectifier input
parameters(option_3,rectifier_power_input) = 0;
% battery net charge
parameters(option_3,battery_power_setpoint) = ...
- parameters(option_3,inverter_power_input) + simulation_state.batteries(1).power_setpoint;
% primary load served
parameters(option_3,primary_load_served) = ...
parameters(option_3,generator_power_setpoint) + parameters(option_3,inverter_power_output);
% ac bus excess electricity
parameters(option_3,ac_bus_excess_electricity) = excess_solar_step_one * inv_efficiency/100;
else
% inverter input: 0
parameters(option_3,inverter_power_input) = 0;
% inverter output: 0
parameters(option_3,inverter_power_output) = 0;
% use the remaining to charge battery
excess_generator_output = parameters(option_3,generator_power_setpoint) - matlab_simulation_variables.net_load;
% rectifier output
parameters(option_3,rectifier_power_output) = ...
min(excess_generator_output, simulation_parameters.converters(1).rectifier_capacity);
% rectifier input
parameters(option_3,rectifier_power_input) = parameters(option_3,rectifier_power_output)/(rect_efficiency/100);
% battery net charge
parameters(option_3,battery_power_setpoint) = ...
simulation_state.batteries(1).power_setpoint + parameters(option_3,rectifier_power_input);
% primary load served
parameters(option_3,primary_load_served) = simulation_state.ac_bus.load_requested;
% ac bus excess electricity
parameters(option_3,ac_bus_excess_electricity) = ...
excess_solar_step_one * inv_efficiency/100 + excess_generator_output - parameters(option_3,rectifier_power_input);
end
% ac bus load served
parameters(option_3,ac_bus_load_served) = parameters(option_3,primary_load_served);
% ac bus operating capacity requested
parameters(option_3,ac_bus_capacity_requested) = ...
parameters(option_3,primary_load_served) + ...
(simulation_parameters.operating_reserve.timestep_requirement/100) * parameters(option_1,primary_load_served);
% ac bus operating capacity served
parameters(option_3,ac_bus_operating_capacity_served) = ...
actual_inverted_power + simulation_state.generators(1).power_available;
% as bus unmet load
parameters(option_3,ac_bus_unmet_load) = ...
simulation_state.ac_bus.load_requested - parameters(option_3,primary_load_served);
% ac bus capacity shortage
parameters(option_3,ac_bus_capacity_shortage) = ...
parameters(option_3,ac_bus_capacity_requested) - parameters(option_3,ac_bus_operating_capacity_served);
end
%%
% costs
parameters(:,marginal_cost) = ...
% if generator is turned on, calculate fuel cost
matlab_simulation_variables.generator_fuel_cost * parameters(:,generator_power_setpoint)/matlab_simulation_variables.net_load ...
% if generator is turned on, calculate O&M cost
+ (parameters(:,generator_power_setpoint)>0) * matlab_simulation_variables.generator_OM / matlab_simulation_variables.net_load ...
% if battery is discharged, calculate the fuel cost of stored energy
+ simulation_state.batteries(1).energy_cost * parameters(:,inverter_power_output)/matlab_simulation_variables.net_load ...
% if battery is discharged, calculate the battery wear cost of discharging
+ simulation_parameters.batteries(1).wear_cost * parameters(:,inverter_power_output)/matlab_simulation_variables.net_load ...
% if battery is charged, calculate the battery wear cost of charging
+ simulation_parameters.batteries(1).wear_cost * parameters(:,rectifier_power_input)/matlab_simulation_variables.net_load ...
% if battery is discharged, add on the value of stored energy
+ matlab_simulation_variables.electricity_price * parameters(:,inverter_power_output)/matlab_simulation_variables.net_load ...
% if battery is charged, take out the value of stored energy
- matlab_simulation_variables.electricity_price * parameters(:,rectifier_power_input)/matlab_simulation_variables.net_load ...
% add on the value of unmet load if there is any
+ matlab_simulation_variables.electricity_price * parameters(:,ac_bus_unmet_load)/matlab_simulation_variables.net_load;
costs = parameters(:,marginal_cost);
indx_min_cost = find(costs == min(costs));
% if there is a tie, always choose the one that charge the battery most
if length(indx_min_cost)>1
indx_min_cost = max(indx_min_cost);
end
simulation_state.generators(1).power_setpoint = parameters(indx_min_cost,generator_power_setpoint)
simulation_state.converters(1).inverter_power_input = parameters(indx_min_cost,inverter_power_input)
simulation_state.converters(1).inverter_power_output = parameters(indx_min_cost,inverter_power_output)
simulation_state.converters(1).rectifier_power_input = parameters(indx_min_cost,rectifier_power_input)
simulation_state.converters(1).rectifier_power_output = parameters(indx_min_cost,rectifier_power_output)
simulation_state.batteries(1).power_setpoint = parameters(indx_min_cost,battery_power_setpoint)
simulation_state.primary_loads(1).load_served = parameters(indx_min_cost,primary_load_served)
simulation_state.ac_bus.excess_electricity = parameters(indx_min_cost,ac_bus_excess_electricity)
simulation_state.ac_bus.load_served = parameters(indx_min_cost,ac_bus_load_served)
simulation_state.ac_bus.load_requested = parameters(indx_min_cost,ac_bus_capacity_requested)
simulation_state.ac_bus.operating_capacity_served = parameters(indx_min_cost,ac_bus_operating_capacity_served)
simulation_state.ac_bus.unmet_load = parameters(indx_min_cost,ac_bus_unmet_load)
simulation_state.ac_bus.capacity_shortage = parameters(indx_min_cost,ac_bus_capacity_shortage)
end