IDAES/idaes-pse

HeatExchanger model build fails

Closed this issue · 1 comments

We are not able to use the following code to create a model:


import pyomo.environ as pe # Pyomo environment
from idaes.core import FlowsheetBlock, StateBlock
from idaes.models.unit_models import HeatExchanger
from idaes.models.unit_models.heat_exchanger import delta_temperature_amtd_callback
from idaes.models.properties import iapws95

# Create an empty flowsheet and steam property parameter block.
model = pe.ConcreteModel()
property_pack = iapws95.Iapws95ParameterBlock()
model.fs = FlowsheetBlock(dynamic=False, default_property_package=property_pack)
model.fs.properties = property_pack

# Add a Heater model to the flowsheet.
model.fs.heat_exchanger = HeatExchanger(
    delta_temperature_callback=delta_temperature_amtd_callback,
    hot_side_name="shell",
    cold_side_name="tube"
)


This is the traceback:


Traceback (most recent call last):
  File "/home/shabroz/.config/JetBrains/PyCharmCE2023.2/scratches/pyomo_test.py", line 14, in <module>
    model.fs.heat_exchanger = HeatExchanger(
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/pyomo/core/base/block.py", line 580, in __setattr__
    self.add_component(name, val)
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/pyomo/core/base/block.py", line 1185, in add_component
    val.construct(data)
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/pyomo/core/base/block.py", line 2191, in construct
    self._getitem_when_not_present(_idx)
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/pyomo/core/base/block.py", line 2111, in _getitem_when_not_present
    obj = self._rule(_block, idx)
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/pyomo/core/base/initializer.py", line 313, in __call__
    return self._fcn(parent, idx)
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/idaes/core/base/process_block.py", line 39, in _rule_default
    b.build()
  File "/home/shabroz/.virtualenvs/empc/lib/python3.9/site-packages/idaes/models/unit_models/heat_exchanger.py", line 439, in build
    s1_metadata = config.hot_side.property_package.get_metadata()
AttributeError: 'object' object has no attribute 'get_metadata'

Heat exchanger does not build if the hot side is not provided a property pack but there is a default property pack defined for the flowsheet

@vova292 Thank you for reporting this - I have been able to replicate the issue and have worked out how to fix it. I'll work on a pull request to fix it, and it might make it into the v2.2.0 release which will hopefully be done by the end of the week.