From a59310a033fa9f7700b5ed75e4dc6ae96c3b17e5 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Thu, 21 Dec 2023 14:43:46 -0600 Subject: [PATCH] Updated code, compiler warnings, format, etc. for Ubuntu 23.10/GCC 13.2/Python 3.11, definitely not ready as-is --- cmake/CompilerFlags.cmake | 12 +- src/ConvertInputFormat/main.cpp | 2 +- src/EnergyPlus/EPVector.hh | 16 +- src/EnergyPlus/FileSystem.hh | 4 +- src/EnergyPlus/HeatBalanceKivaManager.cc | 2 +- src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh | 9 +- src/EnergyPlus/IOFiles.hh | 21 +- .../PhaseChangeModeling/HysteresisModel.cc | 10 +- src/EnergyPlus/PoweredInductionUnits.hh | 6 +- src/EnergyPlus/StringUtilities.hh | 2 +- third_party/ssc/shared/lib_battery_lifetime.h | 4 +- .../unit/HVACVariableRefrigerantFlow.unit.cc | 468 +++++++++--------- .../unit/OutputReportTabular.unit.cc | 5 +- 13 files changed, 284 insertions(+), 277 deletions(-) diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index c622c9d0b1e..6367627154e 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -86,9 +86,10 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O # COMPILER FLAGS target_compile_options(project_options INTERFACE -pipe) # Faster compiler processing - target_compile_options(project_warnings INTERFACE -Wpedantic - )# Turn on warnings about constructs/situations that may be non-portable or outside of the standard - target_compile_options(project_warnings INTERFACE -Wall -Wextra) # Turn on warnings + target_compile_options(project_warnings INTERFACE -Wpedantic) + # Turn on warnings about constructs/situations that may be non-portable or outside of the standard + target_compile_options(project_warnings INTERFACE -Wall) # Turn on warnings + target_compile_options(project_warnings INTERFACE -Wextra) # Turn on warnings target_compile_options(project_warnings INTERFACE -Wno-unknown-pragmas) if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0) target_compile_options(project_warnings INTERFACE -Wno-deprecated-copy) @@ -101,6 +102,11 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O target_compile_options(project_warnings INTERFACE -Wno-unused-but-set-parameter -Wno-unused-but-set-variable) target_compile_options(project_warnings INTERFACE -Wno-maybe-uninitialized) target_compile_options(project_warnings INTERFACE -Wno-aggressive-loop-optimizations) + # Sadly, GCC 13.2 is throwing many false positives on dangling references and compile time array-bounds + # https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=6b927b1297e66e26e62e722bf15c921dcbbd25b9 + target_compile_options(project_warnings INTERFACE -Wno-dangling-reference) + target_compile_options(project_warnings INTERFACE -Wno-array-bounds) + target_compile_options(project_warnings INTERFACE -Wno-stringop-overflow) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0) # Suppress unused-but-set warnings until more serious ones are addressed diff --git a/src/ConvertInputFormat/main.cpp b/src/ConvertInputFormat/main.cpp index 3efc0f46fa9..c6a8a3677c0 100644 --- a/src/ConvertInputFormat/main.cpp +++ b/src/ConvertInputFormat/main.cpp @@ -88,7 +88,7 @@ static constexpr std::array(OutputTypes::Num) static constexpr auto outputTypeExperimentalStart = OutputTypes::CBOR; -template void displayMessage(std::string_view str_format, Args &&... args) +template void displayMessage(std::string_view str_format, Args &&...args) { fmt::print(std::cout, str_format, args...); std::cout.write("\n", 1); diff --git a/src/EnergyPlus/EPVector.hh b/src/EnergyPlus/EPVector.hh index 9b5c02f294a..1cb6505b668 100644 --- a/src/EnergyPlus/EPVector.hh +++ b/src/EnergyPlus/EPVector.hh @@ -263,12 +263,12 @@ private: bool m_allocated{false}; }; -template [[nodiscard]] bool allocated(EPVector const &v) noexcept +template [[nodiscard]] bool allocated(EPVector const &v) noexcept { return v.allocated(); } -template [[nodiscard]] auto isize(const EPVector &v) noexcept +template [[nodiscard]] auto isize(const EPVector &v) noexcept { return v.isize(); } @@ -294,7 +294,7 @@ template [[nodiscard]] auto isize(const EPVector &v) noexcept return std::count_if(values.cbegin(), values.cend(), [](bool v) { return v; }); } -template [[nodiscard]] EPVector pack(EPVector const &v, EPVector const &mask) +template [[nodiscard]] EPVector pack(EPVector const &v, EPVector const &mask) { EPVector r; r.reserve(mask.size()); @@ -306,7 +306,7 @@ template [[nodiscard]] EPVector pack(EPVector const &v, EPVect return r; } -template [[nodiscard]] Array1D pack(Array1 const &a, EPVector const &mask) +template [[nodiscard]] Array1D pack(Array1 const &a, EPVector const &mask) { Array1D r; r.reserve(mask.size()); @@ -318,17 +318,17 @@ template [[nodiscard]] Array1D pack(Array1 const &a, EPVector< return r; } -template [[nodiscard]] T magnitude_squared(const EPVector &v) +template [[nodiscard]] T magnitude_squared(const EPVector &v) { return std::inner_product(v.begin(), v.end(), v.begin(), T{}); } -template [[nodiscard]] T dot(const EPVector &u, const V &v) +template [[nodiscard]] T dot(const EPVector &u, const V &v) { return std::inner_product(u.begin(), u.end(), v.begin(), T{}); } -template [[nodiscard]] Member maxval(EPVector const &a, Member Element::*pmem) +template [[nodiscard]] Member maxval(EPVector const &a, Member Element::*pmem) { Member v(a.empty() ? std::numeric_limits::lowest() : a(1).*pmem); for (int i = 2, e = a.isize(); i <= e; ++i) { @@ -343,7 +343,7 @@ template inline Member sum(EPVector return std::accumulate(c.cbegin(), c.cend(), 0.0, [&pmem](const Member &sum, const Element &e) { return sum + e.*pmem; }); } -template [[nodiscard]] T maxval(EPVector const &a) +template [[nodiscard]] T maxval(EPVector const &a) { auto max = std::max_element(a.begin(), a.end()); if (max == a.end()) { diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index a8c31c20300..b23b40f8364 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -229,8 +229,8 @@ namespace FileSystem { is_any, std::unique_ptr, std::unique_ptr, std::unique_ptr>::value; template - inline constexpr bool enable_json_v = is_all_json_type(fileType) && is_any::value && - !is_any::value; + inline constexpr bool enable_json_v = + is_all_json_type(fileType) && is_any::value && !is_any::value; template void writeFile(fs::path const &filePath, const std::string_view data) { diff --git a/src/EnergyPlus/HeatBalanceKivaManager.cc b/src/EnergyPlus/HeatBalanceKivaManager.cc index 435b29f05c0..ec82cb61fba 100644 --- a/src/EnergyPlus/HeatBalanceKivaManager.cc +++ b/src/EnergyPlus/HeatBalanceKivaManager.cc @@ -839,7 +839,7 @@ bool KivaManager::setupKivaInstances(EnergyPlusData &state) Real64 surfHeight = Surfaces(wl).get_average_height(state); // round to avoid numerical precision differences - surfHeight = std::round((surfHeight)*1000.0) / 1000.0; + surfHeight = std::round((surfHeight) * 1000.0) / 1000.0; if (combinationMap.count({Surfaces(wl).Construction, surfHeight}) == 0) { // create new combination diff --git a/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh b/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh index d8f995a4f53..589efb9ee43 100644 --- a/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh +++ b/src/EnergyPlus/HeatPumpWaterToWaterCOOLING.hh @@ -128,11 +128,10 @@ namespace HeatPumpWaterToWaterCOOLING { MaxPartLoadRat(0.0), OptPartLoadRat(0.0), LoadSideVolFlowRate(0.0), LoadSideDesignMassFlow(0.0), SourceSideVolFlowRate(0.0), SourceSideDesignMassFlow(0.0), SourceSideInletNodeNum(0), SourceSideOutletNodeNum(0), LoadSideInletNodeNum(0), LoadSideOutletNodeNum(0), SourceSideUACoeff(0.0), LoadSideUACoeff(0.0), CompPistonDisp(0.0), CompClearanceFactor(0.0), CompSucPressDrop(0.0), SuperheatTemp(0.0), - PowerLosses(0.0), LossFactor(0.0), HighPressCutoff(0.0), LowPressCutoff(0.0), IsOn(false), - MustRun(false), SourcePlantLoc{}, LoadPlantLoc{}, CondMassFlowIndex(0), Power(0.0), Energy(0.0), QLoad(0.0), QLoadEnergy(0.0), - QSource(0.0), QSourceEnergy(0.0), LoadSideWaterInletTemp(0.0), SourceSideWaterInletTemp(0.0), LoadSideWaterOutletTemp(0.0), - SourceSideWaterOutletTemp(0.0), Running(0), LoadSideWaterMassFlowRate(0.0), SourceSideWaterMassFlowRate(0.0), plantScanFlag(true), - beginEnvironFlag(true) + PowerLosses(0.0), LossFactor(0.0), HighPressCutoff(0.0), LowPressCutoff(0.0), IsOn(false), MustRun(false), SourcePlantLoc{}, + LoadPlantLoc{}, CondMassFlowIndex(0), Power(0.0), Energy(0.0), QLoad(0.0), QLoadEnergy(0.0), QSource(0.0), QSourceEnergy(0.0), + LoadSideWaterInletTemp(0.0), SourceSideWaterInletTemp(0.0), LoadSideWaterOutletTemp(0.0), SourceSideWaterOutletTemp(0.0), Running(0), + LoadSideWaterMassFlowRate(0.0), SourceSideWaterMassFlowRate(0.0), plantScanFlag(true), beginEnvironFlag(true) { } diff --git a/src/EnergyPlus/IOFiles.hh b/src/EnergyPlus/IOFiles.hh index 01da0c23427..5991b069993 100644 --- a/src/EnergyPlus/IOFiles.hh +++ b/src/EnergyPlus/IOFiles.hh @@ -141,6 +141,9 @@ private: std::string_view spec_builder() { buffer.clear(); + // This line seems to be the culprit with some array-bounds warnings + // during compilation on GCC 13.2. I don't see how at the moment. + // I tried pragma-ing it away but it didn't help buffer.push_back('{'); buffer.push_back(':'); // [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type] @@ -492,7 +495,7 @@ inline constexpr bool is_fortran_syntax(const std::string_view format_str) class InputOutputFile; template -void print(InputOutputFile &outputFile, std::string_view format_str, Args &&... args); +void print(InputOutputFile &outputFile, std::string_view format_str, Args &&...args); inline constexpr FormatSyntax check_syntax(const std::string_view format_str) { @@ -610,7 +613,7 @@ public: private: std::unique_ptr os; bool print_to_dev_null = false; - template friend void print(InputOutputFile &outputFile, std::string_view format_str, Args &&... args); + template friend void print(InputOutputFile &outputFile, std::string_view format_str, Args &&...args); friend class IOFiles; }; @@ -802,7 +805,7 @@ public: } }; -template void vprint(std::ostream &os, std::string_view format_str, const Args &... args) +template void vprint(std::ostream &os, std::string_view format_str, const Args &...args) { // assert(os.good()); auto buffer = fmt::memory_buffer(); @@ -814,7 +817,7 @@ template void vprint(std::ostream &os, std::string_view forma os.write(buffer.data(), buffer.size()); } -template std::string vprint(std::string_view format_str, const Args &... args) +template std::string vprint(std::string_view format_str, const Args &...args) { auto buffer = fmt::memory_buffer(); try { @@ -848,19 +851,19 @@ template std::string vprint(std::string_view format_str, cons // namespace { - template void print_fortran_syntax(std::ostream &os, std::string_view format_str, const Args &... args) + template void print_fortran_syntax(std::ostream &os, std::string_view format_str, const Args &...args) { EnergyPlus::vprint, DoubleWrapper, Args>...>(os, format_str, args...); } - template std::string format_fortran_syntax(std::string_view format_str, const Args &... args) + template std::string format_fortran_syntax(std::string_view format_str, const Args &...args) { return EnergyPlus::vprint, DoubleWrapper, Args>...>(format_str, args...); } } // namespace template -void print(std::ostream &os, std::string_view format_str, Args &&... args) +void print(std::ostream &os, std::string_view format_str, Args &&...args) { if constexpr (formatSyntax == FormatSyntax::Fortran) { print_fortran_syntax(os, format_str, args...); @@ -871,7 +874,7 @@ void print(std::ostream &os, std::string_view format_str, Args &&... args) } } -template void print(InputOutputFile &outputFile, std::string_view format_str, Args &&... args) +template void print(InputOutputFile &outputFile, std::string_view format_str, Args &&...args) { auto *outputStream = [&]() -> std::ostream * { if (outputFile.os) { @@ -894,7 +897,7 @@ template void print(InputOutputFil } } -template std::string format(std::string_view format_str, Args &&... args) +template std::string format(std::string_view format_str, Args &&...args) { if constexpr (formatSyntax == FormatSyntax::Fortran) { return format_fortran_syntax(format_str, args...); diff --git a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc index 4094b42a302..8e3af8a8de2 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc @@ -165,7 +165,7 @@ namespace HysteresisPhaseChange { phaseChangeState = PhaseChangeStates::FREEZING; this->enthNew = this->getEnthalpy(updatedTempTDT, this->peakTempFreezing, this->deltaTempFreezingLow, this->deltaTempFreezingHigh); - } else if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM) { + } else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF) { phaseChangeState = PhaseChangeStates::TRANSITION; this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthOld - (this->specHeatTransition * prevTempTD)); } else if (this->enthNew < this->enthalpyF && updatedTempTDT > phaseChangeTempReverse) { @@ -191,11 +191,11 @@ namespace HysteresisPhaseChange { this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthOld - (this->specHeatTransition * prevTempTD)); this->enthalpyM = this->getEnthalpy(updatedTempTDT, this->peakTempMelting, this->deltaTempMeltingLow, this->deltaTempMeltingHigh); this->enthalpyF = this->getEnthalpy(updatedTempTDT, this->peakTempMelting, this->deltaTempMeltingLow, this->deltaTempMeltingHigh); - if (updatedTempTDT < phaseChangeTempReverse && this->enthNew > this->enthalpyF) { + if (this->enthNew > this->enthalpyF && updatedTempTDT < phaseChangeTempReverse) { phaseChangeState = PhaseChangeStates::FREEZING; this->enthNew = this->getEnthalpy(updatedTempTDT, this->peakTempFreezing, this->deltaTempFreezingLow, this->deltaTempFreezingHigh); - } else if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM && + } else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF && (updatedTempTDT < prevTempTD || updatedTempTDT > prevTempTD)) { phaseChangeState = PhaseChangeStates::TRANSITION; this->enthNew = @@ -211,7 +211,7 @@ namespace HysteresisPhaseChange { this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthRev - (this->specHeatTransition * phaseChangeTempReverse)); this->enthalpyM = this->getEnthalpy(updatedTempTDT, this->peakTempMelting, this->deltaTempMeltingLow, this->deltaTempMeltingHigh); this->enthalpyF = this->getEnthalpy(updatedTempTDT, this->peakTempFreezing, this->deltaTempFreezingLow, this->deltaTempFreezingHigh); - if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM) { + if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF) { phaseChangeState = PhaseChangeStates::TRANSITION; this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthRev - (this->specHeatTransition * phaseChangeTempReverse)); @@ -226,7 +226,7 @@ namespace HysteresisPhaseChange { if (this->enthNew < this->enthOld && updatedTempTDT < prevTempTD) { phaseChangeState = PhaseChangeStates::TRANSITION; this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthOld - (this->specHeatTransition * prevTempTD)); - } else if (this->enthNew < this->enthalpyF && this->enthNew > this->enthalpyM && updatedTempTDT < prevTempTD) { + } else if (this->enthNew > this->enthalpyM && this->enthNew < this->enthalpyF && updatedTempTDT < prevTempTD) { phaseChangeState = PhaseChangeStates::TRANSITION; this->enthNew = (this->specHeatTransition * updatedTempTDT) + (this->enthRev - (this->specHeatTransition * phaseChangeTempReverse)); diff --git a/src/EnergyPlus/PoweredInductionUnits.hh b/src/EnergyPlus/PoweredInductionUnits.hh index 0e8beca99f2..babe185b7c3 100644 --- a/src/EnergyPlus/PoweredInductionUnits.hh +++ b/src/EnergyPlus/PoweredInductionUnits.hh @@ -156,9 +156,9 @@ namespace PoweredInductionUnits { OutAirNode(0), HCoilInAirNode(0), ControlCompTypeNum(0), CompErrIndex(0), Mixer_Num(0), Fan_Num(0), Fan_Index(0), FanAvailSchedPtr(0), HCoilType(HtgCoilType::Invalid), HCoil_PlantType(DataPlant::PlantEquipmentType::Invalid), HCoil_Index(0), HCoil_FluidIndex(0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), - MinHotSteamFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), HotControlNode(0), HotCoilOutNodeNum(0), - HotControlOffset(0.0), HWplantLoc{}, ADUNum(0), InducesPlenumAir(false), HeatingRate(0.0), HeatingEnergy(0.0), SensCoolRate(0.0), - SensCoolEnergy(0.0), CtrlZoneNum(0), ctrlZoneInNodeIndex(0), AirLoopNum(0), OutdoorAirFlowRate(0.0) + MinHotSteamFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0), HotControlNode(0), HotCoilOutNodeNum(0), HotControlOffset(0.0), + HWplantLoc{}, ADUNum(0), InducesPlenumAir(false), HeatingRate(0.0), HeatingEnergy(0.0), SensCoolRate(0.0), SensCoolEnergy(0.0), + CtrlZoneNum(0), ctrlZoneInNodeIndex(0), AirLoopNum(0), OutdoorAirFlowRate(0.0) { } diff --git a/src/EnergyPlus/StringUtilities.hh b/src/EnergyPlus/StringUtilities.hh index 2748eb14369..3f12c78a384 100644 --- a/src/EnergyPlus/StringUtilities.hh +++ b/src/EnergyPlus/StringUtilities.hh @@ -157,7 +157,7 @@ inline auto nth_occurrence(std::string_view input_str, char const search_char, s return pos; } -template bool readList(std::string_view input, Param &&... param) +template bool readList(std::string_view input, Param &&...param) { if constexpr (std::conjunction_v...> || std::conjunction_v...>) { size_t index = 0; diff --git a/third_party/ssc/shared/lib_battery_lifetime.h b/third_party/ssc/shared/lib_battery_lifetime.h index 7c0c5cf1799..fc6298a93e0 100644 --- a/third_party/ssc/shared/lib_battery_lifetime.h +++ b/third_party/ssc/shared/lib_battery_lifetime.h @@ -68,7 +68,7 @@ struct lifetime_state { lifetime_state(const std::shared_ptr& cyc, const std::shared_ptr& cal); - lifetime_state(const std::shared_ptr& nmc); + explicit lifetime_state(const std::shared_ptr& nmc); lifetime_state &operator=(const lifetime_state &rhs); @@ -81,7 +81,7 @@ class lifetime_t { lifetime_t(const lifetime_t &rhs); - virtual lifetime_t &operator=(const lifetime_t &rhs); + lifetime_t &operator=(const lifetime_t &rhs); virtual lifetime_t *clone() = 0; diff --git a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc index 68f17f37af8..17f2a681acf 100644 --- a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc +++ b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc @@ -2487,109 +2487,109 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Compressor) } // Run and Check: VRFOU_CompSpd - {// Test the method VRFOU_CompSpd, which calculates the compressor speed at given - // operational conditions to meet the evaporator or condenser capacity provided. + { // Test the method VRFOU_CompSpd, which calculates the compressor speed at given + // operational conditions to meet the evaporator or condenser capacity provided. - {// a. Evaporator + { // a. Evaporator - // Inputs_condition - Real64 constexpr Q_req = 6971; // Required capacity [W] - Real64 constexpr T_suction = -13.35; // Compressor suction temperature Te' [C] - Real64 constexpr T_discharge = 36.37; // Compressor discharge temperature Tc' [C] - Real64 constexpr h_IU_evap_in = 225016; // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg] - Real64 constexpr h_comp_in = 429529; // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg] - Real64 CompSpdActual; // Actual compressor running speed [rps] + // Inputs_condition + Real64 constexpr Q_req = 6971; // Required capacity [W] + Real64 constexpr T_suction = -13.35; // Compressor suction temperature Te' [C] + Real64 constexpr T_discharge = 36.37; // Compressor discharge temperature Tc' [C] + Real64 constexpr h_IU_evap_in = 225016; // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg] + Real64 constexpr h_comp_in = 429529; // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg] + Real64 CompSpdActual; // Actual compressor running speed [rps] - // Run - state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompSpd( - *state, Q_req, HXOpMode::EvapMode, T_suction, T_discharge, h_IU_evap_in, h_comp_in, CompSpdActual); + // Run + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompSpd( + *state, Q_req, HXOpMode::EvapMode, T_suction, T_discharge, h_IU_evap_in, h_comp_in, CompSpdActual); - // Test - EXPECT_NEAR(1295, CompSpdActual, 5); -} + // Test + EXPECT_NEAR(1295, CompSpdActual, 5); + } -{ - // b. Condenser - - // Inputs_condition - Real64 constexpr Q_req = 6953; // Required capacity [W] - Real64 constexpr T_suction = -13.35; // Compressor suction temperature Te' [C] - Real64 constexpr T_discharge = 36.37; // Compressor discharge temperature Tc' [C] - Real64 constexpr h_IU_evap_in = 225016; // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg] - Real64 constexpr h_comp_in = 429529; // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg] - Real64 CompSpdActual; // Actual compressor running speed [rps] - - // Run - state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompSpd( - *state, Q_req, HXOpMode::CondMode, T_suction, T_discharge, h_IU_evap_in, h_comp_in, CompSpdActual); - - // Test - EXPECT_NEAR(950, CompSpdActual, 5); -} -} // namespace EnergyPlus + { + // b. Condenser -// Run and Check: VRFOU_CompCap -{ - // Test the method VRFOU_CompCap, which calculates the compressor performance (power and capacity) - // at given compressor speed and operational conditions. - - // Inputs_condition - Real64 constexpr CompSpdActual = 1298; // Actual compressor running speed [rps] - Real64 constexpr T_suction = -13.35; // Compressor suction temperature Te' [C] - Real64 constexpr T_discharge = 36.37; // Compressor discharge temperature Tc' [C] - Real64 constexpr h_IU_evap_in = 225016; // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg] - Real64 constexpr h_comp_in = 429529; // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg] - Real64 Q_c_tot; // Compressor evaporative capacity [W] - Real64 Ncomp; // Compressor power [W] - - // Run - state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompCap(*state, CompSpdActual, T_suction, T_discharge, h_IU_evap_in, h_comp_in, Q_c_tot, Ncomp); - - // Test - EXPECT_NEAR(6990, Q_c_tot, 10); - EXPECT_NEAR(1601, Ncomp, 10); -} + // Inputs_condition + Real64 constexpr Q_req = 6953; // Required capacity [W] + Real64 constexpr T_suction = -13.35; // Compressor suction temperature Te' [C] + Real64 constexpr T_discharge = 36.37; // Compressor discharge temperature Tc' [C] + Real64 constexpr h_IU_evap_in = 225016; // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg] + Real64 constexpr h_comp_in = 429529; // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg] + Real64 CompSpdActual; // Actual compressor running speed [rps] -// Run and Check: VRFOU_CalcComp -{ - // Test the method VRFOU_CalcCompH, which simulates the compressor performance at given oprtaional conditions. More specifically, it - // sepcifies the compressor speed to provide sufficient evaporative capacity, and calculate the power of the compressor running at the - // specified speed. Note that it may be needed to manipulate the operational conditions to further adjust system capacity at low load - // conditions. The low load modification logics are different for cooling mode and heating mode. - - // Inputs_condition - Real64 TU_load = 6006; // Indoor unit cooling load [W] - Real64 T_suction = 8.86; // Compressor suction temperature Te' [C] - Real64 T_discharge = 40.26; // Compressor discharge temperature Tc' [C] - Real64 Pipe_h_out_ave = 233428; // Average Enthalpy of the refrigerant leaving IUs [kJ/kg] - Real64 IUMaxCondTemp = 36; // VRV IU condensing temperature, max among all indoor units [C] - Real64 MinOutdoorUnitTe = -72; // The minimum temperature that OU Te can be at cooling mode (only used for calculating Min capacity) - Real64 Tfs = 10.90; // Temperature of the air at the OU evaporator coil surface [C]] - Real64 Pipe_Q = 162.67; // Piping Loss Algorithm Parameter: Heat loss [W] - Real64 OUEvapHeatExtract = 5110.40; // Evaporator heat extract [W] - Real64 Ncomp = 1058; // Compressor power [W] - Real64 CompSpdActual; // Actual compressor running speed [rps] - - // Run - state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CalcCompH(*state, - TU_load, - T_suction, - T_discharge, - Pipe_h_out_ave, - IUMaxCondTemp, - MinOutdoorUnitTe, - Tfs, - Pipe_Q, - OUEvapHeatExtract, - CompSpdActual, - Ncomp); - - // Test - EXPECT_NEAR(5110, OUEvapHeatExtract, 1); - EXPECT_NEAR(1500, CompSpdActual, 1); - EXPECT_NEAR(2080, Ncomp, 1); - EXPECT_EQ(state->dataLoopNodes->Node(state->dataHVACVarRefFlow->VRFTU(1).VRFTUInletNodeNum).MassFlowRate, 0.0); -} + // Run + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompSpd( + *state, Q_req, HXOpMode::CondMode, T_suction, T_discharge, h_IU_evap_in, h_comp_in, CompSpdActual); + + // Test + EXPECT_NEAR(950, CompSpdActual, 5); + } + } // namespace EnergyPlus + + // Run and Check: VRFOU_CompCap + { + // Test the method VRFOU_CompCap, which calculates the compressor performance (power and capacity) + // at given compressor speed and operational conditions. + + // Inputs_condition + Real64 constexpr CompSpdActual = 1298; // Actual compressor running speed [rps] + Real64 constexpr T_suction = -13.35; // Compressor suction temperature Te' [C] + Real64 constexpr T_discharge = 36.37; // Compressor discharge temperature Tc' [C] + Real64 constexpr h_IU_evap_in = 225016; // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg] + Real64 constexpr h_comp_in = 429529; // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg] + Real64 Q_c_tot; // Compressor evaporative capacity [W] + Real64 Ncomp; // Compressor power [W] + + // Run + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompCap(*state, CompSpdActual, T_suction, T_discharge, h_IU_evap_in, h_comp_in, Q_c_tot, Ncomp); + + // Test + EXPECT_NEAR(6990, Q_c_tot, 10); + EXPECT_NEAR(1601, Ncomp, 10); + } + + // Run and Check: VRFOU_CalcComp + { + // Test the method VRFOU_CalcCompH, which simulates the compressor performance at given oprtaional conditions. More specifically, it + // sepcifies the compressor speed to provide sufficient evaporative capacity, and calculate the power of the compressor running at the + // specified speed. Note that it may be needed to manipulate the operational conditions to further adjust system capacity at low load + // conditions. The low load modification logics are different for cooling mode and heating mode. + + // Inputs_condition + Real64 TU_load = 6006; // Indoor unit cooling load [W] + Real64 T_suction = 8.86; // Compressor suction temperature Te' [C] + Real64 T_discharge = 40.26; // Compressor discharge temperature Tc' [C] + Real64 Pipe_h_out_ave = 233428; // Average Enthalpy of the refrigerant leaving IUs [kJ/kg] + Real64 IUMaxCondTemp = 36; // VRV IU condensing temperature, max among all indoor units [C] + Real64 MinOutdoorUnitTe = -72; // The minimum temperature that OU Te can be at cooling mode (only used for calculating Min capacity) + Real64 Tfs = 10.90; // Temperature of the air at the OU evaporator coil surface [C]] + Real64 Pipe_Q = 162.67; // Piping Loss Algorithm Parameter: Heat loss [W] + Real64 OUEvapHeatExtract = 5110.40; // Evaporator heat extract [W] + Real64 Ncomp = 1058; // Compressor power [W] + Real64 CompSpdActual; // Actual compressor running speed [rps] + + // Run + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CalcCompH(*state, + TU_load, + T_suction, + T_discharge, + Pipe_h_out_ave, + IUMaxCondTemp, + MinOutdoorUnitTe, + Tfs, + Pipe_Q, + OUEvapHeatExtract, + CompSpdActual, + Ncomp); + + // Test + EXPECT_NEAR(5110, OUEvapHeatExtract, 1); + EXPECT_NEAR(1500, CompSpdActual, 1); + EXPECT_NEAR(2080, Ncomp, 1); + EXPECT_EQ(state->dataLoopNodes->Node(state->dataHVACVarRefFlow->VRFTU(1).VRFTUInletNodeNum).MassFlowRate, 0.0); + } } TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Coil) @@ -2632,163 +2632,165 @@ TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_VRFOU_Coil) InitializePsychRoutines(*state); // Run and Check: VRFOU_Cap - { // Test the method VRFOU_Cap, which determines the VRF OU heat transfer rate, given refrigerant side temperature, - // i.e., condensing temperature and SC for condenser, or evaporating temperature and SH for evaporator. - {// a. Condenser - - // Inputs_condition - m_air = 3.6; - OutDryBulbTemp = 28; - OutHumRat = 0.0146; - SC = 1; - Tdischarge = 36; - - // Run - Q_h_OU = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_Cap(*state, HXOpMode::CondMode, Tdischarge, SC, m_air, OutDryBulbTemp, OutHumRat); - - // Test - EXPECT_NEAR(27551, Q_h_OU, 10); -} - -{ - // b. Evaporator - - // Inputs_condition - m_air = 3.6; - OutDryBulbTemp = 7; - OutHumRat = 0.0019; - SH = 1; - Tsuction = -3; - - // Run - Q_c_OU = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_Cap(*state, HXOpMode::EvapMode, Tsuction, SH, m_air, OutDryBulbTemp, OutHumRat); - - // Test - EXPECT_NEAR(24456, Q_c_OU, 10); -} -} // namespace EnergyPlus - -// Run and Check: VRFOU_FlowRate -{ // Test the method VRFOU_Cap, which calculates the outdoor unit fan flow rate, given VRF OU load and refrigerant side temperature, i.e., - // condensing temperature and SC for condenser, or evaporating temperature and SH for evaporator. - {// a. Condenser + { // Test the method VRFOU_Cap, which determines the VRF OU heat transfer rate, given refrigerant side temperature, + // i.e., condensing temperature and SC for condenser, or evaporating temperature and SH for evaporator. + { // a. Condenser + + // Inputs_condition + m_air = 3.6; + OutDryBulbTemp = 28; + OutHumRat = 0.0146; + SC = 1; + Tdischarge = 36; + + // Run + Q_h_OU = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_Cap(*state, HXOpMode::CondMode, Tdischarge, SC, m_air, OutDryBulbTemp, OutHumRat); + + // Test + EXPECT_NEAR(27551, Q_h_OU, 10); + } - // Inputs_condition - Q_h_OU = 27551; -OutDryBulbTemp = 28; -OutHumRat = 0.0146; -SC = 1; -Tdischarge = 36; + { + // b. Evaporator -// Run -m_air = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_FlowRate(*state, HXOpMode::CondMode, Tdischarge, SC, Q_h_OU, OutDryBulbTemp, OutHumRat); + // Inputs_condition + m_air = 3.6; + OutDryBulbTemp = 7; + OutHumRat = 0.0019; + SH = 1; + Tsuction = -3; -// Test -EXPECT_NEAR(3.6, m_air, 0.01); -} + // Run + Q_c_OU = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_Cap(*state, HXOpMode::EvapMode, Tsuction, SH, m_air, OutDryBulbTemp, OutHumRat); -{ - // b. Evaporator + // Test + EXPECT_NEAR(24456, Q_c_OU, 10); + } + } // namespace EnergyPlus + + // Run and Check: VRFOU_FlowRate + { // Test the method VRFOU_Cap, which calculates the outdoor unit fan flow rate, given VRF OU load and refrigerant side temperature, i.e., + // condensing temperature and SC for condenser, or evaporating temperature and SH for evaporator. + { // a. Condenser + + // Inputs_condition + Q_h_OU = 27551; + OutDryBulbTemp = 28; + OutHumRat = 0.0146; + SC = 1; + Tdischarge = 36; + + // Run + m_air = + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_FlowRate(*state, HXOpMode::CondMode, Tdischarge, SC, Q_h_OU, OutDryBulbTemp, OutHumRat); + + // Test + EXPECT_NEAR(3.6, m_air, 0.01); + } - // Inputs_condition - Q_c_OU = 24456; - OutDryBulbTemp = 7; - OutHumRat = 0.0019; - SH = 1; - Tsuction = -3; + { + // b. Evaporator - // Run - m_air = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_FlowRate(*state, HXOpMode::EvapMode, Tsuction, SH, Q_c_OU, OutDryBulbTemp, OutHumRat); + // Inputs_condition + Q_c_OU = 24456; + OutDryBulbTemp = 7; + OutHumRat = 0.0019; + SH = 1; + Tsuction = -3; - // Test - EXPECT_NEAR(3.6, m_air, 0.01); -} -} + // Run + m_air = + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_FlowRate(*state, HXOpMode::EvapMode, Tsuction, SH, Q_c_OU, OutDryBulbTemp, OutHumRat); -// Run and Check: VRFOU_TeTc -{ // Test the method VRFOU_Cap, which calculates the VRF OU refrigerant side temperature, i.e., condensing temperature - // at cooling mode, or evaporating temperature at heating mode, given the coil heat - // release/extract amount and air side parameters. - {// a. Condenser - - // Inputs_condition - m_air = 3.6; -Q_h_OU = 27551; -OutDryBulbTemp = 28; -OutHumRat = 0.0146; -SC = 1; - -// Run -state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_TeTc( - *state, HXOpMode::CondMode, Q_h_OU, SC, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress, temp, Tdischarge); - -// Test -EXPECT_NEAR(36, Tdischarge, 0.05); -} + // Test + EXPECT_NEAR(3.6, m_air, 0.01); + } + } -{ - // b. Evaporator - - // Inputs_condition - m_air = 3.6; - Q_c_OU = 24456; - OutDryBulbTemp = 7; - OutHumRat = 0.0019; - SH = 1; - Tsuction = -3; - - // Run - state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_TeTc( - *state, HXOpMode::EvapMode, Q_c_OU, SH, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress, temp, Tsuction); - - // Test - EXPECT_NEAR(-3, Tsuction, 0.05); -} -} + // Run and Check: VRFOU_TeTc + { // Test the method VRFOU_Cap, which calculates the VRF OU refrigerant side temperature, i.e., condensing temperature + // at cooling mode, or evaporating temperature at heating mode, given the coil heat + // release/extract amount and air side parameters. + { // a. Condenser + + // Inputs_condition + m_air = 3.6; + Q_h_OU = 27551; + OutDryBulbTemp = 28; + OutHumRat = 0.0146; + SC = 1; + + // Run + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_TeTc( + *state, HXOpMode::CondMode, Q_h_OU, SC, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress, temp, Tdischarge); + + // Test + EXPECT_NEAR(36, Tdischarge, 0.05); + } -// Run and Check: VRFOU_SCSH -{ - // Test the method VRFOU_Cap, which calculates the VRF OU refrigerant side temperature, i.e., condensing temperature - // at cooling mode, or evaporating temperature at heating mode, given the coil heat - // release/extract amount and air side parameters. - { - // a. Condenser + { + // b. Evaporator - // Inputs_condition - m_air = 3.6; - Q_h_OU = 27551; - OutDryBulbTemp = 28; - OutHumRat = 0.0146; - Tdischarge = 36; + // Inputs_condition + m_air = 3.6; + Q_c_OU = 24456; + OutDryBulbTemp = 7; + OutHumRat = 0.0019; + SH = 1; + Tsuction = -3; - // Run - SC = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_SCSH( - *state, HXOpMode::CondMode, Q_h_OU, Tdischarge, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress); + // Run + state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_TeTc( + *state, HXOpMode::EvapMode, Q_c_OU, SH, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress, temp, Tsuction); - // Test - EXPECT_NEAR(1, SC, 0.01); + // Test + EXPECT_NEAR(-3, Tsuction, 0.05); + } } + // Run and Check: VRFOU_SCSH { - // b. Evaporator + // Test the method VRFOU_Cap, which calculates the VRF OU refrigerant side temperature, i.e., condensing temperature + // at cooling mode, or evaporating temperature at heating mode, given the coil heat + // release/extract amount and air side parameters. + { + // a. Condenser + + // Inputs_condition + m_air = 3.6; + Q_h_OU = 27551; + OutDryBulbTemp = 28; + OutHumRat = 0.0146; + Tdischarge = 36; + + // Run + SC = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_SCSH( + *state, HXOpMode::CondMode, Q_h_OU, Tdischarge, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress); + + // Test + EXPECT_NEAR(1, SC, 0.01); + } - // Inputs_condition - m_air = 3.6; - Q_c_OU = 24456; - OutDryBulbTemp = 7; - OutHumRat = 0.0019; - Tsuction = -3; + { + // b. Evaporator - // Run - SH = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_SCSH( - *state, HXOpMode::EvapMode, Q_c_OU, Tsuction, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress); + // Inputs_condition + m_air = 3.6; + Q_c_OU = 24456; + OutDryBulbTemp = 7; + OutHumRat = 0.0019; + Tsuction = -3; - // Test - EXPECT_NEAR(1, SH, 0.01); + // Run + SH = state->dataHVACVarRefFlow->VRF(VRFCond).VRFOU_SCSH( + *state, HXOpMode::EvapMode, Q_c_OU, Tsuction, m_air, OutDryBulbTemp, OutHumRat, OutBaroPress); + + // Test + EXPECT_NEAR(1, SH, 0.01); + } } -} -// Clean up -state->dataHVACVarRefFlow->VRF.deallocate(); + // Clean up + state->dataHVACVarRefFlow->VRF.deallocate(); } TEST_F(EnergyPlusFixture, VRF_FluidTCtrl_GetCoilInput) diff --git a/tst/EnergyPlus/unit/OutputReportTabular.unit.cc b/tst/EnergyPlus/unit/OutputReportTabular.unit.cc index 02079680f88..02bf71ec73b 100644 --- a/tst/EnergyPlus/unit/OutputReportTabular.unit.cc +++ b/tst/EnergyPlus/unit/OutputReportTabular.unit.cc @@ -7208,10 +7208,7 @@ TEST_F(SQLiteFixture, OutputReportTabular_WriteLoadComponentSummaryTables_AirLoo state->dataSize->SysSizInput.allocate(state->dataSize->NumSysSizInput); state->dataSize->SysSizInput(1).AirLoopNum = 1; state->dataSize->SysSizInput(1).SizingOption = DataSizing::NonCoincident; - auto degC_to_F = [](Real64 celsius) constexpr - { - return celsius * (9.0 / 5.0) + 32.0; - }; + auto degC_to_F = [](Real64 celsius) constexpr { return celsius * (9.0 / 5.0) + 32.0; }; constexpr Real64 coolMixTempSys = 26.2; constexpr Real64 coolMixTempSysIP = degC_to_F(coolMixTempSys); constexpr Real64 heatMixTempSys = -1.7;