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 5a4a2565..6465bd7d 100644 --- a/src/omotes_simulator_core/entities/assets/demand_cluster.py +++ b/src/omotes_simulator_core/entities/assets/demand_cluster.py @@ -78,12 +78,12 @@ 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 ) - 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: 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