Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benchmarks/power_distribution/power_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async def run_test( # pylint: disable=too-many-locals
battery_status_channel = Broadcast[ComponentPoolStatus]("battery-status")
power_result_channel = Broadcast[Result]("power-result")
async with PowerDistributingActor(
component_category=ComponentCategory.BATTERY,
requests_receiver=power_request_channel.new_receiver(),
results_sender=power_result_channel.new_sender(),
component_pool_status_sender=battery_status_channel.new_sender(),
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/timeseries/benchmark_ringbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ def main() -> None:
"Time to fill 29 days with data:\n\t"
+ f"Array: {array_times['fill']} seconds\n\t"
+ f"List: {list_times['fill']} seconds\n\t"
+ f"Diff: {array_times['fill'] - list_times['fill']}"
+ f"Diff: {array_times['fill'] - list_times['fill']}"
)

print(
"Day-Slices into 29 days with data:\n\t"
+ f"Array: {array_times['test']/num_runs} seconds\n\t"
+ f"List: {list_times['test']/num_runs} seconds\n\t"
+ f"Diff: {array_times['test']/num_runs - list_times['test']/num_runs}"
+ f"Diff: {array_times['test']/num_runs - list_times['test']/num_runs}"
)

print(f" {''.join(['='] * (num_runs + 1))}")
Expand All @@ -195,15 +195,15 @@ def main() -> None:
"Avg of windows of 29 days and running average & mean on every day:\n\t"
+ f"Array: {slicing_array_times['avg']/num_runs} seconds\n\t"
+ f"List: {slicing_list_times['avg']/num_runs} seconds\n\t"
+ f"Diff: {slicing_array_times['avg']/num_runs - slicing_list_times['avg']/num_runs}"
+ f"Diff: {slicing_array_times['avg']/num_runs - slicing_list_times['avg']/num_runs}"
)

print(
"Median of windows of 29 days and running average & mean on every day:\n\t"
+ f"Array: {slicing_array_times['median']/num_runs} seconds\n\t"
+ f"List: {slicing_list_times['median']/num_runs} seconds\n\t"
+ "Diff: "
+ f"{slicing_array_times['median']/num_runs - slicing_list_times['median']/num_runs}"
+ f"{slicing_array_times['median']/num_runs - slicing_list_times['median']/num_runs}"
)


Expand Down
15 changes: 10 additions & 5 deletions src/frequenz/sdk/actor/_power_managing/_power_managing_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,22 @@ def _add_bounds_tracker(self, component_ids: frozenset[int]) -> None:
microgrid,
)

if self._component_category is not ComponentCategory.BATTERY:
bounds_receiver: Receiver[SystemBounds]
# pylint: disable=protected-access
if self._component_category is ComponentCategory.BATTERY:
battery_pool = microgrid.battery_pool(component_ids)
bounds_receiver = battery_pool._system_power_bounds.new_receiver()
elif self._component_category is ComponentCategory.EV_CHARGER:
ev_charger_pool = microgrid.ev_charger_pool(component_ids)
bounds_receiver = ev_charger_pool._system_power_bounds.new_receiver()
# pylint: enable=protected-access
else:
err = (
"PowerManagingActor: Unsupported component category: "
f"{self._component_category}"
)
_logger.error(err)
raise NotImplementedError(err)
battery_pool = microgrid.battery_pool(component_ids)
# pylint: disable=protected-access
bounds_receiver = battery_pool._system_power_bounds.new_receiver()
# pylint: enable=protected-access

self._system_bounds[component_ids] = SystemBounds(
timestamp=datetime.now(tz=timezone.utc),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

from ._battery_manager import BatteryManager
from ._component_manager import ComponentManager
from ._ev_charger_manager import EVChargerManager

__all__ = [
"BatteryManager",
"ComponentManager",
"EVChargerManager",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH

"""Manage ev chargers for the power distributor."""

from ._ev_charger_manager import EVChargerManager

__all__ = [
"EVChargerManager",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# License: MIT
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH

"""Configuration for the power distributor's EV charger manager."""

from collections import abc
from dataclasses import dataclass, field
from datetime import timedelta

from .....timeseries import Current


@dataclass(frozen=True)
class EVDistributionConfig:
"""Configuration for the power distributor's EV charger manager."""

component_ids: abc.Set[int]
"""The component ids of the EV chargers."""

min_current: Current = field(default_factory=lambda: Current.from_amperes(6.0))
"""The minimum current that can be allocated to an EV charger."""

initial_current: Current = field(default_factory=lambda: Current.from_amperes(10.0))
"""The initial current that can be allocated to an EV charger."""

increase_power_interval: timedelta = timedelta(seconds=30)
"""The interval at which the power can be increased for an EV charger."""
Loading