diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index 936b844962c..9acc1c3691a 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -76,15 +76,19 @@ if(MSVC AND NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) # Visual C++ (VS target_compile_options(project_options INTERFACE $<$:/Ob0>) # Disable inlining target_compile_options(project_options INTERFACE $<$:/RTCsu>) # Runtime checks target_compile_options(project_fp_options INTERFACE $<$:/fp:strict>) # Floating point model - target_compile_options(project_options INTERFACE $<$:/DMSVC_DEBUG>) # Triggers code in main.cc to catch floating point NaNs - target_compile_options(turn_off_warnings INTERFACE /W0) + option(FORCE_DEBUG_ARITHM_MSVC "Enable trapping floating point exceptions in non Debug mode" OFF) + mark_as_advanced(FORCE_DEBUG_ARITHM_MSVC) + + set(need_arithm_debug_genex "$,$>") + + # in main.cc for E+ (actual: api/EnergyPlusPgm.cc) and gtest: will catch _EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW + target_compile_definitions(project_fp_options INTERFACE $<${need_arithm_debug_genex}:DEBUG_ARITHM_MSVC>) + elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # g++/Clang - # TODO: after we fix all test, enable this by default on Debug builds - # option(FORCE_DEBUG_ARITHM_GCC_OR_CLANG "Enable trapping floating point exceptions in non Debug mode" OFF) - option(FORCE_DEBUG_ARITHM_GCC_OR_CLANG "Enable trapping floating point exceptions" OFF) + option(FORCE_DEBUG_ARITHM_GCC_OR_CLANG "Enable trapping floating point exceptions in non Debug mode" OFF) mark_as_advanced(FORCE_DEBUG_ARITHM_GCC_OR_CLANG) # COMPILER FLAGS @@ -126,16 +130,13 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O set(need_arithm_debug_genex "$,$>") - # TODO: after we fix all tests, remove this if statement (keeping the block to always execute) to enable this by default on Debug builds - if (FORCE_DEBUG_ARITHM_GCC_OR_CLANG) - # in main.cc for E+ and gtest: feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW) - target_compile_definitions(project_fp_options INTERFACE $<${need_arithm_debug_genex}:DEBUG_ARITHM_GCC_OR_CLANG>) - include(CheckCXXSymbolExists) - check_cxx_symbol_exists(feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT) - message(VERBOSE "HAVE_FEENABLEEXCEPT=${HAVE_FEENABLEEXCEPT}") - if(HAVE_FEENABLEEXCEPT) - target_compile_definitions(project_fp_options INTERFACE HAVE_FEENABLEEXCEPT) - endif() + # in main.cc for E+ (actual: api/EnergyPlusPgm.cc) and gtest: feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW) + target_compile_definitions(project_fp_options INTERFACE $<${need_arithm_debug_genex}:DEBUG_ARITHM_GCC_OR_CLANG>) + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT) + message(VERBOSE "HAVE_FEENABLEEXCEPT=${HAVE_FEENABLEEXCEPT}") + if(HAVE_FEENABLEEXCEPT) + target_compile_definitions(project_fp_options INTERFACE HAVE_FEENABLEEXCEPT) endif() # ADDITIONAL GCC-SPECIFIC FLAGS diff --git a/src/EnergyPlus/Autosizing/HeatingCapacitySizing.cc b/src/EnergyPlus/Autosizing/HeatingCapacitySizing.cc index 60339fe5202..1cf816f2658 100644 --- a/src/EnergyPlus/Autosizing/HeatingCapacitySizing.cc +++ b/src/EnergyPlus/Autosizing/HeatingCapacitySizing.cc @@ -378,11 +378,8 @@ Real64 HeatingCapacitySizer::size(EnergyPlusData &state, Real64 _originalValue, FlagCheckVolFlowPerRatedTotCap = false; } - if (this->dataIsDXCoil && FlagCheckVolFlowPerRatedTotCap) { - Real64 RatedVolFlowPerRatedTotCap = 0.0; - if (this->autoSizedValue > 0.0) { - RatedVolFlowPerRatedTotCap = DesVolFlow / this->autoSizedValue; - } + if (this->dataIsDXCoil && FlagCheckVolFlowPerRatedTotCap && this->autoSizedValue > 0.0) { + Real64 RatedVolFlowPerRatedTotCap = DesVolFlow / this->autoSizedValue; if (RatedVolFlowPerRatedTotCap < HVAC::MinRatedVolFlowPerRatedTotCap[(int)state.dataHVACGlobal->DXCT]) { if ((this->dataEMSOverride == 0.0) && state.dataGlobal->DisplayExtraWarnings && this->printWarningFlag) { ShowWarningError(state, this->callingRoutine + ' ' + this->compType + ' ' + this->compName); diff --git a/src/EnergyPlus/CurveManager.cc b/src/EnergyPlus/CurveManager.cc index e8c3faec990..77a0e811884 100644 --- a/src/EnergyPlus/CurveManager.cc +++ b/src/EnergyPlus/CurveManager.cc @@ -2497,6 +2497,7 @@ namespace Curve { ShowSevereError( state, format("Table:Lookup named \"{}\": Normalization divisor entered as zero, which is invalid", thisCurve->Name)); ErrorsFound = true; + continue; } } diff --git a/src/EnergyPlus/DXCoils.cc b/src/EnergyPlus/DXCoils.cc index c2fcfaef4a0..355e0bc83fc 100644 --- a/src/EnergyPlus/DXCoils.cc +++ b/src/EnergyPlus/DXCoils.cc @@ -4099,6 +4099,7 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.MSRatedCOP.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSRatedAirVolFlowRate.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSRatedAirMassFlowRate.allocate(thisDXCoil.NumOfSpeeds); + thisDXCoil.MSRatedAirMassFlowRate = 1.0; // avoid divide by 0, will get overwritten in InitDXCoil thisDXCoil.MSCCapFTemp.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSCCapFFlow.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSEIRFTemp.allocate(thisDXCoil.NumOfSpeeds); @@ -4613,6 +4614,7 @@ void GetDXCoils(EnergyPlusData &state) thisDXCoil.MSRatedCOP.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSRatedAirVolFlowRate.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSRatedAirMassFlowRate.allocate(thisDXCoil.NumOfSpeeds); + thisDXCoil.MSRatedAirMassFlowRate = 1.0; // avoid divide by 0, will get overwritten in InitDXCoil thisDXCoil.MSCCapFTemp.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSCCapFFlow.allocate(thisDXCoil.NumOfSpeeds); thisDXCoil.MSEIRFTemp.allocate(thisDXCoil.NumOfSpeeds); diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index df6c21bf79b..08e52b8fef0 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -415,7 +415,6 @@ void GetShadowingInput(EnergyPlusData &state) int NumNumbers; int NumAlphas; int IOStat; - int Found = 0; auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; state.dataIPShortCut->rNumericArgs({1, 4}) = 0.0; // so if nothing gotten, defaults will be maintained. state.dataIPShortCut->cAlphaArgs(1) = ""; @@ -2587,7 +2586,6 @@ void AnisoSkyViewFactors(EnergyPlusData &state) Real64 Epsilon; // Sky clearness parameter Real64 Delta; // Sky brightness parameter Real64 CosIncAngBeamOnSurface; // Cosine of incidence angle of beam solar on surface - Real64 IncAng; // Incidence angle of beam solar on surface (radians) int EpsilonBin; // Sky clearness (Epsilon) bin index Real64 AirMass; // Relative air mass Real64 AirMassH; // Intermediate variable for relative air mass calculation @@ -2652,8 +2650,6 @@ void AnisoSkyViewFactors(EnergyPlusData &state) CosIncAngBeamOnSurface = -1.0; } - IncAng = std::acos(CosIncAngBeamOnSurface); - ViewFactorSkyGeom = state.dataSurface->Surface(SurfNum).ViewFactorSky; state.dataSolarShading->SurfMultIsoSky(SurfNum) = ViewFactorSkyGeom * (1.0 - F1); // 0.0871557 below corresponds to a zenith angle of 85 deg @@ -3141,19 +3137,17 @@ bool polygon_contains_point(int const nsides, // number of sides (ver // Using/Aliasing using namespace DataVectorTypes; - // Return value - bool inside; // return value, true=inside, false = not inside + // return value, true=inside, false = not inside EP_SIZE_CHECK(polygon_3d, nsides); - int i; int ip1; // Object Data Array1D polygon(nsides); Vector_2d point; - inside = false; + bool inside = false; if (ignorex) { for (int i = 1; i <= nsides; ++i) { polygon(i).x = polygon_3d(i).y; @@ -3180,7 +3174,7 @@ bool polygon_contains_point(int const nsides, // number of sides (ver point.x = point.y = 0.0; // Elim possibly used uninitialized warnings } - for (i = 1; i <= nsides; ++i) { + for (int i = 1; i <= nsides; ++i) { if (i < nsides) { ip1 = i + 1; diff --git a/src/EnergyPlus/VariableSpeedCoils.cc b/src/EnergyPlus/VariableSpeedCoils.cc index 72555173ab9..324a94c8872 100644 --- a/src/EnergyPlus/VariableSpeedCoils.cc +++ b/src/EnergyPlus/VariableSpeedCoils.cc @@ -5556,7 +5556,11 @@ namespace VariableSpeedCoils { RatedInletEnth = Psychrometrics::PsyHFnTdbW(RatedInletAirTemp, RatedInletAirHumRat); CBFRated = AdjustCBF(varSpeedCoil.MSRatedCBF(NormSpeed), varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed), RatedAirMassFlowRate); if (CBFRated > 0.999) CBFRated = 0.999; - AirMassFlowRatio = RatedAirMassFlowRate / varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed); + if (varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed) > 1.0e-10) { + AirMassFlowRatio = RatedAirMassFlowRate / varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed); + } else { + AirMassFlowRatio = 1.0; + } if (varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed) > 1.0e-10) { WaterMassFlowRatio = varSpeedCoil.RatedWaterVolFlowRate / varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed); @@ -8622,7 +8626,11 @@ namespace VariableSpeedCoils { Real64 tADP = PsyTsatFnHPb(state, hADP, Pressure, RoutineName); // Apparatus dew point temperature [C] Real64 wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName); // Apparatus dew point humidity ratio [kg/kg] Real64 hTinwADP = PsyHFnTdbW(InletDryBulb, wADP); // Enthalpy at inlet dry-bulb and wADP [J/kg] - SHRCalc = min((hTinwADP - hADP) / (InletEnthalpy - hADP), 1.0); // temporary calculated value of SHR + if (TotCapCalc > 1.0e-10) { + SHRCalc = min((hTinwADP - hADP) / (InletEnthalpy - hADP), 1.0); // temporary calculated value of SHR + } else { + SHRCalc = 1.0; + } // Check for dry evaporator conditions (win < wadp) if (wADP > InletHumRatCalc || (Counter >= 1 && Counter < MaxIter)) { diff --git a/src/EnergyPlus/api/EnergyPlusPgm.cc b/src/EnergyPlus/api/EnergyPlusPgm.cc index a86e8c1a94e..6c7a375f371 100644 --- a/src/EnergyPlus/api/EnergyPlusPgm.cc +++ b/src/EnergyPlus/api/EnergyPlusPgm.cc @@ -182,10 +182,12 @@ #include #include -#ifndef NDEBUG -#ifdef __unix__ -#include +#ifdef DEBUG_ARITHM_GCC_OR_CLANG +#include #endif + +#ifdef DEBUG_ARITHM_MSVC +#include #endif // ObjexxFCL Headers @@ -248,17 +250,22 @@ void commonInitialize(EnergyPlus::EnergyPlusData &state) // std::cin.tie(nullptr); // Untie cin and cout: Could cause odd behavior for interactive prompts // Enable floating point exceptions -#ifndef NDEBUG -#ifdef __unix__ +#ifdef DEBUG_ARITHM_GCC_OR_CLANG feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); // These exceptions are enabled (FE_INEXACT and FE_UNDERFLOW will not throw) #endif -#endif -#ifdef MSVC_DEBUG - // the following line enables NaN detection in Visual Studio debug builds. See +#ifdef DEBUG_ARITHM_MSVC + // the following enables NaN detection in Visual Studio debug builds. See // https://github.com/NREL/EnergyPlus/wiki/Debugging-Tips - int fp_control_state = - _controlfp(_EM_INEXACT | _EM_UNDERFLOW, _MCW_EM); // These exceptions are disabled (_EM_INEXACT and _EM_UNDERFLOW will not throw) + + // Note: what you need to pass to the _controlfp_s is actually the opposite + // By default all bits are 1, and the exceptions are turned off, so you need to turn off the bits for the exceptions you want to enable + // > For the _MCW_EM mask, clearing it sets the exception, which allows the hardware exception; setting it hides the exception. + unsigned int fpcntrl = 0; + _controlfp_s(&fpcntrl, 0, 0); + unsigned int new_exceptions = _EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW; + unsigned int new_control = fpcntrl & ~new_exceptions; + _controlfp_s(&fpcntrl, new_control, _MCW_EM); #endif #ifdef _MSC_VER diff --git a/src/EnergyPlus/main.cc b/src/EnergyPlus/main.cc index b7ee17b6659..cffbc573080 100644 --- a/src/EnergyPlus/main.cc +++ b/src/EnergyPlus/main.cc @@ -50,16 +50,8 @@ #include -#ifdef DEBUG_ARITHM_GCC_OR_CLANG -#include -#endif - int main(int argc, char **argv) { -#ifdef DEBUG_ARITHM_GCC_OR_CLANG - feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); -#endif - #ifdef _WIN32 const std::vector args = CLI::detail::compute_win32_argv(); #else diff --git a/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc b/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc index e94bc58351d..6096d877bc0 100644 --- a/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc +++ b/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc @@ -2212,7 +2212,7 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_TestPressureStat) // Check indoor pressure and mass flow rate EXPECT_NEAR(PressureSet, state->afn->AirflowNetworkNodeSimu(3).PZ, 0.0001); - EXPECT_NEAR(0.00255337, state->afn->ReliefMassFlowRate, 0.0001); + EXPECT_NEAR(0.06551, state->afn->ReliefMassFlowRate, 0.0001); // Start a test for #5687 to report zero values of AirflowNetwork:Distribution airflow and pressure outputs when a system is off state->afn->AirflowNetworkFanActivated = false; diff --git a/tst/EnergyPlus/unit/DXCoils.unit.cc b/tst/EnergyPlus/unit/DXCoils.unit.cc index 1e6bdeeb19b..fddcb1dd1c0 100644 --- a/tst/EnergyPlus/unit/DXCoils.unit.cc +++ b/tst/EnergyPlus/unit/DXCoils.unit.cc @@ -87,13 +87,138 @@ using namespace DataEnvironment; namespace EnergyPlus { +void createFlatCurves(EnergyPlusData *state) +{ + state->dataCurveManager->allocateCurveVector(4); + + { + auto *curve = state->dataCurveManager->PerfCurve(1); + curve->curveType = CurveType::BiQuadratic; + curve->interpolationType = InterpType::EvaluateCurveToLimits; + curve->Name = "Non Flat BiQuadratic FT"; + curve->coeff[0] = 0.95624428; + curve->coeff[1] = 0; + curve->coeff[2] = 0; + curve->coeff[3] = 0.005999544; + curve->coeff[4] = -0.0000900072; + curve->coeff[5] = 0; + curve->inputLimits[0].min = 0.0; + curve->inputLimits[0].max = 2.0; + curve->inputLimits[1].min = 0.0; + curve->inputLimits[1].max = 2.0; + } + + { + auto *curve = state->dataCurveManager->PerfCurve(2); + curve->curveType = CurveType::Quadratic; + curve->Name = "Flat Quadratic FFlow"; + curve->coeff[0] = 1; + curve->coeff[1] = 0; + curve->coeff[2] = 0; + curve->inputLimits[0].min = 0; + curve->inputLimits[0].max = 2; + curve->outputLimits.min = 0; + curve->outputLimits.max = 2; + } + + { + auto *curve = state->dataCurveManager->PerfCurve(3); + curve->Name = "Flat Quadratic PLFFPLR"; + curve->curveType = CurveType::Quadratic; + curve->interpolationType = InterpType::EvaluateCurveToLimits; + curve->coeff[0] = 1; + curve->coeff[1] = 0.0; + curve->coeff[2] = 0.0; + curve->coeff[3] = 0.0; + curve->coeff[4] = 0.0; + curve->coeff[5] = 0.0; + curve->inputLimits[0].min = 0.0; + curve->inputLimits[0].max = 1.0; + curve->inputLimits[1].min = 0.7; + curve->inputLimits[1].max = 1.0; + } + + { + auto *curve = state->dataCurveManager->PerfCurve(4); + curve->Name = "Flat BiQuadratic FEIR"; + curve->curveType = CurveType::BiQuadratic; + curve->interpolationType = InterpType::EvaluateCurveToLimits; + curve->coeff[0] = 1; + curve->coeff[1] = 0.0; + curve->coeff[2] = 0.0; + curve->coeff[3] = 0.0; + curve->coeff[4] = 0.0; + curve->coeff[5] = 0.0; + curve->inputLimits[0].min = -100.0; + curve->inputLimits[0].max = 100.0; + curve->inputLimits[1].min = -100.0; + curve->inputLimits[1].max = 100.0; + } +} +void createSpeedsWithDefaults(DXCoils::DXCoilData &thisDXCoil) +{ + int const numSpeeds = thisDXCoil.NumOfSpeeds; + thisDXCoil.MSRatedTotCap.allocate(numSpeeds); + thisDXCoil.MSRatedTotCap = DataSizing::AutoSize; + + thisDXCoil.MSRatedSHR.allocate(numSpeeds); + thisDXCoil.MSRatedSHR = DataSizing::AutoSize; + + thisDXCoil.MSRatedCOP.allocate(numSpeeds); + thisDXCoil.MSRatedCOP = 3.0; + + thisDXCoil.MSRatedAirVolFlowRate.allocate(numSpeeds); + thisDXCoil.MSRatedAirVolFlowRate = DataSizing::AutoSize; + + thisDXCoil.MSFanPowerPerEvapAirFlowRate.allocate(numSpeeds); + thisDXCoil.MSFanPowerPerEvapAirFlowRate = 777.3; + + thisDXCoil.MSFanPowerPerEvapAirFlowRate_2023.allocate(numSpeeds); + thisDXCoil.MSFanPowerPerEvapAirFlowRate_2023 = 934.4; + + thisDXCoil.MSCCapFTemp.allocate(numSpeeds); + thisDXCoil.MSCCapFFlow.allocate(numSpeeds); + thisDXCoil.MSEIRFTemp.allocate(numSpeeds); + thisDXCoil.MSEIRFFlow.allocate(numSpeeds); + thisDXCoil.MSPLFFPLR.allocate(numSpeeds); + + thisDXCoil.MSTwet_Rated.allocate(numSpeeds); + thisDXCoil.MSTwet_Rated = 0.0; + + thisDXCoil.MSGamma_Rated.allocate(numSpeeds); + thisDXCoil.MSGamma_Rated = 0.0; + + thisDXCoil.MSMaxONOFFCyclesperHour.allocate(numSpeeds); + thisDXCoil.MSMaxONOFFCyclesperHour = 0.0; + + thisDXCoil.MSLatentCapacityTimeConstant.allocate(numSpeeds); + thisDXCoil.MSLatentCapacityTimeConstant = 0.0; + + thisDXCoil.MSWasteHeatFrac.allocate(numSpeeds); + thisDXCoil.MSWasteHeatFrac = 0.2; + + thisDXCoil.MSWasteHeat.allocate(numSpeeds); + + thisDXCoil.MSEvapCondEffect.allocate(numSpeeds); + thisDXCoil.MSEvapCondEffect = 0.9; + + thisDXCoil.MSEvapCondAirFlow.allocate(numSpeeds); + thisDXCoil.MSEvapCondAirFlow = DataSizing::AutoSize; + + thisDXCoil.MSEvapCondPumpElecNomPower.allocate(numSpeeds); + thisDXCoil.MSEvapCondPumpElecNomPower = DataSizing::AutoSize; + + // Other + thisDXCoil.MSRatedCBF.allocate(numSpeeds); + thisDXCoil.MSRatedAirMassFlowRate.allocate(numSpeeds); +} + TEST_F(EnergyPlusFixture, DXCoils_Test1) { using Psychrometrics::PsyRhFnTdbWPb; using Psychrometrics::PsyTdbFnHW; using Psychrometrics::PsyTsatFnHPb; using Psychrometrics::PsyWFnTdbH; - int DXCoilNum; state->dataDXCoils->NumDXCoils = 2; state->dataDXCoils->DXCoil.allocate(state->dataDXCoils->NumDXCoils); @@ -114,38 +239,20 @@ TEST_F(EnergyPlusFixture, DXCoils_Test1) state->dataDXCoils->DXCoil(1).NumOfSpeeds = 2; state->dataDXCoils->DXCoil(2).NumOfSpeeds = 2; - for (DXCoilNum = 1; DXCoilNum <= 2; ++DXCoilNum) { - state->dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSTwet_Rated.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSGamma_Rated.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSMaxONOFFCyclesperHour.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSLatentCapacityTimeConstant.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); - state->dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate_2023.allocate(state->dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds); + for (int DXCoilNum = 1; DXCoilNum <= 2; ++DXCoilNum) { + createSpeedsWithDefaults(state->dataDXCoils->DXCoil(DXCoilNum)); } - state->dataDXCoils->DXCoil(1).MSRatedTotCap(1) = 4455.507579219055; - state->dataDXCoils->DXCoil(1).MSRatedTotCap(2) = 6188.507579219055; - state->dataDXCoils->DXCoil(1).MSCCapFFlow = 1; - state->dataDXCoils->DXCoil(1).MSCCapFTemp = 3; - state->dataDXCoils->DXCoil(1).MSEIRFFlow = 1; - state->dataDXCoils->DXCoil(1).MSEIRFTemp = 3; - state->dataDXCoils->DXCoil(1).MSPLFFPLR = 2; + createFlatCurves(state); + + int DXCoilNum = 1; + state->dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(1) = 4455.507579219055; + state->dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(2) = 6188.507579219055; + state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow = 2; + state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp = 1; + state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow = 2; + state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp = 4; + state->dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR = 3; DXCoilNum = 2; state->dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(1) = 4455.507579219055; @@ -153,11 +260,11 @@ TEST_F(EnergyPlusFixture, DXCoils_Test1) state->dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(1) = 4.03; state->dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(2) = 3.53; - state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow = 1; - state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp = 3; - state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow = 1; - state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp = 3; - state->dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR = 2; + state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow = 2; + state->dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp = 1; + state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow = 2; + state->dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp = 4; + state->dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR = 3; state->dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(1) = 0.2339; state->dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(2) = 0.2924; state->dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate = 0.0; @@ -165,50 +272,6 @@ TEST_F(EnergyPlusFixture, DXCoils_Test1) state->dataDXCoils->DXCoil(DXCoilNum).RegionNum = 4; state->dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = -17.78; - state->dataCurveManager->allocateCurveVector(3); - - auto *curve1 = state->dataCurveManager->PerfCurve(1); - curve1->curveType = CurveType::Quadratic; - curve1->interpolationType = InterpType::EvaluateCurveToLimits; - curve1->coeff[0] = 1; - curve1->coeff[1] = 0.0; - curve1->coeff[2] = 0.0; - curve1->coeff[3] = 0.0; - curve1->coeff[4] = 0.0; - curve1->coeff[5] = 0.0; - curve1->inputLimits[0].min = 0.0; - curve1->inputLimits[0].max = 2.0; - curve1->inputLimits[1].min = 0.0; - curve1->inputLimits[1].max = 2.0; - - auto *curve2 = state->dataCurveManager->PerfCurve(2); - curve2->curveType = CurveType::Quadratic; - curve2->interpolationType = InterpType::EvaluateCurveToLimits; - curve2->coeff[0] = 1; - curve2->coeff[1] = 0.0; - curve2->coeff[2] = 0.0; - curve2->coeff[3] = 0.0; - curve2->coeff[4] = 0.0; - curve2->coeff[5] = 0.0; - curve2->inputLimits[0].min = 0.0; - curve2->inputLimits[0].max = 1.0; - curve2->inputLimits[1].min = 0.7; - curve2->inputLimits[1].max = 1.0; - - auto *curve3 = state->dataCurveManager->PerfCurve(3); - curve3->curveType = CurveType::BiQuadratic; - curve3->interpolationType = InterpType::EvaluateCurveToLimits; - curve3->coeff[0] = 1; - curve3->coeff[1] = 0.0; - curve3->coeff[2] = 0.0; - curve3->coeff[3] = 0.0; - curve3->coeff[4] = 0.0; - curve3->coeff[5] = 0.0; - curve3->inputLimits[0].min = -100.0; - curve3->inputLimits[0].max = 100.0; - curve3->inputLimits[1].min = -100.0; - curve3->inputLimits[1].max = 100.0; - SetPredefinedTables(*state); SizeDXCoil(*state, 2); EXPECT_DOUBLE_EQ(5000.0, state->dataDXCoils->DXCoil(2).DefrostCapacity); @@ -1940,6 +2003,14 @@ TEST_F(EnergyPlusFixture, TestReadingCoilCoolingHeatingDX) GetCurveInput(*state); GetDXCoils(*state); VariableSpeedCoils::GetVarSpeedCoilInput(*state); + + state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->OutDryBulbTemp = 20.0; + state->dataEnvrn->OutHumRat = 0.008; + state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, 20.0, 0.0); + Psychrometrics::InitializePsychRoutines(*state); + // Coil:Cooling:DX:SingleSpeed EXPECT_EQ(state->dataDXCoils->DXCoil(1).DXCoilType_Num, HVAC::CoilDX_CoolingSingleSpeed); EXPECT_EQ("HEATERCAPCURVE", Curve::GetCurveName(*state, state->dataDXCoils->DXCoil(1).CrankcaseHeaterCapacityCurveIndex)); @@ -2004,6 +2075,7 @@ TEST_F(EnergyPlusFixture, TestReadingCoilCoolingHeatingDX) Real64 LatentLoad = 100.0; Real64 OnOffAirFlowRatio = 0.5; state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).AirMassFlowRate = 1.0; + state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).DesignAirMassFlowRate = 1.0; state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).RunFrac = 0.0; state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).RatedCapCoolTotal = 100.0; // power = 26 + 2x @@ -2022,6 +2094,7 @@ TEST_F(EnergyPlusFixture, TestReadingCoilCoolingHeatingDX) VarSpeedCoilNum = 2; state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).AirMassFlowRate = 0.5; state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).RunFrac = 0.0; + state->dataVariableSpeedCoils->VarSpeedCoil(VarSpeedCoilNum).DesignAirMassFlowRate = 1.0; // power = 28 + 2x state->dataEnvrn->OutHumRat = 0.0114507065; state->dataEnvrn->OutBaroPress = 98200.0; @@ -3247,7 +3320,11 @@ TEST_F(SQLiteFixture, DXCoils_TestComponentSizingOutput_TwoSpeed) state->dataSize->SysSizInput(1).AirLoopNum = state->dataSize->CurSysNum; state->dataSize->NumSysSizInput = 1; - state->dataEnvrn->StdBaroPress = 101325.0; + state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->OutDryBulbTemp = 20.0; + state->dataEnvrn->OutHumRat = 0.008; + state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); Psychrometrics::InitializePsychRoutines(*state); // Need this to prevent crash in Sizers @@ -3472,7 +3549,11 @@ TEST_F(SQLiteFixture, DXCoils_TestComponentSizingOutput_SingleSpeed) state->dataSize->SysSizInput(1).AirLoopNum = state->dataSize->CurSysNum; state->dataSize->NumSysSizInput = 1; - state->dataEnvrn->StdBaroPress = 101325.0; + state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->OutDryBulbTemp = 20.0; + state->dataEnvrn->OutHumRat = 0.008; + state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); Psychrometrics::InitializePsychRoutines(*state); // Need this to prevent crash in Sizers @@ -5087,6 +5168,7 @@ TEST_F(EnergyPlusFixture, SingleSpeedDXCoolingCoilOutputTest) Coil.RatedTotCap(1) = 17580.0; Coil.RatedCOP(1) = 3.0; Coil.RatedEIR(1) = 1.0 / Coil.RatedCOP(1); + Coil.RatedCBF(1) = 0.00000001; // autosizing is disabled so initialize coil bypass factor Coil.RatedAirMassFlowRate = 1.0; Coil.MinOATCompressor = -17.78; Coil.CCapFTemp(1) = 1; @@ -5142,6 +5224,10 @@ TEST_F(EnergyPlusFixture, SingleSpeedDXCoolingCoilOutputTest) state->dataEnvrn->OutHumRat = 0.0120; state->dataEnvrn->WindSpeed = 5.0; state->dataEnvrn->WindDir = 0.0; + state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); + Psychrometrics::InitializePsychRoutines(*state); + // run coil at full capacity Real64 PartLoadRatio(1.0); Real64 AirFlowRatio(1.0); @@ -5225,47 +5311,21 @@ TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) state->dataDXCoils->DXCoilOutletHumRat.allocate(1); state->dataDXCoils->DXCoilPartLoadRatio.allocate(1); state->dataDXCoils->DXCoilFanOp.allocate(1); - state->dataCurveManager->allocateCurveVector(2); auto &Coil = state->dataDXCoils->DXCoil(1); - EnergyPlus::Curve::Curve *constantcurve1 = state->dataCurveManager->PerfCurve(1); - EnergyPlus::Curve::Curve *constantcurve2 = state->dataCurveManager->PerfCurve(2); auto &AirInletNode = state->dataLoopNodes->Node(1); auto &AirOutletNode = state->dataLoopNodes->Node(2); Coil.DXCoilType_Num = HVAC::CoilDX_MultiSpeedCooling; Coil.DXCoilType = "Coil:Cooling:DX:MultiSpeed"; Coil.SchedPtr = ScheduleManager::ScheduleAlwaysOn; + Coil.NumOfSpeeds = 2; - Coil.MSRatedTotCap.allocate(Coil.NumOfSpeeds); - Coil.MSRatedSHR.allocate(Coil.NumOfSpeeds); - Coil.MSRatedCOP.allocate(Coil.NumOfSpeeds); - Coil.MSRatedAirVolFlowRate.allocate(Coil.NumOfSpeeds); - Coil.MSRatedAirMassFlowRate.allocate(Coil.NumOfSpeeds); - Coil.MSCCapFTemp.allocate(Coil.NumOfSpeeds); - Coil.MSCCapFFlow.allocate(Coil.NumOfSpeeds); - Coil.MSEIRFTemp.allocate(Coil.NumOfSpeeds); - Coil.MSEIRFFlow.allocate(Coil.NumOfSpeeds); - Coil.MSWasteHeat.allocate(Coil.NumOfSpeeds); - Coil.MSEvapCondEffect.allocate(Coil.NumOfSpeeds); - Coil.MSEvapCondAirFlow.allocate(Coil.NumOfSpeeds); - Coil.MSEvapCondPumpElecNomPower.allocate(Coil.NumOfSpeeds); - Coil.MSRatedCBF.allocate(Coil.NumOfSpeeds); - Coil.MSWasteHeatFrac.allocate(Coil.NumOfSpeeds); - Coil.MSPLFFPLR.allocate(Coil.NumOfSpeeds); - Coil.MSTwet_Rated.allocate(Coil.NumOfSpeeds); - Coil.MSGamma_Rated.allocate(Coil.NumOfSpeeds); - Coil.MSMaxONOFFCyclesperHour.allocate(Coil.NumOfSpeeds); - Coil.MSLatentCapacityTimeConstant.allocate(Coil.NumOfSpeeds); - Coil.MSFanPowerPerEvapAirFlowRate.allocate(Coil.NumOfSpeeds); - Coil.MSCCapFTemp = 1; - Coil.MSCCapFFlow = 2; - Coil.MSEIRFTemp = 1; - Coil.MSEIRFFlow = 2; - Coil.MSPLFFPLR = 2; - Coil.AirOutNode = 2; - Coil.AirInNode = 1; + createSpeedsWithDefaults(Coil); + + state->dataCurveManager->allocateCurveVector(2); // biquadratic curve + EnergyPlus::Curve::Curve *constantcurve1 = state->dataCurveManager->PerfCurve(1); constantcurve1->Name = "constant biquadratic curve"; constantcurve1->curveType = CurveType::BiQuadratic; constantcurve1->interpolationType = InterpType::EvaluateCurveToLimits; @@ -5282,6 +5342,7 @@ TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) constantcurve1->outputLimits.min = 1.0; constantcurve1->outputLimits.max = 1.0; // quadratic curve + EnergyPlus::Curve::Curve *constantcurve2 = state->dataCurveManager->PerfCurve(2); constantcurve2->Name = "constant quadratic curve"; constantcurve2->curveType = CurveType::Quadratic; constantcurve2->interpolationType = InterpType::EvaluateCurveToLimits; @@ -5292,14 +5353,22 @@ TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) constantcurve2->inputLimits[0].max = 1.0; constantcurve2->outputLimits.min = 1.0; constantcurve2->outputLimits.max = 1.0; + + Coil.MSCCapFTemp = 1; + Coil.MSCCapFFlow = 2; + Coil.MSEIRFTemp = 1; + Coil.MSEIRFFlow = 2; + Coil.MSPLFFPLR = 2; + Coil.AirInNode = 1; + Coil.AirOutNode = 2; // set coil parameter Coil.MSRatedTotCap(1) = 10710.0; // 60 % of full capacity Coil.MSRatedTotCap(2) = 17850.0; // 5 ton capcity Coil.InletAirMassFlowRate = state->dataHVACGlobal->MSHPMassFlowRateHigh; Coil.MSRatedAirMassFlowRate(1) = state->dataHVACGlobal->MSHPMassFlowRateLow; Coil.MSRatedAirMassFlowRate(2) = state->dataHVACGlobal->MSHPMassFlowRateHigh; - Coil.MSRatedCBF(1) = 0.0; - Coil.MSRatedCBF(2) = 0.0; + Coil.MSRatedCBF(1) = 0.00000001; + Coil.MSRatedCBF(2) = 0.00000001; Coil.MSWasteHeat(1) = 0; Coil.MSWasteHeat(2) = 0; Coil.MSWasteHeatFrac(1) = 0; @@ -5326,6 +5395,9 @@ TEST_F(EnergyPlusFixture, MultiSpeedDXCoolingCoilOutputTest) state->dataEnvrn->OutHumRat = 0.0120; state->dataEnvrn->WindSpeed = 5.0; state->dataEnvrn->WindDir = 0.0; + state->dataEnvrn->StdBaroPress = DataEnvironment::StdPressureSeaLevel; + state->dataEnvrn->StdRhoAir = Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->StdBaroPress, 20.0, 0.0); + Psychrometrics::InitializePsychRoutines(*state); int SpeedNum = 2; HVAC::FanOp fanOp = HVAC::FanOp::Cycling; HVAC::CompressorOp compressorOp = HVAC::CompressorOp::On; @@ -5536,6 +5608,8 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatingsTest) state->dataGlobal->SysSizingCalc = true; coolcoilTwoSpeed.RatedAirMassFlowRate(1) = coolcoilTwoSpeed.RatedAirVolFlowRate(1) * state->dataEnvrn->StdRhoAir; coolcoilTwoSpeed.RatedAirMassFlowRate2 = coolcoilTwoSpeed.RatedAirVolFlowRate2 * state->dataEnvrn->StdRhoAir; + coolcoilTwoSpeed.RatedCBF(1) = 0.00000001; // autosizing is disabled so initialize coil bypass factor + coolcoilTwoSpeed.RatedCBF2 = 0.00000001; supplyFan->maxAirMassFlowRate = supplyFan->maxAirFlowRate * state->dataEnvrn->StdRhoAir; supplyFan->rhoAirStdInit = state->dataEnvrn->StdRhoAir; auto &InletNode = state->dataLoopNodes->Node(supplyFan->inletNodeNum); @@ -5557,7 +5631,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatingsTest) EXPECT_EQ(coolcoilTwoSpeed.InternalStaticPressureDrop, 400.0); EXPECT_TRUE(coolcoilTwoSpeed.RateWithInternalStaticAndFanObject); EXPECT_EQ("8.77", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilEERIP, coolcoilTwoSpeed.Name)); - EXPECT_EQ("11.2", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); + EXPECT_EQ("10.8", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); // TODO: The IEER will not be generated for this particular coil because the cpacity is below the minimum for IEER // i.e, 65,000 Btu/h (19049.61955 Watts) // EXPECT_EQ("N/A", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); @@ -5566,7 +5640,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatingsTest) OutputReportPredefined::SetPredefinedTables(*state); CalcTwoSpeedDXCoilStandardRating(*state, dXCoilIndex); EXPECT_EQ("8.72", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilEERIP, coolcoilTwoSpeed.Name)); - EXPECT_EQ("10.1", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); + EXPECT_EQ("9.8", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); // EXPECT_EQ("N/A", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); } @@ -5778,6 +5852,8 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatings_Curve_Fix_Test) state->dataGlobal->SysSizingCalc = true; coolcoilTwoSpeed.RatedAirMassFlowRate(1) = coolcoilTwoSpeed.RatedAirVolFlowRate(1) * state->dataEnvrn->StdRhoAir; coolcoilTwoSpeed.RatedAirMassFlowRate2 = coolcoilTwoSpeed.RatedAirVolFlowRate2 * state->dataEnvrn->StdRhoAir; + coolcoilTwoSpeed.RatedCBF(1) = 0.00000001; // autosizing is disabled so initialize coil bypass factor + coolcoilTwoSpeed.RatedCBF2 = 0.00000001; supplyFan->maxAirMassFlowRate = supplyFan->maxAirFlowRate * state->dataEnvrn->StdRhoAir; supplyFan->rhoAirStdInit = state->dataEnvrn->StdRhoAir; auto &InletNode = state->dataLoopNodes->Node(supplyFan->inletNodeNum); @@ -5801,7 +5877,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatings_Curve_Fix_Test) EXPECT_EQ(coolcoilTwoSpeed.InternalStaticPressureDrop, 400.0); EXPECT_TRUE(coolcoilTwoSpeed.RateWithInternalStaticAndFanObject); EXPECT_EQ("8.77", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilEERIP, coolcoilTwoSpeed.Name)); - EXPECT_EQ("11.2", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); + EXPECT_EQ("10.8", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); // The IEER will not be generated for this particular coil because the cpacity is below the minimum for IEER // TODO: EXPECT_EQ("N/A", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); @@ -5813,7 +5889,7 @@ TEST_F(EnergyPlusFixture, TwoSpeedDXCoilStandardRatings_Curve_Fix_Test) OutputReportPredefined::SetPredefinedTables(*state); CalcTwoSpeedDXCoilStandardRating(*state, dXCoilIndex); EXPECT_EQ("8.72", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilEERIP, coolcoilTwoSpeed.Name)); - EXPECT_EQ("10.2", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); + EXPECT_EQ("9.8", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); // TODO: The IEER will not be generated for this particular coil because the cpacity is below the minimum for IEER // EXPECT_EQ("N/A", RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchDXCoolCoilIEERIP, coolcoilTwoSpeed.Name)); diff --git a/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc b/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc index 05f2f7cc81d..ec4c23113c4 100644 --- a/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc +++ b/tst/EnergyPlus/unit/ElectricPowerServiceManager.unit.cc @@ -693,6 +693,7 @@ TEST_F(EnergyPlusFixture, ManageElectricPowerTest_CheckOutputReporting) ASSERT_TRUE(process_idf(idf_objects)); state->dataHVACGlobal->TimeStepSys = 1.0; + state->dataHVACGlobal->TimeStepSysSec = 3600.0; state->dataGlobal->TimeStepZoneSec = 3600.0; createFacilityElectricPowerServiceObject(*state); diff --git a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc index f3da433eec1..4616f9874a1 100644 --- a/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc +++ b/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc @@ -119,6 +119,7 @@ void EnergyPlusFixture::SetUp() Psychrometrics::InitializePsychRoutines(*state); createCoilSelectionReportObj(*state); + state->dataEnvrn->StdRhoAir = 1.2; } void EnergyPlusFixture::TearDown() diff --git a/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc b/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc index 11e18252587..ecab9c6fdcd 100644 --- a/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc @@ -2204,6 +2204,14 @@ TEST_F(EnergyPlusFixture, HVACMSHP_UnitarySystemElectricityRateTest) state->dataEnvrn->OutHumRat = 0.005; state->dataEnvrn->StdBaroPress = 101325.0; state->dataEnvrn->OutBaroPress = 101325.0; + + for (int Mode = 1; Mode <= dxClgCoilMain.NumOfSpeeds; ++Mode) { + dxClgCoilMain.MSRatedAirMassFlowRate(Mode) = dxClgCoilMain.MSRatedAirVolFlowRate(Mode) * state->dataEnvrn->StdRhoAir; + } + for (int Mode = 1; Mode <= dxHtgCoilMain.NumOfSpeeds; ++Mode) { + dxHtgCoilMain.MSRatedAirMassFlowRate(Mode) = dxHtgCoilMain.MSRatedAirVolFlowRate(Mode) * state->dataEnvrn->StdRhoAir; + } + // set zone air conditions auto &zoneAirNode = state->dataLoopNodes->Node(Util::FindItemInList("Z401 AIR NODE", state->dataLoopNodes->NodeID, state->dataLoopNodes->NumOfNodes)); diff --git a/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc b/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc index 0f871939e9b..e53ed583850 100644 --- a/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc +++ b/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc @@ -1715,13 +1715,21 @@ TEST_F(EnergyPlusFixture, UnitaryBypassVAV_ParentElectricityRateTest) // set sizing variables state->dataSize->SysSizingRunDone = true; state->dataSize->ZoneSizingRunDone = true; - state->dataGlobal->SysSizingCalc = true; + state->dataGlobal->SysSizingCalc = true; // disable sizing calculation state->dataGlobal->SysSizingCalc = true; state->dataGlobal->BeginEnvrnFlag = true; // set local variables for convenience auto *supplyFan = state->dataFans->fans(1); auto &dxClgCoilMain = state->dataVariableSpeedCoils->VarSpeedCoil(1); auto &dxHtgCoilMain = state->dataVariableSpeedCoils->VarSpeedCoil(2); + + for (int Mode = 1; Mode <= dxClgCoilMain.NumOfSpeeds; ++Mode) { + dxClgCoilMain.MSRatedAirMassFlowRate(Mode) = dxClgCoilMain.MSRatedAirVolFlowRate(Mode) * state->dataEnvrn->StdRhoAir; + } + for (int Mode = 1; Mode <= dxHtgCoilMain.NumOfSpeeds; ++Mode) { + dxHtgCoilMain.MSRatedAirMassFlowRate(Mode) = dxHtgCoilMain.MSRatedAirVolFlowRate(Mode) * state->dataEnvrn->StdRhoAir; + } + // initialize priority control BypassVAV.PriorityControl = HVACUnitaryBypassVAV::PriorityCtrlMode::HeatingPriority; BypassVAV.AirFlowControl = HVACUnitaryBypassVAV::AirFlowCtrlMode::UseCompressorOnFlow; diff --git a/tst/EnergyPlus/unit/MixedAir.unit.cc b/tst/EnergyPlus/unit/MixedAir.unit.cc index 47d9a53d472..01bdbee4868 100644 --- a/tst/EnergyPlus/unit/MixedAir.unit.cc +++ b/tst/EnergyPlus/unit/MixedAir.unit.cc @@ -840,6 +840,13 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataEnvrn->StdBaroPress = StdPressureSeaLevel; + state->dataEnvrn->OutDryBulbTemp = 13.0; + state->dataEnvrn->OutBaroPress = StdPressureSeaLevel; + state->dataEnvrn->OutHumRat = 0.008; + state->dataEnvrn->StdRhoAir = + Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); + ScheduleManager::ProcessScheduleInput(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); GetOAControllerInputs(*state); @@ -873,7 +880,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) state->dataLoopNodes->Node(10).Temp = 13.00; state->dataLoopNodes->Node(10).HumRat = 0.008; state->dataLoopNodes->Node(10).MassFlowRate = 1.7 * state->dataEnvrn->StdRhoAir; - state->dataEnvrn->OutBaroPress = 101325; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(1); oaRequirements.OAFlowMethod = OAFlowCalcMethod::PCDesOcc; @@ -914,7 +920,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) EXPECT_EQ("ProportionalControlBasedOnDesignOccupancy", DataSizing::OAFlowCalcMethodNames[static_cast(ventMechanical.VentMechZone(1).ZoneOAFlowMethod)]); - state->dataEnvrn->StdRhoAir = 1.2; oaController.MixMassFlow = 1.7 * state->dataEnvrn->StdRhoAir; oaController.MaxOAMassFlowRate = 1.7 * state->dataEnvrn->StdRhoAir; state->dataAirLoop->AirLoopFlow(1).DesSupply = 1.7 * state->dataEnvrn->StdRhoAir; @@ -925,25 +930,32 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest) // Case 1 - Zone CO2 greater than CO2 Max, so OA flow is flow/area+flow/person state->dataContaminantBalance->ZoneAirCO2(1) = 600.0; - Real64 expectedOAMassFlow = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + - oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants) * - state->dataEnvrn->StdRhoAir; + Real64 ZoneOA = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + + oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants); + Real64 ZoneOAFrac = ZoneOA / 1.7; + Real64 Evz = 1.0 - ZoneOAFrac; // SysEv == Evz + Real64 expectedOAMassFlow = ZoneOA * state->dataEnvrn->StdRhoAir / Evz; oaController.CalcOAController(*state, 1, true); EXPECT_NEAR(expectedOAMassFlow, oaController.OAMassFlow, 0.00001); EXPECT_NEAR(expectedOAMassFlow / oaController.MixMassFlow, oaController.MinOAFracLimit, 0.00001); // Case 2 - Zone CO2 greater than CO2 Min, so OA flow is flow/area state->dataContaminantBalance->ZoneAirCO2(1) = 200.0; - expectedOAMassFlow = oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea * state->dataEnvrn->StdRhoAir; + ZoneOA = oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea; + ZoneOAFrac = ZoneOA / 1.7; + Evz = 1.0 - ZoneOAFrac; + expectedOAMassFlow = ZoneOA * state->dataEnvrn->StdRhoAir / Evz; oaController.CalcOAController(*state, 1, true); EXPECT_NEAR(expectedOAMassFlow, oaController.OAMassFlow, 0.00001); EXPECT_NEAR(expectedOAMassFlow / oaController.MixMassFlow, oaController.MinOAFracLimit, 0.00001); // Case 3 - Zone CO2 in between CO2 Max and Min, so OA flow is flow/area + proportionate flow/person state->dataContaminantBalance->ZoneAirCO2(1) = zoneCO2Min + 0.3 * (zoneCO2Max - zoneCO2Min); - expectedOAMassFlow = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + - 0.3 * oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants) * - state->dataEnvrn->StdRhoAir; + ZoneOA = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + + 0.3 * oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants); + ZoneOAFrac = ZoneOA / 1.7; + Evz = 1.0 - ZoneOAFrac; + expectedOAMassFlow = ZoneOA * state->dataEnvrn->StdRhoAir / Evz; oaController.CalcOAController(*state, 1, true); EXPECT_NEAR(expectedOAMassFlow, oaController.OAMassFlow, 0.00001); EXPECT_NEAR(expectedOAMassFlow / oaController.MixMassFlow, oaController.MinOAFracLimit, 0.00001); @@ -1117,6 +1129,13 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataGlobal->NumOfTimeStepInHour = 4; // must initialize this to get schedules initialized state->dataGlobal->MinutesPerTimeStep = 15; // must initialize this to get schedules initialized + state->dataEnvrn->StdBaroPress = StdPressureSeaLevel; + state->dataEnvrn->OutDryBulbTemp = 13.0; + state->dataEnvrn->OutBaroPress = StdPressureSeaLevel; + state->dataEnvrn->OutHumRat = 0.008; + state->dataEnvrn->StdRhoAir = + Psychrometrics::PsyRhoAirFnPbTdbW(*state, state->dataEnvrn->OutBaroPress, state->dataEnvrn->OutDryBulbTemp, state->dataEnvrn->OutHumRat); + ScheduleManager::ProcessScheduleInput(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); GetOAControllerInputs(*state); @@ -1174,7 +1193,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataLoopNodes->Node(10).MassFlowRate = 1.7 * state->dataEnvrn->StdRhoAir; state->dataLoopNodes->Node(11) = state->dataLoopNodes->Node(10); state->dataLoopNodes->Node(12) = state->dataLoopNodes->Node(10); - state->dataEnvrn->OutBaroPress = 101325; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.allocate(3); oaRequirements.OAFlowMethod = OAFlowCalcMethod::PCDesOcc; @@ -1223,7 +1241,6 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) EXPECT_EQ("ProportionalControlBasedOnDesignOccupancy", DataSizing::OAFlowCalcMethodNames[static_cast(ventMechanical.VentMechZone(3).ZoneOAFlowMethod)]); - state->dataEnvrn->StdRhoAir = 1.2; oaController.MixMassFlow = 1.7 * state->dataEnvrn->StdRhoAir; oaController.MaxOAMassFlowRate = 1.7 * state->dataEnvrn->StdRhoAir; state->dataAirLoop->AirLoopFlow(1).DesSupply = 1.7 * state->dataEnvrn->StdRhoAir; @@ -1236,9 +1253,11 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataContaminantBalance->ZoneAirCO2(1) = 600.0; state->dataContaminantBalance->ZoneAirCO2(2) = 600.0; state->dataContaminantBalance->ZoneAirCO2(3) = 600.0; - Real64 expectedOAMassFlow = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + - oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants) * - state->dataEnvrn->StdRhoAir; + Real64 ZoneOA = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + + oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants); + Real64 ZoneOAFrac = ZoneOA / 1.7; + Real64 Evz = 1.0 - ZoneOAFrac; // SysEv == Evz + Real64 expectedOAMassFlow = ZoneOA * state->dataEnvrn->StdRhoAir / Evz; oaController.CalcOAController(*state, 1, true); // 3 identical zones should produce 3x OA flow EXPECT_NEAR(3 * expectedOAMassFlow, oaController.OAMassFlow, 0.00001); @@ -1248,7 +1267,10 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataContaminantBalance->ZoneAirCO2(1) = 200.0; state->dataContaminantBalance->ZoneAirCO2(2) = 200.0; state->dataContaminantBalance->ZoneAirCO2(3) = 200.0; - expectedOAMassFlow = oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea * state->dataEnvrn->StdRhoAir; + ZoneOA = oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea; + ZoneOAFrac = ZoneOA / 1.7; + Evz = 1.0 - ZoneOAFrac; + expectedOAMassFlow = ZoneOA * state->dataEnvrn->StdRhoAir / Evz; oaController.CalcOAController(*state, 1, true); // 3 identical zones should produce 3x OA flow EXPECT_NEAR(3 * expectedOAMassFlow, oaController.OAMassFlow, 0.00001); @@ -1258,9 +1280,11 @@ TEST_F(EnergyPlusFixture, CO2ControlDesignOccupancyTest3Zone) state->dataContaminantBalance->ZoneAirCO2(1) = zoneCO2Min + 0.3 * (zoneCO2Max - zoneCO2Min); state->dataContaminantBalance->ZoneAirCO2(2) = zoneCO2Min + 0.3 * (zoneCO2Max - zoneCO2Min); state->dataContaminantBalance->ZoneAirCO2(3) = zoneCO2Min + 0.3 * (zoneCO2Max - zoneCO2Min); - expectedOAMassFlow = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + - 0.3 * oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants) * - state->dataEnvrn->StdRhoAir; + ZoneOA = (oaRequirements.OAFlowPerArea * state->dataHeatBal->Zone(1).FloorArea + + 0.3 * oaRequirements.OAFlowPerPerson * state->dataHeatBal->Zone(1).TotOccupants); + ZoneOAFrac = ZoneOA / 1.7; + Evz = 1.0 - ZoneOAFrac; + expectedOAMassFlow = ZoneOA * state->dataEnvrn->StdRhoAir / Evz; oaController.CalcOAController(*state, 1, true); // 3 identical zones should produce 3x OA flow EXPECT_NEAR(3 * expectedOAMassFlow, oaController.OAMassFlow, 0.00001); diff --git a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc index feb753e7edc..7487dcafe92 100644 --- a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc @@ -4613,7 +4613,7 @@ TEST_F(EnergyPlusFixture, ZonePTHP_ElectricityRateTest) // set sizing parameters state->dataSize->SysSizingRunDone = true; state->dataSize->ZoneSizingRunDone = true; - state->dataGlobal->SysSizingCalc = true; + state->dataGlobal->SysSizingCalc = true; // disable sizing calculation state->dataZoneEnergyDemand->CurDeadBandOrSetback.allocate(1); state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; @@ -4654,6 +4654,10 @@ TEST_F(EnergyPlusFixture, ZonePTHP_ElectricityRateTest) auto &dxHtgCoilMain = state->dataDXCoils->DXCoil(2); auto &elecHtgCoilSupp = state->dataHeatingCoils->HeatingCoil(1); + // We disabled sizing calculation, so we must initialize these + dxClgCoilMain.RatedAirMassFlowRate(1) = dxClgCoilMain.RatedAirVolFlowRate(1) * state->dataEnvrn->StdRhoAir; + dxHtgCoilMain.RatedAirMassFlowRate(1) = dxHtgCoilMain.RatedAirVolFlowRate(1) * state->dataEnvrn->StdRhoAir; + state->dataGlobal->BeginEnvrnFlag = true; mySys->simulate(*state, thisSys.Name, diff --git a/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc b/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc index 589dd49cb73..ae91acad1de 100644 --- a/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc +++ b/tst/EnergyPlus/unit/RefrigeratedCase.unit.cc @@ -54,6 +54,7 @@ // I should not have to import these, but I do, the headers don't declare them #include +#include #include #include #include @@ -385,6 +386,7 @@ Schedule:Compact, ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects state->dataZoneEquip->ZoneEquipInputsFilled = true; + state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -479,6 +481,7 @@ Refrigeration:WalkIn, ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects state->dataZoneEquip->ZoneEquipInputsFilled = true; + state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -576,6 +579,7 @@ Refrigeration:WalkIn, ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects state->dataZoneEquip->ZoneEquipInputsFilled = true; + state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); @@ -733,6 +737,7 @@ Schedule:Compact, ASSERT_TRUE(process_idf(fmt::format("{}\n{}", oneZoneBuildingWithIdealLoads, idf_objects))); // read idf objects state->dataZoneEquip->ZoneEquipInputsFilled = true; + state->dataEnvrn->OutBaroPress = 101325.0; bool ErrorsFound = false; HeatBalanceManager::GetZoneData(*state, ErrorsFound); ASSERT_FALSE(ErrorsFound); diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index e3f3988895f..a3ac60850a3 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -1880,6 +1880,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonClippingDirect) SolarShading::SkyDifSolarShading(*state); state->dataSolarShading->CalcSkyDifShading = false; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(1) = 0.20531446332266728; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(2) = -0.84761109808931534; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(3) = 0.48928662105799514; + FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); int surfNum = Util::FindItemInList("ZN001:WALL-SOUTH:WIN001", state->dataSurface->Surface); EXPECT_NEAR(0.6504, state->dataSolarShading->SurfDifShdgRatioIsoSkyHRTS(4, 9, surfNum), 0.0001); @@ -4674,6 +4678,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) state->dataGlobal->BeginSimFlag = false; state->dataGlobal->BeginEnvrnFlag = false; HeatBalanceIntRadExchange::InitSolarViewFactors(*state); // prevents crash in GetDaylightingParametersInput + state->dataSolarShading->ShadowingDaysLeft = 20; SolarShading::PerformSolarCalculations(*state); // Get surface nums @@ -4697,6 +4702,11 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap2) shade2SchedEMSOn = true; shade1SchedEMSValue = 1.0; shade2SchedEMSValue = 1.0; + + // Gotten from running 1ZoneUncontrolled.idf with chicago weather on Jan 1 at 12 + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(1) = 0.20531446332266728; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(2) = -0.84761109808931534; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(3) = 0.48928662105799514; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -5035,6 +5045,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap3) state->dataGlobal->BeginSimFlag = false; state->dataGlobal->BeginEnvrnFlag = false; HeatBalanceIntRadExchange::InitSolarViewFactors(*state); // prevents crash in GetDaylightingParametersInput + state->dataSolarShading->ShadowingDaysLeft = 20; SolarShading::PerformSolarCalculations(*state); // Get surface nums @@ -5043,6 +5054,9 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap3) // Use the base transmittance schedules (no EMS override) // shade1 transmittance = 0.5, shade2 transmittance = 0.8 + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(1) = 0.20531446332266728; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(2) = -0.84761109808931534; + state->dataBSDFWindow->SUNCOSTS(state->dataGlobal->TimeStep, state->dataGlobal->HourOfDay)(3) = 0.48928662105799514; FigureSolarBeamAtTimestep(*state, state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep); ReportSurfaceShading(*state); @@ -5192,6 +5206,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcBeamSolarOnWinRevealSurface) surf2.SinTilt = 1.0; surf1.CosTilt = 0.0; surf2.CosTilt = 0.0; + surf1.Area = 2.0; + surf2.Area = 2.0; + state->dataSurface->SurfWinFrameArea(1) = 0.64; + state->dataSurface->SurfWinFrameArea(2) = 0.64; state->dataSurface->SurfActiveConstruction(1) = 1; state->dataSurface->SurfActiveConstruction(2) = 1; diff --git a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc index 42969011661..dcc74d48ce4 100644 --- a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc +++ b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc @@ -54,6 +54,7 @@ #include "Fixtures/EnergyPlusFixture.hh" #include #include +#include #include #include #include @@ -1046,6 +1047,7 @@ TEST_F(EnergyPlusFixture, HPWHSizing) ASSERT_FALSE(ErrorsFound); state->dataHVACGlobal->TimeStepSys = 1; state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + state->dataEnvrn->OutBaroPress = 101325; SetPredefinedTables(*state); state->dataZoneTempPredictorCorrector->zoneHeatBalance.allocate(1); diff --git a/tst/EnergyPlus/unit/WindowManager.unit.cc b/tst/EnergyPlus/unit/WindowManager.unit.cc index 03e131c0934..3dec455a767 100644 --- a/tst/EnergyPlus/unit/WindowManager.unit.cc +++ b/tst/EnergyPlus/unit/WindowManager.unit.cc @@ -480,12 +480,17 @@ TEST_F(EnergyPlusFixture, WindowManager_RefAirTempTest) state->dataGlobal->TimeStep = 1; state->dataGlobal->TimeStepZone = 1; + state->dataGlobal->TimeStepZoneSec = 3600.0; state->dataGlobal->HourOfDay = 1; state->dataGlobal->NumOfTimeStepInHour = 1; state->dataGlobal->BeginSimFlag = true; state->dataGlobal->BeginEnvrnFlag = true; state->dataEnvrn->OutBaroPress = 100000; + HeatBalanceManager::AllocateHeatBalArrays(*state); + SolarShading::AllocateModuleArrays(*state); + HeatBalanceSurfaceManager::AllocateSurfaceHeatBalArrays(*state); + state->dataZoneEquip->ZoneEquipConfig.allocate(1); state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "Zone"; state->dataHeatBal->Zone(1).IsControlled = true; @@ -535,7 +540,6 @@ TEST_F(EnergyPlusFixture, WindowManager_RefAirTempTest) state->dataLoopNodes->Node(3).MassFlowRate = 0.1; state->dataLoopNodes->Node(4).MassFlowRate = 0.1; - state->dataHeatBalSurf->SurfHConvInt.allocate(3); state->dataHeatBalSurf->SurfHConvInt(surfNum1) = 0.5; state->dataHeatBalSurf->SurfHConvInt(surfNum2) = 0.5; state->dataHeatBalSurf->SurfHConvInt(surfNum3) = 0.5; @@ -549,30 +553,6 @@ TEST_F(EnergyPlusFixture, WindowManager_RefAirTempTest) state->dataZoneTempPredictorCorrector->spaceHeatBalance(1).airHumRatAvg = 0.011; state->dataZoneTempPredictorCorrector->spaceHeatBalance(1).airHumRat = 0.011; - state->dataHeatBalSurf->SurfQdotRadHVACInPerArea.allocate(3); - state->dataHeatBalSurf->SurfWinInitialDifSolInTrans.allocate(3); - state->dataHeatBal->SurfWinQRadSWwinAbs.allocate(3, 1); - state->dataHeatBal->SurfQdotRadIntGainsInPerArea.allocate(3); - state->dataHeatBal->SurfQRadSWOutIncident.allocate(3); - state->dataSurface->SurfWinTransSolar.allocate(3); - state->dataHeatBal->ZoneWinHeatGain.allocate(1); - state->dataHeatBal->ZoneWinHeatGainRep.allocate(1); - state->dataHeatBal->ZoneWinHeatGainRepEnergy.allocate(1); - state->dataSurface->SurfWinHeatGain.allocate(3); - state->dataSurface->SurfWinGainConvGlazToZoneRep.allocate(3); - state->dataSurface->SurfWinGainIRGlazToZoneRep.allocate(3); - state->dataSurface->SurfWinGapConvHtFlowRep.allocate(3); - state->dataSurface->SurfWinGapConvHtFlowRepEnergy.allocate(3); - state->dataHeatBal->EnclSolQSWRad.allocate(1); - state->dataSurface->SurfWinLossSWZoneToOutWinRep.allocate(3); - state->dataSurface->SurfWinSysSolTransmittance.allocate(3); - state->dataSurface->SurfWinSysSolAbsorptance.allocate(3); - state->dataSurface->SurfWinSysSolReflectance.allocate(3); - state->dataSurface->SurfWinInsideGlassCondensationFlag.allocate(3); - state->dataSurface->SurfWinGainFrameDividerToZoneRep.allocate(3); - state->dataSurface->SurfWinInsideFrameCondensationFlag.allocate(3); - state->dataSurface->SurfWinInsideDividerCondensationFlag.allocate(3); - state->dataSurface->SurfTAirRef(surfNum1) = DataSurfaces::RefAirTemp::ZoneMeanAirTemp; state->dataSurface->SurfTAirRef(surfNum2) = DataSurfaces::RefAirTemp::ZoneSupplyAirTemp; state->dataSurface->SurfTAirRef(surfNum3) = DataSurfaces::RefAirTemp::AdjacentAirTemp; @@ -580,17 +560,6 @@ TEST_F(EnergyPlusFixture, WindowManager_RefAirTempTest) state->dataHeatBalSurf->SurfWinCoeffAdjRatio.allocate(3); state->dataHeatBalSurf->SurfWinCoeffAdjRatio(surfNum2) = 1.0; - state->dataHeatBalSurf->SurfQdotConvOutRep.allocate(3); - state->dataHeatBalSurf->SurfQdotConvOutPerArea.allocate(3); - state->dataHeatBalSurf->SurfQConvOutReport.allocate(3); - state->dataHeatBalSurf->SurfQdotRadOutRep.allocate(3); - state->dataHeatBalSurf->SurfQdotRadOutRepPerArea.allocate(3); - state->dataHeatBalSurf->SurfQRadOutReport.allocate(3); - state->dataHeatBalSurf->SurfQRadLWOutSrdSurfs.allocate(3); - state->dataHeatBalSurf->SurfQAirExtReport.allocate(3); - state->dataHeatBalSurf->SurfQHeatEmiReport.allocate(3); - state->dataHeatBalSurf->SurfWinInitialBeamSolInTrans.dimension(3, 0.0); - state->dataHeatBal->SurfQRadSWOutIncident = 0.0; state->dataHeatBal->SurfWinQRadSWwinAbs = 0.0; state->dataHeatBal->SurfQdotRadIntGainsInPerArea = 0.0; diff --git a/tst/EnergyPlus/unit/main.cc b/tst/EnergyPlus/unit/main.cc index 45d9421cf3b..b46336bf040 100644 --- a/tst/EnergyPlus/unit/main.cc +++ b/tst/EnergyPlus/unit/main.cc @@ -54,6 +54,10 @@ #include #endif +#ifdef DEBUG_ARITHM_MSVC +#include +#endif + // Google Test main int main(int argc, char **argv) { @@ -68,5 +72,17 @@ int main(int argc, char **argv) #ifdef DEBUG_ARITHM_GCC_OR_CLANG feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); #endif + +#ifdef DEBUG_ARITHM_MSVC + // Note: what you need to pass to the _controlfp_s is actually the opposite + // By default all bits are 1, and the exceptions are turned off, so you need to turn off the bits for the exceptions you want to enable + // > For the _MCW_EM mask, clearing it sets the exception, which allows the hardware exception; setting it hides the exception. + unsigned int fpcntrl = 0; + _controlfp_s(&fpcntrl, 0, 0); + unsigned int new_exceptions = _EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW; + unsigned int new_control = fpcntrl & ~new_exceptions; + _controlfp_s(&fpcntrl, new_control, _MCW_EM); +#endif + return RUN_ALL_TESTS(); }