diff --git a/resources/energyplus/ProposedEnergy+.idd b/resources/energyplus/ProposedEnergy+.idd index 2d545c31f7c..e3615f10522 100644 --- a/resources/energyplus/ProposedEnergy+.idd +++ b/resources/energyplus/ProposedEnergy+.idd @@ -43458,10 +43458,10 @@ Chiller:Electric:EIR, A17, \field Condenser Flow Control \note Select the chiller condenser flow request mode. With "ConstantFlow" a chiller will always request \note its maximum condenser flow rate. With "ModulatedChillerPLR" the condenser flow request corresponds - \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With - \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water + \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With + \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water \note loop's part load ratio, see the "Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio - \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet + \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet \note the condenser loop load based on the condenser leaving fluid temperature and a reference temperature, \note see the "Temperature Difference Across Condenser" and "Temperature Difference Across Condenser Schedule \note Name" input. @@ -43475,7 +43475,7 @@ Chiller:Electric:EIR, \default ConstantFlow A18, \field Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name \note Condenser loop flow rate fraction as a function of loop part load ratio - \note CWFR = C * PLR + D + \note CWFR = C * PLR + D \note Where: \note CWFR is the condenser water flow fraction (actual/design) \note C and D are coefficients, see "Optimizing Design & Control Of Chilled Water Plants, Part 5", S. Taylor, ASHRAE Journal June 2012 @@ -43483,7 +43483,7 @@ Chiller:Electric:EIR, \type object-list \object-list UnivariateFunctions A19, \field Temperature Difference Across Condenser Schedule Name - \note A schedule that defines the temperature difference across the condenser. This input is used to + \note A schedule that defines the temperature difference across the condenser. This input is used to \note calculate the condenser flow. This input is only used when "Condenser Flow Control" is set to \note "ModulatedDeltaTemperature". \type object-list @@ -43707,10 +43707,10 @@ Chiller:Electric:ReformulatedEIR, A16, \field Condenser Flow Control \note Select the chiller condenser flow request mode. With "ConstantFlow" a chiller will always request \note its maximum condenser flow rate. With "ModulatedChillerPLR" the condenser flow request corresponds - \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With - \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water + \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With + \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water \note loop's part load ratio, see the "Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio - \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet + \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet \note the condenser loop load based on the condenser leaving fluid temperature and a reference temperature, \note see the "Temperature Difference Across Condenser" and "Temperature Difference Across Condenser Schedule \note Name" input. @@ -43724,7 +43724,7 @@ Chiller:Electric:ReformulatedEIR, \default ConstantFlow A17, \field Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name \note Condenser loop flow rate fraction as a function of loop part load ratio - \note CWFR = C * PLR + D + \note CWFR = C * PLR + D \note Where: \note CWFR is the condenser water flow fraction (actual/design) \note C and D are coefficients, see "Optimizing Design & Control Of Chilled Water Plants, Part 5", S. Taylor, ASHRAE Journal June 2012 @@ -43732,7 +43732,7 @@ Chiller:Electric:ReformulatedEIR, \type object-list \object-list UnivariateFunctions A18, \field Temperature Difference Across Condenser Schedule Name - \note A schedule that defines the temperature difference across the condenser. This input is used to + \note A schedule that defines the temperature difference across the condenser. This input is used to \note calculate the condenser flow. This input is only used when "Condenser Flow Control" is set to \note "ModulatedDeltaTemperature". \type object-list @@ -45259,7 +45259,7 @@ HeatPump:PlantLoop:EIR:Cooling, \note curve = a + b*CWS + c*CWS**2 + d*ECT + e*ECT**2 + f*CWS*ECT \note CWS = supply (leaving) chilled water temperature(C) \note ECT = entering condenser fluid temperature(C) - \note If this field is blank, the AWHP curve without heat recovery will be used + \note If this field is blank, the AWHP curve without heat recovery will be used A19, \field Thermosiphon Capacity Fraction Curve Name \type object-list \object-list UnivariateFunctions @@ -45513,7 +45513,7 @@ HeatPump:PlantLoop:EIR:Heating, \note curve = a + b*HWS + c*HWS**2 + d*ECT + e*ECT**2 + f*HWS*ECT \note HWS = supply (leaving) hot water temperature(C) \note ECT = entering condenser fluid temperature(C) - \note If this field is blank, the AWHP curve without heat recovery will be used + \note If this field is blank, the AWHP curve without heat recovery will be used HeatPump:AirToWater:FuelFired:Heating, \memo The object defines a fuel-fired absorption heat pump based on equation-fit models. diff --git a/resources/model/OpenStudio.idd b/resources/model/OpenStudio.idd index beb79d9b3fb..149165355fb 100644 --- a/resources/model/OpenStudio.idd +++ b/resources/model/OpenStudio.idd @@ -14290,7 +14290,7 @@ OS:HeatPump:PlantLoop:EIR:Heating, \note curve = a + b*HWS + c*HWS**2 + d*ECT + e*ECT**2 + f*HWS*ECT \note HWS = supply (leaving) hot water temperature(C) \note ECT = entering condenser fluid temperature(C) - \note If this field is blank, the AWHP curve without heat recovery will be used + \note If this field is blank, the AWHP curve without heat recovery will be used OS:HeatPump:PlantLoop:EIR:Cooling, \memo An EIR formulated water to water heat pump model, cooling operation. @@ -14471,7 +14471,7 @@ OS:HeatPump:PlantLoop:EIR:Cooling, \note curve = a + b*CWS + c*CWS**2 + d*ECT + e*ECT**2 + f*CWS*ECT \note CWS = supply (leaving) chilled water temperature(C) \note ECT = entering condenser fluid temperature(C) - \note If this field is blank, the AWHP curve without heat recovery will be used + \note If this field is blank, the AWHP curve without heat recovery will be used A18,\field Thermosiphon Capacity Fraction Curve Name \type object-list \object-list UnivariateFunctions @@ -15048,10 +15048,10 @@ OS:Chiller:Electric:EIR, A18, \field Condenser Flow Control \note Select the chiller condenser flow request mode. With "ConstantFlow" a chiller will always request \note its maximum condenser flow rate. With "ModulatedChillerPLR" the condenser flow request corresponds - \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With - \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water + \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With + \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water \note loop's part load ratio, see the "Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio - \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet + \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet \note the condenser loop load based on the condenser leaving fluid temperature and a reference temperature, \note see the "Temperature Difference Across Condenser" and "Temperature Difference Across Condenser Schedule \note Name" input. @@ -15065,7 +15065,7 @@ OS:Chiller:Electric:EIR, \required-field A19, \field Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name \note Condenser loop flow rate fraction as a function of loop part load ratio - \note CWFR = C * PLR + D + \note CWFR = C * PLR + D \note Where: \note CWFR is the condenser water flow fraction (actual/design) \note C and D are coefficients, see "Optimizing Design & Control Of Chilled Water Plants, Part 5", S. Taylor, ASHRAE Journal June 2012 @@ -15073,7 +15073,7 @@ OS:Chiller:Electric:EIR, \type object-list \object-list UnivariateFunctions A20, \field Temperature Difference Across Condenser Schedule Name - \note A schedule that defines the temperature difference across the condenser. This input is used to + \note A schedule that defines the temperature difference across the condenser. This input is used to \note calculate the condenser flow. This input is only used when "Condenser Flow Control" is set to \note "ModulatedDeltaTemperature". \type object-list @@ -15300,7 +15300,7 @@ OS:Chiller:Electric:ReformulatedEIR, \note Using this triggers a model more suited to series bundle and chillers with higher temperature heat recovery \note If this field is not used, the bundles are modeled as being in parallel \type object-list - \object-list ConnectionNames + \object-list Node A16, \field End-Use Subcategory \note Any text may be used here to categorize the end-uses in the ABUPS End Uses by Subcategory table. \type alpha @@ -15309,10 +15309,10 @@ OS:Chiller:Electric:ReformulatedEIR, A17, \field Condenser Flow Control \note Select the chiller condenser flow request mode. With "ConstantFlow" a chiller will always request \note its maximum condenser flow rate. With "ModulatedChillerPLR" the condenser flow request corresponds - \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With - \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water + \note to the chiller part load ratio multiplied by the chiller maximum condenser flow rate. With + \note "ModulatedLoopPLR" the chiller will request a flow rate that is function of the chilled water \note loop's part load ratio, see the "Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio - \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet + \note Curve Name" input. With "ModulatedDeltaTemperature" the chiller will request the flow rate required to meet \note the condenser loop load based on the condenser leaving fluid temperature and a reference temperature, \note see the "Temperature Difference Across Condenser" and "Temperature Difference Across Condenser Schedule \note Name" input. @@ -15326,7 +15326,7 @@ OS:Chiller:Electric:ReformulatedEIR, \required-field A18, \field Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name \note Condenser loop flow rate fraction as a function of loop part load ratio - \note CWFR = C * PLR + D + \note CWFR = C * PLR + D \note Where: \note CWFR is the condenser water flow fraction (actual/design) \note C and D are coefficients, see "Optimizing Design & Control Of Chilled Water Plants, Part 5", S. Taylor, ASHRAE Journal June 2012 @@ -15334,7 +15334,7 @@ OS:Chiller:Electric:ReformulatedEIR, \type object-list \object-list UnivariateFunctions A19, \field Temperature Difference Across Condenser Schedule Name - \note A schedule that defines the temperature difference across the condenser. This input is used to + \note A schedule that defines the temperature difference across the condenser. This input is used to \note calculate the condenser flow. This input is only used when "Condenser Flow Control" is set to \note "ModulatedDeltaTemperature". \type object-list diff --git a/src/energyplus/CMakeLists.txt b/src/energyplus/CMakeLists.txt index 111f254b1f0..ab463994554 100644 --- a/src/energyplus/CMakeLists.txt +++ b/src/energyplus/CMakeLists.txt @@ -687,6 +687,8 @@ set(${target_name}_test_src Test/BoilerHotWater_GTest.cpp Test/Building_GTest.cpp Test/ChillerElectricASHRAE205_GTest.cpp + Test/ChillerElectricEIR_GTest.cpp + Test/ChillerElectricReformulatedEIR_GTest.cpp Test/CentralHeatPumpSystem_GTest.cpp Test/CoilCoolingDX_GTest.cpp Test/CoilCoolingDXCurveFitPerformance_GTest.cpp @@ -799,6 +801,7 @@ set(${target_name}_test_src Test/ShadingSurface_GTest.cpp Test/ShadowCalculation_GTest.cpp Test/SimulationControl_GTest.cpp + Test/Site_GTest.cpp Test/SiteGroundTemperatureUndisturbedKusudaAchenbach_GTest.cpp Test/SiteGroundTemperatureUndisturbedXing_GTest.cpp Test/SizingSystem_GTest.cpp diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricEIR.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricEIR.cpp index c165adf298a..a724374b553 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricEIR.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricEIR.cpp @@ -293,9 +293,7 @@ namespace energyplus { } // Condenser Minimum Flow Fraction - if ((value = modelObject.condenserMinimumFlowFraction())) { - idfObject.setDouble(Chiller_Electric_EIRFields::CondenserMinimumFlowFraction, value.get()); - } + idfObject.setDouble(Chiller_Electric_EIRFields::CondenserMinimumFlowFraction, modelObject.condenserMinimumFlowFraction()); // Thermosiphon Capacity Fraction Curve Name if (boost::optional thermosiphonCapacityFractionCurve_ = modelObject.thermosiphonCapacityFractionCurve()) { diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricReformulatedEIR.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricReformulatedEIR.cpp index 9003aa7531f..42ffea72a60 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricReformulatedEIR.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateChillerElectricReformulatedEIR.cpp @@ -237,9 +237,7 @@ namespace energyplus { } // Condenser Minimum Flow Fraction - if ((value = modelObject.condenserMinimumFlowFraction())) { - idfObject.setDouble(Chiller_Electric_ReformulatedEIRFields::CondenserMinimumFlowFraction, value.get()); - } + idfObject.setDouble(Chiller_Electric_ReformulatedEIRFields::CondenserMinimumFlowFraction, modelObject.condenserMinimumFlowFraction()); // Thermosiphon Capacity Fraction Curve Name if (boost::optional thermosiphonCapacityFractionCurve_ = modelObject.thermosiphonCapacityFractionCurve()) { diff --git a/src/energyplus/Test/ChillerElectricEIR_GTest.cpp b/src/energyplus/Test/ChillerElectricEIR_GTest.cpp new file mode 100644 index 00000000000..e31e8bd73bf --- /dev/null +++ b/src/energyplus/Test/ChillerElectricEIR_GTest.cpp @@ -0,0 +1,317 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. +* See also https://openstudio.net/license +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ForwardTranslator.hpp" + +#include "../../model/ChillerElectricEIR.hpp" +#include "../../model/ChillerElectricEIR_Impl.hpp" + +#include "../../model/CurveBiquadratic.hpp" +#include "../../model/CurveLinear.hpp" +#include "../../model/CurveQuadratic.hpp" +#include "../../model/PlantLoop.hpp" +#include "../../model/PlantLoop_Impl.hpp" +#include "../../model/Node.hpp" +#include "../../model/Node_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/ScheduleConstant.hpp" +#include "../../model/Mixer.hpp" +#include "../../model/Splitter.hpp" + +#include "../../utilities/geometry/Point3d.hpp" + +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/WorkspaceObject.hpp" +#include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +// E+ FieldEnums +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include "../../utilities/core/PathHelpers.hpp" + +#include +#include + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +/* Ensures that the nodes that translated correctly + * that means correct node names in the ChillerElectricASHRAE205 but also + * on the Branches + */ +TEST_F(EnergyPlusFixture, ForwardTranslator_ChillerElectricEIR) { + + ForwardTranslator ft; + + Model m; + + auto createLoop = [&m](const std::string& prefix) { + PlantLoop p(m); + static constexpr std::array compNames = { + "Supply Inlet", "Supply Splitter", "Supply Connection Node", "Supply Mixer", "Supply Outlet", + "Demand Inlet", "Demand Splitter", "Demand Connection Node", "Demand Mixer", "Demand Outlet", + }; + p.setName(prefix); + for (size_t i = 0; auto& comp : p.components()) { + comp.setName(prefix + " " + std::string{compNames[i++]}); + } + return p; + }; + + ChillerElectricEIR ch(m); + + ch.setName("My ChillerElectricEIR"); + + // Reference Capacity: Required Double + // Autosize + EXPECT_TRUE(ch.setReferenceCapacity(30000.0)); + EXPECT_TRUE(ch.setReferenceCOP(4.5)); + EXPECT_TRUE(ch.setReferenceLeavingChilledWaterTemperature(7.0)); + EXPECT_TRUE(ch.setReferenceEnteringCondenserFluidTemperature(30.0)); + EXPECT_TRUE(ch.setReferenceChilledWaterFlowRate(3.0)); + EXPECT_TRUE(ch.setReferenceCondenserFluidFlowRate(4.0)); + + // Cooling Capacity Function of Temperature Curve Name: Required Object + ch.coolingCapacityFunctionOfTemperature().setName("capfT"); + + // Electric Input to Cooling Output Ratio Function of Temperature Curve Name: Required Object + ch.electricInputToCoolingOutputRatioFunctionOfTemperature().setName("EIRfT"); + + // Electric Input to Cooling Output Ratio Function of Part Load Ratio Curve Name: Required Object + ch.electricInputToCoolingOutputRatioFunctionOfPLR().setName("EIRfPLR"); + + EXPECT_TRUE(ch.setMinimumPartLoadRatio(0.1)); + EXPECT_TRUE(ch.setMaximumPartLoadRatio(1.3)); + EXPECT_TRUE(ch.setOptimumPartLoadRatio(0.8)); + EXPECT_TRUE(ch.setMinimumUnloadingRatio(0.2)); + + // Chilled Water Inlet Node Name: Required Object + // Chilled Water Outlet Node Name: Required Object + auto chwLoop = createLoop("chwLoop"); + EXPECT_TRUE(chwLoop.addSupplyBranchForComponent(ch)); + ch.supplyInletModelObject()->setName("ChilledWater Inlet Node"); + ch.supplyOutletModelObject()->setName("ChilledWater Outlet Node"); + + // Condenser Inlet Node Name: Optional Object + // Condenser Outlet Node Name: Optional Object + auto cndLoop = createLoop("cndLoop"); + EXPECT_TRUE(cndLoop.addDemandBranchForComponent(ch)); + ch.demandInletModelObject()->setName("Condenser Inlet Node"); + ch.demandOutletModelObject()->setName("Condenser Outlet Node"); + + // Condenser Type + + EXPECT_TRUE(ch.setCondenserFanPowerRatio(1.1)); + EXPECT_TRUE(ch.setFractionofCompressorElectricConsumptionRejectedbyCondenser(0.957)); + EXPECT_TRUE(ch.setLeavingChilledWaterLowerTemperatureLimit(2.3)); + EXPECT_EQ(2.3, ch.leavingChilledWaterLowerTemperatureLimit()); + EXPECT_TRUE(ch.setChillerFlowMode("LeavingSetpointModulated")); + EXPECT_TRUE(ch.setDesignHeatRecoveryWaterFlowRate(2.5)); + + // Heat Recovery Inlet Node Name: Optional Object + // Heat Recovery Outlet Node Name: Optional Object + auto hwLoop = createLoop("HWLoop"); + EXPECT_TRUE(hwLoop.addDemandBranchForComponent(ch)); + + ch.tertiaryInletModelObject()->setName("Heat Recovery Inlet Node"); + ch.tertiaryOutletModelObject()->setName("Heat Recovery Outlet Node"); + + EXPECT_TRUE(ch.setSizingFactor(1.8)); + EXPECT_TRUE(ch.setBasinHeaterCapacity(2000.0)); + + // Basin Heater Setpoint Temperature: Optional Double + EXPECT_TRUE(ch.setBasinHeaterSetpointTemperature(5.0)); + + // Basin Heater Operating Schedule Name: Optional Object + ScheduleConstant basinHeaterOperatingSchedule(m); + basinHeaterOperatingSchedule.setName("basinHeaterOperatingSchedule"); + EXPECT_TRUE(ch.setBasinHeaterSchedule(basinHeaterOperatingSchedule)); + + // Condenser Heat Recovery Relative Capacity Fraction: Required Double + EXPECT_TRUE(ch.setCondenserHeatRecoveryRelativeCapacityFraction(0.97)); + + // Heat Recovery Inlet High Temperature Limit Schedule Name: Optional Object + ScheduleConstant heatRecoveryInletHighTemperatureLimitSchedule(m); + heatRecoveryInletHighTemperatureLimitSchedule.setName("heatRecoveryInletHighTemperatureLimitSchedule"); + EXPECT_TRUE(ch.setHeatRecoveryInletHighTemperatureLimitSchedule(heatRecoveryInletHighTemperatureLimitSchedule)); + + // Heat Recovery Leaving Temperature Setpoint Node Name: Optional Object + EXPECT_TRUE(ch.setHeatRecoveryLeavingTemperatureSetpointNode(hwLoop.supplyOutletNode())); + + EXPECT_TRUE(ch.setEndUseSubcategory("Chillers")); + + // Condenser Flow Control: Required String + EXPECT_TRUE(ch.setCondenserFlowControl("ConstantFlow")); + + // Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name: Optional Object + CurveLinear condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(m); + condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve.setName("condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve"); + EXPECT_TRUE(ch.setCondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve)); + + // Temperature Difference Across Condenser Schedule Name: Optional Object + ScheduleConstant temperatureDifferenceAcrossCondenserSchedule(m); + temperatureDifferenceAcrossCondenserSchedule.setName("temperatureDifferenceAcrossCondenserSchedule"); + EXPECT_TRUE(ch.setTemperatureDifferenceAcrossCondenserSchedule(temperatureDifferenceAcrossCondenserSchedule)); + + // Condenser Minimum Flow Fraction: Required Double + EXPECT_TRUE(ch.setCondenserMinimumFlowFraction(0.9)); + EXPECT_EQ(0.9, ch.condenserMinimumFlowFraction()); + + // Thermosiphon Capacity Fraction Curve Name: Optional Object + CurveLinear thermosiphonCapacityFractionCurve(m); + thermosiphonCapacityFractionCurve.setName("thermosiphonCapacityFractionCurve"); + EXPECT_TRUE(ch.setThermosiphonCapacityFractionCurve(thermosiphonCapacityFractionCurve)); + + // Thermosiphon Minimum Temperature Difference: Required Double + EXPECT_TRUE(ch.setThermosiphonMinimumTemperatureDifference(4.1)); + + { + Workspace w = ft.translateModel(m); + + std::vector woChs = w.getObjectsByType(IddObjectType::Chiller_Electric_EIR); + ASSERT_EQ(1, woChs.size()); + auto& woCh = woChs.front(); + + EXPECT_EQ("My ChillerElectricEIR", woCh.getString(Chiller_Electric_EIRFields::Name).get()); + EXPECT_EQ(30000.0, woCh.getDouble(Chiller_Electric_EIRFields::ReferenceCapacity).get()); + EXPECT_EQ(4.5, woCh.getDouble(Chiller_Electric_EIRFields::ReferenceCOP).get()); + EXPECT_EQ(7.0, woCh.getDouble(Chiller_Electric_EIRFields::ReferenceLeavingChilledWaterTemperature).get()); + EXPECT_EQ(30.0, woCh.getDouble(Chiller_Electric_EIRFields::ReferenceEnteringCondenserFluidTemperature).get()); + EXPECT_EQ(3.0, woCh.getDouble(Chiller_Electric_EIRFields::ReferenceChilledWaterFlowRate).get()); + EXPECT_EQ(4.0, woCh.getDouble(Chiller_Electric_EIRFields::ReferenceCondenserFluidFlowRate).get()); + EXPECT_EQ("capfT", woCh.getString(Chiller_Electric_EIRFields::CoolingCapacityFunctionofTemperatureCurveName).get()); + EXPECT_EQ("EIRfT", woCh.getString(Chiller_Electric_EIRFields::ElectricInputtoCoolingOutputRatioFunctionofTemperatureCurveName).get()); + EXPECT_EQ("EIRfPLR", woCh.getString(Chiller_Electric_EIRFields::ElectricInputtoCoolingOutputRatioFunctionofPartLoadRatioCurveName).get()); + EXPECT_EQ(0.1, woCh.getDouble(Chiller_Electric_EIRFields::MinimumPartLoadRatio).get()); + EXPECT_EQ(1.3, woCh.getDouble(Chiller_Electric_EIRFields::MaximumPartLoadRatio).get()); + EXPECT_EQ(0.8, woCh.getDouble(Chiller_Electric_EIRFields::OptimumPartLoadRatio).get()); + EXPECT_EQ(0.2, woCh.getDouble(Chiller_Electric_EIRFields::MinimumUnloadingRatio).get()); + EXPECT_EQ("ChilledWater Inlet Node", woCh.getString(Chiller_Electric_EIRFields::ChilledWaterInletNodeName).get()); + EXPECT_EQ("ChilledWater Outlet Node", woCh.getString(Chiller_Electric_EIRFields::ChilledWaterOutletNodeName).get()); + EXPECT_EQ("Condenser Inlet Node", woCh.getString(Chiller_Electric_EIRFields::CondenserInletNodeName).get()); + EXPECT_EQ("Condenser Outlet Node", woCh.getString(Chiller_Electric_EIRFields::CondenserOutletNodeName).get()); + EXPECT_EQ("WaterCooled", woCh.getString(Chiller_Electric_EIRFields::CondenserType).get()); + EXPECT_EQ(1.1, woCh.getDouble(Chiller_Electric_EIRFields::CondenserFanPowerRatio).get()); + EXPECT_EQ(0.957, woCh.getDouble(Chiller_Electric_EIRFields::FractionofCompressorElectricConsumptionRejectedbyCondenser).get()); + EXPECT_EQ(2.3, woCh.getDouble(Chiller_Electric_EIRFields::LeavingChilledWaterLowerTemperatureLimit).get()); + EXPECT_EQ("LeavingSetpointModulated", woCh.getString(Chiller_Electric_EIRFields::ChillerFlowMode).get()); + EXPECT_EQ(2.5, woCh.getDouble(Chiller_Electric_EIRFields::DesignHeatRecoveryWaterFlowRate).get()); + EXPECT_EQ("Heat Recovery Inlet Node", woCh.getString(Chiller_Electric_EIRFields::HeatRecoveryInletNodeName).get()); + EXPECT_EQ("Heat Recovery Outlet Node", woCh.getString(Chiller_Electric_EIRFields::HeatRecoveryOutletNodeName).get()); + EXPECT_EQ(1.8, woCh.getDouble(Chiller_Electric_EIRFields::SizingFactor).get()); + EXPECT_EQ(2000.0, woCh.getDouble(Chiller_Electric_EIRFields::BasinHeaterCapacity).get()); + EXPECT_EQ(5.0, woCh.getDouble(Chiller_Electric_EIRFields::BasinHeaterSetpointTemperature).get()); + EXPECT_EQ("basinHeaterOperatingSchedule", woCh.getString(Chiller_Electric_EIRFields::BasinHeaterOperatingScheduleName).get()); + EXPECT_EQ(0.97, woCh.getDouble(Chiller_Electric_EIRFields::CondenserHeatRecoveryRelativeCapacityFraction).get()); + EXPECT_EQ("heatRecoveryInletHighTemperatureLimitSchedule", + woCh.getString(Chiller_Electric_EIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName).get()); + EXPECT_EQ("HWLoop Supply Outlet", woCh.getString(Chiller_Electric_EIRFields::HeatRecoveryLeavingTemperatureSetpointNodeName).get()); + EXPECT_EQ("Chillers", woCh.getString(Chiller_Electric_EIRFields::EndUseSubcategory).get()); + EXPECT_EQ("ConstantFlow", woCh.getString(Chiller_Electric_EIRFields::CondenserFlowControl).get()); + EXPECT_EQ("condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve", + woCh.getString(Chiller_Electric_EIRFields::CondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurveName).get()); + EXPECT_EQ("temperatureDifferenceAcrossCondenserSchedule", + woCh.getString(Chiller_Electric_EIRFields::TemperatureDifferenceAcrossCondenserScheduleName).get()); + EXPECT_EQ(0.9, woCh.getDouble(Chiller_Electric_EIRFields::CondenserMinimumFlowFraction).get()); + EXPECT_EQ("thermosiphonCapacityFractionCurve", woCh.getString(Chiller_Electric_EIRFields::ThermosiphonCapacityFractionCurveName).get()); + EXPECT_EQ(4.1, woCh.getDouble(Chiller_Electric_EIRFields::ThermosiphonMinimumTemperatureDifference).get()); + + // Check node names on supply/demand branches + // Checks that the special case implemented in ForwardTranslatePlantLoop::populateBranch does the right job + + struct Expected + { + Expected(bool t_isSupply, std::string t_plantName, std::string t_inletNodeName, std::string t_outletNodeName) + : isSupply(t_isSupply), + plantName(std::move(t_plantName)), + inletNodeName(std::move(t_inletNodeName)), + outletNodeName(std::move(t_outletNodeName)) {} + bool isSupply = true; + std::string plantName; + std::string inletNodeName; + std::string outletNodeName; + }; + + std::vector expecteds = { + {true, ch.chilledWaterLoop()->nameString(), ch.supplyInletModelObject()->nameString(), ch.supplyOutletModelObject()->nameString()}, + {false, ch.condenserWaterLoop()->nameString(), ch.demandInletModelObject()->nameString(), ch.demandOutletModelObject()->nameString()}, + {false, ch.heatRecoveryLoop()->nameString(), ch.tertiaryInletModelObject()->nameString(), ch.tertiaryOutletModelObject()->nameString()}, + }; + + for (const auto& e : expecteds) { + auto p_ = w.getObjectByTypeAndName(IddObjectType::PlantLoop, e.plantName); + ASSERT_TRUE(p_.is_initialized()) << "Cannot find PlantLoop named " << e.plantName; + WorkspaceObject idf_plant = p_.get(); + unsigned index = e.isSupply ? PlantLoopFields::PlantSideBranchListName : PlantLoopFields::DemandSideBranchListName; + WorkspaceObject idf_brlist = idf_plant.getTarget(index).get(); + + // Should have at least three branches: supply inlet, the one with the Chiller, supply outlet. + // On the demand side, there's also a bypass branch that is added by the FT by default + ASSERT_EQ(e.isSupply ? 3 : 4, idf_brlist.extensibleGroups().size()) << "Failed for " << e.plantName; + // Get the Chiller one + auto w_eg = idf_brlist.extensibleGroups()[1].cast(); + WorkspaceObject idf_branch = w_eg.getTarget(BranchListExtensibleFields::BranchName).get(); + + // There should be only one equipment on the branch + ASSERT_EQ(1, idf_branch.extensibleGroups().size()); + auto w_eg2 = idf_branch.extensibleGroups()[0].cast(); + + ASSERT_EQ(w_eg2.getString(BranchExtensibleFields::ComponentName).get(), ch.nameString()); + ASSERT_EQ(w_eg2.getString(BranchExtensibleFields::ComponentInletNodeName).get(), e.inletNodeName); + ASSERT_EQ(w_eg2.getString(BranchExtensibleFields::ComponentOutletNodeName).get(), e.outletNodeName); + + WorkspaceObject idf_plant_op = p_->getTarget(PlantLoopFields::PlantEquipmentOperationSchemeName).get(); + if (e.isSupply) { + // Should have created a Cooling Load one only + ASSERT_EQ(1, idf_plant_op.extensibleGroups().size()); + auto w_eg = idf_plant_op.extensibleGroups()[0].cast(); + ASSERT_EQ("PlantEquipmentOperation:CoolingLoad", + w_eg.getString(PlantEquipmentOperationSchemesExtensibleFields::ControlSchemeObjectType).get()); + + // Get the Operation Scheme + auto op_scheme_ = w_eg.getTarget(PlantEquipmentOperationSchemesExtensibleFields::ControlSchemeName); + ASSERT_TRUE(op_scheme_); + + // Get the Plant Equipment List of this CoolingLoad scheme + // There should only be one Load Range + ASSERT_EQ(1u, op_scheme_->extensibleGroups().size()); + + // Load range 1 + w_eg = op_scheme_->extensibleGroups()[0].cast(); + auto peq_list_ = w_eg.getTarget(PlantEquipmentOperation_HeatingLoadExtensibleFields::RangeEquipmentListName); + ASSERT_TRUE(peq_list_); + + // Should have one equipment on it: CentralHeatPumpSystem + auto peqs = peq_list_->extensibleGroups(); + ASSERT_EQ(1, peqs.size()); + ASSERT_EQ("Chiller:Electric:EIR", peqs.front().getString(PlantEquipmentListExtensibleFields::EquipmentObjectType).get()); + ASSERT_EQ(ch.nameString(), peqs.front().getString(PlantEquipmentListExtensibleFields::EquipmentName).get()); + + } else { + EXPECT_EQ(0, idf_plant_op.extensibleGroups().size()); + } + } + } +} diff --git a/src/energyplus/Test/ChillerElectricReformulatedEIR_GTest.cpp b/src/energyplus/Test/ChillerElectricReformulatedEIR_GTest.cpp new file mode 100644 index 00000000000..91bfb31445e --- /dev/null +++ b/src/energyplus/Test/ChillerElectricReformulatedEIR_GTest.cpp @@ -0,0 +1,310 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. +* See also https://openstudio.net/license +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ForwardTranslator.hpp" + +#include "../../model/ChillerElectricReformulatedEIR.hpp" +#include "../../model/ChillerElectricReformulatedEIR_Impl.hpp" + +#include "../../model/CurveBiquadratic.hpp" +#include "../../model/CurveLinear.hpp" +#include "../../model/CurveQuadratic.hpp" +#include "../../model/PlantLoop.hpp" +#include "../../model/PlantLoop_Impl.hpp" +#include "../../model/Node.hpp" +#include "../../model/Node_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/ScheduleConstant.hpp" +#include "../../model/Mixer.hpp" +#include "../../model/Splitter.hpp" + +#include "../../utilities/geometry/Point3d.hpp" + +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/WorkspaceObject.hpp" +#include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +// E+ FieldEnums +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include "../../utilities/core/PathHelpers.hpp" + +#include +#include + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +/* Ensures that the nodes that translated correctly + * that means correct node names in the ChillerElectricASHRAE205 but also + * on the Branches + */ +TEST_F(EnergyPlusFixture, ForwardTranslator_ChillerElectricReformulatedEIR) { + + ForwardTranslator ft; + + Model m; + + auto createLoop = [&m](const std::string& prefix) { + PlantLoop p(m); + static constexpr std::array compNames = { + "Supply Inlet", "Supply Splitter", "Supply Connection Node", "Supply Mixer", "Supply Outlet", + "Demand Inlet", "Demand Splitter", "Demand Connection Node", "Demand Mixer", "Demand Outlet", + }; + p.setName(prefix); + for (size_t i = 0; auto& comp : p.components()) { + comp.setName(prefix + " " + std::string{compNames[i++]}); + } + return p; + }; + + ChillerElectricReformulatedEIR ch(m); + + ch.setName("My ChillerElectricReformulatedEIR"); + + // Reference Capacity: Required Double + // Autosize + EXPECT_TRUE(ch.setReferenceCapacity(30000.0)); + EXPECT_TRUE(ch.setReferenceCOP(4.5)); + EXPECT_TRUE(ch.setReferenceLeavingChilledWaterTemperature(7.0)); + EXPECT_TRUE(ch.setReferenceLeavingCondenserWaterTemperature(36.0)); + EXPECT_TRUE(ch.setReferenceChilledWaterFlowRate(3.0)); + EXPECT_TRUE(ch.setReferenceCondenserWaterFlowRate(4.0)); + + // Cooling Capacity Function of Temperature Curve Name: Required Object + ch.coolingCapacityFunctionOfTemperature().setName("capfT"); + + // Electric Input to Cooling Output Ratio Function of Temperature Curve Name: Required Object + ch.electricInputToCoolingOutputRatioFunctionOfTemperature().setName("EIRfT"); + + EXPECT_TRUE(ch.setElectricInputToCoolingOutputRatioFunctionOfPLRType("Lift")); + + // Electric Input to Cooling Output Ratio Function of Part Load Ratio Curve Name: Required Object + ch.electricInputToCoolingOutputRatioFunctionOfPLR().setName("EIRfPLR"); + + EXPECT_TRUE(ch.setMinimumPartLoadRatio(0.1)); + EXPECT_TRUE(ch.setMaximumPartLoadRatio(1.3)); + EXPECT_TRUE(ch.setOptimumPartLoadRatio(0.8)); + EXPECT_TRUE(ch.setMinimumUnloadingRatio(0.2)); + + // Chilled Water Inlet Node Name: Required Object + // Chilled Water Outlet Node Name: Required Object + auto chwLoop = createLoop("chwLoop"); + EXPECT_TRUE(chwLoop.addSupplyBranchForComponent(ch)); + ch.supplyInletModelObject()->setName("ChilledWater Inlet Node"); + ch.supplyOutletModelObject()->setName("ChilledWater Outlet Node"); + + // Condenser Inlet Node Name: Optional Object + // Condenser Outlet Node Name: Optional Object + auto cndLoop = createLoop("cndLoop"); + EXPECT_TRUE(cndLoop.addDemandBranchForComponent(ch)); + ch.demandInletModelObject()->setName("Condenser Inlet Node"); + ch.demandOutletModelObject()->setName("Condenser Outlet Node"); + + // Condenser Type + + EXPECT_TRUE(ch.setFractionofCompressorElectricConsumptionRejectedbyCondenser(0.957)); + EXPECT_TRUE(ch.setLeavingChilledWaterLowerTemperatureLimit(2.3)); + EXPECT_EQ(2.3, ch.leavingChilledWaterLowerTemperatureLimit()); + EXPECT_TRUE(ch.setChillerFlowMode("LeavingSetpointModulated")); + EXPECT_TRUE(ch.setDesignHeatRecoveryWaterFlowRate(2.5)); + + // Heat Recovery Inlet Node Name: Optional Object + // Heat Recovery Outlet Node Name: Optional Object + auto hwLoop = createLoop("HWLoop"); + EXPECT_TRUE(hwLoop.addDemandBranchForComponent(ch)); + + ch.tertiaryInletModelObject()->setName("Heat Recovery Inlet Node"); + ch.tertiaryOutletModelObject()->setName("Heat Recovery Outlet Node"); + + EXPECT_TRUE(ch.setSizingFactor(1.8)); + + // Condenser Heat Recovery Relative Capacity Fraction: Required Double + EXPECT_TRUE(ch.setCondenserHeatRecoveryRelativeCapacityFraction(0.97)); + + // Heat Recovery Inlet High Temperature Limit Schedule Name: Optional Object + ScheduleConstant heatRecoveryInletHighTemperatureLimitSchedule(m); + heatRecoveryInletHighTemperatureLimitSchedule.setName("heatRecoveryInletHighTemperatureLimitSchedule"); + EXPECT_TRUE(ch.setHeatRecoveryInletHighTemperatureLimitSchedule(heatRecoveryInletHighTemperatureLimitSchedule)); + + // Heat Recovery Leaving Temperature Setpoint Node Name: Optional Object + EXPECT_TRUE(ch.setHeatRecoveryLeavingTemperatureSetpointNode(hwLoop.supplyOutletNode())); + + EXPECT_TRUE(ch.setEndUseSubcategory("Chillers")); + + // Condenser Flow Control: Required String + EXPECT_TRUE(ch.setCondenserFlowControl("ConstantFlow")); + + // Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name: Optional Object + CurveLinear condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(m); + condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve.setName("condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve"); + EXPECT_TRUE(ch.setCondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve)); + + // Temperature Difference Across Condenser Schedule Name: Optional Object + ScheduleConstant temperatureDifferenceAcrossCondenserSchedule(m); + temperatureDifferenceAcrossCondenserSchedule.setName("temperatureDifferenceAcrossCondenserSchedule"); + EXPECT_TRUE(ch.setTemperatureDifferenceAcrossCondenserSchedule(temperatureDifferenceAcrossCondenserSchedule)); + + // Condenser Minimum Flow Fraction: Required Double + EXPECT_TRUE(ch.setCondenserMinimumFlowFraction(0.9)); + EXPECT_EQ(0.9, ch.condenserMinimumFlowFraction()); + + // Thermosiphon Capacity Fraction Curve Name: Optional Object + CurveLinear thermosiphonCapacityFractionCurve(m); + thermosiphonCapacityFractionCurve.setName("thermosiphonCapacityFractionCurve"); + EXPECT_TRUE(ch.setThermosiphonCapacityFractionCurve(thermosiphonCapacityFractionCurve)); + + // Thermosiphon Minimum Temperature Difference: Required Double + EXPECT_TRUE(ch.setThermosiphonMinimumTemperatureDifference(4.1)); + + m.save("chiller.osm", true); + + { + Workspace w = ft.translateModel(m); + + std::vector woChs = w.getObjectsByType(IddObjectType::Chiller_Electric_ReformulatedEIR); + ASSERT_EQ(1, woChs.size()); + auto& woCh = woChs.front(); + + EXPECT_EQ("My ChillerElectricReformulatedEIR", woCh.getString(Chiller_Electric_ReformulatedEIRFields::Name).get()); + EXPECT_EQ(30000.0, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ReferenceCapacity).get()); + EXPECT_EQ(4.5, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ReferenceCOP).get()); + EXPECT_EQ(7.0, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ReferenceLeavingChilledWaterTemperature).get()); + EXPECT_EQ(36.0, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ReferenceLeavingCondenserWaterTemperature).get()); + EXPECT_EQ(3.0, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ReferenceChilledWaterFlowRate).get()); + EXPECT_EQ(4.0, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ReferenceCondenserWaterFlowRate).get()); + EXPECT_EQ("capfT", woCh.getString(Chiller_Electric_ReformulatedEIRFields::CoolingCapacityFunctionofTemperatureCurveName).get()); + EXPECT_EQ("EIRfT", woCh.getString(Chiller_Electric_ReformulatedEIRFields::ElectricInputtoCoolingOutputRatioFunctionofTemperatureCurveName).get()); + EXPECT_EQ("Lift", + woCh.getString(Chiller_Electric_ReformulatedEIRFields::ElectricInputtoCoolingOutputRatioFunctionofPartLoadRatioCurveType).get()); + EXPECT_EQ("EIRfPLR", + woCh.getString(Chiller_Electric_ReformulatedEIRFields::ElectricInputtoCoolingOutputRatioFunctionofPartLoadRatioCurveName).get()); + EXPECT_EQ(0.1, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::MinimumPartLoadRatio).get()); + EXPECT_EQ(1.3, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::MaximumPartLoadRatio).get()); + EXPECT_EQ(0.8, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::OptimumPartLoadRatio).get()); + EXPECT_EQ(0.2, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::MinimumUnloadingRatio).get()); + EXPECT_EQ("ChilledWater Inlet Node", woCh.getString(Chiller_Electric_ReformulatedEIRFields::ChilledWaterInletNodeName).get()); + EXPECT_EQ("ChilledWater Outlet Node", woCh.getString(Chiller_Electric_ReformulatedEIRFields::ChilledWaterOutletNodeName).get()); + EXPECT_EQ("Condenser Inlet Node", woCh.getString(Chiller_Electric_ReformulatedEIRFields::CondenserInletNodeName).get()); + EXPECT_EQ("Condenser Outlet Node", woCh.getString(Chiller_Electric_ReformulatedEIRFields::CondenserOutletNodeName).get()); + EXPECT_EQ(0.957, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::FractionofCompressorElectricConsumptionRejectedbyCondenser).get()); + EXPECT_EQ(2.3, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::LeavingChilledWaterLowerTemperatureLimit).get()); + EXPECT_EQ("LeavingSetpointModulated", woCh.getString(Chiller_Electric_ReformulatedEIRFields::ChillerFlowModeType).get()); + EXPECT_EQ(2.5, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::DesignHeatRecoveryWaterFlowRate).get()); + EXPECT_EQ("Heat Recovery Inlet Node", woCh.getString(Chiller_Electric_ReformulatedEIRFields::HeatRecoveryInletNodeName).get()); + EXPECT_EQ("Heat Recovery Outlet Node", woCh.getString(Chiller_Electric_ReformulatedEIRFields::HeatRecoveryOutletNodeName).get()); + EXPECT_EQ(1.8, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::SizingFactor).get()); + EXPECT_EQ(0.97, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::CondenserHeatRecoveryRelativeCapacityFraction).get()); + EXPECT_EQ("heatRecoveryInletHighTemperatureLimitSchedule", + woCh.getString(Chiller_Electric_ReformulatedEIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName).get()); + EXPECT_EQ("HWLoop Supply Outlet", woCh.getString(Chiller_Electric_ReformulatedEIRFields::HeatRecoveryLeavingTemperatureSetpointNodeName).get()); + EXPECT_EQ("Chillers", woCh.getString(Chiller_Electric_ReformulatedEIRFields::EndUseSubcategory).get()); + EXPECT_EQ("ConstantFlow", woCh.getString(Chiller_Electric_ReformulatedEIRFields::CondenserFlowControl).get()); + EXPECT_EQ("condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve", + woCh.getString(Chiller_Electric_ReformulatedEIRFields::CondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurveName).get()); + EXPECT_EQ("temperatureDifferenceAcrossCondenserSchedule", + woCh.getString(Chiller_Electric_ReformulatedEIRFields::TemperatureDifferenceAcrossCondenserScheduleName).get()); + EXPECT_EQ(0.9, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::CondenserMinimumFlowFraction).get()); + EXPECT_EQ("thermosiphonCapacityFractionCurve", + woCh.getString(Chiller_Electric_ReformulatedEIRFields::ThermosiphonCapacityFractionCurveName).get()); + EXPECT_EQ(4.1, woCh.getDouble(Chiller_Electric_ReformulatedEIRFields::ThermosiphonMinimumTemperatureDifference).get()); + + // Check node names on supply/demand branches + // Checks that the special case implemented in ForwardTranslatePlantLoop::populateBranch does the right job + + struct Expected + { + Expected(bool t_isSupply, std::string t_plantName, std::string t_inletNodeName, std::string t_outletNodeName) + : isSupply(t_isSupply), + plantName(std::move(t_plantName)), + inletNodeName(std::move(t_inletNodeName)), + outletNodeName(std::move(t_outletNodeName)) {} + bool isSupply = true; + std::string plantName; + std::string inletNodeName; + std::string outletNodeName; + }; + + std::vector expecteds = { + {true, ch.chilledWaterLoop()->nameString(), ch.supplyInletModelObject()->nameString(), ch.supplyOutletModelObject()->nameString()}, + {false, ch.condenserWaterLoop()->nameString(), ch.demandInletModelObject()->nameString(), ch.demandOutletModelObject()->nameString()}, + {false, ch.heatRecoveryLoop()->nameString(), ch.tertiaryInletModelObject()->nameString(), ch.tertiaryOutletModelObject()->nameString()}, + }; + + for (const auto& e : expecteds) { + auto p_ = w.getObjectByTypeAndName(IddObjectType::PlantLoop, e.plantName); + ASSERT_TRUE(p_.is_initialized()) << "Cannot find PlantLoop named " << e.plantName; + WorkspaceObject idf_plant = p_.get(); + unsigned index = e.isSupply ? PlantLoopFields::PlantSideBranchListName : PlantLoopFields::DemandSideBranchListName; + WorkspaceObject idf_brlist = idf_plant.getTarget(index).get(); + + // Should have at least three branches: supply inlet, the one with the Chiller, supply outlet. + // On the demand side, there's also a bypass branch that is added by the FT by default + ASSERT_EQ(e.isSupply ? 3 : 4, idf_brlist.extensibleGroups().size()) << "Failed for " << e.plantName; + // Get the Chiller one + auto w_eg = idf_brlist.extensibleGroups()[1].cast(); + WorkspaceObject idf_branch = w_eg.getTarget(BranchListExtensibleFields::BranchName).get(); + + // There should be only one equipment on the branch + ASSERT_EQ(1, idf_branch.extensibleGroups().size()); + auto w_eg2 = idf_branch.extensibleGroups()[0].cast(); + + ASSERT_EQ(w_eg2.getString(BranchExtensibleFields::ComponentName).get(), ch.nameString()); + ASSERT_EQ(w_eg2.getString(BranchExtensibleFields::ComponentInletNodeName).get(), e.inletNodeName); + ASSERT_EQ(w_eg2.getString(BranchExtensibleFields::ComponentOutletNodeName).get(), e.outletNodeName); + + WorkspaceObject idf_plant_op = p_->getTarget(PlantLoopFields::PlantEquipmentOperationSchemeName).get(); + if (e.isSupply) { + // Should have created a Cooling Load one only + ASSERT_EQ(1, idf_plant_op.extensibleGroups().size()); + auto w_eg = idf_plant_op.extensibleGroups()[0].cast(); + ASSERT_EQ("PlantEquipmentOperation:CoolingLoad", + w_eg.getString(PlantEquipmentOperationSchemesExtensibleFields::ControlSchemeObjectType).get()); + + // Get the Operation Scheme + auto op_scheme_ = w_eg.getTarget(PlantEquipmentOperationSchemesExtensibleFields::ControlSchemeName); + ASSERT_TRUE(op_scheme_); + + // Get the Plant Equipment List of this CoolingLoad scheme + // There should only be one Load Range + ASSERT_EQ(1u, op_scheme_->extensibleGroups().size()); + + // Load range 1 + w_eg = op_scheme_->extensibleGroups()[0].cast(); + auto peq_list_ = w_eg.getTarget(PlantEquipmentOperation_HeatingLoadExtensibleFields::RangeEquipmentListName); + ASSERT_TRUE(peq_list_); + + // Should have one equipment on it: CentralHeatPumpSystem + auto peqs = peq_list_->extensibleGroups(); + ASSERT_EQ(1, peqs.size()); + ASSERT_EQ("Chiller:Electric:ReformulatedEIR", peqs.front().getString(PlantEquipmentListExtensibleFields::EquipmentObjectType).get()); + ASSERT_EQ(ch.nameString(), peqs.front().getString(PlantEquipmentListExtensibleFields::EquipmentName).get()); + + } else { + EXPECT_EQ(0, idf_plant_op.extensibleGroups().size()); + } + } + } +} diff --git a/src/energyplus/Test/Site_GTest.cpp b/src/energyplus/Test/Site_GTest.cpp new file mode 100644 index 00000000000..b6ebc569d82 --- /dev/null +++ b/src/energyplus/Test/Site_GTest.cpp @@ -0,0 +1,54 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. +* See also https://openstudio.net/license +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/Site.hpp" + +#include + +#include +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/IdfObject_Impl.hpp" + +#include "../../utilities/idf/WorkspaceObject.hpp" +#include "../../utilities/idf/WorkspaceObject_Impl.hpp" + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +TEST_F(EnergyPlusFixture, ForwardTranslator_Site) { + Model m; + + Site site = m.getUniqueModelObject(); + + EXPECT_TRUE(site.setName("Site 1")); + EXPECT_TRUE(site.setLatitude(0.0)); + EXPECT_TRUE(site.setLongitude(0.0)); + EXPECT_TRUE(site.setTimeZone(0.0)); + EXPECT_TRUE(site.setElevation(0.0)); + EXPECT_TRUE(site.setTerrain("Suburbs")); + EXPECT_TRUE(site.setKeepSiteLocationInformation("Yes")); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::Site_Location).size()); + + IdfObject idf_site = w.getObjectsByType(IddObjectType::Site_Location)[0]; + + EXPECT_EQ("Site 1", idf_site.getString(Site_LocationFields::Name).get()); + EXPECT_EQ(0.0, idf_site.getDouble(Site_LocationFields::Latitude).get()); + EXPECT_EQ(0.0, idf_site.getDouble(Site_LocationFields::Longitude).get()); + EXPECT_EQ(0.0, idf_site.getDouble(Site_LocationFields::TimeZone).get()); + EXPECT_EQ(0.0, idf_site.getDouble(Site_LocationFields::Elevation).get()); + // EXPECT_EQ("Suburbs", idf_site.getString(Site_LocationFields::Terrain).get()); not in FT + EXPECT_EQ("Yes", idf_site.getString(Site_LocationFields::KeepSiteLocationInformation).get()); +} diff --git a/src/energyplus/Test/SizingZone_GTest.cpp b/src/energyplus/Test/SizingZone_GTest.cpp index 6fba8c58e10..0ab9feb2402 100644 --- a/src/energyplus/Test/SizingZone_GTest.cpp +++ b/src/energyplus/Test/SizingZone_GTest.cpp @@ -184,6 +184,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_SizingZone) { EXPECT_EQ(dehumSch.nameString(), idf_sz.getString(Sizing_ZoneFields::ZoneHumidistatDehumidificationSetPointScheduleName).get()); EXPECT_EQ(humSch.nameString(), idf_sz.getString(Sizing_ZoneFields::ZoneHumidistatHumidificationSetPointScheduleName).get()); } + + EXPECT_TRUE(sz.setSizingOption("NonCoincident")); + + { + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idfObjs = w.getObjectsByType(IddObjectType::Sizing_Zone); + ASSERT_EQ(1u, idfObjs.size()); + WorkspaceObject idf_sz(idfObjs[0]); + + EXPECT_EQ("NonCoincident", idf_sz.getString(Sizing_ZoneFields::TypeofSpaceSumtoUse).get()); + } } TEST_F(EnergyPlusFixture, ReverseTranslator_SizingZone) { diff --git a/src/model/ChillerElectricEIR.cpp b/src/model/ChillerElectricEIR.cpp index 288e52186f2..19e30135d51 100644 --- a/src/model/ChillerElectricEIR.cpp +++ b/src/model/ChillerElectricEIR.cpp @@ -91,9 +91,11 @@ namespace model { UnsignedVector::const_iterator b(fieldIndices.begin()); UnsignedVector::const_iterator e(fieldIndices.end()); if (std::find(b, e, OS_Chiller_Electric_EIRFields::BasinHeaterOperatingScheduleName) != e) { - result.push_back(ScheduleTypeKey("ChillerElectricEIR", "Basin Heater Operating")); + result.emplace_back("ChillerElectricEIR", "Basin Heater Operating"); } else if (std::find(b, e, OS_Chiller_Electric_EIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName) != e) { - result.push_back(ScheduleTypeKey("ChillerElectricEIR", "Heat Recovery Inlet High Temperature Limit")); + result.emplace_back("ChillerElectricEIR", "Heat Recovery Inlet High Temperature Limit"); + } else if (std::find(b, e, OS_Chiller_Electric_EIRFields::TemperatureDifferenceAcrossCondenserScheduleName) != e) { + result.emplace_back("ChillerElectricEIR", "Temperature Difference Across Condenser"); } return result; } @@ -607,11 +609,17 @@ namespace model { std::vector ChillerElectricEIR_Impl::children() const { std::vector result; + result.reserve(5); result.push_back(coolingCapacityFunctionOfTemperature()); result.push_back(electricInputToCoolingOutputRatioFunctionOfTemperature()); result.push_back(electricInputToCoolingOutputRatioFunctionOfPLR()); - + if (auto curve_ = condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve()) { + result.emplace_back(std::move(*curve_)); + } + if (auto curve_ = thermosiphonCapacityFractionCurve()) { + result.emplace_back(std::move(*curve_)); + } return result; } @@ -630,6 +638,48 @@ namespace model { return WaterToWaterComponent_Impl::tertiaryPlantLoop(); } + boost::optional ChillerElectricEIR_Impl::chilledWaterInletNode() const { + if (auto mo_ = supplyInletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricEIR_Impl::chilledWaterOutletNode() const { + if (auto mo_ = supplyOutletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricEIR_Impl::condenserInletNode() const { + if (auto mo_ = demandInletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricEIR_Impl::condenserOutletNode() const { + if (auto mo_ = demandOutletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricEIR_Impl::heatRecoveryInletNode() const { + if (auto mo_ = tertiaryInletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricEIR_Impl::heatRecoveryOutletNode() const { + if (auto mo_ = tertiaryOutletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + bool ChillerElectricEIR_Impl::addToNode(Node& node) { boost::optional t_plantLoop = node.plantLoop(); @@ -788,7 +838,6 @@ namespace model { OS_Chiller_Electric_EIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName); } - // TODO: ScheduleTypeLimits bool ChillerElectricEIR_Impl::setHeatRecoveryInletHighTemperatureLimitSchedule(Schedule& schedule) { bool result = setSchedule(OS_Chiller_Electric_EIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName, "ChillerElectricEIR", "Heat Recovery Inlet High Temperature Limit", schedule); @@ -828,8 +877,10 @@ namespace model { return getObject().getModelObjectTarget(OS_Chiller_Electric_EIRFields::TemperatureDifferenceAcrossCondenserScheduleName); } - boost::optional ChillerElectricEIR_Impl::condenserMinimumFlowFraction() const { - return getDouble(OS_Chiller_Electric_EIRFields::CondenserMinimumFlowFraction, true); + double ChillerElectricEIR_Impl::condenserMinimumFlowFraction() const { + boost::optional value = getDouble(OS_Chiller_Electric_EIRFields::CondenserMinimumFlowFraction, true); + OS_ASSERT(value); + return value.get(); } boost::optional ChillerElectricEIR_Impl::thermosiphonCapacityFractionCurve() const { @@ -859,8 +910,8 @@ namespace model { } bool ChillerElectricEIR_Impl::setTemperatureDifferenceAcrossCondenserSchedule(Schedule& temperatureDifferenceAcrossCondenserSchedule) { - bool result = setPointer(OS_Chiller_Electric_EIRFields::TemperatureDifferenceAcrossCondenserScheduleName, - temperatureDifferenceAcrossCondenserSchedule.handle()); + bool result = setSchedule(OS_Chiller_Electric_EIRFields::TemperatureDifferenceAcrossCondenserScheduleName, "ChillerElectricEIR", + "Temperature Difference Across Condenser", temperatureDifferenceAcrossCondenserSchedule); return result; } @@ -874,11 +925,6 @@ namespace model { return result; } - void ChillerElectricEIR_Impl::resetCondenserMinimumFlowFraction() { - bool result = setString(OS_Chiller_Electric_EIRFields::CondenserMinimumFlowFraction, ""); - OS_ASSERT(result); - } - bool ChillerElectricEIR_Impl::setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve) { bool result = setPointer(OS_Chiller_Electric_EIRFields::ThermosiphonCapacityFractionCurveName, thermosiphonCapacityFractionCurve.handle()); return result; @@ -926,18 +972,17 @@ namespace model { OS_ASSERT(setCoolingCapacityFunctionOfTemperature(CCFofT)); OS_ASSERT(setElectricInputToCoolingOutputRatioFunctionOfTemperature(EItoCORFofT)); OS_ASSERT(setElectricInputToCoolingOutputRatioFunctionOfPLR(EItoCORFofPLR)); - OS_ASSERT(setReferenceCOP(5.5f)); + OS_ASSERT(setReferenceCOP(5.5)); autosizeReferenceCapacity(); autosizeReferenceChilledWaterFlowRate(); // autosizeReferenceCondenserFluidFlowRate(); autosizeDesignHeatRecoveryWaterFlowRate(); - setSizingFactor(1.0); + // setSizingFactor(1.0); + // setBasinHeaterCapacity(0.0); - setBasinHeaterCapacity(0.0); - - setBasinHeaterSetpointTemperature(10.0); + setBasinHeaterSetpointTemperature(10.0); // Note: the IDD has a default of 2.0... resetBasinHeaterSchedule(); @@ -989,16 +1034,17 @@ namespace model { setElectricInputToCoolingOutputRatioFunctionOfTemperature(eirToCorfOfT); setElectricInputToCoolingOutputRatioFunctionOfPLR(eirToCorfOfPlr); - OS_ASSERT(setReferenceCOP(5.5f)); + OS_ASSERT(setReferenceCOP(5.5)); autosizeReferenceCapacity(); autosizeReferenceChilledWaterFlowRate(); // autosizeReferenceCondenserFluidFlowRate(); autosizeDesignHeatRecoveryWaterFlowRate(); - setSizingFactor(1.0); - setBasinHeaterCapacity(0.0); - setBasinHeaterSetpointTemperature(10.0); + // setSizingFactor(1.0); + // setBasinHeaterCapacity(0.0); + + setBasinHeaterSetpointTemperature(10.0); // Note: the IDD has a default of 2.0... resetBasinHeaterSchedule(); setCondenserHeatRecoveryRelativeCapacityFraction(1.0); resetHeatRecoveryLeavingTemperatureSetpointNode(); @@ -1389,19 +1435,6 @@ namespace model { return getImpl()->setEndUseSubcategory(endUseSubcategory); } - // Convenience functions - boost::optional ChillerElectricEIR::chilledWaterLoop() const { - return getImpl()->chilledWaterLoop(); - } - - boost::optional ChillerElectricEIR::condenserWaterLoop() const { - return getImpl()->condenserWaterLoop(); - } - - boost::optional ChillerElectricEIR::heatRecoveryLoop() const { - return getImpl()->heatRecoveryLoop(); - } - double ChillerElectricEIR::condenserHeatRecoveryRelativeCapacityFraction() const { return getImpl()->condenserHeatRecoveryRelativeCapacityFraction(); } @@ -1447,7 +1480,7 @@ namespace model { return getImpl()->temperatureDifferenceAcrossCondenserSchedule(); } - boost::optional ChillerElectricEIR::condenserMinimumFlowFraction() const { + double ChillerElectricEIR::condenserMinimumFlowFraction() const { return getImpl()->condenserMinimumFlowFraction(); } @@ -1485,10 +1518,6 @@ namespace model { return getImpl()->setCondenserMinimumFlowFraction(condenserMinimumFlowFraction); } - void ChillerElectricEIR::resetCondenserMinimumFlowFraction() { - getImpl()->resetCondenserMinimumFlowFraction(); - } - bool ChillerElectricEIR::setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve) { return getImpl()->setThermosiphonCapacityFractionCurve(thermosiphonCapacityFractionCurve); } @@ -1506,6 +1535,43 @@ namespace model { /// @endcond + // Convenience functions + boost::optional ChillerElectricEIR::chilledWaterLoop() const { + return getImpl()->chilledWaterLoop(); + } + + boost::optional ChillerElectricEIR::chilledWaterInletNode() const { + return getImpl()->chilledWaterInletNode(); + } + + boost::optional ChillerElectricEIR::chilledWaterOutletNode() const { + return getImpl()->chilledWaterOutletNode(); + } + + boost::optional ChillerElectricEIR::condenserWaterLoop() const { + return getImpl()->condenserWaterLoop(); + } + + boost::optional ChillerElectricEIR::condenserInletNode() const { + return getImpl()->condenserInletNode(); + } + + boost::optional ChillerElectricEIR::condenserOutletNode() const { + return getImpl()->condenserOutletNode(); + } + + boost::optional ChillerElectricEIR::heatRecoveryLoop() const { + return getImpl()->heatRecoveryLoop(); + } + + boost::optional ChillerElectricEIR::heatRecoveryInletNode() const { + return getImpl()->heatRecoveryInletNode(); + } + + boost::optional ChillerElectricEIR::heatRecoveryOutletNode() const { + return getImpl()->heatRecoveryOutletNode(); + } + boost::optional ChillerElectricEIR::autosizedReferenceCapacity() const { return getImpl()->autosizedReferenceCapacity(); } diff --git a/src/model/ChillerElectricEIR.hpp b/src/model/ChillerElectricEIR.hpp index 46787685738..0c1d69f5cce 100644 --- a/src/model/ChillerElectricEIR.hpp +++ b/src/model/ChillerElectricEIR.hpp @@ -155,7 +155,7 @@ namespace model { boost::optional temperatureDifferenceAcrossCondenserSchedule() const; - boost::optional condenserMinimumFlowFraction() const; + double condenserMinimumFlowFraction() const; boost::optional thermosiphonCapacityFractionCurve() const; @@ -278,7 +278,6 @@ namespace model { void resetTemperatureDifferenceAcrossCondenserSchedule(); bool setCondenserMinimumFlowFraction(double condenserMinimumFlowFraction); - void resetCondenserMinimumFlowFraction(); bool setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve); void resetThermosiphonCapacityFractionCurve(); @@ -299,12 +298,19 @@ namespace model { /** Convenience Function to return the Chilled Water Loop (chiller on supply) **/ boost::optional chilledWaterLoop() const; + // Same as supplyInletModelObject, but cast to a Node + boost::optional chilledWaterInletNode() const; + boost::optional chilledWaterOutletNode() const; /** Convenience Function to return the Condenser Water Loop (chiller on demand side) **/ boost::optional condenserWaterLoop() const; + boost::optional condenserInletNode() const; + boost::optional condenserOutletNode() const; /** Convenience Function to return the Heat Recovery Loop (chiller on demand side - tertiary) **/ boost::optional heatRecoveryLoop() const; + boost::optional heatRecoveryInletNode() const; + boost::optional heatRecoveryOutletNode() const; //@} protected: diff --git a/src/model/ChillerElectricEIR_Impl.hpp b/src/model/ChillerElectricEIR_Impl.hpp index 714d2349a07..34db4fee965 100644 --- a/src/model/ChillerElectricEIR_Impl.hpp +++ b/src/model/ChillerElectricEIR_Impl.hpp @@ -182,7 +182,7 @@ namespace model { boost::optional temperatureDifferenceAcrossCondenserSchedule() const; - boost::optional condenserMinimumFlowFraction() const; + double condenserMinimumFlowFraction() const; boost::optional thermosiphonCapacityFractionCurve() const; @@ -306,7 +306,6 @@ namespace model { void resetTemperatureDifferenceAcrossCondenserSchedule(); bool setCondenserMinimumFlowFraction(double condenserMinimumFlowFraction); - void resetCondenserMinimumFlowFraction(); bool setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve); void resetThermosiphonCapacityFractionCurve(); @@ -327,12 +326,19 @@ namespace model { /** Convenience Function to return the Chilled Water Loop (chiller on supply) **/ boost::optional chilledWaterLoop() const; + // Same as supplyInletModelObject, but cast to a Node + boost::optional chilledWaterInletNode() const; + boost::optional chilledWaterOutletNode() const; /** Convenience Function to return the Condenser Water Loop (chiller on demand side) **/ boost::optional condenserWaterLoop() const; + boost::optional condenserInletNode() const; + boost::optional condenserOutletNode() const; /** Convenience Function to return the Heat Recovery Loop (chiller on demand side - tertiary) **/ boost::optional heatRecoveryLoop() const; + boost::optional heatRecoveryInletNode() const; + boost::optional heatRecoveryOutletNode() const; //@} protected: diff --git a/src/model/ChillerElectricReformulatedEIR.cpp b/src/model/ChillerElectricReformulatedEIR.cpp index 8ee29d9b366..72a825bbd73 100644 --- a/src/model/ChillerElectricReformulatedEIR.cpp +++ b/src/model/ChillerElectricReformulatedEIR.cpp @@ -88,8 +88,11 @@ namespace model { UnsignedVector::const_iterator b(fieldIndices.begin()); UnsignedVector::const_iterator e(fieldIndices.end()); if (std::find(b, e, OS_Chiller_Electric_ReformulatedEIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName) != e) { - result.push_back(ScheduleTypeKey("ChillerElectricReformulatedEIR", "Heat Recovery Inlet High Temperature Limit")); + result.emplace_back("ChillerElectricReformulatedEIR", "Heat Recovery Inlet High Temperature Limit"); + } else if (std::find(b, e, OS_Chiller_Electric_ReformulatedEIRFields::TemperatureDifferenceAcrossCondenserScheduleName) != e) { + result.emplace_back("ChillerElectricReformulatedEIR", "Temperature Difference Across Condenser"); } + return result; } @@ -527,11 +530,17 @@ namespace model { std::vector ChillerElectricReformulatedEIR_Impl::children() const { std::vector result; + result.reserve(5); - result.push_back(coolingCapacityFunctionOfTemperature()); - result.push_back(electricInputToCoolingOutputRatioFunctionOfTemperature()); - result.push_back(electricInputToCoolingOutputRatioFunctionOfPLR()); - + result.emplace_back(coolingCapacityFunctionOfTemperature()); + result.emplace_back(electricInputToCoolingOutputRatioFunctionOfTemperature()); + result.emplace_back(electricInputToCoolingOutputRatioFunctionOfPLR()); + if (auto curve_ = condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve()) { + result.emplace_back(std::move(*curve_)); + } + if (auto curve_ = thermosiphonCapacityFractionCurve()) { + result.emplace_back(std::move(*curve_)); + } return result; } @@ -550,6 +559,48 @@ namespace model { return WaterToWaterComponent_Impl::tertiaryPlantLoop(); } + boost::optional ChillerElectricReformulatedEIR_Impl::chilledWaterInletNode() const { + if (auto mo_ = supplyInletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricReformulatedEIR_Impl::chilledWaterOutletNode() const { + if (auto mo_ = supplyOutletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricReformulatedEIR_Impl::condenserInletNode() const { + if (auto mo_ = demandInletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricReformulatedEIR_Impl::condenserOutletNode() const { + if (auto mo_ = demandOutletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricReformulatedEIR_Impl::heatRecoveryInletNode() const { + if (auto mo_ = tertiaryInletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + + boost::optional ChillerElectricReformulatedEIR_Impl::heatRecoveryOutletNode() const { + if (auto mo_ = tertiaryOutletModelObject()) { + return mo_->optionalCast(); + } + return boost::none; + } + bool ChillerElectricReformulatedEIR_Impl::addToNode(Node& node) { boost::optional t_plantLoop = node.plantLoop(); @@ -678,7 +729,6 @@ namespace model { OS_Chiller_Electric_ReformulatedEIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName); } - // TODO: ScheduleTypeLimits bool ChillerElectricReformulatedEIR_Impl::setHeatRecoveryInletHighTemperatureLimitSchedule(Schedule& schedule) { bool result = setSchedule(OS_Chiller_Electric_ReformulatedEIRFields::HeatRecoveryInletHighTemperatureLimitScheduleName, "ChillerElectricReformulatedEIR", "Heat Recovery Inlet High Temperature Limit", schedule); @@ -720,8 +770,10 @@ namespace model { OS_Chiller_Electric_ReformulatedEIRFields::TemperatureDifferenceAcrossCondenserScheduleName); } - boost::optional ChillerElectricReformulatedEIR_Impl::condenserMinimumFlowFraction() const { - return getDouble(OS_Chiller_Electric_ReformulatedEIRFields::CondenserMinimumFlowFraction, true); + double ChillerElectricReformulatedEIR_Impl::condenserMinimumFlowFraction() const { + boost::optional value = getDouble(OS_Chiller_Electric_ReformulatedEIRFields::CondenserMinimumFlowFraction, true); + OS_ASSERT(value); + return value.get(); } boost::optional ChillerElectricReformulatedEIR_Impl::thermosiphonCapacityFractionCurve() const { @@ -752,8 +804,9 @@ namespace model { bool ChillerElectricReformulatedEIR_Impl::setTemperatureDifferenceAcrossCondenserSchedule(Schedule& temperatureDifferenceAcrossCondenserSchedule) { - bool result = setPointer(OS_Chiller_Electric_ReformulatedEIRFields::TemperatureDifferenceAcrossCondenserScheduleName, - temperatureDifferenceAcrossCondenserSchedule.handle()); + bool result = + setSchedule(OS_Chiller_Electric_ReformulatedEIRFields::TemperatureDifferenceAcrossCondenserScheduleName, "ChillerElectricReformulatedEIR", + "Temperature Difference Across Condenser", temperatureDifferenceAcrossCondenserSchedule); return result; } @@ -767,11 +820,6 @@ namespace model { return result; } - void ChillerElectricReformulatedEIR_Impl::resetCondenserMinimumFlowFraction() { - bool result = setString(OS_Chiller_Electric_ReformulatedEIRFields::CondenserMinimumFlowFraction, ""); - OS_ASSERT(result); - } - bool ChillerElectricReformulatedEIR_Impl::setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve) { bool result = setPointer(OS_Chiller_Electric_ReformulatedEIRFields::ThermosiphonCapacityFractionCurveName, thermosiphonCapacityFractionCurve.handle()); @@ -829,7 +877,8 @@ namespace model { // autosizeReferenceCondenserWaterFlowRate(); autosizeDesignHeatRecoveryWaterFlowRate(); - setSizingFactor(1.0); + // setSizingFactor(1.0); + setCondenserHeatRecoveryRelativeCapacityFraction(1.0); resetHeatRecoveryLeavingTemperatureSetpointNode(); resetHeatRecoveryInletHighTemperatureLimitSchedule(); @@ -893,7 +942,8 @@ namespace model { // autosizeReferenceCondenserWaterFlowRate(); autosizeDesignHeatRecoveryWaterFlowRate(); - setSizingFactor(1.0); + // setSizingFactor(1.0); + setCondenserHeatRecoveryRelativeCapacityFraction(1.0); resetHeatRecoveryLeavingTemperatureSetpointNode(); resetHeatRecoveryInletHighTemperatureLimitSchedule(); @@ -916,6 +966,11 @@ namespace model { return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Chiller_Electric_ReformulatedEIRFields::CondenserFlowControl); } + std::vector ChillerElectricReformulatedEIR::validElectricInputToCoolingOutputRatioFunctionOfPLRTypeValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_Chiller_Electric_ReformulatedEIRFields::ElectricInputtoCoolingOutputRatioFunctionofPartLoadRatioCurveType); + } + boost::optional ChillerElectricReformulatedEIR::referenceCapacity() const { return getImpl()->referenceCapacity(); } @@ -1219,19 +1274,6 @@ namespace model { return getImpl()->setEndUseSubcategory(endUseSubcategory); } - // Convenience functions - boost::optional ChillerElectricReformulatedEIR::chilledWaterLoop() const { - return getImpl()->chilledWaterLoop(); - } - - boost::optional ChillerElectricReformulatedEIR::condenserWaterLoop() const { - return getImpl()->condenserWaterLoop(); - } - - boost::optional ChillerElectricReformulatedEIR::heatRecoveryLoop() const { - return getImpl()->heatRecoveryLoop(); - } - double ChillerElectricReformulatedEIR::condenserHeatRecoveryRelativeCapacityFraction() const { return getImpl()->condenserHeatRecoveryRelativeCapacityFraction(); } @@ -1276,7 +1318,7 @@ namespace model { return getImpl()->temperatureDifferenceAcrossCondenserSchedule(); } - boost::optional ChillerElectricReformulatedEIR::condenserMinimumFlowFraction() const { + double ChillerElectricReformulatedEIR::condenserMinimumFlowFraction() const { return getImpl()->condenserMinimumFlowFraction(); } @@ -1315,10 +1357,6 @@ namespace model { return getImpl()->setCondenserMinimumFlowFraction(condenserMinimumFlowFraction); } - void ChillerElectricReformulatedEIR::resetCondenserMinimumFlowFraction() { - getImpl()->resetCondenserMinimumFlowFraction(); - } - bool ChillerElectricReformulatedEIR::setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve) { return getImpl()->setThermosiphonCapacityFractionCurve(thermosiphonCapacityFractionCurve); } @@ -1338,6 +1376,43 @@ namespace model { /// @endcond + // Convenience functions + boost::optional ChillerElectricReformulatedEIR::chilledWaterLoop() const { + return getImpl()->chilledWaterLoop(); + } + + boost::optional ChillerElectricReformulatedEIR::chilledWaterInletNode() const { + return getImpl()->chilledWaterInletNode(); + } + + boost::optional ChillerElectricReformulatedEIR::chilledWaterOutletNode() const { + return getImpl()->chilledWaterOutletNode(); + } + + boost::optional ChillerElectricReformulatedEIR::condenserWaterLoop() const { + return getImpl()->condenserWaterLoop(); + } + + boost::optional ChillerElectricReformulatedEIR::condenserInletNode() const { + return getImpl()->condenserInletNode(); + } + + boost::optional ChillerElectricReformulatedEIR::condenserOutletNode() const { + return getImpl()->condenserOutletNode(); + } + + boost::optional ChillerElectricReformulatedEIR::heatRecoveryLoop() const { + return getImpl()->heatRecoveryLoop(); + } + + boost::optional ChillerElectricReformulatedEIR::heatRecoveryInletNode() const { + return getImpl()->heatRecoveryInletNode(); + } + + boost::optional ChillerElectricReformulatedEIR::heatRecoveryOutletNode() const { + return getImpl()->heatRecoveryOutletNode(); + } + boost::optional ChillerElectricReformulatedEIR::autosizedReferenceCapacity() const { return getImpl()->autosizedReferenceCapacity(); } diff --git a/src/model/ChillerElectricReformulatedEIR.hpp b/src/model/ChillerElectricReformulatedEIR.hpp index 81febbc53e7..e7dce67db57 100644 --- a/src/model/ChillerElectricReformulatedEIR.hpp +++ b/src/model/ChillerElectricReformulatedEIR.hpp @@ -54,6 +54,8 @@ namespace model { static std::vector validCondenserFlowControlValues(); + static std::vector validElectricInputToCoolingOutputRatioFunctionOfPLRTypeValues(); + /** @name Getters */ //@{ @@ -137,7 +139,7 @@ namespace model { boost::optional temperatureDifferenceAcrossCondenserSchedule() const; - boost::optional condenserMinimumFlowFraction() const; + double condenserMinimumFlowFraction() const; boost::optional thermosiphonCapacityFractionCurve() const; @@ -244,7 +246,6 @@ namespace model { void resetTemperatureDifferenceAcrossCondenserSchedule(); bool setCondenserMinimumFlowFraction(double condenserMinimumFlowFraction); - void resetCondenserMinimumFlowFraction(); bool setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve); void resetThermosiphonCapacityFractionCurve(); @@ -266,12 +267,19 @@ namespace model { /** Convenience Function to return the Chilled Water Loop (chiller on supply) **/ boost::optional chilledWaterLoop() const; + // Same as supplyInletModelObject, but cast to a Node + boost::optional chilledWaterInletNode() const; + boost::optional chilledWaterOutletNode() const; /** Convenience Function to return the Condenser Water Loop (chiller on demand side) **/ boost::optional condenserWaterLoop() const; + boost::optional condenserInletNode() const; + boost::optional condenserOutletNode() const; /** Convenience Function to return the Heat Recovery Loop (chiller on demand side - tertiary) **/ boost::optional heatRecoveryLoop() const; + boost::optional heatRecoveryInletNode() const; + boost::optional heatRecoveryOutletNode() const; //@} protected: diff --git a/src/model/ChillerElectricReformulatedEIR_Impl.hpp b/src/model/ChillerElectricReformulatedEIR_Impl.hpp index 54b723c95ff..46fd60b1931 100644 --- a/src/model/ChillerElectricReformulatedEIR_Impl.hpp +++ b/src/model/ChillerElectricReformulatedEIR_Impl.hpp @@ -164,7 +164,7 @@ namespace model { boost::optional temperatureDifferenceAcrossCondenserSchedule() const; - boost::optional condenserMinimumFlowFraction() const; + double condenserMinimumFlowFraction() const; boost::optional thermosiphonCapacityFractionCurve() const; @@ -272,7 +272,6 @@ namespace model { void resetTemperatureDifferenceAcrossCondenserSchedule(); bool setCondenserMinimumFlowFraction(double condenserMinimumFlowFraction); - void resetCondenserMinimumFlowFraction(); bool setThermosiphonCapacityFractionCurve(const Curve& thermosiphonCapacityFractionCurve); void resetThermosiphonCapacityFractionCurve(); @@ -293,12 +292,19 @@ namespace model { /** Convenience Function to return the Chilled Water Loop (chiller on supply) **/ boost::optional chilledWaterLoop() const; + // Same as supplyInletModelObject, but cast to a Node + boost::optional chilledWaterInletNode() const; + boost::optional chilledWaterOutletNode() const; /** Convenience Function to return the Condenser Water Loop (chiller on demand side) **/ boost::optional condenserWaterLoop() const; + boost::optional condenserInletNode() const; + boost::optional condenserOutletNode() const; /** Convenience Function to return the Heat Recovery Loop (chiller on demand side - tertiary) **/ boost::optional heatRecoveryLoop() const; + boost::optional heatRecoveryInletNode() const; + boost::optional heatRecoveryOutletNode() const; //@} protected: diff --git a/src/model/ScheduleTypeRegistry.cpp b/src/model/ScheduleTypeRegistry.cpp index 142d34b9e5f..a24cbe7b579 100644 --- a/src/model/ScheduleTypeRegistry.cpp +++ b/src/model/ScheduleTypeRegistry.cpp @@ -155,8 +155,12 @@ namespace model { {"ChillerElectricEIR", "Basin Heater Operating", "basinHeaterSchedule", false, "Availability", 0.0, 1.0}, {"ChillerElectricEIR", "Heat Recovery Inlet High Temperature Limit", "heatRecoveryInletHighTemperatureLimitSchedule", true, "Temperature", OptionalDouble(), OptionalDouble()}, + {"ChillerElectricEIR", "Temperature Difference Across Condenser", "heatRecoveryInletHighTemperatureLimitSchedule", true, "Temperature", + OptionalDouble(), OptionalDouble()}, {"ChillerElectricReformulatedEIR", "Heat Recovery Inlet High Temperature Limit", "heatRecoveryInletHighTemperatureLimitSchedule", true, "Temperature", OptionalDouble(), OptionalDouble()}, + {"ChillerElectricReformulatedEIR", "Temperature Difference Across Condenser", "heatRecoveryInletHighTemperatureLimitSchedule", true, + "Temperature", OptionalDouble(), OptionalDouble()}, {"CoilCoolingCooledBeam", "Availability", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"CoilCoolingDX", "Availability Schedule", "availabilitySchedule", false, "Availability", 0.0, 1.0}, {"CoilCoolingDXCurveFitPerformance", "Evaporative Condenser Basin Heater Operating Schedule", diff --git a/src/model/SizingZone.cpp b/src/model/SizingZone.cpp index 57ece2ec0b9..a8ab2bb3e60 100644 --- a/src/model/SizingZone.cpp +++ b/src/model/SizingZone.cpp @@ -865,20 +865,11 @@ namespace model { return value.get(); } - bool SizingZone_Impl::isSizingOptionDefaulted() const { - return isEmpty(OS_Sizing_ZoneFields::SizingOption); - } - bool SizingZone_Impl::setSizingOption(const std::string& sizingOption) { bool result = setString(OS_Sizing_ZoneFields::SizingOption, sizingOption); return result; } - void SizingZone_Impl::resetSizingOption() { - bool result = setString(OS_Sizing_ZoneFields::SizingOption, ""); - OS_ASSERT(result); - } - void SizingZone_Impl::autosize() { autosizeDedicatedOutdoorAirLowSetpointTemperatureforDesign(); autosizeDedicatedOutdoorAirHighSetpointTemperatureforDesign(); @@ -1481,18 +1472,10 @@ namespace model { return getImpl()->sizingOption(); } - bool SizingZone::isSizingOptionDefaulted() const { - return getImpl()->isSizingOptionDefaulted(); - } - bool SizingZone::setSizingOption(const std::string& sizingOption) { return getImpl()->setSizingOption(sizingOption); } - void SizingZone::resetSizingOption() { - getImpl()->resetSizingOption(); - } - void SizingZone::autosize() { return getImpl()->autosize(); } diff --git a/src/model/SizingZone.hpp b/src/model/SizingZone.hpp index e2941e65f9a..9b9880b4ffd 100644 --- a/src/model/SizingZone.hpp +++ b/src/model/SizingZone.hpp @@ -166,8 +166,6 @@ namespace model { std::string sizingOption() const; - bool isSizingOptionDefaulted() const; - //@} /** @name Setters */ //@{ @@ -290,8 +288,6 @@ namespace model { bool setSizingOption(const std::string& sizingOption); - void resetSizingOption(); - //@} /** @name Other */ //@{ diff --git a/src/model/SizingZone_Impl.hpp b/src/model/SizingZone_Impl.hpp index 87ed011ccec..59e030787d9 100644 --- a/src/model/SizingZone_Impl.hpp +++ b/src/model/SizingZone_Impl.hpp @@ -164,8 +164,6 @@ namespace model { std::string sizingOption() const; - bool isSizingOptionDefaulted() const; - //@} /** @name Setters */ //@{ @@ -290,8 +288,6 @@ namespace model { bool setSizingOption(const std::string& sizingOption); - void resetSizingOption(); - //@} /** @name Other */ //@{ diff --git a/src/model/test/ChillerElectricEIR_GTest.cpp b/src/model/test/ChillerElectricEIR_GTest.cpp index 1516fffdb4f..d0d16d5e47b 100644 --- a/src/model/test/ChillerElectricEIR_GTest.cpp +++ b/src/model/test/ChillerElectricEIR_GTest.cpp @@ -7,55 +7,434 @@ #include "ModelFixture.hpp" -#include "../PlantLoop.hpp" #include "../Model.hpp" #include "../ChillerElectricEIR.hpp" + #include "../CurveBiquadratic.hpp" -#include "../CurveQuadratic.hpp" -#include "../CurveQuadratic_Impl.hpp" #include "../CurveCubic.hpp" #include "../CurveCubic_Impl.hpp" +#include "../CurveLinear.hpp" +#include "../CurveQuadratic.hpp" +#include "../CurveQuadratic_Impl.hpp" +#include "../DistrictCooling.hpp" #include "../Mixer.hpp" #include "../Mixer_Impl.hpp" -#include "../Splitter.hpp" -#include "../Splitter_Impl.hpp" +#include "../HVACComponent.hpp" +#include "../HVACComponent_Impl.hpp" #include "../Node.hpp" #include "../Node_Impl.hpp" +#include "../PlantLoop.hpp" +#include "../ScheduleConstant.hpp" +#include "../Splitter.hpp" using namespace openstudio; +using namespace openstudio::model; TEST_F(ModelFixture, ChillerElectricEIR_ChillerElectricEIR) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; ASSERT_EXIT( { - model::Model m; + Model m; - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); exit(0); }, ::testing::ExitedWithCode(0), ""); } +TEST_F(ModelFixture, ChillerElectricEIR_GettersSetters) { + Model m; + ChillerElectricEIR ch(m); + + ch.setName("My ChillerElectricEIR"); + + // Reference Capacity: Required Double + // Autosize + ch.autosizeReferenceCapacity(); + EXPECT_TRUE(ch.isReferenceCapacityAutosized()); + // Set + EXPECT_TRUE(ch.setReferenceCapacity(0.3)); + ASSERT_TRUE(ch.referenceCapacity()); + EXPECT_EQ(0.3, ch.referenceCapacity().get()); + // Bad Value + EXPECT_FALSE(ch.setReferenceCapacity(-10.0)); + ASSERT_TRUE(ch.referenceCapacity()); + EXPECT_EQ(0.3, ch.referenceCapacity().get()); + EXPECT_FALSE(ch.isReferenceCapacityAutosized()); + + // Reference COP: Required Double + EXPECT_TRUE(ch.setReferenceCOP(0.4)); + EXPECT_EQ(0.4, ch.referenceCOP()); + // Bad Value + EXPECT_FALSE(ch.setReferenceCOP(-10.0)); + EXPECT_EQ(0.4, ch.referenceCOP()); + + // Reference Leaving Chilled Water Temperature: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isReferenceLeavingChilledWaterTemperatureDefaulted()); + // Set + EXPECT_TRUE(ch.setReferenceLeavingChilledWaterTemperature(0.5)); + EXPECT_EQ(0.5, ch.referenceLeavingChilledWaterTemperature()); + EXPECT_FALSE(ch.isReferenceLeavingChilledWaterTemperatureDefaulted()); + // Reset + ch.resetReferenceLeavingChilledWaterTemperature(); + EXPECT_TRUE(ch.isReferenceLeavingChilledWaterTemperatureDefaulted()); + + // Reference Entering Condenser Fluid Temperature: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isReferenceEnteringCondenserFluidTemperatureDefaulted()); + // Set + EXPECT_TRUE(ch.setReferenceEnteringCondenserFluidTemperature(0.6)); + EXPECT_EQ(0.6, ch.referenceEnteringCondenserFluidTemperature()); + EXPECT_FALSE(ch.isReferenceEnteringCondenserFluidTemperatureDefaulted()); + // Reset + ch.resetReferenceEnteringCondenserFluidTemperature(); + EXPECT_TRUE(ch.isReferenceEnteringCondenserFluidTemperatureDefaulted()); + + // Reference Chilled Water Flow Rate: Required Double + // Autosize + ch.autosizeReferenceChilledWaterFlowRate(); + EXPECT_TRUE(ch.isReferenceChilledWaterFlowRateAutosized()); + // Set + EXPECT_TRUE(ch.setReferenceChilledWaterFlowRate(0.7)); + ASSERT_TRUE(ch.referenceChilledWaterFlowRate()); + EXPECT_EQ(0.7, ch.referenceChilledWaterFlowRate().get()); + // Bad Value + EXPECT_FALSE(ch.setReferenceChilledWaterFlowRate(-10.0)); + ASSERT_TRUE(ch.referenceChilledWaterFlowRate()); + EXPECT_EQ(0.7, ch.referenceChilledWaterFlowRate().get()); + EXPECT_FALSE(ch.isReferenceChilledWaterFlowRateAutosized()); + + // Reference Condenser Fluid Flow Rate: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isReferenceCondenserFluidFlowRateAutosized()); + // Set + EXPECT_TRUE(ch.setReferenceCondenserFluidFlowRate(0.8)); + ASSERT_TRUE(ch.referenceCondenserFluidFlowRate()); + EXPECT_EQ(0.8, ch.referenceCondenserFluidFlowRate().get()); + // Bad Value + EXPECT_FALSE(ch.setReferenceCondenserFluidFlowRate(-10.0)); + ASSERT_TRUE(ch.referenceCondenserFluidFlowRate()); + EXPECT_EQ(0.8, ch.referenceCondenserFluidFlowRate().get()); + // Autosize + ch.autosizeReferenceCondenserFluidFlowRate(); + EXPECT_TRUE(ch.isReferenceCondenserFluidFlowRateAutosized()); + // Reset + EXPECT_TRUE(ch.setReferenceCondenserFluidFlowRate(0.8)); + ch.resetReferenceCondenserFluidFlowRate(); + EXPECT_TRUE(ch.isReferenceCondenserFluidFlowRateAutosized()); + + // Cooling Capacity Function of Temperature Curve Name: Required Object + CurveBiquadratic ccFofT(m); + EXPECT_TRUE(ch.setCoolingCapacityFunctionOfTemperature(ccFofT)); + EXPECT_EQ(ccFofT, ch.coolingCapacityFunctionOfTemperature()); + + // Electric Input to Cooling Output Ratio Function of Temperature Curve Name: Required Object + CurveBiquadratic eirToCorfOfT(m); + EXPECT_TRUE(ch.setElectricInputToCoolingOutputRatioFunctionOfTemperature(eirToCorfOfT)); + EXPECT_EQ(eirToCorfOfT, ch.electricInputToCoolingOutputRatioFunctionOfTemperature()); + + // Electric Input to Cooling Output Ratio Function of Part Load Ratio Curve Name: Required Object + CurveQuadratic eiToCorfOfPlr(m); + EXPECT_TRUE(ch.setElectricInputToCoolingOutputRatioFunctionOfPLR(eiToCorfOfPlr)); + EXPECT_EQ(eiToCorfOfPlr, ch.electricInputToCoolingOutputRatioFunctionOfPLR()); + + // Minimum Part Load Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isMinimumPartLoadRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setMinimumPartLoadRatio(1.2)); + EXPECT_EQ(1.2, ch.minimumPartLoadRatio()); + EXPECT_FALSE(ch.isMinimumPartLoadRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setMinimumPartLoadRatio(-10.0)); + EXPECT_EQ(1.2, ch.minimumPartLoadRatio()); + // Reset + ch.resetMinimumPartLoadRatio(); + EXPECT_TRUE(ch.isMinimumPartLoadRatioDefaulted()); + + // Maximum Part Load Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isMaximumPartLoadRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setMaximumPartLoadRatio(1.3)); + EXPECT_EQ(1.3, ch.maximumPartLoadRatio()); + EXPECT_FALSE(ch.isMaximumPartLoadRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setMaximumPartLoadRatio(-10.0)); + EXPECT_EQ(1.3, ch.maximumPartLoadRatio()); + // Reset + ch.resetMaximumPartLoadRatio(); + EXPECT_TRUE(ch.isMaximumPartLoadRatioDefaulted()); + + // Optimum Part Load Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isOptimumPartLoadRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setOptimumPartLoadRatio(1.4)); + EXPECT_EQ(1.4, ch.optimumPartLoadRatio()); + EXPECT_FALSE(ch.isOptimumPartLoadRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setOptimumPartLoadRatio(-10.0)); + EXPECT_EQ(1.4, ch.optimumPartLoadRatio()); + // Reset + ch.resetOptimumPartLoadRatio(); + EXPECT_TRUE(ch.isOptimumPartLoadRatioDefaulted()); + + // Minimum Unloading Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isMinimumUnloadingRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setMinimumUnloadingRatio(1.5)); + EXPECT_EQ(1.5, ch.minimumUnloadingRatio()); + EXPECT_FALSE(ch.isMinimumUnloadingRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setMinimumUnloadingRatio(-10.0)); + EXPECT_EQ(1.5, ch.minimumUnloadingRatio()); + // Reset + ch.resetMinimumUnloadingRatio(); + EXPECT_TRUE(ch.isMinimumUnloadingRatioDefaulted()); + + // Chilled Water Inlet Node Name: Required Object + // Chilled Water Outlet Node Name: Required Object + + // Condenser Inlet Node Name: Optional Object + // Condenser Outlet Node Name: Optional Object + + // Condenser Type + + // Condenser Fan Power Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isCondenserFanPowerRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setCondenserFanPowerRatio(2.1)); + EXPECT_EQ(2.1, ch.condenserFanPowerRatio()); + EXPECT_FALSE(ch.isCondenserFanPowerRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setCondenserFanPowerRatio(-10.0)); + EXPECT_EQ(2.1, ch.condenserFanPowerRatio()); + // Reset + ch.resetCondenserFanPowerRatio(); + EXPECT_TRUE(ch.isCondenserFanPowerRatioDefaulted()); + + // Fraction of Compressor Electric Consumption Rejected by Condenser: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isFractionofCompressorElectricConsumptionRejectedbyCondenserDefaulted()); + // Set + EXPECT_TRUE(ch.setFractionofCompressorElectricConsumptionRejectedbyCondenser(0.957)); + EXPECT_EQ(0.957, ch.fractionofCompressorElectricConsumptionRejectedbyCondenser()); + EXPECT_FALSE(ch.isFractionofCompressorElectricConsumptionRejectedbyCondenserDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setFractionofCompressorElectricConsumptionRejectedbyCondenser(-10.0)); + EXPECT_EQ(0.957, ch.fractionofCompressorElectricConsumptionRejectedbyCondenser()); + // Reset + ch.resetFractionofCompressorElectricConsumptionRejectedbyCondenser(); + EXPECT_TRUE(ch.isFractionofCompressorElectricConsumptionRejectedbyCondenserDefaulted()); + + // Leaving Chilled Water Lower Temperature Limit: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isLeavingChilledWaterLowerTemperatureLimitDefaulted()); + // Set + EXPECT_TRUE(ch.setLeavingChilledWaterLowerTemperatureLimit(2.3)); + EXPECT_EQ(2.3, ch.leavingChilledWaterLowerTemperatureLimit()); + EXPECT_FALSE(ch.isLeavingChilledWaterLowerTemperatureLimitDefaulted()); + // Reset + ch.resetLeavingChilledWaterLowerTemperatureLimit(); + EXPECT_TRUE(ch.isLeavingChilledWaterLowerTemperatureLimitDefaulted()); + + // Chiller Flow Mode: Optional String + // Default value from IDD + EXPECT_TRUE(ch.isChillerFlowModeDefaulted()); + EXPECT_EQ("NotModulated", ch.chillerFlowMode()); + // Set + EXPECT_TRUE(ch.setChillerFlowMode("ConstantFlow")); + EXPECT_EQ("ConstantFlow", ch.chillerFlowMode()); + EXPECT_FALSE(ch.isChillerFlowModeDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setChillerFlowMode("BADENUM")); + EXPECT_EQ("ConstantFlow", ch.chillerFlowMode()); + // Reset + ch.resetChillerFlowMode(); + EXPECT_TRUE(ch.isChillerFlowModeDefaulted()); + + // Design Heat Recovery Water Flow Rate: Required Double + // Autosize + ch.autosizeDesignHeatRecoveryWaterFlowRate(); + EXPECT_TRUE(ch.isDesignHeatRecoveryWaterFlowRateAutosized()); + // Set + EXPECT_TRUE(ch.setDesignHeatRecoveryWaterFlowRate(2.5)); + ASSERT_TRUE(ch.designHeatRecoveryWaterFlowRate()); + EXPECT_EQ(2.5, ch.designHeatRecoveryWaterFlowRate().get()); + // Bad Value + EXPECT_FALSE(ch.setDesignHeatRecoveryWaterFlowRate(-10.0)); + ASSERT_TRUE(ch.designHeatRecoveryWaterFlowRate()); + EXPECT_EQ(2.5, ch.designHeatRecoveryWaterFlowRate().get()); + EXPECT_FALSE(ch.isDesignHeatRecoveryWaterFlowRateAutosized()); + + // Heat Recovery Inlet Node Name: Optional Object + // Heat Recovery Outlet Node Name: Optional Object + + // Sizing Factor: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isSizingFactorDefaulted()); + // Set + EXPECT_TRUE(ch.setSizingFactor(2.8)); + EXPECT_EQ(2.8, ch.sizingFactor()); + EXPECT_FALSE(ch.isSizingFactorDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setSizingFactor(-10.0)); + EXPECT_EQ(2.8, ch.sizingFactor()); + // Reset + ch.resetSizingFactor(); + EXPECT_TRUE(ch.isSizingFactorDefaulted()); + + // Basin Heater Capacity: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isBasinHeaterCapacityDefaulted()); + // Set + EXPECT_TRUE(ch.setBasinHeaterCapacity(2.9)); + EXPECT_EQ(2.9, ch.basinHeaterCapacity()); + EXPECT_FALSE(ch.isBasinHeaterCapacityDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setBasinHeaterCapacity(-10.0)); + EXPECT_EQ(2.9, ch.basinHeaterCapacity()); + // Reset + ch.resetBasinHeaterCapacity(); + EXPECT_TRUE(ch.isBasinHeaterCapacityDefaulted()); + + // Basin Heater Setpoint Temperature: Optional Double + // Default value from IDD + EXPECT_FALSE(ch.isBasinHeaterSetpointTemperatureDefaulted()); + EXPECT_EQ(10.0, ch.basinHeaterSetpointTemperature()); + // Set + EXPECT_TRUE(ch.setBasinHeaterSetpointTemperature(5.0)); + EXPECT_EQ(5.0, ch.basinHeaterSetpointTemperature()); + EXPECT_FALSE(ch.isBasinHeaterSetpointTemperatureDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setBasinHeaterSetpointTemperature(-8.0)); + EXPECT_EQ(5.0, ch.basinHeaterSetpointTemperature()); + // Reset + ch.resetBasinHeaterSetpointTemperature(); + EXPECT_TRUE(ch.isBasinHeaterSetpointTemperatureDefaulted()); + EXPECT_EQ(2.0, ch.basinHeaterSetpointTemperature()); + + // Basin Heater Operating Schedule Name: Optional Object + ScheduleConstant basinHeaterOperatingSchedule(m); + EXPECT_TRUE(ch.setBasinHeaterSchedule(basinHeaterOperatingSchedule)); + ASSERT_TRUE(ch.basinHeaterSchedule()); + EXPECT_EQ(basinHeaterOperatingSchedule, ch.basinHeaterSchedule().get()); + // Reset + ch.resetBasinHeaterSchedule(); + EXPECT_FALSE(ch.basinHeaterSchedule()); + + // Condenser Heat Recovery Relative Capacity Fraction: Required Double + EXPECT_TRUE(ch.setCondenserHeatRecoveryRelativeCapacityFraction(0.97)); + EXPECT_EQ(0.97, ch.condenserHeatRecoveryRelativeCapacityFraction()); + // Bad Value + EXPECT_FALSE(ch.setCondenserHeatRecoveryRelativeCapacityFraction(-10.0)); + EXPECT_EQ(0.97, ch.condenserHeatRecoveryRelativeCapacityFraction()); + + // Heat Recovery Inlet High Temperature Limit Schedule Name: Optional Object + ScheduleConstant heatRecoveryInletHighTemperatureLimitSchedule(m); + EXPECT_TRUE(ch.setHeatRecoveryInletHighTemperatureLimitSchedule(heatRecoveryInletHighTemperatureLimitSchedule)); + ASSERT_TRUE(ch.heatRecoveryInletHighTemperatureLimitSchedule()); + EXPECT_EQ(heatRecoveryInletHighTemperatureLimitSchedule, ch.heatRecoveryInletHighTemperatureLimitSchedule().get()); + // Reset + ch.resetHeatRecoveryInletHighTemperatureLimitSchedule(); + EXPECT_FALSE(ch.heatRecoveryInletHighTemperatureLimitSchedule()); + + // Heat Recovery Leaving Temperature Setpoint Node Name: Optional Object + + // End-Use Subcategory: String + EXPECT_EQ("General", ch.endUseSubcategory()); + // Set + EXPECT_TRUE(ch.setEndUseSubcategory("Chillers")); + EXPECT_EQ("Chillers", ch.endUseSubcategory()); + + // Condenser Flow Control: Required String + EXPECT_TRUE(ch.setCondenserFlowControl("ConstantFlow")); + EXPECT_EQ("ConstantFlow", ch.condenserFlowControl()); + // Bad Value + EXPECT_FALSE(ch.setCondenserFlowControl("BADENUM")); + EXPECT_EQ("ConstantFlow", ch.condenserFlowControl()); + + // Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name: Optional Object + CurveLinear condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(m); + EXPECT_TRUE(ch.setCondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve)); + ASSERT_TRUE(ch.condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve()); + EXPECT_EQ(condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve, ch.condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve().get()); + // Reset + ch.resetCondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(); + EXPECT_FALSE(ch.condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve()); + + // Temperature Difference Across Condenser Schedule Name: Optional Object + ScheduleConstant temperatureDifferenceAcrossCondenserSchedule(m); + EXPECT_TRUE(ch.setTemperatureDifferenceAcrossCondenserSchedule(temperatureDifferenceAcrossCondenserSchedule)); + ASSERT_TRUE(ch.temperatureDifferenceAcrossCondenserSchedule()); + EXPECT_EQ(temperatureDifferenceAcrossCondenserSchedule, ch.temperatureDifferenceAcrossCondenserSchedule().get()); + // Reset + ch.resetTemperatureDifferenceAcrossCondenserSchedule(); + EXPECT_FALSE(ch.temperatureDifferenceAcrossCondenserSchedule()); + + // Condenser Minimum Flow Fraction: Required Double + EXPECT_TRUE(ch.setCondenserMinimumFlowFraction(0.9)); + EXPECT_EQ(0.9, ch.condenserMinimumFlowFraction()); + + // Thermosiphon Capacity Fraction Curve Name: Optional Object + CurveLinear thermosiphonCapacityFractionCurve(m); + EXPECT_TRUE(ch.setThermosiphonCapacityFractionCurve(thermosiphonCapacityFractionCurve)); + ASSERT_TRUE(ch.thermosiphonCapacityFractionCurve()); + EXPECT_EQ(thermosiphonCapacityFractionCurve, ch.thermosiphonCapacityFractionCurve().get()); + // Reset + ch.resetThermosiphonCapacityFractionCurve(); + EXPECT_FALSE(ch.thermosiphonCapacityFractionCurve()); + + // Thermosiphon Minimum Temperature Difference: Required Double + EXPECT_TRUE(ch.setThermosiphonMinimumTemperatureDifference(4.1)); + EXPECT_EQ(4.1, ch.thermosiphonMinimumTemperatureDifference()); + // Bad Value + EXPECT_FALSE(ch.setThermosiphonMinimumTemperatureDifference(-10.0)); + EXPECT_EQ(4.1, ch.thermosiphonMinimumTemperatureDifference()); +} + +TEST_F(ModelFixture, ChillerElectricEIR_HeatCoolFuelTypes) { + Model m; + ChillerElectricEIR ch(m); + + EXPECT_EQ(ComponentType(ComponentType::Cooling), ch.componentType()); + testFuelTypeEquality({FuelType::Electricity}, ch.coolingFuelTypes()); + // Add a CondenserWaterLoop with a component that has another fuel than electricity + PlantLoop cndLoop(m); + cndLoop.addDemandBranchForComponent(ch); + testFuelTypeEquality({FuelType::Electricity}, ch.coolingFuelTypes()); + DistrictCooling dc(m); + cndLoop.addSupplyBranchForComponent(dc); + testFuelTypeEquality({FuelType::Electricity, FuelType::DistrictCooling}, ch.coolingFuelTypes()); + + testFuelTypeEquality({}, ch.heatingFuelTypes()); + testAppGFuelTypeEquality({}, ch.appGHeatingFuelTypes()); +} + // Add to the end of an empty supply side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricEIR_addToNode1) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node supplyOutletNode = plantLoop.supplyOutletNode(); - model::Mixer supplyMixer = plantLoop.supplyMixer(); + Node supplyOutletNode = plantLoop.supplyOutletNode(); + Mixer supplyMixer = plantLoop.supplyMixer(); EXPECT_TRUE(chiller.addToNode(supplyOutletNode)); @@ -65,11 +444,11 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToNode1) { EXPECT_EQ(supplyOutletNode, chiller.supplyOutletModelObject().get()); - boost::optional mo = chiller.supplyInletModelObject(); + boost::optional mo = chiller.supplyInletModelObject(); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -77,30 +456,30 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToNode1) { ASSERT_TRUE(mo); - boost::optional mixer = mo->optionalCast(); + boost::optional mixer = mo->optionalCast(); ASSERT_TRUE(mixer); } // Add to the front of an empty supply side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricEIR_addToNode2) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node supplyInletNode = plantLoop.supplyInletNode(); + Node supplyInletNode = plantLoop.supplyInletNode(); EXPECT_TRUE(chiller.addToNode(supplyInletNode)); EXPECT_EQ(7u, plantLoop.supplyComponents().size()); - boost::optional mo = chiller.supplyInletModelObject(); + boost::optional mo = chiller.supplyInletModelObject(); ASSERT_TRUE(mo); @@ -110,7 +489,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToNode2) { ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -123,24 +502,24 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToNode2) { // Add to the middle of the existing branch. TEST_F(ModelFixture, ChillerElectricEIR_addToNode3) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Mixer supplyMixer = plantLoop.supplyMixer(); - model::Splitter supplySplitter = plantLoop.supplySplitter(); + Mixer supplyMixer = plantLoop.supplyMixer(); + Splitter supplySplitter = plantLoop.supplySplitter(); - boost::optional mo = supplyMixer.inletModelObject(0); + boost::optional mo = supplyMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -164,7 +543,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToNode3) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -176,45 +555,45 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToNode3) { mo = supplySplitter.outletModelObject(0); - boost::optional mo2 = supplyMixer.inletModelObject(0); + boost::optional mo2 = supplyMixer.inletModelObject(0); ASSERT_TRUE(mo); ASSERT_TRUE(mo2); - boost::optional comp = mo->optionalCast(); - boost::optional comp2 = mo2->optionalCast(); + boost::optional comp = mo->optionalCast(); + boost::optional comp2 = mo2->optionalCast(); ASSERT_TRUE(comp); ASSERT_TRUE(comp2); - std::vector comps = plantLoop.supplyComponents(comp.get(), comp2.get()); + std::vector comps = plantLoop.supplyComponents(comp.get(), comp2.get()); ASSERT_EQ(3u, comps.size()); } // Add to new branch TEST_F(ModelFixture, ChillerElectricEIR_PlantLoop_addSupplyBranch) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); ASSERT_TRUE(plantLoop.addSupplyBranchForComponent(chiller)); EXPECT_EQ(7u, plantLoop.supplyComponents().size()); - model::Mixer supplyMixer = plantLoop.supplyMixer(); + Mixer supplyMixer = plantLoop.supplyMixer(); - boost::optional mo = supplyMixer.inletModelObject(0); + boost::optional mo = supplyMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -228,7 +607,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoop_addSupplyBranch) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -241,18 +620,18 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoop_addSupplyBranch) { // Add to the end of an empty demand side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode1) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node demandOutletNode = plantLoop.demandOutletNode(); - model::Mixer demandMixer = plantLoop.demandMixer(); + Node demandOutletNode = plantLoop.demandOutletNode(); + Mixer demandMixer = plantLoop.demandMixer(); EXPECT_TRUE(chiller.addToNode(demandOutletNode)); @@ -262,11 +641,11 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode1) { EXPECT_EQ(demandOutletNode, chiller.demandOutletModelObject().get()); - boost::optional mo = chiller.demandInletModelObject(); + boost::optional mo = chiller.demandInletModelObject(); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -274,7 +653,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode1) { ASSERT_TRUE(mo); - boost::optional mixer = mo->optionalCast(); + boost::optional mixer = mo->optionalCast(); ASSERT_TRUE(mixer); @@ -285,23 +664,23 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode1) { // Add to the front of an empty demand side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode2) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node demandInletNode = plantLoop.demandInletNode(); + Node demandInletNode = plantLoop.demandInletNode(); EXPECT_TRUE(chiller.addToNode(demandInletNode)); EXPECT_EQ(7u, plantLoop.demandComponents().size()); - boost::optional mo = chiller.demandInletModelObject(); + boost::optional mo = chiller.demandInletModelObject(); ASSERT_TRUE(mo); @@ -311,7 +690,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode2) { ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -328,23 +707,23 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode2) { // Add to the middle of the existing branch. TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode3) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Mixer demandMixer = plantLoop.demandMixer(); + Mixer demandMixer = plantLoop.demandMixer(); - boost::optional mo = demandMixer.inletModelObject(0); + boost::optional mo = demandMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -362,7 +741,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode3) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -379,27 +758,27 @@ TEST_F(ModelFixture, ChillerElectricEIR_addToDemandNode3) { // Add to new demand branch TEST_F(ModelFixture, ChillerElectricEIR_PlantLoop_addDemandBranch) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveQuadratic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveQuadratic eiToCorfOfPlr(m); - model::ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); ASSERT_TRUE(plantLoop.addDemandBranchForComponent(chiller)); EXPECT_EQ(7u, plantLoop.demandComponents().size()); - model::Mixer demandMixer = plantLoop.demandMixer(); + Mixer demandMixer = plantLoop.demandMixer(); - boost::optional mo = demandMixer.inletModelObject(0); + boost::optional mo = demandMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -413,7 +792,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoop_addDemandBranch) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -430,12 +809,12 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoop_addDemandBranch) { // Check condenser type setting/defaulting TEST_F(ModelFixture, ChillerElectricEIR_CondenserType) { - model::Model m; + Model m; - model::PlantLoop pl1(m); - model::PlantLoop pl2(m); + PlantLoop pl1(m); + PlantLoop pl2(m); - model::ChillerElectricEIR ch(m); + ChillerElectricEIR ch(m); // By default, AirCooled (from IDD) EXPECT_EQ("AirCooled", ch.condenserType()); @@ -484,12 +863,12 @@ TEST_F(ModelFixture, ChillerElectricEIR_CondenserType) { } TEST_F(ModelFixture, ChillerElectricEIR_PlantLoopConnections) { - model::Model model; - model::ChillerElectricEIR chiller(model); + Model model; + ChillerElectricEIR chiller(model); // Chilled Water Loop: on the supply side { - model::PlantLoop chwLoop(model); + PlantLoop chwLoop(model); auto node = chwLoop.supplyOutletNode(); EXPECT_TRUE(chiller.addToNode(node)); auto plant = chiller.plantLoop(); @@ -510,7 +889,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoopConnections) { // Condenser Loop: on the demand side { - model::PlantLoop cndwLoop(model); + PlantLoop cndwLoop(model); auto node = cndwLoop.demandInletNode(); EXPECT_TRUE(chiller.addToNode(node)); auto plant = chiller.secondaryPlantLoop(); @@ -531,7 +910,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoopConnections) { // Heat Recovery Loop: on the demand side { - model::PlantLoop hrLoop(model); + PlantLoop hrLoop(model); auto node = hrLoop.demandOutletNode(); EXPECT_TRUE(chiller.addToTertiaryNode(node)); auto plant = chiller.tertiaryPlantLoop(); @@ -562,16 +941,16 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoopConnections) { * This should work with addDemandBranchForComponent too * AddToTertiaryNode is overriden to not work when trying to add to a supply side node */ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoopConnections_addToNodeOverride) { - model::Model model; - model::ChillerElectricEIR chiller(model); + Model model; + ChillerElectricEIR chiller(model); - model::PlantLoop chwLoop(model); + PlantLoop chwLoop(model); - model::PlantLoop cndwLoop(model); - model::PlantLoop cndwLoop2(model); + PlantLoop cndwLoop(model); + PlantLoop cndwLoop2(model); auto c_demand_node2 = cndwLoop2.demandOutletNode(); - model::PlantLoop hrLoop(model); + PlantLoop hrLoop(model); auto h_supply_node = hrLoop.supplyOutletNode(); auto h_demand_node = hrLoop.demandInletNode(); @@ -640,34 +1019,34 @@ TEST_F(ModelFixture, ChillerElectricEIR_PlantLoopConnections_addToNodeOverride) TEST_F(ModelFixture, ChillerElectricEIR_ElectricInputToCoolingOutputRatioFunctionOfPLR) { // Test for #4611 - Allow non-Quadratic curves for the EIR-f-PLR for the Chiller:Electric:EIR object - model::Model model; + Model model; // test ctor 1 { // ctor maintains backward compatibility - model::ChillerElectricEIR chiller(model); - ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); + ChillerElectricEIR chiller(model); + ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); } // test ctor 2 { // ctor maintains backward compatibility - model::CurveBiquadratic ccFofT(model); - model::CurveBiquadratic eirToCorfOfT(model); - model::CurveQuadratic eirToCorfOfPlr(model); - model::ChillerElectricEIR chiller(model, ccFofT, eirToCorfOfT, eirToCorfOfPlr); - ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); + CurveBiquadratic ccFofT(model); + CurveBiquadratic eirToCorfOfT(model); + CurveQuadratic eirToCorfOfPlr(model); + ChillerElectricEIR chiller(model, ccFofT, eirToCorfOfT, eirToCorfOfPlr); + ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); EXPECT_EQ(ccFofT, chiller.coolingCapacityFunctionOfTemperature()); EXPECT_EQ(eirToCorfOfT, chiller.electricInputToCoolingOutputRatioFunctionOfTemperature()); EXPECT_EQ(eirToCorfOfPlr, chiller.electricInputToCoolingOutputRatioFunctionOfPLR()); } { // ctor can now handle cubic curves - model::CurveBiquadratic ccFofT2(model); - model::CurveBiquadratic eirToCorfOfT2(model); - model::CurveCubic eirToCorfOfPlr2(model); - model::ChillerElectricEIR chiller(model, ccFofT2, eirToCorfOfT2, eirToCorfOfPlr2); - ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); + CurveBiquadratic ccFofT2(model); + CurveBiquadratic eirToCorfOfT2(model); + CurveCubic eirToCorfOfPlr2(model); + ChillerElectricEIR chiller(model, ccFofT2, eirToCorfOfT2, eirToCorfOfPlr2); + ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); EXPECT_EQ(ccFofT2, chiller.coolingCapacityFunctionOfTemperature()); EXPECT_EQ(eirToCorfOfT2, chiller.electricInputToCoolingOutputRatioFunctionOfTemperature()); EXPECT_EQ(eirToCorfOfPlr2, chiller.electricInputToCoolingOutputRatioFunctionOfPLR()); @@ -675,18 +1054,18 @@ TEST_F(ModelFixture, ChillerElectricEIR_ElectricInputToCoolingOutputRatioFunctio // test new setter/getter { - model::ChillerElectricEIR chiller(model); + ChillerElectricEIR chiller(model); // setter maintains backward compatibility - model::CurveQuadratic curveQuadratic(model); + CurveQuadratic curveQuadratic(model); EXPECT_TRUE(chiller.setElectricInputToCoolingOutputRatioFunctionOfPLR(curveQuadratic)); - ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); + ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); EXPECT_EQ(curveQuadratic, chiller.electricInputToCoolingOutputRatioFunctionOfPLR()); // setter can now handle cubic curves - model::CurveCubic curveCubic(model); + CurveCubic curveCubic(model); EXPECT_TRUE(chiller.setElectricInputToCoolingOutputRatioFunctionOfPLR(curveCubic)); - ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); + ASSERT_TRUE(chiller.electricInputToCoolingOutputRatioFunctionOfPLR().optionalCast()); EXPECT_EQ(curveCubic, chiller.electricInputToCoolingOutputRatioFunctionOfPLR()); } } @@ -694,22 +1073,22 @@ TEST_F(ModelFixture, ChillerElectricEIR_ElectricInputToCoolingOutputRatioFunctio TEST_F(ModelFixture, ChillerElectricEIR_HeatRecoverySetpointNode) { // Test for #4724 - model::Model model; - model::ChillerElectricEIR chiller(model); + Model model; + ChillerElectricEIR chiller(model); // Chilled Water Loop: on the supply side - model::PlantLoop chwLoop(model); + PlantLoop chwLoop(model); EXPECT_TRUE(chwLoop.addSupplyBranchForComponent(chiller)); EXPECT_TRUE(chiller.plantLoop()); EXPECT_TRUE(chiller.chilledWaterLoop()); // Condenser Loop: on the demand side - model::PlantLoop cndwLoop(model); + PlantLoop cndwLoop(model); EXPECT_TRUE(cndwLoop.addDemandBranchForComponent(chiller)); EXPECT_TRUE(chiller.secondaryPlantLoop()); EXPECT_TRUE(chiller.condenserWaterLoop()); - model::PlantLoop hrLoop(model); + PlantLoop hrLoop(model); EXPECT_TRUE(hrLoop.addDemandBranchForComponent(chiller)); EXPECT_TRUE(chiller.tertiaryPlantLoop()); EXPECT_TRUE(chiller.heatRecoveryLoop()); @@ -732,7 +1111,7 @@ TEST_F(ModelFixture, ChillerElectricEIR_HeatRecoverySetpointNode) { // Get the Chiller Tertirary Outlet Node = HR Loop Outlet Node ASSERT_TRUE(chiller.tertiaryOutletModelObject()); - auto hrOutletNode = chiller.tertiaryOutletModelObject()->cast(); + auto hrOutletNode = chiller.tertiaryOutletModelObject()->cast(); // Actual test for #4724 EXPECT_TRUE(chiller.setHeatRecoveryLeavingTemperatureSetpointNode(hrOutletNode)); ASSERT_TRUE(chiller.heatRecoveryLeavingTemperatureSetpointNode()); diff --git a/src/model/test/ChillerElectricReformulatedEIR_GTest.cpp b/src/model/test/ChillerElectricReformulatedEIR_GTest.cpp index 3dde60966ca..413f61c5fde 100644 --- a/src/model/test/ChillerElectricReformulatedEIR_GTest.cpp +++ b/src/model/test/ChillerElectricReformulatedEIR_GTest.cpp @@ -7,52 +7,388 @@ #include "ModelFixture.hpp" -#include "../PlantLoop.hpp" #include "../Model.hpp" #include "../ChillerElectricReformulatedEIR.hpp" + #include "../CurveBiquadratic.hpp" #include "../CurveBicubic.hpp" +#include "../CurveLinear.hpp" +#include "../DistrictCooling.hpp" #include "../Mixer.hpp" #include "../Mixer_Impl.hpp" -#include "../Splitter.hpp" -#include "../Splitter_Impl.hpp" #include "../Node.hpp" #include "../Node_Impl.hpp" +#include "../PlantLoop.hpp" +#include "../ScheduleConstant.hpp" +#include "../Splitter.hpp" +#include "../Splitter_Impl.hpp" using namespace openstudio; +using namespace openstudio::model; TEST_F(ModelFixture, ChillerElectricReformulatedEIR_ChillerElectricReformulatedEIR) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; ASSERT_EXIT( { - model::Model m; + Model m; - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); exit(0); }, ::testing::ExitedWithCode(0), ""); } +TEST_F(ModelFixture, ChillerElectricReformulatedEIR_GettersSetters) { + Model m; + ChillerElectricReformulatedEIR ch(m); + + ch.setName("My ChillerElectricReformulatedEIR"); + + // Reference Capacity: Required Double + // Autosize + ch.autosizeReferenceCapacity(); + EXPECT_TRUE(ch.isReferenceCapacityAutosized()); + // Set + EXPECT_TRUE(ch.setReferenceCapacity(0.3)); + ASSERT_TRUE(ch.referenceCapacity()); + EXPECT_EQ(0.3, ch.referenceCapacity().get()); + // Bad Value + EXPECT_FALSE(ch.setReferenceCapacity(-10.0)); + ASSERT_TRUE(ch.referenceCapacity()); + EXPECT_EQ(0.3, ch.referenceCapacity().get()); + EXPECT_FALSE(ch.isReferenceCapacityAutosized()); + + // Reference COP: Required Double + EXPECT_TRUE(ch.setReferenceCOP(0.4)); + EXPECT_EQ(0.4, ch.referenceCOP()); + // Bad Value + EXPECT_FALSE(ch.setReferenceCOP(-10.0)); + EXPECT_EQ(0.4, ch.referenceCOP()); + + // Reference Leaving Chilled Water Temperature: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isReferenceLeavingChilledWaterTemperatureDefaulted()); + // Set + EXPECT_TRUE(ch.setReferenceLeavingChilledWaterTemperature(0.5)); + EXPECT_EQ(0.5, ch.referenceLeavingChilledWaterTemperature()); + EXPECT_FALSE(ch.isReferenceLeavingChilledWaterTemperatureDefaulted()); + // Reset + ch.resetReferenceLeavingChilledWaterTemperature(); + EXPECT_TRUE(ch.isReferenceLeavingChilledWaterTemperatureDefaulted()); + + // Reference Leaving Condenser Water Temperature: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isReferenceLeavingCondenserWaterTemperatureDefaulted()); + // Set + EXPECT_TRUE(ch.setReferenceLeavingCondenserWaterTemperature(0.6)); + EXPECT_EQ(0.6, ch.referenceLeavingCondenserWaterTemperature()); + EXPECT_FALSE(ch.isReferenceLeavingCondenserWaterTemperatureDefaulted()); + // Reset + ch.resetReferenceLeavingCondenserWaterTemperature(); + EXPECT_TRUE(ch.isReferenceLeavingCondenserWaterTemperatureDefaulted()); + + // Reference Chilled Water Flow Rate: Required Double + // Autosize + ch.autosizeReferenceChilledWaterFlowRate(); + EXPECT_TRUE(ch.isReferenceChilledWaterFlowRateAutosized()); + // Set + EXPECT_TRUE(ch.setReferenceChilledWaterFlowRate(0.7)); + ASSERT_TRUE(ch.referenceChilledWaterFlowRate()); + EXPECT_EQ(0.7, ch.referenceChilledWaterFlowRate().get()); + // Bad Value + EXPECT_FALSE(ch.setReferenceChilledWaterFlowRate(-10.0)); + ASSERT_TRUE(ch.referenceChilledWaterFlowRate()); + EXPECT_EQ(0.7, ch.referenceChilledWaterFlowRate().get()); + EXPECT_FALSE(ch.isReferenceChilledWaterFlowRateAutosized()); + + // Reference Condenser Water Flow Rate: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isReferenceCondenserWaterFlowRateAutosized()); + // Set + EXPECT_TRUE(ch.setReferenceCondenserWaterFlowRate(0.8)); + ASSERT_TRUE(ch.referenceCondenserWaterFlowRate()); + EXPECT_EQ(0.8, ch.referenceCondenserWaterFlowRate().get()); + // Bad Value + EXPECT_FALSE(ch.setReferenceCondenserWaterFlowRate(-10.0)); + ASSERT_TRUE(ch.referenceCondenserWaterFlowRate()); + EXPECT_EQ(0.8, ch.referenceCondenserWaterFlowRate().get()); + // Autosize + ch.autosizeReferenceCondenserWaterFlowRate(); + EXPECT_TRUE(ch.isReferenceCondenserWaterFlowRateAutosized()); + // Reset + EXPECT_TRUE(ch.setReferenceCondenserWaterFlowRate(0.8)); + ch.resetReferenceCondenserWaterFlowRate(); + EXPECT_TRUE(ch.isReferenceCondenserWaterFlowRateAutosized()); + + // Cooling Capacity Function of Temperature Curve Name: Required Object + CurveBiquadratic ccFofT(m); + EXPECT_TRUE(ch.setCoolingCapacityFunctionOfTemperature(ccFofT)); + EXPECT_EQ(ccFofT, ch.coolingCapacityFunctionOfTemperature()); + + // Electric Input to Cooling Output Ratio Function of Temperature Curve Name: Required Object + CurveBiquadratic eirToCorfOfT(m); + EXPECT_TRUE(ch.setElectricInputToCoolingOutputRatioFunctionOfTemperature(eirToCorfOfT)); + EXPECT_EQ(eirToCorfOfT, ch.electricInputToCoolingOutputRatioFunctionOfTemperature()); + + // Electric Input to Cooling Output Ratio Function of Part Load Ratio Curve Type: Optional String + // Default value from IDD but harcoded in Ctor.. and no isDefaulted getter... + EXPECT_EQ("LeavingCondenserWaterTemperature", ch.electricInputToCoolingOutputRatioFunctionOfPLRType()); + // Set + EXPECT_TRUE(ch.setElectricInputToCoolingOutputRatioFunctionOfPLRType("Lift")); + EXPECT_EQ("Lift", ch.electricInputToCoolingOutputRatioFunctionOfPLRType()); + // Bad Value + EXPECT_FALSE(ch.setElectricInputToCoolingOutputRatioFunctionOfPLRType("BADENUM")); + EXPECT_EQ("Lift", ch.electricInputToCoolingOutputRatioFunctionOfPLRType()); + // Reset + ch.resetElectricInputToCoolingOutputRatioFunctionOfPLRType(); + EXPECT_EQ("LeavingCondenserWaterTemperature", ch.electricInputToCoolingOutputRatioFunctionOfPLRType()); + + // Electric Input to Cooling Output Ratio Function of Part Load Ratio Curve Name: Required Object + CurveBicubic eiToCorfOfPlr(m); + EXPECT_TRUE(ch.setElectricInputToCoolingOutputRatioFunctionOfPLR(eiToCorfOfPlr)); + EXPECT_EQ(eiToCorfOfPlr, ch.electricInputToCoolingOutputRatioFunctionOfPLR()); + + // Minimum Part Load Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isMinimumPartLoadRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setMinimumPartLoadRatio(1.3)); + EXPECT_EQ(1.3, ch.minimumPartLoadRatio()); + EXPECT_FALSE(ch.isMinimumPartLoadRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setMinimumPartLoadRatio(-10.0)); + EXPECT_EQ(1.3, ch.minimumPartLoadRatio()); + // Reset + ch.resetMinimumPartLoadRatio(); + EXPECT_TRUE(ch.isMinimumPartLoadRatioDefaulted()); + + // Maximum Part Load Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isMaximumPartLoadRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setMaximumPartLoadRatio(1.4)); + EXPECT_EQ(1.4, ch.maximumPartLoadRatio()); + EXPECT_FALSE(ch.isMaximumPartLoadRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setMaximumPartLoadRatio(-10.0)); + EXPECT_EQ(1.4, ch.maximumPartLoadRatio()); + // Reset + ch.resetMaximumPartLoadRatio(); + EXPECT_TRUE(ch.isMaximumPartLoadRatioDefaulted()); + + // Optimum Part Load Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isOptimumPartLoadRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setOptimumPartLoadRatio(1.5)); + EXPECT_EQ(1.5, ch.optimumPartLoadRatio()); + EXPECT_FALSE(ch.isOptimumPartLoadRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setOptimumPartLoadRatio(-10.0)); + EXPECT_EQ(1.5, ch.optimumPartLoadRatio()); + // Reset + ch.resetOptimumPartLoadRatio(); + EXPECT_TRUE(ch.isOptimumPartLoadRatioDefaulted()); + + // Minimum Unloading Ratio: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isMinimumUnloadingRatioDefaulted()); + // Set + EXPECT_TRUE(ch.setMinimumUnloadingRatio(1.6)); + EXPECT_EQ(1.6, ch.minimumUnloadingRatio()); + EXPECT_FALSE(ch.isMinimumUnloadingRatioDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setMinimumUnloadingRatio(-10.0)); + EXPECT_EQ(1.6, ch.minimumUnloadingRatio()); + // Reset + ch.resetMinimumUnloadingRatio(); + EXPECT_TRUE(ch.isMinimumUnloadingRatioDefaulted()); + + // Chilled Water Inlet Node Name: Required Object + // Chilled Water Outlet Node Name: Required Object + + // Condenser Inlet Node Name: Required Object + // Condenser Outlet Node Name: Required Object + + // Fraction of Compressor Electric Consumption Rejected by Condenser: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isFractionofCompressorElectricConsumptionRejectedbyCondenserDefaulted()); + // Set + EXPECT_TRUE(ch.setFractionofCompressorElectricConsumptionRejectedbyCondenser(0.955)); + EXPECT_EQ(0.955, ch.fractionofCompressorElectricConsumptionRejectedbyCondenser()); + EXPECT_FALSE(ch.isFractionofCompressorElectricConsumptionRejectedbyCondenserDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setFractionofCompressorElectricConsumptionRejectedbyCondenser(-10.0)); + EXPECT_EQ(0.955, ch.fractionofCompressorElectricConsumptionRejectedbyCondenser()); + // Reset + ch.resetFractionofCompressorElectricConsumptionRejectedbyCondenser(); + EXPECT_TRUE(ch.isFractionofCompressorElectricConsumptionRejectedbyCondenserDefaulted()); + + // Leaving Chilled Water Lower Temperature Limit: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isLeavingChilledWaterLowerTemperatureLimitDefaulted()); + // Set + EXPECT_TRUE(ch.setLeavingChilledWaterLowerTemperatureLimit(2.2)); + EXPECT_EQ(2.2, ch.leavingChilledWaterLowerTemperatureLimit()); + EXPECT_FALSE(ch.isLeavingChilledWaterLowerTemperatureLimitDefaulted()); + // Reset + ch.resetLeavingChilledWaterLowerTemperatureLimit(); + EXPECT_TRUE(ch.isLeavingChilledWaterLowerTemperatureLimitDefaulted()); + + // Chiller Flow Mode: Optional String + // Default value from IDD + EXPECT_TRUE(ch.isChillerFlowModeDefaulted()); + EXPECT_EQ("NotModulated", ch.chillerFlowMode()); + // Set + EXPECT_TRUE(ch.setChillerFlowMode("ConstantFlow")); + EXPECT_EQ("ConstantFlow", ch.chillerFlowMode()); + EXPECT_FALSE(ch.isChillerFlowModeDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setChillerFlowMode("BADENUM")); + EXPECT_EQ("ConstantFlow", ch.chillerFlowMode()); + // Reset + ch.resetChillerFlowMode(); + EXPECT_TRUE(ch.isChillerFlowModeDefaulted()); + + // Design Heat Recovery Water Flow Rate: Required Double + // Autosize + ch.autosizeDesignHeatRecoveryWaterFlowRate(); + EXPECT_TRUE(ch.isDesignHeatRecoveryWaterFlowRateAutosized()); + // Set + EXPECT_TRUE(ch.setDesignHeatRecoveryWaterFlowRate(2.4)); + ASSERT_TRUE(ch.designHeatRecoveryWaterFlowRate()); + EXPECT_EQ(2.4, ch.designHeatRecoveryWaterFlowRate().get()); + // Bad Value + EXPECT_FALSE(ch.setDesignHeatRecoveryWaterFlowRate(-10.0)); + ASSERT_TRUE(ch.designHeatRecoveryWaterFlowRate()); + EXPECT_EQ(2.4, ch.designHeatRecoveryWaterFlowRate().get()); + EXPECT_FALSE(ch.isDesignHeatRecoveryWaterFlowRateAutosized()); + + // Heat Recovery Inlet Node Name: Optional Object + // Heat Recovery Outlet Node Name: Optional Object + + // Sizing Factor: Optional Double + // Default value from IDD + EXPECT_TRUE(ch.isSizingFactorDefaulted()); + // Set + EXPECT_TRUE(ch.setSizingFactor(2.7)); + EXPECT_EQ(2.7, ch.sizingFactor()); + EXPECT_FALSE(ch.isSizingFactorDefaulted()); + // Bad Value + EXPECT_FALSE(ch.setSizingFactor(-10.0)); + EXPECT_EQ(2.7, ch.sizingFactor()); + // Reset + ch.resetSizingFactor(); + EXPECT_TRUE(ch.isSizingFactorDefaulted()); + + // Condenser Heat Recovery Relative Capacity Fraction: Required Double + EXPECT_TRUE(ch.setCondenserHeatRecoveryRelativeCapacityFraction(0.966)); + EXPECT_EQ(0.966, ch.condenserHeatRecoveryRelativeCapacityFraction()); + // Bad Value + EXPECT_FALSE(ch.setCondenserHeatRecoveryRelativeCapacityFraction(-10.0)); + EXPECT_EQ(0.966, ch.condenserHeatRecoveryRelativeCapacityFraction()); + + // Heat Recovery Inlet High Temperature Limit Schedule Name: Optional Object + ScheduleConstant heatRecoveryInletHighTemperatureLimitSchedule(m); + EXPECT_TRUE(ch.setHeatRecoveryInletHighTemperatureLimitSchedule(heatRecoveryInletHighTemperatureLimitSchedule)); + ASSERT_TRUE(ch.heatRecoveryInletHighTemperatureLimitSchedule()); + EXPECT_EQ(heatRecoveryInletHighTemperatureLimitSchedule, ch.heatRecoveryInletHighTemperatureLimitSchedule().get()); + // Reset + ch.resetHeatRecoveryInletHighTemperatureLimitSchedule(); + EXPECT_FALSE(ch.heatRecoveryInletHighTemperatureLimitSchedule()); + + // Heat Recovery Leaving Temperature Setpoint Node Name: Optional Object + + // End-Use Subcategory: String + EXPECT_EQ("General", ch.endUseSubcategory()); + // Set + EXPECT_TRUE(ch.setEndUseSubcategory("Chillers")); + EXPECT_EQ("Chillers", ch.endUseSubcategory()); + + // Condenser Flow Control: Required String + EXPECT_TRUE(ch.setCondenserFlowControl("ConstantFlow")); + EXPECT_EQ("ConstantFlow", ch.condenserFlowControl()); + // Bad Value + EXPECT_FALSE(ch.setCondenserFlowControl("BADENUM")); + EXPECT_EQ("ConstantFlow", ch.condenserFlowControl()); + + // Condenser Loop Flow Rate Fraction Function of Loop Part Load Ratio Curve Name: Optional Object + CurveLinear condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(m); + EXPECT_TRUE(ch.setCondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve)); + ASSERT_TRUE(ch.condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve()); + EXPECT_EQ(condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve, ch.condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve().get()); + // Reset + ch.resetCondenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve(); + EXPECT_FALSE(ch.condenserLoopFlowRateFractionFunctionofLoopPartLoadRatioCurve()); + + // Temperature Difference Across Condenser Schedule Name: Optional Object + ScheduleConstant temperatureDifferenceAcrossCondenserSchedule(m); + EXPECT_TRUE(ch.setTemperatureDifferenceAcrossCondenserSchedule(temperatureDifferenceAcrossCondenserSchedule)); + ASSERT_TRUE(ch.temperatureDifferenceAcrossCondenserSchedule()); + EXPECT_EQ(temperatureDifferenceAcrossCondenserSchedule, ch.temperatureDifferenceAcrossCondenserSchedule().get()); + // Reset + ch.resetTemperatureDifferenceAcrossCondenserSchedule(); + EXPECT_FALSE(ch.temperatureDifferenceAcrossCondenserSchedule()); + + // Condenser Minimum Flow Fraction: Required Double + EXPECT_TRUE(ch.setCondenserMinimumFlowFraction(0.9)); + EXPECT_EQ(0.9, ch.condenserMinimumFlowFraction()); + + // Thermosiphon Capacity Fraction Curve Name: Optional Object + CurveLinear thermosiphonCapacityFractionCurve(m); + EXPECT_TRUE(ch.setThermosiphonCapacityFractionCurve(thermosiphonCapacityFractionCurve)); + ASSERT_TRUE(ch.thermosiphonCapacityFractionCurve()); + EXPECT_EQ(thermosiphonCapacityFractionCurve, ch.thermosiphonCapacityFractionCurve().get()); + // Reset + ch.resetThermosiphonCapacityFractionCurve(); + EXPECT_FALSE(ch.thermosiphonCapacityFractionCurve()); + + // Thermosiphon Minimum Temperature Difference: Required Double + EXPECT_TRUE(ch.setThermosiphonMinimumTemperatureDifference(3.7)); + EXPECT_EQ(3.7, ch.thermosiphonMinimumTemperatureDifference()); + // Bad Value + EXPECT_FALSE(ch.setThermosiphonMinimumTemperatureDifference(-10.0)); + EXPECT_EQ(3.7, ch.thermosiphonMinimumTemperatureDifference()); +} + +TEST_F(ModelFixture, ChillerElectricReformulatedEIR_HeatCoolFuelTypes) { + Model m; + ChillerElectricReformulatedEIR ch(m); + + EXPECT_EQ(ComponentType(ComponentType::Cooling), ch.componentType()); + testFuelTypeEquality({FuelType::Electricity}, ch.coolingFuelTypes()); + // Add a CondenserWaterLoop with a component that has another fuel than electricity + PlantLoop cndLoop(m); + cndLoop.addDemandBranchForComponent(ch); + testFuelTypeEquality({FuelType::Electricity}, ch.coolingFuelTypes()); + DistrictCooling dc(m); + cndLoop.addSupplyBranchForComponent(dc); + testFuelTypeEquality({FuelType::Electricity, FuelType::DistrictCooling}, ch.coolingFuelTypes()); + + testFuelTypeEquality({}, ch.heatingFuelTypes()); + testAppGFuelTypeEquality({}, ch.appGHeatingFuelTypes()); +} + // Add to the end of an empty supply side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode1) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node supplyOutletNode = plantLoop.supplyOutletNode(); - model::Mixer supplyMixer = plantLoop.supplyMixer(); + Node supplyOutletNode = plantLoop.supplyOutletNode(); + Mixer supplyMixer = plantLoop.supplyMixer(); EXPECT_TRUE(chiller.addToNode(supplyOutletNode)); @@ -62,11 +398,11 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode1) { EXPECT_EQ(supplyOutletNode, chiller.supplyOutletModelObject().get()); - boost::optional mo = chiller.supplyInletModelObject(); + boost::optional mo = chiller.supplyInletModelObject(); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -74,30 +410,30 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode1) { ASSERT_TRUE(mo); - boost::optional mixer = mo->optionalCast(); + boost::optional mixer = mo->optionalCast(); ASSERT_TRUE(mixer); } // Add to the front of an empty supply side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode2) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node supplyInletNode = plantLoop.supplyInletNode(); + Node supplyInletNode = plantLoop.supplyInletNode(); EXPECT_TRUE(chiller.addToNode(supplyInletNode)); EXPECT_EQ(7u, plantLoop.supplyComponents().size()); - boost::optional mo = chiller.supplyInletModelObject(); + boost::optional mo = chiller.supplyInletModelObject(); ASSERT_TRUE(mo); @@ -107,7 +443,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode2) { ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -120,24 +456,24 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode2) { // Add to the middle of the existing branch. TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode3) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Mixer supplyMixer = plantLoop.supplyMixer(); - model::Splitter supplySplitter = plantLoop.supplySplitter(); + Mixer supplyMixer = plantLoop.supplyMixer(); + Splitter supplySplitter = plantLoop.supplySplitter(); - boost::optional mo = supplyMixer.inletModelObject(0); + boost::optional mo = supplyMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -161,7 +497,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode3) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -173,45 +509,45 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToNode3) { mo = supplySplitter.outletModelObject(0); - boost::optional mo2 = supplyMixer.inletModelObject(0); + boost::optional mo2 = supplyMixer.inletModelObject(0); ASSERT_TRUE(mo); ASSERT_TRUE(mo2); - boost::optional comp = mo->optionalCast(); - boost::optional comp2 = mo2->optionalCast(); + boost::optional comp = mo->optionalCast(); + boost::optional comp2 = mo2->optionalCast(); ASSERT_TRUE(comp); ASSERT_TRUE(comp2); - std::vector comps = plantLoop.supplyComponents(comp.get(), comp2.get()); + std::vector comps = plantLoop.supplyComponents(comp.get(), comp2.get()); ASSERT_EQ(3u, comps.size()); } // Add to new branch TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoop_addSupplyBranch) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); ASSERT_TRUE(plantLoop.addSupplyBranchForComponent(chiller)); EXPECT_EQ(7u, plantLoop.supplyComponents().size()); - model::Mixer supplyMixer = plantLoop.supplyMixer(); + Mixer supplyMixer = plantLoop.supplyMixer(); - boost::optional mo = supplyMixer.inletModelObject(0); + boost::optional mo = supplyMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -225,7 +561,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoop_addSupplyBranch) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -238,18 +574,18 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoop_addSupplyBranch) { // Add to the end of an empty demand side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode1) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node demandOutletNode = plantLoop.demandOutletNode(); - model::Mixer demandMixer = plantLoop.demandMixer(); + Node demandOutletNode = plantLoop.demandOutletNode(); + Mixer demandMixer = plantLoop.demandMixer(); EXPECT_TRUE(chiller.addToNode(demandOutletNode)); @@ -259,11 +595,11 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode1) { EXPECT_EQ(demandOutletNode, chiller.demandOutletModelObject().get()); - boost::optional mo = chiller.demandInletModelObject(); + boost::optional mo = chiller.demandInletModelObject(); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -271,7 +607,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode1) { ASSERT_TRUE(mo); - boost::optional mixer = mo->optionalCast(); + boost::optional mixer = mo->optionalCast(); ASSERT_TRUE(mixer); @@ -282,23 +618,23 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode1) { // Add to the front of an empty demand side and check that it is placed correctly. TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode2) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Node demandInletNode = plantLoop.demandInletNode(); + Node demandInletNode = plantLoop.demandInletNode(); EXPECT_TRUE(chiller.addToNode(demandInletNode)); EXPECT_EQ(7u, plantLoop.demandComponents().size()); - boost::optional mo = chiller.demandInletModelObject(); + boost::optional mo = chiller.demandInletModelObject(); ASSERT_TRUE(mo); @@ -308,7 +644,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode2) { ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -325,23 +661,23 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode2) { // Add to the middle of the existing branch. TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode3) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); - model::Mixer demandMixer = plantLoop.demandMixer(); + Mixer demandMixer = plantLoop.demandMixer(); - boost::optional mo = demandMixer.inletModelObject(0); + boost::optional mo = demandMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -359,7 +695,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode3) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -376,27 +712,27 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_addToDemandNode3) { // Add to new demand branch TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoop_addDemandBranch) { - model::Model m; + Model m; - model::PlantLoop plantLoop(m); + PlantLoop plantLoop(m); - model::CurveBiquadratic ccFofT(m); - model::CurveBiquadratic eirToCorfOfT(m); - model::CurveBicubic eiToCorfOfPlr(m); + CurveBiquadratic ccFofT(m); + CurveBiquadratic eirToCorfOfT(m); + CurveBicubic eiToCorfOfPlr(m); - model::ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); + ChillerElectricReformulatedEIR chiller(m, ccFofT, eirToCorfOfT, eiToCorfOfPlr); ASSERT_TRUE(plantLoop.addDemandBranchForComponent(chiller)); EXPECT_EQ(7u, plantLoop.demandComponents().size()); - model::Mixer demandMixer = plantLoop.demandMixer(); + Mixer demandMixer = plantLoop.demandMixer(); - boost::optional mo = demandMixer.inletModelObject(0); + boost::optional mo = demandMixer.inletModelObject(0); ASSERT_TRUE(mo); - boost::optional node = mo->optionalCast(); + boost::optional node = mo->optionalCast(); ASSERT_TRUE(node); @@ -410,7 +746,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoop_addDemandBranch) { ASSERT_TRUE(mo); - node = mo->optionalCast(); + node = mo->optionalCast(); ASSERT_TRUE(node); @@ -426,12 +762,12 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoop_addDemandBranch) { } TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoopConnections) { - model::Model model; - model::ChillerElectricReformulatedEIR chiller(model); + Model model; + ChillerElectricReformulatedEIR chiller(model); // Chilled Water Loop: on the supply side { - model::PlantLoop chwLoop(model); + PlantLoop chwLoop(model); auto node = chwLoop.supplyOutletNode(); EXPECT_TRUE(chiller.addToNode(node)); auto plant = chiller.plantLoop(); @@ -452,7 +788,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoopConnections) { // Condenser Loop: on the demand side { - model::PlantLoop cndwLoop(model); + PlantLoop cndwLoop(model); auto node = cndwLoop.demandInletNode(); EXPECT_TRUE(chiller.addToNode(node)); auto plant = chiller.secondaryPlantLoop(); @@ -473,7 +809,7 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoopConnections) { // Heat Recovery Loop: on the demand side { - model::PlantLoop hrLoop(model); + PlantLoop hrLoop(model); auto node = hrLoop.demandOutletNode(); EXPECT_TRUE(chiller.addToTertiaryNode(node)); auto plant = chiller.tertiaryPlantLoop(); @@ -504,16 +840,16 @@ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoopConnections) { * This should work with addDemandBranchForComponent too * AddToTertiaryNode is overriden to not work when trying to add to a supply side node */ TEST_F(ModelFixture, ChillerElectricReformulatedEIR_PlantLoopConnections_addToNodeOverride) { - model::Model model; - model::ChillerElectricReformulatedEIR chiller(model); + Model model; + ChillerElectricReformulatedEIR chiller(model); - model::PlantLoop chwLoop(model); + PlantLoop chwLoop(model); - model::PlantLoop cndwLoop(model); - model::PlantLoop cndwLoop2(model); + PlantLoop cndwLoop(model); + PlantLoop cndwLoop2(model); auto c_demand_node2 = cndwLoop2.demandOutletNode(); - model::PlantLoop hrLoop(model); + PlantLoop hrLoop(model); auto h_supply_node = hrLoop.supplyOutletNode(); auto h_demand_node = hrLoop.demandInletNode(); diff --git a/src/model/test/Site_GTest.cpp b/src/model/test/Site_GTest.cpp index f9499a3eb2f..289fb033f4d 100644 --- a/src/model/test/Site_GTest.cpp +++ b/src/model/test/Site_GTest.cpp @@ -39,3 +39,97 @@ TEST_F(ModelFixture, Site_Outputvariables) { EXPECT_EQ(site.outputVariableNames(), site.outputVariableNames()); EXPECT_EQ(site.outputVariableNames().front(), site.outputVariableNames().front()); } + +TEST_F(ModelFixture, Site_GettersSetters) { + Model m; + EXPECT_FALSE(m.getOptionalUniqueModelObject()); + Site site = m.getUniqueModelObject(); + EXPECT_TRUE(m.getOptionalUniqueModelObject()); + + site.setName("My Site"); + + // Latitude: Optional Double + // Default value from IDD + EXPECT_TRUE(site.isLatitudeDefaulted()); + // Set + EXPECT_TRUE(site.setLatitude(45.0)); + EXPECT_EQ(45.0, site.latitude()); + EXPECT_FALSE(site.isLatitudeDefaulted()); + // Bad Value + EXPECT_FALSE(site.setLatitude(-100.0)); + EXPECT_EQ(45.0, site.latitude()); + // Reset + site.resetLatitude(); + EXPECT_TRUE(site.isLatitudeDefaulted()); + + // Longitude: Optional Double + // Default value from IDD + EXPECT_TRUE(site.isLongitudeDefaulted()); + // Set + EXPECT_TRUE(site.setLongitude(108.0)); + EXPECT_EQ(108.0, site.longitude()); + EXPECT_FALSE(site.isLongitudeDefaulted()); + // Bad Value + EXPECT_FALSE(site.setLongitude(-190.0)); + EXPECT_EQ(108.0, site.longitude()); + // Reset + site.resetLongitude(); + EXPECT_TRUE(site.isLongitudeDefaulted()); + + // Time Zone: Optional Double + // Default value from IDD + EXPECT_TRUE(site.isTimeZoneDefaulted()); + // Set + EXPECT_TRUE(site.setTimeZone(9.667)); + EXPECT_EQ(9.667, site.timeZone()); + EXPECT_FALSE(site.isTimeZoneDefaulted()); + // Bad Value + EXPECT_FALSE(site.setTimeZone(-22.0)); + EXPECT_EQ(9.667, site.timeZone()); + // Reset + site.resetTimeZone(); + EXPECT_TRUE(site.isTimeZoneDefaulted()); + + // Elevation: Optional Double + // Default value from IDD + EXPECT_TRUE(site.isElevationDefaulted()); + // Set + EXPECT_TRUE(site.setElevation(7585.714)); + EXPECT_EQ(7585.714, site.elevation()); + EXPECT_FALSE(site.isElevationDefaulted()); + // Bad Value + EXPECT_FALSE(site.setElevation(-310.0)); + EXPECT_EQ(7585.714, site.elevation()); + // Reset + site.resetElevation(); + EXPECT_TRUE(site.isElevationDefaulted()); + + // Terrain: Optional String + // Default value from IDD + EXPECT_TRUE(site.isTerrainDefaulted()); + EXPECT_EQ("Suburbs", site.terrain()); + // Set + EXPECT_TRUE(site.setTerrain("Country")); + EXPECT_EQ("Country", site.terrain()); + EXPECT_FALSE(site.isTerrainDefaulted()); + // Bad Value + EXPECT_FALSE(site.setTerrain("BADENUM")); + EXPECT_EQ("Country", site.terrain()); + // Reset + site.resetTerrain(); + EXPECT_TRUE(site.isTerrainDefaulted()); + + // Keep Site Location Information: Optional Boolean + // Default value from IDD + EXPECT_TRUE(site.isKeepSiteLocationInformationDefaulted()); + EXPECT_FALSE(site.keepSiteLocationInformation()); + // Set + EXPECT_TRUE(site.setKeepSiteLocationInformation(true)); + EXPECT_TRUE(site.keepSiteLocationInformation()); + EXPECT_TRUE(site.setKeepSiteLocationInformation(false)); + EXPECT_FALSE(site.keepSiteLocationInformation()); + // Reset + site.resetKeepSiteLocationInformation(); + EXPECT_TRUE(site.isKeepSiteLocationInformationDefaulted()); + EXPECT_FALSE(site.keepSiteLocationInformation()); +} diff --git a/src/model/test/SizingZone_GTest.cpp b/src/model/test/SizingZone_GTest.cpp index 7b0d3c3aee5..abfe70adf98 100644 --- a/src/model/test/SizingZone_GTest.cpp +++ b/src/model/test/SizingZone_GTest.cpp @@ -406,4 +406,14 @@ TEST_F(ModelFixture, SizingZone_GettersSetters) { EXPECT_TRUE(sz.setZoneHumidistatHumidificationSetPointSchedule(humSch)); ASSERT_TRUE(sz.zoneHumidistatHumidificationSetPointSchedule()); EXPECT_EQ(humSch, sz.zoneHumidistatHumidificationSetPointSchedule().get()); + + // Sizing Option: String + // Default value from IDD, set in Ctor + EXPECT_EQ("Coincident", sz.sizingOption()); + // Set + EXPECT_TRUE(sz.setSizingOption("NonCoincident")); + EXPECT_EQ("NonCoincident", sz.sizingOption()); + // Bad Value + EXPECT_FALSE(sz.setSizingOption("BADENUM")); + EXPECT_EQ("NonCoincident", sz.sizingOption()); }