Skip to content

Commit 8905ed6

Browse files
Add 3-phase voltage to inverter data
The voltage was missing from the inverter data. Signed-off-by: Daniel Zullo <[email protected]>
1 parent efa3cf5 commit 8905ed6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/frequenz/sdk/microgrid/component/_component_data.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ class InverterData(ComponentData):
237237
-ve current means supply into the grid.
238238
"""
239239

240+
voltage_per_phase: tuple[float, float, float]
241+
"""The AC voltage in Volts (V) between the line and the neutral wire for
242+
phase/line 1, 2 and 3 respectively.
243+
"""
244+
240245
# pylint: disable=line-too-long
241246
active_power_inclusion_lower_bound: float
242247
"""Lower inclusion bound for inverter power in watts.
@@ -312,6 +317,11 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> InverterData:
312317
raw.inverter.data.ac.phase_2.current.value,
313318
raw.inverter.data.ac.phase_3.current.value,
314319
),
320+
voltage_per_phase=(
321+
raw.inverter.data.ac.phase_1.voltage.value,
322+
raw.inverter.data.ac.phase_2.voltage.value,
323+
raw.inverter.data.ac.phase_3.voltage.value,
324+
),
315325
active_power_inclusion_lower_bound=raw_power.system_inclusion_bounds.lower,
316326
active_power_exclusion_lower_bound=raw_power.system_exclusion_bounds.lower,
317327
active_power_inclusion_upper_bound=raw_power.system_inclusion_bounds.upper,

tests/microgrid/test_component_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ def test_inverter_data() -> None:
5252
),
5353
phase_1=electrical_pb2.AC.ACPhase(
5454
current=metrics_pb2.Metric(value=12.3),
55+
voltage=metrics_pb2.Metric(value=229.8),
5556
),
5657
phase_2=electrical_pb2.AC.ACPhase(
5758
current=metrics_pb2.Metric(value=23.4),
59+
voltage=metrics_pb2.Metric(value=230.0),
5860
),
5961
phase_3=electrical_pb2.AC.ACPhase(
6062
current=metrics_pb2.Metric(value=34.5),
63+
voltage=metrics_pb2.Metric(value=230.2),
6164
),
6265
),
6366
),
@@ -76,6 +79,7 @@ def test_inverter_data() -> None:
7679
assert inv_data.frequency == pytest.approx(50.1)
7780
assert inv_data.active_power == pytest.approx(100.2)
7881
assert inv_data.current_per_phase == pytest.approx((12.3, 23.4, 34.5))
82+
assert inv_data.voltage_per_phase == pytest.approx((229.8, 230.0, 230.2))
7983
assert inv_data.active_power_inclusion_lower_bound == pytest.approx(-51_000.0)
8084
assert inv_data.active_power_inclusion_upper_bound == pytest.approx(51_000.0)
8185
assert inv_data.active_power_exclusion_lower_bound == pytest.approx(-501.0)

tests/utils/component_data_wrapper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def __init__( # pylint: disable=too-many-arguments
102102
timestamp: datetime,
103103
active_power: float = math.nan,
104104
current_per_phase: tuple[float, float, float] | None = None,
105+
voltage_per_phase: tuple[float, float, float] | None = None,
105106
active_power_inclusion_lower_bound: float = math.nan,
106107
active_power_exclusion_lower_bound: float = math.nan,
107108
active_power_inclusion_upper_bound: float = math.nan,
@@ -126,6 +127,11 @@ def __init__( # pylint: disable=too-many-arguments
126127
if current_per_phase
127128
else (math.nan, math.nan, math.nan)
128129
),
130+
voltage_per_phase=(
131+
voltage_per_phase
132+
if voltage_per_phase
133+
else (math.nan, math.nan, math.nan)
134+
),
129135
active_power_inclusion_lower_bound=active_power_inclusion_lower_bound,
130136
active_power_exclusion_lower_bound=active_power_exclusion_lower_bound,
131137
active_power_inclusion_upper_bound=active_power_inclusion_upper_bound,

0 commit comments

Comments
 (0)