openstudiocoalition / OpenStudioApplication

The OpenStudio Application is a fully featured graphical interface to OpenStudio models including envelope, loads, schedules, and HVAC.
https://openstudiocoalition.org
Other
137 stars 25 forks source link

Crashing Issue in OpenStudio When Accessing Thermal Zone Tab #686

Closed eliaseid1 closed 8 months ago

eliaseid1 commented 8 months ago

Hi there,

I'm experiencing consistent crashes in OpenStudio whenever I try to access the thermal zones tab. This issue arose after I included natural ventilation and an exhaust fan in a kitchen I'm modelling (as zone equipment). Could you please provide assistance? I've ensured that I have the latest updates for both OpenStudio and EnergyPlus. I can provide the OSM if someone can help please.

Thanks in advance.

macumber commented 8 months ago

@eliaseid1 sent the OSM in question and the issue was a OS:ZoneHVAC:EquipmentList with objects of priority 1, 3, 4 (missing priority 2). @eliaseid1 if you can provide steps to reproduce the issue when building a model, we can try to fix it

eliaseid1 commented 8 months ago

Dear Dan,

I appreciate your response and apologize for the delay in getting back to you. During this time, I have been attempting to recreate the bug. After conducting various tests, I have successfully identified the issue: -Initially, I added a CV Unit Heater gas (OS:ZoneHVAC:UnitHeater). -Following that, I integrated a natural ventilation system (OS:ZoneVentilation:DesignFlowRate). -Subsequently, I included an exhaust fan (another OS:ZoneVentilation:DesignFlowRate). -Lastly, I removed the CV Unit Heater gas in order to experiment with adding a different type of heater. It was during this step that the bug occurred. Specifically, upon navigating to another tab and returning to the thermal zone tab, OpenStudio crashed.

I suspect that the problem may be related to the OS:ZoneVentilation component as well, particularly because the crash did not occur when only the CV Unit Heater gas was present. I really hope you can solve the issue. Thank you for your continued assistance.

Best regards, Elias

macumber commented 8 months ago

Thanks @eliaseid1, in your model the third zone equipment named "Exhaust Fan" is actually a schedule. I'm not sure how you added that to the zone equipment list? I can't drag a schedule to that location. Can you share how you did that?

image

eliaseid1 commented 8 months ago

Hello Dan, I am not sure how you are able to observe the exhaust fan in the zone equipment, which is strange. When I access my OS model, the exhaust ventilation appears within the zone equipment, not the exhaust fan as part of a schedule. I've attached a picture of the model for reference. Pic

macumber commented 8 months ago

@jmarrec I can't reproduce this, can you?

eliaseid1 commented 8 months ago

@macumber I've just noticed that the screenshot you shared depicts the old OSM model. In my last email of Thursday, I provided you with two OSMs: one before encountering the bug and another immediately after. Could you please confirm whether you received the email and attempted to address the issue using these two models? Thank you!

jmarrec commented 8 months ago

Where do I find the "faulty" (before) model? I don't see it on the OSC email.

Also, what do you mean by "before the bug" and "another immediately after". Did you change anything in between or just reopened it?

Did you ever edit the model by hand / outside of the OpenStudioApplication?

eliaseid1 commented 8 months ago

Hello Julien,

I appreciate your response. Dan requested that I replicate the bug for you to address, which is why I generated two versions of the file: one before the bug and one after. The sole difference between the two is removing the CV unit heater from the zone equipment in the model after, which triggers the bug. Furthermore, I made no edits to the model outside of the OS Application.

I believe Dan has the two models, if you don't have them, I'm more than happy to provide them.

Thank you for your help.

macumber commented 8 months ago

I put the files in the issues repo for this issue @jmarrec. I just now saw the second set of files you sent, the before and after osms are the exact same. However, I can reproduce the bug by opening Kitchen Domestic (before removing the CV unit heater).osm and deleting the unit heater. @jmarrec I can look into this tonight if you don't have time.

@eliaseid1 are you able to reproduce this issue if you start a model in OpenStudio Application 1.7.0? Or does it only occur if you build the model in OpenStudio Application 1.5.0 and then upgrade it to OpenStudio Application 1.7.0?

macumber commented 8 months ago

I think this is an OpenStudio issue, there is an assertion failing in ZoneHVACEquipmentList_Impl::removeEquipment when the unit heater is removed.

      for (const auto& elem : coolingVector) {
        boost::optional<ModelExtensibleGroup> eg = getGroupForModelObject(elem);
        OS_ASSERT(eg); // <-- THIS IS FAILING
        eg->setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence, priority);

        priority++;
      }
eliaseid1 commented 8 months ago

Hi @macumber , I indeed attempted it in Openstudio 1.7.0, and unfortunately, I encountered the same bug. Additionally, it's important to mention that this issue did not occur when the Natural and exhaust ventilation were not added. This implies that I could freely use and remove the CV unit heater without encountering any issues. So, the crashing in Openstudio somehow is related to this OS:ZoneVentilation:DesignFlowRate.

eliaseid1 commented 8 months ago

