fpowerkit 0.3.0__tar.gz → 0.3.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.
Files changed (25) hide show
  1. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/PKG-INFO +3 -10
  2. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/README.md +1 -1
  3. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/ess.py +6 -1
  4. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/pvwind.py +6 -2
  5. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/solcmb.py +4 -3
  6. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/soldist.py +5 -3
  7. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/soldss.py +3 -3
  8. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit.egg-info/PKG-INFO +3 -10
  9. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/setup.py +2 -2
  10. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/LICENSE +0 -0
  11. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/__init__.py +0 -0
  12. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/bus.py +0 -0
  13. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/cases.py +0 -0
  14. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/gen.py +0 -0
  15. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/grid.py +0 -0
  16. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/island.py +0 -0
  17. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/line.py +0 -0
  18. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/solbase.py +0 -0
  19. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/solnt.py +0 -0
  20. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit/utils.py +0 -0
  21. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit.egg-info/SOURCES.txt +0 -0
  22. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit.egg-info/dependency_links.txt +0 -0
  23. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit.egg-info/requires.txt +0 -0
  24. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/fpowerkit.egg-info/top_level.txt +0 -0
  25. {fpowerkit-0.3.0 → fpowerkit-0.3.2}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: fpowerkit
3
- Version: 0.3.0
4
- Summary: A Distflow PDN solver based on Gurobi.
3
+ Version: 0.3.2
4
+ Summary: A PDN solver with multiple solutions.
5
5
  Author: fmy_xfk
6
6
  Classifier: Programming Language :: Python :: 3
7
7
  Classifier: License :: OSI Approved :: MIT License
@@ -11,13 +11,6 @@ Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: feasytools>=0.0.21
13
13
  Requires-Dist: numpy>=1.19.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
14
 
22
15
  # FPowerKit - A power distribution network calculation component
23
16
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  ## 简介
5
5
  - FPowerKit是一个配电网求解组件,它包含电网的描述(含母线、发电机、线路、光伏、风机和储能等)和多种内置和外部求解方案:
6
- + (内置) 改进DistFlow配电网最优潮流
6
+ + (内置) 改进DistFlow配电网最优潮流 ([原理介绍](docs/principle.md))
7
7
  + (内置) Newton-Raphson潮流计算
8
8
  + (外接) OpenDSS配电网潮流计算
9
9
  + 最优潮流+潮流计算核验的混合方案
@@ -72,9 +72,14 @@ class ESS:
72
72
  return self.Charge(self.P, dur)
73
73
  return 0
74
74
 
75
+ @property
76
+ def tanPhi(self) -> float:
77
+ '''tan φ = sqrt(1 - PF**2) / PF'''
78
+ return math.sqrt(1 - self._pf**2) / self._pf
79
+
75
80
  def __q(self, P: float) -> float:
76
81
  '''Calculate reactive power'''
77
- return P * math.sqrt(1 - self._pf**2)
82
+ return P * self.tanPhi
78
83
 
79
84
  def GetLoad(self, t: int, cprice:float, dprice:float) -> 'tuple[float, float]':
