-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.m
101 lines (75 loc) · 2.89 KB
/
main.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
%% Main file
% Description of the main file
%
%
%% Parameter settings
clear;
clc;
close all;
savefig = false; % Save figure or not
savedata = true; % Save PF and OPF results
verbose = false; % Verbose printing or not
runloop = false; % Loop through the whole year or not
addrenew = false; % Add additional renewable or not
usemat = false; % Read mat files
%% Data preparation
% Specify a year, and download and format the data in that year. Downlaoded
% data are stored in the "Prep" directory. Formatted data are stored in the
% "Data" directory.
% Data sources include:
% 1. NYISO: (1) hourly fuel mix
% (2) hourly interface flow
% (3) hourly real time price
% 2. RGGI: (1) hourly generation for thermal generators larger than 25 MW
% 3. NRC: (1) Daily nuclear capacity factor
% 4. EIA: (1) Monthly hydro generation data for Niagara and St. Lawrence
testyear = 2019;
writeFuelmix(testyear);
writeHydroGen(testyear);
writeNuclearGen(testyear);
writePrice(testyear);
writeInterflow(testyear);
writeFuelPrice(testyear);
writeGenParam(testyear);
%% Modify MPC
% Read original NPCC 140 MATPOWER case and make modifications.
mpc = modifyMPC();
%% Test case
% Specify a timestamp with year, month, day and hour, update operation
% condition for that timestamp, and then run power flow (PF) and optimal
% power flow (OPF). Produce figures for comparing simulation results with
% historical data, including interface flow, fuel mix and locational
% marginal price (LMP).
testyear = 2019;
testmonth = 1;
testday = 1;
testhour = 1;
timeStamp = datetime(testyear,testmonth,testday,testhour,0,0,"Format","MM/dd/uuuu HH:mm:ss");
%% Operation condition update
mpcreduced = updateOpCond(mpc,timeStamp,savedata,verbose,usemat);
% PF test
resultPF = PFtestcase(mpcreduced,timeStamp,savefig,savedata,addrenew);
% OPF test
resultOPF = OPFtestcase(mpcreduced,timeStamp,savefig,savedata,addrenew);
%% Loop through the whole year 2019
% Specify the range of year, month, day, and hour that you want to loop
% though, update operation condition for the specified timestamps, and then
% run PF and OPF.
if runloop
testyear = 2019;
for testmonth = 7
for testday = 1:7
parfor testhour = 1:24
timeStamp = datetime(testyear,testmonth,testday,testhour,0,0,"Format","MM/dd/uuuu HH:mm:ss");
fprintf("Start running %s ...\n",datestr(timeStamp));
% Operation condition update
mpcreduced = updateOpCond(mpc,timeStamp,savedata,verbose);
% PF test
resultPF = PFtestcase(mpcreduced,timeStamp,savefig,savedata,addrenew);
% OPF test
resultOPF = OPFtestcase(mpcreduced,timeStamp,savefig,savedata,addrenew);
fprintf("Success!\n");
end
end
end
end