Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing Issue in OpenStudio When Accessing Thermal Zone Tab #686

Closed
eliaseid1 opened this issue Mar 5, 2024 · 20 comments
Closed

Crashing Issue in OpenStudio When Accessing Thermal Zone Tab #686

eliaseid1 opened this issue Mar 5, 2024 · 20 comments
Labels
Triage Issue needs to be assessed and labeled, further information on reported might be needed

Comments

@eliaseid1
Copy link

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.

@eliaseid1 eliaseid1 added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label Mar 5, 2024
@macumber
Copy link
Collaborator

macumber commented Mar 7, 2024

@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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

eliaseid1 commented Mar 18, 2024

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

@eliaseid1 eliaseid1 reopened this Mar 18, 2024
@macumber
Copy link
Collaborator

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

@eliaseid1
Copy link
Author

@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
Copy link
Collaborator

jmarrec commented Mar 19, 2024

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Collaborator

macumber commented Mar 19, 2024

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
Copy link
Author

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
Copy link
Author

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
Copy link
Collaborator

jmarrec commented Mar 22, 2024

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

  • I can remove the unit heater without a crash with 1.7.0
  • I can remove the unit heater in the OS SDK bindings

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
Copy link
Collaborator

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
Copy link
Collaborator

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

@jmarrec
Copy link
Collaborator

jmarrec commented Mar 25, 2024

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
Copy link
Collaborator

jmarrec commented Mar 25, 2024

Ok what the hell, I can reproduce on windoze

@jmarrec
Copy link
Collaborator

jmarrec commented Mar 25, 2024

Moved to NREL/OpenStudio#5121 . Will reopen if I find this is an OSApp issue after all but I doubt it

@jmarrec jmarrec closed this as completed Mar 25, 2024
@jmarrec
Copy link
Collaborator

jmarrec commented Mar 25, 2024

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
Copy link
Collaborator

jmarrec commented Mar 26, 2024

Fix is in NREL/OpenStudio#5122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage Issue needs to be assessed and labeled, further information on reported might be needed
Projects
None yet
Development

No branches or pull requests

3 participants