Skip to content
Merged
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
37 changes: 26 additions & 11 deletions src/omotes_simulator_core/adapter/transforms/controller_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from omotes_simulator_core.adapter.transforms.string_to_esdl import OmotesAssetLabels
from omotes_simulator_core.adapter.utility.graph import Graph
from omotes_simulator_core.entities.assets.controller import (
ControllerAtestStorage,
ControllerAtesStorage,
ControllerConsumer,
ControllerHeatTransferAsset,
ControllerIdealHeatStorage,
Expand All @@ -51,7 +51,7 @@ class NetworkItems:
heat_transfer_secondary: list[ControllerHeatTransferAsset]
consumer: list[ControllerConsumer]
producer: list[ControllerProducer]
storage: list[ControllerAtestStorage | ControllerIdealHeatStorage]
storage: list[ControllerAtesStorage | ControllerIdealHeatStorage]

def add(
self,
Expand All @@ -62,7 +62,7 @@ def add(
self.consumer.append(asset)
elif isinstance(asset, ControllerProducer):
self.producer.append(asset)
elif isinstance(asset, ControllerAtestStorage) or isinstance(
elif isinstance(asset, ControllerAtesStorage) or isinstance(
asset, ControllerIdealHeatStorage
):
self.storage.append(asset)
Expand Down Expand Up @@ -123,13 +123,7 @@ def to_entity(
if esdl_asset.get_number_of_ports() == 2
]

storages = [
ControllerIdealHeatStorageMapper().to_entity(esdl_asset=esdl_asset)
for esdl_asset in esdl_object.get_all_assets_of_type(OmotesAssetLabels.STORAGE)
] + [
ControllerAtesStorageMapper().to_entity(esdl_asset=esdl_asset)
for esdl_asset in esdl_object.get_all_assets_of_type(OmotesAssetLabels.ATES)
]
storages = self.convert_heat_storages_and_ates(esdl_object)

# if there are no heat transfer assets, all assets can be stored into one network.
if not heat_transfer_assets:
Expand Down Expand Up @@ -201,7 +195,7 @@ def assets_to_networks(
assets: list[
ControllerConsumer
| ControllerProducer
| ControllerAtestStorage
| ControllerAtesStorage
| ControllerIdealHeatStorage
],
) -> None:
Expand Down Expand Up @@ -264,6 +258,27 @@ def heat_transfer_assets_to_network(
)
return network_list

def convert_heat_storages_and_ates(
self, esdl_object: EsdlObject
) -> list[ControllerAtesStorage | ControllerIdealHeatStorage]:
"""Method to convert heat storages and ates to controller storage objects."""
esdl_storages = esdl_object.get_all_assets_of_type(OmotesAssetLabels.STORAGE)
esdl_storages = [
storage
for storage in esdl_storages
if storage.get_esdl_type() == OmotesAssetLabels.STORAGE
]
esdl_ates = esdl_object.get_all_assets_of_type(OmotesAssetLabels.ATES)

storages = [
ControllerIdealHeatStorageMapper().to_entity(esdl_asset=esdl_asset)
for esdl_asset in esdl_storages
] + [
ControllerAtesStorageMapper().to_entity(esdl_asset=esdl_asset)
for esdl_asset in esdl_ates
]
return storages


def belongs_to_network(id: str, network: NetworkItems, graph: Graph) -> bool:
"""Check if the id is connected to a heat transfer asset in the network.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
AssetControllerAbstract,
)
from omotes_simulator_core.entities.assets.controller.controller_storage import (
ControllerAtestStorage,
ControllerAtesStorage,
ControllerIdealHeatStorage,
)
from omotes_simulator_core.entities.assets.controller.profile_interpolation import (
Expand All @@ -43,7 +43,7 @@ def to_esdl(self, entity: AssetControllerAbstract) -> EsdlAssetObject:

def to_entity(
self, esdl_asset: EsdlAssetObject, timestep: Optional[int] = None
) -> ControllerAtestStorage:
) -> ControllerAtesStorage:
"""Method to map an esdl asset to a Ates Storage entity class.

:param EsdlAssetObject model: Object to be converted to an asset entity.
Expand All @@ -59,7 +59,7 @@ def to_entity(
)
resampled_profile = self.profile_interpolator.get_resampled_profile()

return ControllerAtestStorage(
return ControllerAtesStorage(
name=esdl_asset.esdl_asset.name,
identifier=esdl_asset.esdl_asset.id,
temperature_in=esdl_asset.get_temperature("In", "Supply"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from omotes_simulator_core.entities.assets.controller.controller_network import ControllerNetwork
from omotes_simulator_core.entities.assets.controller.controller_producer import ControllerProducer
from omotes_simulator_core.entities.assets.controller.controller_storage import (
ControllerAtestStorage,
ControllerAtesStorage,
ControllerIdealHeatStorage,
ControllerStorageAbstract,
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from omotes_simulator_core.entities.assets.controller.controller_producer import ControllerProducer
from omotes_simulator_core.entities.assets.controller.controller_storage import (
ControllerAtestStorage,
ControllerAtesStorage,
ControllerIdealHeatStorage,
)

Expand All @@ -47,7 +47,7 @@ class ControllerNetwork:
"""List of all consumers in the network."""
producers: list[ControllerProducer]
"""List of all producers in the network."""
storages: list[ControllerAtestStorage | ControllerIdealHeatStorage]
storages: list[ControllerAtesStorage | ControllerIdealHeatStorage]
"""List of all storages in the network."""
factor_to_first_network: float
"""Factor to calculate power in the first network in the list of networks."""
Expand All @@ -60,7 +60,7 @@ def __init__(
heat_transfer_assets_sec_in: list[ControllerHeatTransferAsset],
consumers_in: list[ControllerConsumer],
producers_in: list[ControllerProducer],
storages_in: list[ControllerAtestStorage | ControllerIdealHeatStorage],
storages_in: list[ControllerAtesStorage | ControllerIdealHeatStorage],
factor_to_first_network: float = 1,
) -> None:
"""Constructor of the class, which sets all attributes."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_effective_max_charge_power(
return self.effective_max_charge_power


class ControllerAtestStorage(ControllerStorageAbstract):
class ControllerAtesStorage(ControllerStorageAbstract):
"""Class to store the storage for the controller asset."""

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pandas as pd
from esdl import esdl

from omotes_simulator_core.adapter.transforms.string_to_esdl import StringEsdlAssetMapper
from omotes_simulator_core.adapter.transforms.transform_utils import Port, PortType, sort_ports
from omotes_simulator_core.entities.assets.controller.profile_interpolation import (
ProfileInterpolationMethod,
Expand Down Expand Up @@ -194,6 +195,10 @@ def is_heat_transfer_asset(self) -> bool:
self.esdl_asset, esdl.HeatExchange
)

def get_esdl_type(self) -> str:
"""Returns the ESDL type of the asset as a string."""
return StringEsdlAssetMapper().to_entity(type(self.esdl_asset))


def get_return_temperature(esdl_port: esdl.Port) -> float:
"""Get the temperature of the port."""
Expand Down
Loading