NatLabRockies / NatLabRockies/OpenStudio

SizingSystem ctor and clone

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

Nobody has claimed this yet.

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

Description

Issue overview

I wrote some model tests for SizingSystem (there were none), and now seeing some weird things.

Current Behavior

Issue 1

  Model m;
  AirLoopHVAC airLoopHVAC(m);
  SizingSystem sizingSystem = airLoopHVAC.sizingSystem();
  auto sizingSystemClone = sizingSystem.clone(m).cast<SizingSystem>();

  // FIXME: AirLoopHVAC returns the original SizingSystem OR the cloned SizingSystem
  EXPECT_EQ(airLoopHVAC.sizingSystem().handle(), sizingSystem.handle());  // sometimes true, sometimes not
  EXPECT_NE(airLoopHVAC.sizingSystem().handle(), sizingSystemClone.handle());  // sometimes true, sometimes not

Issue 2

  Model m;
  AirLoopHVAC airLoopHVAC(m);
  SizingSystem sizingSystem1 = airLoopHVAC.sizingSystem();
  SizingSystem sizingSystem2(m, airLoopHVAC);

  // FIXME: AirLoopHVAC returns the original SizingSystem OR the new SizingSystem
  EXPECT_EQ(airLoopHVAC.sizingSystem().handle(), sizingSystem1.handle());  // sometimes true, sometimes not
  EXPECT_NE(airLoopHVAC.sizingSystem().handle(), sizingSystem2.handle());  // sometimes true, sometimes not

Expected Behavior

I'm not really sure what should happen. But I do know that results should be deterministic (which they aren't).

Possible Solution

Issue 1: don't allow cloning SizingSystem.
Issue 2: A) don't make the SizingSystem ctor public, or B) ctor call removes existing SizingSystem.

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 by locating the model tests for SizingSystem and read the implementations of AirLoopHVAC.sizingSystem(), SizingSystem::clone(), and the SizingSystem(Model, AirLoopHVAC) constructor. Reproduce both examples and determine the intended ownership and replacement behavior. Done means the relevant tests consistently establish deterministic results and document the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.