Another observation I made while reviewing the model: Yesterday, I encountered what seems to be another bug. When attempting to use an electric baseboard convective heater as a zone equipment, I opted for autosize for the heater capacity. However, despite this setting, I consistently received a 0 W output and no heating in the kitchen. Interestingly, manually specifying a value for the heater capacity resolved the issue. It appears that Openstudio considered the autosizing of this component as 0 W. I hope this information proves helpful.

jmarrec commented 8 months ago

However, I can reproduce the bug by opening Kitchen Domestic (before removing the CV unit heater).osm and deleting the unit heater. @jmarrec I can look into this tonight if you don't have time.

So funny thing @macumber

One liner test:

openstudio -e "m = OpenStudio::Model::Model::load('Kitchen Domestic (before removing the CV unit heater).osm').get; uh = m.getZoneHVACUnitHeaters.first; uh.remove; puts 'ok'"
macumber commented 8 months ago

Hey @jmarrec must be some differences in logging, when I run your command I see the failed BOOST_ASSERT statements below:

$ /c/openstudio-3.7.0/bin/openstudio -e "m = OpenStudio::Model::Model::load('Kitchen Domestic (before removing the CV unit heater).osm').get; uh = m.getZoneHVACUnitHeaters.first; uh.remove; puts 'ok'"
[BOOST_ASSERT] <2> Assertion eg failed on line 346 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 346 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 356 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 356 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
ok

If I add forward translation I get a crash:

$ /c/openstudio-3.7.0/bin/openstudio -e "m = OpenStudio::Model::Model::load('Kitchen Domestic (before removing the CV unit heater).osm').get; uh = m.getZoneHVACUnitHeaters.first; uh.remove; ft = OpenStudio::EnergyPlus::ForwardTranslator.new; ft.translateModel(m); puts 'ok'"
[BOOST_ASSERT] <2> Assertion eg failed on line 346 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 346 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 356 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 356 of bool __cdecl openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const class openstudio::model::ModelObject &) in file D:\OSN\src\model\ZoneHVACEquipmentList.cpp.
eval:1: [BUG] Segmentation fault
ruby 2.7.2p137 (2020-10-01) [x64-mswin64_140]
macumber commented 8 months ago

This seems like an OpenStudio issue rather than an OpenStudio Application issue to me.

jmarrec commented 8 months ago

Even with a debugger attached I can't reproduce it. Also, I see no reason it would do that. Here's the equivalent ruby code (also on the OpenStudioApplication-Issues repo):

require 'openstudio'

include OpenStudio::Model

# Helper to load a model in one line
# It will raise if the path (or the model) isn't valid
#
# @param path [String] The path to the osm
# @return [OpenStudio::Model::Model] the resulting model.
def osload(path)
  translator = OpenStudio::OSVersion::VersionTranslator.new
  ospath = OpenStudio::Path.new(path)
  model = translator.loadModel(ospath)
  if model.empty?
      raise "Path '#{path}' is not a valid path to an OpenStudio Model"
  else
      model = model.get
  end
  return model
end

def getGroupForModelObject(eqlist, modelObject)
  eqlist.extensibleGroups.each do |eg|
    meg = eg.to_ModelExtensibleGroup.get
    if meg.getTarget(0).get.handle == modelObject.handle
      return meg
    end
  end
end

m = osload('Kitchen Domestic (before removing the CV unit heater).osm')
eqlist = m.getZoneHVACEquipmentLists.first
uh = m.getZoneHVACUnitHeaters.first

puts "Eq List before"
pp eqlist.extensibleGroups.map{|eg| [eg.to_ModelExtensibleGroup.get.getTarget(0).get.nameString, eg.getUnsigned(1).get, eg.getUnsigned(2).get]}

coolingVector = eqlist.equipmentInCoolingOrder
heatingVector = eqlist.equipmentInHeatingOrder

eqlist.eraseExtensibleGroup(getGroupForModelObject(eqlist, uh).groupIndex)

heatingVector = heatingVector.reject{|x| x==uh}
coolingVector = coolingVector.reject{|x| x==uh}

priority = 1
coolingVector.each do |elem|
  eg = getGroupForModelObject(eqlist, elem)
  raise if eg.nil?
  eg.setUnsigned(1, priority)
  priority += 1
end

priority = 1
heatingVector.each do |elem|
  eg = getGroupForModelObject(eqlist, elem)
  raise if eg.nil?
  eg.setUnsigned(2, priority)
  priority += 1
end

puts "Eq List after"
pp eqlist.extensibleGroups.map{|eg| [eg.to_ModelExtensibleGroup.get.getTarget(0).get.nameString, eg.getUnsigned(1).get, eg.getUnsigned(2).get]}
jmarrec commented 8 months ago

Ok what the hell, I can reproduce on windoze

jmarrec commented 8 months ago

Moved to https://github.com/NREL/OpenStudio/issues/5121 . Will reopen if I find this is an OSApp issue after all but I doubt it

jmarrec commented 8 months ago

Just an FYI, the issue arises only because the ZoneVentilation:DesignFlowRate object named "Natural Ventilation" has a Schedule assigned that is also named exactly the same. If you were to rename the Schedule to "Natural Ventilation Schedule", the problem goes away.

jmarrec commented 8 months ago

Fix is in https://github.com/NREL/OpenStudio/pull/5122