ltbams 1.0.11__py3-none-any.whl → 1.0.13__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.
Files changed (46) hide show
  1. ams/_version.py +3 -3
  2. ams/core/matprocessor.py +183 -118
  3. ams/io/matpower.py +55 -20
  4. ams/io/psse.py +4 -0
  5. ams/opt/exprcalc.py +11 -0
  6. ams/routines/grbopt.py +2 -0
  7. ams/routines/pypower.py +21 -4
  8. ams/routines/routine.py +127 -15
  9. ams/shared.py +30 -2
  10. ams/system.py +51 -3
  11. ams/utils/paths.py +64 -0
  12. docs/source/index.rst +4 -3
  13. docs/source/release-notes.rst +25 -10
  14. {ltbams-1.0.11.dist-info → ltbams-1.0.13.dist-info}/METADATA +4 -2
  15. {ltbams-1.0.11.dist-info → ltbams-1.0.13.dist-info}/RECORD +18 -46
  16. {ltbams-1.0.11.dist-info → ltbams-1.0.13.dist-info}/WHEEL +1 -1
  17. {ltbams-1.0.11.dist-info → ltbams-1.0.13.dist-info}/top_level.txt +0 -1
  18. tests/__init__.py +0 -0
  19. tests/test_1st_system.py +0 -64
  20. tests/test_addressing.py +0 -40
  21. tests/test_case.py +0 -301
  22. tests/test_cli.py +0 -34
  23. tests/test_export_csv.py +0 -89
  24. tests/test_group.py +0 -83
  25. tests/test_interface.py +0 -238
  26. tests/test_io.py +0 -180
  27. tests/test_jumper.py +0 -27
  28. tests/test_known_good.py +0 -267
  29. tests/test_matp.py +0 -437
  30. tests/test_model.py +0 -54
  31. tests/test_omodel.py +0 -119
  32. tests/test_paths.py +0 -22
  33. tests/test_report.py +0 -251
  34. tests/test_repr.py +0 -21
  35. tests/test_routine.py +0 -178
  36. tests/test_rtn_acopf.py +0 -75
  37. tests/test_rtn_dcopf.py +0 -101
  38. tests/test_rtn_dcopf2.py +0 -103
  39. tests/test_rtn_ed.py +0 -279
  40. tests/test_rtn_opf.py +0 -142
  41. tests/test_rtn_pflow.py +0 -147
  42. tests/test_rtn_pypower.py +0 -315
  43. tests/test_rtn_rted.py +0 -273
  44. tests/test_rtn_uc.py +0 -248
  45. tests/test_service.py +0 -73
  46. {ltbams-1.0.11.dist-info → ltbams-1.0.13.dist-info}/entry_points.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  ams/__init__.py,sha256=q-9-f0YCg6aaTW19VCkY6VosfvRA2ObI9mF1f_3016Y,313
2
2
  ams/__main__.py,sha256=EB4GfGiKgvnQ_psNr0QwPoziYvjmGvQ2yVsBwQtfrLw,170
3
- ams/_version.py,sha256=9w0v2vIzAou5TWcsacfNdhiCAr9S83BM7FAKRy_t8h0,498
3
+ ams/_version.py,sha256=cx7xVAwESB33WAGN1aq_ze2Enb6iFPvXPOw8AEV7mrg,498
4
4
  ams/cli.py,sha256=EyNFXn565gFCppTxpyTZviBdPgUuKtgAPZ4WE6xewRk,6164
5
5
  ams/interface.py,sha256=-UN7-TiSt7mOS0W7526LuOk4KCIGDZSguRaVmh_KMRM,45240
6
6
  ams/main.py,sha256=lIqC16TO0pye75Wv8l_6EemNtm15iyMdvu8YQFkdd_4,23599
7
7
  ams/report.py,sha256=ewcffopOzT5o45eJNmcV8pxeQqPIjKbarGN33-yHGA8,10961
8
- ams/shared.py,sha256=4sY2U0sghs_S2V6C7Z0OyQ6WZRfpCXk2_Cf_Mg24Vr4,3900
9
- ams/system.py,sha256=eAsaXO2O_7_PAIuPFup3edztuAhKMhODrR9l92CYx38,29765
8
+ ams/shared.py,sha256=HNkW-fa7l1PSubHPUvG5iaJTKeKXEt-IUCEv1MyrX3Q,4820
9
+ ams/system.py,sha256=rKd9xeb6NKTcb74iqMh5zHS4ZrvQXI88zx56ChIoKkc,32118
10
10
  ams/cases/5bus/pjm5bus_demo.json,sha256=IpxO2vzB9-9Kg9xjOXREKeXEz9wjFE7cuQbcUu8VORA,23152
11
11
  ams/cases/5bus/pjm5bus_demo.xlsx,sha256=OWIUprkg8_aQ_bTCaEFMl7Bhfa1R20zxAHXRQtXBix0,32607
12
12
  ams/cases/5bus/pjm5bus_ev.xlsx,sha256=vR8dJv5jIxib1pgcMonhzvraoqZVJWhBSJdVXDL0qsI,19498
