Skip to content

Commit 89ca11e

Browse files
Remove the consumption and production power formulas (#697)
Users must understand passive sign conventions to utilize these formulas effectively, and therefore they do not provide significant benefits.
2 parents 5629ea5 + 3dfdb3c commit 89ca11e

File tree

14 files changed

+8
-391
lines changed

14 files changed

+8
-391
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ This version ships an experimental version of the **Power Manager**, adds prelim
6464

6565
- Add consumption and production operators that will replace the logical meters production and consumption function variants.
6666

67+
- Consumption and production power formulas have been removed.
68+
6769
## Bug Fixes
6870

6971
- Fix rendering of diagrams in the documentation.

src/frequenz/sdk/timeseries/battery_pool/_battery_pool.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from ..formula_engine._formula_generators import (
2222
BatteryPowerFormula,
2323
FormulaGeneratorConfig,
24-
FormulaType,
2524
)
2625
from ._battery_pool_reference_store import BatteryPoolReferenceStore
2726
from ._methods import SendOnUpdate
@@ -255,61 +254,6 @@ def power(self) -> FormulaEngine[Power]:
255254
BatteryPowerFormula,
256255
FormulaGeneratorConfig(
257256
component_ids=self._battery_pool._batteries,
258-
formula_type=FormulaType.PASSIVE_SIGN_CONVENTION,
259-
),
260-
)
261-
assert isinstance(engine, FormulaEngine)
262-
return engine
263-
264-
@property
265-
def production_power(self) -> FormulaEngine[Power]:
266-
"""Fetch the total production power of the batteries in the pool.
267-
268-
This formula produces positive values when producing power and 0 otherwise.
269-
270-
If a formula engine to calculate this metric is not already running, it will be
271-
started.
272-
273-
A receiver from the formula engine can be obtained by calling the `new_receiver`
274-
method.
275-
276-
Returns:
277-
A FormulaEngine that will calculate and stream the total production power of
278-
all batteries in the pool.
279-
"""
280-
engine = self._battery_pool._formula_pool.from_power_formula_generator(
281-
"battery_pool_production_power",
282-
BatteryPowerFormula,
283-
FormulaGeneratorConfig(
284-
component_ids=self._battery_pool._batteries,
285-
formula_type=FormulaType.PRODUCTION,
286-
),
287-
)
288-
assert isinstance(engine, FormulaEngine)
289-
return engine
290-
291-
@property
292-
def consumption_power(self) -> FormulaEngine[Power]:
293-
"""Fetch the total consumption power of the batteries in the pool.
294-
295-
This formula produces positive values when consuming power and 0 otherwise.
296-
297-
If a formula engine to calculate this metric is not already running, it will be
298-
started.
299-
300-
A receiver from the formula engine can be obtained by calling the `new_receiver`
301-
method.
302-
303-
Returns:
304-
A FormulaEngine that will calculate and stream the total consumption
305-
power of all batteries in the pool.
306-
"""
307-
engine = self._battery_pool._formula_pool.from_power_formula_generator(
308-
"battery_pool_consumption_power",
309-
BatteryPowerFormula,
310-
FormulaGeneratorConfig(
311-
component_ids=self._battery_pool._batteries,
312-
formula_type=FormulaType.CONSUMPTION,
313257
),
314258
)
315259
assert isinstance(engine, FormulaEngine)

