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

AirLoopHVAC::clone will duplicate components that are on the relief and intake air streams of an OutdoorAirSystem #4869

Closed
jmarrec opened this issue Apr 27, 2023 · 2 comments · Fixed by #4872

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Apr 27, 2023

Issue overview

Current Behavior

Cloning an airloop with air-to-air heat exchanger doubles the number of heat exchangers:
2023-04-13

Expected Behavior

Shouldn't be cloned twice.

Steps to Reproduce

m = Model.new
a = AirLoopHVAC.new(m)
controller = OpenStudio::Model::ControllerOutdoorAir.new(m)
oas = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(m, controller)
oas.addToNode(a.supplyOutletNode)
erv = HeatExchangerAirToAirSensibleAndLatent.new(m)
erv.addToNode(oas.outboardOANode.get)

a.supplyComponents.map(&:nameString)
=> ["Node 1", "Air Loop HVAC Outdoor Air System 1", "Node 2"
oas.components.map(&:nameString)
=> ["Node 6", "Heat Exchanger Air To Air Sensible And Latent 1", "Node 9", "Node 10", "Heat Exchanger Air To Air Sensible And Latent 1", "Node 7"]

a2 = a.clone(m).to_AirLoopHVAC.get

a2.supplyComponents.map(&:nameString)
=> ["Node 8", "Air Loop HVAC Outdoor Air System 2", "Node 11"]

oas2 = a2.airLoopHVACOutdoorAirSystem.get
oas2.components.map(&:nameString)
=> ["Node 15",
 "Heat Exchanger Air To Air Sensible And Latent 3",
 "Node 20",
 "Heat Exchanger Air To Air Sensible And Latent 2",
 "Node 18",
 "Node 19",
 "Heat Exchanger Air To Air Sensible And Latent 2",
 "Node 21",
 "Heat Exchanger Air To Air Sensible And Latent 3",
 "Node 16"]

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): All
  • Version of OpenStudio (if using an intermediate build, include SHA): 3.6.0-rc2

Context

Initially reported at openstudiocoalition/OpenStudioApplication#600

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 27, 2023

The issue is with the AirLoopHVACOutdoorAirSystem::clone, and I'm not surprised we didn't catch it given the "clone" test here which does essentially nothing:

TEST_F(ModelFixture, AirLoopHVACOutdoorAirSystem_clone) {
Model model = Model();
Model model2 = Model();
OptionalModelObject modelObject;
ControllerOutdoorAir controller(model);
AirLoopHVACOutdoorAirSystem oaSystem = AirLoopHVACOutdoorAirSystem(model, controller);
ASSERT_EQ(openstudio::IddObjectType::OS_Controller_OutdoorAir, oaSystem.getControllerOutdoorAir().iddObjectType().value());
auto oaSystem2 = oaSystem.clone(model2).cast<AirLoopHVACOutdoorAirSystem>();
ASSERT_EQ(openstudio::IddObjectType::OS_Controller_OutdoorAir, oaSystem2.getControllerOutdoorAir().iddObjectType().value());
}

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 27, 2023

That is one OLD file... time to modernize and avoid optional casting an object that's already the right type... And this shoudl be AirLoopHVAC as an override from HVACComponent

OptionalAirLoopHVAC AirLoopHVACOutdoorAirSystem_Impl::airLoop() const {
OptionalAirLoopHVAC result;
AirLoopHVACVector airLoops = this->model().getConcreteModelObjects<AirLoopHVAC>();
AirLoopHVACVector::iterator it;
for (it = airLoops.begin(); it != airLoops.end(); ++it) {
OptionalAirLoopHVAC airLoop = it->optionalCast<AirLoopHVAC>();
if (airLoop) {
if (airLoop->component(this->handle())) {
return airLoop;
}
}
}
return result;
}

jmarrec added a commit that referenced this issue May 2, 2023
jmarrec added a commit that referenced this issue May 2, 2023
jmarrec added a commit that referenced this issue May 10, 2023
jmarrec added a commit that referenced this issue May 10, 2023
jmarrec added a commit that referenced this issue Jun 29, 2023
Fix #4869 - Handle AirToAirComponents (ERVs) when cloning AirLoopHVACOutdoorAirSystem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant