fpowerkit 0.5.1__tar.gz → 0.5.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.5.1 → fpowerkit-0.5.2}/PKG-INFO +1 -1
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/soldist.py +67 -6
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/pyproject.toml +1 -1
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/.gitignore +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/LICENSE +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/README.md +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/bench_parameter_reuse.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/desc.md +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/__init__.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/bus.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/cases.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/comb.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/ess.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/gen.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/grid.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/island.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/line.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/lpwrapper.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/pvwind.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solbase.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solcmb.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solcvx.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/soldc.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/soldcopf.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/soldss.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solldf.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solldf2.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solnt.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solpq.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/solsw.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/fpowerkit/utils.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/main.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/test.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/test314t.py +0 -0
- {fpowerkit-0.5.1 → fpowerkit-0.5.2}/test_cmb.py +0 -0
|
@@ -56,7 +56,10 @@ class DistFlowSolver(LRSolverBase):
|
|
|
56
56
|
def UpdateGrid(self, grid: Grid, cut_overflow_lines: bool = False):
|
|
57
57
|
if cut_overflow_lines:
|
|
58
58
|
for lID in getattr(self, "_oflines", set()):
|
|
59
|
-
self.grid.Line(lID)
|
|
59
|
+
line = self.grid.Line(lID)
|
|
60
|
+
line.active = False
|
|
61
|
+
# A disconnected line must not retain its pre-trip results.
|
|
62
|
+
line.I = line.P = line.Q = 0.0
|
|
60
63
|
super().UpdateGrid(grid)
|
|
61
64
|
if hasattr(self, "_cvx_cache"):
|
|
62
65
|
self._cvx_cache.clear()
|
|
@@ -65,6 +68,9 @@ class DistFlowSolver(LRSolverBase):
|
|
|
65
68
|
|
|
66
69
|
def solve(self, _t: int, /, *, timeout_s: float = 1) -> 'tuple[GridSolveResult, float]':
|
|
67
70
|
'''Get the best result at time _t, return a tuple: (result status, optimal objective value).'''
|
|
71
|
+
# Collect overflow records across all islands in this grid solve.
|
|
72
|
+
self._ofbuses.clear()
|
|
73
|
+
self._oflines.clear()
|
|
68
74
|
allOK = True
|
|
69
75
|
allFail = True
|
|
70
76
|
val = 0
|
|
@@ -73,7 +79,7 @@ class DistFlowSolver(LRSolverBase):
|
|
|
73
79
|
r, v = self.solve_island(i, il, _t, timeout_s, relax, relax)
|
|
74
80
|
self._islands[i].result = r
|
|
75
81
|
self._islands[i].result_value = v
|
|
76
|
-
if r == IslandResult.Failed:
|
|
82
|
+
if r == IslandResult.Failed and not self._is_unpowered_island(il, _t):
|
|
77
83
|
self.__il_relax[i] = True
|
|
78
84
|
r, v = self.solve_island(i, il, _t, timeout_s, True, True)
|
|
79
85
|
self._islands[i].result = r
|
|
@@ -593,8 +599,53 @@ class DistFlowSolver(LRSolverBase):
|
|
|
593
599
|
self._set_parameter(p["reduce_limit"][bus], lim.Limit(_t) * self._mlrp,
|
|
594
600
|
f"reduce_limit[{bus}]")
|
|
595
601
|
|
|
602
|
+
def _is_unpowered_island(self, island: Island, _t: int) -> bool:
|
|
603
|
+
"""Identify passive islands without a modeled source of active power.
|
|
604
|
+
|
|
605
|
+
Dormant internal V2G bids are omitted by the baseline CVXPY model;
|
|
606
|
+
their mere presence must not make a disconnected load island live.
|
|
607
|
+
Keep islands with conventional generators, active V2G, PV/wind,
|
|
608
|
+
storage, fixed voltage or negative active demand on the normal path.
|
|
609
|
+
"""
|
|
610
|
+
if island.PVWs or island.ESSs:
|
|
611
|
+
return False
|
|
612
|
+
if any(not getattr(g, "IsV2GBidGroup", False)
|
|
613
|
+
for _, g in island.GenItems()):
|
|
614
|
+
return False
|
|
615
|
+
if self._has_active_v2g(island, _t):
|
|
616
|
+
return False
|
|
617
|
+
return all(not bus.FixedV and bus.Pd(_t) >= 0.0
|
|
618
|
+
for _, bus in island.BusItems())
|
|
619
|
+
|
|
620
|
+
def _clear_unpowered_island(self, island: Island):
|
|
621
|
+
"""Reset realized results without changing load or device schedules."""
|
|
622
|
+
for bID, bus in island.BusItems():
|
|
623
|
+
bus._v = 0.0
|
|
624
|
+
bus._t = 0.0
|
|
625
|
+
if not getattr(island.grid, "_holdShadowPrice", False):
|
|
626
|
+
bus.ShadowPrice = 0.0
|
|
627
|
+
if bID in self._decb:
|
|
628
|
+
self._decb[bID].Reduction = 0.0
|
|
629
|
+
for _, line in island.LineItems():
|
|
630
|
+
line.I = line.P = line.Q = 0.0
|
|
631
|
+
# Only dormant internal V2G generators can remain in such an island.
|
|
632
|
+
for _, gen in island.GenItems():
|
|
633
|
+
gen._p = gen._q = 0.0
|
|
634
|
+
|
|
596
635
|
def solve_island(self, il_idx: int, island: Island, _t: int, timeout_s: float,
|
|
597
636
|
relaxV: bool, relaxI: bool, clear_results: bool = False) -> 'tuple[IslandResult, float]':
|
|
637
|
+
# Replace this island's own previous records, not other islands'.
|
|
638
|
+
# This also supports callers that invoke solve_island directly.
|
|
639
|
+
self._ofbuses.difference_update(island.Buses)
|
|
640
|
+
self._oflines.difference_update(island.Lines)
|
|
641
|
+
|
|
642
|
+
# After over-current protection, a passive island can have no lines
|
|
643
|
+
# or generator variables. Do not pass its degenerate model to ECOS.
|
|
644
|
+
# Return Failed so the caller can identify its buses as de-energized.
|
|
645
|
+
if self._is_unpowered_island(island, _t):
|
|
646
|
+
self._clear_unpowered_island(island)
|
|
647
|
+
return IslandResult.Failed, -1.0
|
|
648
|
+
|
|
598
649
|
try:
|
|
599
650
|
import cvxpy as cp
|
|
600
651
|
from cvxpy import Variable as Var
|
|
@@ -730,17 +781,27 @@ class DistFlowSolver(LRSolverBase):
|
|
|
730
781
|
pv._cr = 1 - pv._pr / pgen if pgen > 0 else 0
|
|
731
782
|
|
|
732
783
|
overflow = False
|
|
733
|
-
self._ofbuses.clear()
|
|
734
784
|
if relaxV:
|
|
735
785
|
for bID, bv in chain(dvmax.items(), dvmin.items()):
|
|
736
786
|
if self.__chkv(bv.value) > 1e-8:
|
|
737
787
|
overflow = True
|
|
738
788
|
self._ofbuses.add(bID)
|
|
739
789
|
|
|
740
|
-
self._oflines.clear()
|
|
741
790
|
if relaxI:
|
|
742
|
-
for lID,
|
|
743
|
-
if
|
|
791
|
+
for lID, line in island.LineItems():
|
|
792
|
+
if not math.isfinite(line.max_I):
|
|
793
|
+
continue
|
|
794
|
+
|
|
795
|
+
i_actual = math.sqrt(
|
|
796
|
+
max(0.0, self.__chkv(l[lID].value))
|
|
797
|
+
) * island.grid.Ib
|
|
798
|
+
|
|
799
|
+
i_limit = float(line.max_I)
|
|
800
|
+
|
|
801
|
+
# Numerical tolerance: 0.1% of the current limit.
|
|
802
|
+
tol = max(1e-6, 1e-3 * i_limit)
|
|
803
|
+
|
|
804
|
+
if i_actual > i_limit + tol:
|
|
744
805
|
overflow = True
|
|
745
806
|
self._oflines.add(lID)
|
|
746
807
|
|
|
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
|
|
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
|
|
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
|