80
85
  '''
@@ -53,15 +53,19 @@ class PVWind:
53
53
 
54
54
  @property
55
55
  def PF(self):
56
- '''Power factor, cos(phi). Reactive output Q = P * sqrt(1 - PF**2)'''
56
+ '''Power factor, cos(phi). Reactive output Q = P * tan φ'''
57
57
  return self._pf
58
58
  @PF.setter
59
59
  def PF(self, pf: float):
60
60
  self._pf = pf
61
61
 
62
+ @property
63
+ def tanPhi(self):
64
+ return math.sqrt(1 - self._pf**2) / self._pf
65
+
62
66
  def Q(self, _t):
63
67
  '''Reactive power output, pu'''
64
- return self.P(_t) * math.sqrt(1 - self._pf**2)
68
+ return self.P(_t) * self.tanPhi
65
69
 
66
70
  def position(self):
67
71
  '''Return the position of the PV Panel'''
@@ -1,13 +1,13 @@
1
- from enum import StrEnum
1
+ from enum import Enum
2
2
  from typing import Union, Iterable
3
3
  from .grid import Grid
4
4
  from .solbase import DEFAULT_SAVETO, GridSolveResult, SolverBase
5
5
  from warnings import warn
6
6
 
7
- class Estimator(StrEnum):
7
+ class Estimator(Enum):
8
8
  DistFlow = 'DistFlow'
9
9
 
10
- class Calculator(StrEnum):
10
+ class Calculator(Enum):
11
11
  OpenDSS = 'OpenDSS'
12
12
  Newton = 'Newton'
13
13
  NoneSolver = 'None'
@@ -24,6 +24,7 @@ class CombinedSolver(SolverBase):
24
24
  super().__init__(grid, eps, max_iter, default_saveto = default_saveto)
25
25
 
26
26
  from .soldist import DistFlowSolver
27
+ assert estimator == Estimator.DistFlow, "Only DistFlow is supported for now."
27
28
  self.est = DistFlowSolver(grid, mlrp = mlrp)
28
29
  self.cal_str = calculator
29
30
  if calculator in CALCULATORS_NEED_SOURCE_BUS:
@@ -3,6 +3,7 @@ from pathlib import Path
3
3
  from typing import Optional, Union
4
4
  from dataclasses import dataclass
5
5
  import math
6
+ import warnings
6
7
  from .solbase import *
7
8
  from .island import *
8
9
 
@@ -138,6 +139,7 @@ class DistFlowSolver(SolverBase):
138
139
  from cvxpy import Variable as Var
139
140
  except ImportError:
140
141
  raise ImportError("cvxpy or ecos is not installed. Please install them using 'pip install cvxpy ecos'")
142
+ warnings.filterwarnings("ignore", category=FutureWarning, module="cvxpy")
141
143
  cons: 'list[cp.Constraint]' = []
142
144
  # Create GEN vars
143
145
  pg0: 'dict[str, VF]' = {}
@@ -176,7 +178,7 @@ class DistFlowSolver(SolverBase):
176
178
  # Add PVW constraints
177
179
  for pID, p in island.PVWItems():
178
180
  cons.append(pvwp[pID] <= p.P(_t))
179
- cons.append(pvwp[pID] * math.sqrt(1 - p.PF**2) == pvwq[pID])
181
+ cons.append(pvwp[pID] * p.tanPhi == pvwq[pID])
180
182
 
181
183
  # Bind GEN vars to Bus
182
184
  pg: 'dict[str, list[VF]]' = {b: [] for b in island.Buses}
@@ -272,8 +274,8 @@ class DistFlowSolver(SolverBase):
272
274
  cp.quad_over_lin(cp.hstack([P[lid], Q[lid]]), v[i]) <= l[lid]
273
275
  )
274
276
 
275
- for pID, p in island.PVWItems():
276
- cons.append(pvwp[pID] + cp.sqrt(1 - p.PF**2) == pvwq[pID])
277
+ #for pID, p in island.PVWItems():
278
+ # cons.append(pvwp[pID] + cp.sqrt(1 - p.PF**2) == pvwq[pID])
277
279
 
278
280
  # Objective components
279
281
  decs = self.C * (cp.sum(list(Pdec.values())) +
@@ -8,7 +8,7 @@ def _convert(il:Island, t:int, source_bus:str):
8
8
  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'")
9
9
 
10
10
  try:
11
- d = DSS()
11
+ d = DSS() # type: ignore
12
12
  except:
13
13
  d = DSS.DSSDLL() # type: ignore
14
14
  d.text("clear")
@@ -103,8 +103,8 @@ class OpenDSSSolver(SolverBase):
103
103
  self.dss.text("calcv")
104
104
  self.dss.text("solve maxcontrol=10000")
105
105
  if hasattr(self.dss, "circuit"):
106
- bnames = self.dss.circuit.buses_names
107
- bvolt = np.array(self.dss.circuit.buses_volts).reshape(-1, 3, 2)
106
+ bnames = self.dss.circuit.buses_names # type: ignore
107
+ bvolt = np.array(self.dss.circuit.buses_volts).reshape(-1, 3, 2) # type: ignore
108
108
  else:
109
109
  bnames = self.dss.circuit_all_bus_names() # type: ignore
110
110
  bvolt = np.array(self.dss.circuit_all_bus_volts()).reshape(-1, 3, 2) # type: ignore
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: fpowerkit
3
- Version: 0.3.0
4
- Summary: A Distflow PDN solver based on Gurobi.
3
+ Version: 0.3.2
4
+ Summary: A PDN solver with multiple solutions.
5
5
  Author: fmy_xfk
6
6
  Classifier: Programming Language :: Python :: 3
7
7
  Classifier: License :: OSI Approved :: MIT License
@@ -11,13 +11,6 @@ Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: feasytools>=0.0.21
13
13
  Requires-Dist: numpy>=1.19.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
14
 
22
15
  # FPowerKit - A power distribution network calculation component
23
16
 
@@ -5,10 +5,10 @@ with open("desc.md", "r", encoding="utf8") as f:
5
5
 
6
6
  setup(
7
7
  name="fpowerkit",
8
- version="0.3.0",
8
+ version="0.3.2",
9
9
  author="fmy_xfk",
10
10
  packages=find_packages(),
11
- description="A Distflow PDN solver based on Gurobi.",
11
+ description="A PDN solver with multiple solutions.",
12
12
  long_description=long_description,
13
13
  long_description_content_type="text/markdown",
14
14
  classifiers=[
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