-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce and use energy related interfaces in EnergyCalculator in order to not require dtos in energy calculator.
- Loading branch information
Showing
21 changed files
with
355 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
25 changes: 25 additions & 0 deletions
25
src/libecalc/application/energy/component_energy_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import abc | ||
from typing import Optional | ||
|
||
from libecalc.common.utils.rates import TimeSeriesFloat, TimeSeriesStreamDayRate | ||
|
||
|
||
class ComponentEnergyContext(abc.ABC): | ||
""" | ||
The context for which a component should be calculated. | ||
""" | ||
|
||
@abc.abstractmethod | ||
def get_power_requirement(self) -> Optional[TimeSeriesFloat]: | ||
""" | ||
Get power demand for the component. | ||
Returns: | ||
""" | ||
|
||
@abc.abstractmethod | ||
def get_fuel_usage(self) -> Optional[TimeSeriesStreamDayRate]: | ||
""" | ||
Get fuel usage for the component. | ||
Returns: | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import abc | ||
|
||
from libecalc.application.energy.component_energy_context import ComponentEnergyContext | ||
from libecalc.core.result import EcalcModelResult | ||
|
||
|
||
class EnergyComponent(abc.ABC): | ||
""" | ||
A component in the energy model, aka a node in the energy graph. This might be a provider or consumer or both. | ||
TODO: might also be an emitter, which consumes or provides no energy. | ||
""" | ||
|
||
@property | ||
@abc.abstractmethod | ||
def id(self) -> str: ... | ||
|
||
@abc.abstractmethod | ||
def evaluate(self, energy_context: ComponentEnergyContext) -> EcalcModelResult: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import abc | ||
from datetime import datetime | ||
|
||
from libecalc.application.energy.energy_component import EnergyComponent | ||
from libecalc.expression import Expression | ||
|
||
|
||
class EnergyModel(abc.ABC): | ||
""" | ||
Energy model contains energy components which can be consumers, providers, emitters | ||
""" | ||
|
||
@abc.abstractmethod | ||
def get_regularity(self, component_id: str) -> dict[datetime, Expression]: | ||
""" | ||
Temporary solution to get regularity since (dto) components don't have the necessary info to evaluate itself. | ||
""" | ||
... | ||
|
||
@abc.abstractmethod | ||
def get_consumers(self, provider_id: str) -> list[EnergyComponent]: | ||
""" | ||
Get consumers of the given provider | ||
""" | ||
... | ||
|
||
@abc.abstractmethod | ||
def get_energy_components(self) -> list[EnergyComponent]: | ||
""" | ||
Get a sorted list of energy components | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.