omotes-simulator-core 0.0.3.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omotes_simulator_core-0.0.3.dev0.dist-info/LICENSE +621 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/METADATA +55 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/RECORD +59 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/WHEEL +5 -0
- omotes_simulator_core-0.0.3.dev0.dist-info/top_level.txt +1 -0
- simulator_core/__init__.py +15 -0
- simulator_core/__main__.py +21 -0
- simulator_core/adapter/__init__.py +16 -0
- simulator_core/adapter/presentation/__init__.py +16 -0
- simulator_core/adapter/transforms/__init__.py +16 -0
- simulator_core/adapter/transforms/esdl_asset_mapper.py +53 -0
- simulator_core/adapter/transforms/mappers.py +226 -0
- simulator_core/adapter/transforms/string_to_esdl.py +66 -0
- simulator_core/adapter/transforms/transform_utils.py +34 -0
- simulator_core/entities/__init__.py +16 -0
- simulator_core/entities/assets/__init__.py +16 -0
- simulator_core/entities/assets/asset_abstract.py +116 -0
- simulator_core/entities/assets/asset_defaults.py +68 -0
- simulator_core/entities/assets/controller_classes.py +81 -0
- simulator_core/entities/assets/demand_cluster.py +117 -0
- simulator_core/entities/assets/esdl_asset_object.py +60 -0
- simulator_core/entities/assets/junction.py +64 -0
- simulator_core/entities/assets/pipe.py +174 -0
- simulator_core/entities/assets/production_cluster.py +222 -0
- simulator_core/entities/assets/utils.py +154 -0
- simulator_core/entities/esdl_object.py +90 -0
- simulator_core/entities/heat_network.py +82 -0
- simulator_core/entities/network_controller.py +67 -0
- simulator_core/entities/simulation_configuration.py +31 -0
- simulator_core/entities/utility/__init__.py +16 -0
- simulator_core/entities/utility/influxdb_reader.py +129 -0
- simulator_core/infrastructure/__init__.py +16 -0
- simulator_core/infrastructure/app.py +55 -0
- simulator_core/infrastructure/simulation_manager.py +55 -0
- simulator_core/infrastructure/utils.py +45 -0
- simulator_core/py.typed +0 -0
- simulator_core/simulation/__init__.py +18 -0
- simulator_core/simulation/mappers/__init__.py +16 -0
- simulator_core/simulation/mappers/mappers.py +35 -0
- simulator_core/simulation/networksimulation.py +63 -0
- simulator_core/solver/__init__.py +15 -0
- simulator_core/solver/matrix/__init__.py +15 -0
- simulator_core/solver/matrix/core_enum.py +26 -0
- simulator_core/solver/matrix/equation_object.py +56 -0
- simulator_core/solver/matrix/matrix.py +125 -0
- simulator_core/solver/matrix/utility.py +38 -0
- simulator_core/solver/network/__init__.py +15 -0
- simulator_core/solver/network/assets/__init__.py +15 -0
- simulator_core/solver/network/assets/base_asset.py +303 -0
- simulator_core/solver/network/assets/base_item.py +63 -0
- simulator_core/solver/network/assets/base_node_item.py +67 -0
- simulator_core/solver/network/assets/boundary.py +83 -0
- simulator_core/solver/network/assets/fall_type.py +225 -0
- simulator_core/solver/network/assets/node.py +274 -0
- simulator_core/solver/network/assets/production_asset.py +171 -0
- simulator_core/solver/network/assets/solver_pipe.py +541 -0
- simulator_core/solver/network/network.py +398 -0
- simulator_core/solver/solver.py +80 -0
- simulator_core/solver/utils/fluid_properties.py +173 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
simulator_core/__init__.py,sha256=TRRHUopVEKu2hkNW5lzfNar2eAeoWqCzY8aFZARf_cA,733
|
|
2
|
+
simulator_core/__main__.py,sha256=BDvrVprBDYbyjqwY15WimOw8Bctl-JKAdauv4MuVZaI,830
|
|
3
|
+
simulator_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
simulator_core/adapter/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
5
|
+
simulator_core/adapter/presentation/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
6
|
+
simulator_core/adapter/transforms/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
7
|
+
simulator_core/adapter/transforms/esdl_asset_mapper.py,sha256=ZO2GLYxlQLZmLE6CuLziZFbAgLd4s9EiQ7CQ8rIosQ0,2168
|
|
8
|
+
simulator_core/adapter/transforms/mappers.py,sha256=XDwqMagTUVfgCWm8-PaoWlcXm0XSaHa6IWeJlhpEUpQ,10852
|
|
9
|
+
simulator_core/adapter/transforms/string_to_esdl.py,sha256=qgVCOVydqf7UE8WaRmLEDR_2pzzm7bPL4AqKEJVSKOc,2757
|
|
10
|
+
simulator_core/adapter/transforms/transform_utils.py,sha256=tW0d2LnkC4UPPyZDvxU1aq0qcBViBAGjzszHXxLAlg0,1310
|
|
11
|
+
simulator_core/entities/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
12
|
+
simulator_core/entities/esdl_object.py,sha256=LBYmF4k4qNslmNBWpArbVPW0-cd83BfuGIjwQU9Zumg,3871
|
|
13
|
+
simulator_core/entities/heat_network.py,sha256=rC2gdv44l39tUEucoc2qi55CE_mYUAQdkDXc9aavWDs,3326
|
|
14
|
+
simulator_core/entities/network_controller.py,sha256=1wZ8LBjFkt-3mLd2Shp1yPCeWP1yyrtORYOo_A8Vybg,3411
|
|
15
|
+
simulator_core/entities/simulation_configuration.py,sha256=oZ5fWE6eFIXEY7-WfAr32n_gdQ2PsIVa_QKVCaSQcP8,1063
|
|
16
|
+
simulator_core/entities/assets/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
17
|
+
simulator_core/entities/assets/asset_abstract.py,sha256=4bBIzE_b760VSmYyyB2t5dhh_59IMVADKxz7JJxcrrg,4119
|
|
18
|
+
simulator_core/entities/assets/asset_defaults.py,sha256=UTs6fLRnxg-mSySNg0uE6qyp6_V9yigecwqu30NrPjI,2445
|
|
19
|
+
simulator_core/entities/assets/controller_classes.py,sha256=ESTyMekSCceJrNLs3OSgOI3X-z2G8RigigaNV-VwcoY,3178
|
|
20
|
+
simulator_core/entities/assets/demand_cluster.py,sha256=4vJiaYVHnu-9gG4PRyZK2MEyH_vdW2Po59oFM0th1Po,4883
|
|
21
|
+
simulator_core/entities/assets/esdl_asset_object.py,sha256=cUtINgVUbZG_5u0dXeeHBRE7MWMSL17ifWh_9sH0d9Q,2177
|
|
22
|
+
simulator_core/entities/assets/junction.py,sha256=GdlFJhyV9ahS24MM6eCSKeE0bHfaz6fwu7pUOrWmoZU,2395
|
|
23
|
+
simulator_core/entities/assets/pipe.py,sha256=oaUFp5s54qWMThgA7WOduDQga6B1eR6cQoEcElhdpug,7971
|
|
24
|
+
simulator_core/entities/assets/production_cluster.py,sha256=maIYUVFCbSEsripY7OAdSJCJ-DEHbOsMrsWVKjkwBvw,9236
|
|
25
|
+
simulator_core/entities/assets/utils.py,sha256=m_SStM6f9kCjhpsDsiRIJTpCq1WCI34CvK9mAesgf38,6605
|
|
26
|
+
simulator_core/entities/utility/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
27
|
+
simulator_core/entities/utility/influxdb_reader.py,sha256=cSo15Bhl3nkrgDtFXA0_naf6Xsr4CKUS001WDI5Bulc,5409
|
|
28
|
+
simulator_core/infrastructure/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
29
|
+
simulator_core/infrastructure/app.py,sha256=jKU13EJxI1lFWGrWhyJgjPyGpM07JPNuxqtzfSGQtNI,2033
|
|
30
|
+
simulator_core/infrastructure/simulation_manager.py,sha256=lF3kmWticXdFrKL6ZKT-fpr4TcIxu0g2s49_QxojWzE,2301
|
|
31
|
+
simulator_core/infrastructure/utils.py,sha256=KLrp-AEsR4hKX3vhwStC5PVLt3gPo1bCo-aHXrYBGp4,1670
|
|
32
|
+
simulator_core/simulation/__init__.py,sha256=I3jmv1oaRKVktAw4j7-oPBBVbhj0N7cR1wo0cVBpZlc,784
|
|
33
|
+
simulator_core/simulation/networksimulation.py,sha256=JwkDfsaNSKSl8a8rgqC38kMvxASukzX1Lf1Ls2uEAUs,2641
|
|
34
|
+
simulator_core/simulation/mappers/__init__.py,sha256=0uQyiQt-16nEsoaDvVzwTwQmj7H4zlN_7a3c_H9m1Xg,734
|
|
35
|
+
simulator_core/simulation/mappers/mappers.py,sha256=lxwVnjGDCSoaG-Dy0g-tg-v5STYy6iJh25PFOKC3xJY,1304
|
|
36
|
+
simulator_core/solver/__init__.py,sha256=TRRHUopVEKu2hkNW5lzfNar2eAeoWqCzY8aFZARf_cA,733
|
|
37
|
+
simulator_core/solver/solver.py,sha256=ZWwmcQe9s8UnvcKTOEAteCKYImTMdneukZMs3UOvIog,3200
|
|
38
|
+
simulator_core/solver/matrix/__init__.py,sha256=TRRHUopVEKu2hkNW5lzfNar2eAeoWqCzY8aFZARf_cA,733
|
|
39
|
+
simulator_core/solver/matrix/core_enum.py,sha256=aYzq7L7qdsrgzDPczg-iGM1CH0O2K__E-Egm-KJcU28,943
|
|
40
|
+
simulator_core/solver/matrix/equation_object.py,sha256=OCI3-4Hyw-eg_dMWcdibFASEmCkxF49-RnJmgKglIos,2192
|
|
41
|
+
simulator_core/solver/matrix/matrix.py,sha256=KAIyOCWC2u3MwEPXs43F_65ffBBUkBWF2p5GwaKydFw,5513
|
|
42
|
+
simulator_core/solver/matrix/utility.py,sha256=4LTWEQG9t7uFw9LpwRNpe1xhaOX65bfiYcsBpejI-T4,1490
|
|
43
|
+
simulator_core/solver/network/__init__.py,sha256=TRRHUopVEKu2hkNW5lzfNar2eAeoWqCzY8aFZARf_cA,733
|
|
44
|
+
simulator_core/solver/network/network.py,sha256=d4tnKI5jX6s_897bQeJLK9WS8dMPx4y-kGT0Sv67OM8,17629
|
|
45
|
+
simulator_core/solver/network/assets/__init__.py,sha256=TRRHUopVEKu2hkNW5lzfNar2eAeoWqCzY8aFZARf_cA,733
|
|
46
|
+
simulator_core/solver/network/assets/base_asset.py,sha256=DlANH4uTRQgKjY9PLBZDHjZ6e26PCjxTCwh-txXww8I,12632
|
|
47
|
+
simulator_core/solver/network/assets/base_item.py,sha256=GKJYrhiTtG_M4GrrwiAMxU32SO-K4wcK2i4ZX1jCbq8,2354
|
|
48
|
+
simulator_core/solver/network/assets/base_node_item.py,sha256=SvA_9TK-VJBXxsGIoT9ppuQgmkkiMCupo-L3POrILqQ,2480
|
|
49
|
+
simulator_core/solver/network/assets/boundary.py,sha256=5JZ55Y3Z1WRpQvns8xa0PcQATRn7IgYofpaCyL89jTA,3480
|
|
50
|
+
simulator_core/solver/network/assets/fall_type.py,sha256=l5WeDUo0QbVRu2l2q54LPz45j-KEIkqx0IjM43vn09c,9621
|
|
51
|
+
simulator_core/solver/network/assets/node.py,sha256=no0YdK7HVR7J-KqQV77qxdpAG9r6edGPHy4Uj4wPOA8,11828
|
|
52
|
+
simulator_core/solver/network/assets/production_asset.py,sha256=NxuI_iHlOGew1GhQWthPou0FtxLXEbSE1dcLGUjV8jU,7073
|
|
53
|
+
simulator_core/solver/network/assets/solver_pipe.py,sha256=dMIyUTeeGC8U_SWwbC6w47EJbGJJVMrFVmTFrchFQHg,22136
|
|
54
|
+
simulator_core/solver/utils/fluid_properties.py,sha256=vyDRjD8FLcMTu94l5R3f51r1TfHAqzUgmqOXWNS7c0c,7288
|
|
55
|
+
omotes_simulator_core-0.0.3.dev0.dist-info/LICENSE,sha256=UiCnq3ALVoE2_2UYK0HpZY8amAxQ-6NkJfDt6GrGhlI,32472
|
|
56
|
+
omotes_simulator_core-0.0.3.dev0.dist-info/METADATA,sha256=fJdgRvuVkWC8m7p0nEqo_2Xw4ZNTFx9nNeMrMEGn7DU,2490
|
|
57
|
+
omotes_simulator_core-0.0.3.dev0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
58
|
+
omotes_simulator_core-0.0.3.dev0.dist-info/top_level.txt,sha256=ZQNUqmxeDErBZUWTewBdpG5ixU80gMwZEJad4t3kNLw,15
|
|
59
|
+
omotes_simulator_core-0.0.3.dev0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
simulator_core
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
"""__init__.py file for initialization code."""
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""__main__.py file entry point for testing."""
|
|
17
|
+
|
|
18
|
+
from simulator_core.infrastructure.app import run
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
print(run())
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""__init__.py file for initialization code."""
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""__init__.py file for initialization code."""
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""__init__.py file for initialization code."""
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""Module containing the Esdl to asset mapper class."""
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
import esdl
|
|
20
|
+
|
|
21
|
+
from simulator_core.entities.assets.asset_abstract import AssetAbstract
|
|
22
|
+
from simulator_core.entities.assets.demand_cluster import DemandCluster
|
|
23
|
+
from simulator_core.entities.assets.esdl_asset_object import EsdlAssetObject
|
|
24
|
+
from simulator_core.entities.assets.pipe import Pipe
|
|
25
|
+
from simulator_core.entities.assets.production_cluster import ProductionCluster
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class EsdlAssetMapper:
|
|
29
|
+
"""Creates entity Asset objects based on a PyESDL EnergySystem assets."""
|
|
30
|
+
|
|
31
|
+
conversion_dict = {
|
|
32
|
+
esdl.Producer: ProductionCluster,
|
|
33
|
+
esdl.GenericProducer: ProductionCluster,
|
|
34
|
+
esdl.Consumer: DemandCluster,
|
|
35
|
+
esdl.HeatingDemand: DemandCluster,
|
|
36
|
+
esdl.Pipe: Pipe,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def to_esdl(self, entity: AssetAbstract) -> Any:
|
|
40
|
+
"""Maps entity object to PyEsdl objects."""
|
|
41
|
+
raise NotImplementedError("EsdlAssetMapper.to_esdl()")
|
|
42
|
+
|
|
43
|
+
def to_entity(self, model: EsdlAssetObject) -> AssetAbstract:
|
|
44
|
+
"""Method to map an esdl asset to an asset entity class.
|
|
45
|
+
|
|
46
|
+
:param EsdlAssetObject model: Object to be converted to an asset entity.
|
|
47
|
+
|
|
48
|
+
:return: Entity object.
|
|
49
|
+
"""
|
|
50
|
+
if not type(model.esdl_asset) in self.conversion_dict:
|
|
51
|
+
raise NotImplementedError(str(model.esdl_asset) + " not implemented in conversion")
|
|
52
|
+
return self.conversion_dict[type(model.esdl_asset)](
|
|
53
|
+
model.esdl_asset.name, model.esdl_asset.id)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""Mapper classes."""
|
|
17
|
+
from typing import Dict, List, Tuple
|
|
18
|
+
|
|
19
|
+
from esdl.esdl import Joint as esdl_junction
|
|
20
|
+
|
|
21
|
+
from simulator_core.adapter.transforms.esdl_asset_mapper import EsdlAssetMapper
|
|
22
|
+
from simulator_core.entities.assets.asset_abstract import AssetAbstract
|
|
23
|
+
from simulator_core.entities.assets.controller_classes import (
|
|
24
|
+
ControllerConsumer,
|
|
25
|
+
ControllerSource,
|
|
26
|
+
)
|
|
27
|
+
from simulator_core.entities.assets.junction import Junction
|
|
28
|
+
from simulator_core.entities.assets.utils import Port
|
|
29
|
+
from simulator_core.entities.esdl_object import EsdlObject
|
|
30
|
+
from simulator_core.entities.heat_network import HeatNetwork
|
|
31
|
+
from simulator_core.entities.network_controller import NetworkController
|
|
32
|
+
from simulator_core.simulation.mappers.mappers import EsdlMapperAbstract
|
|
33
|
+
from simulator_core.solver.network.network import Network
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def connect_connected_asset(
|
|
37
|
+
connected_py_assets: List[Tuple[str, Port]],
|
|
38
|
+
junction: Junction,
|
|
39
|
+
py_assets_list: List[AssetAbstract],
|
|
40
|
+
) -> None:
|
|
41
|
+
"""Method to connect assets connected to one asset to the same junction.
|
|
42
|
+
|
|
43
|
+
:param connected_py_assets: List of connected assets
|
|
44
|
+
:param junction: Junction to connect the assets to
|
|
45
|
+
:param py_assets_list: List of assets
|
|
46
|
+
:return: None
|
|
47
|
+
"""
|
|
48
|
+
for connected_py_asset in connected_py_assets:
|
|
49
|
+
index = [py_asset_temp.asset_id for py_asset_temp in py_assets_list].index(
|
|
50
|
+
connected_py_asset[0]
|
|
51
|
+
)
|
|
52
|
+
if connected_py_asset[1] == Port.In: # from
|
|
53
|
+
py_assets_list[index].set_from_junction(from_junction=junction)
|
|
54
|
+
else: # to
|
|
55
|
+
py_assets_list[index].set_to_junction(to_junction=junction)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def replace_joint_in_connected_assets(
|
|
59
|
+
connected_py_assets: List[Tuple[str, Port]],
|
|
60
|
+
py_joint_dict: Dict[str, List[Tuple[str, Port]]],
|
|
61
|
+
py_asset_id: str,
|
|
62
|
+
iteration_limit: int = 10,
|
|
63
|
+
) -> List[Tuple[str, Port]]:
|
|
64
|
+
"""Replace joint with assets connected to the elements.
|
|
65
|
+
|
|
66
|
+
Replace items in the connected_py_assets list that are connected to a Joint
|
|
67
|
+
with the items that are connected to the Joint, except for the current asset.
|
|
68
|
+
|
|
69
|
+
:param connected_py_assets: List of connected assets
|
|
70
|
+
:param py_joint_dict: Dictionary with joint id as key and list of tuples with
|
|
71
|
+
connected asset id and port as value.
|
|
72
|
+
:param py_asset_id: Id of the asset all the connected assets are connected to
|
|
73
|
+
:param iteration_limit: Limit for the number of iterations
|
|
74
|
+
|
|
75
|
+
"""
|
|
76
|
+
replace_bool = True
|
|
77
|
+
while replace_bool and iteration_limit > 0:
|
|
78
|
+
replace_bool = False
|
|
79
|
+
iteration_limit -= 1
|
|
80
|
+
for index, connected_py_asset in enumerate(connected_py_assets):
|
|
81
|
+
connected_py_asset_id, _ = connected_py_asset
|
|
82
|
+
if connected_py_asset_id in py_joint_dict:
|
|
83
|
+
# remove the joint from the list and add the connected assets
|
|
84
|
+
connected_py_assets.pop(index)
|
|
85
|
+
# get the connected assets
|
|
86
|
+
additional_assets = py_joint_dict[connected_py_asset_id].copy()
|
|
87
|
+
# remove the current asset from the list
|
|
88
|
+
for index, additional_asset_properties in enumerate(additional_assets):
|
|
89
|
+
additional_asset_id, _ = additional_asset_properties
|
|
90
|
+
if additional_asset_id == py_asset_id:
|
|
91
|
+
additional_assets.pop(index)
|
|
92
|
+
break
|
|
93
|
+
# add the connected assets to the list
|
|
94
|
+
connected_py_assets.extend(additional_assets)
|
|
95
|
+
replace_bool = True
|
|
96
|
+
break
|
|
97
|
+
if iteration_limit == 0:
|
|
98
|
+
raise RuntimeError("Error in replacing joint in connected assets.")
|
|
99
|
+
else:
|
|
100
|
+
return connected_py_assets
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class EsdlEnergySystemMapper(EsdlMapperAbstract):
|
|
104
|
+
"""Creates a HeatNetwork entity object based on a PyESDL EnergySystem object."""
|
|
105
|
+
|
|
106
|
+
def __init__(self, esdl_object: EsdlObject):
|
|
107
|
+
"""Constructor for esdl to heat network mapper.
|
|
108
|
+
|
|
109
|
+
:param esdl_object: Esdl object to be converted to a Heatnetwork
|
|
110
|
+
"""
|
|
111
|
+
self.esdl_object = esdl_object
|
|
112
|
+
|
|
113
|
+
def to_esdl(self, entity: HeatNetwork) -> EsdlObject:
|
|
114
|
+
"""Method to convert a HeatNetwork object back to an esdlobject.
|
|
115
|
+
|
|
116
|
+
For now this method is not implemented.
|
|
117
|
+
:param HeatNetwork entity: HeatNetwork object to be converted to esdl object
|
|
118
|
+
:return: EsdlObject, which is the converted HeatNetwork object.
|
|
119
|
+
"""
|
|
120
|
+
raise NotImplementedError("EsdlEnergySystemMapper.to_esdl()")
|
|
121
|
+
|
|
122
|
+
def to_entity(self, network: Network) -> Tuple[List[AssetAbstract], List[Junction]]:
|
|
123
|
+
"""Method to convert esdl to Heatnetwork object.
|
|
124
|
+
|
|
125
|
+
This method first converts all assets into a list of assets.
|
|
126
|
+
Next to this a list of Junctions is created. This is then used
|
|
127
|
+
to create the Heatnetwork object.
|
|
128
|
+
:param Network network: netowrk to add the compenents to.
|
|
129
|
+
:return: (List[AssetAbstract], List[Junction]), tuple of list of assets and junctions.
|
|
130
|
+
"""
|
|
131
|
+
# TODO: This method requires a clean-up!
|
|
132
|
+
py_assets_list = []
|
|
133
|
+
py_joint_dict = {}
|
|
134
|
+
for esdl_asset in self.esdl_object.get_all_assets_of_type("asset"):
|
|
135
|
+
# Junctions need to be skipped, as they are replaced by merged pandapipes junctions.
|
|
136
|
+
if isinstance(esdl_asset.esdl_asset, esdl_junction):
|
|
137
|
+
py_joint_dict[esdl_asset.esdl_asset.id] = [
|
|
138
|
+
*self.esdl_object.get_connected_assets(esdl_asset.esdl_asset.id, Port.In),
|
|
139
|
+
*self.esdl_object.get_connected_assets(esdl_asset.esdl_asset.id, Port.Out),
|
|
140
|
+
]
|
|
141
|
+
else:
|
|
142
|
+
py_assets_list.append(EsdlAssetMapper().to_entity(esdl_asset))
|
|
143
|
+
py_assets_list[-1].add_physical_data(esdl_asset=esdl_asset)
|
|
144
|
+
network.add_existing_asset(py_assets_list[-1].solver_asset)
|
|
145
|
+
|
|
146
|
+
py_junction_list = []
|
|
147
|
+
|
|
148
|
+
# loop over assets and create junctions and connect them
|
|
149
|
+
for py_asset in py_assets_list:
|
|
150
|
+
for con_point in range(0, 2):
|
|
151
|
+
if not py_asset.solver_asset.is_connected(con_point):
|
|
152
|
+
connected_py_assets = self.esdl_object.get_connected_assets(
|
|
153
|
+
py_asset.asset_id, Port.In if con_point == 0 else Port.Out
|
|
154
|
+
)
|
|
155
|
+
# Replace items in the connected_py_assets list that are connected to a Joint
|
|
156
|
+
# with the items that are connected to the Joint, except for the current asset.
|
|
157
|
+
connected_py_assets = replace_joint_in_connected_assets(
|
|
158
|
+
connected_py_assets, py_joint_dict, py_asset.asset_id
|
|
159
|
+
)
|
|
160
|
+
for connected_py_asset, connected_py_port in connected_py_assets:
|
|
161
|
+
index = [py_asset_temp.asset_id for py_asset_temp in py_assets_list].index(
|
|
162
|
+
connected_py_asset
|
|
163
|
+
)
|
|
164
|
+
if connected_py_port == Port.In:
|
|
165
|
+
node_id = network.connect_assets(
|
|
166
|
+
asset1_id=py_asset.solver_asset.name,
|
|
167
|
+
connection_point_1=con_point,
|
|
168
|
+
asset2_id=py_assets_list[index].solver_asset.name,
|
|
169
|
+
connection_point_2=0,
|
|
170
|
+
)
|
|
171
|
+
py_junction_list.append(
|
|
172
|
+
Junction(network.get_node(node_id), name=str(node_id))
|
|
173
|
+
)
|
|
174
|
+
py_assets_list[index].set_to_junction(py_junction_list[-1])
|
|
175
|
+
else:
|
|
176
|
+
node_id = network.connect_assets(
|
|
177
|
+
asset1_id=py_asset.solver_asset.name,
|
|
178
|
+
connection_point_1=con_point,
|
|
179
|
+
asset2_id=py_assets_list[index].solver_asset.name,
|
|
180
|
+
connection_point_2=1,
|
|
181
|
+
)
|
|
182
|
+
py_junction_list.append(
|
|
183
|
+
Junction(network.get_node(node_id), name=str(node_id))
|
|
184
|
+
)
|
|
185
|
+
py_assets_list[index].set_from_junction(py_junction_list[-1])
|
|
186
|
+
# connect the connected assets to the junction
|
|
187
|
+
if con_point == 0:
|
|
188
|
+
py_asset.set_to_junction(py_junction_list[-1])
|
|
189
|
+
else:
|
|
190
|
+
py_asset.set_from_junction(py_junction_list[-1])
|
|
191
|
+
|
|
192
|
+
return py_assets_list, py_junction_list
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class EsdlControllerMapper(EsdlMapperAbstract):
|
|
196
|
+
"""Creates a NetworkController entity object based on a PyESDL EnergySystem object."""
|
|
197
|
+
|
|
198
|
+
def to_esdl(self, entity: NetworkController) -> EsdlObject:
|
|
199
|
+
"""Method to convert a NetworkController object to an esdlobject.
|
|
200
|
+
|
|
201
|
+
For now this method is not implemented.
|
|
202
|
+
:param NetworkController entity: NetworkController object to be converted to esdl object
|
|
203
|
+
:return: EsdlObject, which is the converted NetworkController object.
|
|
204
|
+
"""
|
|
205
|
+
raise NotImplementedError("EsdlControllerMapper.to_esdl()")
|
|
206
|
+
|
|
207
|
+
def to_entity(self, model: EsdlObject) -> NetworkController:
|
|
208
|
+
"""Method to convert esdl to NetworkController object.
|
|
209
|
+
|
|
210
|
+
This method first converts all assets into a list of assets.
|
|
211
|
+
Next to this a list of Junctions is created. This is then used
|
|
212
|
+
to create the NetworkController object.
|
|
213
|
+
:param EsdlObject model: EsdlObject object to be converted to NetworkController object
|
|
214
|
+
:return: NetworkController, which is the converted EsdlObject object.
|
|
215
|
+
"""
|
|
216
|
+
consumers = []
|
|
217
|
+
for esdl_asset in model.get_all_assets_of_type("consumer"):
|
|
218
|
+
consumers.append(
|
|
219
|
+
ControllerConsumer(esdl_asset.esdl_asset.name, esdl_asset.esdl_asset.id)
|
|
220
|
+
)
|
|
221
|
+
consumers[-1].add_profile(esdl_asset.get_profile())
|
|
222
|
+
|
|
223
|
+
sources = []
|
|
224
|
+
for esdl_asset in model.get_all_assets_of_type("producer"):
|
|
225
|
+
sources.append(ControllerSource(esdl_asset.esdl_asset.name, esdl_asset.esdl_asset.id))
|
|
226
|
+
return NetworkController(consumers, sources)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
"""Module containing class to convert a string to asdl class type and vica-versa."""
|
|
16
|
+
import esdl
|
|
17
|
+
|
|
18
|
+
from simulator_core.adapter.transforms.transform_utils import reverse_dict
|
|
19
|
+
from typing import List
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class StringEsdlAssetMapper:
|
|
23
|
+
"""Mapper class to convert strings to an esdl class type and vica-versa.
|
|
24
|
+
|
|
25
|
+
Please note that the str_to_type_dict needs to have unique keys and values.
|
|
26
|
+
Also note that fo the esdl class only the derived classes should be listed.
|
|
27
|
+
Otherwise asset might be selected twice, since a HeatingDemand is also and Consumer.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
type_to_str_dict = {
|
|
31
|
+
esdl.Asset: "asset",
|
|
32
|
+
esdl.GenericProducer: "producer",
|
|
33
|
+
esdl.GenericConsumer: "consumer",
|
|
34
|
+
esdl.HeatingDemand: "consumer",
|
|
35
|
+
esdl.GeothermalSource: "geothermal",
|
|
36
|
+
esdl.Conversion: "conversion",
|
|
37
|
+
esdl.Pipe: "pipe",
|
|
38
|
+
esdl.Transport: "transport",
|
|
39
|
+
esdl.Joint: "junction",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
str_to_type_dict = reverse_dict(original_dict=type_to_str_dict)
|
|
43
|
+
|
|
44
|
+
def to_esdl(self, entity: str) -> List[type]:
|
|
45
|
+
"""Method to convert a string to esdl class type.
|
|
46
|
+
|
|
47
|
+
:param str entity: String to be converted to an esdl class type object.
|
|
48
|
+
:return: ESDL class described in the string.
|
|
49
|
+
"""
|
|
50
|
+
if entity not in self.str_to_type_dict:
|
|
51
|
+
raise NotImplementedError(entity + " not implemented in StringESDLAssetMapper class")
|
|
52
|
+
return self.str_to_type_dict[entity]
|
|
53
|
+
|
|
54
|
+
def to_entity(self, entity: type) -> str:
|
|
55
|
+
"""Method to convert esdl type class to a string.
|
|
56
|
+
|
|
57
|
+
The dict values are converted to a list to find the index in the list.
|
|
58
|
+
Then the list of keys is created and the value at the index found is returned.
|
|
59
|
+
:param type entity: ESDl object clas to be converted to a string
|
|
60
|
+
:return: str belonging to the entity.
|
|
61
|
+
"""
|
|
62
|
+
if entity not in self.type_to_str_dict:
|
|
63
|
+
raise NotImplementedError(
|
|
64
|
+
str(entity) + " not implemented in StringESDLAssetMapper class"
|
|
65
|
+
)
|
|
66
|
+
return self.type_to_str_dict[entity]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""File containing utility functions for the transforms."""
|
|
17
|
+
from typing import Dict, List
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def reverse_dict(original_dict: dict) -> Dict[str, List[type]]:
|
|
21
|
+
"""Method to reverse a dict.
|
|
22
|
+
|
|
23
|
+
Creates a dict with set(values) as keys and the keys of the original dict as list values.
|
|
24
|
+
|
|
25
|
+
:param dict original_dict: Dict to be reversed {keys:values}.
|
|
26
|
+
:return: Reversed dict with {set(values):list[keys]}.
|
|
27
|
+
"""
|
|
28
|
+
new_dict = {}
|
|
29
|
+
for key, value in original_dict.items():
|
|
30
|
+
if value not in new_dict:
|
|
31
|
+
new_dict[value] = [key]
|
|
32
|
+
else:
|
|
33
|
+
new_dict[value].append(key)
|
|
34
|
+
return new_dict
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""__init__.py file for initialization code."""
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023. Deltares & TNO
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
"""__init__.py file for initialization code."""
|