NatLabRockies / NatLabRockies/OpenStudio

ModelObjectLists used to store Speed Data for coils aren't removed when a parent of the coil is removed

Open
#4,241 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component - Model severity - Minor Bug
Dominant language
C++
Stars
646
Forks
237
Avg merge
3d 11h
Merged PRs (30d)
10

Description

Enhancement Request

Found on #4236, e2e41ca16761251c3fb06cd1076c35551855c063

Detailed Description

Here is a MCVE

  1. coil.remove => obviously it works, https://github.com/NREL/OpenStudio/blob/83b05b54a0a8d96fa90a9d8e3692f44ce16b104d/src/model/CoilCoolingDXVariableSpeed.cpp#L615-L620
[1] OS-build(main)> model = Model.new; cooling_coil = OpenStudio::Model::CoilCoolingDXVariableSpeed.new(model); cooling_coil.remove
=> [#<OpenStudio::IdfObject:0x0000562dc0a954e0 @__swigtype__="_p_openstudio__IdfObject">, #<OpenStudio::IdfObject:0x0000562dc0a95490 @__swigtype__="_p_openstudio__IdfObject">]
[2] OS-build(main)> puts model

OS:Version,
  {c735f745-8a07-44a9-a22b-a55ef3c26528}, !- Handle
  3.1.1,                                  !- Version Identifier
  alpha;                                  !- Prerelease Identifier
  1. Now, put the coil inside a parent, and delete the parent. ParentObject_Impl::remove is called, and the specific Coil::remove method is never called, and the Speed Data ModelObjectList is orphaned.
[3] OS-build(main)> cooling_coil = OpenStudio::Model::CoilCoolingDXVariableSpeed.new(model)
[4] OS-build(main)> a = AirLoopHVACUnitarySystem.new(model)
[5] OS-build(main)> a.setCoolingCoil(cooling_coil)
=> true
[6] OS-build(main)> a.remove
=> [#<OpenStudio::IdfObject:0x0000562dc4c047f0 @__swigtype__="_p_openstudio__IdfObject">,
 #<OpenStudio::IdfObject:0x0000562dc4c047a0 @__swigtype__="_p_openstudio__IdfObject">,
 #<OpenStudio::IdfObject:0x0000562dc4c04750 @__swigtype__="_p_openstudio__IdfObject">]
[7] OS-build(main)> puts model

OS:Version,
  {c735f745-8a07-44a9-a22b-a55ef3c26528}, !- Handle
  3.1.1,                                  !- Version Identifier
  alpha;                                  !- Prerelease Identifier

OS:ModelObjectList,
  {ce9592a4-f728-461b-9063-b8f037397972}, !- Handle
  Coil Cooling DX Variable Speed 1 Speed Data List; !- Name

https://github.com/NREL/OpenStudio/blob/83b05b54a0a8d96fa90a9d8e3692f44ce16b104d/src/model/ParentObject.cpp#L67-L95

Possible Implementation

The issue is the fact that to be deleted via ParentObject_Impl::remove, the coil would have to list its Speed Data ModelObjectList as a children. That's not a good idea though, because of how ModelObjectList behaves when it's cloned/deleted (it clones every object referenced / deletes every object)

I do not see any possible implementation at the moment. I'm just filing so we have a trace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MCVE and inspect src/model/ParentObject.cpp around ParentObject_Impl::remove, then compare it with CoilCoolingDXVariableSpeed.cpp around the coil’s remove implementation. Reproduce removal of a parent containing a variable-speed coil and verify that no orphaned OS:ModelObjectList remains, while avoiding the cloning and deletion behavior described for ModelObjectList.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, ruby
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.