@@ -38,7 +38,7 @@ ams/cases/wecc/wecc_uced.xlsx,sha256=R3tZgxEqz_ctKcjA1wwFecxn-QZXutvf7NzgnCg_078
38
38
  ams/core/__init__.py,sha256=lIvrAvYf2yrHWqYi0rVuJgJt8KNA8nTmN2iuZ125z9Q,123
39
39
  ams/core/common.py,sha256=934J7xq5JvC14yKp2Z4hWKUFJFhxzAnxB_8_99CChY0,704
40
40
  ams/core/documenter.py,sha256=3-jUYrtN8zDZXd8tQZlmZouJluJPH9_xIDbK9ZEEnRU,25762
41
- ams/core/matprocessor.py,sha256=3eEij-ul8Rx25ZwNbv66YEOKyUXB-fYO-ZQs5BpqmIU,26610
41
+ ams/core/matprocessor.py,sha256=T_WcfTS2qoXa8IxiaYBgSjt56yQm_qUKSsh3Gfq-yIc,27923
42
42
  ams/core/model.py,sha256=LNZtzyf2A7Tz3pn9IDs35JYaHSkQRqhqZicTpZGSqsc,10926
43
43
  ams/core/param.py,sha256=LPH48xUHyqWqODD6IsiamUtkJDDSgGCEMAo6vroFoHE,11130
44
44
  ams/core/service.py,sha256=Q4aeaYFWycIEH7I8DSO8Itah2CJxc3oAW46dtKCQEyA,28041
@@ -48,8 +48,8 @@ ams/extension/__init__.py,sha256=5IFTNirDL0uDaUsg05_oociVT9VCy2rhPx1ad4LGveM,65
48
48
  ams/extension/eva.py,sha256=4_q4ME0WrQIcd205SBTjv0-rMRZZIdQ07QJuEHwLIC8,16340
49
49
  ams/io/__init__.py,sha256=GIfF7X44olHaySL8EzOBU1eXUnunr1owzzdPfPvvHZU,3802
50
50
  ams/io/json.py,sha256=IurwcZDuKczSbRTpcbQZiIi0ARCrMK6kJ0E3wS8ENy8,2585
51
- ams/io/matpower.py,sha256=IK6NwVUAM0FAv2rFF1hBoSTowfXD8l6YXrKiPch9hW8,26166
52
- ams/io/psse.py,sha256=qvKP9CP-70UejUsffPu4ibtyF1JXO0Sz0-evT4fDPXg,13631
51
+ ams/io/matpower.py,sha256=qxZ6qqFDm1F9mWotLT6walWD-rZaFKyh0-DVtRcjhgY,27601
52
+ ams/io/psse.py,sha256=qLKM9pRsNuSVNRHrgy4i6beSLuxu4fcBEU_SIV8owRA,13714
53
53
  ams/io/pypower.py,sha256=Fe0sxzC5DZegtYksTixadXk_LcfJ1GNetWu9EuHCkG8,2790
54
54
  ams/io/xlsx.py,sha256=7ATW1seyxsGn7d5p5IuSRFHcoCHVVjMu3E7mP1Mc74U,2460
55
55
  ams/models/__init__.py,sha256=EGkViLkVX_We9FAGuEkgfleMNmPw_vGp2Nq1OQimL7U,691
@@ -74,7 +74,7 @@ ams/models/static/gen.py,sha256=QXklOYlnU7QHWy-WFJwhxuNItUPqFsLJIjAO4sGMUbg,7087
74
74
  ams/models/static/pq.py,sha256=SCwAqhqvKy_PFHp6VYO_zgv3v6gI5pK3KvT3RNX-nvA,2782
75
75
  ams/opt/__init__.py,sha256=INsl8yxtOzTKqV9pzVxlL6RSGDRaUDwxpZMY1QROrF4,459
76
76
  ams/opt/constraint.py,sha256=ERT9zwjQyGkvDo465Yd0wBexlIhjVmw0MyWq4BWnWoI,5534
77
- ams/opt/exprcalc.py,sha256=oVtjNHzdWvYHV-8PdRehAxjledsQxpxatdNgMLeWS5o,3935
77
+ ams/opt/exprcalc.py,sha256=7io0vEZu5zqsEnetocasRT1tu7o7g0TXw7iJf2YFIxI,4317
78
78
  ams/opt/expression.py,sha256=WrWnYliB61uHA_wQjtYgtAXdpgSN1pNqQmWvzHWSsdE,5569
79
79
  ams/opt/objective.py,sha256=W0dQfW5dHNdWEc2DQtWYNGMuhMY6Pu-HTD0n7-izDZA,5519
80
80
  ams/opt/omodel.py,sha256=hEtfKoSNssSxHgUDdep79pifNTsywytDTjgGgne7nKM,12750
@@ -88,24 +88,24 @@ ams/routines/dcopf2.py,sha256=sDCP8zqYHDh7s7p9SX6G8QhMfIxCg3VPYJn6r3pRKyo,3620
88
88
  ams/routines/dcpf.py,sha256=lGZ9LmCL1DsFB-sNxI7NGrq0qd_iBRMDPJmU5022t20,8242
89
89
  ams/routines/dopf.py,sha256=8D36-FkPORYGaMnwGTqwz8HxAXk5ywo3mk8NlGq327g,6289
90
90
  ams/routines/ed.py,sha256=9Hf_ZqD6poIxCIBfsTMC0DGoPNEja1ZtVxqhb4ijhgE,11875