src/frequenz/sdk/timeseries/ev_charger_pool/_ev_charger_pool.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
EVChargerCurrentFormula,
2727
EVChargerPowerFormula,
2828
FormulaGeneratorConfig,
29-
FormulaType,
3029
)
3130
from ._set_current_bounds import BoundsSetter, ComponentCurrentLimit
3231
from ._state_tracker import EVChargerState, StateTracker
@@ -181,61 +180,6 @@ def power(self) -> FormulaEngine[Power]:
181180
EVChargerPowerFormula,
182181
FormulaGeneratorConfig(
183182
component_ids=self._component_ids,
184-
formula_type=FormulaType.PASSIVE_SIGN_CONVENTION,
185-
),
186-
)
187-
assert isinstance(engine, FormulaEngine)
188-
return engine
189-
190-
@property
191-
def production_power(self) -> FormulaEngine[Power]:
192-
"""Fetch the total power produced by the EV Chargers in the pool.
193-
194-
This formula produces positive values when producing power and 0 otherwise.
195-
196-
If a formula engine to calculate EV Charger power is not already running, it
197-
will be started.
198-
199-
A receiver from the formula engine can be created using the `new_receiver`
200-
method.
201-
202-
Returns:
203-
A FormulaEngine that will calculate and stream the production power of all
204-
EV Chargers.
205-
"""
206-
engine = self._formula_pool.from_power_formula_generator(
207-
"ev_charger_production_power",
208-
EVChargerPowerFormula,
209-
FormulaGeneratorConfig(
210-
component_ids=self._component_ids,
211-
formula_type=FormulaType.PRODUCTION,
212-
),
213-
)
214-
assert isinstance(engine, FormulaEngine)
215-
return engine
216-
217-
@property
218-
def consumption_power(self) -> FormulaEngine[Power]:
219-
"""Fetch the total power consumed by the EV Chargers in the pool.
220-
221-
This formula produces positive values when consuming power and 0 otherwise.
222-
223-
If a formula engine to calculate EV Charger power is not already running, it
224-
will be started.
225-
226-
A receiver from the formula engine can be created using the `new_receiver`
227-
method.
228-
229-
Returns:
230-
A FormulaEngine that will calculate and stream the consumption power of all
231-
EV Chargers.
232-
"""
233-
engine = self._formula_pool.from_power_formula_generator(
234-
"ev_charger_consumption_power",
235-
EVChargerPowerFormula,
236-
FormulaGeneratorConfig(
237-
component_ids=self._component_ids,
238-
formula_type=FormulaType.CONSUMPTION,
239183
),
240184
)
241185
assert isinstance(engine, FormulaEngine)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
FormulaGenerationError,
1414
FormulaGenerator,
1515
FormulaGeneratorConfig,
16-
FormulaType,
1716
)
1817
from ._grid_current_formula import GridCurrentFormula
1918
from ._grid_power_formula import GridPowerFormula
@@ -26,7 +25,6 @@
2625
#
2726
"FormulaGenerator",
2827
"FormulaGeneratorConfig",
29-
"FormulaType",
3028
#
3129
# Power Formula generators
3230
#

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_battery_power_formula.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
NON_EXISTING_COMPONENT_ID,
1414
ComponentNotFound,
1515
FormulaGenerator,
16-
FormulaType,
1716
)
1817

1918
_logger = logging.getLogger(__name__)
@@ -78,12 +77,5 @@ def generate(
7877
builder.push_oper("+")
7978
builder.push_component_metric(comp.component_id, nones_are_zeros=True)
8079
builder.push_oper(")")
81-
if self._config.formula_type == FormulaType.PRODUCTION:
82-
builder.push_oper("*")
83-
builder.push_constant(-1)
84-
builder.push_oper(")")
85-
86-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
87-
builder.push_clipper(0.0, None)
8880

8981
return builder.build()

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_chp_power_formula.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
NON_EXISTING_COMPONENT_ID,
1616
FormulaGenerationError,
1717
FormulaGenerator,
18-
FormulaType,
1918
)
2019

