From bc6477d4e779097c3bcaf242adec8414f761e1a8 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Wed, 18 Dec 2024 14:51:07 -0700 Subject: [PATCH 01/24] Add ZoneHVAC:EvaporativeCoolerUnit to idd. --- resources/model/OpenStudio.idd | 89 +++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/resources/model/OpenStudio.idd b/resources/model/OpenStudio.idd index 3c3f6568f7..0faad653da 100644 --- a/resources/model/OpenStudio.idd +++ b/resources/model/OpenStudio.idd @@ -24507,6 +24507,7 @@ OS:EvaporativeCooler:Indirect:ResearchSpecial, \type alpha \required-field \reference ConnectionObject + \reference EvapCoolerNames A3 , \field Availability Schedule Name \note Availability schedule name for this system. Schedule value > 0 means the system is available. \note If this field is blank, the system is always available. @@ -24657,6 +24658,7 @@ OS:EvaporativeCooler:Direct:ResearchSpecial, \type alpha \required-field \reference ConnectionObject + \reference EvapCoolerNames A3, \field Availability Schedule Name \type object-list \required-field @@ -31192,13 +31194,98 @@ OS:ZoneHVAC:CoolingPanel:RadiantConvective:Water, \minimum 0 \maximum 1 +OS:ZoneHVAC:EvaporativeCoolerUnit, + \memo Zone evaporative cooler. Forced-convection cooling-only unit with supply fan, + \memo 100% outdoor air supply. Optional relief exhaust node + \min-fields 16 + A1, \field Handle + \type handle + \required-field + A2, \field Name + \required-field + \type alpha + \reference ConnectionObject + A3, \field Availability Schedule Name + \note Availability schedule name for this system. Schedule value > 0 means the system is available. + \note If this field is blank, the system is always available. + \type object-list + \object-list ScheduleNames + A4, \field Availability Manager List Name + \note Enter the name of an AvailabilityManagerAssignmentList object. + \type object-list + \object-list SystemAvailabilityManagerLists + A5, \field Outdoor Air Inlet Node Name + \required-field + \type object-list + \object-list ConnectionNames + \note this is an outdoor air node + A6, \field Cooler Outlet Node Name + \required-field + \type object-list + \object-list ConnectionNames + \note this is a zone inlet node + A7, \field Zone Relief Air Node Name + \type object-list + \object-list ConnectionNames + \note this is a zone exhaust node, optional if flow is being balanced elsewhere + A8, \field Supply Air Fan Name + \required-field + \type object-list + \object-list Fans + N1, \field Design Supply Air Flow Rate + \required-field + \units m3/s + \minimum> 0 + \autosizable + A9, \field Fan Placement + \required-field + \type choice + \key BlowThrough + \key DrawThrough + A10, \field Cooler Unit Control Method + \required-field + \type choice + \key ZoneTemperatureDeadbandOnOffCycling + \key ZoneCoolingLoadOnOffCycling + \key ZoneCoolingLoadVariableSpeedFan + N2, \field Throttling Range Temperature Difference + \note used for ZoneTemperatureDeadbandOnOffCycling hysteresis range for thermostatic control + \type real + \units deltaC + \required-field + \minimum> 0.0 + N3, \field Cooling Load Control Threshold Heat Transfer Rate + \type real + \units W + \required-field + \note Sign convention is that positive values indicate a cooling load + \minimum> 0.0 + A11, \field First Evaporative Cooler Object Name + \required-field + \type object-list + \object-list EvapCoolerNames + A12, \field Second Evaporative Cooler Name + \note optional, used for direct/indirect configurations + \type object-list + \object-list EvapCoolerNames + A13, \field Design Specification ZoneHVAC Sizing Object Name + \note Enter the name of a DesignSpecificationZoneHVACSizing object. + \type object-list + \object-list DesignSpecificationZoneHVACSizingName + N4; \field Shut Off Relative Humidity + \note Zone relative humidity above which the evap cooler is shut off. + \type real + \minimum 0.00 + \maximum 100.00 + \units percent + OS:ZoneMixing, \memo ZoneMixing is a simple air exchange from one zone or space to another. Note that this statement \memo only affects the energy balance of the "receiving" zone or space and will not produce \memo any effect on the "source" zone. Mixing statements can be complementary and include \memo multiple zones, but the balancing of flows between zones is left to the user's \memo discretion. - \min-fields 18 + \min-fields 18 A1, \field Handle \type handle \required-field From 26b5f56b6af677e58eeefdaa29afea7250e790f1 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Thu, 19 Dec 2024 10:38:42 -0700 Subject: [PATCH 02/24] Update the new idd entry. --- resources/model/OpenStudio.idd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/model/OpenStudio.idd b/resources/model/OpenStudio.idd index 0faad653da..07aa068b79 100644 --- a/resources/model/OpenStudio.idd +++ b/resources/model/OpenStudio.idd @@ -31208,6 +31208,7 @@ OS:ZoneHVAC:EvaporativeCoolerUnit, A3, \field Availability Schedule Name \note Availability schedule name for this system. Schedule value > 0 means the system is available. \note If this field is blank, the system is always available. + \required-field \type object-list \object-list ScheduleNames A4, \field Availability Manager List Name @@ -31260,7 +31261,7 @@ OS:ZoneHVAC:EvaporativeCoolerUnit, \required-field \note Sign convention is that positive values indicate a cooling load \minimum> 0.0 - A11, \field First Evaporative Cooler Object Name + A11, \field First Evaporative Cooler \required-field \type object-list \object-list EvapCoolerNames @@ -31268,12 +31269,13 @@ OS:ZoneHVAC:EvaporativeCoolerUnit, \note optional, used for direct/indirect configurations \type object-list \object-list EvapCoolerNames - A13, \field Design Specification ZoneHVAC Sizing Object Name + A13, \field Design Specification ZoneHVAC Sizing \note Enter the name of a DesignSpecificationZoneHVACSizing object. \type object-list \object-list DesignSpecificationZoneHVACSizingName N4; \field Shut Off Relative Humidity \note Zone relative humidity above which the evap cooler is shut off. + \required-field \type real \minimum 0.00 \maximum 100.00 From 5045e196cbe97b9ca60492bb66da7252a4d439ef Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Fri, 20 Dec 2024 10:48:29 -0700 Subject: [PATCH 03/24] First add of model, ft, and test files. --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 179 ++++++ .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 122 ++++ src/model/ScheduleTypeRegistry.cpp | 1 + src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 585 ++++++++++++++++++ src/model/ZoneHVACEvaporativeCoolerUnit.hpp | 209 +++++++ .../ZoneHVACEvaporativeCoolerUnit_Impl.hpp | 215 +++++++ .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 176 ++++++ 7 files changed, 1487 insertions(+) create mode 100644 src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp create mode 100644 src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp create mode 100644 src/model/ZoneHVACEvaporativeCoolerUnit.cpp create mode 100644 src/model/ZoneHVACEvaporativeCoolerUnit.hpp create mode 100644 src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp create mode 100644 src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp new file mode 100644 index 0000000000..2050f7ff8e --- /dev/null +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -0,0 +1,179 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#include "../ForwardTranslator.hpp" +#include "../../model/Model.hpp" + +#include "../../model/ZoneHVACEvaporativeCoolerUnit.hpp" + +// TODO: Check the following class names against object getters and setters. +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" + +#include "../../model/SystemAvailabilityManagerLists.hpp" +#include "../../model/SystemAvailabilityManagerLists_Impl.hpp" + +#include "../../model/Node.hpp" +#include "../../model/Node_Impl.hpp" + +#include "../../model/Fans.hpp" +#include "../../model/Fans_Impl.hpp" + +#include "../../model/EvapCooler.hpp" +#include "../../model/EvapCooler_Impl.hpp" + +#include "../../model/DesignSpecificationZoneHVACSizingName.hpp" +#include "../../model/DesignSpecificationZoneHVACSizingName_Impl.hpp" + +#include +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + + boost::optional ForwardTranslator::translateZoneHVACEvaporativeCoolerUnit( model::ZoneHVACEvaporativeCoolerUnit& modelObject ) { + + // Instantiate an IdfObject of the class to store the values + IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EvaporativeCoolerUnit, modelObject); + + // Availability Schedule Name: Optional Object + if (boost::optional availabilitySchedule_ = modelObject.availabilitySchedule()) { + if (boost::optional wo_ = translateAndMapModelObject(availabilitySchedule_.get())) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString()); + } + } + + // Availability Manager List Name: Optional Object + if (boost::optional availabilityManagerList_ = modelObject.availabilityManagerList()) { + if (boost::optional wo_ = translateAndMapModelObject(availabilityManagerList_.get())) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, wo_->nameString()); + } + } + + // Outdoor Air Inlet Node Name: Required Node + Node outdoorAirInletNodeName = modelObject.inletNode(); + if (boost::optional wo_ = translateAndMapModelObject(outdoorAirInletNodeName)) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, wo_->nameString()); + } + + // Cooler Outlet Node Name: Required Node + Node coolerOutletNodeName = modelObject.outletNode(); + if (boost::optional wo_ = translateAndMapModelObject(coolerOutletNodeName)) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, wo_->nameString()); + } + + // Zone Relief Air Node Name: Optional Node + Node zoneReliefAirNodeName = modelObject.zoneReliefAirNodeName(); + if (boost::optional wo_ = translateAndMapModelObject(zoneReliefAirNodeName)) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, wo_->nameString()); + } + + // Supply Air Fan Object Type: Required String + const std::string supplyAirFanObjectType = modelObject.supplyAirFanObjectType(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, supplyAirFanObjectType); + + + // Supply Air Fan Name: Required Object + Fans supplyAirFan = modelObject.supplyAirFan(); + if (boost::optional wo_ = translateAndMapModelObject(supplyAirFan)) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, wo_->nameString()); + } + + if (modelObject.isDesignSupplyAirFlowRateAutosized()) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, "Autosize"); + } else { + // Design Supply Air Flow Rate: boost::optional + if (boost::optional designSupplyAirFlowRate_ = modelObject.designSupplyAirFlowRate()) { + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, designSupplyAirFlowRate_.get()); + } + } + + // Fan Placement: Required String + const std::string fanPlacement = modelObject.fanPlacement(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement, fanPlacement); + + + // Cooler Unit Control Method: Required String + const std::string coolerUnitControlMethod = modelObject.coolerUnitControlMethod(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod, coolerUnitControlMethod); + + + // Throttling Range Temperature Difference: Optional Double + const double throttlingRangeTemperatureDifference = modelObject.throttlingRangeTemperatureDifference(); + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference, throttlingRangeTemperatureDifference); + + + // Cooling Load Control Threshold Heat Transfer Rate: Optional Double + const double coolingLoadControlThresholdHeatTransferRate = modelObject.coolingLoadControlThresholdHeatTransferRate(); + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, coolingLoadControlThresholdHeatTransferRate); + + + // First Evaporative Cooler Object Type: Required String + const std::string firstEvaporativeCoolerObjectType = modelObject.firstEvaporativeCoolerObjectType(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType, firstEvaporativeCoolerObjectType); + + + // First Evaporative Cooler Object Name: Required Object + EvapCooler firstEvaporativeCoolerObject = modelObject.firstEvaporativeCoolerObject(); + if (boost::optional wo_ = translateAndMapModelObject(firstEvaporativeCoolerObject)) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName, wo_->nameString()); + } + + // Second Evaporative Cooler Object Type: boost::optional + if (boost::optional secondEvaporativeCoolerObjectType_ = modelObject.secondEvaporativeCoolerObjectType()) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType, secondEvaporativeCoolerObjectType_.get()); + } + + // Second Evaporative Cooler Name: Optional Object + if (boost::optional secondEvaporativeCooler_ = modelObject.secondEvaporativeCooler()) { + if (boost::optional wo_ = translateAndMapModelObject(secondEvaporativeCooler_.get())) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, wo_->nameString()); + } + } + + // Design Specification ZoneHVAC Sizing Object Name: Optional Object + if (boost::optional designSpecificationZoneHVACSizingObject_ = modelObject.designSpecificationZoneHVACSizingObject()) { + if (boost::optional wo_ = translateAndMapModelObject(designSpecificationZoneHVACSizingObject_.get())) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName, wo_->nameString()); + } + } + + // Shut Off Relative Humidity: boost::optional + if (boost::optional shutOffRelativeHumidity_ = modelObject.shutOffRelativeHumidity()) { + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity, shutOffRelativeHumidity_.get()); + } + + return idfObject; + } // End of translate function + +} // end namespace energyplus +} // end namespace openstudio diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp new file mode 100644 index 0000000000..8b6e2581f8 --- /dev/null +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -0,0 +1,122 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ForwardTranslator.hpp" +#include "../ReverseTranslator.hpp" + +#include "../../model/ZoneHVACEvaporativeCoolerUnit.hpp" +#include "../../model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp" +// TODO: Check the following class names against object getters and setters. +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/SystemAvailabilityManagerLists.hpp" +#include "../../model/SystemAvailabilityManagerLists_Impl.hpp" +#include "../../model/Fans.hpp" +#include "../../model/Fans_Impl.hpp" +#include "../../model/EvapCooler.hpp" +#include "../../model/EvapCooler_Impl.hpp" +#include "../../model/EvapCooler.hpp" +#include "../../model/EvapCooler_Impl.hpp" +#include "../../model/DesignSpecificationZoneHVACSizingName.hpp" +#include "../../model/DesignSpecificationZoneHVACSizingName_Impl.hpp" + +#include "../../utilities/idf/Workspace.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/WorkspaceObject.hpp" +// E+ FieldEnums +#include +#include +#include +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { + + ForwardTranslator ft; + + Model m; + // TODO: Check regular Ctor arguments + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); + // TODO: Or if a UniqueModelObject (and make sure _Impl is included) + // ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit = m.getUniqueModelObject(); + + zoneHVACEvaporativeCoolerUnit.setName("My ZoneHVACEvaporativeCoolerUnit"); + boost::optional availabilitySchedule(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilitySchedule(availabilitySchedule)); + boost::optional availabilityManagerList(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilityManagerList(availabilityManagerList)); + Node outdoorAirInletNodeName(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setOutdoorAirInletNodeName(outdoorAirInletNodeName)); + Node coolerOutletNodeName(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerOutletNodeName(coolerOutletNodeName)); + Node zoneReliefAirNodeName(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setZoneReliefAirNodeName(zoneReliefAirNodeName)); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFanObjectType("Fan:SystemModel")); + Fans supplyAirFan(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFan(supplyAirFan)); + // Autosize + // zoneHVACEvaporativeCoolerUnit.autosizeDesignSupplyAirFlowRate(); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSupplyAirFlowRate(0.9)); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFanPlacement("BlowThrough")); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerUnitControlMethod("ZoneTemperatureDeadbandOnOffCycling")); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setThrottlingRangeTemperatureDifference(1.2)); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolingLoadControlThresholdHeatTransferRate(1.3)); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCoolerObjectType("EvaporativeCooler:Direct:CelDekPad")); + EvapCooler firstEvaporativeCoolerObject(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCoolerObject(firstEvaporativeCoolerObject)); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCoolerObjectType("EvaporativeCooler:Direct:CelDekPad")); + boost::optional secondEvaporativeCooler(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); + boost::optional designSpecificationZoneHVACSizingObject(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSpecificationZoneHVACSizingObject(designSpecificationZoneHVACSizingObject)); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(95.0)); + + + // TODO: you're responsible for creating all other objects needed so this object actually gets ForwardTranslated + + const Workspace w = ft.translateModel(m); + const auto idfObjs = w.getObjectsByType(IddObjectType::ZoneHVAC_EvaporativeCoolerUnit); + ASSERT_EQ(1u, idfObjs.size()); + + const auto& idfObject = idfObjs.front(); + EXPECT_EQ(availabilitySchedule.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName).get()); + EXPECT_EQ(availabilityManagerList.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName).get()); + EXPECT_EQ(outdoorAirInletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); + EXPECT_EQ(coolerOutletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); + EXPECT_EQ(zoneReliefAirNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); + EXPECT_EQ("Fan:SystemModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); EXPECT_EQ(supplyAirFan.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get()); + // EXPECT_EQ("Autosize", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); EXPECT_EQ(0.9, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); EXPECT_EQ("BlowThrough", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement).get()); EXPECT_EQ("ZoneTemperatureDeadbandOnOffCycling", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod).get()); EXPECT_EQ(1.2, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference).get()); EXPECT_EQ(1.3, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate).get()); EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType).get()); EXPECT_EQ(firstEvaporativeCoolerObject.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName).get()); + EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType).get()); EXPECT_EQ(secondEvaporativeCooler.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get()); + EXPECT_EQ(designSpecificationZoneHVACSizingObject.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName).get()); + EXPECT_EQ(95.0, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity).get()); +} diff --git a/src/model/ScheduleTypeRegistry.cpp b/src/model/ScheduleTypeRegistry.cpp index a24cbe7b57..e63e6ddf9f 100644 --- a/src/model/ScheduleTypeRegistry.cpp +++ b/src/model/ScheduleTypeRegistry.cpp @@ -558,6 +558,7 @@ namespace model { {"ZoneHVACUnitVentilator", "Maximum Outdoor Air Fraction or Temperature", "maximumOutdoorAirFractionorTemperatureSchedule", true, "", OptionalDouble(), OptionalDouble()}, {"ZoneHVACUnitVentilator", "Supply Air Fan Operating Mode", "supplyAirFanOperatingModeSchedule", false, "ControlMode", 0.0, 1.0}, + {"ZoneHVACEvaporativeCoolerUnit", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"ZoneMixing", "Zone Mixing", "schedule", true, "Dimensionless", 0.0, 1.0}, {"ZoneMixing", "Delta Temperature", "deltaTemperatureSchedule", true, "DeltaTemperature", OptionalDouble(), OptionalDouble()}, {"ZoneMixing", "Minimum Receiving Temperature", "minimumReceivingTemperatureSchedule", true, "Temperature", OptionalDouble(), OptionalDouble()}, diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp new file mode 100644 index 0000000000..c48633e554 --- /dev/null +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -0,0 +1,585 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" + +// TODO: Check the following class names against object getters and setters. +#include "Schedule.hpp" +#include "Schedule_Impl.hpp" +#include "SystemAvailabilityManagerLists.hpp" +#include "SystemAvailabilityManagerLists_Impl.hpp" +#include "Connection.hpp" +#include "Connection_Impl.hpp" +#include "Fans.hpp" +#include "Fans_Impl.hpp" +#include "EvapCooler.hpp" +#include "EvapCooler_Impl.hpp" +#include "DesignSpecificationZoneHVACSizingName.hpp" +#include "DesignSpecificationZoneHVACSizingName_Impl.hpp" +#include "ScheduleTypeLimits.hpp" +#include "ScheduleTypeRegistry.hpp" + +#include "../utilities/core/Assert.hpp" +#include "../utilities/data/DataEnums.hpp" + +#include +#include +#include + +namespace openstudio { +namespace model { + + namespace detail { + + ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const IdfObject& idfObject, + Model_Impl* model, bool keepHandle) + : ZoneHVACComponent_Impl(idfObject, model, keepHandle) { + OS_ASSERT(idfObject.iddObject().type() == ZoneHVACEvaporativeCoolerUnit::iddObjectType()); + } + + ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, bool keepHandle) + : ZoneHVACComponent_Impl(other, model, keepHandle) { + OS_ASSERT(other.iddObject().type() == ZoneHVACEvaporativeCoolerUnit::iddObjectType()); + } + + ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const ZoneHVACEvaporativeCoolerUnit_Impl& other, + Model_Impl* model, bool keepHandle) + : ZoneHVACComponent_Impl(other, model, keepHandle) {} + + const std::vector& ZoneHVACEvaporativeCoolerUnit_Impl::outputVariableNames() const { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType ZoneHVACEvaporativeCoolerUnit_Impl::iddObjectType() const { + return ZoneHVACEvaporativeCoolerUnit::iddObjectType(); + } + + std::vector ZoneHVACEvaporativeCoolerUnit_Impl::getScheduleTypeKeys(const Schedule& schedule) const { + // TODO: Check schedule display names. + std::vector result; + const UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); + if (std::find(fieldIndices.cbegin(), fieldIndices.cend(), + OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName) + != fieldIndices.cend()) { + result.emplace_back("ZoneHVACEvaporativeCoolerUnit", "Availability"); + } + return result; + } + + ComponentType ZoneHVACEvaporativeCoolerUnit_Impl::componentType() const { + // TODO + return ComponentType::None; + } + + std::vector ZoneHVACEvaporativeCoolerUnit_Impl::coolingFuelTypes() const { + // TODO + return {}; + } + + std::vector ZoneHVACEvaporativeCoolerUnit_Impl::heatingFuelTypes() const { + // TODO + return {}; + } + + std::vector ZoneHVACEvaporativeCoolerUnit_Impl::appGHeatingFuelTypes() const { + + // TODO + return {}; + } + + Schedule ZoneHVACEvaporativeCoolerUnit_Impl::availabilitySchedule() const { + boost::optional value = optionalAvailabilitySchedule(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Availability Schedule attached."); + } + return value.get(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::availabilityManagerList() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName ); + } + + Connection ZoneHVACEvaporativeCoolerUnit_Impl::outdoorAirInletNode() const { + boost::optional value = optionalOutdoorAirInletNode(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Outdoor Air Inlet Node attached."); + } + return value.get(); + } + + Connection ZoneHVACEvaporativeCoolerUnit_Impl::coolerOutletNode() const { + boost::optional value = optionalCoolerOutletNode(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Cooler Outlet Node attached."); + } + return value.get(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::zoneReliefAirNode() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName ); + } + + Fans ZoneHVACEvaporativeCoolerUnit_Impl::supplyAirFan() const { + boost::optional value = optionalSupplyAirFan(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Supply Air Fan attached."); + } + return value.get(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::designSupplyAirFlowRate() const { + return getDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate , true ); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::isDesignSupplyAirFlowRateAutosized() const { + bool result = false; + boost::optional value = getString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, true); + if (value) { + result = openstudio::istringEqual(value.get(), "autosize"); + } + return result; + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::autosizedDesignSupplyAirFlowRate() { + return getAutosizedValue("TODO_CHECK_SQL Design Supply Air Flow Rate", "m3/s"); + } + + std::string ZoneHVACEvaporativeCoolerUnit_Impl::fanPlacement() const { + boost::optional value = getString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement, true); + OS_ASSERT(value); + return value.get(); + } + + std::string ZoneHVACEvaporativeCoolerUnit_Impl::coolerUnitControlMethod() const { + boost::optional value = getString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod, true); + OS_ASSERT(value); + return value.get(); + } + + double ZoneHVACEvaporativeCoolerUnit_Impl::throttlingRangeTemperatureDifference() const { + boost::optional value = getDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference, true); + OS_ASSERT(value); + return value.get(); + } + + double ZoneHVACEvaporativeCoolerUnit_Impl::coolingLoadControlThresholdHeatTransferRate() const { + boost::optional value = getDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, true); + OS_ASSERT(value); + return value.get(); + } + + EvapCooler ZoneHVACEvaporativeCoolerUnit_Impl::firstEvaporativeCooler() const { + boost::optional value = optionalFirstEvaporativeCooler(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an First Evaporative Cooler attached."); + } + return value.get(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::secondEvaporativeCooler() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName ); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::designSpecificationZoneHVACSizing() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing ); + } + + double ZoneHVACEvaporativeCoolerUnit_Impl::shutOffRelativeHumidity() const { + boost::optional value = getDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity, true); + OS_ASSERT(value); + return value.get(); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setAvailabilitySchedule(Schedule& schedule) { + const bool result = setSchedule(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, + "ZoneHVACEvaporativeCoolerUnit", + "Availability", + schedule); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, systemAvailabilityManagerLists.handle()); + return result; + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::resetAvailabilityManagerList() { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, ""); + OS_ASSERT(result); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setOutdoorAirInletNode(const Connection& connection) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, connection.handle()); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setCoolerOutletNode(const Connection& connection) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, connection.handle()); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setZoneReliefAirNode(const Connection& connection) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, connection.handle()); + return result; + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::resetZoneReliefAirNode() { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, ""); + OS_ASSERT(result); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setSupplyAirFan(const Fans& fans) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fans.handle()); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setDesignSupplyAirFlowRate(double designSupplyAirFlowRate) { + const bool result = setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, designSupplyAirFlowRate); + return result; + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::autosizeDesignSupplyAirFlowRate() { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, "autosize"); + OS_ASSERT(result); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setFanPlacement(const std::string& fanPlacement) { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement, fanPlacement); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setCoolerUnitControlMethod(const std::string& coolerUnitControlMethod) { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod, coolerUnitControlMethod); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setThrottlingRangeTemperatureDifference(double throttlingRangeTemperatureDifference) { + const bool result = setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference, throttlingRangeTemperatureDifference); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate) { + const bool result = setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, coolingLoadControlThresholdHeatTransferRate); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setFirstEvaporativeCooler(const EvapCooler& evapCooler) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCooler, evapCooler.handle()); + return result; + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setSecondEvaporativeCooler(const EvapCooler& evapCooler) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, evapCooler.handle()); + return result; + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::resetSecondEvaporativeCooler() { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, ""); + OS_ASSERT(result); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing, designSpecificationZoneHVACSizingName.handle()); + return result; + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::resetDesignSpecificationZoneHVACSizing() { + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing, ""); + OS_ASSERT(result); + } + + bool ZoneHVACEvaporativeCoolerUnit_Impl::setShutOffRelativeHumidity(double shutOffRelativeHumidity) { + const bool result = setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity, shutOffRelativeHumidity); + return result; + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::autosize() { + autosizeDesignSupplyAirFlowRate(); + } + + void ZoneHVACEvaporativeCoolerUnit_Impl::applySizingValues() { + if (boost::optional val_ = autosizedDesignSupplyAirFlowRate()) { + setDesignSupplyAirFlowRate(*val_)); + } + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalAvailabilitySchedule() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalOutdoorAirInletNode() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalCoolerOutletNode() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalSupplyAirFan() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalFirstEvaporativeCooler() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCooler); + } + + } // namespace detail + + ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit(const Model& model) + : ZoneHVACComponent(ZoneHVACEvaporativeCoolerUnit::iddObjectType(), model) { + OS_ASSERT(getImpl()); + + bool ok = true; + auto alwaysOn = model.alwaysOnDiscreteSchedule(); + ok = setAvailabilitySchedule(alwaysOn); + OS_ASSERT(ok); + // ok = setOutdoorAirInletNode(); + OS_ASSERT(ok); + // ok = setCoolerOutletNode(); + OS_ASSERT(ok); + // ok = setSupplyAirFan(); + OS_ASSERT(ok); + autosizeDesignSupplyAirFlowRate(); + ok = setFanPlacement("BlowThrough"); + OS_ASSERT(ok); + ok = setCoolerUnitControlMethod("ZoneTemperatureDeadbandOnOffCycling"); + OS_ASSERT(ok); + ok = setThrottlingRangeTemperatureDifference(1.0); + OS_ASSERT(ok); + ok = setCoolingLoadControlThresholdHeatTransferRate(100.0); + OS_ASSERT(ok); + // ok = setFirstEvaporativeCooler(); + OS_ASSERT(ok); + ok = setShutOffRelativeHumidity(100.0); + OS_ASSERT(ok); + } + + ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit(const Model& model, Schedule& availabilitySchedule, HVACComponent& supplyAirFan, HVACComponent& firstEvaporativeCooler) + : ZoneHVACComponent(ZoneHVACEvaporativeCoolerUnit::iddObjectType(), model) { + OS_ASSERT(getImpl()); + + bool ok = true; + ok = setAvailabilitySchedule(availabilitySchedule); + OS_ASSERT(ok); + // ok = setOutdoorAirInletNode(); + OS_ASSERT(ok); + // ok = setCoolerOutletNode(); + OS_ASSERT(ok); + ok = setSupplyAirFan(supplyAirFan); + OS_ASSERT(ok); + autosizeDesignSupplyAirFlowRate(); + ok = setFanPlacement("BlowThrough"); + OS_ASSERT(ok); + ok = setCoolerUnitControlMethod("ZoneTemperatureDeadbandOnOffCycling"); + OS_ASSERT(ok); + ok = setThrottlingRangeTemperatureDifference(1.0); + OS_ASSERT(ok); + ok = setCoolingLoadControlThresholdHeatTransferRate(100.0); + OS_ASSERT(ok); + ok = setFirstEvaporativeCooler(firstEvaporativeCooler); + OS_ASSERT(ok); + ok = setShutOffRelativeHumidity(100.0); + OS_ASSERT(ok); + } + + IddObjectType ZoneHVACEvaporativeCoolerUnit::iddObjectType() { + return {IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit}; + } + + std::vector ZoneHVACEvaporativeCoolerUnit::fanPlacementValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement); + } + + std::vector ZoneHVACEvaporativeCoolerUnit::coolerUnitControlMethodValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod); + } + + Schedule ZoneHVACEvaporativeCoolerUnit::availabilitySchedule() const { + return getImpl()->availabilitySchedule(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit::availabilityManagerList() const { + return getImpl()->availabilityManagerList(); + } + + Connection ZoneHVACEvaporativeCoolerUnit::outdoorAirInletNode() const { + return getImpl()->outdoorAirInletNode(); + } + + Connection ZoneHVACEvaporativeCoolerUnit::coolerOutletNode() const { + return getImpl()->coolerOutletNode(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit::zoneReliefAirNode() const { + return getImpl()->zoneReliefAirNode(); + } + + Fans ZoneHVACEvaporativeCoolerUnit::supplyAirFan() const { + return getImpl()->supplyAirFan(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit::designSupplyAirFlowRate() const { + return getImpl()->designSupplyAirFlowRate(); + } + + bool ZoneHVACEvaporativeCoolerUnit::isDesignSupplyAirFlowRateAutosized() const { + return getImpl()->isDesignSupplyAirFlowRateAutosized(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit::autosizedDesignSupplyAirFlowRate() { + return getImpl()->autosizedDesignSupplyAirFlowRate(); + } + + std::string ZoneHVACEvaporativeCoolerUnit::fanPlacement() const { + return getImpl()->fanPlacement(); + } + + std::string ZoneHVACEvaporativeCoolerUnit::coolerUnitControlMethod() const { + return getImpl()->coolerUnitControlMethod(); + } + + double ZoneHVACEvaporativeCoolerUnit::throttlingRangeTemperatureDifference() const { + return getImpl()->throttlingRangeTemperatureDifference(); + } + + double ZoneHVACEvaporativeCoolerUnit::coolingLoadControlThresholdHeatTransferRate() const { + return getImpl()->coolingLoadControlThresholdHeatTransferRate(); + } + + EvapCooler ZoneHVACEvaporativeCoolerUnit::firstEvaporativeCooler() const { + return getImpl()->firstEvaporativeCooler(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit::secondEvaporativeCooler() const { + return getImpl()->secondEvaporativeCooler(); + } + + boost::optional ZoneHVACEvaporativeCoolerUnit::designSpecificationZoneHVACSizing() const { + return getImpl()->designSpecificationZoneHVACSizing(); + } + + double ZoneHVACEvaporativeCoolerUnit::shutOffRelativeHumidity() const { + return getImpl()->shutOffRelativeHumidity(); + } + + bool ZoneHVACEvaporativeCoolerUnit::setAvailabilitySchedule(Schedule& schedule) { + return getImpl()->setAvailabilitySchedule(schedule); + } + + bool ZoneHVACEvaporativeCoolerUnit::setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists) { + return getImpl()->setAvailabilityManagerList(systemAvailabilityManagerLists); + } + + void ZoneHVACEvaporativeCoolerUnit::resetAvailabilityManagerList() { + getImpl()->resetAvailabilityManagerList(); + } + + bool ZoneHVACEvaporativeCoolerUnit::setOutdoorAirInletNode(const Connection& connection) { + return getImpl()->setOutdoorAirInletNode(connection); + } + + bool ZoneHVACEvaporativeCoolerUnit::setCoolerOutletNode(const Connection& connection) { + return getImpl()->setCoolerOutletNode(connection); + } + + bool ZoneHVACEvaporativeCoolerUnit::setZoneReliefAirNode(const Connection& connection) { + return getImpl()->setZoneReliefAirNode(connection); + } + + void ZoneHVACEvaporativeCoolerUnit::resetZoneReliefAirNode() { + getImpl()->resetZoneReliefAirNode(); + } + + bool ZoneHVACEvaporativeCoolerUnit::setSupplyAirFan(const Fans& fans) { + return getImpl()->setSupplyAirFan(fans); + } + + bool ZoneHVACEvaporativeCoolerUnit::setDesignSupplyAirFlowRate(double designSupplyAirFlowRate) { + return getImpl()->setDesignSupplyAirFlowRate(designSupplyAirFlowRate); + } + + void ZoneHVACEvaporativeCoolerUnit::autosizeDesignSupplyAirFlowRate() { + getImpl()->autosizeDesignSupplyAirFlowRate(); + } + + bool ZoneHVACEvaporativeCoolerUnit::setFanPlacement(const std::string& fanPlacement) { + return getImpl()->setFanPlacement(fanPlacement); + } + + bool ZoneHVACEvaporativeCoolerUnit::setCoolerUnitControlMethod(const std::string& coolerUnitControlMethod) { + return getImpl()->setCoolerUnitControlMethod(coolerUnitControlMethod); + } + + bool ZoneHVACEvaporativeCoolerUnit::setThrottlingRangeTemperatureDifference(double throttlingRangeTemperatureDifference) { + return getImpl()->setThrottlingRangeTemperatureDifference(throttlingRangeTemperatureDifference); + } + + bool ZoneHVACEvaporativeCoolerUnit::setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate) { + return getImpl()->setCoolingLoadControlThresholdHeatTransferRate(coolingLoadControlThresholdHeatTransferRate); + } + + bool ZoneHVACEvaporativeCoolerUnit::setFirstEvaporativeCooler(const EvapCooler& evapCooler) { + return getImpl()->setFirstEvaporativeCooler(evapCooler); + } + + bool ZoneHVACEvaporativeCoolerUnit::setSecondEvaporativeCooler(const EvapCooler& evapCooler) { + return getImpl()->setSecondEvaporativeCooler(evapCooler); + } + + void ZoneHVACEvaporativeCoolerUnit::resetSecondEvaporativeCooler() { + getImpl()->resetSecondEvaporativeCooler(); + } + + bool ZoneHVACEvaporativeCoolerUnit::setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { + return getImpl()->setDesignSpecificationZoneHVACSizing(designSpecificationZoneHVACSizingName); + } + + void ZoneHVACEvaporativeCoolerUnit::resetDesignSpecificationZoneHVACSizing() { + getImpl()->resetDesignSpecificationZoneHVACSizing(); + } + + bool ZoneHVACEvaporativeCoolerUnit::setShutOffRelativeHumidity(double shutOffRelativeHumidity) { + return getImpl()->setShutOffRelativeHumidity(shutOffRelativeHumidity); + } + + /// @cond + ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit( + std::shared_ptr impl) + : ZoneHVACComponent(std::move(impl)) {} + /// @endcond + +} // namespace model +} // namespace openstudio diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp new file mode 100644 index 0000000000..2714eabeda --- /dev/null +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp @@ -0,0 +1,209 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#ifndef MODEL_ZONEHVACEVAPORATIVECOOLERUNIT_HPP +#define MODEL_ZONEHVACEVAPORATIVECOOLERUNIT_HPP + +#include +#include "ZoneHVACComponent.hpp" + +namespace openstudio { + +namespace model { + + // TODO: Check the following class names against object getters and setters. + class Schedule; + class SystemAvailabilityManagerLists; + class Connection; + class Fans; + class EvapCooler; + class DesignSpecificationZoneHVACSizingName; + + namespace detail { + + class ZoneHVACEvaporativeCoolerUnit_Impl; + + } // namespace detail + + /** ZoneHVACEvaporativeCoolerUnit is a ZoneHVACComponent that wraps the OpenStudio IDD object 'OS:ZoneHVAC:EvaporativeCoolerUnit'. */ + class MODEL_API ZoneHVACEvaporativeCoolerUnit : public ZoneHVACComponent + { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit ZoneHVACEvaporativeCoolerUnit(const Model& model); + + explicit ZoneHVACEvaporativeCoolerUnit(const Model& model, Schedule& availabilitySchedule, HVACComponent& supplyAirFan, HVACComponent& firstEvaporativeCooler); + + virtual ~ZoneHVACEvaporativeCoolerUnit() = default; + // Default the copy and move operators because the virtual dtor is explicit + ZoneHVACEvaporativeCoolerUnit(const ZoneHVACEvaporativeCoolerUnit& other) = default; + ZoneHVACEvaporativeCoolerUnit(ZoneHVACEvaporativeCoolerUnit&& other) = default; + ZoneHVACEvaporativeCoolerUnit& operator=(const ZoneHVACEvaporativeCoolerUnit&) = default; + ZoneHVACEvaporativeCoolerUnit& operator=(ZoneHVACEvaporativeCoolerUnit&&) = default; + + //@} + + static IddObjectType iddObjectType(); + + static std::vector fanPlacementValues(); + + static std::vector coolerUnitControlMethodValues(); + + /** @name Getters */ + //@{ + + // TODO: Check return type. From object lists, some candidates are: Schedule. + Schedule availabilitySchedule() const; + + // TODO: Check return type. From object lists, some candidates are: SystemAvailabilityManagerLists. + boost::optional availabilityManagerList() const; + + // TODO: Check return type. From object lists, some candidates are: Connection. + Connection outdoorAirInletNode() const; + + // TODO: Check return type. From object lists, some candidates are: Connection. + Connection coolerOutletNode() const; + + // TODO: Check return type. From object lists, some candidates are: Connection. + boost::optional zoneReliefAirNode() const; + + // TODO: Check return type. From object lists, some candidates are: Fans. + Fans supplyAirFan() const; + + boost::optional designSupplyAirFlowRate() const; + + bool isDesignSupplyAirFlowRateAutosized() const; + + boost::optional autosizedDesignSupplyAirFlowRate(); + + std::string fanPlacement() const; + + std::string coolerUnitControlMethod() const; + + double throttlingRangeTemperatureDifference() const; + + double coolingLoadControlThresholdHeatTransferRate() const; + + // TODO: Check return type. From object lists, some candidates are: EvapCooler. + EvapCooler firstEvaporativeCooler() const; + + // TODO: Check return type. From object lists, some candidates are: EvapCooler. + boost::optional secondEvaporativeCooler() const; + + // TODO: Check return type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. + boost::optional designSpecificationZoneHVACSizing() const; + + double shutOffRelativeHumidity() const; + + //@} + /** @name Setters */ + //@{ + + // TODO: Check argument type. From object lists, some candidates are: Schedule. + // Note Schedules are passed by reference, not const reference. + bool setAvailabilitySchedule(Schedule& schedule); + + // TODO: Check argument type. From object lists, some candidates are: SystemAvailabilityManagerLists. + bool setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists); + + void resetAvailabilityManagerList(); + + // TODO: Check argument type. From object lists, some candidates are: Connection. + bool setOutdoorAirInletNode(const Connection& connection); + + // TODO: Check argument type. From object lists, some candidates are: Connection. + bool setCoolerOutletNode(const Connection& connection); + + // TODO: Check argument type. From object lists, some candidates are: Connection. + bool setZoneReliefAirNode(const Connection& connection); + + void resetZoneReliefAirNode(); + + // TODO: Check argument type. From object lists, some candidates are: Fans. + bool setSupplyAirFan(const Fans& fans); + + bool setDesignSupplyAirFlowRate(double designSupplyAirFlowRate); + + void autosizeDesignSupplyAirFlowRate(); + + bool setFanPlacement(const std::string& fanPlacement); + + bool setCoolerUnitControlMethod(const std::string& coolerUnitControlMethod); + + bool setThrottlingRangeTemperatureDifference(double throttlingRangeTemperatureDifference); + + bool setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate); + + // TODO: Check argument type. From object lists, some candidates are: EvapCooler. + bool setFirstEvaporativeCooler(const EvapCooler& evapCooler); + + // TODO: Check argument type. From object lists, some candidates are: EvapCooler. + bool setSecondEvaporativeCooler(const EvapCooler& evapCooler); + + void resetSecondEvaporativeCooler(); + + // TODO: Check argument type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. + bool setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName); + + void resetDesignSpecificationZoneHVACSizing(); + + bool setShutOffRelativeHumidity(double shutOffRelativeHumidity); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + using ImplType = detail::ZoneHVACEvaporativeCoolerUnit_Impl; + + explicit ZoneHVACEvaporativeCoolerUnit(std::shared_ptr impl); + + friend class detail::ZoneHVACEvaporativeCoolerUnit_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.ZoneHVACEvaporativeCoolerUnit"); + }; + + /** \relates ZoneHVACEvaporativeCoolerUnit*/ + using OptionalZoneHVACEvaporativeCoolerUnit = boost::optional; + + /** \relates ZoneHVACEvaporativeCoolerUnit*/ + using ZoneHVACEvaporativeCoolerUnitVector = std::vector; + +} // namespace model +} // namespace openstudio + +#endif // MODEL_ZONEHVACEVAPORATIVECOOLERUNIT_HPP diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp new file mode 100644 index 0000000000..8ab666ef28 --- /dev/null +++ b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp @@ -0,0 +1,215 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#ifndef MODEL_ZONEHVACEVAPORATIVECOOLERUNIT_IMPL_HPP +#define MODEL_ZONEHVACEVAPORATIVECOOLERUNIT_IMPL_HPP + +#include +#include "ZoneHVACComponent_Impl.hpp" + +namespace openstudio { +namespace model { + + // TODO: Check the following class names against object getters and setters. + class Schedule; + class SystemAvailabilityManagerLists; + class Connection; + class Fans; + class EvapCooler; + class DesignSpecificationZoneHVACSizingName; + + namespace detail { + + /** ZoneHVACEvaporativeCoolerUnit_Impl is a ZoneHVACComponent_Impl that is the implementation class for ZoneHVACEvaporativeCoolerUnit.*/ + class MODEL_API ZoneHVACEvaporativeCoolerUnit_Impl : public ZoneHVACComponent_Impl + { + public: + /** @name Constructors and Destructors */ + //@{ + + ZoneHVACEvaporativeCoolerUnit_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + ZoneHVACEvaporativeCoolerUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + ZoneHVACEvaporativeCoolerUnit_Impl(const ZoneHVACEvaporativeCoolerUnit_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~ZoneHVACEvaporativeCoolerUnit_Impl() = default; + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const override; + + virtual IddObjectType iddObjectType() const override; + + virtual std::vector getScheduleTypeKeys(const Schedule& schedule) const override; + + virtual ComponentType componentType() const override; + virtual std::vector coolingFuelTypes() const override; + virtual std::vector heatingFuelTypes() const override; + virtual std::vector appGHeatingFuelTypes() const override; + + //@} + /** @name Getters */ + //@{ + + // TODO: Check return type. From object lists, some candidates are: Schedule. + Schedule availabilitySchedule() const; + + // TODO: Check return type. From object lists, some candidates are: SystemAvailabilityManagerLists. + boost::optional availabilityManagerList() const; + + // TODO: Check return type. From object lists, some candidates are: Connection. + Connection outdoorAirInletNode() const; + + // TODO: Check return type. From object lists, some candidates are: Connection. + Connection coolerOutletNode() const; + + // TODO: Check return type. From object lists, some candidates are: Connection. + boost::optional zoneReliefAirNode() const; + + // TODO: Check return type. From object lists, some candidates are: Fans. + Fans supplyAirFan() const; + + boost::optional designSupplyAirFlowRate() const; + + bool isDesignSupplyAirFlowRateAutosized() const; + + boost::optional autosizedDesignSupplyAirFlowRate(); + + std::string fanPlacement() const; + + std::string coolerUnitControlMethod() const; + + double throttlingRangeTemperatureDifference() const; + + double coolingLoadControlThresholdHeatTransferRate() const; + + // TODO: Check return type. From object lists, some candidates are: EvapCooler. + EvapCooler firstEvaporativeCooler() const; + + // TODO: Check return type. From object lists, some candidates are: EvapCooler. + boost::optional secondEvaporativeCooler() const; + + // TODO: Check return type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. + boost::optional designSpecificationZoneHVACSizing() const; + + double shutOffRelativeHumidity() const; + + //@} + /** @name Setters */ + //@{ + + // TODO: Check argument type. From object lists, some candidates are: Schedule. + // Note Schedules are passed by reference, not const reference. + bool setAvailabilitySchedule(Schedule& schedule); + + // TODO: Check argument type. From object lists, some candidates are: SystemAvailabilityManagerLists. + bool setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists); + + void resetAvailabilityManagerList(); + + // TODO: Check argument type. From object lists, some candidates are: Connection. + bool setOutdoorAirInletNode(const Connection& connection); + + // TODO: Check argument type. From object lists, some candidates are: Connection. + bool setCoolerOutletNode(const Connection& connection); + + // TODO: Check argument type. From object lists, some candidates are: Connection. + bool setZoneReliefAirNode(const Connection& connection); + + void resetZoneReliefAirNode(); + + // TODO: Check argument type. From object lists, some candidates are: Fans. + bool setSupplyAirFan(const Fans& fans); + + bool setDesignSupplyAirFlowRate(double designSupplyAirFlowRate); + + void autosizeDesignSupplyAirFlowRate(); + + bool setFanPlacement(const std::string& fanPlacement); + + bool setCoolerUnitControlMethod(const std::string& coolerUnitControlMethod); + + bool setThrottlingRangeTemperatureDifference(double throttlingRangeTemperatureDifference); + + bool setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate); + + // TODO: Check argument type. From object lists, some candidates are: EvapCooler. + bool setFirstEvaporativeCooler(const EvapCooler& evapCooler); + + // TODO: Check argument type. From object lists, some candidates are: EvapCooler. + bool setSecondEvaporativeCooler(const EvapCooler& evapCooler); + + void resetSecondEvaporativeCooler(); + + // TODO: Check argument type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. + bool setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName); + + void resetDesignSpecificationZoneHVACSizing(); + + bool setShutOffRelativeHumidity(double shutOffRelativeHumidity); + + virtual void autosize() override; + + virtual void applySizingValues() override; + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.ZoneHVACEvaporativeCoolerUnit"); + + // TODO: Check the return types of these methods. + // Optional getters for use by methods like children() so can remove() if the constructor fails. + // There are other ways for the public versions of these getters to fail--perhaps all required + // objects should be returned as boost::optionals + boost::optional optionalAvailabilitySchedule() const; + boost::optional optionalOutdoorAirInletNode() const; + boost::optional optionalCoolerOutletNode() const; + boost::optional optionalSupplyAirFan() const; + boost::optional optionalFirstEvaporativeCooler() const; + }; + + } // namespace detail + +} // namespace model +} // namespace openstudio + +#endif // MODEL_ZONEHVACEVAPORATIVECOOLERUNIT_IMPL_HPP diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp new file mode 100644 index 0000000000..cc9e6146fa --- /dev/null +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -0,0 +1,176 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +* following conditions are met: +* +* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following +* disclaimer. +* +* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided with the distribution. +* +* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products +* derived from this software without specific prior written permission from the respective party. +* +* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works +* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior +* written permission from Alliance for Sustainable Energy, LLC. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED +* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************************************************************/ + +#include "ModelFixture.hpp" + +#include "../ZoneHVACEvaporativeCoolerUnit.hpp" +#include "../ZoneHVACEvaporativeCoolerUnit_Impl.hpp" + +// TODO: Check the following class names against object getters and setters. +#include "../Schedule.hpp" +#include "../Schedule_Impl.hpp" + +#include "../SystemAvailabilityManagerLists.hpp" +#include "../SystemAvailabilityManagerLists_Impl.hpp" + +#include "../Connection.hpp" +#include "../Connection_Impl.hpp" + +#include "../Fans.hpp" +#include "../Fans_Impl.hpp" + +#include "../EvapCooler.hpp" +#include "../EvapCooler_Impl.hpp" + +#include "../DesignSpecificationZoneHVACSizingName.hpp" +#include "../DesignSpecificationZoneHVACSizingName_Impl.hpp" + +using namespace openstudio; +using namespace openstudio::model; + +TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_GettersSetters) { + Model m; + // TODO: Check regular Ctor arguments + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); + // TODO: Or if a UniqueModelObject (and make sure _Impl is included) + // ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit = m.getUniqueModelObject(); + + zoneHVACEvaporativeCoolerUnit.setName("My ZoneHVACEvaporativeCoolerUnit"); + + // Availability Schedule Name: Required Object + Schedule availabilitySchedule(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilitySchedule(availabilitySchedule)); + EXPECT_EQ(availabilitySchedule, zoneHVACEvaporativeCoolerUnit.availabilitySchedule()); + + // Availability Manager List Name: Optional Object + boost::optional availabilityManagerList(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilityManagerList(availabilityManagerList)); + ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.availabilityManagerList()); + EXPECT_EQ(availabilityManagerList, zoneHVACEvaporativeCoolerUnit.availabilityManagerList().get()); + + // Outdoor Air Inlet Node Name: Required Object + Connection outdoorAirInletNode(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setOutdoorAirInletNode(outdoorAirInletNode)); + EXPECT_EQ(outdoorAirInletNode, zoneHVACEvaporativeCoolerUnit.outdoorAirInletNode()); + + // Cooler Outlet Node Name: Required Object + Connection coolerOutletNode(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerOutletNode(coolerOutletNode)); + EXPECT_EQ(coolerOutletNode, zoneHVACEvaporativeCoolerUnit.coolerOutletNode()); + + // Zone Relief Air Node Name: Optional Object + boost::optional zoneReliefAirNode(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setZoneReliefAirNode(zoneReliefAirNode)); + ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.zoneReliefAirNode()); + EXPECT_EQ(zoneReliefAirNode, zoneHVACEvaporativeCoolerUnit.zoneReliefAirNode().get()); + + // Supply Air Fan Name: Required Object + Fans supplyAirFan(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFan(supplyAirFan)); + EXPECT_EQ(supplyAirFan, zoneHVACEvaporativeCoolerUnit.supplyAirFan()); + + // Design Supply Air Flow Rate: Required Double + // Autosize + zoneHVACEvaporativeCoolerUnit.autosizeDesignSupplyAirFlowRate(); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.isDesignSupplyAirFlowRateAutosized()); + // Set + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSupplyAirFlowRate(0.9)); + ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.designSupplyAirFlowRate()); + EXPECT_EQ(0.9, zoneHVACEvaporativeCoolerUnit.designSupplyAirFlowRate().get()); + // Bad Value + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setDesignSupplyAirFlowRate(-10.0)); + ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.designSupplyAirFlowRate()); + EXPECT_EQ(0.9, zoneHVACEvaporativeCoolerUnit.designSupplyAirFlowRate().get()); + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.isDesignSupplyAirFlowRateAutosized()); + + // Fan Placement: Required String + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFanPlacement("BlowThrough")); + EXPECT_EQ("BlowThrough", zoneHVACEvaporativeCoolerUnit.fanPlacement()); + // Bad Value + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setFanPlacement("BADENUM")); + EXPECT_EQ("BlowThrough", zoneHVACEvaporativeCoolerUnit.fanPlacement()); + + // Cooler Unit Control Method: Required String + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerUnitControlMethod("ZoneTemperatureDeadbandOnOffCycling")); + EXPECT_EQ("ZoneTemperatureDeadbandOnOffCycling", zoneHVACEvaporativeCoolerUnit.coolerUnitControlMethod()); + // Bad Value + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setCoolerUnitControlMethod("BADENUM")); + EXPECT_EQ("ZoneTemperatureDeadbandOnOffCycling", zoneHVACEvaporativeCoolerUnit.coolerUnitControlMethod()); + + // Throttling Range Temperature Difference: Required Double + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setThrottlingRangeTemperatureDifference(1.2)); + EXPECT_EQ(1.2, zoneHVACEvaporativeCoolerUnit.throttlingRangeTemperatureDifference()); + // Bad Value + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setThrottlingRangeTemperatureDifference(-10.0)); + EXPECT_EQ(1.2, zoneHVACEvaporativeCoolerUnit.throttlingRangeTemperatureDifference()); + + // Cooling Load Control Threshold Heat Transfer Rate: Required Double + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolingLoadControlThresholdHeatTransferRate(1.3)); + EXPECT_EQ(1.3, zoneHVACEvaporativeCoolerUnit.coolingLoadControlThresholdHeatTransferRate()); + // Bad Value + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setCoolingLoadControlThresholdHeatTransferRate(-10.0)); + EXPECT_EQ(1.3, zoneHVACEvaporativeCoolerUnit.coolingLoadControlThresholdHeatTransferRate()); + + // First Evaporative Cooler: Required Object + EvapCooler firstEvaporativeCooler(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCooler(firstEvaporativeCooler)); + EXPECT_EQ(firstEvaporativeCooler, zoneHVACEvaporativeCoolerUnit.firstEvaporativeCooler()); + + // Second Evaporative Cooler Name: Optional Object + boost::optional secondEvaporativeCooler(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); + ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.secondEvaporativeCooler()); + EXPECT_EQ(secondEvaporativeCooler, zoneHVACEvaporativeCoolerUnit.secondEvaporativeCooler().get()); + + // Design Specification ZoneHVAC Sizing: Optional Object + boost::optional designSpecificationZoneHVACSizing(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSpecificationZoneHVACSizing(designSpecificationZoneHVACSizing)); + ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.designSpecificationZoneHVACSizing()); + EXPECT_EQ(designSpecificationZoneHVACSizing, zoneHVACEvaporativeCoolerUnit.designSpecificationZoneHVACSizing().get()); + + // Shut Off Relative Humidity: Required Double + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(94.444)); + EXPECT_EQ(94.444, zoneHVACEvaporativeCoolerUnit.shutOffRelativeHumidity()); + // Bad Value + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(-10.0)); + EXPECT_EQ(94.444, zoneHVACEvaporativeCoolerUnit.shutOffRelativeHumidity()); + +} +TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_HeatCoolFuelTypes) { + Model m; + // TODO: Check regular Ctor arguments + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); + // TODO: Or if a UniqueModelObject (and make sure _Impl is included) + // ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit = m.getUniqueModelObject(); + + EXPECT_EQ(ComponentType(ComponentType::Both), zoneHVACEvaporativeCoolerUnit.componentType()); + testFuelTypeEquality({FuelType::Electricity}, zoneHVACEvaporativeCoolerUnit.coolingFuelTypes()); + testFuelTypeEquality({FuelType::Electricity, FuelType::Propane}, zoneHVACEvaporativeCoolerUnit.heatingFuelTypes()); + testAppGFuelTypeEquality({AppGFuelType::Fuel, AppGFuelType::HeatPump}, zoneHVACEvaporativeCoolerUnit.appGHeatingFuelTypes()); +} From 40983fac990614cb988777f5fa6322460c44c11a Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Fri, 20 Dec 2024 12:34:46 -0700 Subject: [PATCH 04/24] Update model resource files. --- src/energyplus/CMakeLists.txt | 2 + src/energyplus/ForwardTranslator.cpp | 5 ++ src/energyplus/ForwardTranslator.hpp | 3 + ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 34 ++++----- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 20 +++--- src/model/CMakeLists.txt | 4 ++ src/model/Model.cpp | 2 + src/model/ModelZoneHVAC.i | 2 + src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 70 ++++++++++--------- src/model/ZoneHVACEvaporativeCoolerUnit.hpp | 5 +- .../ZoneHVACEvaporativeCoolerUnit_Impl.hpp | 20 ++---- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 1 - 12 files changed, 90 insertions(+), 78 deletions(-) diff --git a/src/energyplus/CMakeLists.txt b/src/energyplus/CMakeLists.txt index eaafa6c3fb..e7d407a525 100644 --- a/src/energyplus/CMakeLists.txt +++ b/src/energyplus/CMakeLists.txt @@ -444,6 +444,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateZoneHVACEnergyRecoveryVentilator.cpp ForwardTranslator/ForwardTranslateZoneHVACEnergyRecoveryVentilatorController.cpp ForwardTranslator/ForwardTranslateZoneHVACEquipmentList.cpp + ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp ForwardTranslator/ForwardTranslateZoneHVACFourPipeFanCoil.cpp ForwardTranslator/ForwardTranslateZoneHVACHighTemperatureRadiant.cpp ForwardTranslator/ForwardTranslateZoneHVACIdealLoadsAirSystem.cpp @@ -840,6 +841,7 @@ set(${target_name}_test_src Test/WaterUseConnections_GTest.cpp Test/ZoneAirHeatBalanceAlgorithm_GTest.cpp Test/ZoneHVACBaseboardRadiantConvectiveWater_GTest.cpp + Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp Test/ZoneHVACLowTemperatureRadiantElectric_GTest.cpp Test/ZoneHVACLowTempRadiantConstFlow_GTest.cpp Test/ZoneHVACLowTempRadiantVarFlow_GTest.cpp diff --git a/src/energyplus/ForwardTranslator.cpp b/src/energyplus/ForwardTranslator.cpp index 10432603e3..ec486ebb35 100644 --- a/src/energyplus/ForwardTranslator.cpp +++ b/src/energyplus/ForwardTranslator.cpp @@ -3204,6 +3204,11 @@ namespace energyplus { retVal = translateZoneHVACEquipmentList(mo); break; } + case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { + auto mo = modelObject.cast(); + retVal = translateZoneHVACEvaporativeCoolerUnit(mo); + break; + } case openstudio::IddObjectType::OS_ZoneHVAC_FourPipeFanCoil: { auto mo = modelObject.cast(); retVal = translateZoneHVACFourPipeFanCoil(mo); diff --git a/src/energyplus/ForwardTranslator.hpp b/src/energyplus/ForwardTranslator.hpp index b14c46dabe..f007e98448 100644 --- a/src/energyplus/ForwardTranslator.hpp +++ b/src/energyplus/ForwardTranslator.hpp @@ -481,6 +481,7 @@ namespace model { class ZoneHVACEnergyRecoveryVentilator; class ZoneHVACEnergyRecoveryVentilatorController; class ZoneHVACEquipmentList; + class ZoneHVACEvaporativeCoolerUnit; class ZoneHVACFourPipeFanCoil; class ZoneHVACHighTemperatureRadiant; class ZoneHVACIdealLoadsAirSystem; @@ -1551,6 +1552,8 @@ namespace energyplus { boost::optional translateZoneHVACEquipmentList(model::ZoneHVACEquipmentList& modelObject); + boost::optional translateZoneHVACEvaporativeCoolerUnit(model::ZoneHVACEvaporativeCoolerUnit& modelObject); + boost::optional translateZoneHVACFourPipeFanCoil(model::ZoneHVACFourPipeFanCoil& modelObject); boost::optional translateZoneHVACHighTemperatureRadiant(model::ZoneHVACHighTemperatureRadiant& modelObject); diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index 2050f7ff8e..cf9c44a8a3 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -60,40 +60,40 @@ namespace openstudio { namespace energyplus { - boost::optional ForwardTranslator::translateZoneHVACEvaporativeCoolerUnit( model::ZoneHVACEvaporativeCoolerUnit& modelObject ) { + boost::optional ForwardTranslator::translateZoneHVACEvaporativeCoolerUnit(model::ZoneHVACEvaporativeCoolerUnit& modelObject) { // Instantiate an IdfObject of the class to store the values IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EvaporativeCoolerUnit, modelObject); // Availability Schedule Name: Optional Object if (boost::optional availabilitySchedule_ = modelObject.availabilitySchedule()) { - if (boost::optional wo_ = translateAndMapModelObject(availabilitySchedule_.get())) { + if (boost::optional wo_ = translateAndMapModelObject(availabilitySchedule_.get())) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString()); } } // Availability Manager List Name: Optional Object if (boost::optional availabilityManagerList_ = modelObject.availabilityManagerList()) { - if (boost::optional wo_ = translateAndMapModelObject(availabilityManagerList_.get())) { + if (boost::optional wo_ = translateAndMapModelObject(availabilityManagerList_.get())) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, wo_->nameString()); } } // Outdoor Air Inlet Node Name: Required Node Node outdoorAirInletNodeName = modelObject.inletNode(); - if (boost::optional wo_ = translateAndMapModelObject(outdoorAirInletNodeName)) { + if (boost::optional wo_ = translateAndMapModelObject(outdoorAirInletNodeName)) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, wo_->nameString()); } // Cooler Outlet Node Name: Required Node Node coolerOutletNodeName = modelObject.outletNode(); - if (boost::optional wo_ = translateAndMapModelObject(coolerOutletNodeName)) { + if (boost::optional wo_ = translateAndMapModelObject(coolerOutletNodeName)) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, wo_->nameString()); } // Zone Relief Air Node Name: Optional Node Node zoneReliefAirNodeName = modelObject.zoneReliefAirNodeName(); - if (boost::optional wo_ = translateAndMapModelObject(zoneReliefAirNodeName)) { + if (boost::optional wo_ = translateAndMapModelObject(zoneReliefAirNodeName)) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, wo_->nameString()); } @@ -101,10 +101,9 @@ namespace energyplus { const std::string supplyAirFanObjectType = modelObject.supplyAirFanObjectType(); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, supplyAirFanObjectType); - // Supply Air Fan Name: Required Object Fans supplyAirFan = modelObject.supplyAirFan(); - if (boost::optional wo_ = translateAndMapModelObject(supplyAirFan)) { + if (boost::optional wo_ = translateAndMapModelObject(supplyAirFan)) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, wo_->nameString()); } @@ -115,36 +114,32 @@ namespace energyplus { if (boost::optional designSupplyAirFlowRate_ = modelObject.designSupplyAirFlowRate()) { idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, designSupplyAirFlowRate_.get()); } - } + } // Fan Placement: Required String const std::string fanPlacement = modelObject.fanPlacement(); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement, fanPlacement); - // Cooler Unit Control Method: Required String const std::string coolerUnitControlMethod = modelObject.coolerUnitControlMethod(); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod, coolerUnitControlMethod); - // Throttling Range Temperature Difference: Optional Double const double throttlingRangeTemperatureDifference = modelObject.throttlingRangeTemperatureDifference(); idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference, throttlingRangeTemperatureDifference); - // Cooling Load Control Threshold Heat Transfer Rate: Optional Double const double coolingLoadControlThresholdHeatTransferRate = modelObject.coolingLoadControlThresholdHeatTransferRate(); - idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, coolingLoadControlThresholdHeatTransferRate); - + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, + coolingLoadControlThresholdHeatTransferRate); // First Evaporative Cooler Object Type: Required String const std::string firstEvaporativeCoolerObjectType = modelObject.firstEvaporativeCoolerObjectType(); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType, firstEvaporativeCoolerObjectType); - // First Evaporative Cooler Object Name: Required Object EvapCooler firstEvaporativeCoolerObject = modelObject.firstEvaporativeCoolerObject(); - if (boost::optional wo_ = translateAndMapModelObject(firstEvaporativeCoolerObject)) { + if (boost::optional wo_ = translateAndMapModelObject(firstEvaporativeCoolerObject)) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName, wo_->nameString()); } @@ -155,14 +150,15 @@ namespace energyplus { // Second Evaporative Cooler Name: Optional Object if (boost::optional secondEvaporativeCooler_ = modelObject.secondEvaporativeCooler()) { - if (boost::optional wo_ = translateAndMapModelObject(secondEvaporativeCooler_.get())) { + if (boost::optional wo_ = translateAndMapModelObject(secondEvaporativeCooler_.get())) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, wo_->nameString()); } } // Design Specification ZoneHVAC Sizing Object Name: Optional Object - if (boost::optional designSpecificationZoneHVACSizingObject_ = modelObject.designSpecificationZoneHVACSizingObject()) { - if (boost::optional wo_ = translateAndMapModelObject(designSpecificationZoneHVACSizingObject_.get())) { + if (boost::optional designSpecificationZoneHVACSizingObject_ = + modelObject.designSpecificationZoneHVACSizingObject()) { + if (boost::optional wo_ = translateAndMapModelObject(designSpecificationZoneHVACSizingObject_.get())) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName, wo_->nameString()); } } diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 8b6e2581f8..84ef665c88 100644 --- a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -101,7 +101,6 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSpecificationZoneHVACSizingObject(designSpecificationZoneHVACSizingObject)); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(95.0)); - // TODO: you're responsible for creating all other objects needed so this object actually gets ForwardTranslated const Workspace w = ft.translateModel(m); @@ -109,14 +108,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { ASSERT_EQ(1u, idfObjs.size()); const auto& idfObject = idfObjs.front(); - EXPECT_EQ(availabilitySchedule.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName).get()); - EXPECT_EQ(availabilityManagerList.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName).get()); - EXPECT_EQ(outdoorAirInletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); - EXPECT_EQ(coolerOutletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); - EXPECT_EQ(zoneReliefAirNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); - EXPECT_EQ("Fan:SystemModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); EXPECT_EQ(supplyAirFan.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get()); + EXPECT_EQ(availabilitySchedule.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName).get()); + EXPECT_EQ(availabilityManagerList.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName).get()); + EXPECT_EQ(outdoorAirInletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); + EXPECT_EQ(coolerOutletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); + EXPECT_EQ(zoneReliefAirNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); + EXPECT_EQ("Fan:SystemModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); + EXPECT_EQ(supplyAirFan.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get()); // EXPECT_EQ("Autosize", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); EXPECT_EQ(0.9, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); EXPECT_EQ("BlowThrough", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement).get()); EXPECT_EQ("ZoneTemperatureDeadbandOnOffCycling", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod).get()); EXPECT_EQ(1.2, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference).get()); EXPECT_EQ(1.3, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate).get()); EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType).get()); EXPECT_EQ(firstEvaporativeCoolerObject.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName).get()); - EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType).get()); EXPECT_EQ(secondEvaporativeCooler.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get()); - EXPECT_EQ(designSpecificationZoneHVACSizingObject.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName).get()); + EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType).get()); + EXPECT_EQ(secondEvaporativeCooler.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get()); + EXPECT_EQ(designSpecificationZoneHVACSizingObject.nameString(), + idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName).get()); EXPECT_EQ(95.0, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity).get()); } diff --git a/src/model/CMakeLists.txt b/src/model/CMakeLists.txt index 8477362fea..548f9e3816 100644 --- a/src/model/CMakeLists.txt +++ b/src/model/CMakeLists.txt @@ -1774,6 +1774,9 @@ set(${target_name}_src ZoneHVACEquipmentList.hpp ZoneHVACEquipmentList_Impl.hpp ZoneHVACEquipmentList.cpp + ZoneHVACEvaporativeCoolerUnit.hpp + ZoneHVACEvaporativeCoolerUnit_Impl.hpp + ZoneHVACEvaporativeCoolerUnit.cpp ZoneHVACFourPipeFanCoil.hpp ZoneHVACFourPipeFanCoil_Impl.hpp ZoneHVACFourPipeFanCoil.cpp @@ -2365,6 +2368,7 @@ set(${target_name}_test_src test/ZoneHVACEnergyRecoveryVentilator_GTest.cpp test/ZoneHVACEnergyRecoveryVentilatorController_GTest.cpp test/ZoneHVACEquipmentList_GTest.cpp + test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp test/ZoneHVACFourPipeFanCoil_GTest.cpp test/ZoneHVACHighTemperatureRadiant_GTest.cpp test/ZoneHVACLowTemperatureRadiantElectric_GTest.cpp diff --git a/src/model/Model.cpp b/src/model/Model.cpp index 75d57bf3ea..bfe9fd1cb2 100644 --- a/src/model/Model.cpp +++ b/src/model/Model.cpp @@ -4410,6 +4410,7 @@ namespace model { REGISTER_CONSTRUCTOR(ZoneControlHumidistat); REGISTER_CONSTRUCTOR(ZoneControlThermostatStagedDualSetpoint); REGISTER_CONSTRUCTOR(ZoneHVACEquipmentList); + REGISTER_CONSTRUCTOR(ZoneHVACEvaporativeCoolerUnit); REGISTER_CONSTRUCTOR(ZoneHVACBaseboardConvectiveElectric); REGISTER_CONSTRUCTOR(ZoneHVACBaseboardConvectiveWater); REGISTER_CONSTRUCTOR(ZoneHVACBaseboardRadiantConvectiveElectric); @@ -4984,6 +4985,7 @@ namespace model { REGISTER_COPYCONSTRUCTORS(ZoneControlHumidistat); REGISTER_COPYCONSTRUCTORS(ZoneControlThermostatStagedDualSetpoint); REGISTER_COPYCONSTRUCTORS(ZoneHVACEquipmentList); + REGISTER_COPYCONSTRUCTORS(ZoneHVACEvaporativeCoolerUnit); REGISTER_COPYCONSTRUCTORS(ZoneHVACBaseboardConvectiveElectric); REGISTER_COPYCONSTRUCTORS(ZoneHVACBaseboardConvectiveWater); REGISTER_COPYCONSTRUCTORS(ZoneHVACBaseboardRadiantConvectiveElectric); diff --git a/src/model/ModelZoneHVAC.i b/src/model/ModelZoneHVAC.i index aa727fd6b0..2c9d85ae1f 100644 --- a/src/model/ModelZoneHVAC.i +++ b/src/model/ModelZoneHVAC.i @@ -54,6 +54,7 @@ MODELOBJECT_TEMPLATES(ZoneHVACCoolingPanelRadiantConvectiveWater); MODELOBJECT_TEMPLATES(ZoneHVACDehumidifierDX); MODELOBJECT_TEMPLATES(ZoneHVACEnergyRecoveryVentilator); MODELOBJECT_TEMPLATES(ZoneHVACEnergyRecoveryVentilatorController); +MODELOBJECT_TEMPLATES(ZoneHVACEvaporativeCoolerUnit); MODELOBJECT_TEMPLATES(ZoneHVACFourPipeFanCoil); MODELOBJECT_TEMPLATES(ZoneHVACHighTemperatureRadiant); MODELOBJECT_TEMPLATES(ZoneHVACIdealLoadsAirSystem); @@ -79,6 +80,7 @@ SWIG_MODELOBJECT(ZoneHVACCoolingPanelRadiantConvectiveWater,1); SWIG_MODELOBJECT(ZoneHVACDehumidifierDX,1); SWIG_MODELOBJECT(ZoneHVACEnergyRecoveryVentilator,1); SWIG_MODELOBJECT(ZoneHVACEnergyRecoveryVentilatorController,1); +SWIG_MODELOBJECT(ZoneHVACEvaporativeCoolerUnit,1); SWIG_MODELOBJECT(ZoneHVACFourPipeFanCoil,1); SWIG_MODELOBJECT(ZoneHVACHighTemperatureRadiant,1); SWIG_MODELOBJECT(ZoneHVACIdealLoadsAirSystem,1); diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index c48633e554..554cf0903f 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -58,25 +58,24 @@ namespace model { namespace detail { - ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const IdfObject& idfObject, - Model_Impl* model, bool keepHandle) + ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : ZoneHVACComponent_Impl(idfObject, model, keepHandle) { OS_ASSERT(idfObject.iddObject().type() == ZoneHVACEvaporativeCoolerUnit::iddObjectType()); } - ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, - Model_Impl* model, bool keepHandle) + ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, + bool keepHandle) : ZoneHVACComponent_Impl(other, model, keepHandle) { OS_ASSERT(other.iddObject().type() == ZoneHVACEvaporativeCoolerUnit::iddObjectType()); } - ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const ZoneHVACEvaporativeCoolerUnit_Impl& other, - Model_Impl* model, bool keepHandle) - : ZoneHVACComponent_Impl(other, model, keepHandle) {} + ZoneHVACEvaporativeCoolerUnit_Impl::ZoneHVACEvaporativeCoolerUnit_Impl(const ZoneHVACEvaporativeCoolerUnit_Impl& other, Model_Impl* model, + bool keepHandle) + : ZoneHVACComponent_Impl(other, model, keepHandle) {} const std::vector& ZoneHVACEvaporativeCoolerUnit_Impl::outputVariableNames() const { static std::vector result; - if (result.empty()){ + if (result.empty()) { } return result; } @@ -89,8 +88,7 @@ namespace model { // TODO: Check schedule display names. std::vector result; const UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); - if (std::find(fieldIndices.cbegin(), fieldIndices.cend(), - OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName) + if (std::find(fieldIndices.cbegin(), fieldIndices.cend(), OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName) != fieldIndices.cend()) { result.emplace_back("ZoneHVACEvaporativeCoolerUnit", "Availability"); } @@ -127,7 +125,8 @@ namespace model { } boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::availabilityManagerList() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName ); + return getObject().getModelObjectTarget( + OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName); } Connection ZoneHVACEvaporativeCoolerUnit_Impl::outdoorAirInletNode() const { @@ -147,7 +146,7 @@ namespace model { } boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::zoneReliefAirNode() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName ); + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName); } Fans ZoneHVACEvaporativeCoolerUnit_Impl::supplyAirFan() const { @@ -159,7 +158,7 @@ namespace model { } boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::designSupplyAirFlowRate() const { - return getDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate , true ); + return getDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, true); } bool ZoneHVACEvaporativeCoolerUnit_Impl::isDesignSupplyAirFlowRateAutosized() const { @@ -171,7 +170,7 @@ namespace model { return result; } - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::autosizedDesignSupplyAirFlowRate() { + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::autosizedDesignSupplyAirFlowRate() { return getAutosizedValue("TODO_CHECK_SQL Design Supply Air Flow Rate", "m3/s"); } @@ -208,11 +207,12 @@ namespace model { } boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::secondEvaporativeCooler() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName ); + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName); } boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::designSpecificationZoneHVACSizing() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing ); + return getObject().getModelObjectTarget( + OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing); } double ZoneHVACEvaporativeCoolerUnit_Impl::shutOffRelativeHumidity() const { @@ -222,10 +222,8 @@ namespace model { } bool ZoneHVACEvaporativeCoolerUnit_Impl::setAvailabilitySchedule(Schedule& schedule) { - const bool result = setSchedule(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, - "ZoneHVACEvaporativeCoolerUnit", - "Availability", - schedule); + const bool result = + setSchedule(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, "ZoneHVACEvaporativeCoolerUnit", "Availability", schedule); return result; } @@ -285,12 +283,14 @@ namespace model { } bool ZoneHVACEvaporativeCoolerUnit_Impl::setThrottlingRangeTemperatureDifference(double throttlingRangeTemperatureDifference) { - const bool result = setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference, throttlingRangeTemperatureDifference); + const bool result = + setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference, throttlingRangeTemperatureDifference); return result; } bool ZoneHVACEvaporativeCoolerUnit_Impl::setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate) { - const bool result = setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, coolingLoadControlThresholdHeatTransferRate); + const bool result = + setDouble(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate, coolingLoadControlThresholdHeatTransferRate); return result; } @@ -309,8 +309,10 @@ namespace model { OS_ASSERT(result); } - bool ZoneHVACEvaporativeCoolerUnit_Impl::setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing, designSpecificationZoneHVACSizingName.handle()); + bool ZoneHVACEvaporativeCoolerUnit_Impl::setDesignSpecificationZoneHVACSizing( + const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { + const bool result = + setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing, designSpecificationZoneHVACSizingName.handle()); return result; } @@ -385,7 +387,8 @@ namespace model { OS_ASSERT(ok); } - ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit(const Model& model, Schedule& availabilitySchedule, HVACComponent& supplyAirFan, HVACComponent& firstEvaporativeCooler) + ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit(const Model& model, Schedule& availabilitySchedule, HVACComponent& supplyAirFan, + HVACComponent& firstEvaporativeCooler) : ZoneHVACComponent(ZoneHVACEvaporativeCoolerUnit::iddObjectType(), model) { OS_ASSERT(getImpl()); @@ -418,13 +421,11 @@ namespace model { } std::vector ZoneHVACEvaporativeCoolerUnit::fanPlacementValues() { - return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), - OS_ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement); + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement); } std::vector ZoneHVACEvaporativeCoolerUnit::coolerUnitControlMethodValues() { - return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), - OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod); + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod); } Schedule ZoneHVACEvaporativeCoolerUnit::availabilitySchedule() const { @@ -459,7 +460,7 @@ namespace model { return getImpl()->isDesignSupplyAirFlowRateAutosized(); } - boost::optional ZoneHVACEvaporativeCoolerUnit::autosizedDesignSupplyAirFlowRate() { + boost::optional ZoneHVACEvaporativeCoolerUnit::autosizedDesignSupplyAirFlowRate() { return getImpl()->autosizedDesignSupplyAirFlowRate(); } @@ -548,7 +549,8 @@ namespace model { } bool ZoneHVACEvaporativeCoolerUnit::setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate) { - return getImpl()->setCoolingLoadControlThresholdHeatTransferRate(coolingLoadControlThresholdHeatTransferRate); + return getImpl()->setCoolingLoadControlThresholdHeatTransferRate( + coolingLoadControlThresholdHeatTransferRate); } bool ZoneHVACEvaporativeCoolerUnit::setFirstEvaporativeCooler(const EvapCooler& evapCooler) { @@ -563,7 +565,8 @@ namespace model { getImpl()->resetSecondEvaporativeCooler(); } - bool ZoneHVACEvaporativeCoolerUnit::setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { + bool ZoneHVACEvaporativeCoolerUnit::setDesignSpecificationZoneHVACSizing( + const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { return getImpl()->setDesignSpecificationZoneHVACSizing(designSpecificationZoneHVACSizingName); } @@ -576,8 +579,7 @@ namespace model { } /// @cond - ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit( - std::shared_ptr impl) + ZoneHVACEvaporativeCoolerUnit::ZoneHVACEvaporativeCoolerUnit(std::shared_ptr impl) : ZoneHVACComponent(std::move(impl)) {} /// @endcond diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp index 2714eabeda..e7fefe42a9 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp @@ -60,7 +60,8 @@ namespace model { explicit ZoneHVACEvaporativeCoolerUnit(const Model& model); - explicit ZoneHVACEvaporativeCoolerUnit(const Model& model, Schedule& availabilitySchedule, HVACComponent& supplyAirFan, HVACComponent& firstEvaporativeCooler); + explicit ZoneHVACEvaporativeCoolerUnit(const Model& model, Schedule& availabilitySchedule, HVACComponent& supplyAirFan, + HVACComponent& firstEvaporativeCooler); virtual ~ZoneHVACEvaporativeCoolerUnit() = default; // Default the copy and move operators because the virtual dtor is explicit @@ -102,7 +103,7 @@ namespace model { bool isDesignSupplyAirFlowRateAutosized() const; - boost::optional autosizedDesignSupplyAirFlowRate(); + boost::optional autosizedDesignSupplyAirFlowRate(); std::string fanPlacement() const; diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp index 8ab666ef28..003ffcc419 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp @@ -46,24 +46,18 @@ namespace model { namespace detail { - /** ZoneHVACEvaporativeCoolerUnit_Impl is a ZoneHVACComponent_Impl that is the implementation class for ZoneHVACEvaporativeCoolerUnit.*/ + /** ZoneHVACEvaporativeCoolerUnit_Impl is a ZoneHVACComponent_Impl that is the implementation class for ZoneHVACEvaporativeCoolerUnit.*/ class MODEL_API ZoneHVACEvaporativeCoolerUnit_Impl : public ZoneHVACComponent_Impl { public: /** @name Constructors and Destructors */ //@{ - ZoneHVACEvaporativeCoolerUnit_Impl(const IdfObject& idfObject, - Model_Impl* model, - bool keepHandle); + ZoneHVACEvaporativeCoolerUnit_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle); - ZoneHVACEvaporativeCoolerUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, - Model_Impl* model, - bool keepHandle); + ZoneHVACEvaporativeCoolerUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle); - ZoneHVACEvaporativeCoolerUnit_Impl(const ZoneHVACEvaporativeCoolerUnit_Impl& other, - Model_Impl* model, - bool keepHandle); + ZoneHVACEvaporativeCoolerUnit_Impl(const ZoneHVACEvaporativeCoolerUnit_Impl& other, Model_Impl* model, bool keepHandle); virtual ~ZoneHVACEvaporativeCoolerUnit_Impl() = default; @@ -108,7 +102,7 @@ namespace model { bool isDesignSupplyAirFlowRateAutosized() const; - boost::optional autosizedDesignSupplyAirFlowRate(); + boost::optional autosizedDesignSupplyAirFlowRate(); std::string fanPlacement() const; @@ -134,7 +128,7 @@ namespace model { //@{ // TODO: Check argument type. From object lists, some candidates are: Schedule. - // Note Schedules are passed by reference, not const reference. + // Note Schedules are passed by reference, not const reference. bool setAvailabilitySchedule(Schedule& schedule); // TODO: Check argument type. From object lists, some candidates are: SystemAvailabilityManagerLists. @@ -195,7 +189,7 @@ namespace model { protected: private: REGISTER_LOGGER("openstudio.model.ZoneHVACEvaporativeCoolerUnit"); - + // TODO: Check the return types of these methods. // Optional getters for use by methods like children() so can remove() if the constructor fails. // There are other ways for the public versions of these getters to fail--perhaps all required diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index cc9e6146fa..ff0d3f6ae8 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -160,7 +160,6 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_GettersSetters) { // Bad Value EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(-10.0)); EXPECT_EQ(94.444, zoneHVACEvaporativeCoolerUnit.shutOffRelativeHumidity()); - } TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_HeatCoolFuelTypes) { Model m; From 70dff3bcf4e24ca0fc3ea9d5c73005bd179c8309 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 23 Dec 2024 12:51:11 -0700 Subject: [PATCH 05/24] Update nodes in ft, general cleanup. --- resources/model/OpenStudio.idd | 4 +- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 188 +++++++++----- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 84 +++---- src/model/ConcreteModelObjects.hpp | 2 + src/model/Model.cpp | 6 +- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 238 ++++-------------- src/model/ZoneHVACEvaporativeCoolerUnit.hpp | 64 +---- .../ZoneHVACEvaporativeCoolerUnit_Impl.hpp | 78 +----- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 69 ++--- 9 files changed, 260 insertions(+), 473 deletions(-) diff --git a/resources/model/OpenStudio.idd b/resources/model/OpenStudio.idd index 07aa068b79..8ed098072d 100644 --- a/resources/model/OpenStudio.idd +++ b/resources/model/OpenStudio.idd @@ -31197,7 +31197,7 @@ OS:ZoneHVAC:CoolingPanel:RadiantConvective:Water, OS:ZoneHVAC:EvaporativeCoolerUnit, \memo Zone evaporative cooler. Forced-convection cooling-only unit with supply fan, \memo 100% outdoor air supply. Optional relief exhaust node - \min-fields 16 + \min-fields 17 A1, \field Handle \type handle \required-field @@ -31265,7 +31265,7 @@ OS:ZoneHVAC:EvaporativeCoolerUnit, \required-field \type object-list \object-list EvapCoolerNames - A12, \field Second Evaporative Cooler Name + A12, \field Second Evaporative Cooler \note optional, used for direct/indirect configurations \type object-list \object-list EvapCoolerNames diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index cf9c44a8a3..970f107edb 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -29,29 +29,21 @@ #include "../ForwardTranslator.hpp" #include "../../model/Model.hpp" - #include "../../model/ZoneHVACEvaporativeCoolerUnit.hpp" - -// TODO: Check the following class names against object getters and setters. +#include "../../model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "../../model/Schedule.hpp" #include "../../model/Schedule_Impl.hpp" - -#include "../../model/SystemAvailabilityManagerLists.hpp" -#include "../../model/SystemAvailabilityManagerLists_Impl.hpp" - #include "../../model/Node.hpp" #include "../../model/Node_Impl.hpp" -#include "../../model/Fans.hpp" -#include "../../model/Fans_Impl.hpp" - -#include "../../model/EvapCooler.hpp" -#include "../../model/EvapCooler_Impl.hpp" - -#include "../../model/DesignSpecificationZoneHVACSizingName.hpp" -#include "../../model/DesignSpecificationZoneHVACSizingName_Impl.hpp" - #include +#include +#include +#include +#include +#include +#include +#include #include using namespace openstudio::model; @@ -72,39 +64,31 @@ namespace energyplus { } } - // Availability Manager List Name: Optional Object - if (boost::optional availabilityManagerList_ = modelObject.availabilityManagerList()) { - if (boost::optional wo_ = translateAndMapModelObject(availabilityManagerList_.get())) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, wo_->nameString()); - } - } + boost::optional outdoorAirInletNodeName; + boost::optional coolerOutletNodeName; // Outdoor Air Inlet Node Name: Required Node - Node outdoorAirInletNodeName = modelObject.inletNode(); - if (boost::optional wo_ = translateAndMapModelObject(outdoorAirInletNodeName)) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, wo_->nameString()); + if (boost::optional node = modelObject.inletNode()) { + outdoorAirInletNodeName = node->name().get(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, node->name().get()); } // Cooler Outlet Node Name: Required Node - Node coolerOutletNodeName = modelObject.outletNode(); - if (boost::optional wo_ = translateAndMapModelObject(coolerOutletNodeName)) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, wo_->nameString()); - } - - // Zone Relief Air Node Name: Optional Node - Node zoneReliefAirNodeName = modelObject.zoneReliefAirNodeName(); - if (boost::optional wo_ = translateAndMapModelObject(zoneReliefAirNodeName)) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, wo_->nameString()); + if (boost::optional node = modelObject.outletNode()) { + coolerOutletNodeName = node->name().get(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, node->name().get()); } - // Supply Air Fan Object Type: Required String - const std::string supplyAirFanObjectType = modelObject.supplyAirFanObjectType(); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, supplyAirFanObjectType); + // Supply Air Fan Object Type + // Supply Air Fan Name + boost::optional fan_; + if (boost::optional supplyAirFan = modelObject.supplyAirFan()) { + fan_ = translateAndMapModelObject(supplyAirFan.get()); - // Supply Air Fan Name: Required Object - Fans supplyAirFan = modelObject.supplyAirFan(); - if (boost::optional wo_ = translateAndMapModelObject(supplyAirFan)) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, wo_->nameString()); + if (fan_ && fan_->name()) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fan_->name().get()); + } } if (modelObject.isDesignSupplyAirFlowRateAutosized()) { @@ -134,32 +118,120 @@ namespace energyplus { coolingLoadControlThresholdHeatTransferRate); // First Evaporative Cooler Object Type: Required String - const std::string firstEvaporativeCoolerObjectType = modelObject.firstEvaporativeCoolerObjectType(); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType, firstEvaporativeCoolerObjectType); - // First Evaporative Cooler Object Name: Required Object - EvapCooler firstEvaporativeCoolerObject = modelObject.firstEvaporativeCoolerObject(); - if (boost::optional wo_ = translateAndMapModelObject(firstEvaporativeCoolerObject)) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName, wo_->nameString()); + HVACComponent firstEvaporativeCooler = modelObject.firstEvaporativeCooler(); + boost::optional firstEvaporativeCooler_ = translateAndMapModelObject(firstEvaporativeCooler); + if (firstEvaporativeCooler_) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType, firstEvaporativeCooler_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName, firstEvaporativeCooler_->nameString()); } // Second Evaporative Cooler Object Type: boost::optional - if (boost::optional secondEvaporativeCoolerObjectType_ = modelObject.secondEvaporativeCoolerObjectType()) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType, secondEvaporativeCoolerObjectType_.get()); + // Second Evaporative Cooler Name: Optional Object + boost::optional _secondEvaporativeCooler = modelObject.secondEvaporativeCooler(); + boost::optional secondEvaporativeCooler_; + if (_secondEvaporativeCooler) { + secondEvaporativeCooler_ = translateAndMapModelObject(_secondEvaporativeCooler.get()); + if (secondEvaporativeCooler_) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType, secondEvaporativeCooler_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, secondEvaporativeCooler_->nameString()); + } } - // Second Evaporative Cooler Name: Optional Object - if (boost::optional secondEvaporativeCooler_ = modelObject.secondEvaporativeCooler()) { - if (boost::optional wo_ = translateAndMapModelObject(secondEvaporativeCooler_.get())) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, wo_->nameString()); + // If BlowThrough: o---- Fan ---- E1 ---- E2 ----o + // If DrawThrough: o---- E1 ---- E2 ---- Fan ----o + std::string baseName = modelObject.name().get(); + if (fan_) { + std::string outletNodeName; + std::string inletNodeName = outdoorAirInletNodeName.get(); + if (istringEqual(fanPlacement, "BlowThrough")) { + if (firstEvaporativeCooler_) { + outletNodeName = baseName + " Fan - First Evaporative Cooler Node"; + } else if (secondEvaporativeCooler_) { + outletNodeName = baseName + " Fan - Second Evaporative Cooler Node"; + } else { + outletNodeName = coolerOutletNodeName.get(); + } + } else { + if (secondEvaporativeCooler_) { + inletNodeName = baseName + " Second Evaporative Cooler - Fan Node"; + } else { + inletNodeName = baseName + " First Evaporative Cooler - Fan Node"; + } + outletNodeName = coolerOutletNodeName.get(); + } + + if (fan_->iddObject().type() == IddObjectType::Fan_ConstantVolume) { + fan_->setString(Fan_ConstantVolumeFields::AirInletNodeName, inletNodeName); + fan_->setString(Fan_ConstantVolumeFields::AirOutletNodeName, outletNodeName); + } else if (fan_->iddObject().type() == IddObjectType::Fan_VariableVolume) { + fan_->setString(Fan_VariableVolumeFields::AirInletNodeName, inletNodeName); + fan_->setString(Fan_VariableVolumeFields::AirOutletNodeName, outletNodeName); + } else if (fan_->iddObject().type() == IddObjectType::Fan_OnOff) { + fan_->setString(Fan_OnOffFields::AirInletNodeName, inletNodeName); + fan_->setString(Fan_OnOffFields::AirOutletNodeName, outletNodeName); + } else if (fan_->iddObject().type() == IddObjectType::Fan_SystemModel) { + fan_->setString(Fan_SystemModelFields::AirInletNodeName, inletNodeName); + fan_->setString(Fan_SystemModelFields::AirOutletNodeName, outletNodeName); + } else if (fan_->iddObject().type() == IddObjectType::Fan_ComponentModel) { + fan_->setString(Fan_ComponentModelFields::AirInletNodeName, inletNodeName); + fan_->setString(Fan_ComponentModelFields::AirOutletNodeName, outletNodeName); + } + } + + if (firstEvaporativeCooler_) { + std::string outletNodeName; + std::string inletNodeName; + if (istringEqual(fanPlacement, "BlowThrough") && fan_) { + inletNodeName = baseName + " Fan - First Evaporative Cooler Node"; + } else { + inletNodeName = outdoorAirInletNodeName.get(); + } + + if (secondEvaporativeCooler_) { + outletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; + } else if (istringEqual(fanPlacement, "BlowThrough")) { + outletNodeName = coolerOutletNodeName.get(); + } else { + outletNodeName = baseName + " First Evaporative Cooler - Fan Node"; + } + + if (firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { + firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); + firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); + } else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { + firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); + firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); + } else { + LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << firstEvaporativeCooler_->iddObject().type() << "."); } } - // Design Specification ZoneHVAC Sizing Object Name: Optional Object - if (boost::optional designSpecificationZoneHVACSizingObject_ = - modelObject.designSpecificationZoneHVACSizingObject()) { - if (boost::optional wo_ = translateAndMapModelObject(designSpecificationZoneHVACSizingObject_.get())) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName, wo_->nameString()); + if (secondEvaporativeCooler_) { + std::string outletNodeName; + std::string inletNodeName; + if (firstEvaporativeCooler_) { + inletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; + } else if (istringEqual(fanPlacement, "BlowThrough") && fan_) { + inletNodeName = baseName + " Fan - Second Evaporative Cooler Node"; + } else { + inletNodeName = outdoorAirInletNodeName.get(); + } + + if (fan_) { + outletNodeName = baseName + " Second Evaporative Cooler - Fan Node"; + } else { + outletNodeName = outdoorAirInletNodeName.get(); + } + + if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { + secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); + secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); + } else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { + secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); + secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); + } else { + LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << secondEvaporativeCooler_->iddObject().type() << "."); } } diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 84ef665c88..bc2403f886 100644 --- a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -31,23 +31,19 @@ #include "EnergyPlusFixture.hpp" #include "../ForwardTranslator.hpp" -#include "../ReverseTranslator.hpp" #include "../../model/ZoneHVACEvaporativeCoolerUnit.hpp" #include "../../model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp" -// TODO: Check the following class names against object getters and setters. #include "../../model/Schedule.hpp" #include "../../model/Schedule_Impl.hpp" -#include "../../model/SystemAvailabilityManagerLists.hpp" -#include "../../model/SystemAvailabilityManagerLists_Impl.hpp" -#include "../../model/Fans.hpp" -#include "../../model/Fans_Impl.hpp" -#include "../../model/EvapCooler.hpp" -#include "../../model/EvapCooler_Impl.hpp" -#include "../../model/EvapCooler.hpp" -#include "../../model/EvapCooler_Impl.hpp" -#include "../../model/DesignSpecificationZoneHVACSizingName.hpp" -#include "../../model/DesignSpecificationZoneHVACSizingName_Impl.hpp" +#include "../../model/FanComponentModel.hpp" +#include "../../model/FanComponentModel_Impl.hpp" +#include "../../model/EvaporativeCoolerDirectResearchSpecial.hpp" +#include "../../model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp" +#include "../../model/EvaporativeCoolerIndirectResearchSpecial.hpp" +#include "../../model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" +#include "../../model/ThermalZone.hpp" +#include "../../model/Space.hpp" #include "../../utilities/idf/Workspace.hpp" #include "../../utilities/idf/IdfObject.hpp" @@ -56,6 +52,7 @@ #include #include #include + using namespace openstudio::energyplus; using namespace openstudio::model; using namespace openstudio; @@ -65,60 +62,55 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { ForwardTranslator ft; Model m; - // TODO: Check regular Ctor arguments + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); - // TODO: Or if a UniqueModelObject (and make sure _Impl is included) - // ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit = m.getUniqueModelObject(); zoneHVACEvaporativeCoolerUnit.setName("My ZoneHVACEvaporativeCoolerUnit"); - boost::optional availabilitySchedule(m); + Schedule availabilitySchedule = m.alwaysOnDiscreteSchedule(); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilitySchedule(availabilitySchedule)); - boost::optional availabilityManagerList(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilityManagerList(availabilityManagerList)); - Node outdoorAirInletNodeName(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setOutdoorAirInletNodeName(outdoorAirInletNodeName)); - Node coolerOutletNodeName(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerOutletNodeName(coolerOutletNodeName)); - Node zoneReliefAirNodeName(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setZoneReliefAirNodeName(zoneReliefAirNodeName)); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFanObjectType("Fan:SystemModel")); - Fans supplyAirFan(m); + FanComponentModel supplyAirFan(m); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFan(supplyAirFan)); - // Autosize - // zoneHVACEvaporativeCoolerUnit.autosizeDesignSupplyAirFlowRate(); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSupplyAirFlowRate(0.9)); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFanPlacement("BlowThrough")); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerUnitControlMethod("ZoneTemperatureDeadbandOnOffCycling")); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setThrottlingRangeTemperatureDifference(1.2)); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolingLoadControlThresholdHeatTransferRate(1.3)); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCoolerObjectType("EvaporativeCooler:Direct:CelDekPad")); - EvapCooler firstEvaporativeCoolerObject(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCoolerObject(firstEvaporativeCoolerObject)); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCoolerObjectType("EvaporativeCooler:Direct:CelDekPad")); - boost::optional secondEvaporativeCooler(m); + EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(m, availabilitySchedule); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCooler(firstEvaporativeCooler)); + EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); - boost::optional designSpecificationZoneHVACSizingObject(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSpecificationZoneHVACSizingObject(designSpecificationZoneHVACSizingObject)); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(95.0)); - // TODO: you're responsible for creating all other objects needed so this object actually gets ForwardTranslated + // Need to be in a thermal zone to be translated, with at least one space + ThermalZone z(m); + zoneHVACEvaporativeCoolerUnit.addToThermalZone(z); + Space s(m); + s.setThermalZone(z); const Workspace w = ft.translateModel(m); const auto idfObjs = w.getObjectsByType(IddObjectType::ZoneHVAC_EvaporativeCoolerUnit); ASSERT_EQ(1u, idfObjs.size()); - const auto& idfObject = idfObjs.front(); + + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::Name).get()); EXPECT_EQ(availabilitySchedule.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName).get()); - EXPECT_EQ(availabilityManagerList.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName).get()); - EXPECT_EQ(outdoorAirInletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); - EXPECT_EQ(coolerOutletNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); - EXPECT_EQ(zoneReliefAirNodeName.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); - EXPECT_EQ("Fan:SystemModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); + EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName).get()); + EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); + EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); + EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); + EXPECT_EQ("Fan:ComponentModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); EXPECT_EQ(supplyAirFan.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get()); - // EXPECT_EQ("Autosize", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); EXPECT_EQ(0.9, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); EXPECT_EQ("BlowThrough", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement).get()); EXPECT_EQ("ZoneTemperatureDeadbandOnOffCycling", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod).get()); EXPECT_EQ(1.2, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference).get()); EXPECT_EQ(1.3, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate).get()); EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType).get()); EXPECT_EQ(firstEvaporativeCoolerObject.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName).get()); - EXPECT_EQ("EvaporativeCooler:Direct:CelDekPad", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType).get()); + EXPECT_EQ(0.9, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); + EXPECT_EQ("BlowThrough", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement).get()); + EXPECT_EQ("ZoneTemperatureDeadbandOnOffCycling", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerUnitControlMethod).get()); + EXPECT_EQ(1.2, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ThrottlingRangeTemperatureDifference).get()); + EXPECT_EQ(1.3, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::CoolingLoadControlThresholdHeatTransferRate).get()); + EXPECT_EQ("EvaporativeCooler:Direct:ResearchSpecial", + idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType).get()); + EXPECT_EQ(firstEvaporativeCooler.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName).get()); + EXPECT_EQ("EvaporativeCooler:Indirect:ResearchSpecial", + idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType).get()); EXPECT_EQ(secondEvaporativeCooler.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get()); - EXPECT_EQ(designSpecificationZoneHVACSizingObject.nameString(), - idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName).get()); + EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName).get()); EXPECT_EQ(95.0, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity).get()); } diff --git a/src/model/ConcreteModelObjects.hpp b/src/model/ConcreteModelObjects.hpp index 9d36231578..3ea8d92cf8 100644 --- a/src/model/ConcreteModelObjects.hpp +++ b/src/model/ConcreteModelObjects.hpp @@ -542,6 +542,7 @@ #include "ZoneHVACEnergyRecoveryVentilator.hpp" #include "ZoneHVACEnergyRecoveryVentilatorController.hpp" #include "ZoneHVACEquipmentList.hpp" +#include "ZoneHVACEvaporativeCoolerUnit.hpp" #include "ZoneHVACFourPipeFanCoil.hpp" #include "ZoneHVACHighTemperatureRadiant.hpp" #include "ZoneHVACIdealLoadsAirSystem.hpp" @@ -1096,6 +1097,7 @@ #include "ZoneHVACEnergyRecoveryVentilator_Impl.hpp" #include "ZoneHVACEnergyRecoveryVentilatorController_Impl.hpp" #include "ZoneHVACEquipmentList_Impl.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "ZoneHVACFourPipeFanCoil_Impl.hpp" #include "ZoneHVACHighTemperatureRadiant_Impl.hpp" #include "ZoneHVACIdealLoadsAirSystem_Impl.hpp" diff --git a/src/model/Model.cpp b/src/model/Model.cpp index bfe9fd1cb2..38a56fb71d 100644 --- a/src/model/Model.cpp +++ b/src/model/Model.cpp @@ -2254,9 +2254,9 @@ namespace model { if (!openstudio::equal(inputResult, outputResult, tol)) { LOG_FREE(logLevel, "openstudio.model.Model", "The " << attributeName << " values determined for " << object.briefDescription() - << " using input and output data differ by a (relative) error " << "greater than " << tol - << ". The value calculated from input data was " << inputResult << ", whereas the value calculated from output data was " - << outputResult << "."); + << " using input and output data differ by a (relative) error " + << "greater than " << tol << ". The value calculated from input data was " << inputResult + << ", whereas the value calculated from output data was " << outputResult << "."); return false; } return true; diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index 554cf0903f..97b920a1e9 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -30,21 +30,18 @@ #include "ZoneHVACEvaporativeCoolerUnit.hpp" #include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" -// TODO: Check the following class names against object getters and setters. +#include "Model.hpp" +#include "Model_Impl.hpp" #include "Schedule.hpp" #include "Schedule_Impl.hpp" -#include "SystemAvailabilityManagerLists.hpp" -#include "SystemAvailabilityManagerLists_Impl.hpp" -#include "Connection.hpp" -#include "Connection_Impl.hpp" -#include "Fans.hpp" -#include "Fans_Impl.hpp" -#include "EvapCooler.hpp" -#include "EvapCooler_Impl.hpp" -#include "DesignSpecificationZoneHVACSizingName.hpp" -#include "DesignSpecificationZoneHVACSizingName_Impl.hpp" +#include "HVACComponent.hpp" +#include "HVACComponent_Impl.hpp" #include "ScheduleTypeLimits.hpp" #include "ScheduleTypeRegistry.hpp" +#include "FanComponentModel.hpp" +#include "FanComponentModel_Impl.hpp" +#include "EvaporativeCoolerDirectResearchSpecial.hpp" +#include "EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "../utilities/core/Assert.hpp" #include "../utilities/data/DataEnums.hpp" @@ -85,7 +82,6 @@ namespace model { } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::getScheduleTypeKeys(const Schedule& schedule) const { - // TODO: Check schedule display names. std::vector result; const UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); if (std::find(fieldIndices.cbegin(), fieldIndices.cend(), OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName) @@ -95,24 +91,27 @@ namespace model { return result; } + unsigned ZoneHVACEvaporativeCoolerUnit_Impl::inletPort() const { + return OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName; + } + + unsigned ZoneHVACEvaporativeCoolerUnit_Impl::outletPort() const { + return OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName; + } + ComponentType ZoneHVACEvaporativeCoolerUnit_Impl::componentType() const { - // TODO return ComponentType::None; } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::coolingFuelTypes() const { - // TODO return {}; } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::heatingFuelTypes() const { - // TODO return {}; } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::appGHeatingFuelTypes() const { - - // TODO return {}; } @@ -124,33 +123,8 @@ namespace model { return value.get(); } - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::availabilityManagerList() const { - return getObject().getModelObjectTarget( - OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName); - } - - Connection ZoneHVACEvaporativeCoolerUnit_Impl::outdoorAirInletNode() const { - boost::optional value = optionalOutdoorAirInletNode(); - if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Outdoor Air Inlet Node attached."); - } - return value.get(); - } - - Connection ZoneHVACEvaporativeCoolerUnit_Impl::coolerOutletNode() const { - boost::optional value = optionalCoolerOutletNode(); - if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Cooler Outlet Node attached."); - } - return value.get(); - } - - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::zoneReliefAirNode() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName); - } - - Fans ZoneHVACEvaporativeCoolerUnit_Impl::supplyAirFan() const { - boost::optional value = optionalSupplyAirFan(); + HVACComponent ZoneHVACEvaporativeCoolerUnit_Impl::supplyAirFan() const { + boost::optional value = optionalSupplyAirFan(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an Supply Air Fan attached."); } @@ -198,21 +172,16 @@ namespace model { return value.get(); } - EvapCooler ZoneHVACEvaporativeCoolerUnit_Impl::firstEvaporativeCooler() const { - boost::optional value = optionalFirstEvaporativeCooler(); + HVACComponent ZoneHVACEvaporativeCoolerUnit_Impl::firstEvaporativeCooler() const { + boost::optional value = optionalFirstEvaporativeCooler(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an First Evaporative Cooler attached."); } return value.get(); } - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::secondEvaporativeCooler() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName); - } - - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::designSpecificationZoneHVACSizing() const { - return getObject().getModelObjectTarget( - OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing); + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::secondEvaporativeCooler() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCooler); } double ZoneHVACEvaporativeCoolerUnit_Impl::shutOffRelativeHumidity() const { @@ -227,38 +196,8 @@ namespace model { return result; } - bool ZoneHVACEvaporativeCoolerUnit_Impl::setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, systemAvailabilityManagerLists.handle()); - return result; - } - - void ZoneHVACEvaporativeCoolerUnit_Impl::resetAvailabilityManagerList() { - const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName, ""); - OS_ASSERT(result); - } - - bool ZoneHVACEvaporativeCoolerUnit_Impl::setOutdoorAirInletNode(const Connection& connection) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, connection.handle()); - return result; - } - - bool ZoneHVACEvaporativeCoolerUnit_Impl::setCoolerOutletNode(const Connection& connection) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, connection.handle()); - return result; - } - - bool ZoneHVACEvaporativeCoolerUnit_Impl::setZoneReliefAirNode(const Connection& connection) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, connection.handle()); - return result; - } - - void ZoneHVACEvaporativeCoolerUnit_Impl::resetZoneReliefAirNode() { - const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, ""); - OS_ASSERT(result); - } - - bool ZoneHVACEvaporativeCoolerUnit_Impl::setSupplyAirFan(const Fans& fans) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fans.handle()); + bool ZoneHVACEvaporativeCoolerUnit_Impl::setSupplyAirFan(const HVACComponent& hvacComponent) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, hvacComponent.handle()); return result; } @@ -294,30 +233,18 @@ namespace model { return result; } - bool ZoneHVACEvaporativeCoolerUnit_Impl::setFirstEvaporativeCooler(const EvapCooler& evapCooler) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCooler, evapCooler.handle()); + bool ZoneHVACEvaporativeCoolerUnit_Impl::setFirstEvaporativeCooler(const HVACComponent& hvacComponent) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCooler, hvacComponent.handle()); return result; } - bool ZoneHVACEvaporativeCoolerUnit_Impl::setSecondEvaporativeCooler(const EvapCooler& evapCooler) { - const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, evapCooler.handle()); + bool ZoneHVACEvaporativeCoolerUnit_Impl::setSecondEvaporativeCooler(const HVACComponent& hvacComponent) { + const bool result = setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCooler, hvacComponent.handle()); return result; } void ZoneHVACEvaporativeCoolerUnit_Impl::resetSecondEvaporativeCooler() { - const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, ""); - OS_ASSERT(result); - } - - bool ZoneHVACEvaporativeCoolerUnit_Impl::setDesignSpecificationZoneHVACSizing( - const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { - const bool result = - setPointer(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing, designSpecificationZoneHVACSizingName.handle()); - return result; - } - - void ZoneHVACEvaporativeCoolerUnit_Impl::resetDesignSpecificationZoneHVACSizing() { - const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizing, ""); + const bool result = setString(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCooler, ""); OS_ASSERT(result); } @@ -332,7 +259,7 @@ namespace model { void ZoneHVACEvaporativeCoolerUnit_Impl::applySizingValues() { if (boost::optional val_ = autosizedDesignSupplyAirFlowRate()) { - setDesignSupplyAirFlowRate(*val_)); + setDesignSupplyAirFlowRate(*val_); } } @@ -340,20 +267,12 @@ namespace model { return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName); } - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalOutdoorAirInletNode() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName); + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalSupplyAirFan() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName); } - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalCoolerOutletNode() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName); - } - - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalSupplyAirFan() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName); - } - - boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalFirstEvaporativeCooler() const { - return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCooler); + boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::optionalFirstEvaporativeCooler() const { + return getObject().getModelObjectTarget(OS_ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCooler); } } // namespace detail @@ -366,12 +285,11 @@ namespace model { auto alwaysOn = model.alwaysOnDiscreteSchedule(); ok = setAvailabilitySchedule(alwaysOn); OS_ASSERT(ok); - // ok = setOutdoorAirInletNode(); - OS_ASSERT(ok); - // ok = setCoolerOutletNode(); - OS_ASSERT(ok); - // ok = setSupplyAirFan(); + + FanComponentModel supplyAirFan(model); // StripMallZoneEvapCooler.idf + ok = setSupplyAirFan(supplyAirFan); OS_ASSERT(ok); + autosizeDesignSupplyAirFlowRate(); ok = setFanPlacement("BlowThrough"); OS_ASSERT(ok); @@ -381,8 +299,11 @@ namespace model { OS_ASSERT(ok); ok = setCoolingLoadControlThresholdHeatTransferRate(100.0); OS_ASSERT(ok); - // ok = setFirstEvaporativeCooler(); + + EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(model, alwaysOn); + ok = setFirstEvaporativeCooler(firstEvaporativeCooler); // StripMallZoneEvapCooler.idf OS_ASSERT(ok); + ok = setShutOffRelativeHumidity(100.0); OS_ASSERT(ok); } @@ -395,10 +316,6 @@ namespace model { bool ok = true; ok = setAvailabilitySchedule(availabilitySchedule); OS_ASSERT(ok); - // ok = setOutdoorAirInletNode(); - OS_ASSERT(ok); - // ok = setCoolerOutletNode(); - OS_ASSERT(ok); ok = setSupplyAirFan(supplyAirFan); OS_ASSERT(ok); autosizeDesignSupplyAirFlowRate(); @@ -432,23 +349,7 @@ namespace model { return getImpl()->availabilitySchedule(); } - boost::optional ZoneHVACEvaporativeCoolerUnit::availabilityManagerList() const { - return getImpl()->availabilityManagerList(); - } - - Connection ZoneHVACEvaporativeCoolerUnit::outdoorAirInletNode() const { - return getImpl()->outdoorAirInletNode(); - } - - Connection ZoneHVACEvaporativeCoolerUnit::coolerOutletNode() const { - return getImpl()->coolerOutletNode(); - } - - boost::optional ZoneHVACEvaporativeCoolerUnit::zoneReliefAirNode() const { - return getImpl()->zoneReliefAirNode(); - } - - Fans ZoneHVACEvaporativeCoolerUnit::supplyAirFan() const { + HVACComponent ZoneHVACEvaporativeCoolerUnit::supplyAirFan() const { return getImpl()->supplyAirFan(); } @@ -480,18 +381,14 @@ namespace model { return getImpl()->coolingLoadControlThresholdHeatTransferRate(); } - EvapCooler ZoneHVACEvaporativeCoolerUnit::firstEvaporativeCooler() const { + HVACComponent ZoneHVACEvaporativeCoolerUnit::firstEvaporativeCooler() const { return getImpl()->firstEvaporativeCooler(); } - boost::optional ZoneHVACEvaporativeCoolerUnit::secondEvaporativeCooler() const { + boost::optional ZoneHVACEvaporativeCoolerUnit::secondEvaporativeCooler() const { return getImpl()->secondEvaporativeCooler(); } - boost::optional ZoneHVACEvaporativeCoolerUnit::designSpecificationZoneHVACSizing() const { - return getImpl()->designSpecificationZoneHVACSizing(); - } - double ZoneHVACEvaporativeCoolerUnit::shutOffRelativeHumidity() const { return getImpl()->shutOffRelativeHumidity(); } @@ -500,32 +397,8 @@ namespace model { return getImpl()->setAvailabilitySchedule(schedule); } - bool ZoneHVACEvaporativeCoolerUnit::setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists) { - return getImpl()->setAvailabilityManagerList(systemAvailabilityManagerLists); - } - - void ZoneHVACEvaporativeCoolerUnit::resetAvailabilityManagerList() { - getImpl()->resetAvailabilityManagerList(); - } - - bool ZoneHVACEvaporativeCoolerUnit::setOutdoorAirInletNode(const Connection& connection) { - return getImpl()->setOutdoorAirInletNode(connection); - } - - bool ZoneHVACEvaporativeCoolerUnit::setCoolerOutletNode(const Connection& connection) { - return getImpl()->setCoolerOutletNode(connection); - } - - bool ZoneHVACEvaporativeCoolerUnit::setZoneReliefAirNode(const Connection& connection) { - return getImpl()->setZoneReliefAirNode(connection); - } - - void ZoneHVACEvaporativeCoolerUnit::resetZoneReliefAirNode() { - getImpl()->resetZoneReliefAirNode(); - } - - bool ZoneHVACEvaporativeCoolerUnit::setSupplyAirFan(const Fans& fans) { - return getImpl()->setSupplyAirFan(fans); + bool ZoneHVACEvaporativeCoolerUnit::setSupplyAirFan(const HVACComponent& hvacComponent) { + return getImpl()->setSupplyAirFan(hvacComponent); } bool ZoneHVACEvaporativeCoolerUnit::setDesignSupplyAirFlowRate(double designSupplyAirFlowRate) { @@ -553,27 +426,18 @@ namespace model { coolingLoadControlThresholdHeatTransferRate); } - bool ZoneHVACEvaporativeCoolerUnit::setFirstEvaporativeCooler(const EvapCooler& evapCooler) { - return getImpl()->setFirstEvaporativeCooler(evapCooler); + bool ZoneHVACEvaporativeCoolerUnit::setFirstEvaporativeCooler(const HVACComponent& hvacComponent) { + return getImpl()->setFirstEvaporativeCooler(hvacComponent); } - bool ZoneHVACEvaporativeCoolerUnit::setSecondEvaporativeCooler(const EvapCooler& evapCooler) { - return getImpl()->setSecondEvaporativeCooler(evapCooler); + bool ZoneHVACEvaporativeCoolerUnit::setSecondEvaporativeCooler(const HVACComponent& hvacComponent) { + return getImpl()->setSecondEvaporativeCooler(hvacComponent); } void ZoneHVACEvaporativeCoolerUnit::resetSecondEvaporativeCooler() { getImpl()->resetSecondEvaporativeCooler(); } - bool ZoneHVACEvaporativeCoolerUnit::setDesignSpecificationZoneHVACSizing( - const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName) { - return getImpl()->setDesignSpecificationZoneHVACSizing(designSpecificationZoneHVACSizingName); - } - - void ZoneHVACEvaporativeCoolerUnit::resetDesignSpecificationZoneHVACSizing() { - getImpl()->resetDesignSpecificationZoneHVACSizing(); - } - bool ZoneHVACEvaporativeCoolerUnit::setShutOffRelativeHumidity(double shutOffRelativeHumidity) { return getImpl()->setShutOffRelativeHumidity(shutOffRelativeHumidity); } diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp index e7fefe42a9..2d428b998a 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp @@ -37,13 +37,8 @@ namespace openstudio { namespace model { - // TODO: Check the following class names against object getters and setters. class Schedule; - class SystemAvailabilityManagerLists; - class Connection; - class Fans; - class EvapCooler; - class DesignSpecificationZoneHVACSizingName; + class HVACComponent; namespace detail { @@ -81,23 +76,9 @@ namespace model { /** @name Getters */ //@{ - // TODO: Check return type. From object lists, some candidates are: Schedule. Schedule availabilitySchedule() const; - // TODO: Check return type. From object lists, some candidates are: SystemAvailabilityManagerLists. - boost::optional availabilityManagerList() const; - - // TODO: Check return type. From object lists, some candidates are: Connection. - Connection outdoorAirInletNode() const; - - // TODO: Check return type. From object lists, some candidates are: Connection. - Connection coolerOutletNode() const; - - // TODO: Check return type. From object lists, some candidates are: Connection. - boost::optional zoneReliefAirNode() const; - - // TODO: Check return type. From object lists, some candidates are: Fans. - Fans supplyAirFan() const; + HVACComponent supplyAirFan() const; boost::optional designSupplyAirFlowRate() const; @@ -113,14 +94,9 @@ namespace model { double coolingLoadControlThresholdHeatTransferRate() const; - // TODO: Check return type. From object lists, some candidates are: EvapCooler. - EvapCooler firstEvaporativeCooler() const; + HVACComponent firstEvaporativeCooler() const; - // TODO: Check return type. From object lists, some candidates are: EvapCooler. - boost::optional secondEvaporativeCooler() const; - - // TODO: Check return type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. - boost::optional designSpecificationZoneHVACSizing() const; + boost::optional secondEvaporativeCooler() const; double shutOffRelativeHumidity() const; @@ -128,28 +104,9 @@ namespace model { /** @name Setters */ //@{ - // TODO: Check argument type. From object lists, some candidates are: Schedule. - // Note Schedules are passed by reference, not const reference. bool setAvailabilitySchedule(Schedule& schedule); - // TODO: Check argument type. From object lists, some candidates are: SystemAvailabilityManagerLists. - bool setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists); - - void resetAvailabilityManagerList(); - - // TODO: Check argument type. From object lists, some candidates are: Connection. - bool setOutdoorAirInletNode(const Connection& connection); - - // TODO: Check argument type. From object lists, some candidates are: Connection. - bool setCoolerOutletNode(const Connection& connection); - - // TODO: Check argument type. From object lists, some candidates are: Connection. - bool setZoneReliefAirNode(const Connection& connection); - - void resetZoneReliefAirNode(); - - // TODO: Check argument type. From object lists, some candidates are: Fans. - bool setSupplyAirFan(const Fans& fans); + bool setSupplyAirFan(const HVACComponent& hvacComponent); bool setDesignSupplyAirFlowRate(double designSupplyAirFlowRate); @@ -163,19 +120,12 @@ namespace model { bool setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate); - // TODO: Check argument type. From object lists, some candidates are: EvapCooler. - bool setFirstEvaporativeCooler(const EvapCooler& evapCooler); + bool setFirstEvaporativeCooler(const HVACComponent& hvacComponent); - // TODO: Check argument type. From object lists, some candidates are: EvapCooler. - bool setSecondEvaporativeCooler(const EvapCooler& evapCooler); + bool setSecondEvaporativeCooler(const HVACComponent& hvacComponent); void resetSecondEvaporativeCooler(); - // TODO: Check argument type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. - bool setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName); - - void resetDesignSpecificationZoneHVACSizing(); - bool setShutOffRelativeHumidity(double shutOffRelativeHumidity); //@} diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp index 003ffcc419..eb891a3fe1 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp @@ -36,13 +36,8 @@ namespace openstudio { namespace model { - // TODO: Check the following class names against object getters and setters. class Schedule; - class SystemAvailabilityManagerLists; - class Connection; - class Fans; - class EvapCooler; - class DesignSpecificationZoneHVACSizingName; + class HVACComponent; namespace detail { @@ -71,6 +66,10 @@ namespace model { virtual std::vector getScheduleTypeKeys(const Schedule& schedule) const override; + virtual unsigned inletPort() const override; + + virtual unsigned outletPort() const override; + virtual ComponentType componentType() const override; virtual std::vector coolingFuelTypes() const override; virtual std::vector heatingFuelTypes() const override; @@ -80,23 +79,9 @@ namespace model { /** @name Getters */ //@{ - // TODO: Check return type. From object lists, some candidates are: Schedule. Schedule availabilitySchedule() const; - // TODO: Check return type. From object lists, some candidates are: SystemAvailabilityManagerLists. - boost::optional availabilityManagerList() const; - - // TODO: Check return type. From object lists, some candidates are: Connection. - Connection outdoorAirInletNode() const; - - // TODO: Check return type. From object lists, some candidates are: Connection. - Connection coolerOutletNode() const; - - // TODO: Check return type. From object lists, some candidates are: Connection. - boost::optional zoneReliefAirNode() const; - - // TODO: Check return type. From object lists, some candidates are: Fans. - Fans supplyAirFan() const; + HVACComponent supplyAirFan() const; boost::optional designSupplyAirFlowRate() const; @@ -112,14 +97,9 @@ namespace model { double coolingLoadControlThresholdHeatTransferRate() const; - // TODO: Check return type. From object lists, some candidates are: EvapCooler. - EvapCooler firstEvaporativeCooler() const; + HVACComponent firstEvaporativeCooler() const; - // TODO: Check return type. From object lists, some candidates are: EvapCooler. - boost::optional secondEvaporativeCooler() const; - - // TODO: Check return type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. - boost::optional designSpecificationZoneHVACSizing() const; + boost::optional secondEvaporativeCooler() const; double shutOffRelativeHumidity() const; @@ -127,28 +107,9 @@ namespace model { /** @name Setters */ //@{ - // TODO: Check argument type. From object lists, some candidates are: Schedule. - // Note Schedules are passed by reference, not const reference. bool setAvailabilitySchedule(Schedule& schedule); - // TODO: Check argument type. From object lists, some candidates are: SystemAvailabilityManagerLists. - bool setAvailabilityManagerList(const SystemAvailabilityManagerLists& systemAvailabilityManagerLists); - - void resetAvailabilityManagerList(); - - // TODO: Check argument type. From object lists, some candidates are: Connection. - bool setOutdoorAirInletNode(const Connection& connection); - - // TODO: Check argument type. From object lists, some candidates are: Connection. - bool setCoolerOutletNode(const Connection& connection); - - // TODO: Check argument type. From object lists, some candidates are: Connection. - bool setZoneReliefAirNode(const Connection& connection); - - void resetZoneReliefAirNode(); - - // TODO: Check argument type. From object lists, some candidates are: Fans. - bool setSupplyAirFan(const Fans& fans); + bool setSupplyAirFan(const HVACComponent& hvacComponent); bool setDesignSupplyAirFlowRate(double designSupplyAirFlowRate); @@ -162,19 +123,12 @@ namespace model { bool setCoolingLoadControlThresholdHeatTransferRate(double coolingLoadControlThresholdHeatTransferRate); - // TODO: Check argument type. From object lists, some candidates are: EvapCooler. - bool setFirstEvaporativeCooler(const EvapCooler& evapCooler); + bool setFirstEvaporativeCooler(const HVACComponent& hvacComponent); - // TODO: Check argument type. From object lists, some candidates are: EvapCooler. - bool setSecondEvaporativeCooler(const EvapCooler& evapCooler); + bool setSecondEvaporativeCooler(const HVACComponent& hvacComponent); void resetSecondEvaporativeCooler(); - // TODO: Check argument type. From object lists, some candidates are: DesignSpecificationZoneHVACSizingName. - bool setDesignSpecificationZoneHVACSizing(const DesignSpecificationZoneHVACSizingName& designSpecificationZoneHVACSizingName); - - void resetDesignSpecificationZoneHVACSizing(); - bool setShutOffRelativeHumidity(double shutOffRelativeHumidity); virtual void autosize() override; @@ -190,15 +144,9 @@ namespace model { private: REGISTER_LOGGER("openstudio.model.ZoneHVACEvaporativeCoolerUnit"); - // TODO: Check the return types of these methods. - // Optional getters for use by methods like children() so can remove() if the constructor fails. - // There are other ways for the public versions of these getters to fail--perhaps all required - // objects should be returned as boost::optionals boost::optional optionalAvailabilitySchedule() const; - boost::optional optionalOutdoorAirInletNode() const; - boost::optional optionalCoolerOutletNode() const; - boost::optional optionalSupplyAirFan() const; - boost::optional optionalFirstEvaporativeCooler() const; + boost::optional optionalSupplyAirFan() const; + boost::optional optionalFirstEvaporativeCooler() const; }; } // namespace detail diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index ff0d3f6ae8..65c8b75f0a 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -31,67 +31,32 @@ #include "../ZoneHVACEvaporativeCoolerUnit.hpp" #include "../ZoneHVACEvaporativeCoolerUnit_Impl.hpp" - -// TODO: Check the following class names against object getters and setters. #include "../Schedule.hpp" #include "../Schedule_Impl.hpp" - -#include "../SystemAvailabilityManagerLists.hpp" -#include "../SystemAvailabilityManagerLists_Impl.hpp" - -#include "../Connection.hpp" -#include "../Connection_Impl.hpp" - -#include "../Fans.hpp" -#include "../Fans_Impl.hpp" - -#include "../EvapCooler.hpp" -#include "../EvapCooler_Impl.hpp" - -#include "../DesignSpecificationZoneHVACSizingName.hpp" -#include "../DesignSpecificationZoneHVACSizingName_Impl.hpp" +#include "../FanComponentModel.hpp" +#include "../FanComponentModel_Impl.hpp" +#include "../EvaporativeCoolerDirectResearchSpecial.hpp" +#include "../EvaporativeCoolerDirectResearchSpecial_Impl.hpp" +#include "../EvaporativeCoolerIndirectResearchSpecial.hpp" +#include "../EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" using namespace openstudio; using namespace openstudio::model; TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_GettersSetters) { Model m; - // TODO: Check regular Ctor arguments + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); - // TODO: Or if a UniqueModelObject (and make sure _Impl is included) - // ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit = m.getUniqueModelObject(); zoneHVACEvaporativeCoolerUnit.setName("My ZoneHVACEvaporativeCoolerUnit"); // Availability Schedule Name: Required Object - Schedule availabilitySchedule(m); + Schedule availabilitySchedule = m.alwaysOnDiscreteSchedule(); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilitySchedule(availabilitySchedule)); EXPECT_EQ(availabilitySchedule, zoneHVACEvaporativeCoolerUnit.availabilitySchedule()); - // Availability Manager List Name: Optional Object - boost::optional availabilityManagerList(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setAvailabilityManagerList(availabilityManagerList)); - ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.availabilityManagerList()); - EXPECT_EQ(availabilityManagerList, zoneHVACEvaporativeCoolerUnit.availabilityManagerList().get()); - - // Outdoor Air Inlet Node Name: Required Object - Connection outdoorAirInletNode(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setOutdoorAirInletNode(outdoorAirInletNode)); - EXPECT_EQ(outdoorAirInletNode, zoneHVACEvaporativeCoolerUnit.outdoorAirInletNode()); - - // Cooler Outlet Node Name: Required Object - Connection coolerOutletNode(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setCoolerOutletNode(coolerOutletNode)); - EXPECT_EQ(coolerOutletNode, zoneHVACEvaporativeCoolerUnit.coolerOutletNode()); - - // Zone Relief Air Node Name: Optional Object - boost::optional zoneReliefAirNode(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setZoneReliefAirNode(zoneReliefAirNode)); - ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.zoneReliefAirNode()); - EXPECT_EQ(zoneReliefAirNode, zoneHVACEvaporativeCoolerUnit.zoneReliefAirNode().get()); - // Supply Air Fan Name: Required Object - Fans supplyAirFan(m); + FanComponentModel supplyAirFan(m); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFan(supplyAirFan)); EXPECT_EQ(supplyAirFan, zoneHVACEvaporativeCoolerUnit.supplyAirFan()); @@ -138,22 +103,17 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_GettersSetters) { EXPECT_EQ(1.3, zoneHVACEvaporativeCoolerUnit.coolingLoadControlThresholdHeatTransferRate()); // First Evaporative Cooler: Required Object - EvapCooler firstEvaporativeCooler(m); + EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(m, availabilitySchedule); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setFirstEvaporativeCooler(firstEvaporativeCooler)); EXPECT_EQ(firstEvaporativeCooler, zoneHVACEvaporativeCoolerUnit.firstEvaporativeCooler()); // Second Evaporative Cooler Name: Optional Object - boost::optional secondEvaporativeCooler(m); + EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.secondEvaporativeCooler()); + EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.secondEvaporativeCooler()); EXPECT_EQ(secondEvaporativeCooler, zoneHVACEvaporativeCoolerUnit.secondEvaporativeCooler().get()); - // Design Specification ZoneHVAC Sizing: Optional Object - boost::optional designSpecificationZoneHVACSizing(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setDesignSpecificationZoneHVACSizing(designSpecificationZoneHVACSizing)); - ASSERT_TRUE(zoneHVACEvaporativeCoolerUnit.designSpecificationZoneHVACSizing()); - EXPECT_EQ(designSpecificationZoneHVACSizing, zoneHVACEvaporativeCoolerUnit.designSpecificationZoneHVACSizing().get()); - // Shut Off Relative Humidity: Required Double EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(94.444)); EXPECT_EQ(94.444, zoneHVACEvaporativeCoolerUnit.shutOffRelativeHumidity()); @@ -161,12 +121,11 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_GettersSetters) { EXPECT_FALSE(zoneHVACEvaporativeCoolerUnit.setShutOffRelativeHumidity(-10.0)); EXPECT_EQ(94.444, zoneHVACEvaporativeCoolerUnit.shutOffRelativeHumidity()); } + TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_HeatCoolFuelTypes) { Model m; - // TODO: Check regular Ctor arguments + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); - // TODO: Or if a UniqueModelObject (and make sure _Impl is included) - // ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit = m.getUniqueModelObject(); EXPECT_EQ(ComponentType(ComponentType::Both), zoneHVACEvaporativeCoolerUnit.componentType()); testFuelTypeEquality({FuelType::Electricity}, zoneHVACEvaporativeCoolerUnit.coolingFuelTypes()); From 7fb2a46bee00444ca954e9138d16aa2a1ffc94c1 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 23 Dec 2024 16:08:29 -0700 Subject: [PATCH 06/24] Fix and improve model and ft tests. --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 6 +- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 165 +++++++++++++++++- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 91 +++++++++- .../ZoneHVACEvaporativeCoolerUnit_Impl.hpp | 6 + .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 6 +- src/osversion/VersionTranslator.cpp | 22 ++- 6 files changed, 270 insertions(+), 26 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index 970f107edb..edbdb1d04e 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -218,16 +218,16 @@ namespace energyplus { inletNodeName = outdoorAirInletNodeName.get(); } - if (fan_) { + if (istringEqual(fanPlacement, "DrawThrough") && fan_) { outletNodeName = baseName + " Second Evaporative Cooler - Fan Node"; } else { - outletNodeName = outdoorAirInletNodeName.get(); + outletNodeName = coolerOutletNodeName.get(); } if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); - } else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { + } else if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); } else { diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index bc2403f886..ed331a958f 100644 --- a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -52,6 +52,9 @@ #include #include #include +#include +#include +#include using namespace openstudio::energyplus; using namespace openstudio::model; @@ -94,10 +97,12 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::Name).get()); EXPECT_EQ(availabilitySchedule.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName).get()); - EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName).get()); - EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); - EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); - EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); + EXPECT_TRUE(idfObject.isEmpty(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName)); + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airInletModelObject()->nameString(), + idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airOutletModelObject()->nameString(), + idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); + EXPECT_TRUE(idfObject.isEmpty(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName)); EXPECT_EQ("Fan:ComponentModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); EXPECT_EQ(supplyAirFan.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get()); EXPECT_EQ(0.9, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); @@ -111,6 +116,156 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { EXPECT_EQ("EvaporativeCooler:Indirect:ResearchSpecial", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType).get()); EXPECT_EQ(secondEvaporativeCooler.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get()); - EXPECT_EQ("", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName).get()); + EXPECT_TRUE(idfObject.isEmpty(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSpecificationZoneHVACSizingObjectName)); EXPECT_EQ(95.0, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity).get()); + + auto idf_supplyAirFan = idfObject.getTarget(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get(); + EXPECT_EQ(idf_supplyAirFan.iddObject().type(), IddObjectType::Fan_ComponentModel); + + auto idf_firstEvaporativeCooler = idfObject.getTarget(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName).get(); + EXPECT_EQ(idf_firstEvaporativeCooler.iddObject().type(), IddObjectType::EvaporativeCooler_Direct_ResearchSpecial); + + auto idf_secondEvaporativeCooler = idfObject.getTarget(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get(); + EXPECT_EQ(idf_secondEvaporativeCooler.iddObject().type(), IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial); + + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airInletModelObject()->nameString(), + idf_supplyAirFan.getString(Fan_ComponentModelFields::AirInletNodeName).get()); + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString() + " Fan - First Evaporative Cooler Node", + idf_supplyAirFan.getString(Fan_ComponentModelFields::AirOutletNodeName).get()); + + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString() + " Fan - First Evaporative Cooler Node", + idf_firstEvaporativeCooler.getString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName).get()); + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString() + " First Evaporative Cooler - Second Evaporative Cooler Node", + idf_firstEvaporativeCooler.getString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName).get()); + + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString() + " First Evaporative Cooler - Second Evaporative Cooler Node", + idf_secondEvaporativeCooler.getString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName).get()); + EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airOutletModelObject()->nameString(), + idf_secondEvaporativeCooler.getString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName).get()); +} + +std::vector getEvaporativeCoolerUnitNodes(const Workspace& workspace) { + WorkspaceObjectVector idfEvaporativeCoolerUnits(workspace.getObjectsByType(IddObjectType::ZoneHVAC_EvaporativeCoolerUnit)); + if (idfEvaporativeCoolerUnits.empty()) { + return {}; + } + + auto& idfEvaporativeCoolerUnit = idfEvaporativeCoolerUnits[0]; + + return { + idfEvaporativeCoolerUnit.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get(), + idfEvaporativeCoolerUnit.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get(), + }; +} + +std::vector getSupplyAirFanNodes(const Workspace& workspace) { + WorkspaceObjectVector idfFans(workspace.getObjectsByType(IddObjectType::Fan_ComponentModel)); + if (idfFans.empty()) { + return {}; + } + + auto& idfFan = idfFans[0]; + + return { + idfFan.getString(Fan_ComponentModelFields::AirInletNodeName).get(), + idfFan.getString(Fan_ComponentModelFields::AirOutletNodeName).get(), + }; +} + +std::vector getFirstEvaporativeCoolerNodes(const Workspace& workspace) { + WorkspaceObjectVector idfFirstEvaporativeCoolers(workspace.getObjectsByType(IddObjectType::EvaporativeCooler_Direct_ResearchSpecial)); + if (idfFirstEvaporativeCoolers.empty()) { + return {}; + } + + auto& idfFirstEvaporativeCooler = idfFirstEvaporativeCoolers[0]; + + return { + idfFirstEvaporativeCooler.getString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName).get(), + idfFirstEvaporativeCooler.getString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName).get(), + }; +} + +std::vector getSecondEvaporativeCoolerNodes(const Workspace& workspace) { + WorkspaceObjectVector idfSecondEvaporativeCoolers(workspace.getObjectsByType(IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial)); + if (idfSecondEvaporativeCoolers.empty()) { + return {}; + } + + auto& idfSecondEvaporativeCooler = idfSecondEvaporativeCoolers[0]; + + return { + idfSecondEvaporativeCooler.getString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName).get(), + idfSecondEvaporativeCooler.getString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName).get(), + }; +} + +TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit_Nodes) { + for (std::string fanPlacement : {"BlowThrough", "DrawThrough"}) { + + // first evaporative cooler + { + Model m; + + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); + zoneHVACEvaporativeCoolerUnit.setFanPlacement(fanPlacement); + + ThermalZone z(m); + zoneHVACEvaporativeCoolerUnit.addToThermalZone(z); + Space s(m); + s.setThermalZone(z); + + ForwardTranslator ft; + Workspace workspace = ft.translateModel(m); + + std::vector evaporativeCoolerUnitNodes = getEvaporativeCoolerUnitNodes(workspace); + std::vector fanNodes = getSupplyAirFanNodes(workspace); + std::vector firstEvaporativeCoolerNodes = getFirstEvaporativeCoolerNodes(workspace); + + if (fanPlacement == "BlowThrough") { + EXPECT_EQ(evaporativeCoolerUnitNodes[0], fanNodes[0]); + EXPECT_EQ(fanNodes[1], firstEvaporativeCoolerNodes[0]); + EXPECT_EQ(firstEvaporativeCoolerNodes[1], evaporativeCoolerUnitNodes[1]); + } else if (fanPlacement == "DrawThrough") { + EXPECT_EQ(evaporativeCoolerUnitNodes[0], firstEvaporativeCoolerNodes[0]); + EXPECT_EQ(firstEvaporativeCoolerNodes[1], fanNodes[0]); + EXPECT_EQ(fanNodes[1], evaporativeCoolerUnitNodes[1]); + } + } + + // first evaporative cooler, second evaporative cooler + { + Model m; + + ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); + zoneHVACEvaporativeCoolerUnit.setFanPlacement(fanPlacement); + EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); + + ThermalZone z(m); + zoneHVACEvaporativeCoolerUnit.addToThermalZone(z); + Space s(m); + s.setThermalZone(z); + + ForwardTranslator ft; + Workspace workspace = ft.translateModel(m); + + std::vector evaporativeCoolerUnitNodes = getEvaporativeCoolerUnitNodes(workspace); + std::vector fanNodes = getSupplyAirFanNodes(workspace); + std::vector firstEvaporativeCoolerNodes = getFirstEvaporativeCoolerNodes(workspace); + std::vector secondEvaporativeCoolerNodes = getSecondEvaporativeCoolerNodes(workspace); + + if (fanPlacement == "BlowThrough") { + EXPECT_EQ(evaporativeCoolerUnitNodes[0], fanNodes[0]); + EXPECT_EQ(fanNodes[1], firstEvaporativeCoolerNodes[0]); + EXPECT_EQ(firstEvaporativeCoolerNodes[1], secondEvaporativeCoolerNodes[0]); + EXPECT_EQ(secondEvaporativeCoolerNodes[1], evaporativeCoolerUnitNodes[1]); + } else if (fanPlacement == "DrawThrough") { + EXPECT_EQ(evaporativeCoolerUnitNodes[0], firstEvaporativeCoolerNodes[0]); + EXPECT_EQ(firstEvaporativeCoolerNodes[1], secondEvaporativeCoolerNodes[0]); + EXPECT_EQ(secondEvaporativeCoolerNodes[1], fanNodes[0]); + EXPECT_EQ(fanNodes[1], evaporativeCoolerUnitNodes[1]); + } + } + } } diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index 97b920a1e9..3377d1b0a8 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -70,6 +70,44 @@ namespace model { bool keepHandle) : ZoneHVACComponent_Impl(other, model, keepHandle) {} + ModelObject ZoneHVACEvaporativeCoolerUnit_Impl::clone(Model model) const { + auto evaporativeCoolUnitClone = ZoneHVACComponent_Impl::clone(model).cast(); + + if (OptionalHVACComponent intermediate = optionalSupplyAirFan()) { + evaporativeCoolUnitClone.setSupplyAirFan(intermediate->clone(model).cast()); + } + if (OptionalHVACComponent intermediate = optionalFirstEvaporativeCooler()) { + evaporativeCoolUnitClone.setFirstEvaporativeCooler(intermediate->clone(model).cast()); + } + if (OptionalHVACComponent intermediate = secondEvaporativeCooler()) { + evaporativeCoolUnitClone.setSecondEvaporativeCooler(intermediate->clone(model).cast()); + } + + return std::move(evaporativeCoolUnitClone); + } + + std::vector ZoneHVACEvaporativeCoolerUnit_Impl::remove() { + std::vector result; + + if (OptionalHVACComponent intermediate = optionalSupplyAirFan()) { + std::vector removedSupplyAirFans = intermediate->remove(); + result.insert(result.end(), removedSupplyAirFans.begin(), removedSupplyAirFans.end()); + } + if (OptionalHVACComponent intermediate = optionalFirstEvaporativeCooler()) { + std::vector removedFirstEvaporativeCoolers = intermediate->remove(); + result.insert(result.end(), removedFirstEvaporativeCoolers.begin(), removedFirstEvaporativeCoolers.end()); + } + if (OptionalHVACComponent intermediate = secondEvaporativeCooler()) { + std::vector removedSecondEvaporativeCoolers = intermediate->remove(); + result.insert(result.end(), removedSecondEvaporativeCoolers.begin(), removedSecondEvaporativeCoolers.end()); + } + + std::vector removedZoneHVACEvaporativeCoolerUnit = ZoneHVACComponent_Impl::remove(); + result.insert(result.end(), removedZoneHVACEvaporativeCoolerUnit.begin(), removedZoneHVACEvaporativeCoolerUnit.end()); + + return result; + } + const std::vector& ZoneHVACEvaporativeCoolerUnit_Impl::outputVariableNames() const { static std::vector result; if (result.empty()) { @@ -91,6 +129,20 @@ namespace model { return result; } + std::vector ZoneHVACEvaporativeCoolerUnit_Impl::children() const { + std::vector result; + if (OptionalHVACComponent intermediate = optionalSupplyAirFan()) { + result.push_back(*intermediate); + } + if (OptionalHVACComponent intermediate = optionalFirstEvaporativeCooler()) { + result.push_back(*intermediate); + } + if (OptionalHVACComponent intermediate = secondEvaporativeCooler()) { + result.push_back(*intermediate); + } + return result; + } + unsigned ZoneHVACEvaporativeCoolerUnit_Impl::inletPort() const { return OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName; } @@ -100,19 +152,46 @@ namespace model { } ComponentType ZoneHVACEvaporativeCoolerUnit_Impl::componentType() const { - return ComponentType::None; + return ComponentType::Cooling; } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::coolingFuelTypes() const { - return {}; + std::set result; + for (auto ft : firstEvaporativeCooler().coolingFuelTypes()) { + result.insert(ft); + } + if (auto secondEvaporativeCooler_ = secondEvaporativeCooler()) { + for (auto ft : secondEvaporativeCooler_->coolingFuelTypes()) { + result.insert(ft); + } + } + return {result.begin(), result.end()}; } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::heatingFuelTypes() const { - return {}; + std::set result; + for (auto ft : firstEvaporativeCooler().heatingFuelTypes()) { + result.insert(ft); + } + if (auto secondEvaporativeCooler_ = secondEvaporativeCooler()) { + for (auto ft : secondEvaporativeCooler_->heatingFuelTypes()) { + result.insert(ft); + } + } + return {result.begin(), result.end()}; } std::vector ZoneHVACEvaporativeCoolerUnit_Impl::appGHeatingFuelTypes() const { - return {}; + std::set result; + for (auto ft : firstEvaporativeCooler().appGHeatingFuelTypes()) { + result.insert(ft); + } + if (auto secondEvaporativeCooler_ = secondEvaporativeCooler()) { + for (auto ft : secondEvaporativeCooler_->appGHeatingFuelTypes()) { + result.insert(ft); + } + } + return {result.begin(), result.end()}; } Schedule ZoneHVACEvaporativeCoolerUnit_Impl::availabilitySchedule() const { @@ -286,7 +365,7 @@ namespace model { ok = setAvailabilitySchedule(alwaysOn); OS_ASSERT(ok); - FanComponentModel supplyAirFan(model); // StripMallZoneEvapCooler.idf + FanComponentModel supplyAirFan(model); ok = setSupplyAirFan(supplyAirFan); OS_ASSERT(ok); @@ -301,7 +380,7 @@ namespace model { OS_ASSERT(ok); EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(model, alwaysOn); - ok = setFirstEvaporativeCooler(firstEvaporativeCooler); // StripMallZoneEvapCooler.idf + ok = setFirstEvaporativeCooler(firstEvaporativeCooler); OS_ASSERT(ok); ok = setShutOffRelativeHumidity(100.0); diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp index eb891a3fe1..f97b213240 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp @@ -60,12 +60,18 @@ namespace model { /** @name Virtual Methods */ //@{ + virtual ModelObject clone(Model model) const override; + + virtual std::vector remove() override; + virtual const std::vector& outputVariableNames() const override; virtual IddObjectType iddObjectType() const override; virtual std::vector getScheduleTypeKeys(const Schedule& schedule) const override; + virtual std::vector children() const override; + virtual unsigned inletPort() const override; virtual unsigned outletPort() const override; diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 65c8b75f0a..2d51594ca9 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -127,8 +127,8 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_HeatCoolFuelTypes) { ZoneHVACEvaporativeCoolerUnit zoneHVACEvaporativeCoolerUnit(m); - EXPECT_EQ(ComponentType(ComponentType::Both), zoneHVACEvaporativeCoolerUnit.componentType()); + EXPECT_EQ(ComponentType(ComponentType::Cooling), zoneHVACEvaporativeCoolerUnit.componentType()); testFuelTypeEquality({FuelType::Electricity}, zoneHVACEvaporativeCoolerUnit.coolingFuelTypes()); - testFuelTypeEquality({FuelType::Electricity, FuelType::Propane}, zoneHVACEvaporativeCoolerUnit.heatingFuelTypes()); - testAppGFuelTypeEquality({AppGFuelType::Fuel, AppGFuelType::HeatPump}, zoneHVACEvaporativeCoolerUnit.appGHeatingFuelTypes()); + testFuelTypeEquality({}, zoneHVACEvaporativeCoolerUnit.heatingFuelTypes()); + testAppGFuelTypeEquality({}, zoneHVACEvaporativeCoolerUnit.appGHeatingFuelTypes()); } diff --git a/src/osversion/VersionTranslator.cpp b/src/osversion/VersionTranslator.cpp index dcf9f7564b..bb579c75b4 100644 --- a/src/osversion/VersionTranslator.cpp +++ b/src/osversion/VersionTranslator.cpp @@ -333,7 +333,8 @@ namespace osversion { OS_ASSERT(tempModel.strictnessLevel() == StrictnessLevel::Minimal); std::vector> issueInfo = fixInterobjectIssuesStage1(tempModel, m_originalVersion); if (!tempModel.isValid(StrictnessLevel::Draft)) { - LOG(Error, "Model with Version " << openStudioVersion() << " IDD is not valid to draft " << "strictness level."); + LOG(Error, "Model with Version " << openStudioVersion() << " IDD is not valid to draft " + << "strictness level."); LOG(Error, tempModel.validityReport(StrictnessLevel::Draft)); return boost::none; } @@ -382,7 +383,8 @@ namespace osversion { // bracket allowable versions LOG(Debug, "Starting translation from Version " << currentVersion.str() << "."); if (currentVersion < VersionString("0.7.0")) { - LOG(Error, "Version translation is not provided for OpenStudio models created prior to " << "Version 0.7.0."); + LOG(Error, "Version translation is not provided for OpenStudio models created prior to " + << "Version 0.7.0."); return; } if (currentVersion > VersionString(openStudioVersion())) { @@ -390,8 +392,8 @@ namespace osversion { // if currentVersion is just one ahead, may be a developer using the cloud. // let it pass as if currentVersion == openStudioVersion(), with a warning if (VersionString(openStudioVersion()).isNextVersion(currentVersion)) { - LOG(Warn, "Version extracted from file '" << currentVersion.str() << "' is one " << "increment ahead of OpenStudio Version " - << openStudioVersion() << ". " + LOG(Warn, "Version extracted from file '" << currentVersion.str() << "' is one " + << "increment ahead of OpenStudio Version " << openStudioVersion() << ". " << "Proceeding as if these versions are the same. Use with caution."); currentVersion = VersionString(openStudioVersion()); } else { @@ -620,7 +622,8 @@ namespace osversion { OS_ASSERT(ok); result = objCopy; } else { - LOG(Warn, "Tried to update the file path '" << original << "' to the new format, " << "but was unsuccessful."); + LOG(Warn, "Tried to update the file path '" << original << "' to the new format, " + << "but was unsuccessful."); } } } @@ -770,8 +773,8 @@ namespace osversion { match = candidates[0]; } if (match && match->name()) { - LOG(Warn, "Found match for object in OS:ComponentData contents list by type only, even " << "though this type of object (" << typeStr - << ") has a name field."); + LOG(Warn, "Found match for object in OS:ComponentData contents list by type only, even " + << "though this type of object (" << typeStr << ") has a name field."); } } @@ -785,7 +788,8 @@ namespace osversion { } else { LOG(Warn, "Unable to locate object in OS:ComponentData contents list called out " << "as object type '" << typeStr << "', and with name '" << nameStr - << "'. Skipping this object (that is, removing it from the Component " << "definition)."); + << "'. Skipping this object (that is, removing it from the Component " + << "definition)."); continue; } } @@ -1093,7 +1097,7 @@ namespace osversion { } } } // for keys - } // for users + } // for users m_refactored.emplace_back(originalSchedule, schedule.idfObject()); for (const auto& candidate : candidates) { model::ModelObjectVector wholeCandidate = getRecursiveChildren(candidate); From 9fc6562b0ef9edde676866899b5b3caf580d2a31 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Thu, 2 Jan 2025 15:25:10 -0700 Subject: [PATCH 07/24] Add tests and clean up cpp and ft. --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 23 ++-- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 14 ++- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 113 ++++++++++++++++++ 3 files changed, 133 insertions(+), 17 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index edbdb1d04e..a95c97deeb 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -57,11 +57,9 @@ namespace energyplus { // Instantiate an IdfObject of the class to store the values IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EvaporativeCoolerUnit, modelObject); - // Availability Schedule Name: Optional Object - if (boost::optional availabilitySchedule_ = modelObject.availabilitySchedule()) { - if (boost::optional wo_ = translateAndMapModelObject(availabilitySchedule_.get())) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString()); - } + // Availability Schedule Name: Required Object + if (boost::optional wo_ = translateAndMapModelObject(modelObject.availabilitySchedule())) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString()); } boost::optional outdoorAirInletNodeName; @@ -81,23 +79,18 @@ namespace energyplus { // Supply Air Fan Object Type // Supply Air Fan Name - boost::optional fan_; - if (boost::optional supplyAirFan = modelObject.supplyAirFan()) { - fan_ = translateAndMapModelObject(supplyAirFan.get()); + boost::optional fan_ = translateAndMapModelObject(modelObject.supplyAirFan().get()); - if (fan_ && fan_->name()) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name()); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fan_->name().get()); - } + if (fan_ && fan_->name()) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fan_->name().get()); } if (modelObject.isDesignSupplyAirFlowRateAutosized()) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, "Autosize"); } else { // Design Supply Air Flow Rate: boost::optional - if (boost::optional designSupplyAirFlowRate_ = modelObject.designSupplyAirFlowRate()) { - idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, designSupplyAirFlowRate_.get()); - } + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, modelObject.designSupplyAirFlowRate().get()); } // Fan Placement: Required String diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index 3377d1b0a8..588f95c39d 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -395,8 +395,13 @@ namespace model { bool ok = true; ok = setAvailabilitySchedule(availabilitySchedule); OS_ASSERT(ok); + ok = setSupplyAirFan(supplyAirFan); - OS_ASSERT(ok); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s supply air fan to " << supplyAirFan.briefDescription() << "."); + } + autosizeDesignSupplyAirFlowRate(); ok = setFanPlacement("BlowThrough"); OS_ASSERT(ok); @@ -406,8 +411,13 @@ namespace model { OS_ASSERT(ok); ok = setCoolingLoadControlThresholdHeatTransferRate(100.0); OS_ASSERT(ok); + ok = setFirstEvaporativeCooler(firstEvaporativeCooler); - OS_ASSERT(ok); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s first evaporative cooler to " << firstEvaporativeCooler.briefDescription() << "."); + } + ok = setShutOffRelativeHumidity(100.0); OS_ASSERT(ok); } diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 2d51594ca9..96440d29c7 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -39,6 +39,14 @@ #include "../EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "../EvaporativeCoolerIndirectResearchSpecial.hpp" #include "../EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" +#include "../Node.hpp" +#include "../Node_Impl.hpp" +#include "../AirLoopHVAC.hpp" +#include "../AirLoopHVAC_Impl.hpp" +#include "../AirLoopHVACZoneSplitter.hpp" +#include "../AirLoopHVACZoneSplitter_Impl.hpp" +#include "../PlantLoop.hpp" +#include "../PlantLoop_Impl.hpp" using namespace openstudio; using namespace openstudio::model; @@ -132,3 +140,108 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_HeatCoolFuelTypes) { testFuelTypeEquality({}, zoneHVACEvaporativeCoolerUnit.heatingFuelTypes()); testAppGFuelTypeEquality({}, zoneHVACEvaporativeCoolerUnit.appGHeatingFuelTypes()); } + +TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToThermalZone) { + Model m; + ZoneHVACEvaporativeCoolerUnit zonehvac(m); + + ThermalZone tz(m); + ASSERT_TRUE(zonehvac.addToThermalZone(tz)); + ASSERT_TRUE(zonehvac.thermalZone()); + ASSERT_EQ(tz, zonehvac.thermalZone().get()); + ASSERT_EQ(1u, tz.equipment().size()); + zonehvac.removeFromThermalZone(); + ASSERT_EQ(0u, tz.equipment().size()); + + ZoneHVACEvaporativeCoolerUnit zonehvac2(m); + zonehvac2.addToThermalZone(tz); + zonehvac2.remove(); + ASSERT_EQ(0u, tz.equipment().size()); +} + +TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { + Model m; + FanComponentModel fan(m); + Schedule availabilitySchedule = m.alwaysOnDiscreteSchedule(); + EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(model, availabilitySchedule); + ZoneHVACEvaporativeCoolerUnit zonehvac(m, availabilitySchedule, fan, firstEvaporativeCooler); + EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m); + EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + + ThermalZone tz(m); + EXPECT_TRUE(zonehvac.addToThermalZone(tz)); + EXPECT_TRUE(zonehvac.inletModelObject()); + EXPECT_TRUE(zonehvac.outletModelObject()); + EXPECT_TRUE(zonehvac.thermalZone()); + { + Model m2; + auto zonehvacClone = zonehvac.clone(m2).cast(); + EXPECT_FALSE(zonehvacClone.inletModelObject()); + EXPECT_FALSE(zonehvacClone.outletModelObject()); + EXPECT_FALSE(zonehvacClone.thermalZone()); + EXPECT_NE(fan.handle(), zonehvacClone.supplyAirFan().handle()); + EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); + EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().handle()); + EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); + } + + { + auto zonehvacClone = zonehvac.clone(m).cast(); + EXPECT_FALSE(zonehvacClone.inletModelObject()); + EXPECT_FALSE(zonehvacClone.outletModelObject()); + EXPECT_FALSE(zonehvacClone.thermalZone()); + EXPECT_NE(fan.handle(), zonehvacClone.supplyAirFan().handle()); + EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); + EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().handle()); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + } +} + +TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_remove) { + Model m; + ZoneHVACEvaporativeCoolerUnit zonehvac(m); + + auto size = m.modelObjects().size(); + EXPECT_FALSE(zonehvac.remove().empty()); + EXPECT_EQ(size - 1, m.modelObjects().size()); + EXPECT_EQ(0, m.getConcreteModelObjects().size()); +} + +TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToNode) { + Model m; + ZoneHVACEvaporativeCoolerUnit zonehvac(m); + + AirLoopHVAC airLoop(m); + + Node supplyOutletNode = airLoop.supplyOutletNode(); + + EXPECT_FALSE(zonehvac.addToNode(supplyOutletNode)); + EXPECT_EQ(2, airLoop.supplyComponents().size()); + + Node inletNode = airLoop.zoneSplitter().lastOutletModelObject()->cast(); + + EXPECT_FALSE(zonehvac.addToNode(inletNode)); + EXPECT_EQ(5, airLoop.demandComponents().size()); + + PlantLoop plantLoop(m); + supplyOutletNode = plantLoop.supplyOutletNode(); + EXPECT_TRUE(zonehvac.addToNode(supplyOutletNode)); + EXPECT_EQ(7, plantLoop.supplyComponents().size()); + + Node demandOutletNode = plantLoop.demandOutletNode(); + EXPECT_FALSE(zonehvac.addToNode(demandOutletNode)); + EXPECT_EQ(5, plantLoop.demandComponents().size()); + + auto zonehvacClone = zonehvac.clone(m).cast(); + supplyOutletNode = plantLoop.supplyOutletNode(); + + EXPECT_TRUE(zonehvacClone.addToNode(supplyOutletNode)); + EXPECT_EQ(9, plantLoop.supplyComponents().size()); +} From 1b3315e627994d5fe2d0401a6915019f9fb1f552 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Fri, 3 Jan 2025 09:09:28 -0700 Subject: [PATCH 08/24] Fix ft and tests. --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 6 +++-- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index a95c97deeb..7cf2a1d553 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -58,7 +58,8 @@ namespace energyplus { IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EvaporativeCoolerUnit, modelObject); // Availability Schedule Name: Required Object - if (boost::optional wo_ = translateAndMapModelObject(modelObject.availabilitySchedule())) { + Schedule availabilitySchedule_ = modelObject.availabilitySchedule(); + if (boost::optional wo_ = translateAndMapModelObject(availabilitySchedule_)) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString()); } @@ -79,7 +80,8 @@ namespace energyplus { // Supply Air Fan Object Type // Supply Air Fan Name - boost::optional fan_ = translateAndMapModelObject(modelObject.supplyAirFan().get()); + HVACComponent supplyAirFan_ = modelObject.supplyAirFan(); + boost::optional fan_ = translateAndMapModelObject(supplyAirFan_); if (fan_ && fan_->name()) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name()); diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 96440d29c7..8c28b28245 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -47,6 +47,8 @@ #include "../AirLoopHVACZoneSplitter_Impl.hpp" #include "../PlantLoop.hpp" #include "../PlantLoop_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../ThermalZone_Impl.hpp" using namespace openstudio; using namespace openstudio::model; @@ -147,6 +149,8 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToThermalZone) { ThermalZone tz(m); ASSERT_TRUE(zonehvac.addToThermalZone(tz)); + EXPECT_TRUE(zonehvac.inletNode()); + EXPECT_TRUE(zonehvac.outletNode()); ASSERT_TRUE(zonehvac.thermalZone()); ASSERT_EQ(tz, zonehvac.thermalZone().get()); ASSERT_EQ(1u, tz.equipment().size()); @@ -163,28 +167,29 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { Model m; FanComponentModel fan(m); Schedule availabilitySchedule = m.alwaysOnDiscreteSchedule(); - EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(model, availabilitySchedule); + EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(m, availabilitySchedule); ZoneHVACEvaporativeCoolerUnit zonehvac(m, availabilitySchedule, fan, firstEvaporativeCooler); EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m); - EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler)); + EXPECT_TRUE(zonehvac.setSecondEvaporativeCooler(secondEvaporativeCooler)); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); ThermalZone tz(m); EXPECT_TRUE(zonehvac.addToThermalZone(tz)); - EXPECT_TRUE(zonehvac.inletModelObject()); - EXPECT_TRUE(zonehvac.outletModelObject()); + EXPECT_TRUE(zonehvac.inletNode()); + EXPECT_TRUE(zonehvac.outletNode()); EXPECT_TRUE(zonehvac.thermalZone()); { Model m2; auto zonehvacClone = zonehvac.clone(m2).cast(); - EXPECT_FALSE(zonehvacClone.inletModelObject()); - EXPECT_FALSE(zonehvacClone.outletModelObject()); + EXPECT_FALSE(zonehvacClone.inletNode()); + EXPECT_FALSE(zonehvacClone.outletNode()); EXPECT_FALSE(zonehvacClone.thermalZone()); EXPECT_NE(fan.handle(), zonehvacClone.supplyAirFan().handle()); EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); - EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().handle()); + ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler()); + EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle()); EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); @@ -192,12 +197,13 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { { auto zonehvacClone = zonehvac.clone(m).cast(); - EXPECT_FALSE(zonehvacClone.inletModelObject()); - EXPECT_FALSE(zonehvacClone.outletModelObject()); + EXPECT_FALSE(zonehvacClone.inletNode()); + EXPECT_FALSE(zonehvacClone.outletNode()); EXPECT_FALSE(zonehvacClone.thermalZone()); EXPECT_NE(fan.handle(), zonehvacClone.supplyAirFan().handle()); EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); - EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().handle()); + ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler()); + EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); From 985ffd74c6fb417e9e644a090ec08782fdcfb7ad Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 6 Jan 2025 09:52:00 -0700 Subject: [PATCH 09/24] Remove remove override and update tests. --- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 22 ---------------- .../ZoneHVACEvaporativeCoolerUnit_Impl.hpp | 2 -- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 25 +++++++++++++------ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index 588f95c39d..097629289f 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -86,28 +86,6 @@ namespace model { return std::move(evaporativeCoolUnitClone); } - std::vector ZoneHVACEvaporativeCoolerUnit_Impl::remove() { - std::vector result; - - if (OptionalHVACComponent intermediate = optionalSupplyAirFan()) { - std::vector removedSupplyAirFans = intermediate->remove(); - result.insert(result.end(), removedSupplyAirFans.begin(), removedSupplyAirFans.end()); - } - if (OptionalHVACComponent intermediate = optionalFirstEvaporativeCooler()) { - std::vector removedFirstEvaporativeCoolers = intermediate->remove(); - result.insert(result.end(), removedFirstEvaporativeCoolers.begin(), removedFirstEvaporativeCoolers.end()); - } - if (OptionalHVACComponent intermediate = secondEvaporativeCooler()) { - std::vector removedSecondEvaporativeCoolers = intermediate->remove(); - result.insert(result.end(), removedSecondEvaporativeCoolers.begin(), removedSecondEvaporativeCoolers.end()); - } - - std::vector removedZoneHVACEvaporativeCoolerUnit = ZoneHVACComponent_Impl::remove(); - result.insert(result.end(), removedZoneHVACEvaporativeCoolerUnit.begin(), removedZoneHVACEvaporativeCoolerUnit.end()); - - return result; - } - const std::vector& ZoneHVACEvaporativeCoolerUnit_Impl::outputVariableNames() const { static std::vector result; if (result.empty()) { diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp index f97b213240..d4c3392dc9 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp @@ -62,8 +62,6 @@ namespace model { virtual ModelObject clone(Model model) const override; - virtual std::vector remove() override; - virtual const std::vector& outputVariableNames() const override; virtual IddObjectType iddObjectType() const override; diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 8c28b28245..d45d6d2b40 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -33,6 +33,8 @@ #include "../ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "../Schedule.hpp" #include "../Schedule_Impl.hpp" +#include "../ScheduleConstant.hpp" +#include "../ScheduleConstant_Impl.hpp" #include "../FanComponentModel.hpp" #include "../FanComponentModel_Impl.hpp" #include "../EvaporativeCoolerDirectResearchSpecial.hpp" @@ -204,9 +206,9 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler()); EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle()); - EXPECT_EQ(1u, m.getConcreteModelObjects().size()); - EXPECT_EQ(1u, m.getConcreteModelObjects().size()); - EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + EXPECT_EQ(2u, m.getConcreteModelObjects().size()); + EXPECT_EQ(2u, m.getConcreteModelObjects().size()); + EXPECT_EQ(2u, m.getConcreteModelObjects().size()); } } @@ -215,9 +217,18 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_remove) { ZoneHVACEvaporativeCoolerUnit zonehvac(m); auto size = m.modelObjects().size(); + EXPECT_EQ(1, m.getConcreteModelObjects().size()); + EXPECT_EQ(1, m.getConcreteModelObjects().size()); + EXPECT_EQ(1, m.getConcreteModelObjects().size()); + EXPECT_EQ(0, m.getConcreteModelObjects().size()); + EXPECT_EQ(1, m.getConcreteModelObjects().size()); EXPECT_FALSE(zonehvac.remove().empty()); EXPECT_EQ(size - 1, m.modelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); + EXPECT_EQ(0, m.getConcreteModelObjects().size()); + EXPECT_EQ(0, m.getConcreteModelObjects().size()); + EXPECT_EQ(0, m.getConcreteModelObjects().size()); + EXPECT_EQ(1, m.getConcreteModelObjects().size()); } TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToNode) { @@ -238,8 +249,8 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToNode) { PlantLoop plantLoop(m); supplyOutletNode = plantLoop.supplyOutletNode(); - EXPECT_TRUE(zonehvac.addToNode(supplyOutletNode)); - EXPECT_EQ(7, plantLoop.supplyComponents().size()); + EXPECT_FALSE(zonehvac.addToNode(supplyOutletNode)); + EXPECT_EQ(5, plantLoop.supplyComponents().size()); Node demandOutletNode = plantLoop.demandOutletNode(); EXPECT_FALSE(zonehvac.addToNode(demandOutletNode)); @@ -248,6 +259,6 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToNode) { auto zonehvacClone = zonehvac.clone(m).cast(); supplyOutletNode = plantLoop.supplyOutletNode(); - EXPECT_TRUE(zonehvacClone.addToNode(supplyOutletNode)); - EXPECT_EQ(9, plantLoop.supplyComponents().size()); + EXPECT_FALSE(zonehvacClone.addToNode(supplyOutletNode)); + EXPECT_EQ(5, plantLoop.supplyComponents().size()); } From b9800aabc68f57ffc0f2f7539e1ae45ed7a0f8d0 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 7 Jan 2025 17:34:32 +0100 Subject: [PATCH 10/24] Add ZoneHVACEvaporativeCoolerUnit to all Fan's `containingZoneHVACComponent` https://github.com/NREL/OpenStudio/pull/5326#discussion_r1905707331 --- src/model/FanComponentModel.cpp | 36 ++++++++++++++++----------------- src/model/FanConstantVolume.cpp | 15 ++++++++++++++ src/model/FanOnOff.cpp | 9 +++++++++ src/model/FanSystemModel.cpp | 9 +++++++++ src/model/FanVariableVolume.cpp | 15 ++++++++++++++ 5 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/model/FanComponentModel.cpp b/src/model/FanComponentModel.cpp index b949cc3863..c0129635a1 100644 --- a/src/model/FanComponentModel.cpp +++ b/src/model/FanComponentModel.cpp @@ -39,8 +39,8 @@ #include "AirTerminalSingleDuctSeriesPIUReheat_Impl.hpp" // containing ZoneHVAC Component -// #include "ZoneHVACEvaporativeCoolerUnit.hpp" -// #include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include #include @@ -386,23 +386,21 @@ namespace model { boost::optional FanComponentModel_Impl::containingZoneHVACComponent() const { - // Note JM 2021-01-26: Only ZoneHVAC:EvaporativeCoolerUnit apparently, which isn't wrapped in the OS SDK currently - - //std::vector zoneHVACComponent = this->model().getModelObjects(); - //for (const auto& elem : zoneHVACComponent) { - //switch (elem.iddObject().type().value()) { - - //// ZoneHVAC:EvaporativeCoolerUnit: not wrapped - //case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { - //ZoneHVACEnergyRecoveryVentilator component = elem.cast(); - //if (component.supplyAirFan().handle() == this->handle()) return elem; - //break; - //} - //default: { - //break; - //} - //} - //} + std::vector zoneHVACComponent = this->model().getModelObjects(); + for (const auto& elem : zoneHVACComponent) { + switch (elem.iddObject().type().value()) { + case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { + auto component = elem.cast(); + if (component.supplyAirFan().handle() == this->handle()) { + return elem; + } + break; + } + default: { + break; + } + } + } return boost::none; } diff --git a/src/model/FanConstantVolume.cpp b/src/model/FanConstantVolume.cpp index 9471406bea..045d7f4c3d 100644 --- a/src/model/FanConstantVolume.cpp +++ b/src/model/FanConstantVolume.cpp @@ -19,6 +19,8 @@ #include "ZoneHVACUnitHeater_Impl.hpp" #include "ZoneHVACUnitVentilator.hpp" #include "ZoneHVACUnitVentilator_Impl.hpp" +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "AirLoopHVACOutdoorAirSystem.hpp" #include "AirLoopHVACOutdoorAirSystem_Impl.hpp" #include "AirTerminalSingleDuctParallelPIUReheat.hpp" @@ -344,6 +346,19 @@ namespace model { } } + // ZoneHVACEvaporativeCoolerUnit + std::vector zoneHVACEvaporativeCoolerUnit; + + zoneHVACEvaporativeCoolerUnit = this->model().getConcreteModelObjects(); + + for (const auto& elem : zoneHVACEvaporativeCoolerUnit) { + if (boost::optional fan = elem.supplyAirFan()) { + if (fan->handle() == this->handle()) { + return elem; + } + } + } + return boost::none; } diff --git a/src/model/FanOnOff.cpp b/src/model/FanOnOff.cpp index 326bc8c5df..9c092fba30 100644 --- a/src/model/FanOnOff.cpp +++ b/src/model/FanOnOff.cpp @@ -37,6 +37,8 @@ #include "ZoneHVACUnitHeater_Impl.hpp" #include "ZoneHVACUnitVentilator.hpp" #include "ZoneHVACUnitVentilator_Impl.hpp" +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "AirLoopHVACUnitaryHeatPumpAirToAir.hpp" #include "AirLoopHVACUnitaryHeatPumpAirToAir_Impl.hpp" #include "AirLoopHVACUnitarySystem.hpp" @@ -424,6 +426,13 @@ namespace model { } break; } + case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { + auto component = elem.cast(); + if (component.supplyAirFan().handle() == this->handle()) { + return elem; + } + break; + } default: { break; } diff --git a/src/model/FanSystemModel.cpp b/src/model/FanSystemModel.cpp index 6076457f83..0633fee2f2 100644 --- a/src/model/FanSystemModel.cpp +++ b/src/model/FanSystemModel.cpp @@ -47,6 +47,8 @@ #include "ZoneHVACUnitHeater_Impl.hpp" #include "ZoneHVACUnitVentilator.hpp" #include "ZoneHVACUnitVentilator_Impl.hpp" +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "ZoneHVACWaterToAirHeatPump.hpp" #include "ZoneHVACWaterToAirHeatPump_Impl.hpp" // These are supposed to be ZoneHVACComponents @@ -484,6 +486,13 @@ namespace model { } break; } + case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { + auto component = elem.cast(); + if (component.supplyAirFan().handle() == this->handle()) { + return elem; + } + break; + } case openstudio::IddObjectType::OS_ZoneHVAC_WaterToAirHeatPump: { auto component = elem.cast(); if (component.supplyAirFan().handle() == this->handle()) { diff --git a/src/model/FanVariableVolume.cpp b/src/model/FanVariableVolume.cpp index 993893f753..185790c78c 100644 --- a/src/model/FanVariableVolume.cpp +++ b/src/model/FanVariableVolume.cpp @@ -20,6 +20,8 @@ #include "ZoneHVACUnitHeater_Impl.hpp" #include "ZoneHVACUnitVentilator.hpp" #include "ZoneHVACUnitVentilator_Impl.hpp" +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" #include "AirLoopHVACUnitarySystem.hpp" #include "AirLoopHVACUnitarySystem_Impl.hpp" #include "SetpointManagerMixedAir.hpp" @@ -492,6 +494,19 @@ namespace model { } } + // ZoneHVACEvaporativeCoolerUnit + std::vector zoneHVACEvaporativeCoolerUnit; + + zoneHVACEvaporativeCoolerUnit = this->model().getConcreteModelObjects(); + + for (const auto& elem : zoneHVACEvaporativeCoolerUnit) { + if (boost::optional fan = elem.supplyAirFan()) { + if (fan->handle() == this->handle()) { + return elem; + } + } + } + return boost::none; } From 3713357bea382fc3596d109295d7437d43be36f3 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 7 Jan 2025 17:37:06 +0100 Subject: [PATCH 11/24] Add ZoneHVACEvaporativeCoolerUnit to all evaporative cooler component models `containingZoneHVACComponent` cf https://github.com/NREL/OpenStudio/pull/5326#discussion_r1905724217 --- ...EvaporativeCoolerDirectResearchSpecial.cpp | 26 ++++++++++++++++++ ...rativeCoolerDirectResearchSpecial_Impl.hpp | 2 ++ ...aporativeCoolerIndirectResearchSpecial.cpp | 27 +++++++++++++++++++ ...tiveCoolerIndirectResearchSpecial_Impl.hpp | 2 ++ 4 files changed, 57 insertions(+) diff --git a/src/model/EvaporativeCoolerDirectResearchSpecial.cpp b/src/model/EvaporativeCoolerDirectResearchSpecial.cpp index a8c8fa14e0..bc52fbb885 100644 --- a/src/model/EvaporativeCoolerDirectResearchSpecial.cpp +++ b/src/model/EvaporativeCoolerDirectResearchSpecial.cpp @@ -15,6 +15,10 @@ #include "Curve_Impl.hpp" #include "Model.hpp" +// containing ZoneHVAC Component +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" + #include "../utilities/core/Assert.hpp" #include "../utilities/core/Compare.hpp" #include "../utilities/data/DataEnums.hpp" @@ -126,6 +130,28 @@ namespace model { return value.get(); } + boost::optional EvaporativeCoolerDirectResearchSpecial_Impl::containingZoneHVACComponent() const { + + std::vector zoneHVACComponent = this->model().getModelObjects(); + for (const auto& elem : zoneHVACComponent) { + switch (elem.iddObject().type().value()) { + case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { + auto component = elem.cast(); + if (component.firstEvaporativeCooler().handle() == this->handle()) { + return elem; + } + // I guess it's fine since this is optional anyways + // } else if (auto comp_ = component.secondEvaporativeCooler(); comp_ && comp_->handle() == this->handle()) { return elem; } + break; + } + default: { + break; + } + } + } + return boost::none; + } + bool EvaporativeCoolerDirectResearchSpecial_Impl::setAvailabilitySchedule(Schedule& schedule) { bool result = setSchedule(OS_EvaporativeCooler_Direct_ResearchSpecialFields::AvailabilityScheduleName, "EvaporativeCoolerDirectResearchSpecial", "Availability", schedule); diff --git a/src/model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp b/src/model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp index 922fc35265..3757eb5ce3 100644 --- a/src/model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp +++ b/src/model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp @@ -131,6 +131,8 @@ namespace model { boost::optional availabilityScheduleAsModelObject() const; bool setAvailabilityScheduleAsModelObject(const boost::optional& modelObject); + + virtual boost::optional containingZoneHVACComponent() const override; }; } // namespace detail diff --git a/src/model/EvaporativeCoolerIndirectResearchSpecial.cpp b/src/model/EvaporativeCoolerIndirectResearchSpecial.cpp index 0cfa6a6994..a135d61765 100644 --- a/src/model/EvaporativeCoolerIndirectResearchSpecial.cpp +++ b/src/model/EvaporativeCoolerIndirectResearchSpecial.cpp @@ -9,6 +9,7 @@ #include "EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" #include "Schedule.hpp" #include "Schedule_Impl.hpp" +#include "Model.hpp" #include "Node.hpp" #include "Node_Impl.hpp" #include "Curve.hpp" @@ -16,6 +17,10 @@ #include "ScheduleTypeLimits.hpp" #include "ScheduleTypeRegistry.hpp" +// containing ZoneHVAC Component +#include "ZoneHVACEvaporativeCoolerUnit.hpp" +#include "ZoneHVACEvaporativeCoolerUnit_Impl.hpp" + #include "../utilities/core/Assert.hpp" #include "../utilities/data/DataEnums.hpp" @@ -261,6 +266,28 @@ namespace model { return false; } + boost::optional EvaporativeCoolerIndirectResearchSpecial_Impl::containingZoneHVACComponent() const { + + std::vector zoneHVACComponent = this->model().getModelObjects(); + for (const auto& elem : zoneHVACComponent) { + switch (elem.iddObject().type().value()) { + case openstudio::IddObjectType::OS_ZoneHVAC_EvaporativeCoolerUnit: { + auto component = elem.cast(); + if (component.firstEvaporativeCooler().handle() == this->handle()) { + return elem; + } + // I guess it's fine since this is optional anyways + // } else if (auto comp_ = component.secondEvaporativeCooler(); comp_ && comp_->handle() == this->handle()) { return elem; } + break; + } + default: { + break; + } + } + } + return boost::none; + } + bool EvaporativeCoolerIndirectResearchSpecial_Impl::setReliefAirInletNode(const Node& node) { return setPointer(OS_EvaporativeCooler_Indirect_ResearchSpecialFields::ReliefAirInletNode, node.handle()); } diff --git a/src/model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp b/src/model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp index 5b01c4acc3..6db2d3e268 100644 --- a/src/model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp +++ b/src/model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp @@ -195,6 +195,8 @@ namespace model { protected: private: REGISTER_LOGGER("openstudio.model.EvaporativeCoolerIndirectResearchSpecial"); + + virtual boost::optional containingZoneHVACComponent() const override; }; } // namespace detail From c6b3eeb0f038f041dc5dac7330dbacd4522aaaf5 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 7 Jan 2025 17:48:08 +0100 Subject: [PATCH 12/24] Improve and fixup tests --- .../test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index d45d6d2b40..8bb3bf2f3c 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -216,14 +216,27 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_remove) { Model m; ZoneHVACEvaporativeCoolerUnit zonehvac(m); + auto fanComponent = zonehvac.supplyAirFan(); + ASSERT_TRUE(fanComponent.optionalCast()); + EXPECT_TRUE(fanComponent.containingZoneHVACComponent()); + EXPECT_EQ(zonehvac.handle(), fanComponent.containingZoneHVACComponent().get().handle()); + EXPECT_FALSE(fanComponent.isRemovable()); + + auto evapCoolerComponent = zonehvac.firstEvaporativeCooler(); + ASSERT_TRUE(evapCoolerComponent.optionalCast()); + EXPECT_TRUE(evapCoolerComponent.containingZoneHVACComponent()); + EXPECT_EQ(zonehvac.handle(), evapCoolerComponent.containingZoneHVACComponent().get().handle()); + EXPECT_FALSE(evapCoolerComponent.isRemovable()); + auto size = m.modelObjects().size(); EXPECT_EQ(1, m.getConcreteModelObjects().size()); EXPECT_EQ(1, m.getConcreteModelObjects().size()); EXPECT_EQ(1, m.getConcreteModelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(1, m.getConcreteModelObjects().size()); + // remove returns: ["Zone HVAC Evaporative Cooler Unit 1", "Fan Component Model 1", "Evaporative Cooler Direct Research Special 1"] EXPECT_FALSE(zonehvac.remove().empty()); - EXPECT_EQ(size - 1, m.modelObjects().size()); + EXPECT_EQ(size - 3, m.modelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); From d5d632af6ded708c5ce8a9a51b88275595d21098 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 9 Jan 2025 13:32:14 +0100 Subject: [PATCH 13/24] Write Sensor Node Name (do we need to write relief air Node name?) --- ...ardTranslateZoneHVACEvaporativeCoolerUnit.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index 7cf2a1d553..a013aaf5af 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -68,14 +68,14 @@ namespace energyplus { // Outdoor Air Inlet Node Name: Required Node if (boost::optional node = modelObject.inletNode()) { - outdoorAirInletNodeName = node->name().get(); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, node->name().get()); + outdoorAirInletNodeName = node->nameString(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, node->nameString()); } // Cooler Outlet Node Name: Required Node if (boost::optional node = modelObject.outletNode()) { - coolerOutletNodeName = node->name().get(); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, node->name().get()); + coolerOutletNodeName = node->nameString(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, node->nameString()); } // Supply Air Fan Object Type @@ -85,7 +85,7 @@ namespace energyplus { if (fan_ && fan_->name()) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name()); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fan_->name().get()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fan_->nameString()); } if (modelObject.isDesignSupplyAirFlowRateAutosized()) { @@ -135,7 +135,7 @@ namespace energyplus { // If BlowThrough: o---- Fan ---- E1 ---- E2 ----o // If DrawThrough: o---- E1 ---- E2 ---- Fan ----o - std::string baseName = modelObject.name().get(); + std::string baseName = modelObject.nameString(); if (fan_) { std::string outletNodeName; std::string inletNodeName = outdoorAirInletNodeName.get(); @@ -194,9 +194,11 @@ namespace energyplus { if (firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); + firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, outletNodeName); } else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); + firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, outletNodeName); } else { LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << firstEvaporativeCooler_->iddObject().type() << "."); } @@ -222,9 +224,11 @@ namespace energyplus { if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); + secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, outletNodeName); } else if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); + secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, outletNodeName); } else { LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << secondEvaporativeCooler_->iddObject().type() << "."); } From d805651f10373caec5e0f39d5d67945a7cf2ed58 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 9 Jan 2025 14:24:56 +0100 Subject: [PATCH 14/24] Adjust node connections cf https://github.com/NREL/OpenStudio/pull/5326#discussion_r1908751094 --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 26 ++++++++++++------- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index a013aaf5af..b75b2b1b0b 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -63,21 +63,29 @@ namespace energyplus { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString()); } - boost::optional outdoorAirInletNodeName; + const auto outdoorAirInletNodeName = modelObject.nameString() + " Outdoor Air Node"; boost::optional coolerOutletNodeName; - // Outdoor Air Inlet Node Name: Required Node - if (boost::optional node = modelObject.inletNode()) { - outdoorAirInletNodeName = node->nameString(); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, node->nameString()); + // Outdoor Air Inlet Node Name: Required Node - This is an Outdoor Air Node + { + IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList); + oaNodeListIdf.setString(0, outdoorAirInletNodeName); + m_idfObjects.emplace_back(std::move(oaNodeListIdf)); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, outdoorAirInletNodeName); } - // Cooler Outlet Node Name: Required Node + // Cooler Outlet Node Name: Required Node, a zone air inlet node if (boost::optional node = modelObject.outletNode()) { coolerOutletNodeName = node->nameString(); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName, node->nameString()); } + // Zone Relief Air Node Name: optional Node, filled to a Zone Exhaust Node if the flow is being balanced here and not elsewhere + if (boost::optional node = modelObject.inletNode()) { + coolerOutletNodeName = node->nameString(); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, node->nameString()); + } + // Supply Air Fan Object Type // Supply Air Fan Name HVACComponent supplyAirFan_ = modelObject.supplyAirFan(); @@ -138,7 +146,7 @@ namespace energyplus { std::string baseName = modelObject.nameString(); if (fan_) { std::string outletNodeName; - std::string inletNodeName = outdoorAirInletNodeName.get(); + std::string inletNodeName = outdoorAirInletNodeName; if (istringEqual(fanPlacement, "BlowThrough")) { if (firstEvaporativeCooler_) { outletNodeName = baseName + " Fan - First Evaporative Cooler Node"; @@ -180,7 +188,7 @@ namespace energyplus { if (istringEqual(fanPlacement, "BlowThrough") && fan_) { inletNodeName = baseName + " Fan - First Evaporative Cooler Node"; } else { - inletNodeName = outdoorAirInletNodeName.get(); + inletNodeName = outdoorAirInletNodeName; } if (secondEvaporativeCooler_) { @@ -212,7 +220,7 @@ namespace energyplus { } else if (istringEqual(fanPlacement, "BlowThrough") && fan_) { inletNodeName = baseName + " Fan - Second Evaporative Cooler Node"; } else { - inletNodeName = outdoorAirInletNodeName.get(); + inletNodeName = outdoorAirInletNodeName; } if (istringEqual(fanPlacement, "DrawThrough") && fan_) { diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index 097629289f..8c0402b64b 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -122,7 +122,7 @@ namespace model { } unsigned ZoneHVACEvaporativeCoolerUnit_Impl::inletPort() const { - return OS_ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName; + return OS_ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName; } unsigned ZoneHVACEvaporativeCoolerUnit_Impl::outletPort() const { From 86afadc8d1fe128ebaa3751ae5d24c24ba807f92 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 15 Jan 2025 10:21:17 +0100 Subject: [PATCH 15/24] clang-format --- src/model/Model.cpp | 6 +++--- src/osversion/VersionTranslator.cpp | 22 +++++++++------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/model/Model.cpp b/src/model/Model.cpp index 38a56fb71d..bfe9fd1cb2 100644 --- a/src/model/Model.cpp +++ b/src/model/Model.cpp @@ -2254,9 +2254,9 @@ namespace model { if (!openstudio::equal(inputResult, outputResult, tol)) { LOG_FREE(logLevel, "openstudio.model.Model", "The " << attributeName << " values determined for " << object.briefDescription() - << " using input and output data differ by a (relative) error " - << "greater than " << tol << ". The value calculated from input data was " << inputResult - << ", whereas the value calculated from output data was " << outputResult << "."); + << " using input and output data differ by a (relative) error " << "greater than " << tol + << ". The value calculated from input data was " << inputResult << ", whereas the value calculated from output data was " + << outputResult << "."); return false; } return true; diff --git a/src/osversion/VersionTranslator.cpp b/src/osversion/VersionTranslator.cpp index bb579c75b4..dcf9f7564b 100644 --- a/src/osversion/VersionTranslator.cpp +++ b/src/osversion/VersionTranslator.cpp @@ -333,8 +333,7 @@ namespace osversion { OS_ASSERT(tempModel.strictnessLevel() == StrictnessLevel::Minimal); std::vector> issueInfo = fixInterobjectIssuesStage1(tempModel, m_originalVersion); if (!tempModel.isValid(StrictnessLevel::Draft)) { - LOG(Error, "Model with Version " << openStudioVersion() << " IDD is not valid to draft " - << "strictness level."); + LOG(Error, "Model with Version " << openStudioVersion() << " IDD is not valid to draft " << "strictness level."); LOG(Error, tempModel.validityReport(StrictnessLevel::Draft)); return boost::none; } @@ -383,8 +382,7 @@ namespace osversion { // bracket allowable versions LOG(Debug, "Starting translation from Version " << currentVersion.str() << "."); if (currentVersion < VersionString("0.7.0")) { - LOG(Error, "Version translation is not provided for OpenStudio models created prior to " - << "Version 0.7.0."); + LOG(Error, "Version translation is not provided for OpenStudio models created prior to " << "Version 0.7.0."); return; } if (currentVersion > VersionString(openStudioVersion())) { @@ -392,8 +390,8 @@ namespace osversion { // if currentVersion is just one ahead, may be a developer using the cloud. // let it pass as if currentVersion == openStudioVersion(), with a warning if (VersionString(openStudioVersion()).isNextVersion(currentVersion)) { - LOG(Warn, "Version extracted from file '" << currentVersion.str() << "' is one " - << "increment ahead of OpenStudio Version " << openStudioVersion() << ". " + LOG(Warn, "Version extracted from file '" << currentVersion.str() << "' is one " << "increment ahead of OpenStudio Version " + << openStudioVersion() << ". " << "Proceeding as if these versions are the same. Use with caution."); currentVersion = VersionString(openStudioVersion()); } else { @@ -622,8 +620,7 @@ namespace osversion { OS_ASSERT(ok); result = objCopy; } else { - LOG(Warn, "Tried to update the file path '" << original << "' to the new format, " - << "but was unsuccessful."); + LOG(Warn, "Tried to update the file path '" << original << "' to the new format, " << "but was unsuccessful."); } } } @@ -773,8 +770,8 @@ namespace osversion { match = candidates[0]; } if (match && match->name()) { - LOG(Warn, "Found match for object in OS:ComponentData contents list by type only, even " - << "though this type of object (" << typeStr << ") has a name field."); + LOG(Warn, "Found match for object in OS:ComponentData contents list by type only, even " << "though this type of object (" << typeStr + << ") has a name field."); } } @@ -788,8 +785,7 @@ namespace osversion { } else { LOG(Warn, "Unable to locate object in OS:ComponentData contents list called out " << "as object type '" << typeStr << "', and with name '" << nameStr - << "'. Skipping this object (that is, removing it from the Component " - << "definition)."); + << "'. Skipping this object (that is, removing it from the Component " << "definition)."); continue; } } @@ -1097,7 +1093,7 @@ namespace osversion { } } } // for keys - } // for users + } // for users m_refactored.emplace_back(originalSchedule, schedule.idfObject()); for (const auto& candidate : candidates) { model::ModelObjectVector wholeCandidate = getRecursiveChildren(candidate); From c9691108c1dcda4a974cc4a6be3cd87bf19bfae9 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 16 Jan 2025 12:43:55 +0100 Subject: [PATCH 16/24] Implement autosizedDesignSupplyAirFlowRate correclty --- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 2 +- src/model/ZoneHVACEvaporativeCoolerUnit.hpp | 4 ++-- src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index 8c0402b64b..eeb508b922 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -202,7 +202,7 @@ namespace model { } boost::optional ZoneHVACEvaporativeCoolerUnit_Impl::autosizedDesignSupplyAirFlowRate() { - return getAutosizedValue("TODO_CHECK_SQL Design Supply Air Flow Rate", "m3/s"); + return getAutosizedValue("Design Size Design Supply Air Flow Rate", "m3/s"); } std::string ZoneHVACEvaporativeCoolerUnit_Impl::fanPlacement() const { diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp index 2d428b998a..b33c610ac9 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.hpp @@ -84,8 +84,6 @@ namespace model { bool isDesignSupplyAirFlowRateAutosized() const; - boost::optional autosizedDesignSupplyAirFlowRate(); - std::string fanPlacement() const; std::string coolerUnitControlMethod() const; @@ -132,6 +130,8 @@ namespace model { /** @name Other */ //@{ + boost::optional autosizedDesignSupplyAirFlowRate(); + //@} protected: /// @cond diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp index d4c3392dc9..369ebff196 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit_Impl.hpp @@ -74,6 +74,10 @@ namespace model { virtual unsigned outletPort() const override; + virtual void autosize() override; + + virtual void applySizingValues() override; + virtual ComponentType componentType() const override; virtual std::vector coolingFuelTypes() const override; virtual std::vector heatingFuelTypes() const override; @@ -91,8 +95,6 @@ namespace model { bool isDesignSupplyAirFlowRateAutosized() const; - boost::optional autosizedDesignSupplyAirFlowRate(); - std::string fanPlacement() const; std::string coolerUnitControlMethod() const; @@ -135,14 +137,12 @@ namespace model { bool setShutOffRelativeHumidity(double shutOffRelativeHumidity); - virtual void autosize() override; - - virtual void applySizingValues() override; - //@} /** @name Other */ //@{ + boost::optional autosizedDesignSupplyAirFlowRate(); + //@} protected: private: From 66a2f6c250a0fa13663dd39dc83ef511f7b36623 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 16 Jan 2025 14:05:33 +0100 Subject: [PATCH 17/24] Always use the ZoneHVACEvaporativeCoolerUnit's outlet node as the Sensor node --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index b75b2b1b0b..e35af2745f 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -64,7 +64,7 @@ namespace energyplus { } const auto outdoorAirInletNodeName = modelObject.nameString() + " Outdoor Air Node"; - boost::optional coolerOutletNodeName; + std::string coolerOutletNodeName; // Outdoor Air Inlet Node Name: Required Node - This is an Outdoor Air Node { @@ -74,6 +74,9 @@ namespace energyplus { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName, outdoorAirInletNodeName); } + // Technically outletNode and inletNode are always initialized, since they are connected via addToThermalZone and this FT routine is called by + // thermalZone::equipment + // Cooler Outlet Node Name: Required Node, a zone air inlet node if (boost::optional node = modelObject.outletNode()) { coolerOutletNodeName = node->nameString(); @@ -81,8 +84,8 @@ namespace energyplus { } // Zone Relief Air Node Name: optional Node, filled to a Zone Exhaust Node if the flow is being balanced here and not elsewhere + // NOTE: we always assume the airflow is balanced if (boost::optional node = modelObject.inletNode()) { - coolerOutletNodeName = node->nameString(); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName, node->nameString()); } @@ -153,7 +156,7 @@ namespace energyplus { } else if (secondEvaporativeCooler_) { outletNodeName = baseName + " Fan - Second Evaporative Cooler Node"; } else { - outletNodeName = coolerOutletNodeName.get(); + outletNodeName = coolerOutletNodeName; } } else { if (secondEvaporativeCooler_) { @@ -161,7 +164,7 @@ namespace energyplus { } else { inletNodeName = baseName + " First Evaporative Cooler - Fan Node"; } - outletNodeName = coolerOutletNodeName.get(); + outletNodeName = coolerOutletNodeName; } if (fan_->iddObject().type() == IddObjectType::Fan_ConstantVolume) { @@ -194,7 +197,7 @@ namespace energyplus { if (secondEvaporativeCooler_) { outletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; } else if (istringEqual(fanPlacement, "BlowThrough")) { - outletNodeName = coolerOutletNodeName.get(); + outletNodeName = coolerOutletNodeName; } else { outletNodeName = baseName + " First Evaporative Cooler - Fan Node"; } @@ -202,11 +205,11 @@ namespace energyplus { if (firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); - firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, outletNodeName); + firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); } else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); - firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, outletNodeName); + firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); } else { LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << firstEvaporativeCooler_->iddObject().type() << "."); } @@ -226,17 +229,17 @@ namespace energyplus { if (istringEqual(fanPlacement, "DrawThrough") && fan_) { outletNodeName = baseName + " Second Evaporative Cooler - Fan Node"; } else { - outletNodeName = coolerOutletNodeName.get(); + outletNodeName = coolerOutletNodeName; } if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); - secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, outletNodeName); + secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); } else if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); - secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, outletNodeName); + secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); } else { LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << secondEvaporativeCooler_->iddObject().type() << "."); } From 2477a8066eb0adec7537df1f7c08585c8e5deb13 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 16 Jan 2025 15:48:01 +0100 Subject: [PATCH 18/24] Rewrite the FT and fix the issue where it was checking the type of the OS:XXX object This is now impossible to do because I've scoped the variable. --- ...TranslateZoneHVACEvaporativeCoolerUnit.cpp | 182 +++++++++--------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index e35af2745f..cd537de15b 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -54,6 +54,30 @@ namespace energyplus { boost::optional ForwardTranslator::translateZoneHVACEvaporativeCoolerUnit(model::ZoneHVACEvaporativeCoolerUnit& modelObject) { + boost::optional i_firstEvaporativeCooler_; + { + HVACComponent firstEvaporativeCooler = modelObject.firstEvaporativeCooler(); + i_firstEvaporativeCooler_ = translateAndMapModelObject(firstEvaporativeCooler); + if (!i_firstEvaporativeCooler_) { + LOG(Error, "ZoneHVACEvaporativeCoolerUnit '" << modelObject.nameString() << "', could not translate required First Evaporative Cooler:" + << firstEvaporativeCooler.briefDescription()); + return boost::none; + } + } + + boost::optional i_fan_; + { + HVACComponent supplyAirFan = modelObject.supplyAirFan(); + i_fan_ = translateAndMapModelObject(supplyAirFan); + if (!i_fan_) { + LOG(Error, "ZoneHVACEvaporativeCoolerUnit '" << modelObject.nameString() + << "', could not translate required Supply Air Fan:" << supplyAirFan.briefDescription()); + return boost::none; + } + } + + // i_firstEvaporativeCooler_ and i_fan_ are always initialized now + // Instantiate an IdfObject of the class to store the values IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EvaporativeCoolerUnit, modelObject); @@ -91,13 +115,8 @@ namespace energyplus { // Supply Air Fan Object Type // Supply Air Fan Name - HVACComponent supplyAirFan_ = modelObject.supplyAirFan(); - boost::optional fan_ = translateAndMapModelObject(supplyAirFan_); - - if (fan_ && fan_->name()) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name()); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, fan_->nameString()); - } + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, i_fan_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName, i_fan_->nameString()); if (modelObject.isDesignSupplyAirFlowRateAutosized()) { idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate, "Autosize"); @@ -108,6 +127,7 @@ namespace energyplus { // Fan Placement: Required String const std::string fanPlacement = modelObject.fanPlacement(); + const bool blowThroughFan = istringEqual(fanPlacement, "BlowThrough"); idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FanPlacement, fanPlacement); // Cooler Unit Control Method: Required String @@ -125,41 +145,32 @@ namespace energyplus { // First Evaporative Cooler Object Type: Required String // First Evaporative Cooler Object Name: Required Object - HVACComponent firstEvaporativeCooler = modelObject.firstEvaporativeCooler(); - boost::optional firstEvaporativeCooler_ = translateAndMapModelObject(firstEvaporativeCooler); - if (firstEvaporativeCooler_) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType, firstEvaporativeCooler_->iddObject().name()); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName, firstEvaporativeCooler_->nameString()); - } + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectType, i_firstEvaporativeCooler_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::FirstEvaporativeCoolerObjectName, i_firstEvaporativeCooler_->nameString()); // Second Evaporative Cooler Object Type: boost::optional // Second Evaporative Cooler Name: Optional Object - boost::optional _secondEvaporativeCooler = modelObject.secondEvaporativeCooler(); - boost::optional secondEvaporativeCooler_; - if (_secondEvaporativeCooler) { - secondEvaporativeCooler_ = translateAndMapModelObject(_secondEvaporativeCooler.get()); - if (secondEvaporativeCooler_) { - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType, secondEvaporativeCooler_->iddObject().name()); - idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, secondEvaporativeCooler_->nameString()); + boost::optional i_secondEvaporativeCooler_; + if (boost::optional secondEvaporativeCooler_ = modelObject.secondEvaporativeCooler()) { + i_secondEvaporativeCooler_ = translateAndMapModelObject(*secondEvaporativeCooler_); + if (i_secondEvaporativeCooler_) { + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerObjectType, i_secondEvaporativeCooler_->iddObject().name()); + idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName, i_secondEvaporativeCooler_->nameString()); } } - // If BlowThrough: o---- Fan ---- E1 ---- E2 ----o - // If DrawThrough: o---- E1 ---- E2 ---- Fan ----o + // If BlowThrough: o---- Fan ---- E1 (---- E2) ----o + // If DrawThrough: o---- E1 (---- E2) ---- Fan ----o std::string baseName = modelObject.nameString(); - if (fan_) { + // if (i_fan_) is always true + { + std::string inletNodeName; std::string outletNodeName; - std::string inletNodeName = outdoorAirInletNodeName; - if (istringEqual(fanPlacement, "BlowThrough")) { - if (firstEvaporativeCooler_) { - outletNodeName = baseName + " Fan - First Evaporative Cooler Node"; - } else if (secondEvaporativeCooler_) { - outletNodeName = baseName + " Fan - Second Evaporative Cooler Node"; - } else { - outletNodeName = coolerOutletNodeName; - } + if (blowThroughFan) { + inletNodeName = outdoorAirInletNodeName; + outletNodeName = baseName + " Fan - First Evaporative Cooler Node"; } else { - if (secondEvaporativeCooler_) { + if (i_secondEvaporativeCooler_) { inletNodeName = baseName + " Second Evaporative Cooler - Fan Node"; } else { inletNodeName = baseName + " First Evaporative Cooler - Fan Node"; @@ -167,88 +178,77 @@ namespace energyplus { outletNodeName = coolerOutletNodeName; } - if (fan_->iddObject().type() == IddObjectType::Fan_ConstantVolume) { - fan_->setString(Fan_ConstantVolumeFields::AirInletNodeName, inletNodeName); - fan_->setString(Fan_ConstantVolumeFields::AirOutletNodeName, outletNodeName); - } else if (fan_->iddObject().type() == IddObjectType::Fan_VariableVolume) { - fan_->setString(Fan_VariableVolumeFields::AirInletNodeName, inletNodeName); - fan_->setString(Fan_VariableVolumeFields::AirOutletNodeName, outletNodeName); - } else if (fan_->iddObject().type() == IddObjectType::Fan_OnOff) { - fan_->setString(Fan_OnOffFields::AirInletNodeName, inletNodeName); - fan_->setString(Fan_OnOffFields::AirOutletNodeName, outletNodeName); - } else if (fan_->iddObject().type() == IddObjectType::Fan_SystemModel) { - fan_->setString(Fan_SystemModelFields::AirInletNodeName, inletNodeName); - fan_->setString(Fan_SystemModelFields::AirOutletNodeName, outletNodeName); - } else if (fan_->iddObject().type() == IddObjectType::Fan_ComponentModel) { - fan_->setString(Fan_ComponentModelFields::AirInletNodeName, inletNodeName); - fan_->setString(Fan_ComponentModelFields::AirOutletNodeName, outletNodeName); + if (i_fan_->iddObject().type() == IddObjectType::Fan_ConstantVolume) { + i_fan_->setString(Fan_ConstantVolumeFields::AirInletNodeName, inletNodeName); + i_fan_->setString(Fan_ConstantVolumeFields::AirOutletNodeName, outletNodeName); + } else if (i_fan_->iddObject().type() == IddObjectType::Fan_VariableVolume) { + i_fan_->setString(Fan_VariableVolumeFields::AirInletNodeName, inletNodeName); + i_fan_->setString(Fan_VariableVolumeFields::AirOutletNodeName, outletNodeName); + } else if (i_fan_->iddObject().type() == IddObjectType::Fan_OnOff) { + i_fan_->setString(Fan_OnOffFields::AirInletNodeName, inletNodeName); + i_fan_->setString(Fan_OnOffFields::AirOutletNodeName, outletNodeName); + } else if (i_fan_->iddObject().type() == IddObjectType::Fan_SystemModel) { + i_fan_->setString(Fan_SystemModelFields::AirInletNodeName, inletNodeName); + i_fan_->setString(Fan_SystemModelFields::AirOutletNodeName, outletNodeName); + } else if (i_fan_->iddObject().type() == IddObjectType::Fan_ComponentModel) { + i_fan_->setString(Fan_ComponentModelFields::AirInletNodeName, inletNodeName); + i_fan_->setString(Fan_ComponentModelFields::AirOutletNodeName, outletNodeName); } } - if (firstEvaporativeCooler_) { - std::string outletNodeName; + // if (i_firstEvaporativeCooler_) is always true + { std::string inletNodeName; - if (istringEqual(fanPlacement, "BlowThrough") && fan_) { + std::string outletNodeName; + if (blowThroughFan) { inletNodeName = baseName + " Fan - First Evaporative Cooler Node"; + if (i_secondEvaporativeCooler_) { + outletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; + } else { + outletNodeName = coolerOutletNodeName; + } } else { inletNodeName = outdoorAirInletNodeName; - } - - if (secondEvaporativeCooler_) { - outletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; - } else if (istringEqual(fanPlacement, "BlowThrough")) { - outletNodeName = coolerOutletNodeName; - } else { outletNodeName = baseName + " First Evaporative Cooler - Fan Node"; } - if (firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { - firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); - firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); - firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); - } else if (firstEvaporativeCooler.iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { - firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); - firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); - firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); + if (i_firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { + i_firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); + i_firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); + i_firstEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); + } else if (i_firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { + i_firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); + i_firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); + i_firstEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); } else { - LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << firstEvaporativeCooler_->iddObject().type() << "."); + LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << i_firstEvaporativeCooler_->iddObject().type() << "."); } } - if (secondEvaporativeCooler_) { + if (i_secondEvaporativeCooler_) { + const std::string inletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; std::string outletNodeName; - std::string inletNodeName; - if (firstEvaporativeCooler_) { - inletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; - } else if (istringEqual(fanPlacement, "BlowThrough") && fan_) { - inletNodeName = baseName + " Fan - Second Evaporative Cooler Node"; + if (blowThroughFan) { + outletNodeName = coolerOutletNodeName; } else { - inletNodeName = outdoorAirInletNodeName; - } - - if (istringEqual(fanPlacement, "DrawThrough") && fan_) { outletNodeName = baseName + " Second Evaporative Cooler - Fan Node"; - } else { - outletNodeName = coolerOutletNodeName; } - if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { - secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); - secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); - secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); - } else if (secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { - secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); - secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); - secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); + if (i_secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { + i_secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirInletNodeName, inletNodeName); + i_secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::AirOutletNodeName, outletNodeName); + i_secondEvaporativeCooler_->setString(EvaporativeCooler_Direct_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); + } else if (i_secondEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial) { + i_secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirInletNodeName, inletNodeName); + i_secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::PrimaryAirOutletNodeName, outletNodeName); + i_secondEvaporativeCooler_->setString(EvaporativeCooler_Indirect_ResearchSpecialFields::SensorNodeName, coolerOutletNodeName); } else { - LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << secondEvaporativeCooler_->iddObject().type() << "."); + LOG(Warn, modelObject.briefDescription() << ": Contains an unsupported type " << i_secondEvaporativeCooler_->iddObject().type() << "."); } } // Shut Off Relative Humidity: boost::optional - if (boost::optional shutOffRelativeHumidity_ = modelObject.shutOffRelativeHumidity()) { - idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity, shutOffRelativeHumidity_.get()); - } + idfObject.setDouble(ZoneHVAC_EvaporativeCoolerUnitFields::ShutOffRelativeHumidity, modelObject.shutOffRelativeHumidity()); return idfObject; } // End of translate function From 73365b115ad80a1becd857ad86d9cd23056e3a77 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 16 Jan 2025 16:49:20 +0100 Subject: [PATCH 19/24] Fix Severe Node Connection error cf https://github.com/NREL/OpenStudio-resources/pull/215#issuecomment-2596041024 --- .../ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp index cd537de15b..e877912dae 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEvaporativeCoolerUnit.cpp @@ -162,6 +162,7 @@ namespace energyplus { // If BlowThrough: o---- Fan ---- E1 (---- E2) ----o // If DrawThrough: o---- E1 (---- E2) ---- Fan ----o std::string baseName = modelObject.nameString(); + // if (i_fan_) is always true { std::string inletNodeName; @@ -209,7 +210,11 @@ namespace energyplus { } } else { inletNodeName = outdoorAirInletNodeName; - outletNodeName = baseName + " First Evaporative Cooler - Fan Node"; + if (i_secondEvaporativeCooler_) { + outletNodeName = baseName + " First Evaporative Cooler - Second Evaporative Cooler Node"; + } else { + outletNodeName = baseName + " First Evaporative Cooler - Fan Node"; + } } if (i_firstEvaporativeCooler_->iddObject().type() == IddObjectType::EvaporativeCooler_Direct_ResearchSpecial) { From d3e1fe9873a63a940ceab9c1a20c00b360a5639c Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 16 Jan 2025 17:27:07 +0100 Subject: [PATCH 20/24] Adjust FT test after node connections got fixed --- .../Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index ed331a958f..b1b26160e3 100644 --- a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -42,6 +42,8 @@ #include "../../model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "../../model/EvaporativeCoolerIndirectResearchSpecial.hpp" #include "../../model/EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" +#include "../../model/Node.hpp" +#include "../../model/PortList.hpp" #include "../../model/ThermalZone.hpp" #include "../../model/Space.hpp" @@ -90,6 +92,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { Space s(m); s.setThermalZone(z); + z.inletPortList().modelObjects()[0].setName("Zone Air Inlet Node"); + z.exhaustPortList().modelObjects()[0].setName("Zone Air Exhaust Node"); + z.zoneAirNode().setName("Zone Air Node"); + const Workspace w = ft.translateModel(m); const auto idfObjs = w.getObjectsByType(IddObjectType::ZoneHVAC_EvaporativeCoolerUnit); ASSERT_EQ(1u, idfObjs.size()); @@ -98,11 +104,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::Name).get()); EXPECT_EQ(availabilitySchedule.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName).get()); EXPECT_TRUE(idfObject.isEmpty(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityManagerListName)); - EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airInletModelObject()->nameString(), + EXPECT_EQ("My ZoneHVACEvaporativeCoolerUnit Outdoor Air Node", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::OutdoorAirInletNodeName).get()); - EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airOutletModelObject()->nameString(), - idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); - EXPECT_TRUE(idfObject.isEmpty(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName)); + EXPECT_EQ("Zone Air Inlet Node", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::CoolerOutletNodeName).get()); + EXPECT_EQ("Zone Air Exhaust Node", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::ZoneReliefAirNodeName).get()); EXPECT_EQ("Fan:ComponentModel", idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType).get()); EXPECT_EQ(supplyAirFan.nameString(), idfObject.getString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanName).get()); EXPECT_EQ(0.9, idfObject.getDouble(ZoneHVAC_EvaporativeCoolerUnitFields::DesignSupplyAirFlowRate).get()); @@ -128,8 +133,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ZoneHVACEvaporativeCoolerUnit) { auto idf_secondEvaporativeCooler = idfObject.getTarget(ZoneHVAC_EvaporativeCoolerUnitFields::SecondEvaporativeCoolerName).get(); EXPECT_EQ(idf_secondEvaporativeCooler.iddObject().type(), IddObjectType::EvaporativeCooler_Indirect_ResearchSpecial); - EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.airInletModelObject()->nameString(), - idf_supplyAirFan.getString(Fan_ComponentModelFields::AirInletNodeName).get()); + EXPECT_EQ("My ZoneHVACEvaporativeCoolerUnit Outdoor Air Node", idf_supplyAirFan.getString(Fan_ComponentModelFields::AirInletNodeName).get()); EXPECT_EQ(zoneHVACEvaporativeCoolerUnit.nameString() + " Fan - First Evaporative Cooler Node", idf_supplyAirFan.getString(Fan_ComponentModelFields::AirOutletNodeName).get()); From b9e6f0ee75edc2391f881e1cac82988eee0626e0 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 16 Jan 2025 17:37:58 +0100 Subject: [PATCH 21/24] Add a TDB 3.9.1 release notes to mention the "Zone Relief Air Node Name" being always filled out --- ... => OpenStudio_Release_Notes_3_9_1_TDB.md} | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) rename developer/doc/ReleaseNotes/{OpenStudio_Release_Notes_3_9_0_TBD.md => OpenStudio_Release_Notes_3_9_1_TDB.md} (77%) diff --git a/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_9_0_TBD.md b/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_9_1_TDB.md similarity index 77% rename from developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_9_0_TBD.md rename to developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_9_1_TDB.md index 6cded456f3..9b78ef62b7 100644 --- a/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_9_0_TBD.md +++ b/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_9_1_TDB.md @@ -1,8 +1,8 @@ -# OpenStudio Version 3.9.0 +# OpenStudio Version 3.9.1 _Release Notes_ - _TDB_ -These release notes describe version 3.9.0 of the OpenStudio SDK developed by the National Renewable Energy Laboratory (NREL), Buildings and Thermal Sciences Center, Commercial Buildings Research Group, Tools Development Section, and associated collaborators. The notes are organized into the following sections: +These release notes describe version 3.9.1 of the OpenStudio SDK developed by the National Renewable Energy Laboratory (NREL), Buildings and Thermal Sciences Center, Commercial Buildings Research Group, Tools Development Section, and associated collaborators. The notes are organized into the following sections: - Overview - Where to Find OpenStudio Documentation @@ -15,7 +15,7 @@ As of April 2020, development and distribution of the OpenStudioApplication and Below is the list of components that is included in this SDK installer: -__**OpenStudio SDK 3.9.0**__ +__**OpenStudio SDK 3.9.1**__ - EnergyPlus - Command Line Interface (CLI) - Radiance @@ -34,16 +34,16 @@ __**OpenStudio SDK 3.9.0**__ # Installation Notes -OpenStudio SDK 3.9.0 is supported on: +OpenStudio SDK 3.9.1 is supported on: * 64-bit Windows 7 – 11 * macOS: 11.6+ x86_64, 12.1+ arm64 * Ubuntu: 20.04 x86_64, 22.04 x86_64, 22.04 arm64 * Centos7 -OpenStudio SDK 3.9.0 supports [EnergyPlus Release 24.2.0a](https://github.com/NREL/EnergyPlus/releases/tag/24.2.0a), which is bundled with the OpenStudio installer. It is no longer necessary to download and install EnergyPlus separately. Other builds of EnergyPlus are not supported by OpenStudio SDK 3.9.0. +OpenStudio SDK 3.9.1 supports [EnergyPlus Release @EP_VERSION@](https://github.com/NREL/EnergyPlus/releases/tag/v@EP_VERSION@), which is bundled with the OpenStudio installer. It is no longer necessary to download and install EnergyPlus separately. Other builds of EnergyPlus are not supported by OpenStudio SDK 3.9.1. -OpenStudio SDK 3.9.0 supports Radiance 5.0.a.12, which is bundled with the OpenStudio installer; users no longer must install Radiance separately, and OpenStudio will use the included Radiance version regardless of any other versions that may be installed on the system. Other builds of Radiance are not supported by OpenStudio SDK 3.9.0. +OpenStudio SDK 3.9.1 supports Radiance 5.0.a.12, which is bundled with the OpenStudio installer; users no longer must install Radiance separately, and OpenStudio will use the included Radiance version regardless of any other versions that may be installed on the system. Other builds of Radiance are not supported by OpenStudio SDK 3.9.1. As usual, you can refer to the **[OpenStudio SDK Compatibility Matrix](https://github.com/NREL/OpenStudio/wiki/OpenStudio-SDK-Version-Compatibility-Matrix)** for more information. @@ -57,7 +57,7 @@ For help with common installation problems please visit [Getting Started](http:/ # OpenStudio SDK: Changelog -The 3.9.0 is a **major** release. This update includes several new features, performance improvements, and bug fixes. +The 3.9.1 is a **** release. This update includes several new features, performance improvements, and bug fixes. ## C++ Workflow code @@ -67,7 +67,7 @@ As of OpenStudio SDK 3.7.0 a re-written workflow written in C++ is used by defau As of OpenStudio SDK 3.2.0, Python bindings are officially supported and distributed through Python Package Index (PyPI). To install, users will need to have Python3 installed along with pip and simply run the following command in a terminal window. -`pip install openstudio==3.9.0` +`pip install openstudio==3.9.1` Please see [openstudio on PyPi](https://pypi.org/project/openstudio/) for further instructions on how to install. Users can also visit the test channel at [openstudio on TestPyPi](https://test.pypi.org/project/openstudio/) to install development bindings. @@ -75,20 +75,15 @@ You can also refer to the [OpenStudio SDK Python Binding Version Compatibility M ## New Features, Major Fixes and API-breaking changes -* [#5242](https://github.com/NREL/OpenStudio/pull/5242) - Update to EnergyPlus v24.2.0a - * To see the full list of additions and changes, refer to the issue [#5240](https://github.com/NREL/OpenStudio/issues/5240) - -* [#5237](https://github.com/NREL/OpenStudio/pull/5237) - Updates to Controller:OutdoorAir - * This PR implements the fields `Humidistat Control Zone Name` and `Electronic Enthalpy Limit Curve` - * `ControllerOutdoorAir` has two API-breaking changes for `High Humidity Outdoor Air Flow Ratio` and `Control High Indoor Humidity Based on Outdoor Humidity Ratio`. These fields are now-required, so the getters no longer return an optional - * `getHighHumidityOutdoorAirFlowRatio` (`boost::optional` to `double`) - * `getControlHighIndoorHumidityBasedOnOutdoorHumidityRatio` (`boost::optional` to `bool`) +* [#5326](https://github.com/NREL/OpenStudio/pull/5326) - Wrap ZoneHVAC:EvaporativeCoolerUnit + * The object was wrapped in the SDK. + * Note: in EnergyPlus 24.2.0, the `Zone Relief Air Node Name` is an optional field. The OpenStudio SDK always fills with the connected zone's Exhaust Air Node, meaning the airflow is always being balanced by EnergyPlus: the object will extract air from the zone to balance the air supplied to the zone by the cooler outlet node. ## Minor changes and bug fixes -Refer to the changelog on the release page at [v3.9.0](https://github.com/NREL/OpenStudio/releases/v3.9.0) +Refer to the changelog on the release page at [v3.9.1](https://github.com/NREL/OpenStudio/releases/v3.9.1) -**Full Changelog**: https://github.com/NREL/OpenStudio/compare/v3.9.0...v3.9.0 +**Full Changelog**: https://github.com/NREL/OpenStudio/compare/v3.9.0...v3.9.1 **New Contributors**: @@ -106,7 +101,7 @@ In addition to some refactoring, this release also included conversion of 90.1 d --- # This YAML header controls the pandoc (via TeX) to PDF settings # To convert the markdown to pdf, do `pandoc release_notes.md -o release_notes.pdf` -title: 'OpenStudio Release Notes - 3.9.0' +title: 'OpenStudio Release Notes - 3.9.1' author: - National Renewable Energy Laboratory colorlinks: true From 65526d35c03b586e92eb6fb46bb4595ed04cc875 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Fri, 17 Jan 2025 09:53:58 -0700 Subject: [PATCH 22/24] Change ctor to fansystemmodel, and update some tests. --- src/model/Model.cpp | 6 ++-- src/model/ZoneHVACEvaporativeCoolerUnit.cpp | 6 ++-- .../ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 28 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/model/Model.cpp b/src/model/Model.cpp index bfe9fd1cb2..38a56fb71d 100644 --- a/src/model/Model.cpp +++ b/src/model/Model.cpp @@ -2254,9 +2254,9 @@ namespace model { if (!openstudio::equal(inputResult, outputResult, tol)) { LOG_FREE(logLevel, "openstudio.model.Model", "The " << attributeName << " values determined for " << object.briefDescription() - << " using input and output data differ by a (relative) error " << "greater than " << tol - << ". The value calculated from input data was " << inputResult << ", whereas the value calculated from output data was " - << outputResult << "."); + << " using input and output data differ by a (relative) error " + << "greater than " << tol << ". The value calculated from input data was " << inputResult + << ", whereas the value calculated from output data was " << outputResult << "."); return false; } return true; diff --git a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp index eeb508b922..37b35e6506 100644 --- a/src/model/ZoneHVACEvaporativeCoolerUnit.cpp +++ b/src/model/ZoneHVACEvaporativeCoolerUnit.cpp @@ -38,8 +38,8 @@ #include "HVACComponent_Impl.hpp" #include "ScheduleTypeLimits.hpp" #include "ScheduleTypeRegistry.hpp" -#include "FanComponentModel.hpp" -#include "FanComponentModel_Impl.hpp" +#include "FanSystemModel.hpp" +#include "FanSystemModel_Impl.hpp" #include "EvaporativeCoolerDirectResearchSpecial.hpp" #include "EvaporativeCoolerDirectResearchSpecial_Impl.hpp" @@ -343,7 +343,7 @@ namespace model { ok = setAvailabilitySchedule(alwaysOn); OS_ASSERT(ok); - FanComponentModel supplyAirFan(model); + FanSystemModel supplyAirFan(model); ok = setSupplyAirFan(supplyAirFan); OS_ASSERT(ok); diff --git a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index 8bb3bf2f3c..f9c0a7fdb2 100644 --- a/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -35,8 +35,8 @@ #include "../Schedule_Impl.hpp" #include "../ScheduleConstant.hpp" #include "../ScheduleConstant_Impl.hpp" -#include "../FanComponentModel.hpp" -#include "../FanComponentModel_Impl.hpp" +#include "../FanSystemModel.hpp" +#include "../FanSystemModel_Impl.hpp" #include "../EvaporativeCoolerDirectResearchSpecial.hpp" #include "../EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "../EvaporativeCoolerIndirectResearchSpecial.hpp" @@ -68,7 +68,7 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_GettersSetters) { EXPECT_EQ(availabilitySchedule, zoneHVACEvaporativeCoolerUnit.availabilitySchedule()); // Supply Air Fan Name: Required Object - FanComponentModel supplyAirFan(m); + FanSystemModel supplyAirFan(m); EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSupplyAirFan(supplyAirFan)); EXPECT_EQ(supplyAirFan, zoneHVACEvaporativeCoolerUnit.supplyAirFan()); @@ -167,13 +167,13 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToThermalZone) { TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { Model m; - FanComponentModel fan(m); + FanSystemModel fan(m); Schedule availabilitySchedule = m.alwaysOnDiscreteSchedule(); EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(m, availabilitySchedule); ZoneHVACEvaporativeCoolerUnit zonehvac(m, availabilitySchedule, fan, firstEvaporativeCooler); EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m); EXPECT_TRUE(zonehvac.setSecondEvaporativeCooler(secondEvaporativeCooler)); - EXPECT_EQ(1u, m.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m.getConcreteModelObjects().size()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); EXPECT_EQ(1u, m.getConcreteModelObjects().size()); @@ -192,7 +192,7 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler()); EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle()); - EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); + EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); EXPECT_EQ(1u, m2.getConcreteModelObjects().size()); } @@ -206,7 +206,7 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) { EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle()); ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler()); EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle()); - EXPECT_EQ(2u, m.getConcreteModelObjects().size()); + EXPECT_EQ(2u, m.getConcreteModelObjects().size()); EXPECT_EQ(2u, m.getConcreteModelObjects().size()); EXPECT_EQ(2u, m.getConcreteModelObjects().size()); } @@ -216,11 +216,11 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_remove) { Model m; ZoneHVACEvaporativeCoolerUnit zonehvac(m); - auto fanComponent = zonehvac.supplyAirFan(); - ASSERT_TRUE(fanComponent.optionalCast()); - EXPECT_TRUE(fanComponent.containingZoneHVACComponent()); - EXPECT_EQ(zonehvac.handle(), fanComponent.containingZoneHVACComponent().get().handle()); - EXPECT_FALSE(fanComponent.isRemovable()); + auto fanSystem = zonehvac.supplyAirFan(); + ASSERT_TRUE(fanSystem.optionalCast()); + EXPECT_TRUE(fanSystem.containingZoneHVACComponent()); + EXPECT_EQ(zonehvac.handle(), fanSystem.containingZoneHVACComponent().get().handle()); + EXPECT_FALSE(fanSystem.isRemovable()); auto evapCoolerComponent = zonehvac.firstEvaporativeCooler(); ASSERT_TRUE(evapCoolerComponent.optionalCast()); @@ -230,7 +230,7 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_remove) { auto size = m.modelObjects().size(); EXPECT_EQ(1, m.getConcreteModelObjects().size()); - EXPECT_EQ(1, m.getConcreteModelObjects().size()); + EXPECT_EQ(1, m.getConcreteModelObjects().size()); EXPECT_EQ(1, m.getConcreteModelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(1, m.getConcreteModelObjects().size()); @@ -238,7 +238,7 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_remove) { EXPECT_FALSE(zonehvac.remove().empty()); EXPECT_EQ(size - 3, m.modelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); - EXPECT_EQ(0, m.getConcreteModelObjects().size()); + EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(0, m.getConcreteModelObjects().size()); EXPECT_EQ(1, m.getConcreteModelObjects().size()); From b510cdd976162b8e260417cad71be7789198d90c Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Fri, 17 Jan 2025 10:55:55 -0700 Subject: [PATCH 23/24] Fix ft test after ctor fan change. --- .../Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index b1b26160e3..ce04244809 100644 --- a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -38,6 +38,8 @@ #include "../../model/Schedule_Impl.hpp" #include "../../model/FanComponentModel.hpp" #include "../../model/FanComponentModel_Impl.hpp" +#include "../../model/FanSystemModel.hpp" +#include "../../model/FanSystemModel_Impl.hpp" #include "../../model/EvaporativeCoolerDirectResearchSpecial.hpp" #include "../../model/EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "../../model/EvaporativeCoolerIndirectResearchSpecial.hpp" @@ -55,6 +57,7 @@ #include #include #include +#include #include #include @@ -163,7 +166,7 @@ std::vector getEvaporativeCoolerUnitNodes(const Workspace& workspac } std::vector getSupplyAirFanNodes(const Workspace& workspace) { - WorkspaceObjectVector idfFans(workspace.getObjectsByType(IddObjectType::Fan_ComponentModel)); + WorkspaceObjectVector idfFans(workspace.getObjectsByType(IddObjectType::Fan_SystemModel)); if (idfFans.empty()) { return {}; } @@ -171,8 +174,8 @@ std::vector getSupplyAirFanNodes(const Workspace& workspace) { auto& idfFan = idfFans[0]; return { - idfFan.getString(Fan_ComponentModelFields::AirInletNodeName).get(), - idfFan.getString(Fan_ComponentModelFields::AirOutletNodeName).get(), + idfFan.getString(Fan_SystemFields::AirInletNodeName).get(), + idfFan.getString(Fan_SystemFields::AirOutletNodeName).get(), }; } From f8c27b85a2b8f8c03a5527590410a892e965b96d Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Fri, 17 Jan 2025 11:33:14 -0700 Subject: [PATCH 24/24] Fix FT test. --- src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp index ce04244809..a0e13d3bcf 100644 --- a/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp +++ b/src/energyplus/Test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp @@ -174,8 +174,8 @@ std::vector getSupplyAirFanNodes(const Workspace& workspace) { auto& idfFan = idfFans[0]; return { - idfFan.getString(Fan_SystemFields::AirInletNodeName).get(), - idfFan.getString(Fan_SystemFields::AirOutletNodeName).get(), + idfFan.getString(Fan_SystemModelFields::AirInletNodeName).get(), + idfFan.getString(Fan_SystemModelFields::AirOutletNodeName).get(), }; }