Closed jmarrec closed 3 months ago
Oh well well well. The schedule is named exactly (casing aside) like the ZoneVentilationDesignFlowRate object... I found that's the precondition that makes me also reproduce on linux.
test_scratch.rb:
require 'openstudio'
include OpenStudio::Model
m = Model.new
z = ThermalZone.new(m)
uh = ZoneHVACUnitHeater.new(m, m.alwaysOnDiscreteSchedule, FanOnOff.new(m), CoilHeatingElectric.new(m))
nv = ZoneVentilationDesignFlowRate.new(m)
nv.setName("ZVDFR NaturalVentilation")
nv.setVentilationType("Natural")
nv_sch = ScheduleRuleset.new(m)
nv.setSchedule(nv_sch)
nv_sch.setName(nv.nameString) # <-------- comment out this line and it works fine
exhaust = ZoneVentilationDesignFlowRate.new(m)
exhaust.setVentilationType("Exhaust")
exhaust_sch = ScheduleRuleset.new(m)
exhaust.setSchedule(exhaust_sch)
#exhaust_sch.setName(exhaust.nameString)
uh.addToThermalZone(z)
nv.addToThermalZone(z)
exhaust.addToThermalZone(z)
uh.remove
On ubuntu:
$ ruby test_scratch.rb
[BOOST_ASSERT] <2> Assertion eg failed on line 346 of bool openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const openstudio::model::ModelObject&) in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/model/ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 346 of bool openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const openstudio::model::ModelObject&) in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/model/ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 356 of bool openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const openstudio::model::ModelObject&) in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/model/ZoneHVACEquipmentList.cpp.
[BOOST_ASSERT] <2> Assertion eg failed on line 356 of bool openstudio::model::detail::ZoneHVACEquipmentList_Impl::removeEquipment(const openstudio::model::ModelObject&) in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/model/ZoneHVACEquipmentList.cpp.
As long as grabbing by name returns the schedule first, I can reproduce the crash
m = Model.new
z = ThermalZone.new(m)
bb_delete = ZoneHVACBaseboardConvectiveElectric.new(m)
bb = ZoneHVACBaseboardConvectiveElectric.new(m)
bb_sch = ScheduleConstant.new(m)
bb.setName("Baseboard")
bb_sch.setName(bb.nameString)
bb.setAvailabilitySchedule(bb_sch)
bb_delete.addToThermalZone(z)
bb.addToThermalZone(z)
puts "Objects named #{bb.nameString}"
puts m.objects.select{|o| o.nameString == bb.nameString}.map(&:iddObject).map(&:type)
raise unless m.getObjectsByName(bb.nameString).first.iddObject.type == "OS_Schedule_Constant".to_IddObjectType
bb_delete.remove
The explanation of why this happens (along with the fix) is in https://github.com/NREL/OpenStudio/pull/5122#discussion_r1538747049
Issue overview
I am extremely puzzled about what's happening but I can reproduce a crash originally reported at https://github.com/openstudiocoalition/OpenStudioApplication/issues/686 on windows (it works on Ubuntu).
Current Behavior
It seems that when the extensible group corresponding to the UH is deleted, something very strange happens.
In the following group, which points correctly to a ZoneVentilationDesignFlowRate object to begin with, the handle is changed to be the handle of that object's Schedule Name (?!)
Expected Behavior
Steps to Reproduce
I'll provide a shortened file asap: edit: Here is a mcve.osm:
mcve.osm.txt
test2:
On Linux, everything is fine. Comparing the mcve.osm and the mcve_after_erase.osm, I get what's expected:
Adding the WIndows one to the right, we see something weird happened, the handle for former second group and now first group is actually pointing to a Schedule
Possible Solution
Details
Environment
Some additional details about your environment for this issue (if relevant):
Context
https://github.com/openstudiocoalition/OpenStudioApplication/issues/686