Skip to content

Commit 174ae10

Browse files
Remove _soc formula from the LogicalMeter
This feature has been moved to the BatteryPool. Signed-off-by: ela-kotulska-frequenz <[email protected]>
1 parent 21e569f commit 174ae10

File tree

5 files changed

+1
-183
lines changed

5 files changed

+1
-183
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
9+
* Remove `_soc` formula from the LogicalMeter. This feature has been moved to the BatteryPool.
1010

1111
## New Features
1212

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""Generators for formulas from component graphs."""
55

66
from ._battery_power_formula import BatteryPowerFormula
7-
from ._battery_soc_formula import BatterySoCFormula
87
from ._ev_charger_current_formula import EVChargerCurrentFormula
98
from ._ev_charger_power_formula import EVChargerPowerFormula
109
from ._formula_generator import (
@@ -28,7 +27,6 @@
2827
#
2928
"GridPowerFormula",
3029
"BatteryPowerFormula",
31-
"BatterySoCFormula",
3230
"EVChargerPowerFormula",
3331
"PVPowerFormula",
3432
#

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_battery_soc_formula.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/frequenz/sdk/timeseries/logical_meter/_logical_meter.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from .._formula_engine import FormulaEnginePool, FormulaReceiver, FormulaReceiver3Phase
1717
from .._formula_engine._formula_generators import (
1818
BatteryPowerFormula,
19-
BatterySoCFormula,
2019
GridCurrentFormula,
2120
GridPowerFormula,
2221
PVPowerFormula,
@@ -196,14 +195,3 @@ async def pv_power(self) -> FormulaReceiver:
196195
197196
"""
198197
return await self._formula_pool.from_generator("pv_power", PVPowerFormula)
199-
200-
async def _soc(self) -> FormulaReceiver:
201-
"""Fetch the SoC of the active batteries in the microgrid.
202-
203-
NOTE: This method is part of the logical meter only temporarily, and will get
204-
moved to the `BatteryPool` within the next few releases.
205-
206-
Returns:
207-
A *new* receiver that will stream average SoC of active batteries.
208-
"""
209-
return await self._formula_pool.from_generator("soc", BatterySoCFormula)

tests/timeseries/test_logical_meter.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
from __future__ import annotations
77

8-
from math import isclose
9-
108
from pytest_mock import MockerFixture
119

1210
from frequenz.sdk import microgrid
@@ -188,67 +186,3 @@ async def test_battery_and_pv_power( # pylint: disable=too-many-locals
188186
assert equal_float_lists(battery_results, battery_inv_sums)
189187
assert len(pv_results) == 10
190188
assert equal_float_lists(pv_results, pv_inv_sums)
191-
192-
async def test_soc(self, mocker: MockerFixture) -> None:
193-
"""Test the soc calculation."""
194-
mockgrid = MockMicrogrid(grid_side_meter=False, sample_rate_s=0.02)
195-
mockgrid.add_solar_inverters(2)
196-
mockgrid._id_increment = 8 # pylint: disable=protected-access
197-
mockgrid.add_batteries(3)
198-
request_chan, channel_registry = await mockgrid.start(mocker)
199-
logical_meter = LogicalMeter(
200-
channel_registry,
201-
request_chan.new_sender(),
202-
microgrid.get().component_graph,
203-
)
204-
205-
soc_recv = await logical_meter._soc() # pylint: disable=protected-access
206-
207-
bat_receivers = {
208-
bat_id: await get_resampled_stream(
209-
logical_meter,
210-
channel_registry,
211-
request_chan.new_sender(),
212-
bat_id,
213-
ComponentMetricId.SOC,
214-
)
215-
for bat_id in mockgrid.battery_ids
216-
}
217-
218-
bat_inv_map = mockgrid.bat_inv_map
219-
inv_receivers = {
220-
inverter_id: await get_resampled_stream(
221-
logical_meter,
222-
channel_registry,
223-
request_chan.new_sender(),
224-
inverter_id,
225-
ComponentMetricId.ACTIVE_POWER,
226-
)
227-
for inverter_id in mockgrid.bat_inv_map.values()
228-
}
229-
230-
await synchronize_receivers(
231-
[soc_recv, *bat_receivers.values(), *inv_receivers.values()]
232-
)
233-
234-
for _ in range(10):
235-
bat_vals = []
236-
for bat_id, bat_recv in bat_receivers.items():
237-
inv_id = bat_inv_map[bat_id]
238-
inv_recv = inv_receivers[inv_id]
239-
inv_msg = await inv_recv.receive()
240-
# We won't use batteries where adjacent inverter is not sending active
241-
# power.
242-
if inv_msg.value is None:
243-
continue
244-
245-
val = await bat_recv.receive()
246-
assert val is not None and val.value is not None
247-
bat_vals.append(val.value)
248-
249-
soc_sample = await soc_recv.receive()
250-
assert soc_sample is not None and soc_sample.value is not None
251-
252-
assert isclose(soc_sample.value, sum(bat_vals) / len(bat_vals))
253-
254-
await mockgrid.cleanup()

0 commit comments

Comments
 (0)