Skip to content

Commit 368466b

Browse files
Expose 3-phase power through the grid
The 3-phase power is needed to calculate the power factor of the microgrid. The power factor is not available through the microgrid API in the current version used in the SDK. So the 3-phase power is temporary exposed through the grid until the migration to the latest version is completed. Then the 3-phase power factor can be fetched and streamed through the microgrid. Signed-off-by: Daniel Zullo <[email protected]>
1 parent a5db21d commit 368466b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/frequenz/sdk/timeseries/grid.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
from ._quantities import Current, Power
2222
from .formula_engine import FormulaEngine, FormulaEngine3Phase
2323
from .formula_engine._formula_engine_pool import FormulaEnginePool
24-
from .formula_engine._formula_generators import GridCurrentFormula, GridPowerFormula
24+
from .formula_engine._formula_generators import (
25+
GridCurrentFormula,
26+
GridPower3PhaseFormula,
27+
GridPowerFormula,
28+
)
2529

2630
if TYPE_CHECKING:
2731
# Break circular import
@@ -95,6 +99,24 @@ def power(self) -> FormulaEngine[Power]:
9599
assert isinstance(engine, FormulaEngine)
96100
return engine
97101

102+
@property
103+
def _power_3_phase(self) -> FormulaEngine3Phase[Power]:
104+
"""Fetch the grid 3-phase power for the microgrid.
105+
106+
This formula produces values that are in the Passive Sign Convention (PSC).
107+
108+
A receiver from the formula engine can be created using the
109+
`new_receiver`method.
110+
111+
Returns:
112+
A FormulaEngine that will calculate and stream grid 3-phase power.
113+
"""
114+
engine = self._formula_pool.from_power_3_phase_formula_generator(
115+
"grid_power_3_phase", GridPower3PhaseFormula
116+
)
117+
assert isinstance(engine, FormulaEngine3Phase)
118+
return engine
119+
98120
@property
99121
def current(self) -> FormulaEngine3Phase[Current]:
100122
"""Fetch the grid current for the microgrid.

0 commit comments

Comments
 (0)