-
Notifications
You must be signed in to change notification settings - Fork 0
/
results_analysis_DRModule0.6
562 lines (458 loc) · 20.8 KB
/
results_analysis_DRModule0.6
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
!**************************************************************
forward procedure write_DR_flexibility
forward procedure write_summary_dr
forward procedure write_DR_shiftload
forward procedure DR_output
forward procedure write_generation_RESE
forward procedure write_generation_ONWIND
forward procedure print_DR_solution
!*******************************************************************************
!**** Procedures and functions ****
!*******************************************************************************
declarations
!DSM
SHIFT_CLASSES : range;
CURT_CLASSES : range;
FLEX_CLASSES : range;
EUROPE_LOAD : array(SCENARIOS, YEARS, HOURS) of real; ! Load in eUROPE
PEAK_EUROPE : array(SCENARIOS, YEARS, SEASONS) of real; ! pEAK Load in eUROPE
NEW_EUROPE_LOAD : array(SCENARIOS, YEARS, HOURS) of real;
NEW_PEAK_EUROPE : array(SCENARIOS, YEARS, SEASONS) of real; ! pEAK Load in eUROPE
!DSM solution containers
SH_LOAD : array(SCENARIOS, YEARS, HOURS, NODES, SHIFT_CLASSES) of real; ! DR DSM Shiftable loads for each FLEXIBLE class
SHCONST : array(SCENARIOS, YEARS, HOURS, NODES, SHIFT_CLASSES) of real;
CT_LOAD : array(SCENARIOS, YEARS, HOURS, NODES, CURT_CLASSES) of real; ! DR DSM Curtailable loads for each CURTAILABLE class
INF_LOAD : array(SCENARIOS, YEARS, HOURS, NODES) of real; ! TOTAL LOAD AFTER DR DSM
NEW_LOAD : array(SCENARIOS, YEARS, HOURS, NODES) of real; ! TOTAL LOAD AFTER DR DSM
DELTA_LOAD : array(SCENARIOS, YEARS, HOURS, NODES) of real; ! Gives the increase or decrease of LOAD AFTER DR DSM
ALPHA_SHIFT : array(SCENARIOS, HOURS, NODES, SHIFT_CLASSES) of real; ! Weight of each shiftable class.
ALPHA_CURT : array(SCENARIOS, HOURS, NODES, CURT_CLASSES) of real; ! Weight of each shiftable class. They sum up to 1, last class is curtailable load.
DR_CAP : array(YEARS,NODES,FLEX_CLASSES) of real;
DR_CAP_INIT : array(NODES,FLEX_CLASSES) of real;
DR_CAP_POT : array(NODES,FLEX_CLASSES) of real; !Potential DR capacities
MAX_DR_CAP : array(NODES) of real;
DR_INV : array(YEARS,NODES,FLEX_CLASSES) of real;
DR_LIMIT : array(YEARS,NODES,FLEX_CLASSES) of real;
FLEXIBILITY : array(YEARS, NODES) of real;
FLEXIBLE : array(NODES) of real;
LOAD_PEAK : array(YEARS,NODES) of real;
NUM_DR : range;
!TYPE_DR : array(NUM_DR) of integer;
YEARS_STRING: string;
FLEX_STRING : string;
SHIFT : array(SHIFT_CLASSES) of integer;
CURT : array(CURT_CLASSES) of integer;
days : integer;
end-declarations
RESULTFILE_STATEMENT := "zlib.gzip::" + RESULTFILE + ".gz";
DATAFILE_STATEMENT := "zlib.gzip::" + DATAFILE + ".gz";
procedure DR_output
read_DRdata_mosel_format;
read_DRresults_mosel_format;
write_DR_flexibility;
write_summary_dr;
print_DR_solution;
if DETAILS>1 then
write_DR_shiftload;
write_solution_summary_per_country;
end-if
end-procedure
write("DR done!\n\n");
!*******************************************************************************
!**** Procedures and functions ****
!*******************************************************************************
! Include utility functions (for functions declared in the beginning of the file)
!-------------------------------------------------------------------------------------------
! Read data to model
!-------------------------------------------------------------------------------------------
!--- Textfile
procedure read_DRdata_mosel_format
writeln("Reading DR data",DATAFILE_STATEMENT);
initializations from DATAFILE_STATEMENT
!***Sets and arrays linking sets
!DSM-read DR
SHIFT_CLASSES;
CURT_CLASSES;
FLEX_CLASSES;
MAX_DR_CAP;
SHIFT;
CURT;
NUM_DR;
ALPHA_SHIFT;
ALPHA_CURT;
DR_CAP_POT;
end-initializations
end-procedure
procedure read_DRresults_mosel_format
writeln("Reading DR results",RESULTFILE_STATEMENT);
initializations from RESULTFILE_STATEMENT
!DSM-read
INF_LOAD;
NEW_LOAD;
DELTA_LOAD;
SH_LOAD;
CT_LOAD;
SHCONST;
DR_CAP;
DR_INV;
DR_LIMIT;
FLEXIBILITY;
FLEXIBLE;
DR_CAP_INIT;
LOAD_PEAK;
!TYPE_DR;
end-initializations
end-procedure
!-------------------------------------------------------------------------------------------
! Write DR / DSM-results
!-------------------------------------------------------------------------------------------
procedure write_DR_flexibility
fopen(SCENARIO_FOLDER_PATH + "\\DR_operation.csv", F_OUTPUT);
write("Country,Year,Scenario,Season,Load Difference, Average Difference, Max\n");
forall(yy in YEARSH, nn in NODES, scn in SCENARIOS, sea in SEASONS) do
!NEW_LOAD: array(SCENARIOS, YEARS, HOURS, NODES)
aux := SEASON_F_L_HOUR(sea,2)-SEASON_F_L_HOUR(sea,1) + 1; !Number of hours in scenario scn
aux2:= sum(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) abs(DELTA_LOAD(scn,yy,hh,nn));
write(NODE_NAMES(nn,1));
write("," + yy); write(","+scn); write(","+sea);
write(",",aux2 ); !Total shifted load
write(",",aux2 / aux ); !Average increase/decrease of load
write("," + (max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) abs(DELTA_LOAD(scn,yy,hh,nn)) ) );
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_classes.csv", F_OUTPUT);
aux3 := "Country,Year,Scenario,Season";
forall(ff in SHIFT_CLASSES) aux3:= aux3+","+"Shift"+ff;
forall(ff in CURT_CLASSES) aux3:= aux3+","+"Curt"+ff;
writeln(aux3);
forall(nn in NODES, scn in SCENARIOS, yy in YEARSH, sea in SEASONS) do
!NEW_LOAD: array(SCENARIOS, YEARS, HOURS, NODES)
write(nn); !write(NODE_NAMES(nn,1));
write("," + yy); write(","+scn); write(","+sea);
forall (ff in SHIFT_CLASSES) do
aux:=SEASON_SCALE(SEASON_F_L_HOUR(sea,1))*sum(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) abs(DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh,nn,ff) - SH_LOAD(scn,yy,hh,nn,ff));
write(",",aux ); !Total shift from each class
end-do
forall (ff in CURT_CLASSES) do
aux:=SEASON_SCALE(SEASON_F_L_HOUR(sea,1))*sum(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) abs(CT_LOAD(scn,yy,hh,nn,ff));
write(",",aux ); !Total curt from each class
end-do
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_avg_classes.csv", F_OUTPUT);
!Calculates how much have been shifted and curtailed each year on scenario average
aux3 := "Year,Modified,Untouched";
writeln(aux3);
forall(yy in YEARSH) do
!NEW_LOAD: array(SCENARIOS, YEARS, HOURS, NODES)
!write(NODE_NAMES(nn,1));
write(yy);
aux:=1/SCENARIOS.size*sum(scn in SCENARIOS, sea in SEASONS, nn in NODES)
SEASON_SCALE(SEASON_F_L_HOUR(sea,1))*(
0.5*sum(ff in SHIFT_CLASSES, hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) abs(DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh,nn,ff) - SH_LOAD(scn,yy,hh,nn,ff))
+sum(ff in CURT_CLASSES, hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) abs(CT_LOAD(scn,yy,hh,nn,ff))
);
write(",",aux );
aux:=1/SCENARIOS.size*sum(scn in SCENARIOS, sea in SEASONS, nn in NODES)
SEASON_SCALE(SEASON_F_L_HOUR(sea,1))*(
0.5*sum(ff in SHIFT_CLASSES, hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) SH_LOAD(scn,yy,hh,nn,ff)
+sum(ff in CURT_CLASSES, hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) (
DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_CURT(scn,hh,nn,ff) - CT_LOAD(scn,yy,hh,nn,ff) )
);
write(",",aux );
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_newloads.csv", F_OUTPUT);
declarations
SCENH: set of integer;
YEARSHH: set of integer;
NODESH: set of integer;
HOURSH: range;
end-declarations
SCENH := {1,2,3};
YEARSHH := {5};
NODESH := {12};
HOURSH := HOURS;
write("Scenario,Year,Node,Hour,Original Load (MW), Inflexible (MW), New Load, Delta, Shifted, Supplied, Supplied2, Curtailable, % Flexible, Wind Production, Solar Production\n");
forall(scn in SCENH, yy in YEARSHH, nn in NODESH, hh in HOURS) do
write(scn); write("," + yy); write(","+nn); write(","+hh);
write(","+ NODE_LOAD(scn,yy,hh,nn));
write(","+ INF_LOAD(scn,yy,hh,nn));
write(","+ NEW_LOAD(scn,yy,hh,nn));
write(","+ DELTA_LOAD(scn,yy,hh,nn)); !"Delta": Difference between Original and New Load
write(","+ sum(ff in SHIFT_CLASSES) (DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh,nn,ff) - SH_LOAD(scn,yy,hh,nn,ff))); !"Shifted" shift_delta
write(","+ FLEXIBILITY(yy,nn)*NODE_LOAD(scn,yy,hh,nn)-sum(ff in SHIFT_CLASSES) SH_LOAD(scn,yy,hh,nn,ff)); !"Supplied": Includes losses
write(","+ sum(ff in SHIFT_CLASSES) SH_LOAD(scn,yy,hh,nn,ff)); !"Supplied2": Shifted classes without losses
write(","+ sum(ff in CURT_CLASSES) CT_LOAD(scn,yy,hh,nn,ff)); !Curtailed classes without losses
if FLEXIBILITY(yy,nn) > 0 then
write(","+ DELTA_LOAD(scn,yy,hh,nn)/(FLEXIBILITY(yy,nn)*NODE_LOAD(scn,yy,hh,nn)));
end-if
write("," + sum(gg in GENERATORS | GEN_NODE(gg)=nn and TECH_WIND(GEN_TECH(gg))) GEN_PROD(scn,yy,hh,gg)); !solar
write("," + sum(gg in GENERATORS | GEN_NODE(gg)=nn and TECH_SOLAR(GEN_TECH(gg))) GEN_PROD(scn,yy,hh,gg)); !wind
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_classes_cap.csv", F_OUTPUT);
write("Year,Node, Flexible Class, DR Capacity, Peak Ratio (%), DR Cap Dual \n");
forall(nn in NODES, ff in FLEX_CLASSES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write("0, "); write(nn); write("," + ff);
write(","+ DR_CAP_INIT(nn,ff)); write(","+ DR_CAP_INIT(nn,ff)/LOAD_PEAK(1,nn));
write("\n");
end-do
forall(nn in NODES, yy in YEARSH, ff in FLEX_CLASSES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(nn); write(", "+yy); write("," + ff);
write(","+ DR_CAP(yy,nn,ff)); write(","+ DR_CAP(yy,nn,ff)/LOAD_PEAK(yy,nn));
write(","+ DR_LIMIT(yy,nn,ff));
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_binding.csv", F_OUTPUT);
forall (ff in FLEX_CLASSES) do FLEX_STRING := FLEX_STRING + ff +",";
end-do
writeln("Country-Year/Flex.,,"+FLEX_STRING);
forall(nn in NODES, yy in YEARSH) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(nn); write(", "+yy);
forall(ff in FLEX_CLASSES) do write(","+ DR_LIMIT(yy,nn,ff));
end-do
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_capacity_class.csv", F_OUTPUT);
!forall (ff in FLEX_CLASSES) do FLEX_STRING := FLEX_STRING + ff +",";
!end-do
writeln("Country-Year/Capac.,,"+FLEX_STRING);
forall(nn in NODES) do
write(nn); write(","+0);
forall(ff in FLEX_CLASSES) do write(","+ DR_CAP_INIT(nn,ff));
end-do
write("\n");
forall(yy in YEARSH) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(", "+yy);
forall(ff in FLEX_CLASSES) do write(","+ DR_CAP(yy,nn,ff));
end-do
write("\n");
end-do
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_global.csv", F_OUTPUT);
write("Node,Year,Season, DR Capacity, Peak Load, % Peak, New Peak, %New Peak, %Capacity, Investments\n");
forall(nn in NODES, sea in SEASONS) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
aux:= sum(ff in FLEX_CLASSES) DR_CAP_INIT(nn,ff);
aux2:= max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) NODE_LOAD(1,1,hh,nn);
write(nn); write(",0 "); write(","+sea);
write(","+ aux);
write(","+ aux2);
write(","+ aux/aux2);
!New Peak
aux2:= max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) NEW_LOAD(1,1,hh,nn);
write(","+ aux2);
write(","+ aux/aux2);
aux2:= (sum(gg in GENERATORS | GEN_NODE(gg)=nn) GEN_CAP_INIT(gg));
write(","+ aux/aux2);
write("\n");
end-do
forall(nn in NODES, yy in YEARSH, sea in SEASONS) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
aux:= sum(ff in FLEX_CLASSES) DR_CAP(yy,nn,ff);
aux2:= max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) NODE_LOAD(1,yy,hh,nn);
write(nn); write(","+yy); write(","+sea);
write(","+ aux);
write(","+ aux2);
write(","+ aux/aux2);
!New Peak
aux2:= max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) NEW_LOAD(1,yy,hh,nn);
write(","+ aux2);
write(","+ aux/aux2);
aux2:= (sum(tt in TECHNOLOGIES) NODE_TECH_GEN_CAP(yy,nn,tt));
write(","+ aux/aux2);
write(","+ sum(ff in FLEX_CLASSES) DR_INV(yy,nn,ff));
write("\n");
end-do
fclose(F_OUTPUT);
(!fopen(SCENARIO_FOLDER_PATH + "\\flexibilityDR2.csv", F_OUTPUT);
write("Year,Node, % Peak\n");
forall(nn in NODES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write("0, ");
write(nn);
write(","+ FLEXIBLE(nn));
write("\n");
end-do
forall(nn in NODES, yy in YEARS) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(yy); write(","+nn);
write(","+ FLEXIBILITY(yy,nn));
write("\n");
end-do
fclose(F_OUTPUT);
!)
YEARS_STRING := "0,";
fopen(SCENARIO_FOLDER_PATH + "\\DR_flexibility.csv", F_OUTPUT);
forall (yy in YEARSH) do YEARS_STRING := YEARS_STRING + yy +",";
end-do
writeln("Country/Year,"+YEARS_STRING);
forall(nn in NODES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(nn);
write(","+ FLEXIBLE(nn));
forall( yy2 in YEARSH) do write(","+ FLEXIBILITY(yy2,nn));
end-do
write("\n");
end-do
fclose(F_OUTPUT);
YEARS_STRING := "0,";
fopen(SCENARIO_FOLDER_PATH + "\\DR_to_total.csv", F_OUTPUT);
forall (yy in YEARSH) do YEARS_STRING := YEARS_STRING + yy +",";
end-do
writeln("Country/Year,"+YEARS_STRING);
forall(nn in NODES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(nn);
write(","+ (sum(ff in FLEX_CLASSES) DR_CAP_INIT(nn,ff))/(MAX_DR_CAP(nn)*(sum(ff in FLEX_CLASSES) DR_CAP_POT(nn,ff) )));
forall( yy2 in YEARSH) do
write(","+ (sum(ff in FLEX_CLASSES) DR_CAP(yy2,nn,ff))/(MAX_DR_CAP(nn)*(sum(ff in FLEX_CLASSES) DR_CAP_POT(nn,ff) )));
end-do
write("\n");
end-do
fclose(F_OUTPUT);
YEARS_STRING := "0,";
fopen(SCENARIO_FOLDER_PATH + "\\DR_to_total_class.csv", F_OUTPUT);
forall (yy in YEARSH) do YEARS_STRING := YEARS_STRING + yy +",";
end-do
writeln("Country/Year,,"+YEARS_STRING);
forall(ff in FLEX_CLASSES, nn in NODES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(ff); write(","+nn);
if (DR_CAP_POT(nn,ff) > 0) then
write(","+ DR_CAP_INIT(nn,ff)/(MAX_DR_CAP(nn)*(DR_CAP_POT(nn,ff) )));
forall( yy2 in YEARSH) do
write(","+ DR_CAP(yy2,nn,ff)/(MAX_DR_CAP(nn)*(DR_CAP_POT(nn,ff) )));
end-do
else
aux:= -1;
write(","+ aux);
forall( yy2 in YEARSH) do write(","+ aux);
end-do
end-if
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_Europe.csv", F_OUTPUT);
forall (scn in SCENARIOS, yy in YEARSH, hh in HOURS) do
EUROPE_LOAD(scn,yy,hh) := sum(nn in NODES) NODE_LOAD(scn,yy,hh,nn);
NEW_EUROPE_LOAD(scn,yy,hh) := sum(nn in NODES) NEW_LOAD(scn,yy,hh,nn);
end-do
write("Scenario,Year, Season, DR Capacity, Peak Load, % Peak, New Peak, % New Peak, % Capacity \n");
forall (scn in SCENARIOS, yy in YEARSH, sea in SEASONS) do
PEAK_EUROPE(scn,yy,sea) := max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) EUROPE_LOAD(scn,yy,hh);
NEW_PEAK_EUROPE(scn,yy,sea) := max(hh in SEASON_F_L_HOUR(sea,1)..SEASON_F_L_HOUR(sea,2)) NEW_EUROPE_LOAD(scn,yy,hh);
write(scn); write(","+yy); write(","+sea);
aux:=sum(nn in NODES, ff in FLEX_CLASSES) DR_CAP(yy,nn,ff);
write(","+aux);
write(","+PEAK_EUROPE(scn,yy,sea));
write(","+aux/PEAK_EUROPE(scn,yy,sea));
write(","+NEW_PEAK_EUROPE(scn,yy,sea));
write(","+aux/NEW_PEAK_EUROPE(scn,yy,sea));
writeln(","+aux/(sum(nn in NODES, tt in TECHNOLOGIES) NODE_TECH_GEN_CAP(yy,nn,tt)));
end-do
fclose(F_OUTPUT);
end-procedure
procedure write_summary_dr
fopen(SCENARIO_FOLDER_PATH + "\\DR_summary.csv", F_OUTPUT);
write("Year,iRES generation, Curtailed generation, iRES inv, Total DR capacity, Total capacity, Emissions, Intercon inv \n");
write(",TWh, TWh, GW, GW, GW, MtCO2, GW \n");
forall(yy in YEARSH) do
write(yy);
write("," + strfmt(sum(nn in NODES, tt in TECHNOLOGIES | TECH_INTERMITTENT(tt)) NODE_ANNUAL_TECH_GEN_PROD(yy,nn,tt)/1e6,7,5));
write("," + strfmt(sum(nn in NODES, tt in TECHNOLOGIES) NODE_ANNUAL_TECH_GEN_CURT(yy,nn,tt)/1e6,7,5));
write("," + strfmt(sum(gg in GENERATORS | TECH_INTERMITTENT(GEN_TECH(gg))) GEN_INV(yy,gg)/1e3,7,5));
write("," + strfmt(sum(nn in NODES, ff in FLEX_CLASSES) DR_CAP(yy,nn,ff)/1e3,7,5));
write("," + strfmt(sum(nn in NODES, tt in TECHNOLOGIES) NODE_TECH_GEN_CAP(yy,nn,tt)/1e3,7,5));
write("," + strfmt(sum(nn in NODES) EMISSIONS(yy,nn)/1e6,7,5));
writeln("," + strfmt(sum(ll in LINES) LINE_INV(yy,ll)/1e3,7,5));
end-do
fclose(F_OUTPUT);
end-procedure
procedure write_loads
fopen(SCENARIO_FOLDER_PATH + "\\DR_loads.csv", F_OUTPUT);
forall (yy in YEARSH) do YEARS_STRING := YEARS_STRING + yy +",";
end-do
writeln("Country/Year,"+YEARS_STRING);
forall(nn in NODES) do
!max(ss in SCENARIOS, hh in HOURS) NODE_LOAD(ss,1,hh,nn);
write(nn);
forall( yy2 in YEARSH) do write(","+ LOAD_PEAK(yy2,nn));
end-do
write("\n");
end-do
fclose(F_OUTPUT);
end-procedure
procedure write_DR_shiftload
declarations
SCENH: set of integer;
YEARSHH: range;
NODESH: set of integer;
HOURSH: range;
end-declarations
SCENH := {1};
YEARSHH := YEARSH;
NODESH := {8,10,12,16,22};
HOURSH := HOURS;
fopen(SCENARIO_FOLDER_PATH + "\\DR_shiftload.csv", F_OUTPUT);
write("Scenario,Year,Node,Hour, Class,Original Load, Shift Load, Wrong Shift_delta, SH_delta, Slack Var\n");
forall(scn in SCENARIOS, yy in YEARSH, nn in NODESH, ff in SHIFT_CLASSES, hh in HOURS | yy=2 and scn=2) do
write(scn); write("," + yy); write(","+nn); write(","+hh);
write(","+ff);
write(","+ DR_CAP(yy,nn,ff)/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh, nn,ff));
write(","+ SH_LOAD(scn,yy,hh,nn,ff));
aux:=FLEXIBILITY(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh, nn,ff)-SH_LOAD(scn,yy,hh,nn,ff);
write(","+ aux);
write(","+ DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh,nn,ff) - SH_LOAD(scn,yy,hh,nn,ff));
write(","+ SHCONST(scn,yy,hh,nn,ff));
write("\n");
end-do
fclose(F_OUTPUT);
fopen(SCENARIO_FOLDER_PATH + "\\DR_shiftperday.csv", F_OUTPUT);
write("Scenario,Year,Node, Day, Class,Original Daily Load, Shift Load, Shift_delta\n");
days := floor(HOURS.size/24);
forall(scn in SCENH, yy in YEARSHH, nn in NODESH, dd in 1..days, ff in SHIFT_CLASSES) do
write(scn); write("," + yy); write(","+nn); write(","+dd);
write(","+ff);
write(","+ sum(hh in 24*(dd-1)+1..24*(dd)) DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh, nn,ff));
write(","+ sum(hh in 24*(dd-1)+1..24*(dd)) SH_LOAD(scn,yy,hh,nn,ff));
aux:=0.5*sum(hh in 24*(dd-1)+1..24*(dd)) abs(DR_CAP(yy,nn,SHIFT(ff))/LOAD_PEAK(yy,nn)*NODE_LOAD(scn,yy,hh,nn)*ALPHA_SHIFT(scn,hh,nn,ff) - SH_LOAD(scn,yy,hh,nn,ff));
write(","+ aux);
write("\n");
end-do
fclose(F_OUTPUT);
end-procedure
procedure print_DR_solution
declarations
DR_ORDER : array(NODES) of integer;
DR_2050 : array(NODES) of real;
LOG_ENTRY : string;
end-declarations
LOG_ENTRY := "\n----------------------------DR Solution Statistics------------------------------\n";
!-----------------------------------------------------------
! Print solution statistics
LOG_ENTRY += strfmt("Total DR Potential (GW): ",45) + " " + strfmt(1/1e3 * sum(nn in NODES,ff in FLEX_CLASSES) DR_CAP(YEARSH.size,nn,ff),12,4) + "\n";
LOG_ENTRY += strfmt("2050 Total Shifted Energy (GWh): ",45) + " " + strfmt(1/(2*1e3*SCENARIOS.size) * sum(scn in SCENARIOS, hh in HOURS, nn in NODES,ff in SHIFT_CLASSES) abs(DR_CAP(YEARSH.size,nn,SHIFT(ff))/LOAD_PEAK(YEARSH.size,nn)*NODE_LOAD(scn,YEARSH.size,hh,nn)*ALPHA_SHIFT(scn,hh,nn,ff) - SH_LOAD(scn,YEARSH.size,hh,nn,ff)),12,4) + "\n";
LOG_ENTRY += strfmt("2050 Total DR Decreased Energy (GWh): ",45) + " " +strfmt(1/(1e3*SCENARIOS.size) * sum(scn in SCENARIOS, hh in HOURS, nn in NODES,ff in CURT_CLASSES) CT_LOAD(scn,YEARSH.size,hh,nn,ff),12,4) + "\n";
LOG_ENTRY += strfmt("2050 Total Curtailed RES Energy (GWh): ",45) + " " + strfmt(1/1e3 * sum(nn in NODES,tt in TECHNOLOGIES) NODE_ANNUAL_TECH_GEN_CURT(YEARSH.size,nn,tt),12,4) + "\n";
forall (nn in NODES) do
DR_2050(nn) := sum(ff in FLEX_CLASSES) DR_CAP(YEARSH.size,nn,ff);
end-do
qsort(SYS_DOWN, DR_2050, DR_ORDER);
LOG_ENTRY += strfmt("2050 Country with highest DR capacity (GW): " + NODE_NAMES(DR_ORDER(1),1) ,15) + " " + DR_2050(DR_ORDER(1)) + "\n";
LOG_ENTRY += "-----------------------------------------------------------------------------\n";
write(LOG_ENTRY);
end-procedure
!***************************************************************************************************************************************************************