-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompare EPRI21.Rmd
163 lines (130 loc) · 3.29 KB
/
Compare EPRI21.Rmd
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
---
jupyter:
jupytext:
text_representation:
extension: .Rmd
format_name: rmarkdown
format_version: '1.1'
jupytext_version: 1.1.1
kernelspec:
display_name: Python 3
language: python
name: python3
---
```{python}
import json, gzip, os
from glob import glob
import numpy as np
```
```{python}
os.getcwd()
```
```{python}
# read in the gic version
with open("data/epri21-0.json") as h:
mnet = json.load(h);
```
```{python}
# read in the matpower version
with open("data/epri21.json") as h:
jnet = json.load(h);
```
```{python}
def compdiff(x, y):
for k,vx in x.items():
if k in set(('index','rate_b','rate_c','vm','va','source_id','status')):
continue
if k not in y:
print('{} not found'.format(k))
continue
vy = y[k]
numeric = True
if isinstance(vx, list):
vx = np.array(vx)
vy = np.array(vy)
numeric = False
if isinstance(vx, float) or isinstance(vx, int):
d = vx - y[k]
dmax = np.max(np.abs(d))
else:
d = 0.0
dmax = 0.0
if dmax < 1e-6:
continue
if numeric:
print('{:>10}: {:8.2f} = {:8.2f} - {:8.2f}'.format(k, d, vx, vy))
else:
print('{:>10}: {} = {} - {}'.format(k, dmax, vx, vy))
def tablediff(x, y):
for k,v in x.items():
if k not in y:
#print('{} not found'.format(k))
continue
print('Component {}\n---------------------------'.format(k))
compdiff(v, y[k])
print()
```
```{python}
# create dict of branches
jbranches = {}
for b in jnet['gmd_branch'].values():
k = b['f_bus'], b['t_bus']
jbranches[k] = b
# create dict of buses
jbuses = {}
for b in jnet['gmd_bus'].values():
k = b['parent_index']
jbuses[k] = b
jgens = {}
for g in jnet['gen'].values():
k = g['gen_bus']
jgens[k] = g
jloads = {}
for d in jnet['load'].values():
k = d['load_bus']
jloads[k] = d
```
```{python}
mnet['gmd_bus']['1']
```
```{python}
for i,mx in mnet['gmd_bus'].items():
k = mx['parent_index']
jx = jbuses[k]
print('Component {}\n---------------------------'.format(i))
compdiff(mx, jx)
print()
# some generators have 0 pmax for feasible case
# infeasible case (2) has
# zero apf for some generators
# zero qmin/qmax for some generators
# high qmin for some generators
# fixed term for generator cost doesn't matter
# vg is 1.1 instead of 1.05
# powers for case 2 are in MW instead of pu (100 MW base)
```
```{python}
jbuses
```
```{python}
for i,mb in mnet['bus'].items():
k = mb['bus_i']
jb = jbuses[k]
print('Component {}\n---------------------------'.format(i))
compdiff(mb, jb)
print()
```
```{python}
for i,mbr in mnet['branch'].items():
k = mbr['f_bus'], mbr['t_bus']
jbr = jbranches[k]
print('Component {}\n---------------------------'.format(i))
compdiff(mbr, jbr)
print()
# Differences observed
# rate_b, rate_c are zero for jnet, but these are not used
# angmin & angmax are much larger for jnet, for mnet it's just +/- 1 degree
```
```{python}
0.02*
```