2120
_logger = logging.getLogger(__name__)
@@ -58,13 +57,6 @@ def generate( # noqa: DOC502 (FormulaGenerationError is raised indirectly by _g
5857
builder.push_oper("+")
5958
builder.push_component_metric(chp_meter_id, nones_are_zeros=False)
6059
builder.push_oper(")")
61-
if self._config.formula_type == FormulaType.PRODUCTION:
62-
builder.push_oper("*")
63-
builder.push_constant(-1)
64-
builder.push_oper(")")
65-
66-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
67-
builder.push_clipper(0.0, None)
6860

6961
return builder.build()
7062

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_ev_charger_power_formula.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ....microgrid.component import ComponentMetricId
99
from ..._quantities import Power
1010
from .._formula_engine import FormulaEngine
11-
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator, FormulaType
11+
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator
1212

1313
_logger = logging.getLogger(__name__)
1414

@@ -48,12 +48,5 @@ def generate(self) -> FormulaEngine[Power]:
4848
builder.push_oper("+")
4949
builder.push_component_metric(component_id, nones_are_zeros=True)
5050
builder.push_oper(")")
51-
if self._config.formula_type == FormulaType.PRODUCTION:
52-
builder.push_oper("*")
53-
builder.push_constant(-1)
54-
builder.push_oper(")")
55-
56-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
57-
builder.push_clipper(0.0, None)
5851

5952
return builder.build()

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_formula_generator.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from collections import abc
1010
from collections.abc import Callable
1111
from dataclasses import dataclass
12-
from enum import Enum
1312
from typing import Generic
1413

1514
from frequenz.channels import Sender
@@ -41,35 +40,13 @@ class ComponentNotFound(FormulaGenerationError):
4140
"""
4241

4342

44-
class FormulaType(Enum):
45-
"""Enum representing type of formula outputs."""
46-
47-
PASSIVE_SIGN_CONVENTION = 1
48-
"""Formula output will be signed values, following the passive sign convention, with
49-
consumption from the grid being positive and production to the grid being negative.
50-
"""
51-
52-
PRODUCTION = 2
53-
"""Formula output will be unsigned values representing production to the grid. When
54-
power is being consumed from the grid instead, this formula will output zero.
55-
"""
56-
57-
CONSUMPTION = 3
58-
"""Formula output will be unsigned values representing consumption from the grid.
59-
When power is being produced to the grid instead, this formula will output zero.
60-
"""
61-
62-
6343
@dataclass(frozen=True)
6444
class FormulaGeneratorConfig:
6545
"""Config for formula generators."""
6646

6747
component_ids: abc.Set[int] | None = None
6848
"""The component IDs to use for generating the formula."""
6949

70-
formula_type: FormulaType = FormulaType.PASSIVE_SIGN_CONVENTION
71-
"""The type of formula output."""
72-
7350

7451
class FormulaGenerator(ABC, Generic[QuantityT]):
7552
"""A class for generating formulas from the component graph."""

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_grid_power_formula.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ....microgrid.component import ComponentCategory, ComponentMetricId
77
from ..._quantities import Power
88
from .._formula_engine import FormulaEngine
9-
from ._formula_generator import FormulaGenerator, FormulaType
9+
from ._formula_generator import FormulaGenerator
1010

1111

1212
class GridPowerFormula(FormulaGenerator[Power]):
@@ -67,12 +67,4 @@ def generate( # noqa: DOC502
6767
)
6868
builder.push_oper(")")
6969

70-
if self._config.formula_type == FormulaType.PRODUCTION:
71-
builder.push_oper("*")
72-
builder.push_constant(-1)
73-
builder.push_oper(")")
74-
75-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
76-
builder.push_clipper(0.0, None)
77-
7870
return builder.build()

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_pv_power_formula.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ....microgrid.component import ComponentCategory, ComponentMetricId
1010
from ..._quantities import Power
1111
from .._formula_engine import FormulaEngine
12-
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator, FormulaType
12+
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator
1313

1414
_logger = logging.getLogger(__name__)
1515

@@ -69,12 +69,5 @@ def generate( # noqa: DOC502
6969
nones_are_zeros=component.category != ComponentCategory.METER,
7070
)
7171
builder.push_oper(")")
72-
if self._config.formula_type == FormulaType.PRODUCTION:
73-
builder.push_oper("*")
74-
builder.push_constant(-1)
75-
builder.push_oper(")")
76-
77-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
78-
builder.push_clipper(0.0, None)
7972

8073
return builder.build()

0 commit comments

Comments
 (0)