Skip to content

Commit

Permalink
Merge pull request #190 from Project-OMOTES/189-bug-return-temepratur…
Browse files Browse the repository at this point in the history
…e-of-demand-cluster-is-not-set-correctly

Fixed supply temperature not set correctly.
  • Loading branch information
vanmeerkerk authored Oct 24, 2024
2 parents 20eabc7 + 28a0426 commit 45fc15d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions src/omotes_simulator_core/entities/assets/demand_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 44 additions & 0 deletions unit_test/entities/test_esdl_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45fc15d

Please sign in to comment.