fpowerkit 0.2.0rc0__tar.gz → 0.2.2__tar.gz
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.
- fpowerkit-0.2.2/PKG-INFO +50 -0
- fpowerkit-0.2.2/README.md +62 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/__init__.py +2 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/grid.py +3 -3
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/solbase.py +2 -1
- fpowerkit-0.2.2/fpowerkit/solcmb.py +46 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/soldist.py +43 -27
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/soldss.py +18 -10
- fpowerkit-0.2.2/fpowerkit/solgcal.py +132 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/solnt.py +1 -1
- fpowerkit-0.2.2/fpowerkit.egg-info/PKG-INFO +50 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit.egg-info/SOURCES.txt +2 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit.egg-info/requires.txt +0 -2
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/setup.py +2 -2
- fpowerkit-0.2.0rc0/PKG-INFO +0 -30
- fpowerkit-0.2.0rc0/README.md +0 -44
- fpowerkit-0.2.0rc0/fpowerkit.egg-info/PKG-INFO +0 -30
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/LICENSE +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/bus.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/cases.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/ess.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/gen.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/line.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/pvwind.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit/utils.py +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit.egg-info/dependency_links.txt +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/fpowerkit.egg-info/top_level.txt +0 -0
- {fpowerkit-0.2.0rc0 → fpowerkit-0.2.2}/setup.cfg +0 -0
fpowerkit-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: fpowerkit
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: A Distflow PDN solver based on Gurobi.
|
|
5
|
+
Author: fmy_xfk
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: feasytools>=0.0.21
|
|
13
|
+
Requires-Dist: numpy>=1.20.0
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# FPowerKit - A power distribution network calculation component
|
|
23
|
+
|
|
24
|
+
This is a package designed for power distribution network solving.
|
|
25
|
+
|
|
26
|
+
This package is affiliated to V2Sim, an open-aource microscopic V2G simulation platform in urban power and transportation network. If you are using the modified DistFlow model in this package, please cite the [paper](https://ieeexplore.ieee.org/document/10970754):
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
@ARTICLE{10970754,
|
|
30
|
+
author={Qian, Tao and Fang, Mingyu and Hu, Qinran and Shao, Chengcheng and Zheng, Junyi},
|
|
31
|
+
journal={IEEE Transactions on Smart Grid},
|
|
32
|
+
title={V2Sim: An Open-Source Microscopic V2G Simulation Platform in Urban Power and Transportation Network},
|
|
33
|
+
year={2025},
|
|
34
|
+
pages={1-1},
|
|
35
|
+
keywords={Vehicle-to-grid;Partial discharges;Microscopy;Batteries;Planning;Discharges (electric);Optimization;Vehicle dynamics;Transportation;Roads;EV charging load simulation;microscopic EV behavior;Vehicle-to-grid;charging station fault sensing},
|
|
36
|
+
doi={10.1109/TSG.2025.3560976}}
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
There are 3 modes for this package to work:
|
|
41
|
+
|
|
42
|
+
- Optimal power flow (OPF): Use cvxpy to solve the optimal power flow and determine the output of the generators.
|
|
43
|
+
|
|
44
|
+
- Power flow calculation: Use OpenDSS/GridCal/Inner Newton-Raphson method to solve the power flow.
|
|
45
|
+
|
|
46
|
+
- Hybrid: Use OPF to determine the initial value, and then use OpenDSS/GridCal/Inner Newton-Raphson to perform accurate calculation.
|
|
47
|
+
|
|
48
|
+
Since this package is still under development, the API is unstable and may be changed anytime.
|
|
49
|
+
|
|
50
|
+
Please visit https://gitee.com/fmy_xfk/fpowerkit to read the detailed introduction and the usage.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# FPowerKit 配电网运算组件
|
|
2
|
+
**本仓库已上线PyPI**,您可以通过`pip install fpowerkit`直接以Python包的形式安装使用本仓库的代码!
|
|
3
|
+
|
|
4
|
+
这个项目是[V2Sim](https://gitee.com/fmy_xfk/v2sim)的附属项目。V2Sim的论文请见如下链接
|
|
5
|
+
|
|
6
|
+
- 正式版:https://ieeexplore.ieee.org/document/10970754
|
|
7
|
+
|
|
8
|
+
- 早期版本:https://arxiv.org/abs/2412.09808
|
|
9
|
+
|
|
10
|
+
如果你正在使用本项目中的**改进配电网DistFlow模型**,请引用[V2Sim正式版论文](https://ieeexplore.ieee.org/document/10970754):
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
@ARTICLE{10970754,
|
|
14
|
+
author={Qian, Tao and Fang, Mingyu and Hu, Qinran and Shao, Chengcheng and Zheng, Junyi},
|
|
15
|
+
journal={IEEE Transactions on Smart Grid},
|
|
16
|
+
title={V2Sim: An Open-Source Microscopic V2G Simulation Platform in Urban Power and Transportation Network},
|
|
17
|
+
year={2025},
|
|
18
|
+
pages={1-1},
|
|
19
|
+
keywords={Vehicle-to-grid;Partial discharges;Microscopy;Batteries;Planning;Discharges (electric);Optimization;Vehicle dynamics;Transportation;Roads;EV charging load simulation;microscopic EV behavior;Vehicle-to-grid;charging station fault sensing},
|
|
20
|
+
doi={10.1109/TSG.2025.3560976}}
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
IEEE33和IEEE69节点的配网数据从公开渠道收集。除配网数据以外,本仓库代码均遵循LGPL3.0协议使用。
|
|
25
|
+
|
|
26
|
+
## 简介
|
|
27
|
+
- 依赖于feasytools和numpy: `pip install feasytools numpy`(请自行安装Gurobi并申请许可证)
|
|
28
|
+
- 包含电网的描述(含母线、发电机、线路、光伏、风机和储能等)和改进配电网DistFlow模型求解。
|
|
29
|
+
- 优化目标为“发电成本最小”。发电成本模型为二次函数$f(x)=ax^2+bx+c$或者一次函数$f(x)=bx+c$。
|
|
30
|
+
- 内含IEEE 33节点配电网和IEEE 69节点配电网,可通过以下方式快速创建:
|
|
31
|
+
```py
|
|
32
|
+
from fpowerkit import PDNCases
|
|
33
|
+
grid_obj33 = PDNCases.IEEE33()
|
|
34
|
+
grid_obj69 = PDNCases.IEEE69()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 使用
|
|
38
|
+
|
|
39
|
+
克隆本仓库,并输入以下命令开始求解:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
python main.py -g cases/33base.xml
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
请注意上述命令不适用于pip安装的版本。
|
|
46
|
+
|
|
47
|
+
`33base`描述了IEEE 33节点配电网模型。换成`3nodes`则是一个极简版3节点辐射形配电网模型,结构如下:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
G0 G1
|
|
51
|
+
| |
|
|
52
|
+
B0->B1->B2
|
|
53
|
+
| |
|
|
54
|
+
L1 L2
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
您也换成自己的配电网文件来求解,例如`python main.py -g path/to/your_case.xml`
|
|
58
|
+
|
|
59
|
+
## 配电网文件格式
|
|
60
|
+
[XML格式](docs/xml_file.md)
|
|
61
|
+
|
|
62
|
+
ZIP格式已经不再支持。
|
|
@@ -91,13 +91,13 @@ class Grid:
|
|
|
91
91
|
self._ladjfb[line.fBus].append(line)
|
|
92
92
|
self._ladjtb[line.tBus].append(line)
|
|
93
93
|
for gen in self._gens.values():
|
|
94
|
-
assert gen.BusID in self._bnames
|
|
94
|
+
assert gen.BusID in self._bnames, f"Bus {gen.BusID} undefined"
|
|
95
95
|
self._gatb[gen.BusID].append(gen)
|
|
96
96
|
for pvw in self._pvws.values():
|
|
97
|
-
assert pvw.BusID in self._bnames
|
|
97
|
+
assert pvw.BusID in self._bnames, f"Bus {pvw.BusID} undefined"
|
|
98
98
|
self._patb[pvw.BusID].append(pvw)
|
|
99
99
|
for ess in self._esss.values():
|
|
100
|
-
assert ess.BusID in self._bnames
|
|
100
|
+
assert ess.BusID in self._bnames, f"Bus {ess.BusID} undefined"
|
|
101
101
|
self._eatb[ess.BusID].append(ess)
|
|
102
102
|
|
|
103
103
|
@property
|
|
@@ -15,9 +15,10 @@ class GridSolveResult(IntEnum):
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class SolverBase(ABC):
|
|
18
|
-
def __init__(self, grid:Grid, eps:float = 1e-6, default_saveto:str = DEFAULT_SAVETO, **kwargs):
|
|
18
|
+
def __init__(self, grid:Grid, eps:float = 1e-6, max_iter:int = 1000, *, default_saveto:str = DEFAULT_SAVETO, **kwargs):
|
|
19
19
|
self.grid = grid
|
|
20
20
|
self.eps = eps
|
|
21
|
+
self.max_iter = max_iter
|
|
21
22
|
self.saveto = default_saveto
|
|
22
23
|
|
|
23
24
|
def SetErrorSaveTo(self, path:str = DEFAULT_SAVETO):
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from .grid import Grid
|
|
2
|
+
from .solbase import DEFAULT_SAVETO, GridSolveResult, SolverBase
|
|
3
|
+
from warnings import warn
|
|
4
|
+
|
|
5
|
+
ESTIMATORS = ['distflow']
|
|
6
|
+
CALCULATORS = ['opendss', 'newton', 'gridcal', 'none']
|
|
7
|
+
CALCULATORS_NEED_SOURCE_BUS = ['opendss', 'gridcal']
|
|
8
|
+
|
|
9
|
+
class CombinedSolver(SolverBase):
|
|
10
|
+
"""
|
|
11
|
+
A class that use DistFlowSolver to estimate the power flow and then use OpenDSSSolver or NewtonSolver to solve the power flow problem.
|
|
12
|
+
"""
|
|
13
|
+
def __init__(self, grid:Grid, eps:float = 1e-6, max_iter:int = 1000, *,
|
|
14
|
+
default_saveto:str = DEFAULT_SAVETO, estimator:str = 'distflow',
|
|
15
|
+
calculator:str = 'newton', mlrp:float = 0.5 ,source_bus:str = ""):
|
|
16
|
+
super().__init__(grid, eps, max_iter, default_saveto = default_saveto)
|
|
17
|
+
assert estimator in ESTIMATORS, f"Invalid estimator '{estimator}'. Choose from: " + ','.join(ESTIMATORS) + "."
|
|
18
|
+
assert calculator in CALCULATORS, f"Invalid solver type '{calculator}'. Choose from: " + ','.join(CALCULATORS) + "."
|
|
19
|
+
|
|
20
|
+
from .soldist import DistFlowSolver
|
|
21
|
+
self.est = DistFlowSolver(grid, mlrp = mlrp)
|
|
22
|
+
self.cal_str = calculator
|
|
23
|
+
if calculator in CALCULATORS_NEED_SOURCE_BUS:
|
|
24
|
+
assert source_bus != "", "source_bus cannot be empty when using OpenDSSSolver."
|
|
25
|
+
self.source_bus = source_bus
|
|
26
|
+
else:
|
|
27
|
+
if source_bus != "":
|
|
28
|
+
warn(Warning("source_bus is ignored when not using OpenDSSSolver."))
|
|
29
|
+
|
|
30
|
+
def solve(self, _t:int, /, *, timeout_s: float = 1):
|
|
31
|
+
res, obj = self.est.solve(_t, timeout_s=timeout_s)
|
|
32
|
+
if res == GridSolveResult.Failed:
|
|
33
|
+
return res, obj
|
|
34
|
+
if self.cal_str == 'none':
|
|
35
|
+
return res, obj
|
|
36
|
+
elif self.cal_str == 'opendss':
|
|
37
|
+
from .soldss import OpenDSSSolver
|
|
38
|
+
solver = OpenDSSSolver(self.est.grid, source_bus = self.source_bus)
|
|
39
|
+
elif self.cal_str == 'gridcal':
|
|
40
|
+
from .solgcal import GridCalSolver
|
|
41
|
+
solver = GridCalSolver(self.est.grid, slack_bus = self.source_bus)
|
|
42
|
+
else:
|
|
43
|
+
from .solnt import NewtonSolver
|
|
44
|
+
solver = NewtonSolver(self.est.grid)
|
|
45
|
+
res, obj = solver.solve(_t, timeout_s = timeout_s)
|
|
46
|
+
return res, obj
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from itertools import chain
|
|
2
|
-
import cvxpy as cp
|
|
3
2
|
from pathlib import Path
|
|
4
3
|
from typing import Optional, Union
|
|
5
4
|
from dataclasses import dataclass
|
|
@@ -7,8 +6,7 @@ from collections import deque
|
|
|
7
6
|
import math
|
|
8
7
|
from .solbase import *
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
VF = Union[Var, float]
|
|
9
|
+
VF = Union['Var', float] # type: ignore
|
|
12
10
|
|
|
13
11
|
@dataclass
|
|
14
12
|
class LoadReduceModule:
|
|
@@ -67,8 +65,8 @@ class IslandResult(IntEnum):
|
|
|
67
65
|
|
|
68
66
|
class DistFlowSolver(SolverBase):
|
|
69
67
|
'''DistFlow solver'''
|
|
70
|
-
def __init__(self, grid:
|
|
71
|
-
|
|
68
|
+
def __init__(self, grid:Grid, eps:float = 1e-6, max_iter:int = 1000, *,
|
|
69
|
+
default_saveto:str = DEFAULT_SAVETO, mlrp: float = 0.5, secondary_cost: bool = True):
|
|
72
70
|
'''
|
|
73
71
|
Initialize
|
|
74
72
|
grid: Grid object
|
|
@@ -79,7 +77,7 @@ class DistFlowSolver(SolverBase):
|
|
|
79
77
|
If True, the cost is calculated as CostA * Pg^2 + CostB * Pg + CostC,
|
|
80
78
|
which is likely to induce numerical instability.
|
|
81
79
|
'''
|
|
82
|
-
super().__init__(grid, eps, default_saveto)
|
|
80
|
+
super().__init__(grid, eps, max_iter, default_saveto = default_saveto)
|
|
83
81
|
self._decb: dict[BusID, LoadReduceModule] = {}
|
|
84
82
|
self.C = 1e9
|
|
85
83
|
self._mlrp = mlrp
|
|
@@ -192,6 +190,15 @@ class DistFlowSolver(SolverBase):
|
|
|
192
190
|
else:
|
|
193
191
|
return GridSolveResult.PartialOK, val
|
|
194
192
|
|
|
193
|
+
def __chkv(self, d: Union[None, np.ndarray]) -> float:
|
|
194
|
+
assert d is not None, "Value is None"
|
|
195
|
+
assert isinstance(d, (np.ndarray, np.floating, float)), f"Value is {type(d)}"
|
|
196
|
+
ret = d.item()
|
|
197
|
+
assert isinstance(ret, float), f"Value is not a float: {type(ret)}"
|
|
198
|
+
assert ret != float('inf'), "Value is inf"
|
|
199
|
+
assert ret != float('-inf'), "Value is -inf"
|
|
200
|
+
return ret
|
|
201
|
+
|
|
195
202
|
def __solve(self, _t: int, island: _Island, timeout_s: float, relaxV: bool, relaxI: bool, clear_results: bool = False) -> 'tuple[IslandResult, float]':
|
|
196
203
|
|
|
197
204
|
''' ---------Variables----------
|
|
@@ -205,10 +212,15 @@ class DistFlowSolver(SolverBase):
|
|
|
205
212
|
P[i,j]: Line active power
|
|
206
213
|
Q[i,j]: Line reactive power
|
|
207
214
|
'''
|
|
215
|
+
try:
|
|
216
|
+
import cvxpy as cp
|
|
217
|
+
from cvxpy import Variable as Var
|
|
218
|
+
except ImportError:
|
|
219
|
+
raise ImportError("cvxpy or ecos is not installed. Please install them using 'pip install cvxpy ecos'")
|
|
208
220
|
cons:list[cp.Constraint] = []
|
|
209
221
|
# Create GEN vars
|
|
210
|
-
pg0: dict[str, VF] = {}
|
|
211
|
-
qg0: dict[str, VF] = {}
|
|
222
|
+
pg0: 'dict[str, VF]' = {}
|
|
223
|
+
qg0: 'dict[str, VF]' = {}
|
|
212
224
|
for gID, g in island.GenItems():
|
|
213
225
|
if g.FixedP:
|
|
214
226
|
assert g.P is not None
|
|
@@ -246,10 +258,10 @@ class DistFlowSolver(SolverBase):
|
|
|
246
258
|
cons.append(pvwp[pID] * math.sqrt(1 - p.PF**2) == pvwq[pID])
|
|
247
259
|
|
|
248
260
|
# Bind GEN vars to Bus
|
|
249
|
-
pg: dict[str, list[VF]] = {b: [] for b in island.Buses}
|
|
250
|
-
qg: dict[str, list[VF]] = {b: [] for b in island.Buses}
|
|
251
|
-
pd: dict[str, float] = {bID: b.Pd(_t) for bID, b in island.BusItems()}
|
|
252
|
-
qd: dict[str, float] = {bID: b.Qd(_t) for bID, b in island.BusItems()}
|
|
261
|
+
pg: 'dict[str, list[VF]]' = {b: [] for b in island.Buses}
|
|
262
|
+
qg: 'dict[str, list[VF]]' = {b: [] for b in island.Buses}
|
|
263
|
+
pd: 'dict[str, float]' = {bID: b.Pd(_t) for bID, b in island.BusItems()}
|
|
264
|
+
qd: 'dict[str, float]' = {bID: b.Qd(_t) for bID, b in island.BusItems()}
|
|
253
265
|
for gID, g in island.GenItems():
|
|
254
266
|
pg[g.BusID].append(pg0[gID])
|
|
255
267
|
qg[g.BusID].append(qg0[gID])
|
|
@@ -288,6 +300,8 @@ class DistFlowSolver(SolverBase):
|
|
|
288
300
|
l = {lID: Var(name=f"l_{lID}", nonneg=True) for lID in island.Lines}
|
|
289
301
|
|
|
290
302
|
for lID, ln in island.LineItems():
|
|
303
|
+
if ln.max_I == math.inf:
|
|
304
|
+
continue
|
|
291
305
|
if relaxI:
|
|
292
306
|
dlmax[lID] = Var(name=f"dlmax_{lID}", nonneg=True)
|
|
293
307
|
cons.append(l[lID] <= (ln.max_I/island.grid.Ib) ** 2 + dlmax[lID])
|
|
@@ -314,14 +328,14 @@ class DistFlowSolver(SolverBase):
|
|
|
314
328
|
inflow = cp.sum([P[ln.ID] - ln.R * l[ln.ID] for ln in flow_in if ln.ID in island.Lines])
|
|
315
329
|
outflow = cp.sum([P[ln.ID] for ln in flow_out if ln.ID in island.Lines])
|
|
316
330
|
cons.append(
|
|
317
|
-
inflow + cp.sum(pg[j]) == outflow + pd[j] - dec
|
|
331
|
+
inflow + cp.sum(pg[j]) == outflow + pd[j] - dec # type: ignore
|
|
318
332
|
)
|
|
319
333
|
|
|
320
334
|
# Q constraint
|
|
321
335
|
q_inflow = cp.sum([Q[ln.ID] - ln.X * l[ln.ID] for ln in flow_in if ln.ID in island.Lines])
|
|
322
336
|
q_outflow = cp.sum([Q[ln.ID] for ln in flow_out if ln.ID in island.Lines])
|
|
323
337
|
cons.append(
|
|
324
|
-
q_inflow + cp.sum(qg[j]) == q_outflow + qd[j]
|
|
338
|
+
q_inflow + cp.sum(qg[j]) == q_outflow + qd[j] # type: ignore
|
|
325
339
|
)
|
|
326
340
|
|
|
327
341
|
for lid, line in island.LineItems():
|
|
@@ -355,7 +369,7 @@ class DistFlowSolver(SolverBase):
|
|
|
355
369
|
problem = cp.Problem(cp.Minimize(decs + goal + crpe), cons)
|
|
356
370
|
|
|
357
371
|
try:
|
|
358
|
-
problem.solve(solver=cp.ECOS, verbose=False)
|
|
372
|
+
problem.solve(solver=cp.ECOS, verbose=False, max_iters=self.max_iter)
|
|
359
373
|
except cp.SolverError as e:
|
|
360
374
|
if "installed" in e.args[0]:
|
|
361
375
|
raise e
|
|
@@ -377,22 +391,22 @@ class DistFlowSolver(SolverBase):
|
|
|
377
391
|
return IslandResult.Failed, -1
|
|
378
392
|
|
|
379
393
|
for j, bus in island.BusItems():
|
|
380
|
-
bus._v = v[j].value
|
|
394
|
+
bus._v = self.__chkv(v[j].value) ** 0.5
|
|
381
395
|
|
|
382
396
|
for lid, line in island.LineItems():
|
|
383
|
-
line.I = l[lid].value
|
|
384
|
-
line.P = P[lid].value
|
|
385
|
-
line.Q = Q[lid].value
|
|
397
|
+
line.I = self.__chkv(l[lid].value) ** 0.5
|
|
398
|
+
line.P = self.__chkv(P[lid].value)
|
|
399
|
+
line.Q = self.__chkv(Q[lid].value)
|
|
386
400
|
|
|
387
401
|
for j, gen in island.GenItems():
|
|
388
402
|
p = pg0[j]
|
|
389
|
-
if isinstance(p, Var) and p.value is not None: gen._p = p.value
|
|
403
|
+
if isinstance(p, Var) and p.value is not None: gen._p = self.__chkv(p.value)
|
|
390
404
|
q = qg0[j]
|
|
391
|
-
if isinstance(q, Var): gen._q = q.value
|
|
405
|
+
if isinstance(q, Var): gen._q = self.__chkv(q.value)
|
|
392
406
|
|
|
393
407
|
for pID, p in island.PVWItems():
|
|
394
|
-
p._pr = pvwp[pID].value
|
|
395
|
-
p._qr = pvwq[pID].value
|
|
408
|
+
p._pr = self.__chkv(pvwp[pID].value)
|
|
409
|
+
p._qr = self.__chkv(pvwq[pID].value)
|
|
396
410
|
pgen = p.P(_t)
|
|
397
411
|
p._cr = 1 - p._pr / pgen if pgen > 0 else 0
|
|
398
412
|
|
|
@@ -400,19 +414,21 @@ class DistFlowSolver(SolverBase):
|
|
|
400
414
|
self._ofbuses.clear()
|
|
401
415
|
if relaxV:
|
|
402
416
|
for bID, bv in chain(dvmax.items(), dvmin.items()):
|
|
403
|
-
if bv.value > 1e-8:
|
|
417
|
+
if self.__chkv(bv.value) > 1e-8:
|
|
404
418
|
overflow = True
|
|
405
419
|
self._ofbuses.add(bID)
|
|
406
420
|
|
|
407
421
|
self._oflines.clear()
|
|
408
422
|
if relaxI:
|
|
409
423
|
for lID, lv in dlmax.items():
|
|
410
|
-
if lv.value > 1e-8:
|
|
424
|
+
if self.__chkv(lv.value) > 1e-8:
|
|
411
425
|
overflow = True
|
|
412
426
|
self._oflines.add(lID)
|
|
413
427
|
|
|
414
428
|
for bus, lim in self._decb.items():
|
|
415
|
-
lim.Reduction = Pdec[bus].value
|
|
429
|
+
lim.Reduction = self.__chkv(Pdec[bus].value)
|
|
416
430
|
if lim.Reduction < 1e-8: lim.Reduction = 0
|
|
417
431
|
|
|
418
|
-
|
|
432
|
+
if not isinstance(goal, (int, float)):
|
|
433
|
+
goal = self.__chkv(goal.value)
|
|
434
|
+
return IslandResult.OverFlow if overflow else IslandResult.OK, goal
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
from .solbase import *
|
|
2
2
|
|
|
3
3
|
class OpenDSSSolver(SolverBase):
|
|
4
|
-
def __init__(self, grid:Grid,
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
def __init__(self, grid:Grid, eps:float = 1e-6, max_iter:int = 1000, *,
|
|
5
|
+
default_saveto:str = DEFAULT_SAVETO, source_bus:str, init_t:int = 0):
|
|
6
|
+
super().__init__(grid, eps, max_iter, default_saveto = default_saveto)
|
|
7
|
+
try:
|
|
8
|
+
from py_dss_interface import DSS
|
|
9
|
+
except ImportError:
|
|
10
|
+
raise ImportError("py_dss_interface or OpenDSS is not installed. Please install OpenDSS first and then py_dss_interface using 'pip install py_dss_interface'")
|
|
7
11
|
self._g = grid
|
|
8
12
|
t = init_t
|
|
9
13
|
d = DSS()
|
|
@@ -16,9 +20,9 @@ class OpenDSSSolver(SolverBase):
|
|
|
16
20
|
bid = bus.ID
|
|
17
21
|
if bid != bid.lower():
|
|
18
22
|
raise ValueError(f"Bus ID {bid} must be lower case")
|
|
19
|
-
p = bus.Pd(t)
|
|
20
|
-
q = bus.Qd(t)
|
|
21
|
-
d.text(f"New Load.{bid} bus1={bid} kv={self.grid.Ub} kW={p} kvar={q} vmin={bus.MinV} vmax={bus.MaxV}")
|
|
23
|
+
p = bus.Pd(t)
|
|
24
|
+
q = bus.Qd(t)
|
|
25
|
+
d.text(f"New Load.{bid} bus1={bid} kv={self.grid.Ub} kW={p*grid.Sb_kVA} kvar={q*grid.Sb_kVA} vmin={bus.MinV} vmax={bus.MaxV}")
|
|
22
26
|
for line in self.grid.Lines:
|
|
23
27
|
fid = line.fBus
|
|
24
28
|
tid = line.tBus
|
|
@@ -57,15 +61,19 @@ class OpenDSSSolver(SolverBase):
|
|
|
57
61
|
for gen in self.grid.Gens:
|
|
58
62
|
if gen.ID != gen.ID.lower():
|
|
59
63
|
raise ValueError(f"Generator ID {gen.ID} must be lower case")
|
|
60
|
-
|
|
64
|
+
bid = gen.BusID
|
|
65
|
+
if gen.P is None and bid != self.source_bus:
|
|
61
66
|
raise ValueError(f"Generator {gen.ID} has no P value")
|
|
62
67
|
p = gen.P(t) if isinstance(gen.P, TimeFunc) else gen.P
|
|
63
|
-
if gen.Q is None:
|
|
68
|
+
if gen.Q is None and bid != self.source_bus:
|
|
64
69
|
raise ValueError(f"Generator {gen.ID} has no Q value")
|
|
65
70
|
q = gen.Q(t) if isinstance(gen.Q, TimeFunc) else gen.Q
|
|
66
|
-
bid = gen.BusID
|
|
67
71
|
|
|
68
|
-
s = f"New Generator.{gen.ID} bus1={bid} kv={grid.Ub}
|
|
72
|
+
s = f"New Generator.{gen.ID} bus1={bid} kv={grid.Ub} "
|
|
73
|
+
if p is not None:
|
|
74
|
+
s+=f"kw={p*grid.Sb_kVA} "
|
|
75
|
+
if q is not None:
|
|
76
|
+
s+=f"kvar={q*grid.Sb_kVA}"
|
|
69
77
|
d.text(s)
|
|
70
78
|
d.text("set mode=snapshot")
|
|
71
79
|
self.dss = d
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
from warnings import warn
|
|
2
|
+
from .solbase import *
|
|
3
|
+
|
|
4
|
+
class GridCalSolver(SolverBase):
|
|
5
|
+
def __init__(self, grid:Grid, eps:float = 1e-6, max_iter:int = 1000, *, default_saveto:str = DEFAULT_SAVETO,
|
|
6
|
+
slack_bus:str, slack_gen:str = "", init_t:int = 0):
|
|
7
|
+
try:
|
|
8
|
+
import GridCalEngine as gce
|
|
9
|
+
except ImportError:
|
|
10
|
+
raise ImportError("GridCalEngine is not installed. Please install it using 'pip install GridCalEngine'")
|
|
11
|
+
super().__init__(grid, eps, max_iter, default_saveto = default_saveto)
|
|
12
|
+
self.max_iter = max_iter
|
|
13
|
+
self._g = grid
|
|
14
|
+
assert slack_bus in grid.BusNames
|
|
15
|
+
self.slack_bus = slack_bus
|
|
16
|
+
if slack_gen == "":
|
|
17
|
+
slack_gens = grid.GensAtBus(slack_bus)
|
|
18
|
+
if len(slack_gens) == 0:
|
|
19
|
+
raise RuntimeError("Slack generator not identified, and no generator connects with the slack bus.")
|
|
20
|
+
slack_gen = slack_gens[0].ID
|
|
21
|
+
#print(f"FPowerKit Info: Use {slack_gen} as the slack generator.")
|
|
22
|
+
assert slack_gen in grid.GenNames
|
|
23
|
+
self.slack_gen = slack_gen
|
|
24
|
+
gcg = gce.MultiCircuit(Sbase=grid.Sb_MVA)
|
|
25
|
+
t = init_t
|
|
26
|
+
buses:dict[str, gce.Bus] = {}
|
|
27
|
+
for bus in grid.Buses:
|
|
28
|
+
bid = bus.ID
|
|
29
|
+
p = bus.Pd(t)
|
|
30
|
+
q = bus.Qd(t)
|
|
31
|
+
b_inst = gce.Bus(bid,
|
|
32
|
+
Vnom=grid.Ub, # type:ignore
|
|
33
|
+
vmin=bus.MinV, vmax=bus.MaxV, is_slack=bid==slack_bus)
|
|
34
|
+
buses[bid] = b_inst
|
|
35
|
+
gcg.add_bus(b_inst)
|
|
36
|
+
gcg.add_load(b_inst, gce.Load(bid+"_load", P = p*grid.Sb_MVA, Q = q*grid.Sb_MVA))
|
|
37
|
+
|
|
38
|
+
for line in self.grid.Lines:
|
|
39
|
+
fid = line.fBus
|
|
40
|
+
tid = line.tBus
|
|
41
|
+
gcg.add_line(gce.Line(buses[fid], buses[tid], name=line.ID, r=line.R, x=line.X))
|
|
42
|
+
|
|
43
|
+
for pvw in self.grid.PVWinds:
|
|
44
|
+
if pvw.Pr is None:
|
|
45
|
+
raise ValueError(f"PVWind {pvw.ID} has no Pr value")
|
|
46
|
+
p = pvw.Pr
|
|
47
|
+
if pvw.Qr is None:
|
|
48
|
+
raise ValueError(f"PVWind {pvw.ID} has no Qr value")
|
|
49
|
+
q = pvw.Qr
|
|
50
|
+
bid = pvw.BusID
|
|
51
|
+
g_inst = gce.Generator(pvw.ID, P=p*grid.Sb_MVA, power_factor=pvw.PF, Sbase = grid.Sb_MVA)
|
|
52
|
+
gcg.add_generator(buses[bid], g_inst)
|
|
53
|
+
|
|
54
|
+
for ess in self.grid.ESSs:
|
|
55
|
+
if ess.ID != ess.ID.lower():
|
|
56
|
+
raise ValueError(f"ESS ID {ess.ID} must be lower case")
|
|
57
|
+
if ess.P is None:
|
|
58
|
+
raise ValueError(f"ESS {ess.ID} has no P value")
|
|
59
|
+
p = ess.P
|
|
60
|
+
if ess.Q is None:
|
|
61
|
+
raise ValueError(f"ESS {ess.ID} has no Q value")
|
|
62
|
+
q = ess.Q
|
|
63
|
+
bid = ess.BusID
|
|
64
|
+
if p > 0: # charging = load
|
|
65
|
+
bus = self.grid.Bus(bid)
|
|
66
|
+
gcg.add_load(buses[bid], gce.Load(ess.ID, P=p*grid.Sb_MVA, Q=q*grid.Sb_MVA))
|
|
67
|
+
else: # discharging = generator
|
|
68
|
+
g_inst = gce.Generator(ess.ID, P=p*grid.Sb_MVA, power_factor=ess.PF, Sbase = grid.Sb_MVA)
|
|
69
|
+
gcg.add_generator(buses[bid], g_inst)
|
|
70
|
+
|
|
71
|
+
for gen in self.grid.Gens:
|
|
72
|
+
bid = gen.BusID
|
|
73
|
+
if gen.ID == slack_gen:
|
|
74
|
+
g_inst = gce.Generator(gen.ID, vset=1.0)
|
|
75
|
+
if gen.P is not None or gen.Q is not None:
|
|
76
|
+
warn(f"Given value of P and Q of the slack generator {gen.ID} is ignored.")
|
|
77
|
+
else:
|
|
78
|
+
if gen.P is None:
|
|
79
|
+
p = 0
|
|
80
|
+
else:
|
|
81
|
+
p = gen.P(t) if isinstance(gen.P, TimeFunc) else gen.P
|
|
82
|
+
if gen.Q is None:
|
|
83
|
+
pf = 0.8
|
|
84
|
+
else:
|
|
85
|
+
q = gen.Q(t) if isinstance(gen.Q, TimeFunc) else gen.Q
|
|
86
|
+
pf = p / (p**2 + q**2) ** 0.5
|
|
87
|
+
g_inst = gce.Generator(gen.ID, P=p*grid.Sb_MVA, power_factor=pf, Sbase = grid.Sb_MVA, vset=1.0)
|
|
88
|
+
gcg.add_generator(buses[bid], g_inst)
|
|
89
|
+
|
|
90
|
+
self.grid_cal = gcg
|
|
91
|
+
|
|
92
|
+
def solve(self, _t:int, /, *, timeout_s:float = 1) -> 'tuple[GridSolveResult, float]':
|
|
93
|
+
import GridCalEngine as gce
|
|
94
|
+
options = gce.PowerFlowOptions(gce.SolverType.NR,
|
|
95
|
+
max_iter=self.max_iter,
|
|
96
|
+
retry_with_other_methods=False,
|
|
97
|
+
tolerance=self.eps,
|
|
98
|
+
control_q=False,
|
|
99
|
+
control_taps_phase=False,
|
|
100
|
+
control_taps_modules=False,
|
|
101
|
+
apply_temperature_correction=False,
|
|
102
|
+
use_stored_guess=False,
|
|
103
|
+
initialize_angles=True,
|
|
104
|
+
verbose=False)
|
|
105
|
+
|
|
106
|
+
power_flow = gce.PowerFlowDriver(self.grid_cal, options)
|
|
107
|
+
power_flow.run()
|
|
108
|
+
assert isinstance(power_flow.results, gce.PowerFlowResults)
|
|
109
|
+
if not power_flow.results.converged:
|
|
110
|
+
return GridSolveResult.Failed, 0.0
|
|
111
|
+
bus_res = power_flow.results.get_bus_df()
|
|
112
|
+
|
|
113
|
+
for i, bn in enumerate(self._g.BusNames):
|
|
114
|
+
b = self.grid.Bus(bn)
|
|
115
|
+
v = bus_res.loc[bn, 'Vm']
|
|
116
|
+
assert isinstance(v, (float, np.floating)), f"Bus {bn} voltage is not a float: {type(v)}"
|
|
117
|
+
b._v = float(v)
|
|
118
|
+
angle = bus_res.loc[bn, 'Va']
|
|
119
|
+
assert isinstance(angle, (float, np.floating)), f"Bus {bn} angle is not a float: {type(angle)}"
|
|
120
|
+
b.theta = float(angle) / 180 * math.pi
|
|
121
|
+
|
|
122
|
+
for l in self.grid.Lines:
|
|
123
|
+
vi = self.grid.Bus(l.fBus).V_cpx
|
|
124
|
+
vj = self.grid.Bus(l.tBus).V_cpx
|
|
125
|
+
assert vi is not None and vj is not None
|
|
126
|
+
i = (vi-vj)/l.Z
|
|
127
|
+
l.I = abs(i)
|
|
128
|
+
s = vi*i.conjugate()
|
|
129
|
+
l.P = s.real
|
|
130
|
+
l.Q = s.imag
|
|
131
|
+
|
|
132
|
+
return GridSolveResult.OK, 0.0
|
|
@@ -9,7 +9,7 @@ class BusType(IntEnum):
|
|
|
9
9
|
|
|
10
10
|
class NewtonSolver(SolverBase):
|
|
11
11
|
def __init__(self, grid:Grid, eps:float = 1e-6, default_saveto:str = DEFAULT_SAVETO, max_iter:int = 100):
|
|
12
|
-
super().__init__(grid, eps, default_saveto)
|
|
12
|
+
super().__init__(grid, eps, max_iter, default_saveto = default_saveto)
|
|
13
13
|
self.Y = grid.YMat()
|
|
14
14
|
self.G, self.B = self.Y.real, self.Y.imag
|
|
15
15
|
self.max_iter = max_iter
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: fpowerkit
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: A Distflow PDN solver based on Gurobi.
|
|
5
|
+
Author: fmy_xfk
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: feasytools>=0.0.21
|
|
13
|
+
Requires-Dist: numpy>=1.20.0
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# FPowerKit - A power distribution network calculation component
|
|
23
|
+
|
|
24
|
+
This is a package designed for power distribution network solving.
|
|
25
|
+
|
|
26
|
+
This package is affiliated to V2Sim, an open-aource microscopic V2G simulation platform in urban power and transportation network. If you are using the modified DistFlow model in this package, please cite the [paper](https://ieeexplore.ieee.org/document/10970754):
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
@ARTICLE{10970754,
|
|
30
|
+
author={Qian, Tao and Fang, Mingyu and Hu, Qinran and Shao, Chengcheng and Zheng, Junyi},
|
|
31
|
+
journal={IEEE Transactions on Smart Grid},
|
|
32
|
+
title={V2Sim: An Open-Source Microscopic V2G Simulation Platform in Urban Power and Transportation Network},
|
|
33
|
+
year={2025},
|
|
34
|
+
pages={1-1},
|
|
35
|
+
keywords={Vehicle-to-grid;Partial discharges;Microscopy;Batteries;Planning;Discharges (electric);Optimization;Vehicle dynamics;Transportation;Roads;EV charging load simulation;microscopic EV behavior;Vehicle-to-grid;charging station fault sensing},
|
|
36
|
+
doi={10.1109/TSG.2025.3560976}}
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
There are 3 modes for this package to work:
|
|
41
|
+
|
|
42
|
+
- Optimal power flow (OPF): Use cvxpy to solve the optimal power flow and determine the output of the generators.
|
|
43
|
+
|
|
44
|
+
- Power flow calculation: Use OpenDSS/GridCal/Inner Newton-Raphson method to solve the power flow.
|
|
45
|
+
|
|
46
|
+
- Hybrid: Use OPF to determine the initial value, and then use OpenDSS/GridCal/Inner Newton-Raphson to perform accurate calculation.
|
|
47
|
+
|
|
48
|
+
Since this package is still under development, the API is unstable and may be changed anytime.
|
|
49
|
+
|
|
50
|
+
Please visit https://gitee.com/fmy_xfk/fpowerkit to read the detailed introduction and the usage.
|
|
@@ -10,8 +10,10 @@ fpowerkit/grid.py
|
|
|
10
10
|
fpowerkit/line.py
|
|
11
11
|
fpowerkit/pvwind.py
|
|
12
12
|
fpowerkit/solbase.py
|
|
13
|
+
fpowerkit/solcmb.py
|
|
13
14
|
fpowerkit/soldist.py
|
|
14
15
|
fpowerkit/soldss.py
|
|
16
|
+
fpowerkit/solgcal.py
|
|
15
17
|
fpowerkit/solnt.py
|
|
16
18
|
fpowerkit/utils.py
|
|
17
19
|
fpowerkit.egg-info/PKG-INFO
|
|
@@ -5,7 +5,7 @@ with open("desc.md", "r", encoding="utf8") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="fpowerkit",
|
|
8
|
-
version="0.2.
|
|
8
|
+
version="0.2.2",
|
|
9
9
|
author="fmy_xfk",
|
|
10
10
|
packages=find_packages(),
|
|
11
11
|
description="A Distflow PDN solver based on Gurobi.",
|
|
@@ -17,5 +17,5 @@ setup(
|
|
|
17
17
|
"Operating System :: OS Independent",
|
|
18
18
|
],
|
|
19
19
|
python_requires=">=3.8",
|
|
20
|
-
install_requires=["feasytools>=0.0.21", "
|
|
20
|
+
install_requires=["feasytools>=0.0.21", "numpy>=1.20.0"],
|
|
21
21
|
)
|
fpowerkit-0.2.0rc0/PKG-INFO
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: fpowerkit
|
|
3
|
-
Version: 0.2.0rc0
|
|
4
|
-
Summary: A Distflow PDN solver based on Gurobi.
|
|
5
|
-
Author: fmy_xfk
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.8
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Requires-Dist: feasytools>=0.0.21
|
|
13
|
-
Requires-Dist: cvxpy>=1.0
|
|
14
|
-
Requires-Dist: numpy>=1.20.0
|
|
15
|
-
Requires-Dist: ecos
|
|
16
|
-
Dynamic: author
|
|
17
|
-
Dynamic: classifier
|
|
18
|
-
Dynamic: description
|
|
19
|
-
Dynamic: description-content-type
|
|
20
|
-
Dynamic: requires-dist
|
|
21
|
-
Dynamic: requires-python
|
|
22
|
-
Dynamic: summary
|
|
23
|
-
|
|
24
|
-
# FPowerKit - A power distribution network calculation component
|
|
25
|
-
|
|
26
|
-
This is a package based on Gurobipy implementing optimal power flow (OPF).
|
|
27
|
-
|
|
28
|
-
Since this package is still under development, the API is unstable and may be changed anytime.
|
|
29
|
-
|
|
30
|
-
Please visit https://gitee.com/fmy_xfk/fpowerkit to read the detailed introduction and the usage.
|
fpowerkit-0.2.0rc0/README.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# FPowerKit 配电网运算组件
|
|
2
|
-
**本仓库已上线PyPI**,您可以通过`pip install fpowerkit`直接以Python包的形式安装使用本仓库的代码!
|
|
3
|
-
|
|
4
|
-
这个项目是[V2Sim](https://gitee.com/fmy_xfk/v2sim)的附属项目。V2Sim的论文请见arXiv: https://arxiv.org/abs/2412.09808
|
|
5
|
-
|
|
6
|
-
IEEE33和IEEE69节点的配网数据从公开渠道收集。除配网数据以外,本仓库代码均遵循LGPL3.0协议使用。
|
|
7
|
-
|
|
8
|
-
## 简介
|
|
9
|
-
- 依赖于feasytools和gurobipy: `pip install feasytools gurobipy`(请自行安装Gurobi并申请许可证)
|
|
10
|
-
- 包含电网的描述(含母线、发电机、线路等)和采用Gurobi的配电网DistFlow模型求解。
|
|
11
|
-
- 优化目标为“发电成本最小”。发电成本模型为二次函数$f(x)=ax^2+bx+c$。
|
|
12
|
-
- 内含IEEE 33节点配电网和IEEE 69节点配电网,可通过以下方式快速创建:
|
|
13
|
-
```py
|
|
14
|
-
from fpowerkit import PDNCases
|
|
15
|
-
grid_obj33 = PDNCases.IEEE33()
|
|
16
|
-
grid_obj69 = PDNCases.IEEE69()
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## 使用
|
|
20
|
-
|
|
21
|
-
克隆本仓库,并输入以下命令开始求解:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
python main.py -g cases/33base.xml
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
请注意上述命令不适用于pip安装的版本。
|
|
28
|
-
|
|
29
|
-
`33base`描述了IEEE 33节点配电网模型。换成`3nodes`则是一个极简版3节点辐射形配电网模型,结构如下:
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
G0 G1
|
|
33
|
-
| |
|
|
34
|
-
B0->B1->B2
|
|
35
|
-
| |
|
|
36
|
-
L1 L2
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
您也换成自己的配电网文件来求解,例如`python main.py -g path/to/your_zipfile.zip`
|
|
40
|
-
|
|
41
|
-
## 配电网文件格式
|
|
42
|
-
[XML格式](docs/xml_file.md)
|
|
43
|
-
|
|
44
|
-
ZIP格式已经不再支持。
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: fpowerkit
|
|
3
|
-
Version: 0.2.0rc0
|
|
4
|
-
Summary: A Distflow PDN solver based on Gurobi.
|
|
5
|
-
Author: fmy_xfk
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.8
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Requires-Dist: feasytools>=0.0.21
|
|
13
|
-
Requires-Dist: cvxpy>=1.0
|
|
14
|
-
Requires-Dist: numpy>=1.20.0
|
|
15
|
-
Requires-Dist: ecos
|
|
16
|
-
Dynamic: author
|
|
17
|
-
Dynamic: classifier
|
|
18
|
-
Dynamic: description
|
|
19
|
-
Dynamic: description-content-type
|
|
20
|
-
Dynamic: requires-dist
|
|
21
|
-
Dynamic: requires-python
|
|
22
|
-
Dynamic: summary
|
|
23
|
-
|
|
24
|
-
# FPowerKit - A power distribution network calculation component
|
|
25
|
-
|
|
26
|
-
This is a package based on Gurobipy implementing optimal power flow (OPF).
|
|
27
|
-
|
|
28
|
-
Since this package is still under development, the API is unstable and may be changed anytime.
|
|
29
|
-
|
|
30
|
-
Please visit https://gitee.com/fmy_xfk/fpowerkit to read the detailed introduction and the usage.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|