ltbams 1.0.12__py3-none-any.whl → 1.0.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ams/_version.py +3 -3
- ams/cli.py +2 -7
- ams/core/common.py +7 -3
- ams/core/documenter.py +2 -1
- ams/core/matprocessor.py +174 -108
- ams/core/model.py +14 -6
- ams/core/param.py +5 -3
- ams/core/symprocessor.py +8 -2
- ams/core/var.py +1 -1
- ams/extension/eva.py +11 -7
- ams/interface.py +7 -7
- ams/io/json.py +20 -16
- ams/io/matpower.py +10 -6
- ams/io/psse.py +4 -1
- ams/io/xlsx.py +21 -16
- ams/main.py +53 -45
- ams/models/distributed/esd1.py +4 -7
- ams/models/distributed/ev.py +10 -6
- ams/models/distributed/pvd1.py +4 -7
- ams/models/group.py +17 -18
- ams/models/renewable/regc.py +14 -22
- ams/models/timeslot.py +30 -0
- ams/models/zone.py +2 -4
- ams/opt/exprcalc.py +11 -0
- ams/opt/optzbase.py +4 -3
- ams/report.py +2 -7
- ams/routines/dcopf.py +7 -4
- ams/routines/dcopf2.py +14 -4
- ams/routines/dopf.py +2 -2
- ams/routines/ed.py +5 -5
- ams/routines/grbopt.py +2 -0
- ams/routines/pflow.py +1 -1
- ams/routines/pypower.py +8 -0
- ams/routines/routine.py +125 -1
- ams/routines/rted.py +5 -5
- ams/routines/uc.py +2 -2
- ams/shared.py +99 -2
- ams/system.py +103 -18
- ams/utils/paths.py +6 -10
- docs/source/genroutineref.py +12 -0
- docs/source/index.rst +4 -3
- docs/source/release-notes.rst +14 -0
- {ltbams-1.0.12.dist-info → ltbams-1.0.14.dist-info}/METADATA +21 -23
- {ltbams-1.0.12.dist-info → ltbams-1.0.14.dist-info}/RECORD +47 -75
- {ltbams-1.0.12.dist-info → ltbams-1.0.14.dist-info}/top_level.txt +0 -1
- tests/__init__.py +0 -0
- tests/test_1st_system.py +0 -64
- tests/test_addressing.py +0 -40
- tests/test_case.py +0 -301
- tests/test_cli.py +0 -34
- tests/test_export_csv.py +0 -89
- tests/test_group.py +0 -83
- tests/test_interface.py +0 -238
- tests/test_io.py +0 -190
- tests/test_jumper.py +0 -27
- tests/test_known_good.py +0 -267
- tests/test_matp.py +0 -437
- tests/test_model.py +0 -54
- tests/test_omodel.py +0 -119
- tests/test_paths.py +0 -89
- tests/test_report.py +0 -251
- tests/test_repr.py +0 -21
- tests/test_routine.py +0 -178
- tests/test_rtn_acopf.py +0 -75
- tests/test_rtn_dcopf.py +0 -121
- tests/test_rtn_dcopf2.py +0 -103
- tests/test_rtn_ed.py +0 -279
- tests/test_rtn_opf.py +0 -142
- tests/test_rtn_pflow.py +0 -147
- tests/test_rtn_pypower.py +0 -315
- tests/test_rtn_rted.py +0 -273
- tests/test_rtn_uc.py +0 -248
- tests/test_service.py +0 -73
- {ltbams-1.0.12.dist-info → ltbams-1.0.14.dist-info}/WHEEL +0 -0
- {ltbams-1.0.12.dist-info → ltbams-1.0.14.dist-info}/entry_points.txt +0 -0
tests/test_rtn_uc.py
DELETED
@@ -1,248 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
import numpy as np
|
3
|
-
|
4
|
-
import ams
|
5
|
-
from ams.shared import skip_unittest_without_MISOCP
|
6
|
-
|
7
|
-
|
8
|
-
class TestUC(unittest.TestCase):
|
9
|
-
"""
|
10
|
-
Test routine `UC`.
|
11
|
-
"""
|
12
|
-
|
13
|
-
def setUp(self) -> None:
|
14
|
-
self.ss = ams.load(ams.get_case("5bus/pjm5bus_demo.json"),
|
15
|
-
setup=True, default_config=True, no_output=True)
|
16
|
-
# decrease load first
|
17
|
-
self.ss.PQ.set(src='p0', attr='v', idx=['PQ_1', 'PQ_2'], value=[0.3, 0.3])
|
18
|
-
# run UC._initial_guess()
|
19
|
-
self.off_gen = self.ss.UC._initial_guess()
|
20
|
-
|
21
|
-
def test_initial_guess(self):
|
22
|
-
"""
|
23
|
-
Test initial guess.
|
24
|
-
"""
|
25
|
-
u_off_gen = self.ss.StaticGen.get(src='u', idx=self.off_gen)
|
26
|
-
np.testing.assert_equal(u_off_gen, np.zeros_like(u_off_gen),
|
27
|
-
err_msg="UC._initial_guess() failed!")
|
28
|
-
|
29
|
-
def test_init(self):
|
30
|
-
"""
|
31
|
-
Test initialization.
|
32
|
-
"""
|
33
|
-
self.ss.UC.init()
|
34
|
-
self.assertTrue(self.ss.UC.initialized, "UC initialization failed!")
|
35
|
-
|
36
|
-
@skip_unittest_without_MISOCP
|
37
|
-
def test_trip_gen(self):
|
38
|
-
"""
|
39
|
-
Test generator tripping.
|
40
|
-
"""
|
41
|
-
self.ss.UC.run(solver='SCIP')
|
42
|
-
self.assertTrue(self.ss.UC.converged, "UC did not converge!")
|
43
|
-
pg_off_gen = self.ss.UC.get(src='pg', attr='v', idx=self.off_gen)
|
44
|
-
np.testing.assert_almost_equal(np.zeros_like(pg_off_gen),
|
45
|
-
pg_off_gen, decimal=6,
|
46
|
-
err_msg="Off generators are not turned off!")
|
47
|
-
|
48
|
-
@skip_unittest_without_MISOCP
|
49
|
-
def test_set_load(self):
|
50
|
-
"""
|
51
|
-
Test setting and tripping load.
|
52
|
-
"""
|
53
|
-
self.ss.UC.run(solver='SCIP')
|
54
|
-
pgs = self.ss.UC.pg.v.sum()
|
55
|
-
|
56
|
-
# --- set load ---
|
57
|
-
self.ss.PQ.set(src='p0', attr='v', idx='PQ_1', value=0.1)
|
58
|
-
self.ss.UC.update()
|
59
|
-
|
60
|
-
self.ss.UC.run(solver='SCIP')
|
61
|
-
pgs_pqt = self.ss.UC.pg.v.sum()
|
62
|
-
self.assertLess(pgs_pqt, pgs, "Load set does not take effect!")
|
63
|
-
|
64
|
-
# --- trip load ---
|
65
|
-
self.ss.PQ.alter(src='u', idx='PQ_2', value=0)
|
66
|
-
self.ss.UC.update()
|
67
|
-
|
68
|
-
self.ss.UC.run(solver='SCIP')
|
69
|
-
pgs_pqt2 = self.ss.UC.pg.v.sum()
|
70
|
-
self.assertLess(pgs_pqt2, pgs_pqt, "Load trip does not take effect!")
|
71
|
-
|
72
|
-
@skip_unittest_without_MISOCP
|
73
|
-
def test_trip_line(self):
|
74
|
-
"""
|
75
|
-
Test line tripping.
|
76
|
-
"""
|
77
|
-
self.ss.Line.set(src='u', attr='v', idx='Line_3', value=0)
|
78
|
-
self.ss.UC.update()
|
79
|
-
|
80
|
-
self.ss.UC.run(solver='SCIP')
|
81
|
-
self.assertTrue(self.ss.UC.converged, "UC did not converge under line trip!")
|
82
|
-
plf_l3 = self.ss.UC.get(src='plf', attr='v', idx='Line_3')
|
83
|
-
np.testing.assert_almost_equal(np.zeros_like(plf_l3),
|
84
|
-
plf_l3, decimal=6)
|
85
|
-
|
86
|
-
self.ss.Line.alter(src='u', idx='Line_3', value=1)
|
87
|
-
|
88
|
-
|
89
|
-
class TestUCDG(unittest.TestCase):
|
90
|
-
"""
|
91
|
-
Test routine `UCDG`.
|
92
|
-
"""
|
93
|
-
|
94
|
-
def setUp(self) -> None:
|
95
|
-
self.ss = ams.load(ams.get_case("5bus/pjm5bus_demo.json"),
|
96
|
-
setup=True, default_config=True, no_output=True)
|
97
|
-
# decrease load first
|
98
|
-
self.ss.PQ.set(src='p0', attr='v', idx=['PQ_1', 'PQ_2'], value=[0.3, 0.3])
|
99
|
-
# run `_initial_guess()`
|
100
|
-
self.off_gen = self.ss.UCDG._initial_guess()
|
101
|
-
|
102
|
-
def test_initial_guess(self):
|
103
|
-
"""
|
104
|
-
Test initial guess.
|
105
|
-
"""
|
106
|
-
u_off_gen = self.ss.StaticGen.get(src='u', idx=self.off_gen)
|
107
|
-
np.testing.assert_equal(u_off_gen, np.zeros_like(u_off_gen),
|
108
|
-
err_msg="UCDG._initial_guess() failed!")
|
109
|
-
|
110
|
-
def test_init(self):
|
111
|
-
"""
|
112
|
-
Test initialization.
|
113
|
-
"""
|
114
|
-
self.ss.UCDG.init()
|
115
|
-
self.assertTrue(self.ss.UCDG.initialized, "UCDG initialization failed!")
|
116
|
-
|
117
|
-
@skip_unittest_without_MISOCP
|
118
|
-
def test_trip_gen(self):
|
119
|
-
"""
|
120
|
-
Test generator tripping.
|
121
|
-
"""
|
122
|
-
self.ss.UCDG.run(solver='SCIP')
|
123
|
-
self.assertTrue(self.ss.UCDG.converged, "UCDG did not converge!")
|
124
|
-
pg_off_gen = self.ss.UCDG.get(src='pg', attr='v', idx=self.off_gen)
|
125
|
-
np.testing.assert_almost_equal(np.zeros_like(pg_off_gen),
|
126
|
-
pg_off_gen, decimal=6,
|
127
|
-
err_msg="Off generators are not turned off!")
|
128
|
-
|
129
|
-
@skip_unittest_without_MISOCP
|
130
|
-
def test_set_load(self):
|
131
|
-
"""
|
132
|
-
Test setting and tripping load.
|
133
|
-
"""
|
134
|
-
self.ss.UCDG.run(solver='SCIP')
|
135
|
-
pgs = self.ss.UCDG.pg.v.sum()
|
136
|
-
|
137
|
-
# --- set load ---
|
138
|
-
self.ss.PQ.set(src='p0', attr='v', idx='PQ_1', value=0.1)
|
139
|
-
self.ss.UCDG.update()
|
140
|
-
|
141
|
-
self.ss.UCDG.run(solver='SCIP')
|
142
|
-
pgs_pqt = self.ss.UCDG.pg.v.sum()
|
143
|
-
self.assertLess(pgs_pqt, pgs, "Load set does not take effect!")
|
144
|
-
|
145
|
-
# --- trip load ---
|
146
|
-
self.ss.PQ.alter(src='u', idx='PQ_2', value=0)
|
147
|
-
self.ss.UCDG.update()
|
148
|
-
|
149
|
-
self.ss.UCDG.run(solver='SCIP')
|
150
|
-
pgs_pqt2 = self.ss.UCDG.pg.v.sum()
|
151
|
-
self.assertLess(pgs_pqt2, pgs_pqt, "Load trip does not take effect!")
|
152
|
-
|
153
|
-
@skip_unittest_without_MISOCP
|
154
|
-
def test_trip_line(self):
|
155
|
-
"""
|
156
|
-
Test line tripping.
|
157
|
-
"""
|
158
|
-
self.ss.Line.set(src='u', attr='v', idx='Line_3', value=0)
|
159
|
-
self.ss.UCDG.update()
|
160
|
-
|
161
|
-
self.ss.UCDG.run(solver='SCIP')
|
162
|
-
self.assertTrue(self.ss.UCDG.converged, "UCDG did not converge under line trip!")
|
163
|
-
plf_l3 = self.ss.UCDG.get(src='plf', attr='v', idx='Line_3')
|
164
|
-
np.testing.assert_almost_equal(np.zeros_like(plf_l3),
|
165
|
-
plf_l3, decimal=6)
|
166
|
-
|
167
|
-
self.ss.Line.alter(src='u', idx='Line_3', value=1)
|
168
|
-
|
169
|
-
|
170
|
-
class TestUCES(unittest.TestCase):
|
171
|
-
"""
|
172
|
-
Test routine `UCES`.
|
173
|
-
"""
|
174
|
-
|
175
|
-
def setUp(self) -> None:
|
176
|
-
self.ss = ams.load(ams.get_case("5bus/pjm5bus_demo.json"),
|
177
|
-
setup=True, default_config=True, no_output=True)
|
178
|
-
# decrease load first
|
179
|
-
self.ss.PQ.set(src='p0', attr='v', idx=['PQ_1', 'PQ_2'], value=[0.3, 0.3])
|
180
|
-
# run `_initial_guess()`
|
181
|
-
self.off_gen = self.ss.UCES._initial_guess()
|
182
|
-
|
183
|
-
def test_initial_guess(self):
|
184
|
-
"""
|
185
|
-
Test initial guess.
|
186
|
-
"""
|
187
|
-
u_off_gen = self.ss.StaticGen.get(src='u', idx=self.off_gen)
|
188
|
-
np.testing.assert_equal(u_off_gen, np.zeros_like(u_off_gen),
|
189
|
-
err_msg="UCES._initial_guess() failed!")
|
190
|
-
|
191
|
-
def test_init(self):
|
192
|
-
"""
|
193
|
-
Test initialization.
|
194
|
-
"""
|
195
|
-
self.ss.UCES.init()
|
196
|
-
self.assertTrue(self.ss.UCES.initialized, "UCES initialization failed!")
|
197
|
-
|
198
|
-
@skip_unittest_without_MISOCP
|
199
|
-
def test_trip_gen(self):
|
200
|
-
"""
|
201
|
-
Test generator tripping.
|
202
|
-
"""
|
203
|
-
self.ss.UCES.run(solver='SCIP')
|
204
|
-
self.assertTrue(self.ss.UCES.converged, "UCES did not converge!")
|
205
|
-
pg_off_gen = self.ss.UCES.get(src='pg', attr='v', idx=self.off_gen)
|
206
|
-
np.testing.assert_almost_equal(np.zeros_like(pg_off_gen),
|
207
|
-
pg_off_gen, decimal=6,
|
208
|
-
err_msg="Off generators are not turned off!")
|
209
|
-
|
210
|
-
@skip_unittest_without_MISOCP
|
211
|
-
def test_set_load(self):
|
212
|
-
"""
|
213
|
-
Test setting and tripping load.
|
214
|
-
"""
|
215
|
-
self.ss.UCES.run(solver='SCIP')
|
216
|
-
pgs = self.ss.UCES.pg.v.sum()
|
217
|
-
|
218
|
-
# --- set load ---
|
219
|
-
self.ss.PQ.set(src='p0', attr='v', idx='PQ_1', value=0.1)
|
220
|
-
self.ss.UCES.update()
|
221
|
-
|
222
|
-
self.ss.UCES.run(solver='SCIP')
|
223
|
-
pgs_pqt = self.ss.UCES.pg.v.sum()
|
224
|
-
self.assertLess(pgs_pqt, pgs, "Load set does not take effect!")
|
225
|
-
|
226
|
-
# --- trip load ---
|
227
|
-
self.ss.PQ.alter(src='u', idx='PQ_2', value=0)
|
228
|
-
self.ss.UCES.update()
|
229
|
-
|
230
|
-
self.ss.UCES.run(solver='SCIP')
|
231
|
-
pgs_pqt2 = self.ss.UCES.pg.v.sum()
|
232
|
-
self.assertLess(pgs_pqt2, pgs_pqt, "Load trip does not take effect!")
|
233
|
-
|
234
|
-
@skip_unittest_without_MISOCP
|
235
|
-
def test_trip_line(self):
|
236
|
-
"""
|
237
|
-
Test line tripping.
|
238
|
-
"""
|
239
|
-
self.ss.Line.set(src='u', attr='v', idx='Line_3', value=0)
|
240
|
-
self.ss.UCES.update()
|
241
|
-
|
242
|
-
self.ss.UCES.run(solver='SCIP')
|
243
|
-
self.assertTrue(self.ss.UCES.converged, "UCES did not converge under line trip!")
|
244
|
-
plf_l3 = self.ss.UCES.get(src='plf', attr='v', idx='Line_3')
|
245
|
-
np.testing.assert_almost_equal(np.zeros_like(plf_l3),
|
246
|
-
plf_l3, decimal=6)
|
247
|
-
|
248
|
-
self.ss.Line.alter(src='u', idx='Line_3', value=1)
|
tests/test_service.py
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
import numpy as np
|
3
|
-
|
4
|
-
import ams
|
5
|
-
from ams.core.matprocessor import MParam
|
6
|
-
from ams.core.service import NumOp, NumOpDual, ZonalSum
|
7
|
-
|
8
|
-
|
9
|
-
class TestService(unittest.TestCase):
|
10
|
-
"""
|
11
|
-
Test functionality of Services.
|
12
|
-
"""
|
13
|
-
|
14
|
-
def setUp(self) -> None:
|
15
|
-
self.ss = ams.load(ams.get_case("ieee39/ieee39_uced_esd1.xlsx"),
|
16
|
-
default_config=True,
|
17
|
-
no_output=True,)
|
18
|
-
self.nR = self.ss.Zone.n
|
19
|
-
self.nB = self.ss.Bus.n
|
20
|
-
self.nL = self.ss.Line.n
|
21
|
-
self.nD = self.ss.StaticLoad.n # number of static loads
|
22
|
-
|
23
|
-
def test_NumOp_norfun(self):
|
24
|
-
"""
|
25
|
-
Test `NumOp` without return function.
|
26
|
-
"""
|
27
|
-
CftT = NumOp(u=self.ss.mats.Cft, fun=np.transpose)
|
28
|
-
np.testing.assert_array_equal(CftT.v.transpose(), self.ss.mats.Cft.v)
|
29
|
-
|
30
|
-
def test_NumOp_rfun(self):
|
31
|
-
"""
|
32
|
-
Test `NumOp` with return function.
|
33
|
-
"""
|
34
|
-
CftTT = NumOp(u=self.ss.mats.Cft, fun=np.transpose, rfun=np.transpose)
|
35
|
-
np.testing.assert_array_equal(CftTT.v, self.ss.mats.Cft.v)
|
36
|
-
|
37
|
-
def test_NumOp_ArrayOut(self):
|
38
|
-
"""
|
39
|
-
Test `NumOp` non-array output.
|
40
|
-
"""
|
41
|
-
M = NumOp(u=self.ss.PV.pmax,
|
42
|
-
fun=np.max,
|
43
|
-
rfun=np.dot, rargs=dict(b=10),
|
44
|
-
array_out=True,)
|
45
|
-
M2 = NumOp(u=self.ss.PV.pmax,
|
46
|
-
fun=np.max,
|
47
|
-
rfun=np.dot, rargs=dict(b=10),
|
48
|
-
array_out=False,)
|
49
|
-
self.assertIsInstance(M.v, np.ndarray)
|
50
|
-
self.assertIsInstance(M2.v, (int, float))
|
51
|
-
|
52
|
-
def test_NumOpDual(self):
|
53
|
-
"""
|
54
|
-
Test `NumOpDual`.
|
55
|
-
"""
|
56
|
-
p_vec = MParam(v=self.ss.DCOPF.pd.v)
|
57
|
-
one_vec = MParam(v=np.ones(self.ss.StaticLoad.n))
|
58
|
-
p_sum = NumOpDual(u=p_vec, u2=one_vec,
|
59
|
-
fun=np.multiply, rfun=np.sum)
|
60
|
-
self.assertEqual(p_sum.v, self.ss.PQ.p0.v.sum())
|
61
|
-
|
62
|
-
def test_ZonalSum(self):
|
63
|
-
"""
|
64
|
-
Test `ZonalSum`.
|
65
|
-
"""
|
66
|
-
ds = ZonalSum(u=self.ss.RTED.zd, zone="Area",
|
67
|
-
name="ds", tex_name=r"S_{d}",
|
68
|
-
info="Sum pl vector in shape of area",)
|
69
|
-
ds.rtn = self.ss.RTED
|
70
|
-
# check if the shape is correct
|
71
|
-
np.testing.assert_array_equal(ds.v.shape, (self.nR, self.nD))
|
72
|
-
# check if the values are correct
|
73
|
-
self.assertTrue(np.all(ds.v.sum(axis=1) <= np.array([self.nB, self.nB])))
|
File without changes
|
File without changes
|