ltbams 1.0.3a1__py3-none-any.whl → 1.0.5__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 CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2025-02-02T08:55:36-0500",
11
+ "date": "2025-04-09T22:08:11-0400",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "8a697edc2d5ab9e5451fa1d4a5b2bec41d180d4c",
15
- "version": "1.0.3a1"
14
+ "full-revisionid": "115b1575b21ff871fe878121b3ca1cb6020b1a93",
15
+ "version": "1.0.5"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
ams/core/matprocessor.py CHANGED
@@ -485,25 +485,6 @@ class MatProcessor:
485
485
  If True, use UMFPACK as the solver. Effective only when (`incremental=True`)
486
486
  & (`line` contains a single line or `step` is 1). Default is True.
487
487
 
488
- Parameters
489
- ----------
490
- line: int, str, list, optional
491
- Lines index for which the PTDF is calculated. It takes both single
492
- or multiple line indices. Note that if `line` is given, the PTDF will
493
- not be stored in the MParam.
494
- no_store : bool, optional
495
- If False, the PTDF will be stored into `MatProcessor.PTDF._v`.
496
- incremental : bool, optional
497
- If True, the sparse PTDF will be calculated in chunks to save memory.
498
- step : int, optional
499
- Step for incremental calculation.
500
- no_tqdm : bool, optional
501
- If True, the progress bar will be disabled.
502
- permc_spec : str, optional
503
- How to permute the columns of the matrix for sparsity preservation. (default: 'COLAMD')
504
- use_umfpack : bool, optional
505
- If True, use UMFPACK as the solver. (default: True)
506
-
507
488
  Returns
508
489
  -------
509
490
  PTDF : np.ndarray or scipy.sparse.lil_matrix
ams/opt/exprcalc.py CHANGED
@@ -8,6 +8,8 @@ import re
8
8
 
9
9
  import numpy as np
10
10
 
11
+ from ams.shared import sps # NOQA
12
+
11
13
  import cvxpy as cp
12
14
 
13
15
  from ams.utils import pretty_long_message
@@ -68,7 +70,7 @@ class ExpressionCalc(OptzBase):
68
70
  msg = f" - Expression <{self.name}>: {self.code}"
69
71
  logger.debug(pretty_long_message(msg, _prefix, max_length=_max_length))
70
72
  try:
71
- local_vars = {'self': self, 'np': np, 'cp': cp}
73
+ local_vars = {'self': self, 'np': np, 'cp': cp, 'sps': sps}
72
74
  self.optz = self._evaluate_expression(self.code, local_vars=local_vars)
73
75
  except Exception as e:
74
76
  raise Exception(f"Error in evaluating ExpressionCalc <{self.name}>.\n{e}")
