forked from dchassin/ieee123
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.glm
278 lines (247 loc) · 6.17 KB
/
model.glm
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
///////////////////////////////////////////////////////
//
// IEEE 123 realtime simulation model
// Copyright (C) 2016, Stanford University
// Author: [email protected]
//
///////////////////////////////////////////////////////
//
// Read the configuration file for this system
//
#ifexist config.glm
#include "config.glm"
#endif
//
// Check the configuration
//
#ifndef PORT // this is required and defined in config.glm
#error config.glm load failed: if you have not already done so you must copy config-template.glm to config.glm and edit it before starting the service
#endif
///////////////////////////////////////////////////////
//
// BASIC SETTINGS
//
///////////////////////////////////////////////////////
#set randomseed=1
#set suppress_repeat_messages=FALSE
//
// Realtime run
//
#ifdef SWITCHTEST // set if short switch tests are being run
#print Setting up switch test run on ${HISTORY_START_MONTH}/1/${HISTORY_YEAR}...
#define HISTORY=yes
#endif
#ifndef HISTORY
#ifdef HOSTNAME
#set hostname=${HOSTNAME} // tells clients where to get the data
#else
#warning HOSTNAME is not defined in either your environment or in config.glm, using localhost
#define HOSTNAME=localhost
#endif
#print Setting up realtime server on ${HOSTNAME}:${PORT}
#option server // enables the server
#set run_realtime=1 // tells the server to run in realtime mode
#set server_portnum=${PORT} // is the port that clients will connect to
#set suppress_repeat_messages=FALSE // allow all similar messages to be logged
clock {
timezone ${TIMEZONE};
}
//
// Historical run
//
#else
#ifndef SWITCHTEST
#print Setting up history run from ${HISTORY_START_MONTH}/1/${HISTORY_YEAR} to ${HISTORY_END_MONTH}/1/${HISTORY_YEAR}...
clock {
timezone ${TIMEZONE};
starttime '${HISTORY_YEAR}-${HISTORY_START_MONTH}-01 00:00:00 PST';
stoptime '${HISTORY_YEAR}-${HISTORY_END_MONTH}-01 00:00:00 PST';
}
#endif
#endif
#ifdef SWITCHTEST
#define TESTSTART=00:00:00
#define TESTSTOP=00:15:00
clock {
timezone ${TIMEZONE};
starttime '${HISTORY_YEAR}-${HISTORY_START_MONTH}-01 ${TESTSTART} PST';
stoptime '${HISTORY_YEAR}-${HISTORY_START_MONTH}-01 ${TESTSTOP} PST';
}
#endif
///////////////////////////////////////////////////////
//
// WEATHER
//
///////////////////////////////////////////////////////
#ifndef TMYTYPE
#warning TMYTYPE is not defined, using tmy2 by default
#define TMYTYPE=tmy2
#endif
#ifexist ${STATE}-${CITY}.${TMYTYPE}
#define TMY=${STATE}-${CITY}.${TMYTYPE}
#endif
#ifndef TMY
#error TMY file ${STATE}-${CITY}.${TMYTYPE} is not found; you must install this file in $HOME
#endif
#print Loading climate data for ${CITY} ${STATE}...
module climate;
class climate {
double elevation[m];
}
object climate {
name weather;
city "${CITY} ${STATE}";
tmyfile "${TMY}";
elevation 150;
interpolate QUADRATIC;
}
///////////////////////////////////////////////////////
//
// POWER SYSTEM MODEL
//
///////////////////////////////////////////////////////
#print Loading power system model...
module powerflow {
solver_method NR;
line_capacitance true;
#ifndef SWITCHTEST
convergence_error_handling IGNORE;
#endif
}
#ifdef SOLAR==yes
module generators;
#endif
#ifdef VOLTDUMP
#print Voltage dump to ${VOLTDUMP} is enabled...
object voltdump {
filename ${VOLTDUMP};
group "nodevolts";
mode polar;
}
#endif
#ifdef CURRDUMP
#print Current dump to ${CURRDUMP} is enabled...
object currdump {
filename ${CURRDUMP};
mode rect;
}
#endif
//
// Powerflow component configurations
//
#include "library.glm"
//
// Power system topology
//
#include "feeder.glm"
#include "lateral.glm"
//
// Power system geoinformation
//
#include "geolocation.glm"
//
// Switch configuration test
//
#ifdef SWITCHINIT
#ifexist switchtest/switchtest_${SWITCHINIT}.glm
#print Using initial switch configuration ${SWITCHINIT}
#include "switchtest/switchtest_${SWITCHINIT}.glm"
#else
#error switchtest_${SWITCHINIT}.glm does not exist, SWITCHINIT=${SWITCHINIT} is not valid
#endif
#else
#print Using default switch configuration (SWITCHINIT=0)
#define SWITCHINIT=0
#endif
///////////////////////////////////////////////////////
//
// MYSQL DATABASE SUPPORT
//
///////////////////////////////////////////////////////
#ifndef NOMYSQL
#ifndef MYSQLHOST
#define MYSQLHOST=localhost
#endif
#print Setting up database for model ${NAME} on ${MYSQLHOST}...
module mysql {
hostname "${MYSQLHOST}";
username "gridlabd";
password "gridlabd";
#ifdef SOCKETNAME
#print Using socket ${SOCKETNAME} for MySQL...
socketname "${SOCKETNAME}";
#else
#print Using default port 3306 for MySQL...
#endif
}
#ifdef SWITCHTEST
#define MYSQL_SCADA=ieee123_switchtest_${SWITCHINIT}
#define MYSQL_AMI=ieee123_switchtest_${SWITCHINIT}
#endif
#ifdef MYSQL_SCADA
#print Setting SCADA tables ${MYSQL_SCADA}...
object database {
name scada;
schema "${MYSQL_SCADA}";
#ifdef HISTORY
options NEWDB; // only rebuild database for history runs
#endif
}
#endif
#ifdef MYSQL_AMI
#print Setting AMI tables in ${MYSQL_AMI}...
object database {
name ami;
schema "${MYSQL_AMI}";
#ifdef HISTORY
options NEWDB; // only rebuild database for history runs
#endif
}
#endif
#endif // NOMYSQL
///////////////////////////////////////////////////////
//
// LOAD MODEL
//
///////////////////////////////////////////////////////
#include "loads.glm"
///////////////////////////////////////////////////////
//
// DATA COLLECTION
//
///////////////////////////////////////////////////////
#ifndef NOMYSQL
//
// SCADA recorders
//
#ifdef MYSQL_SCADA
#print Setting up SCADA monitoring system...
#include "scada.glm"
#endif
#endif // NOMYSQL
///////////////////////////////////////////////////////
//
// CONTROLS
//
///////////////////////////////////////////////////////
#ifdef MYSQL_SCADA
#print Setting up SCADA control system...
#include "control.glm"
#endif
///////////////////////////////////////////////////////
//
// MODEL EXPORT
//
///////////////////////////////////////////////////////
#ifndef NOMYSQL
#ifdef MYSQL_MODEL
#ifndef SWITCHTEST
#print Exporting system model to mysql schema ${NAME}_model...
export mysql ${NAME}_model;
#else
#print Exporting system model to mysql schema ${NAME}_switchtest_${SWITCHINIT}...
export mysql ${NAME}_switchtest_${SWITCHINIT};
#endif
#endif
#endif // NOMYSQL
#print Load complete.