91
- ams/routines/grbopt.py,sha256=RjrMq6XPHeBEbf-Pt9sLk2D1vnXZYYwaic4BP8lbACg,5480
91
+ ams/routines/grbopt.py,sha256=hEDy7L-lSd7QxSN_GAyDLaLkhIpxl6csXz6ntdKT_fw,5510
92
92
  ams/routines/pflow.py,sha256=5_9n10r_PfsVXIRkaBgKxVITumImZ8mvpHnwxX_ECdw,9432
93
- ams/routines/pypower.py,sha256=U1UJbcNG7JawGmK9sKtjZlRrGwODVWDjJFucisMcvJs,26545
94
- ams/routines/routine.py,sha256=v4jzsziQPvbVh5m0AH629NBEtmKlLvitFW5m-YfFtfY,35833
93
+ ams/routines/pypower.py,sha256=VnqMQZkBIvDe3tDbTJcxYz04idon5XvmGlf7OSs8kOI,27334
94
+ ams/routines/routine.py,sha256=PB-97CkdNAiAGMlagihvFTklt2w7ce4FG2NcjW1InoA,39445
95
95
  ams/routines/rted.py,sha256=GOHRxo0-HS5HhwQg8lv7-2VcGr_M_TdUvvomgJ31fDQ,22070
96
96
  ams/routines/type.py,sha256=lvTWSnCYIbRJXIm3HX6jA0Hv-WWYusTOUPfoW8DITlU,3877
97
97
  ams/routines/uc.py,sha256=VcuNy2TnBjsewKEGIqeo2EFTyuhpx5QsEvgpAtscDIQ,15648
98
98
  ams/utils/__init__.py,sha256=2hAQmWRgmnE-bCGT9cJoW9FkPDMGRiGkbBcUgj-bgjI,122
99
99
  ams/utils/misc.py,sha256=Y6tPKpUKJa7bL9alroJuG2UNW9vdQjnfAmKb2EbIls8,2027
100
- ams/utils/paths.py,sha256=o9Ku2ETmYxsoD7VbMlS4qv_wGtXtT-SWIgDs0F7jpCQ,6693
100
+ ams/utils/paths.py,sha256=6iTux5UaHzRi6mGHnpbYUp-MoD-IFny4IuRsV8FKDcQ,9481
101
101
  docs/Makefile,sha256=UKXBFAbKGPt1Xw9J84343v0Mh8ylAZ-tE0uCd74DrQU,725
102
102
  docs/make.bat,sha256=9UgKGb4SdP006622fJiFxeFT1BeycYAs6hDbV1xwPy8,804
103
103
  docs/source/api.rst,sha256=BRzdDFDzDwVL7Jr_Xj-O5Icgx0gt5hNNd1OjvPl7ap0,1490
104
104
  docs/source/conf.py,sha256=UyoWogZTUNSJU7pQS_JaR28nKddW94zr01LYoIciZZw,6688
105
105
  docs/source/genmodelref.py,sha256=IhmF7bDw8BXPvLD8V3WjQNrfc-H07r5iS-_4DHbbp-8,1420
106
106
  docs/source/genroutineref.py,sha256=glHhbWUXfZzMDrkque9CBZu8QtdxlxPojInERzAAOwA,1063
107
- docs/source/index.rst,sha256=N5phQS5RIyYs-NZo_5yYB8LjvHzOKLeXzRA-M8i-g3Q,2688
108
- docs/source/release-notes.rst,sha256=7BtbNLQ2EUvSvB9KGNELicPAFqNT8uBzQQLqlT9MpMc,13830
107
+ docs/source/index.rst,sha256=oAdRBWTLCX8nEMVatfDFkn0dtvinOK7vg4QUekT4jns,2738
108
+ docs/source/release-notes.rst,sha256=bzZC_X3PP392jjG0j3hSbBtPUFceMcea0FjTIPljyl8,14308
109
109
  docs/source/_templates/autosummary/base.rst,sha256=zl3U4baR4a6YjsHyT-x9zCOrHwKZOVUdWn1NPX2u3bc,106
110
110
  docs/source/_templates/autosummary/class.rst,sha256=Hv_igCsLsUpM62_zN0nqj6FSfKnS5xLyu8ZldMbfOAk,668
111
111
  docs/source/_templates/autosummary/module.rst,sha256=YdbpCudOrEU-JbuSlzGvcOI2hn_KrCM6FW5HcGqkaEE,1113
@@ -135,36 +135,8 @@ docs/source/modeling/index.rst,sha256=TasRAJSglc5KAZaGAj9TLMktOO2TtzZsqG5WvvZXB_
135
135
  docs/source/modeling/model.rst,sha256=j7OSvoXnDht6rGpgwPiJklsCWrebfx4DxIN-G8r6iFo,7086
136
136
  docs/source/modeling/routine.rst,sha256=BkUE3y5L1lA7LP9Nyzc4zzY-tF3t4k7egBE188kybHY,4286
137
137
  docs/source/modeling/system.rst,sha256=NMOPNMOKG1_dRyNPPx-MiCKbbpadxWJxGyU6geRUsvQ,1374
