From 3634bbbc58b38752f80d57f878005ed6d4124cb3 Mon Sep 17 00:00:00 2001 From: Sam van der Zwan Date: Tue, 22 Oct 2024 09:46:12 +0200 Subject: [PATCH 1/3] Fixed supply temperature not set correctly. --- src/omotes_simulator_core/entities/assets/demand_cluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omotes_simulator_core/entities/assets/demand_cluster.py b/src/omotes_simulator_core/entities/assets/demand_cluster.py index 5a4a2565..8b070341 100644 --- a/src/omotes_simulator_core/entities/assets/demand_cluster.py +++ b/src/omotes_simulator_core/entities/assets/demand_cluster.py @@ -83,7 +83,7 @@ def set_setpoints(self, setpoints: Dict) -> None: adjusted_mass_flowrate = heat_demand_and_temperature_to_mass_flow( self.thermal_power_allocation, self.temperature_supply, self.temperature_return_target ) - self.solver_asset.supply_temperature = self.temperature_return_target + self.solver_asset.supply_temperature = self.temperature_supply self.solver_asset.mass_flow_rate_set_point = adjusted_mass_flowrate # type: ignore def add_physical_data(self, esdl_asset: EsdlAssetObject) -> None: From ebb96e4f8411a91aab603f593f5ab47e351636fe Mon Sep 17 00:00:00 2001 From: Sam van der Zwan Date: Tue, 22 Oct 2024 14:50:42 +0200 Subject: [PATCH 2/3] Set the use of supply and eturn temperature correct in the code, and made the required switch in the mapper --- .../adapter/transforms/esdl_asset_mapper.py | 14 ++++++++------ .../entities/assets/demand_cluster.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py b/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py index 0f377066..0ac1f219 100644 --- a/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py +++ b/src/omotes_simulator_core/adapter/transforms/esdl_asset_mapper.py @@ -119,8 +119,10 @@ def to_entity(self, esdl_asset: EsdlAssetObject) -> ControllerConsumer: if power == 0: power = np.inf - temperature_supply = esdl_asset.get_supply_temperature("In") - temperature_return = esdl_asset.get_return_temperature("Out") + # It looks like they are switch, but this is because of the definition used in ESDL, + # which is different as what we use. + temperature_supply = esdl_asset.get_return_temperature("Out") + temperature_return = esdl_asset.get_supply_temperature("In") profile = esdl_asset.get_profile() contr_consumer = ControllerConsumer( name=esdl_asset.esdl_asset.name, @@ -147,14 +149,14 @@ def to_entity(self, esdl_asset: EsdlAssetObject) -> ControllerStorage: :return: Entity object. """ - result = esdl_asset.get_property(esdl_property_name="maxDischargeRate", - default_value=np.inf) + result = esdl_asset.get_property( + esdl_property_name="maxDischargeRate", default_value=np.inf + ) discharge_power = np.inf if result[1]: discharge_power = result[0] - result = esdl_asset.get_property(esdl_property_name="maxChargeRate", - default_value=np.inf) + result = esdl_asset.get_property(esdl_property_name="maxChargeRate", default_value=np.inf) charge_power = np.inf if result[1]: charge_power = result[0] diff --git a/src/omotes_simulator_core/entities/assets/demand_cluster.py b/src/omotes_simulator_core/entities/assets/demand_cluster.py index 8b070341..6465bd7d 100644 --- a/src/omotes_simulator_core/entities/assets/demand_cluster.py +++ b/src/omotes_simulator_core/entities/assets/demand_cluster.py @@ -78,8 +78,8 @@ def set_setpoints(self, setpoints: Dict) -> None: f"The setpoints {necessary_setpoints.difference(setpoints_set)} are missing." ) self.thermal_power_allocation = setpoints[PROPERTY_HEAT_DEMAND] - self.temperature_return_target = setpoints[PROPERTY_TEMPERATURE_SUPPLY] - self.temperature_supply = setpoints[PROPERTY_TEMPERATURE_RETURN] + self.temperature_return_target = setpoints[PROPERTY_TEMPERATURE_RETURN] + self.temperature_supply = setpoints[PROPERTY_TEMPERATURE_SUPPLY] adjusted_mass_flowrate = heat_demand_and_temperature_to_mass_flow( self.thermal_power_allocation, self.temperature_supply, self.temperature_return_target ) From 28a0426e564f17b23762c7381cecfdb448931c4e Mon Sep 17 00:00:00 2001 From: Sam van der Zwan Date: Tue, 22 Oct 2024 15:05:09 +0200 Subject: [PATCH 3/3] Added tests for getting supply and return temperature for consumers and producers --- unit_test/entities/test_esdl_object.py | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/unit_test/entities/test_esdl_object.py b/unit_test/entities/test_esdl_object.py index 28e3d605..c63959e2 100644 --- a/unit_test/entities/test_esdl_object.py +++ b/unit_test/entities/test_esdl_object.py @@ -173,6 +173,50 @@ def test_get_return_temperature_out(self): # Assert self.assertEqual(return_temperature, 313.15) + def test_get_supply_temperature_consumer(self): + """Test get_supply_temperature method.""" + # Arrange + asset = self.esdl_object.get_all_assets_of_type("consumer")[0] + + # Act + supply_temperature = asset.get_return_temperature("Out") + + # Assert + self.assertEqual(supply_temperature, 313.15) + + def test_get_return_temperature_consumer(self): + """Test get_supply_temperature method.""" + # Arrange + asset = self.esdl_object.get_all_assets_of_type("consumer")[0] + + # Act + supply_temperature = asset.get_supply_temperature("In") + + # Assert + self.assertEqual(supply_temperature, 353.15) + + def test_get_supply_temperature_producer(self): + """Test get_supply_temperature method.""" + # Arrange + asset = self.esdl_object.get_all_assets_of_type("producer")[0] + + # Act + supply_temperature = asset.get_supply_temperature("Out") + + # Assert + self.assertEqual(supply_temperature, 353.15) + + def test_get_return_temperature_producer(self): + """Test get_supply_temperature method.""" + # Arrange + asset = self.esdl_object.get_all_assets_of_type("producer")[0] + + # Act + supply_temperature = asset.get_return_temperature("In") + + # Assert + self.assertEqual(supply_temperature, 313.15) + def test_get_port_type_in(self): """Test get_port_type method.""" # Arrange