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

#4663 #4664 - Fix CoilCoolingDXMultiSpeed::clone and extend testing for AirLoopHVAC::clone #4683

Merged
merged 4 commits into from Sep 28, 2022

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Sep 15, 2022

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added severity - Normal Bug component - Model Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Sep 15, 2022
@jmarrec jmarrec self-assigned this Sep 15, 2022
Comment on lines +276 to +309
TEST_F(ModelFixture, CoilCoolingDXMultiSpeed_Clone) {
// Ref #4663
Model m;
CoilCoolingDXMultiSpeed cc(m);

std::vector<CoilCoolingDXMultiSpeedStageData> stages{CoilCoolingDXMultiSpeedStageData{m}, CoilCoolingDXMultiSpeedStageData{m}};
EXPECT_TRUE(cc.setStages(stages));

EXPECT_EQ(2u, cc.stages().size());
EXPECT_EQ(1u, m.getConcreteModelObjects<CoilCoolingDXMultiSpeed>().size());
EXPECT_EQ(2u, m.getConcreteModelObjects<CoilCoolingDXMultiSpeedStageData>().size());

{
// Clone in another model first, so we don't affect the original one
Model m2;
auto cc2 = cc.clone(m2).cast<CoilCoolingDXMultiSpeed>();
EXPECT_EQ(2u, cc2.stages().size());
EXPECT_EQ(1u, m2.getConcreteModelObjects<CoilCoolingDXMultiSpeed>().size());
EXPECT_EQ(2u, m2.getConcreteModelObjects<CoilCoolingDXMultiSpeedStageData>().size());
}

{
// Same model: we expect stages to be cloned and reassigned to the clone
auto cc2 = cc.clone(m).cast<CoilCoolingDXMultiSpeed>();
std::vector<CoilCoolingDXMultiSpeedStageData> stages2 = cc2.stages();
EXPECT_EQ(2u, stages2.size());
EXPECT_EQ(2u, m.getConcreteModelObjects<CoilCoolingDXMultiSpeed>().size());
EXPECT_EQ(4u, m.getConcreteModelObjects<CoilCoolingDXMultiSpeedStageData>().size());
for (auto& stage : stages) {
EXPECT_TRUE(std::find_if(stages2.cbegin(), stages2.cend(), [&stage](const auto& s) { return s.handle() == stage.handle(); }) == stages2.cend())
<< "Did not expect to find, in the cloned Coil, the CoilCoolingDXMultiSpeedStageData '" << stage.nameString() << "'";
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test for CoilCoolingDXMultiSpeed::clone. Originally it fails

// Same model: we expect stages to be cloned and reassigned to the clone
auto cc2 = cc.clone(m).cast<CoilCoolingDXMultiSpeed>();
std::vector<CoilCoolingDXMultiSpeedStageData> stages2 = cc2.stages();
EXPECT_EQ(2u, stages2.size());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original: fails because it's 4

Comment on lines +288 to +289
// Deal with the stages: we want them cloned, so first clear and then clone + assign each
t_clone.removeAllStages();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +1483 to +1673
ASSERT_TRUE(heatingCoil.plantLoop());
EXPECT_EQ(hw_loop, heatingCoil.plantLoop().get());
{
Model m2;
// PlantLoops aren't taken with
auto a2 = a.clone(m2).cast<AirLoopHVAC>();

EXPECT_EQ(1, m2.getConcreteModelObjects<AirLoopHVAC>().size());
EXPECT_EQ(0, m2.getConcreteModelObjects<PlantLoop>().size());
EXPECT_EQ(1, m2.getConcreteModelObjects<AirTerminalSingleDuctConstantVolumeNoReheat>().size());
EXPECT_EQ(0, m2.getConcreteModelObjects<ThermalZone>().size());
EXPECT_EQ(1, m2.getConcreteModelObjects<CoilCoolingWater>().size());
EXPECT_EQ(1, m2.getConcreteModelObjects<CoilHeatingWater>().size());

EXPECT_EQ(7, m2.getConcreteModelObjects<Node>().size());

EXPECT_EQ(7, chw_loop.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(7, hw_loop.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(7, a2.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(1, a2.supplyOutletNodes().size());
EXPECT_EQ(5, a2.supplyComponents().size()); // o----CC----o----HC----o
EXPECT_EQ(7, a2.demandComponents().size()); // o----Splitter-----o----ATU----o --- mixer ----o

// Ensure the ATU is connectable (cf #4663)
auto z2 = z.clone(m2).cast<ThermalZone>();
EXPECT_EQ(8, m2.getConcreteModelObjects<Node>().size());
EXPECT_EQ(1, m2.getConcreteModelObjects<ThermalZone>().size());
EXPECT_EQ(0, z2.equipment().size());

EXPECT_TRUE(a2.addBranchForZone(z2));

EXPECT_EQ(9, m2.getConcreteModelObjects<Node>().size());
EXPECT_EQ(8, a2.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(1, a2.supplyOutletNodes().size());
EXPECT_EQ(5, a2.supplyComponents().size()); // o----CC----o----HC----o
EXPECT_EQ(9, a2.demandComponents().size()); // o----Splitter-----o----ATU----o---Zone----o --- mixer ----o
EXPECT_EQ(1, z2.equipment().size());

ASSERT_EQ(1, a2.components(openstudio::IddObjectType::OS_Coil_Cooling_Water).size());
auto coolingCoil2 = a2.components(openstudio::IddObjectType::OS_Coil_Cooling_Water)[0].cast<CoilCoolingWater>();
EXPECT_FALSE(coolingCoil2.plantLoop());

ASSERT_EQ(1, a2.components(openstudio::IddObjectType::OS_Coil_Heating_Water).size());
auto heatingCoil2 = a2.components(openstudio::IddObjectType::OS_Coil_Heating_Water)[0].cast<CoilHeatingWater>();
EXPECT_FALSE(heatingCoil2.plantLoop());
}

{
// Same model
auto a2 = a.clone(m).cast<AirLoopHVAC>();

EXPECT_EQ(2, m.getConcreteModelObjects<AirLoopHVAC>().size());
EXPECT_EQ(2, m.getConcreteModelObjects<PlantLoop>().size());
EXPECT_EQ(2, m.getConcreteModelObjects<AirTerminalSingleDuctConstantVolumeNoReheat>().size());
EXPECT_EQ(1, m.getConcreteModelObjects<ThermalZone>().size());
EXPECT_EQ(2, m.getConcreteModelObjects<CoilCoolingWater>().size());
EXPECT_EQ(2, m.getConcreteModelObjects<CoilHeatingWater>().size());

// 23 + 7 (new loop) + 2 loops x 2 nodes
EXPECT_EQ(34, m.getConcreteModelObjects<Node>().size());
EXPECT_EQ(9, chw_loop.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(9, hw_loop.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(8, a.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(1, a.supplyOutletNodes().size());
EXPECT_EQ(5, a.supplyComponents().size()); // o----CC----o----HC----o
EXPECT_EQ(9, a.demandComponents().size()); // o----Splitter-----o----ATU----o---Zone----o --- mixer ----o
EXPECT_EQ(7, a2.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(1, a2.supplyOutletNodes().size());
EXPECT_EQ(5, a2.supplyComponents().size()); // o----CC----o----HC----o
EXPECT_EQ(7, a2.demandComponents().size()); // o----Splitter-----o----ATU----o --- mixer ----o

// Ensure the ATU is connectable (cf #4663)
auto z2 = z.clone(m).cast<ThermalZone>();
EXPECT_EQ(35, m.getConcreteModelObjects<Node>().size());
EXPECT_EQ(2, m.getConcreteModelObjects<ThermalZone>().size());
EXPECT_EQ(1, z.equipment().size());
EXPECT_EQ(0, z2.equipment().size());

EXPECT_TRUE(a2.addBranchForZone(z2));

EXPECT_EQ(36, m.getConcreteModelObjects<Node>().size());
EXPECT_EQ(8, a2.components(openstudio::IddObjectType::OS_Node).size());
EXPECT_EQ(1, a2.supplyOutletNodes().size());
EXPECT_EQ(5, a2.supplyComponents().size()); // o----CC----o----HC----o
EXPECT_EQ(9, a2.demandComponents().size()); // o----Splitter-----o----ATU----o---Zone----o --- mixer ----o
EXPECT_EQ(1, z.equipment().size());
EXPECT_EQ(1, z2.equipment().size());

// Coils are also reconnected to plant loops
ASSERT_EQ(1, a2.components(openstudio::IddObjectType::OS_Coil_Cooling_Water).size());
auto coolingCoil2 = a2.components(openstudio::IddObjectType::OS_Coil_Cooling_Water)[0].cast<CoilCoolingWater>();
ASSERT_TRUE(coolingCoil2.plantLoop());
EXPECT_EQ(chw_loop, coolingCoil2.plantLoop().get());

ASSERT_EQ(1, a2.components(openstudio::IddObjectType::OS_Coil_Heating_Water).size());
auto heatingCoil2 = a2.components(openstudio::IddObjectType::OS_Coil_Heating_Water)[0].cast<CoilHeatingWater>();
ASSERT_TRUE(heatingCoil2.plantLoop());
EXPECT_EQ(hw_loop, heatingCoil2.plantLoop().get());
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New full test for #4664

@jmarrec
Copy link
Collaborator Author

jmarrec commented Sep 23, 2022

@mleachNREL If you could try out one of the installers listed above in #4683 (comment) that would be awesome.

jmarrec added a commit that referenced this pull request Sep 26, 2022
@jmarrec
Copy link
Collaborator Author

jmarrec commented Sep 28, 2022

I'm going to merge this, but we can reopen the issues if @mleachNREL tests and find another issue.

@jmarrec jmarrec merged commit 0506e87 into develop Sep 28, 2022
@jmarrec jmarrec deleted the 4663_4664_Clones branch September 28, 2022 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Model Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Normal Bug
Projects
None yet
2 participants