138
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
- tests/test_1st_system.py,sha256=WoCgeyUCjBVwyYCqzwDkYy8F3dWArMQBESqIUQk6tOk,1907
140
- tests/test_addressing.py,sha256=MIT713KCqMg0h2o4rBDZsGUrpGadmMlXnrrdq-wB77E,1364
141
- tests/test_case.py,sha256=b_YZhwIN9sX3FCMD03hRNygV-mYthNj7cOhEv7-by-g,8857
142
- tests/test_cli.py,sha256=TtCGBy2e7Ll_2gJTFo9juZtzhaakho_MqkcqhG2w2dk,870
143
- tests/test_export_csv.py,sha256=NTULXfTexgI1jf5koUMOYi3RLrSQouS7zxRjXo3ng50,2921
144
- tests/test_group.py,sha256=Tq0s9gtenqrv4ws5YNzWxbiF4WgyhtMEAXZfJtew6M4,2699
145
- tests/test_interface.py,sha256=8hOZ1caRfoyoEdy1lnh8Y4rIL97FLb2oUKfX_N1lEDo,8838
146
- tests/test_io.py,sha256=MIale4g0jMC9Vy4jjtFKpnh12aavp9lusczff1iIVC0,6493
147
- tests/test_jumper.py,sha256=bdOknplEGnO_tiJc7p3xQvgTe2b6Dz53bOgbFaXKMAI,537
148
- tests/test_known_good.py,sha256=NBrlAxnVMxIHXR2cWps-Kwjh36fiU4Y-eupspZkM0ks,9670
149
- tests/test_matp.py,sha256=LkjhqxSFr6oY_ENpduDQ77rhLLBl6RzIHZ2d0m_8i-8,17262
150
- tests/test_model.py,sha256=ZgghNYmEeALf8_1sPjq9lIJwuYDQ2SelivJNEYpHxJU,1621
151
- tests/test_omodel.py,sha256=niVdTZJEZNSVHz-ocA0nnVx84Dt3-8P5FUrwKkNiA0I,4305
152
- tests/test_paths.py,sha256=BU6Tjl4Q_WuHbid0ujkiibqx7yas42YJ7eV_avVMwuw,633
153
- tests/test_report.py,sha256=RR23by4G-cyleaHTy9A7SEVet0eOVS-Tm0kk1GXY5dM,8134
154
- tests/test_repr.py,sha256=g7MRdxLcZRI1PlREFdUG_npp0LkcQiJZfOPw1aq0EFM,570
155
- tests/test_routine.py,sha256=DP5CwKtzliw2gNLW2W_3kp0Ihy4rCaxeBxMpgyN5AXA,6234
156
- tests/test_rtn_acopf.py,sha256=Kg-RHflrrwyX2uHr16xSAze9XAdYcK7eg1LHMyr1uyA,2354
157
- tests/test_rtn_dcopf.py,sha256=Pl6yGfvznnjP1oGiIWEhnqFIBW2futxPZS4o_DRkbrw,3660
158
- tests/test_rtn_dcopf2.py,sha256=57_62TnHW-cS6iK2zXT_eXChnh83YiYoPypJwub3VmQ,3747
159
- tests/test_rtn_ed.py,sha256=SeSuzqpTZZnBph41PV2Piplo9yxR3qpbhQUa6UCYnSw,10267
160
- tests/test_rtn_opf.py,sha256=MmMNwb9-G0KzHcrrP4uHTvs9DBU71_XPIJqNnkQQPHo,4846
161
- tests/test_rtn_pflow.py,sha256=QLg0q89Tcb-rrncpiNw6phjMEnvzvExjGTrkqGliiak,4664
162
- tests/test_rtn_pypower.py,sha256=KO5VOZxETxVH2mY1mgNvzj1gz1Gdak1sAWxYleDU4E8,10477
163
- tests/test_rtn_rted.py,sha256=QHDUymorCqQAJKFlDgTy40JyLTGDvNVNU3tjbjDl3-0,9850
164
- tests/test_rtn_uc.py,sha256=UbMeaam3dZwgq2LAJokGOl3LT5B3TWKMjCp4dRcLs40,8497
165
- tests/test_service.py,sha256=6IP6CAH2xHxGHZM4-R8LjZxVJ2L10LcGaPDyRIqKLmc,2438
166
- ltbams-1.0.11.dist-info/METADATA,sha256=HJopLlES434MQhl_hg4DDQNs90TfSJLovZKG-NChtNs,13808
167
- ltbams-1.0.11.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
168
- ltbams-1.0.11.dist-info/entry_points.txt,sha256=FA56FlhO_yVNeEf810SrorVQb7_Xsmo3_EW-W-ijUfA,37
169
- ltbams-1.0.11.dist-info/top_level.txt,sha256=pyKDqG2kj13F9-BYd_wkruRdBSqLXw8Nwc-cmljqrxg,15
170
- ltbams-1.0.11.dist-info/RECORD,,
138
+ ltbams-1.0.13.dist-info/METADATA,sha256=Zlsv1ahEhFMTEJDWhCLAaek_J_nwX7v0i6HTKmZEY0w,14014
139
+ ltbams-1.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
140
+ ltbams-1.0.13.dist-info/entry_points.txt,sha256=FA56FlhO_yVNeEf810SrorVQb7_Xsmo3_EW-W-ijUfA,37
141
+ ltbams-1.0.13.dist-info/top_level.txt,sha256=5QQ_oDY9sa52MVmqCjqjUq07BssHOKmDSaQ8EZi6DOw,9
142
+ ltbams-1.0.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
tests/__init__.py DELETED
File without changes
tests/test_1st_system.py DELETED
@@ -1,64 +0,0 @@
1
- import unittest
2
-
3
- import ams
4
-
5
-
6
- class TestCodegen(unittest.TestCase):
7
- """
8
- Test code generation.
9
- """
10
-
11
- def test_1_docs(self) -> None:
12
- sp = ams.system.System()
13
- out = ''
14
- for tp in sp.types.values():
15
- out += tp.doc_all()
16
-
17
- out = ''
18
- for group in sp.groups.values():
19
- out += group.doc_all()
20
-
21
- def test_docum(self) -> None:
22
- sp = ams.load(ams.get_case('5bus/pjm5bus_demo.json'),
23
- setup=True, no_output=True)
24
- sp.DCOPF.init()
25
- docum = sp.DCOPF.docum
26
- for export in ['plain', 'rest']:
27
- docum._obj_doc(max_width=78, export=export)
28
- docum._constr_doc(max_width=78, export=export)
29
- docum._exprc_doc(max_width=78, export=export)
30
- docum._var_doc(max_width=78, export=export)
31
- docum._service_doc(max_width=78, export=export)
32
- docum._param_doc(max_width=78, export=export)
33
- docum.parent.config.doc(max_width=78, export=export)
34
-
35
-
36
- class TestParamCorrection(unittest.TestCase):
37
- """
38
- Test parameter correction.
39
- """
40
-
41
- def setUp(self) -> None:
42
- """
43
- Test setup.
44
- """
45
- self.ss = ams.load(ams.get_case('matpower/case14.m'),
46
- setup=False, no_output=True, default_config=True,)
47
-
48
- def test_line_correction(self):
49
- """
50
- Test line correction.
51
- """
52
- self.ss.Line.rate_a.v[5] = 0.0
53
- self.ss.Line.rate_b.v[6] = 0.0
54
- self.ss.Line.rate_c.v[7] = 0.0
55
- self.ss.Line.amax.v[8] = 0.0
56
- self.ss.Line.amin.v[9] = 0.0
57
-
58
- self.ss.setup()
59
-
60
- self.assertIsNot(self.ss.Line.rate_a.v[5], 0.0)
61
- self.assertIsNot(self.ss.Line.rate_b.v[6], 0.0)
62
- self.assertIsNot(self.ss.Line.rate_c.v[7], 0.0)
63
- self.assertIsNot(self.ss.Line.amax.v[8], 0.0)
64
- self.assertIsNot(self.ss.Line.amin.v[9], 0.0)
tests/test_addressing.py DELETED
@@ -1,40 +0,0 @@
1
- import unittest
2
- import numpy as np
3
-
4
- import ams
5
-
6
- ams.config_logger(stream_level=40)
7
-
8
-
9
- class TestAddressing(unittest.TestCase):
10
- """
11
- Tests for addressing.
12
- """
13
-
14
- def test_ieee14_address(self):
15
- """
16
- Test IEEE14 address.
17
- """
18
-
19
- # FIXME: why there will be case parsing information using ams.system.example()?
20
- ss = ams.system.example()
21
-
22
- # bus variable indices (internal)
23
- np.testing.assert_array_equal(ss.Bus.a.a,
24
- np.arange(0, ss.Bus.n, 1))
25
- np.testing.assert_array_equal(ss.Bus.v.a,
26
- np.arange(ss.Bus.n, 2*ss.Bus.n, 1))
27
-
28
- # external variable indices
29
- np.testing.assert_array_equal(ss.PV.ud.a,
30
- np.array([31, 32, 33, 34]))
31
- np.testing.assert_array_equal(ss.PV.p.a,
32
- np.array([35, 36, 37, 38]))
33
- np.testing.assert_array_equal(ss.PV.q.a,
34
- np.array([39, 40, 41, 42]))
35
- np.testing.assert_array_equal(ss.Slack.ud.a,
36
- np.array([28]))
37
- np.testing.assert_array_equal(ss.Slack.p.a,
38
- np.array([29]))
39
- np.testing.assert_array_equal(ss.Slack.q.a,
40
- np.array([30]))
tests/test_case.py DELETED
@@ -1,301 +0,0 @@
1
- import os
2
- import unittest
3
-
4
- import numpy as np
5
-
6
- import ams
7
- from ams.utils.paths import get_case
8
-
9
-
10
- class Test5Bus(unittest.TestCase):
11
- """
12
- Tests for the 5-bus system.
13
- """
14
-
15
- def setUp(self) -> None:
16
- self.ss = ams.main.load(
17
- get_case("5bus/pjm5bus_demo.json"),
18
- default_config=True,
19
- no_output=True,
20
- )
21
-
22
- def test_essential(self):
23
- """
24
- Test essential functionalities of Model and System.
25
- """
26
-
27
- # --- test model names
28
- self.assertTrue("Bus" in self.ss.models)
29
- self.assertTrue("PQ" in self.ss.models)
30
-
31
- nBus = 5
32
- nGen = 5
33
- nPQ = 3
34
- nArea = 3
35
- nZone = 5
36
- nDT = 24
37
- # --- test device counts
38
- self.assertEqual(self.ss.Bus.n, nBus)
39
- self.assertEqual(self.ss.PQ.n, nPQ)
40
- self.assertEqual(self.ss.PV.n, 4)
41
- self.assertEqual(self.ss.Slack.n, 1)
42
- self.assertEqual(self.ss.Line.n, 7)
43
- self.assertEqual(self.ss.Zone.n, nZone)
44
- self.assertEqual(self.ss.Area.n, nArea)
45
- self.assertEqual(self.ss.SFR.n, nArea)
46
- self.assertEqual(self.ss.SR.n, nArea)
47
- self.assertEqual(self.ss.NSR.n, nArea)
48
- self.assertEqual(self.ss.GCost.n, nGen)
49
- self.assertEqual(self.ss.DCost.n, nPQ)
50
- self.assertEqual(self.ss.SFRCost.n, nGen)
51
- self.assertEqual(self.ss.SRCost.n, nGen)
52
- self.assertEqual(self.ss.NSRCost.n, nGen)
53
- self.assertEqual(self.ss.EDTSlot.n, nDT)
54
- self.assertEqual(self.ss.UCTSlot.n, nDT)
55
-
56
- # test idx values
57
- self.assertSequenceEqual(self.ss.Bus.idx.v, [0, 1, 2, 3, 4])
58
- self.assertSequenceEqual(self.ss.Area.idx.v, [1, 2, 3])
59
-
60
- # test cache refreshing
61
- self.ss.Bus.cache.refresh() # used in ANDES but not in AMS
62
-
63
- # test conversion to dataframe
64
- self.ss.Bus.as_df()
65
- self.ss.Bus.as_df(vin=True)
66
-
67
- # test conversion to dataframe of ``Horizon`` model
68
- self.ss.EDTSlot.as_df()
69
- self.ss.EDTSlot.as_df(vin=True)
70
-
71
- self.ss.UCTSlot.as_df()
72
- self.ss.UCTSlot.as_df(vin=True)
73
-
74
- def test_pflow_reset(self):
75
- """
76
- Test resetting power flow.
77
- """
78
-
79
- self.ss.PFlow.run()
80
- self.ss.reset()
81
- self.ss.PFlow.run()
82
-
83
- def test_alter_param(self):
84
- """
85
- Test altering parameter for power flow.
86
- """
87
-
88
- self.ss.PV.alter("v0", "PV_3", 0.98)
89
- self.assertEqual(self.ss.PV.v0.v[1], 0.98)
90
- self.ss.PFlow.run()
91
-
92
- def test_alter_param_before_routine(self):
93
- """
94
- Test altering parameter before running routine.
95
- """
96
-
97
- self.ss.GCost.alter("c1", ['GCost_1', 'GCost_2'], [1500., 3100.])
98
- np.testing.assert_array_equal(self.ss.GCost.c1.v, [1500., 3100., 0.4, 0.1, 0.01])
99
- self.ss.ACOPF.run()
100
- np.testing.assert_array_equal(self.ss.GCost.c1.v, [1500., 3100., 0.4, 0.1, 0.01])
101
-
102
- def test_alter_param_after_routine(self):
103
- """
104
- Test altering parameter after running routine.
105
- """
106
-
107
- self.ss.ACOPF.run()
108
- self.ss.GCost.alter("c1", ['GCost_1', 'GCost_2'], [1500., 3100.])
109
- np.testing.assert_array_equal(self.ss.GCost.c1.v, [1500., 3100., 0.4, 0.1, 0.01])
110
- self.ss.ACOPF.run()
111
- np.testing.assert_array_equal(self.ss.GCost.c1.v, [1500., 3100., 0.4, 0.1, 0.01])
112
-
113
- # def test_multiple_disconnected_line(self):
114
- # """
115
- # Test connectivity check for systems with disconnected lines.
116
-
117
- # These disconnected lines (zeros) was not excluded when counting
118
- # connected buses, causing an out-of-bound error.
119
- # """
120
- # # TODO: need to add `connectivity` in `system`
121
- # pass
122
- # # self.ss.Line.u.v[[0, 6]] = 0
123
- # # self.ss.PFlow.run()
124
- # # self.assertEqual(len(self.ss.Bus.islands), 1)
125
- # # self.assertEqual(self.ss.Bus.n_islanded_buses, 0)
126
-
127
-
128
- class TestIEEE14RAW(unittest.TestCase):
129
- """
130
- Test IEEE14 system in the RAW format.
131
- """
132
-
133
- # TODO: after add `run` in `system`, improve this part
134
- def test_ieee14_raw(self):
135
- ss = ams.load(
136
- get_case("ieee14/ieee14.raw"),
137
- default_config=True,
138
- no_output=True,
139
- )
140
- ss.PFlow.run()
141
- self.assertEqual(ss.PFlow.exit_code, 0, "Exit code is not 0.")
142
-
143
- def test_ieee14_raw_convert(self):
144
- ss = ams.run(
145
- get_case("ieee14/ieee14.raw"),
146
- convert=True,
147
- default_config=True,
148
- )
149
- os.remove(ss.files.dump)
150
- self.assertEqual(ss.exit_code, 0, "Exit code is not 0.")
151
-
152
- def test_ieee14_raw2xlsx(self):
153
- ss = ams.load(
154
- get_case("ieee14/ieee14.raw"),
155
- setup=True,
156
- no_output=True,
157
- default_config=True,
158
- )
159
- ams.io.xlsx.write(ss, "ieee14.xlsx", overwrite=True)
160
- self.assertTrue(os.path.exists("ieee14.xlsx"))
161
- os.remove("ieee14.xlsx")
162
-
163
- def test_ieee14_raw2json(self):
164
- ss = ams.load(
165
- get_case("ieee14/ieee14.raw"),
166
- setup=True,
167
- no_output=True,
168
- default_config=True,
169
- )
170
- ams.io.json.write(ss, "ieee14.json", overwrite=True)
171
- self.assertTrue(os.path.exists("ieee14.json"))
172
- os.remove("ieee14.json")
173
-
174
- def test_ieee14_raw2json_convert(self):
175
- ss = ams.run(
176
- get_case("ieee14/ieee14.raw"),
177
- convert="json",
178
- default_config=True,
179
- )
180
-
181
- ss2 = ams.run(
182
- "ieee14.json",
183
- default_config=True,
184
- no_output=True,
185
- )
186
-
187
- os.remove(ss.files.dump)
188
- self.assertEqual(ss2.exit_code, 0, "Exit code is not 0.")
189
-
190
- def test_read_json_from_memory(self):
191
- fd = open(get_case("ieee14/ieee14.json"), "r")
192
-
193
- ss = ams.main.System(
194
- default_config=True,
195
- no_output=True,
196
- )
197
- ams.io.json.read(ss, fd)
198
- ss.setup()
199
- ss.PFlow.run()
200
-
201
- fd.close()
202
- self.assertEqual(ss.exit_code, 0, "Exit code is not 0.")
203
-
204
- def test_read_mpc_from_memory(self):
205
- fd = open(get_case("matpower/case14.m"), "r")
206
-
207
- ss = ams.main.System(
208
- default_config=True,
209
- no_output=True,
210
- )
211
- ams.io.matpower.read(ss, fd)
212
- ss.setup()
213
- ss.PFlow.run()
214
-
215
- fd.close()
216
- self.assertEqual(ss.exit_code, 0, "Exit code is not 0.")
217
-
218
- def test_read_psse_from_memory(self):
219
- fd_raw = open(get_case("ieee14/ieee14.raw"), "r")
220
-
221
- ss = ams.main.System(
222
- default_config=True,
223
- no_output=True,
224
- )
225
- # suppress out-of-normal info
226
- ss.config.warn_limits = 0
227
- ss.config.warn_abnormal = 0
228
-
229
- ams.io.psse.read(ss, fd_raw)
230
- ss.setup()
231
- ss.PFlow.run()
232
-
233
- fd_raw.close()
234
- self.assertEqual(ss.exit_code, 0, "Exit code is not 0.")
235
-
236
-
237
- class TestCaseInit(unittest.TestCase):
238
- """
239
- Test if initializations pass.
240
- """
241
-
242
- def test_ieee39_init(self):
243
- """
244
- Test if ieee39 initialization works.
245
- """
246
- ss = ams.load(
247
- get_case("ieee39/ieee39_uced.xlsx"),
248
- default_config=True,
249
- no_output=True,
250
- )
251
- ss.DCOPF.init()
252
- ss.RTED.init()
253
- ss.ED.init()
254
- ss.UC.init()
255
-
256
- self.assertEqual(ss.DCOPF.exit_code, 0, "Exit code is not 0.")
257
- self.assertEqual(ss.RTED.exit_code, 0, "Exit code is not 0.")
258
- self.assertEqual(ss.ED.exit_code, 0, "Exit code is not 0.")
259
- self.assertEqual(ss.UC.exit_code, 0, "Exit code is not 0.")
260
-
261
- def test_ieee39_esd1_init(self):
262
- """
263
- Test if ieee39 with ESD1 initialization works.
264
- """
265
- ss = ams.load(
266
- get_case("ieee39/ieee39_uced_esd1.xlsx"),
267
- default_config=True,
268
- no_output=True,
269
- )
270
- ss.EDES.init()
271
- ss.UCES.init()
272
-
273
- self.assertEqual(ss.EDES.exit_code, 0, "Exit code is not 0.")
274
- self.assertEqual(ss.UCES.exit_code, 0, "Exit code is not 0.")
275
-
276
-
277
- class TestCase14(unittest.TestCase):
278
- """
279
- Test parameter correction using case14.m
280
- """
281
-
282
- def test_parameter_correction(self):
283
- """
284
- Test if the parameter correction works.
285
- """
286
- mpc = ams.io.matpower.m2mpc(get_case("matpower/case14.m"))
287
- mpc['branch'][:, 11] = 0.0
288
- mpc['branch'][:, 12] = 0.0
289
-
290
- ss = ams.system.System()
291
- ams.io.matpower.mpc2system(mpc, ss)
292
- ss.setup()
293
-
294
- # line rate
295
- np.testing.assert_array_less(0.0, ss.Line.rate_a.v)
296
- np.testing.assert_array_less(0.0, ss.Line.rate_b.v)
297
- np.testing.assert_array_less(0.0, ss.Line.rate_c.v)
298
-
299
- # line angle difference
300
- np.testing.assert_array_less(0.0, ss.Line.amax.v)
301
- np.testing.assert_array_less(ss.Line.amin.v, 0.0)
tests/test_cli.py DELETED
@@ -1,34 +0,0 @@
1
- import unittest
2
- import os
3
-
4
- import ams.main
5
- import ams.cli
6
-
7
-
8
- class TestCLI(unittest.TestCase):
9
-
10
- def test_cli_parser(self):
11
- ams.cli.create_parser()
12
-
13
- def test_cli_preamble(self):
14
- ams.cli.preamble()
15
-
16
- def test_main_doc(self):
17
- ams.main.doc('Bus')
18
- ams.main.doc(list_supported=True)
19
-
20
- def test_versioninfo(self):
21
- ams.main.versioninfo()
22
-
23
- def test_misc(self):
24
- ams.main.misc(show_license=True)
25
- ams.main.misc(save_config=None, overwrite=True)
26
-
27
- def test_profile_run(self):
28
- _ = ams.main.run(ams.get_case('matpower/case5.m'),
29
- no_output=False,
30
- profile=True,)
31
- self.assertTrue(os.path.exists('case5_prof.prof'))
32
- self.assertTrue(os.path.exists('case5_prof.txt'))
33
- os.remove('case5_prof.prof')
34
- os.remove('case5_prof.txt')
tests/test_export_csv.py DELETED
@@ -1,89 +0,0 @@
1
- """
2
- Test routine export to CSV.
3
- """
4
- import unittest
5
- import os
6
- import csv
7
-
8
- import numpy as np
9
-
10
- import ams
11
-
12
-
13
- class TestExportCSV(unittest.TestCase):
14
- """
15
- Tests for Routine export to CSV.
16
- """
17
-
18
- def setUp(self) -> None:
19
- self.ss = ams.main.load(
20
- ams.get_case("5bus/pjm5bus_demo.json"),
21
- default_config=True,
22
- no_output=True,
23
- )
24
- self.expected_csv_DCOPF = 'pjm5bus_demo_DCOPF.csv'
25
- self.expected_csv_ED = 'pjm5bus_demo_ED.csv'
26
-
27
- def test_no_export(self):
28
- """
29
- Test no export when routine is not converged.
30
- """
31
- self.assertIsNone(self.ss.DCOPF.export_csv())
32
-
33
- def test_export_DCOPF(self):
34
- """
35
- Test export DCOPF to CSV.
36
- """
37
- self.ss.DCOPF.run(solver='CLARABEL')
38
- self.ss.DCOPF.export_csv()
39
- self.assertTrue(os.path.exists(self.expected_csv_DCOPF))
40
-
41
- n_rows = 0
42
- n_cols = 0
43
- with open(self.expected_csv_DCOPF, 'r') as csv_file:
44
- csv_reader = csv.reader(csv_file)
45
- for row in csv_reader:
46
- n_rows += 1
47
- # Check if this row has more columns than the previous rows
48
- if n_cols == 0 or len(row) > n_cols:
49
- n_cols = len(row)
50
-
51
- n_cols_expected = np.sum([v.owner.n for v in self.ss.DCOPF.vars.values()])
52
- n_cols_expected += np.sum([v.owner.n for v in self.ss.DCOPF.exprs.values()])
53
- n_cols_expected += np.sum([v.owner.n for v in self.ss.DCOPF.exprcs.values()])
54
- # cols number plus one for the index column
55
- self.assertEqual(n_cols, n_cols_expected + 1)
56
- # header row plus data row
57
- n_rows_expected = 2
58
- self.assertEqual(n_rows, n_rows_expected)
59
-
60
- os.remove(self.expected_csv_DCOPF)
61
-
62
- def test_export_ED(self):
63
- """
64
- Test export ED to CSV.
65
- """
66
- self.ss.ED.run(solver='CLARABEL')
67
- self.ss.ED.export_csv()
68
- self.assertTrue(os.path.exists(self.expected_csv_ED))
69
-
70
- n_rows = 0
71
- n_cols = 0
72
- with open(self.expected_csv_ED, 'r') as csv_file:
73
- csv_reader = csv.reader(csv_file)
74
- for row in csv_reader:
75
- n_rows += 1
76
- # Check if this row has more columns than the previous rows
77
- if n_cols == 0 or len(row) > n_cols:
78
- n_cols = len(row)
79
-
80
- n_cols_expected = np.sum([v.owner.n for v in self.ss.ED.vars.values()])
81
- n_cols_expected += np.sum([v.owner.n for v in self.ss.ED.exprs.values()])
82
- n_cols_expected += np.sum([v.owner.n for v in self.ss.ED.exprcs.values()])
83
- # cols number plus one for the index column
84
- self.assertEqual(n_cols, n_cols_expected + 1)
85
- # header row plus data row
86
- n_rows_expected = len(self.ss.ED.timeslot.v) + 1
87
- self.assertTrue(n_rows, n_rows_expected)
88
-
89
- os.remove(self.expected_csv_ED)