ams/routines/__init__.py CHANGED
@@ -11,6 +11,7 @@ all_routines = OrderedDict([
11
11
  ('cpf', ['CPF']),
12
12
  ('acopf', ['ACOPF']),
13
13
  ('dcopf', ['DCOPF']),
14
+ ('dcopf2', ['DCOPF2']),
14
15
  ('ed', ['ED', 'EDDG', 'EDES']),
15
16
  ('rted', ['RTED', 'RTEDDG', 'RTEDES', 'RTEDVIS']),
16
17
  ('uc', ['UC', 'UCDG', 'UCES']),
ams/routines/dcopf.py CHANGED
@@ -19,7 +19,11 @@ class DCOPF(DCPFBase):
19
19
  """
20
20
  DC optimal power flow (DCOPF).
21
21
 
22
- The nodal price is calculated as ``pi`` in ``pic``.
22
+ Notes
23
+ -----
24
+ 1. The nodal price is calculated as ``pi`` in ``pic``.
25
+ 1. Devices online status of `StaticGen`, `StaticLoad`, and `Shunt` are considered in the connectivity
26
+ matrices `Cft`, `Cg`, `Cl`, and `Csh`.
23
27
 
24
28
  References
25
29
  ----------
@@ -153,7 +157,7 @@ class DCOPF(DCPFBase):
153
157
  Parameters
154
158
  ----------
155
159
  kloss : float, optional
156
- The loss factor for the conversion. Defaults to 1.2.
160
+ The loss factor for the conversion. Defaults to 1.0.
157
161
  """
158
162
  exec_time = self.exec_time
159
163
  if self.exec_time == 0 or self.exit_code != 0:
ams/routines/dcopf2.py ADDED
@@ -0,0 +1,95 @@
1
+ """
2
+ DCOPF routines.
3
+ """
4
+ import logging
5
+
6
+ import numpy as np
7
+ from ams.core.param import RParam
8
+ from ams.core.service import NumOp
9
+
10
+ from ams.routines.dcopf import DCOPF
11
+ from ams.opt import ExpressionCalc
12
+
13
+ from ams.shared import sps
14
+
15
+
16
+ logger = logging.getLogger(__name__)
17
+
18
+
19
+ class DCOPF2(DCOPF):
20
+ """
21
+ DC optimal power flow (DCOPF) using PTDF.
22
+ For large cases, it is recommended to build the PTDF first, especially when incremental
23
+ build is necessary.
24
+
25
+ Notes
26
+ -----
27
+ 1. This routine requires PTDF matrix.
28
+ 1. Nodal price ``pi`` is calculated with three parts.
29
+ 1. Bus angle ``aBus`` is calculated after solving the problem.
30
+ """
31
+
32
+ def __init__(self, system, config):
33
+ DCOPF.__init__(self, system, config)
34
+ self.info = 'DCOPF using PTDF'
35
+ self.type = 'DCED'
36
+
37
+ # NOTE: in this way, we still follow the implementation that devices
38
+ # connectivity status is considered in connection matrix
39
+ self.ued = NumOp(u=self.Cl,
40
+ name='ued', tex_name=r'u_{e,d}',
41
+ info='Effective load connection status',
42
+ fun=np.sum, args=dict(axis=0),
43
+ no_parse=True)
44
+ self.uesh = NumOp(u=self.Csh,
45
+ name='uesh', tex_name=r'u_{e,sh}',
46
+ info='Effective shunt connection status',
47
+ fun=np.sum, args=dict(axis=0),
48
+ no_parse=True)
49
+
50
+ self.PTDF = RParam(info='PTDF',
51
+ name='PTDF', tex_name=r'P_{TDF}',
52
+ model='mats', src='PTDF',
53
+ no_parse=True, sparse=True)
54
+
55
+ # --- rewrite Expression plf: line flow---
56
+ self.plf.e_str = 'PTDF @ (Cg@pg - Cl@pd - Csh@gsh - Pbusinj)'
57
+
58
+ # --- rewrite nodal price ---
59
+ self.Cft = RParam(info='Line connection matrix',
60
+ name='Cft', tex_name=r'C_{ft}',
61
+ model='mats', src='Cft',
62
+ no_parse=True, sparse=True,)
63
+ self.pilb = ExpressionCalc(info='Congestion price, dual of <plflb>',
64
+ name='pilb',
65
+ model='Line', src=None,
66
+ e_str='plflb.dual_variables[0]')
67
+ self.piub = ExpressionCalc(info='Congestion price, dual of <plfub>',
68
+ name='piub',
69
+ model='Line', src=None,
70
+ e_str='plfub.dual_variables[0]')
71
+ self.pib = ExpressionCalc(info='Energy price, dual of <pb>',
72
+ name='pib',
73
+ model='Bus', src=None,
74
+ e_str='pb.dual_variables[0]')
75
+ pi = 'pb.dual_variables[0] + Cft@(plfub.dual_variables[0] - plflb.dual_variables[0])'
76
+ self.pi.e_str = pi
77
+
78
+ def _post_solve(self):
79
+ """Calculate aBus"""
80
+ super()._post_solve()
81
+ sys = self.system
82
+ Pbus = sys.mats.Cg._v @ self.pg.v
83
+ Pbus -= sys.mats.Cl._v @ self.pd.v
84
+ Pbus -= sys.mats.Csh._v @ self.gsh.v
85
+ Pbus -= self.Pbusinj.v
86
+ aBus = sps.linalg.spsolve(sys.mats.Bbus._v, Pbus)
87
+ slack0_uid = sys.Bus.idx2uid(sys.Slack.bus.v[0])
88
+ self.aBus.v = aBus - aBus[slack0_uid]
89
+ return super()._post_solve()
90
+
91
+ def init(self, **kwargs):
92
+ if self.system.mats.PTDF._v is None:
93
+ logger.warning('PTDF is not available, build it now')
94
+ self.system.mats.build_ptdf()
95
+ return super().init(**kwargs)
ams/routines/routine.py CHANGED
@@ -585,6 +585,8 @@ class RoutineBase:
585
585
  True to rebuild the system matrices. Set to False to speed up the process
586
586
  if no system matrices are changed.
587
587
  """
588
+ if not self.initialized:
589
+ return self.init()
588
590
  t0, _ = elapsed()
589
591
  re_finalize = False
590
592
  # sanitize input
@@ -31,4 +31,5 @@ folder of the repository
31
31
 
32
32
  ../_examples/demo/demo_ESD1.ipynb
33
33
  ../_examples/demo/demo_AGC.ipynb
34
- ../_examples/demo/demo_debug.ipynb
34
+ ../_examples/demo/demo_debug.ipynb
35
+ ../_examples/demo/demo_mat.ipynb
@@ -6,17 +6,29 @@ Release notes
6
6
 
7
7
  The APIs before v3.0.0 are in beta and may change without prior notice.
8
8
 
9
- Pre-v1.0.0
9
+ v1.0
10
10
  ==========
11
11
 
12
- v1.0.3 (2024-xx-xx)
12
+ v1.0.5 (2024-04-09)
13
+ --------------------
14
+
15
+ - Include sensitivity matrices calculation demo in documentation
16
+ - Add ``DCOPF2``, a PTDF-based DCOPF routine
17
+ - Fix bug when update routine parameters before it is initialized
18
+
19
+ v1.0.4 (2024-04-05)
20
+ --------------------
13
21
 
22
+ - Fix format in release notes
23
+ - Add badges of GitHub relesase and commits in README
24
+ - Add a demo to show sensitivity matrices calculation
25
+
26
+ v1.0.3 (2024-03-17)
14
27
  --------------------
15
28
 
16
29
  - Bug fix in function ``ams.interface.parse_addfile``, released in v1.0.3a1
17
30
 
18
31
  v1.0.2 (2024-02-01)
19
-
20
32
  --------------------
21
33
 
22
34
  - Enhance the GitHub Actions workflow file
@@ -41,6 +53,9 @@ v1.0.0 (2024-01-24)
41
53
  - Deprecate method ``get_idx`` and suggest using ``get_all_idxes`` instead
42
54
  - Remove module ``benchmarks.py`` and its tests for simplicity
43
55
 
56
+ Pre-v1.0
57
+ ==========
58
+
44
59
  v0.9.13 (2024-12-05)
45
60
  --------------------
46
61
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ltbams
3
- Version: 1.0.3a1
3
+ Version: 1.0.5
4
4
  Summary: Python software for scheduling modeling and co-simulation with dynamics.
5
5
  Home-page: https://github.com/CURENT/ams
6
6
  Author: Jinning Wang
@@ -33,11 +33,17 @@ Python Software for Power System Scheduling Modeling and Co-Simulation with Dyna
33
33
  [![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-blue.svg)](https://github.com/CURENT/ams/blob/master/LICENSE)
34
34
  ![platforms](https://anaconda.org/conda-forge/ltbams/badges/platforms.svg)
35
35
  [![Python Versions](https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/)
36
+ [![DOI:10.1109/TSTE.2025.3528027](https://zenodo.org/badge/DOI/10.1109/TSTE.2025.3528027.svg)](https://ieeexplore.ieee.org/document/10836855)
36
37
  [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
37
- ![Repo Size](https://img.shields.io/github/repo-size/CURENT/ams)
38
+ [![codecov](https://codecov.io/gh/CURENT/ams/graph/badge.svg?token=RZI5GLLBQH)](https://codecov.io/gh/CURENT/ams)
39
+
40
+ [![GitHub Tag](https://img.shields.io/github/v/tag/CURENT/ams)](https://github.com/CURENT/ams/tags)
41
+ ![GitHub commits since latest release (branch)](https://img.shields.io/github/commits-since/curent/ams/latest/develop)
38
42
  [![GitHub last commit (master)](https://img.shields.io/github/last-commit/CURENT/ams/master?label=last%20commit%20to%20master)](https://github.com/CURENT/ams/commits/master/)
39
43
  [![GitHub last commit (develop)](https://img.shields.io/github/last-commit/CURENT/ams/develop?label=last%20commit%20to%20develop)](https://github.com/CURENT/ams/commits/develop/)
44
+
40
45
  [![libraries](https://img.shields.io/librariesio/release/pypi/ltbams)](https://libraries.io/pypi/ltbams)
46
+ ![Repo Size](https://img.shields.io/github/repo-size/CURENT/ams)
41
47
  [![Structure](https://img.shields.io/badge/code_base-visualize-blue)](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=CURENT%2Fams)
42
48
 
43
49
  [![Compatibility Tests](https://github.com/CURENT/ams/actions/workflows/compatibility.yml/badge.svg)](https://github.com/CURENT/ams/actions/workflows/compatibility.yml)
@@ -146,7 +152,7 @@ pip install git+https://github.com/CURENT/ams.git
146
152
  - `cvxpy` is distributed with the open source solvers CLARABEL, OSQP, and SCS, but MIP-capable solvers need separate installation
147
153
  - `cvxpy` versions **below 1.5** are incompatible with `numpy` versions **2.0 and above**
148
154
  - If the solver `SCIP` encounters an import error caused by a missing `libscip.9.1.dylib`, try reinstalling its Python interface by running `pip install pyscipopt --no-binary scip --force`
149
- - `kvxopt` is recommended to install via `conda` as sometimes ``pip`` struggles to set the correct path for compiled libraries
155
+ - `kvxopt` is recommended to install via `conda` as sometimes ``pip`` struggles to set the correct path for compiled libraries, more detailes can be found in this closed issue [Bug with dependency kvxopt 1.3.2.0](https://github.com/CURENT/andes/issues/508)
150
156
  - Versions **1.0.0** and **1.0.1** are only available on PyPI
151
157
  - Version **0.9.9** has known issues and has been yanked from PyPI
152
158
 
@@ -212,4 +218,4 @@ Some commercial solvers provide academic licenses, such as COPT, GUROBI, CPLEX,
212
218
  [Binder]: https://mybinder.org/v2/gh/curent/ams/master
213
219
  [LTB Repository]: https://github.com/CURENT
214
220
  [benchmark]: https://github.com/CURENT/demo/tree/master/demo/ams_benchmark
215
- [paper]: https://ieeexplore.ieee.org/document/9169830
221
+ [paper]: https://ieeexplore.ieee.org/document/10836855
@@ -1,6 +1,6 @@
1
1
  ams/__init__.py,sha256=dKIwng8xES4NQHn6ZHy8RCKeXphN9z2wyfmbvniIEg0,351
2
2
  ams/__main__.py,sha256=EB4GfGiKgvnQ_psNr0QwPoziYvjmGvQ2yVsBwQtfrLw,170
3
- ams/_version.py,sha256=jA4hGqiTxLiBPzRLM8URDRE3F6wZ9myl6bTEt2GKIkQ,499
3
+ ams/_version.py,sha256=fHaf3d1VKT7Y8k0GYj2TxX2ZeGzQ92qYr2or0jwPTXM,497
4
4
  ams/cli.py,sha256=EyNFXn565gFCppTxpyTZviBdPgUuKtgAPZ4WE6xewRk,6164
5
5
  ams/interface.py,sha256=PCR9geO-pvCxXxljWP4u3M-BAdVD5DjA3xvf338g9x8,44487
6
6
  ams/main.py,sha256=wzKLe_BeQAUyFh-U1cxQIOwr-rAJM8ppB3EEi6_v2tw,23607
@@ -38,7 +38,7 @@ ams/cases/wecc/wecc.m,sha256=8Wqal6H5r1wNxLLQBCXo2V3v3JZY5IJDEkyrEGCrCWE,30498
38
38
  ams/cases/wecc/wecc_uced.xlsx,sha256=R3tZgxEqz_ctKcjA1wwFecxn-QZXutvf7NzgnCg_078,94767
39
39
  ams/core/__init__.py,sha256=OUJFLACc9Ggjvzi6DZfmfxrzciRcGtpLTsBfdbOUxGg,80
40
40
  ams/core/documenter.py,sha256=FNkpiP65iO809B4Bgmp5C1QeJTQHi-sS9vTP7Wd9D8Q,23131
41
- ams/core/matprocessor.py,sha256=R3nsA3irZz4cTQMQxE0TXWw9-LucW9PsEMmphA80xns,27608
41
+ ams/core/matprocessor.py,sha256=fkfEE2-PcIuwgeDujyWdW-KNf-JUFhIAOkoWqMAHbnw,26700
42
42
  ams/core/model.py,sha256=vXLActAi9tLXRCNd5RrEMVWvF0Wt4mwltiRY5CjgrP4,10928
43
43
  ams/core/param.py,sha256=LPH48xUHyqWqODD6IsiamUtkJDDSgGCEMAo6vroFoHE,11130
44
44
  ams/core/service.py,sha256=bCeBKoVBd42UVGvjP1dU6DpP6LBW5FGWq3bbOHYSlCI,27984
@@ -74,7 +74,7 @@ ams/models/static/gen.py,sha256=CZepvqhjmlGWkUwP3goiimvhZx04L2ADzzx1aVbfdDg,6685
74
74
  ams/models/static/pq.py,sha256=Ky6vcc_G7K46azn4-xBJD-6Rht_3y6r7gkSpFNXWIx0,2583
75
75
  ams/opt/__init__.py,sha256=INsl8yxtOzTKqV9pzVxlL6RSGDRaUDwxpZMY1QROrF4,459
76
76
  ams/opt/constraint.py,sha256=ERT9zwjQyGkvDo465Yd0wBexlIhjVmw0MyWq4BWnWoI,5534
77
- ams/opt/exprcalc.py,sha256=6g_d4aYEvy9uxikEwhGE6cqL4wElD3KQmtScYSAHW68,3887
77
+ ams/opt/exprcalc.py,sha256=oVtjNHzdWvYHV-8PdRehAxjledsQxpxatdNgMLeWS5o,3935
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
@@ -102,17 +102,18 @@ ams/pypower/routines/cpf_callbacks.py,sha256=93f3sdibG7FsXOP9EmqX-iTe0_eZmGtH1Jh
102
102
  ams/pypower/routines/opf.py,sha256=SNklP0cC8qu-ji1vluEj7DjAtvWDneOEkZWZeMBdd5g,73447
103
103
  ams/pypower/routines/opffcns.py,sha256=o8EpvWH32x3vbN9gV7Xi-D6RHQ5V2eB8NT15cZrwX2w,78144
104
104
  ams/pypower/routines/pflow.py,sha256=q5RFZ5XuB5YQZk1jpJ5aTUB3DfgPJEGsvWyLDNo5PJo,30697
105
- ams/routines/__init__.py,sha256=hB0Nr9RWjnp7Jx2Xria0JpRyIlbIIDEcLwXHqF9v0ug,612
105
+ ams/routines/__init__.py,sha256=idfPyMhFr0hkUZjcAEQw14JA5zPHeFe3Vl3p4DCJ5d0,640
106
106
  ams/routines/acopf.py,sha256=VZC3qs1G7zE--6XxE_wXv432nj3SV5hcrR8967ogYlg,3835
107
107
  ams/routines/cpf.py,sha256=xsrUVjtGQ1b7UCXpwwYihqzTeEGJJKnO9LlX1Tz9Tks,1552
108
- ams/routines/dcopf.py,sha256=cOkqXnSD70QthATeggZUF5c_1tRskzTq2z9ODmsA1JA,10898
108
+ ams/routines/dcopf.py,sha256=6qI1nDf8LepgaHL9HnP1y6a5lGsJAWKQaL7wD7WLbJU,11070
109
+ ams/routines/dcopf2.py,sha256=EtzA1ZQVO4KGVoRdhagV8aIipecWJnXvHYeYTCfgMos,3620
109
110
  ams/routines/dcpf.py,sha256=SswIb7t37ulxe1rjroA7oSa6z01kYjO-x8P1WWOUutM,8237
110
111
  ams/routines/dcpf0.py,sha256=gPPfSUzzJbHz_gAEFVyZ3iriEHvLJ-OGpTzhza8FOkA,6811
111
112
  ams/routines/dopf.py,sha256=yIn4tdxgb_phdvlHn4kMT9dUP0c_0Lu5kFfyCAUG-tk,6241
112
113
  ams/routines/ed.py,sha256=eNo-edm8qNrQCl9aHqBoIPDF6ltH65L7IobghoK7uH4,11646
113
114
  ams/routines/pflow.py,sha256=I4lyXDyprkg_0j3gY5bdkkBA5ImSjnouMzRnuG1yKb8,9435
114
115
  ams/routines/pflow0.py,sha256=xocLw94jcl2hh3WwnS_mdUW6dsm3EVjvZptVb814GdE,3521
115
- ams/routines/routine.py,sha256=QoYxjpItxb7fgPajLoMlGH_TFFgIKgg8Ohhf_WP_SIk,35868
116
+ ams/routines/routine.py,sha256=I98uMg6QCt6bipNYwdgtNMbdw_gWCSNVGokS4UmvkSk,35932
116
117
  ams/routines/rted.py,sha256=BWq2XCYP99siBiLNMF0oKiUmxsCAypBPYxTNeCsjz8Y,22197
117
118
  ams/routines/type.py,sha256=lvTWSnCYIbRJXIm3HX6jA0Hv-WWYusTOUPfoW8DITlU,3877
118
119
  ams/routines/uc.py,sha256=kkYicT1zjD_JmL3HQFe4iBedri1OAHO9-skzjiW21Fc,15625
@@ -126,12 +127,12 @@ docs/source/conf.py,sha256=ozLsGWVbFOZZfruXlvL6ou8i-R8kyCYZedtDzSQVRoU,6688
126
127
  docs/source/genmodelref.py,sha256=IhmF7bDw8BXPvLD8V3WjQNrfc-H07r5iS-_4DHbbp-8,1420
127
128
  docs/source/genroutineref.py,sha256=0JyMc2kV5bWrWbSoO6d7o4QgDgG8mVy3JGGQWacJypw,1064
128
129
  docs/source/index.rst,sha256=N5phQS5RIyYs-NZo_5yYB8LjvHzOKLeXzRA-M8i-g3Q,2688
129
- docs/source/release-notes.rst,sha256=Xna3XJePxxdJxoSAUXQJXwwfKhug0AqQH4OERU3qAxw,12712
130
+ docs/source/release-notes.rst,sha256=se_oKj_P3jyvKEDmnttAv78pmSpvKBjpZLMUg7B8_Q0,13125
130
131
  docs/source/_templates/autosummary/base.rst,sha256=zl3U4baR4a6YjsHyT-x9zCOrHwKZOVUdWn1NPX2u3bc,106
131
132
  docs/source/_templates/autosummary/class.rst,sha256=Hv_igCsLsUpM62_zN0nqj6FSfKnS5xLyu8ZldMbfOAk,668
132
133
  docs/source/_templates/autosummary/module.rst,sha256=YdbpCudOrEU-JbuSlzGvcOI2hn_KrCM6FW5HcGqkaEE,1113
133
134
  docs/source/_templates/autosummary/module_toctree.rst,sha256=sg30OdqFDLyo8Y3hl9V-s2BXb1bzcjjqqWaWi-C3qFM,1126
134
- docs/source/examples/index.rst,sha256=u6-pMB5ecSpNb3x1QWC6tJ8ACh3M6MjLBc4CVFf2z_0,876
135
+ docs/source/examples/index.rst,sha256=6yYgETu_4VQ9x8Jmff5i6pXX4_DLrLpSIRIidhVvqPA,912
135
136
  docs/source/getting_started/copyright.rst,sha256=XBfWvLm7T8p-zh1jkDy1kODvTDcH73AEV_vkiN32A2o,715
136
137
  docs/source/getting_started/index.rst,sha256=mcp1NdUwbPoNzpn7Owf5Qzfd6J_--ToU52PjmrbwjBY,1512
137
138
  docs/source/getting_started/install.rst,sha256=gE4L0ApiC_mwbjbYtkGW4ilyIAu_Jn-VIeoYlgRiOIw,7268
@@ -175,14 +176,15 @@ tests/test_report.py,sha256=B2_ugz5gzF4mDdiba498DrkK9hX4Zfa6KUGW54yCGVE,8069
175
176
  tests/test_repr.py,sha256=g7MRdxLcZRI1PlREFdUG_npp0LkcQiJZfOPw1aq0EFM,570
176
177
  tests/test_routine.py,sha256=gblLHBQ3DJgYiSGsqGdIGnn-CuEZAEnq9CqhqN5m608,6234
177
178
  tests/test_rtn_dcopf.py,sha256=LOfAVFzl2t6oTqTmWhmstu1j9FnpzHxdrplbmb3Y6Mc,3660
179
+ tests/test_rtn_dcopf2.py,sha256=g0MOW8J6WPJPQAV3Xwufa3dWEEeH-cQDErzvb-cq8lE,3747
178
180
  tests/test_rtn_dcpf.py,sha256=QC6F_4LOZ7mrWOEM3s6a6j-eUDM_n49MQouPIR6fzR0,2555
179
181
  tests/test_rtn_ed.py,sha256=2CO0kg3LEN8q75_4Z0cgGz4DTOPUjRHur6Dbfw2tRLQ,10173
180
182
  tests/test_rtn_pflow.py,sha256=aDL5Ewm6lWqpdHqIIu-DTllhXzt4bMjsLJaKbJa8sXQ,6990
181
183
  tests/test_rtn_rted.py,sha256=AyW5B4A51L_nIVLX1eYeu9ZUboOh1CH2FVj2C1XJjSc,9769
182
184
  tests/test_rtn_uc.py,sha256=vdG2ss3q91CXLZ2sUgzoUr1NU-63ue7nOxAYywMordE,8286
183
185
  tests/test_service.py,sha256=8YIa_PXurwgOzsWvUqoyqS_AzlpdrKHIMxAln5fIqCU,2438
184
- ltbams-1.0.3a1.dist-info/METADATA,sha256=zvi17maPhlfJkiEqd-5cxzN7ussINfOaCHJ7_8CdF4o,13417
185
- ltbams-1.0.3a1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
186
- ltbams-1.0.3a1.dist-info/entry_points.txt,sha256=FA56FlhO_yVNeEf810SrorVQb7_Xsmo3_EW-W-ijUfA,37
187
- ltbams-1.0.3a1.dist-info/top_level.txt,sha256=pyKDqG2kj13F9-BYd_wkruRdBSqLXw8Nwc-cmljqrxg,15
188
- ltbams-1.0.3a1.dist-info/RECORD,,
186
+ ltbams-1.0.5.dist-info/METADATA,sha256=Ozov3I100t3YStip3CYXb56cb96APz1juduPF1P2YnY,14023
187
+ ltbams-1.0.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
188
+ ltbams-1.0.5.dist-info/entry_points.txt,sha256=FA56FlhO_yVNeEf810SrorVQb7_Xsmo3_EW-W-ijUfA,37
189
+ ltbams-1.0.5.dist-info/top_level.txt,sha256=pyKDqG2kj13F9-BYd_wkruRdBSqLXw8Nwc-cmljqrxg,15
190
+ ltbams-1.0.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,103 @@
1
+ import unittest
2
+ import numpy as np
3
+
4
+ import ams
5
+
6
+
7
+ class TestDCOPF2(unittest.TestCase):
8
+ """
9
+ Test routine `DCOPF2`.
10
+ """
11
+
12
+ def setUp(self) -> None:
13
+ self.ss = ams.load(ams.get_case("5bus/pjm5bus_demo.xlsx"),
14
+ setup=True, default_config=True, no_output=True)
15
+ # decrease load first
16
+ self.ss.PQ.set(src='p0', attr='v', idx=['PQ_1', 'PQ_2'], value=[0.3, 0.3])
17
+ # build PTDF
18
+ self.ss.mats.build_ptdf()
19
+
20
+ def test_init(self):
21
+ """
22
+ Test initialization.
23
+ """
24
+ self.ss.DCOPF2.init()
25
+ self.assertTrue(self.ss.DCOPF2.initialized, "DCOPF2 initialization failed!")
26
+
27
+ def test_trip_gen(self):
28
+ """
29
+ Test generator tripping.
30
+ """
31
+ stg = 'PV_1'
32
+ self.ss.StaticGen.set(src='u', idx=stg, attr='v', value=0)
33
+
34
+ self.ss.DCOPF2.update()
35
+ self.ss.DCOPF2.run(solver='CLARABEL')
36
+ self.assertTrue(self.ss.DCOPF2.converged, "DCOPF2 did not converge under generator trip!")
37
+ self.assertAlmostEqual(self.ss.DCOPF2.get(src='pg', attr='v', idx=stg),
38
+ 0, places=6,
39
+ msg="Generator trip does not take effect!")
40
+
41
+ self.ss.StaticGen.set(src='u', idx=stg, attr='v', value=1) # reset
42
+
43
+ def test_trip_line(self):
44
+ """
45
+ Test line tripping.
46
+ """
47
+ self.ss.Line.set(src='u', attr='v', idx='Line_3', value=0)
48
+
49
+ self.ss.DCOPF2.update()
50
+ self.ss.DCOPF2.run(solver='CLARABEL')
51
+ self.assertTrue(self.ss.DCOPF2.converged, "DCOPF2 did not converge under line trip!")
52
+ self.assertAlmostEqual(self.ss.DCOPF2.get(src='plf', attr='v', idx='Line_3'),
53
+ 0, places=6,
54
+ msg="Line trip does not take effect!")
55
+
56
+ self.ss.Line.alter(src='u', idx='Line_3', value=1) # reset
57
+
58
+ def test_set_load(self):
59
+ """
60
+ Test setting and tripping load.
61
+ """
62
+ # --- run DCOPF2 ---
63
+ self.ss.DCOPF2.run(solver='CLARABEL')
64
+ pgs = self.ss.DCOPF2.pg.v.sum()
65
+
66
+ # --- set load ---
67
+ self.ss.PQ.set(src='p0', attr='v', idx='PQ_1', value=0.1)
68
+ self.ss.DCOPF2.update()
69
+
70
+ self.ss.DCOPF2.run(solver='CLARABEL')
71
+ pgs_pqt = self.ss.DCOPF2.pg.v.sum()
72
+ self.assertLess(pgs_pqt, pgs, "Load set does not take effect!")
73
+
74
+ # --- trip load ---
75
+ self.ss.PQ.set(src='u', attr='v', idx='PQ_2', value=0)
76
+ self.ss.DCOPF2.update()
77
+
78
+ self.ss.DCOPF2.run(solver='CLARABEL')
79
+ pgs_pqt2 = self.ss.DCOPF2.pg.v.sum()
80
+ self.assertLess(pgs_pqt2, pgs_pqt, "Load trip does not take effect!")
81
+
82
+ def test_dc2ac(self):
83
+ """
84
+ Test `DCOPF2.dc2ac()` method.
85
+ """
86
+ self.ss.DCOPF2.run(solver='CLARABEL')
87
+ self.ss.DCOPF2.dc2ac()
88
+ self.assertTrue(self.ss.DCOPF2.converted, "AC conversion failed!")
89
+ self.assertTrue(self.ss.DCOPF2.exec_time > 0, "Execution time is not greater than 0.")
90
+
91
+ stg_idx = self.ss.StaticGen.get_all_idxes()
92
+ pg_dcopf = self.ss.DCOPF2.get(src='pg', attr='v', idx=stg_idx)
93
+ pg_acopf = self.ss.ACOPF.get(src='pg', attr='v', idx=stg_idx)
94
+ np.testing.assert_almost_equal(pg_dcopf, pg_acopf, decimal=3)
95
+
96
+ bus_idx = self.ss.Bus.get_all_idxes()
97
+ v_dcopf = self.ss.DCOPF2.get(src='vBus', attr='v', idx=bus_idx)
98
+ v_acopf = self.ss.ACOPF.get(src='vBus', attr='v', idx=bus_idx)
99
+ np.testing.assert_almost_equal(v_dcopf, v_acopf, decimal=3)
100
+
101
+ a_dcopf = self.ss.DCOPF2.get(src='aBus', attr='v', idx=bus_idx)
102
+ a_acopf = self.ss.ACOPF.get(src='aBus', attr='v', idx=bus_idx)
103
+ np.testing.assert_almost_equal(a_dcopf, a_acopf, decimal=3)