-
Notifications
You must be signed in to change notification settings - Fork 10
/
FESTIVhelper.m
1763 lines (1677 loc) · 83.9 KB
/
FESTIVhelper.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
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function FESTIVhelper
% Potential real time FESTIV execution interface
% create the figure
f=figure('Visible','off','name','FESTIV HELPER','NumberTitle','off','units','pixels','position',[50 50 800 300],'color','white');
% create the GUI components and properly locate them
uicontrol('Parent',f,'Style','pushbutton','String','ACE','units','normalized','Position', [.685 .58 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_ACE_callback});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Realized<br>Generation</center></html>','units','normalized','Position', [.685 .86 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_realizedgen_callback});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>DASCUC<br>Schedules</center></html>','units','normalized','Position', [.83 .86 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_dagen_callback});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>RTSCED<br>Schedules</center></html>','units','normalized','Position', [.685 .72 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_rtdgen_callback});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Generation<br>Vs. Load</center></html>','units','normalized','Position', [.83 .58 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_genvload_callback});
uicontrol('Parent',f,'Style','pushbutton','String','Energy Prices','units','normalized','Position', [.685 .44 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_dalmp_callback});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Instant VG<br>Penetration</center></html>','units','normalized','Position', [.83 .44 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_vg_penetration});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Comparison Across<br> Sched Processes</center></html>','units','normalized','Position',[.83 .72 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@Compare_Across_Schedule_Process_callback});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Compare ACE<br>Distributions</center></html>','units','normalized','Position',[.83 .30 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_aceDist});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Total Generation<br>By Gen Type</center></html>','units','normalized','Position',[.685 .30 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_gentotals});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>DA Load Vs<br>Actual Load</center></html>','units','normalized','Position',[.685 .16 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_daloadVactual});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Generation<br>Stack by Type</center></html>','units','normalized','Position',[.83 .16 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_genstack});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Number of<br>Committed Units</center></html>','units','normalized','Position',[.685 .02 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_statuses});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>VG Curtailment</center></html>','units','normalized','Position',[.83 .02 .13 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_vgcurtailment});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>RT Price<br>And ACE</center></html>','units','normalized','Position',[.55 .30 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_rtpriceNace});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Number Of<br>Start-Ups</center></html>','units','normalized','Position',[.415 .30 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_numsus});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Actual Vs<br>Capacity</center></html>','units','normalized','Position',[.275 .30 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_onlinecapacity});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Ramp<br>Utilization</center></html>','units','normalized','Position',[.55 .16 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_ramputilization});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Case<br>Summaries</center></html>','units','normalized','Position',[.415 .16 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@show_casesummaries});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Dispatch Vs<br>AGC Signal</center></html>','units','normalized','Position',[.275 .16 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_rtdVSagc});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Net Load</center></html>','units','normalized','Position',[.275 .02 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_netload});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>RT Reserve<br>Schedules</center></html>','units','normalized','Position',[.415 .44 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_reserves});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>RT Market<br>Infeasibilities</center></html>','units','normalized','Position',[.55 .02 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_lossload});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Unused Thermal<br>Capacity</center></html>','units','normalized','position',[.55 .44 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_unused});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Online Time<br>Per Unit</center></html>','units','normalized','position',[.415 .02 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@show_onlinetime});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>RT Reserve<br>Prices</center></html>','units','normalized','position',[.275 .44 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_reserve_prices});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>DA Reserve<br>Prices</center></html>','units','normalized','position',[.275 .58 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_da_reserve_prices});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>DA Reserve<br>Schedules</center></html>','units','normalized','position',[.415 .58 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_da_reserve});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Generator<br>Revenues</center></html>','units','normalized','position',[.55 .58 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_revenues});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Access<br>Variables</center></html>','units','normalized','position',[.55 .72 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@access_variables});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Line<br>Congestion</center></html>','units','normalized','position',[.415 .72 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@plot_congestion});
uicontrol('Parent',f,'Style','pushbutton','String','<html><center>Custom<br>Script</center></html>','units','normalized','position',[.275 .72 .12 .115],'fontunits','normalized','fontsize',0.30,'Callback',{@eval_custom});
listOfCases=uicontrol('Parent',f,'Style','listbox','Max',10,'units','normalized','Position',[0.02 0.20 .23 .76],'FontName','Courier','String','Cases','Max',10,'value',[],'callback',{@loadOnDoubleClick_callback});
uicontrol('Parent',f,'Style','pushbutton','String','Add Case','units','normalized','Position',[0.02 .10 .11 .07],'fontunits','normalized','fontsize',0.5,'Callback',{@addCase_callback});
uicontrol('Parent',f,'Style','pushbutton','String','Remove Case','units','normalized','Position',[.02 .02 .11 .07],'fontunits','normalized','fontsize',0.5,'Callback',{@removeCase_callback});
% outputsummary=uitable('Parent',f,'units','normalized','position',[.275 .44 .395 .525],'ColumnFormat',{'char','char'},'ColumnEditable',[false false],'ColumnWidth',{220 90},'ColumnName',[],'RowName',[]);
uicontrol('Parent',f,'Style','pushbutton','String','Move Up','units','normalized','Position',[0.14 .10 .11 .07],'fontunits','normalized','fontsize',0.5,'Callback',{@moveUp_callback});
uicontrol('Parent',f,'Style','pushbutton','String','Move Down','units','normalized','Position',[0.14 .02 .11 .07],'fontunits','normalized','fontsize',0.5,'Callback',{@moveDown_callback});
currentCase=uipanel('Parent',f,'Title','Current Case','units','normalized','position',[.275 .86 .395 .14],'backgroundcolor','white');
currentCaseName=uicontrol('Parent',currentCase,'style','text','units','normalized','position',[.01 .01 .99 .95],'string','- - -','backgroundcolor','white','fontunits','normalized','fontsize',0.5,'horizontalalignment','left');
movegui('center');
set(f,'Visible','on');
pause on;pause(0.1);pause off;
PathNames=cell(0,1);
row = 1;
assignin('base','PathNames',PathNames);
assignin('base','row',row);
listOfVars=[];
listOfCaseNames=[];
outputVariableName_edit=[];
addpath(strcat(pwd,filesep, 'MODEL_RULES'));
% plot ACE
function plot_ACE_callback(~,~)
x=evalin('base','ACE');
y=evalin('base','ACE_time_index');
z=evalin('base','CPS2_ACE_index');
w=evalin('base','raw_ACE_index');
name=evalin('base','outputname');
figure;plot(x(:,y),x(:,w:z));
titlename=sprintf('ACE levels: %s',name);
title(titlename);
legend('raw Ace','Continuous integrated ACE','CPS2 ACE');
xlabel('Time [hr]');
ylabel('Magnitude [MW]');
end
% plot realized generation
function plot_realizedgen_callback(~,~)
ACTUAL_GENERATION=evalin('base','ACTUAL_GENERATION');
ACTUAL_PUMP=evalin('base','ACTUAL_PUMP');
ngen=evalin('base','ngen');
nESR=evalin('base','nESR');
storage_to_gen_index=evalin('base','storage_to_gen_index');
GEN_VAL=evalin('base','GEN_VAL');
name=evalin('base','outputname');
temp=ACTUAL_GENERATION(:,2:ngen+1);
temp(:,storage_to_gen_index) = temp(:,storage_to_gen_index) - ACTUAL_PUMP(:,2:nESR+1);
figure;plot(ACTUAL_GENERATION(:,1),temp);
titlename=sprintf('Actual Generation: %s',name);
title(titlename)
hlegend=legend(GEN_VAL,'interpreter','none');
set(hlegend,'visible','off');
xlabel('Time [hr]');
ylabel('Output [MW]');
end
% plot DASCUC scheudles
function plot_dagen_callback(~,~)
DASCUCSCHEDULE=evalin('base','DASCUCSCHEDULE');
DASCUCPUMPSCHEDULE=evalin('base','DASCUCPUMPSCHEDULE');
ngen=evalin('base','ngen');
nESR=evalin('base','nESR');
GEN_VAL=evalin('base','GEN_VAL');
storage_to_gen_index=evalin('base','storage_to_gen_index');
name=evalin('base','outputname');
temp=DASCUCSCHEDULE(:,2:ngen+1);
temp(:,storage_to_gen_index) = temp(:,storage_to_gen_index) - DASCUCPUMPSCHEDULE(:,2:nESR+1);
figure;plot(DASCUCSCHEDULE(:,1),temp(:,1:ngen))
titlename=sprintf('Day-Ahead Schedules: %s',name);
title(titlename);
hlegend=legend(GEN_VAL,'interpreter','none');
set(hlegend,'visible','off');
xlabel('Time [hr]');
ylabel('Output [MW]');
end
% plot RTDCED scheudles
function plot_rtdgen_callback(~,~)
RTSCEDBINDINGSCHEDULE=evalin('base','RTSCEDBINDINGSCHEDULE');
RTSCEDBINDINGPUMPSCHEDULE=evalin('base','RTSCEDBINDINGPUMPSCHEDULE');
ngen=evalin('base','ngen');
nESR=evalin('base','nESR');
GEN_VAL=evalin('base','GEN_VAL');
storage_to_gen_index=evalin('base','storage_to_gen_index');
name=evalin('base','outputname');
temp=RTSCEDBINDINGSCHEDULE(:,2:ngen+1);
temp(:,storage_to_gen_index) = temp(:,storage_to_gen_index) - RTSCEDBINDINGPUMPSCHEDULE(:,2:nESR+1);
figure;plot(RTSCEDBINDINGSCHEDULE(:,1),temp);
titlename=sprintf('RTSCED Schedules: %s',name);
title(titlename)
hlegend=legend(GEN_VAL,'interpreter','none');
set(hlegend,'visible','off');
xlabel('Time [hr]');
ylabel('Output [MW]');
end
% plot DA prices
function plot_dalmp_callback(~,~)
w=evalin('base','BUS_VAL');
DASCUCLMP=evalin('base','DASCUCLMP');
lmpFigure=figure('visible','off','name','Locational Marginal Prices (LMPs)','NumberTitle','off','units','pixels','position',[50 50 750 500],'color',[.9412 .9412 .9412]);
movegui(lmpFigure,'center');
set(lmpFigure,'visible','on');
ha=axes('Units','normalized','Position',[0.37,0.10,0.60,0.82]);
plot(DASCUCLMP(:,1),DASCUCLMP(:,2:end));
network_button_group=uibuttongroup('parent',lmpFigure,'title','Select Model','units','normalized','position',[.025 .65 .26 .20],'fontunits','normalized','fontsize',0.15,'SelectionChangeFcn',{@changeLMPPlot});
uicontrol('parent',network_button_group,'style','radiobutton','units','normalized','position',[.07 .60 .90 .40],'string','Day Ahead SCUC','fontsize',10,'tag','plotDASCUClmp');
uicontrol('parent',network_button_group,'style','radiobutton','units','normalized','position',[.07 .10 .90 .40],'string','Real Time SCED','fontsize',10,'tag','plotRTSCEDlmp');
hlegend=legend(w,'interpreter','none');
set(hlegend,'visible','off')
xlabel(gca,'Time [hr]');
ylabel(gca,'LMP [$/MWh]');
name=evalin('base','outputname');
titlename=sprintf('Day-Ahead Prices: %s',name);
title(gca,titlename);
end
function changeLMPPlot(~,eventdata)
switch get(eventdata.NewValue,'tag');
case 'plotDASCUClmp'
DASCUCLMP=evalin('base','DASCUCLMP');
plot(DASCUCLMP(:,1),DASCUCLMP(:,2:end));
w=evalin('base','BUS_VAL');hlegend=legend(w,'interpreter','none');set(hlegend,'visible','off')
xlabel(gca,'Time [hr]');
ylabel(gca,'LMP [$/MWh]');
name=evalin('base','outputname');
titlename=sprintf('Day-Ahead Prices: %s',name);
title(gca,titlename);
case 'plotRTSCEDlmp'
RTSCEDBINDINGLMP=evalin('base','RTSCEDBINDINGLMP');
plot(RTSCEDBINDINGLMP(:,1),RTSCEDBINDINGLMP(:,2:end));
w=evalin('base','BUS_VAL');hlegend=legend(w,'interpreter','none');set(hlegend,'visible','off')
xlabel(gca,'Time [hr]');
ylabel(gca,'LMP [$/MWh]');
name=evalin('base','outputname');
titlename=sprintf('Real-Time Prices: %s',name);
title(gca,titlename);
end
end
% plot instantaneous VG penetration
function plot_vg_penetration(~,~)
GENVALUE_VAL=evalin('base','DEFAULT_DATA.GENVALUE.val');
GEN_VAL=evalin('base','GEN_VAL');
ACE=evalin('base','ACE');
ACTUAL_VG_FIELD=evalin('base','ACTUAL_VG_FIELD');
ACTUAL_VG_FULL=evalin('base','ACTUAL_VG_FULL');
ACTUAL_LOAD_FULL=evalin('base','ACTUAL_LOAD_FULL');
daystosimulate=evalin('base','daystosimulate');
gen_type=evalin('base','gen_type');
wind_gen_type_index=evalin('base','wind_gen_type_index');
PV_gen_type_index=evalin('base','PV_gen_type_index');
ACTUAL_GENERATION=evalin('base','ACTUAL_GENERATION');
gentypes=GENVALUE_VAL(:,gen_type);
windidx=gentypes==wind_gen_type_index;
solaridx=gentypes==PV_gen_type_index;
vgidx=windidx+solaridx;
vg_names=GEN_VAL(find(vgidx));
vgidx=find(vgidx);
actual_vg_idx=zeros(size(vg_names));
for i=1:size(actual_vg_idx,1)
actual_vg_idx(i)=find(strcmp(vg_names{i},ACTUAL_VG_FIELD));
end
total_vg_input=sum(ACTUAL_VG_FULL(:,actual_vg_idx),2);
total_vg_output=sum(ACTUAL_GENERATION(:,vgidx+1),2);
figure;plot(ACE(:,1),(total_vg_input./ACTUAL_LOAD_FULL(:,2)).*100,'blue');
% hold on
% plot(ACE(:,1),(total_vg_output./ACTUAL_LOAD_FULL(:,2)).*100,'red');
axis([0 daystosimulate*24 ylim]);
xlabel('Time [hr]');
ylabel('Penetration Level [%]');
name=evalin('base','outputname');
titlename=sprintf('Instantaneous VG Penetration: %s',name);
title(titlename);
end
% plot generation vs. load
function plot_genvload_callback(~,~)
ACTUAL_GENERATION=evalin('base','ACTUAL_GENERATION');
ACTUAL_PUMP=evalin('base','ACTUAL_PUMP');
ngen=evalin('base','ngen');
nESR=evalin('base','nESR');
storage_to_gen_index=evalin('base','storage_to_gen_index');
ACTUAL_LOAD_FULL=evalin('base','ACTUAL_LOAD_FULL');
AGC_interval_index=evalin('base','AGC_interval_index');
storelosses=evalin('base','storelosses');
name=evalin('base','outputname');
sumgen = sum(ACTUAL_GENERATION(:,2:ngen+1)')'-sum(ACTUAL_PUMP(:,2:nESR+1)')';
figure;plot(ACTUAL_GENERATION(:,1),sumgen);
hold('on')
line(ACTUAL_GENERATION(:,1),ACTUAL_LOAD_FULL(1:AGC_interval_index-1,2)+storelosses,'color','red');
titlename=sprintf('Generation and Load: %s',name);
legend('Total Generation','Total Load');
title(titlename);
xlabel('Time [hr]');
ylabel('Magnitude [MW]');
end
% plot da vg vs actual vg
function Compare_Across_Schedule_Process_callback(~,~)
sched_figure = figure('Visible','on','name','Schedule Comparison','NumberTitle','off','units','pixels','position',[500 500 600 150],'color','white');
uicontrol('parent',sched_figure,'style','text','string','Schedule Data Type','units','normalized','position',[.02 .43 .18 .2],'BackgroundColor',get(sched_figure,'color'));
Sched_Data_Type=uicontrol('parent',sched_figure','style','popupmenu','units','normalized','position',[.2 .45 .2 .2],'string','1 - VG |2 - Load|3 - Net Load|4 - Variable Capacity Resource|5 - Conventional Gen','backgroundcolor','white');
uicontrol('parent',sched_figure,'style','text','string','Schedule Process','units','normalized','position',[.45 .65 .2 .2],'BackgroundColor',get(sched_figure,'color'));
Sched_Process1=uicontrol('parent',sched_figure','style','popupmenu','units','normalized','position',[.7 .65 .2 .2],'string','1 - DASCUC |2 - RTSCUC|3 - RTSCED|4 - ACTUAL','backgroundcolor','white');
uicontrol('parent',sched_figure,'style','text','string','Compared With','units','normalized','position',[.45 .43 .2 .2],'BackgroundColor',get(sched_figure,'color'));
uicontrol('parent',sched_figure,'style','text','string','Schedule Process','units','normalized','position',[.45 .25 .2 .2],'BackgroundColor',get(sched_figure,'color'));
Sched_Process2=uicontrol('parent',sched_figure','style','popupmenu','units','normalized','position',[.7 .25 .2 .2],'string','1 - DASCUC |2 - RTSCUC|3 - RTSCED|4 - ACTUAL','backgroundcolor','white');
uicontrol('Parent',sched_figure,'Style','pushbutton','String','COMPARE','units','normalized','Position', [.35 .05 .15 .15],'Callback',{@sched_proc_comparison});
assignin('base','Sched_Data_Type',Sched_Data_Type);
assignin('base','Sched_Process1',Sched_Process1);
assignin('base','Sched_Process2',Sched_Process2);
end
function sched_proc_comparison(~,~)
Sched_Data_Type = evalin('base','Sched_Data_Type');
Sched_Process1 = evalin('base','Sched_Process1');
Sched_Process2 = evalin('base','Sched_Process2');
schd_proc_cmbn = [Sched_Data_Type.Value;Sched_Process1.Value;Sched_Process2.Value];
close(gcf);
for k=1:2
switch schd_proc_cmbn(1,1)
case 1
COMPARE_TITLE = 'Variable Generation Comparison (No Curtailments)';
GENVALUE_tmp = evalin('base','GENVALUE');
gen_type=evalin('base','gen_type');
wind_gen_type_index=evalin('base','wind_gen_type_index');
PV_gen_type_index=evalin('base','PV_gen_type_index');
nvg = evalin('base','nvg');
tmp_vg_idx = [find(GENVALUE_tmp.val(:,gen_type)==wind_gen_type_index);find(GENVALUE_tmp.val(:,gen_type)==PV_gen_type_index)];
Names = GENVALUE_tmp.uels{1,1};
tmp_vg_names=Names(tmp_vg_idx);
switch schd_proc_cmbn(k+1,1)
case 1
tmp=evalin('base','DAC_VG_FULL');
tmp_sched_names = evalin('base','DAC_VG_FIELD');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp(:,2) zeros(size(tmp,1),1)];
for z=1:nvg
w=3;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
SCHED_COMPARE.(sprintf('part_%d',k))(:,2)=SCHED_COMPARE.(sprintf('part_%d',k))(:,2) + tmp(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_NAME.(sprintf('part_%d',k))='DASCUC';
case 2
tmp=evalin('base','RTC_VG_FULL');
HRTC=evalin('base','HRTC');
tmp_sched_names = evalin('base','RTC_VG_FIELD');
tmp_new=[24.*tmp(:,2) zeros(size(tmp,1),1)];
for z=1:nvg
w=3;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
tmp_new(:,2)=tmp_new(:,2) + tmp(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp_new(1:HRTC:size(tmp_new,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCUC';
case 3
tmp=evalin('base','RTD_VG_FULL');
HRTD=evalin('base','HRTD');
tmp_sched_names = evalin('base','RTD_VG_FIELD');
tmp_new=[24.*tmp(:,2) zeros(size(tmp,1),1)];
for z=1:nvg
w=3;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
tmp_new(:,2)=tmp_new(:,2) + tmp(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp_new(1:HRTD:size(tmp_new,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCED';
case 4
tmp = evalin('base','ACTUAL_VG_FULL');
tmp_sched_names = evalin('base','ACTUAL_VG_FIELD');
tmp_new=[24.*tmp(:,1) zeros(size(tmp,1),1)];
for z=1:nvg
w=2;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
tmp_new(:,2)=tmp_new(:,2) + tmp(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_COMPARE.(sprintf('part_%d',k))=tmp_new;
SCHED_NAME.(sprintf('part_%d',k))='ACTUAL';
end;
case 2
COMPARE_TITLE = 'Load Comparison';
switch schd_proc_cmbn(k+1,1)
case 1
tmp=evalin('base','DAC_LOAD_FULL');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp(:,2) tmp(:,3)];
SCHED_NAME.(sprintf('part_%d',k))='DASCUC';
case 2
tmp=evalin('base','RTC_LOAD_FULL');
HRTC=evalin('base','HRTC');
tmp = [24.*tmp(:,2) tmp(:,3)];
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:HRTC:size(tmp,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCUC';
case 3
tmp=evalin('base','RTD_LOAD_FULL');
HRTD=evalin('base','HRTD');
tmp = [24.*tmp(:,2) tmp(:,3:end)];
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:HRTD:size(tmp,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCED';
case 4
tmp = evalin('base','ACTUAL_LOAD_FULL');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp(:,1) tmp(:,2)];
SCHED_NAME.(sprintf('part_%d',k))='ACTUAL';
end;
case 3
COMPARE_TITLE = 'Net Load Comparison (No curtailments)';
GENVALUE_tmp = evalin('base','GENVALUE');
gen_type=evalin('base','gen_type');
wind_gen_type_index=evalin('base','wind_gen_type_index');
PV_gen_type_index=evalin('base','PV_gen_type_index');
nvg = evalin('base','nvg');
tmp_vg_idx = [find(GENVALUE_tmp.val(:,gen_type)==wind_gen_type_index);find(GENVALUE_tmp.val(:,gen_type)==PV_gen_type_index)];
Names = GENVALUE_tmp.uels{1,1};
tmp_vg_names=Names(tmp_vg_idx);
switch schd_proc_cmbn(k+1,1)
case 1
tmp1=evalin('base','DAC_LOAD_FULL');
tmp2=evalin('base','DAC_VG_FULL');
tmp_sched_names = evalin('base','DAC_VG_FIELD');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp1(:,2) tmp1(:,3)];
for z=1:nvg
w=3;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
SCHED_COMPARE.(sprintf('part_%d',k))(:,2)=SCHED_COMPARE.(sprintf('part_%d',k))(:,2) - tmp2(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_NAME.(sprintf('part_%d',k))='DASCUC';
case 2
tmp1=evalin('base','RTC_LOAD_FULL');
tmp2=evalin('base','RTC_VG_FULL');
tmp_sched_names = evalin('base','RTC_VG_FIELD');
HRTC=evalin('base','HRTC');
tmp = [24.*tmp1(:,2) tmp1(:,3)];
for z=1:nvg
w=3;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
tmp(:,2)=tmp(:,2) - tmp2(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:HRTC:size(tmp,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCUC';
case 3
tmp1=evalin('base','RTD_LOAD_FULL');
tmp2=evalin('base','RTD_VG_FULL');
HRTD=evalin('base','HRTD');
tmp_sched_names = evalin('base','RTD_VG_FIELD');
tmp = [24.*tmp1(:,2) tmp1(:,3)];
for z=1:nvg
w=3;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
tmp(:,2)=tmp(:,2) - tmp2(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:HRTD:size(tmp,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCED';
case 4
tmp1 = evalin('base','ACTUAL_LOAD_FULL');
tmp2 = evalin('base','ACTUAL_VG_FULL');
tmp_sched_names = evalin('base','ACTUAL_VG_FIELD');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp1(:,1) tmp1(:,2)];
for z=1:nvg
w=2;
while w<=size(tmp_sched_names,2)
if strcmp(tmp_vg_names(z),tmp_sched_names(w))
SCHED_COMPARE.(sprintf('part_%d',k))(:,2)=SCHED_COMPARE.(sprintf('part_%d',k))(:,2) - tmp2(:,w);
w=size(tmp_sched_names,2);
end;
w=w+1;
end;
end;
SCHED_NAME.(sprintf('part_%d',k))='ACTUAL';
end;
case 4
COMPARE_TITLE = 'Variable Capacity Resource Comparison (No Curtailments)';
switch schd_proc_cmbn(k+1,1)
case 1
tmp=evalin('base','DAC_VG_FULL');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp(:,2) sum(tmp(:,3:end)')'];
SCHED_NAME.(sprintf('part_%d',k))='DASCUC';
case 2
tmp=evalin('base','RTC_VG_FULL');
HRTC=evalin('base','HRTC');
tmp = [24.*tmp(:,2) sum(tmp(:,3:end)')'];
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:HRTC:size(tmp,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCUC';
case 3
tmp=evalin('base','RTD_VG_FULL');
HRTD=evalin('base','HRTD');
tmp = [24.*tmp(:,2) sum(tmp(:,3:end)')'];
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:HRTD:size(tmp,1),:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCED';
case 4
tmp = evalin('base','ACTUAL_VG_FULL');
SCHED_COMPARE.(sprintf('part_%d',k))=[24.*tmp(:,1) sum(tmp(:,2:end)')'];
SCHED_NAME.(sprintf('part_%d',k))='ACTUAL';
end;
case 5
COMPARE_TITLE = 'Conventional Gen Comparison';
GENVALUE_tmp = evalin('base','GENVALUE');
gen_type=evalin('base','gen_type');
tmp_convgen_idx = [find(GENVALUE_tmp.val(:,gen_type)==1);find(GENVALUE_tmp.val(:,gen_type)==2);find(GENVALUE_tmp.val(:,gen_type)==3);find(GENVALUE_tmp.val(:,gen_type)==4);find(GENVALUE_tmp.val(:,gen_type)==5)];
switch schd_proc_cmbn(k+1,1)
case 1
tmp=evalin('base','DASCUCSCHEDULE');
SCHED_COMPARE.(sprintf('part_%d',k))=[tmp(:,1) sum(tmp(:,tmp_convgen_idx+1),2)];
SCHED_NAME.(sprintf('part_%d',k))='DASCUC';
case 2
tmp=evalin('base','RTSCUCBINDINGSCHEDULE');
RTSCUC_binding_interval_index=evalin('base','RTSCUC_binding_interval_index');
tmp = [tmp(:,1) sum(tmp(:,tmp_convgen_idx+1),2)];
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:RTSCUC_binding_interval_index-1,:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCUC';
case 3
tmp=evalin('base','RTSCEDBINDINGSCHEDULE');
RTSCED_binding_interval_index=evalin('base','RTSCED_binding_interval_index');
tmp = [tmp(:,1) sum(tmp(:,tmp_convgen_idx+1),2)];
SCHED_COMPARE.(sprintf('part_%d',k)) = tmp(1:RTSCED_binding_interval_index-1,:);
SCHED_NAME.(sprintf('part_%d',k))='RTSCED';
case 4
tmp = evalin('base','ACTUAL_GENERATION');
AGC_interval_index=evalin('base','AGC_interval_index');
tmp=[tmp(:,1) sum(tmp(:,tmp_convgen_idx+1),2)];
SCHED_COMPARE.(sprintf('part_%d',k))=tmp(1:AGC_interval_index-1,:);
SCHED_NAME.(sprintf('part_%d',k))='ACTUAL';
end;
end;
end;
figure;
title(COMPARE_TITLE);
line(SCHED_COMPARE.part_1(:,1),SCHED_COMPARE.part_1(:,2),'color','k');
xlabel('Time [hr]');
ylabel('Power [MW]');
ax1=gca;
set(ax1,'xcolor','k','ycolor','k')
ax2=axes('Position',get(ax1,'Position'),'xaxislocation','top','yaxislocation','right','color','none','xcolor','r','ycolor','r','visible','off');
line(SCHED_COMPARE.part_2(:,1).*24,SCHED_COMPARE.part_2(:,2),'color','r','parent',ax2);
linkaxes([ax1 ax2],'xy');
text(0.3,0.95,SCHED_NAME.part_1,'units','normalized','color','k');
text(0.80,0.95,SCHED_NAME.part_2,'units','normalized','color','r');
end
% plot ace vs percentage of time
function plot_aceDist(~,~)
caseValues=get(listOfCases, 'Value');
caseNames=get(listOfCases, 'String');
selectedNames=caseNames(caseValues);
colors={'blue';'red';'black';'green';'magenta';'cyan'};
for i=1:size(selectedNames,1)
x.(sprintf('case%d',i))=eval(sprintf('load(PathNames{caseValues(%d)},''ACE'');',i));
x.(sprintf('L10_%d',i))=eval(sprintf('load(PathNames{caseValues(%d)},''L10'');',i));
end
for i=1:size(selectedNames,1)
x.(sprintf('data%d',i))=x.(sprintf('case%d',i)).ACE(:,2);
end
maxACE=zeros(size(selectedNames,1),1);
minACE=zeros(size(selectedNames,1),1);
for i=1:size(selectedNames,1)
maxACE(i)=max(x.(sprintf('data%d',i)));
minACE(i)=min(x.(sprintf('data%d',i)));
end
ACEmax=ceil(max(maxACE)/100)*100;
ACEmin=floor(min(minACE)/100)*100;
for i=1:size(selectedNames,1)
[temp1,temp2]=hist(x.(sprintf('data%d',i)),(ACEmin:(ACEmax+abs(ACEmin))/((ACEmax+abs(ACEmin))*2):ACEmax));
x.(sprintf('a%d',i))=temp1;
x.(sprintf('b%d',i))=temp2;
end
for i=1:size(selectedNames,1)
x.(sprintf('a%d',i))=x.(sprintf('a%d',i))/sum(x.(sprintf('a%d',i)));
end
for i=1:size(selectedNames,1)
z=x.(sprintf('L10_%d',i));
x.(sprintf('X1_%d',i))=[z.L10 z.L10];
x.(sprintf('X2_%d',i))=-[z.L10 z.L10];
end
figure;
for i=1:size(selectedNames,1)
coloridx=mod(i,size(colors,1));
if coloridx==0;coloridx=size(colors,1);end;
plot(x.(sprintf('b%d',i)),x.(sprintf('a%d',i)),colors{coloridx});
hold on;
end
legend(selectedNames,'interpreter','none');
Y=get(gca,'ylim');
hold on
for i=1:size(selectedNames,1)
plot(x.(sprintf('X1_%d',i)),Y,'red');
plot(x.(sprintf('X2_%d',i)),Y,'red');
text(-x.(sprintf('X1_%d',i))(1)+1,0.75*Y(2),'- L10','verticalalignment','top','horizontalalignment','left','color','red')
text(x.(sprintf('X1_%d',i))(1)-1,0.75*Y(2),' L10','verticalalignment','top','horizontalalignment','right','color','red')
hold on;
end
xlabel('ACE [MW]');
ylabel('Percentage of Intervals');
title('Comparison of ACE Distributions');
axis([-x.(sprintf('X1_%d',i))(1)*1.75 x.(sprintf('X1_%d',i))(1)*1.75 ylim]);
end
% plot total generation by gen type
function plot_gentotals(~,~)
b1=evalin('base','(sum(ACTUAL_GENERATION(:,2:end)).*t_AGC./60./60)'';');
c1=evalin('base','GENVALUE.val(:,8);');
name=evalin('base','outputname');
temptotal=[];
x=unique(c1);
for i=1:size(x,1)
tempsum=0;
for j=1:size(b1,1)
if c1(j) == x(i)
tempsum=tempsum+b1(j);
end
end
temptotal=[temptotal;tempsum,x(i)];
end
figure;bar(temptotal(:,2),temptotal(:,1));
text(temptotal(:,2),temptotal(:,1),num2str(temptotal(:,1),'%0.f'),'HorizontalAlignment','center','VerticalAlignment','bottom');
xlabel('Gen Type');
ylabel('Output [MWh]');
titlename=sprintf('Cumulative Generator Outputs by Type: %s',name);
title(titlename);
end
% plot da load vs actual load
function plot_daloadVactual(~,~)
x=evalin('base','ACTUAL_GENERATION');
y=evalin('base','ACTUAL_LOAD_FULL');
z1=evalin('base','DASCUCSCHEDULE');
z2=evalin('base','DAC_LOAD_FULL');
name=evalin('base','outputname');
figure;plot(x(:,1),y(:,2));
hold on
plot(z1(:,1),z2(1:size(z1,1),3),'red');
legend('Actual','DA');
xlabel('Time [hr]');
ylabel('Load [MW]');
titlename=sprintf('DA Load Vs Actual Load: %s',name);
title(titlename);
end
% plot generation stack
function plot_genstack(~,~)
GENVALUE_VAL=evalin('base','DEFAULT_DATA.GENVALUE.val');
gen_type=evalin('base','gen_type');
ACTUAL_GENERATION=evalin('base','ACTUAL_GENERATION');
t_AGC=evalin('base','t_AGC');
RTD_LOAD_FULL=evalin('base','RTD_LOAD_FULL');
IRTD=evalin('base','IRTD');
total=zeros(size(ACTUAL_GENERATION,1),16);
for t=1:16
temp=[];temp2=[];
for i=1:size(GENVALUE_VAL,1)
if GENVALUE_VAL(i,gen_type) == t
temp = [temp,ACTUAL_GENERATION(:,i+1)];
end
end
temp2=sum(temp,2);
if isempty(temp2)
else
total(:,t)=temp2;
end
end
temp=[total(1,:); total((1:size(ACTUAL_GENERATION,1)/(60/t_AGC*IRTD))*(60/t_AGC*IRTD),:)];
temp2=[temp(:,5),temp(:,1),temp(:,3),temp(:,2),temp(:,4),temp(:,6:end)];
xval=unique(RTD_LOAD_FULL(:,1))*24;
figure;handles=area(xval,temp2);
set(handles(2),'facecolor','blue')
set(handles(4),'facecolor','red')
set(handles(7),'facecolor','green')
set(handles(10),'facecolor','yellow')
set(handles(3),'facecolor',[0.5 0 1])
set(handles(5),'facecolor',[43/255 159/255 1])
set(handles(1),'facecolor','black')
set(handles(6),'facecolor',[0.5 0.5 0.5])
set(handles(8),'facecolor',[1 109/255 23/255])
set(handles(9),'facecolor',[1 109/255 23/255])
set(handles(11),'facecolor',[1 109/255 23/255])
set(handles(12),'facecolor',[0.5 0.5 0.5])
set(handles(13),'facecolor',[1 0 1])
set(handles(14),'facecolor',[1 0 1])
set(handles(15),'facecolor',[1 0 1])
set(handles(16),'facecolor',[0 1 1])
hlegend=legend('Nuclear','Steam','CC','CT','Hydro','Pumped Storage','Wind','CAES','LESR','PV','CSP','Var Pump PSH','Virtual','Intertie','Outage','NVCR');
set(hlegend,'orientation','horizontal','location','north','edgecolor',[1 1 1]);
name=evalin('base','outputname');
titlename=sprintf('Generation Stack by Generator Type: %s',name);
title(titlename);
xlabel('Time [hr]');
ylabel('Output [MW]');
end
% plot number of units committed per RTC interval
function plot_statuses(~,~)
Z=evalin('base','daystosimulate');
X=evalin('base','RTSCUCBINDINGCOMMITMENT(:,1)');
W=evalin('base','IRTC');
GENVALUE=evalin('base','GENVALUE');
y=evalin('base','STATUS');
for gt=1:16
masterind.(sprintf('indicies%d',gt))=find(GENVALUE.val(:,8)==gt);
end
Y1=zeros(size(y,1),1);Y2=Y1;Y3=Y1;Y4=Y1;Y5=Y1;Y6=Y1;Y7=Y1;Y8=Y1;Y9=Y1;Y10=Y1;Y11=Y1;Y12=Y1;Y13=Y1;Y14=Y1;Y15=Y1;Y16=Y1;
for gt=1:16
for i=1:size(y,1)
sum2 = 0;
for k=1:size(masterind.(sprintf('indicies%d',gt)),1)
sum2=sum2+y(i,1+masterind.(sprintf('indicies%d',gt))(k,1));
end
eval(sprintf('Y%d(i)=sum2;',gt));
end
end
for gt=1:16
eval(sprintf('Y%d=Y%d(1:60*24*Z/W+1,1);',gt,gt));
end
temp=[Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11,Y12,Y13,Y14,Y15,Y16];
X=X(1:60*24*Z/W+1,1);
figure;plot(X,Y1,X,Y2,X,Y3,X,Y4,X,Y5,X,Y6,X,Y7,X,Y8,X,Y9,X,Y10,X,Y11,X,Y12,X,Y13,X,Y14,X,Y15,X,Y16);
axis([0 max(max(X,1)) 0 max(max(max(temp,1)))+1]);
name=evalin('base','outputname');
titlename=sprintf('Number of Units Committed: %s',name);
title(titlename);
xlabel('Time [hr]');
ylabel('Number of Units');
legend('STEAM','CT','CC','HYDRO','NUCLEAR','PSH','WIND','CAES','LESR','PV','CSP','VAR PSH','VIRTUAL','TIE','OUTAGE','VCG');
text(0.65,0.92,sprintf('Average = %0.1f Units online',sum(Y1+Y2+Y3+Y4+Y5+Y6+Y7+Y8+Y9+Y10+Y11+Y12+Y13+Y14+Y15+Y16)/size(X,1)),'units','normalized')
end
% plot VG curtailment
function plot_vgcurtailment(~,~)
x=evalin('base','ACTUAL_GENERATION');
y=evalin('base','ACTUAL_VG_FULL');
z=evalin('base','GENVALUE');
w=evalin('base','t_AGC');
q=evalin('base','ACTUAL_VG_FIELD');
gen_type=evalin('base','gen_type');
wind_gen_type_index=evalin('base','wind_gen_type_index');
PV_gen_type_index=evalin('base','PV_gen_type_index');
types=z.val(:,gen_type);indices=[];names=[];
for i=1:size(types,1)
if types(i) == wind_gen_type_index || types(i) == PV_gen_type_index
indices=[indices;i];
names=[names;z.uels{1,1}(1,i)];
end
end
vgtemp=[];actualtemp=[];
for i=1:size(indices,1)
for vg=1:size(q,2)
if strcmp(names{i},q{vg})
index=vg;
end
end
actualtemp=[actualtemp y(:,index)];
vgtemp=[vgtemp x(:,indices(i)+1)];
end
vgcurtailment=max(zeros(size(y,1),size(indices,1)),actualtemp-vgtemp);
figure;plot(x(:,1),vgcurtailment);
assignin('base','actual_vg_curtailment',vgcurtailment);
hlegend=legend(names);
set(hlegend,'visible','off');
xlabel('Time [hr]');
ylabel('Curtailment [MW]');
name=evalin('base','outputname');
titlename=sprintf('VG Curtailment: %s',name);
title(titlename);
text(0.65,0.92,sprintf('Total = %d MWh',round(sum(sum(vgcurtailment))*w/60/60)),'units','normalized')
end
% plot RT Price and ACE in one figure
function plot_rtpriceNace(~,~)
figure;
daystosimulate=evalin('base','daystosimulate');
h1=subplot(2,1,1);
x=evalin('base','RTSCEDBINDINGLMP');
y=evalin('base','nbus');
w=evalin('base','BUS.uels');
name=evalin('base','outputname');
plot(x(:,1),x(:,2:y+1));
titlename=sprintf('Real-Time Prices: %s',name);
title(titlename);
hlegend=legend(w','interpreter','none');
set(hlegend,'visible','off');
axis([0 24*daystosimulate ylim]);
ylabel('LMP [$/MWh]');
xlabel('Time [hr]');
h2=subplot(2,1,2);
x=evalin('base','ACE');
y=evalin('base','ACE_time_index');
w=evalin('base','raw_ACE_index');
name=evalin('base','outputname');
plot(x(:,y),x(:,w));
titlename=sprintf('ACE levels: %s',name);
title(titlename);
xlabel('Time [hr]');
ylabel('ACE [MW]');
axis([0 24*daystosimulate ylim]);
linkaxes([h1 h2],'x');
end
% plot the number of unit startups by gen type
function plot_numsus(~,~)
ACTUAL_GENERATION=evalin('base','RTSCEDBINDINGSCHEDULE');
ngen=evalin('base','ngen');
su=zeros(size(ACTUAL_GENERATION,1),ngen);
GENVALUE=evalin('base','GENVALUE');
for i=2:size(ACTUAL_GENERATION,1)
for j=1:ngen
if ACTUAL_GENERATION(i,j+1) > 0 && ACTUAL_GENERATION(i-1,j+1) == 0
su(i,j)=1;
end
end
end
ind1=GENVALUE.val(:,8)==1;
ind2=GENVALUE.val(:,8)==2;
ind3=GENVALUE.val(:,8)==3;
ind4=GENVALUE.val(:,8)==4;
ind5=GENVALUE.val(:,8)==5;
ind6=GENVALUE.val(:,8)==6;
ind7=GENVALUE.val(:,8)==7;
ind8=GENVALUE.val(:,8)==8;
ind9=GENVALUE.val(:,8)==9;
ind10=GENVALUE.val(:,8)==10;
ind11=GENVALUE.val(:,8)==11;
ind12=GENVALUE.val(:,8)==12;
ind13=GENVALUE.val(:,8)==13;
ind14=GENVALUE.val(:,8)==14;
ind15=GENVALUE.val(:,8)==15;
ind16=GENVALUE.val(:,8)==16;
SU1=su.*repmat(ind1',size(ACTUAL_GENERATION,1),1);
SU2=su.*repmat(ind2',size(ACTUAL_GENERATION,1),1);
SU3=su.*repmat(ind3',size(ACTUAL_GENERATION,1),1);
SU4=su.*repmat(ind4',size(ACTUAL_GENERATION,1),1);
SU5=su.*repmat(ind5',size(ACTUAL_GENERATION,1),1);
SU6=su.*repmat(ind6',size(ACTUAL_GENERATION,1),1);
SU7=su.*repmat(ind7',size(ACTUAL_GENERATION,1),1);
SU8=su.*repmat(ind8',size(ACTUAL_GENERATION,1),1);
SU9=su.*repmat(ind9',size(ACTUAL_GENERATION,1),1);
SU10=su.*repmat(ind10',size(ACTUAL_GENERATION,1),1);
SU11=su.*repmat(ind11',size(ACTUAL_GENERATION,1),1);
SU12=su.*repmat(ind12',size(ACTUAL_GENERATION,1),1);
SU13=su.*repmat(ind13',size(ACTUAL_GENERATION,1),1);
SU14=su.*repmat(ind14',size(ACTUAL_GENERATION,1),1);
SU15=su.*repmat(ind15',size(ACTUAL_GENERATION,1),1);
SU16=su.*repmat(ind16',size(ACTUAL_GENERATION,1),1);
SU1_2=sum(SU1,2);
SU2_2=sum(SU2,2);
SU3_2=sum(SU3,2);
SU4_2=sum(SU4,2);
SU5_2=sum(SU5,2);
SU6_2=sum(SU6,2);
SU7_2=sum(SU7,2);
SU8_2=sum(SU8,2);
SU9_2=sum(SU9,2);
SU10_2=sum(SU10,2);
SU11_2=sum(SU11,2);
SU12_2=sum(SU12,2);
SU13_2=sum(SU13,2);
SU14_2=sum(SU14,2);
SU15_2=sum(SU15,2);
SU16_2=sum(SU16,2);
X=ACTUAL_GENERATION(:,1);
figure;plot(X,SU1_2,X,SU2_2,X,SU3_2,X,SU4_2,X,SU5_2,X,SU6_2,X,SU7_2,X,SU8_2,X,SU9_2,X,SU10_2,X,SU11_2,X,SU12_2,X,SU13_2,X,SU14_2,X,SU15_2,X,SU16_2);
name=evalin('base','outputname');
titlename=sprintf('Number of Start Ups: %s',name);
title(titlename);
xlabel('Time [hr]');
ylabel('Number of Start Ups');
legend('STEAM','CT','CC','HYDRO','NUCLEAR','PSH','WIND','CAES','LESR','PV','CSP','VAR PSH','VIRTUAL','TIE','OUTAGE','VCG');
GENS={'STEAM';'CT';'CC';'HYDRO';'NUCLEAR';'PSH';'WIND';'CAES';'LESR';'PV';'CSP';'VAR PSH';'VIRTUAL';'TIE';'OUTAGE';'VCG'};
totals=[sum(SU1_2),sum(SU2_2),sum(SU3_2),sum(SU4_2),sum(SU5_2),sum(SU6_2),sum(SU7_2),sum(SU8_2),sum(SU9_2),sum(SU10_2),sum(SU11_2),sum(SU12_2),sum(SU13_2),sum(SU14_2),sum(SU15_2),sum(SU16_2)];
dispcount=1;
for i=1:16
if totals(1,i) ~= 0
text(0.05,0.92-((dispcount-1)*0.04),sprintf('%s SUs = %d',cell2mat(GENS(i,1)),totals(1,i)),'units','normalized');
dispcount=dispcount+1;
end
end
end
% plot ramp utilization
function plot_ramputilization(~,~)
RTSCEDBINDINGSCHEDULE=evalin('base','RTSCEDBINDINGSCHEDULE');
GENVALUE=evalin('base','GENVALUE');
RTDRAMP=zeros(size(RTSCEDBINDINGSCHEDULE));
RTDRAMPCAP=zeros(size(RTSCEDBINDINGSCHEDULE));
TEMP=repmat(GENVALUE.val(:,8)',size(RTSCEDBINDINGSCHEDULE,1),1);
RTDGENTYPES=[zeros(size(RTSCEDBINDINGSCHEDULE,1),1),TEMP];
for t=1:size(RTSCEDBINDINGSCHEDULE,1)-1
for i=1:size(RTSCEDBINDINGSCHEDULE,2)-1
if RTSCEDBINDINGSCHEDULE(t,i+1) >= GENVALUE.val(i,7) && abs(RTSCEDBINDINGSCHEDULE(t+1,i+1)) >= GENVALUE.val(i,7)
RTDRAMP(t,i+1)=abs(RTSCEDBINDINGSCHEDULE(t+1,i+1)-RTSCEDBINDINGSCHEDULE(t,i+1));
if RTSCEDBINDINGSCHEDULE(t+1,i+1)-RTSCEDBINDINGSCHEDULE(t,i+1) > 0
RTDRAMPCAP(t,i+1)=min(GENVALUE.val(i,6)*5,GENVALUE.val(i,1)-RTSCEDBINDINGSCHEDULE(t,i+1));
elseif RTSCEDBINDINGSCHEDULE(t+1,i+1)-RTSCEDBINDINGSCHEDULE(t,i+1) < 0
RTDRAMPCAP(t,i+1)=min(GENVALUE.val(i,6)*5,RTSCEDBINDINGSCHEDULE(t,i+1)-GENVALUE.val(i,7));
else
RTDRAMPCAP(t,i+1)=min(GENVALUE.val(i,6)*5,min(RTSCEDBINDINGSCHEDULE(t,i+1)+GENVALUE.val(i,7),GENVALUE.val(i,1)-RTSCEDBINDINGSCHEDULE(t,i+1)));
end
end
end
end
RTDRAMP(:,1)=RTSCEDBINDINGSCHEDULE(:,1);
RTDONLINE=double(RTDRAMPCAP>0);
ind1=0;ind2=0;ind3=0;ind4=0;ind4=0;ind5=0;ind6=0;ind7=0;ind8=0;ind9=0;ind10=0;ind11=0;ind12=0;ind13=0;ind14=0;ind15=0;ind16=0;
for gt=1:16
eval(sprintf('ind%d=find(GENVALUE.val(:,8)==%d);',gt,gt));
end
sum_1=zeros(size(RTSCEDBINDINGSCHEDULE,1),16);
sum_2=zeros(size(RTSCEDBINDINGSCHEDULE,1),16);
for gt=1:16
eval(sprintf('sum_1(:,%d)=sum(RTDRAMP(:,ind%d+1),2);',gt,gt));
eval(sprintf('sum_2(:,%d)=sum(RTDRAMPCAP(:,ind%d+1),2);',gt,gt));
end
X=RTSCEDBINDINGSCHEDULE(:,1);
figure;
% plot(X,sum_1(:,1),X,sum_1(:,2),X,sum_1(:,3),X,sum_1(:,4),X,sum_1(:,5),X,sum_1(:,6),X,sum_2(:,1),X,sum_2(:,2),X,sum_2(:,3),X,sum_2(:,4),X,sum_2(:,5),X,sum_2(:,6));
% legend('STEAM RAMP','CT RAMP','CC RAMP','HYDRO RAMP','NUCLEAR RAMP','PSH RAMP','STEAM RAMP CAP','CT RAMP CAP','CC RAMP CAP','HYDRO RAMP CAP','NUCLEAR RAMP CAP','PSH RAMP CAP');
% plot(X,sum(sum_1(:,1:5),2),X,sum(sum_2(:,1:5),2))
plot(X,sum(sum_2(:,1:5),2)-sum(sum_1(:,1:5),2))
% legend('Thermal Ramp','Thermal Ramp Cap');
ytemp=ylim;
axis([0 (size(RTSCEDBINDINGSCHEDULE,1)-1)/(60/round((RTSCEDBINDINGSCHEDULE(2,1)-RTSCEDBINDINGSCHEDULE(1,1))*60)) ytemp]);
assignin('base','RampUtil',sum(sum_1(:,1:5),2));
assignin('base','RampCap',sum(sum_2(:,1:5),2));
xlabel('Time [hr]');
ylabel('Ramp [MW/5 min]');
name=evalin('base','outputname');
titlename=sprintf('Unused Thermal Ramping Capacity: %s',name);
title(titlename);
end
% plot the actual output vs online capacity by gen type
function plot_onlinecapacity(~,~)
wb=waitbar(0,'Calculating...');
ACTUAL_GENERATION=evalin('base','ACTUAL_GENERATION');
size_AG=size(ACTUAL_GENERATION,1);
ngen=evalin('base','ngen');
GENVALUE_VAL=evalin('base','GENVALUE_VAL');
ramp_rate=evalin('base','ramp_rate');
gen_type=evalin('base','gen_type');
wind_gen_type_index=evalin('base','wind_gen_type_index');
PV_gen_type_index=evalin('base','PV_gen_type_index');
outage_gen_type_index=evalin('base','outage_gen_type_index');
min_gen=evalin('base','min_gen');
su_time=evalin('base','su_time');
sd_time=evalin('base','sd_time');
capacity=evalin('base','capacity');
data=zeros(size(ACTUAL_GENERATION));
data(:,1)=ACTUAL_GENERATION(:,1);
for gen=1:ngen
if GENVALUE_VAL.val(gen,gen_type) ~= wind_gen_type_index && GENVALUE_VAL.val(gen,gen_type) ~= PV_gen_type_index && GENVALUE_VAL.val(gen,gen_type) ~= outage_gen_type_index
sus=zeros(151200,1);sds=zeros(151200,1);
for i=1:size_AG-1
if round(ACTUAL_GENERATION(i,gen+1)/.0001)*.0001 == round((GENVALUE_VAL.val(gen,min_gen)-(GENVALUE_VAL.val(gen,min_gen)/GENVALUE_VAL.val(gen,su_time)/3600*4))/.0001)*.0001 && round(ACTUAL_GENERATION(i+1,gen+1)/.0001)*.0001 > round(ACTUAL_GENERATION(i,gen+1)/.0001)*.0001
sus(i,1)=1;
end
if round(ACTUAL_GENERATION(i,gen+1)/.0001)*.0001 == round((GENVALUE_VAL.val(gen,min_gen)-(GENVALUE_VAL.val(gen,min_gen)/GENVALUE_VAL.val(gen,sd_time)/3600*4))/.0001)*.0001 && round(ACTUAL_GENERATION(i+1,gen+1)/.0001)*.0001 < round(ACTUAL_GENERATION(i,gen+1)/.0001)*.0001
sds(i,1)=1;
end
end
temp2=sus+sds;
ind=find(temp2);
whats=ones(size(ind,1),1);
temp3=find(sus);
for i=1:size(ind,1)
for j=1:size(temp3,1)
if temp3(j,1) == ind(i,1)
whats(i,1)=2; % startups = 2
end
end
end
onint=[];
for i=1:size(ind,1)-1
if whats(1,1)==1 && i == 1
onint=[onint;1 ind(1,1)]; % unit starting off 'on'
end
if whats(i,1)-whats(i+1,1)==1
onint=[onint;ind(i) ind(i+1,1)-ind(i,1)];
end
if whats(size(ind,1),1)==2 && i == size(ind,1)-1
onint=[onint;ind(size(ind,1),1) 151200-ind(size(ind,1),1)];
end
end
onoffints=[];
for i=1:size(onint,1)
if onint(i,1)==1
onoffints(i,1:3)=[onint(i,1) 1 onint(i,2)];
else
onoffints(i,1:3)=[onint(i,1) round(onint(i,2)/2) round(onint(i,2)/2)];
end
end
if size(whats,1)==1 && whats(1,1) == 2
onint=[ind(1,1) size_AG-ind(1,1) 0];
onoffints=[ind(1,1) size_AG-ind(1,1)+1 0];
end
data(:,gen+1)=ACTUAL_GENERATION(:,gen+1);
for k=1:size(onoffints,1)
for o1=1:onoffints(k,2)
data(onoffints(k,1)+o1-1,gen+1)=min(GENVALUE_VAL.val(gen,capacity),data(onoffints(k,1),gen+1)+(GENVALUE_VAL.val(gen,ramp_rate)/60*4)*o1);
end
for o2=1:onoffints(k,3)
data(onoffints(k,1)+onoffints(k,2)+o2-1,gen+1)=max(GENVALUE_VAL.val(gen,min_gen),min(GENVALUE_VAL.val(gen,capacity),(data(onoffints(k,1),gen+1)+(GENVALUE_VAL.val(gen,ramp_rate)/60*4)*o1)-(GENVALUE_VAL.val(gen,ramp_rate)/60*4)*o2));
end
end
onlinecheck=data(:,gen+1)>=GENVALUE_VAL.val(gen,min_gen);
if sum(onlinecheck) == size_AG
data(:,gen+1)=GENVALUE_VAL.val(gen,capacity);
end
end
waitbar(gen/ngen,wb);
end
close(wb);