From 04c32f09a76ce7566378de3919701bcf973e6d6e Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 3 May 2024 13:46:59 -0600 Subject: [PATCH 01/99] add extra bh object, which will break tests --- tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index 13b0fb47b1f..41bfab8e5f2 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -941,6 +941,12 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Given_Single_BHs_IDF_Ch " 5.5, !- X Location {m}", " 5.5; !- Y Location {m}", + "GroundHeatExchanger:Vertical:Single,", + " UNUSED, !- Name", + " GHE-1 Props, !- GHE Properties", + " 8.0, !- X Location {m}", + " 8.0; !- Y Location {m}", + "GroundHeatExchanger:System,", " Vertical GHE 1x4 Std, !- Name", " GHLE Inlet, !- Inlet Node Name", From dc12fc6989ea6eef65b8acc7ec5037c219891e1b Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 3 May 2024 14:02:45 -0600 Subject: [PATCH 02/99] fix bug and add to unit test --- src/EnergyPlus/GroundHeatExchangers.cc | 2 +- tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 7c86b973419..83ff9badca5 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -649,7 +649,7 @@ BuildAndGetResponseFactorsObjectFromSingleBHs(EnergyPlusData &state, std::vector // Make new props object which has the mean values of the other props objects referenced by the individual BH objects std::shared_ptr thisProps(new GLHEVertProps); thisProps->name = format("Response Factor Auto Generated Mean Props No: {}", state.dataGroundHeatExchanger->numAutoGeneratedResponseFactors + 1); - for (auto &thisBH : state.dataGroundHeatExchanger->singleBoreholesVector) { + for (auto &thisBH : singleBHsForRFVect) { thisProps->bhDiameter += thisBH->props->bhDiameter; thisProps->bhLength += thisBH->props->bhLength; thisProps->bhTopDepth += thisBH->props->bhTopDepth; diff --git a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index 41bfab8e5f2..7239f67cba4 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -969,7 +969,7 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Given_Single_BHs_IDF_Ch GetGroundHeatExchangerInput(*state); EXPECT_EQ(2u, state->dataGroundHeatExchanger->vertPropsVector.size()); - EXPECT_EQ(4u, state->dataGroundHeatExchanger->singleBoreholesVector.size()); + EXPECT_EQ(5u, state->dataGroundHeatExchanger->singleBoreholesVector.size()); EXPECT_EQ(1u, state->dataGroundHeatExchanger->verticalGLHE.size()); auto &thisGLHE(state->dataGroundHeatExchanger->verticalGLHE[0]); @@ -984,6 +984,7 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Given_Single_BHs_IDF_Ch EXPECT_EQ(100, thisGLHE.bhLength); EXPECT_EQ(0.04556, thisGLHE.bhUTubeDist); EXPECT_EQ(0, thisGLHE.myRespFactors->maxSimYears); + EXPECT_EQ(4, thisGLHE.myRespFactors->numBoreholes); EXPECT_EQ(400, thisGLHE.totalTubeLength); EXPECT_EQ(thisGLHE.soil.k / thisGLHE.soil.rhoCp, thisGLHE.soil.diffusivity); } From a81192b90fe004b997b37655d263af5111f959cd Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 6 Sep 2024 11:42:19 -0600 Subject: [PATCH 03/99] wip - removing array1ds [skip ci] --- src/EnergyPlus/GroundHeatExchangers.cc | 22 ++++++++-------------- src/EnergyPlus/GroundHeatExchangers.hh | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 83ff9badca5..75d1b794105 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -962,18 +962,12 @@ void GLHEVert::calcUniformBHWallTempGFunctions(EnergyPlusData &state) boreholes.emplace_back(bh->props->bhLength, bh->props->bhTopDepth, bh->props->bhDiameter / 2.0, bh->xLoc, bh->yLoc); } - // convert time to a std::vector from an Array1D - std::vector time; - for (auto &v : this->myRespFactors->time) { - time.push_back(v); - } - // Obtain number of segments by adaptive discretization gt::segments::adaptive adptDisc; int nSegments = adptDisc.discretize(this->bhLength, this->totalTubeLength); this->myRespFactors->GFNC = - gt::gfunction::uniform_borehole_wall_temperature(boreholes, time, this->soil.diffusivity, nSegments, true, state.dataGlobal->numThread); + gt::gfunction::uniform_borehole_wall_temperature(boreholes, this->myRespFactors->time, this->soil.diffusivity, nSegments, true, state.dataGlobal->numThread); } //****************************************************************************** @@ -989,7 +983,7 @@ void GLHEVert::calcGFunctions(EnergyPlusData &state) // save data for later if (state.files.outputControl.glhe && !state.dataSysVars->DisableGLHECaching) { - myCacheData["Response Factors"]["time"] = std::vector(this->myRespFactors->time.begin(), this->myRespFactors->time.end()); + myCacheData["Response Factors"]["time"] = std::vector(this->myRespFactors->time); myCacheData["Response Factors"]["LNTTS"] = std::vector(this->myRespFactors->LNTTS.begin(), this->myRespFactors->LNTTS.end()); myCacheData["Response Factors"]["GFNC"] = std::vector(this->myRespFactors->GFNC.begin(), this->myRespFactors->GFNC.end()); writeGLHECacheToFile(state); @@ -1026,13 +1020,13 @@ void GLHEVert::setupTimeVectors() } // Setup the arrays - this->myRespFactors->time.dimension(tempLNTTS.size(), 0.0); + // this->myRespFactors->time.dimension(tempLNTTS.size(), 0.0); this->myRespFactors->LNTTS.dimension(tempLNTTS.size(), 0.0); this->myRespFactors->GFNC.dimension(tempLNTTS.size(), 0.0); int index = 1; for (auto const &thisLNTTS : tempLNTTS) { - this->myRespFactors->time(index) = exp(thisLNTTS) * t_s; + this->myRespFactors->time.push_back(exp(thisLNTTS) * t_s); this->myRespFactors->LNTTS(index) = thisLNTTS; ++index; } @@ -1049,7 +1043,7 @@ void GLHEVert::calcUniformHeatFluxGFunctions(EnergyPlusData &state) for (auto const &bh_i : this->myRespFactors->myBorholes) { Real64 sum_T_ji = 0; for (auto const &bh_j : this->myRespFactors->myBorholes) { - sum_T_ji += doubleIntegral(bh_i, bh_j, this->myRespFactors->time(lntts_index)); + sum_T_ji += doubleIntegral(bh_i, bh_j, this->myRespFactors->time[lntts_index - 1]); } this->myRespFactors->GFNC(lntts_index) += sum_T_ji; } @@ -1381,11 +1375,11 @@ void GLHEVert::combineShortAndLongTimestepGFunctions() } // Move combined values into right data struct - this->myRespFactors->time.deallocate(); + // this->myRespFactors->time.deallocate(); this->myRespFactors->LNTTS.deallocate(); this->myRespFactors->GFNC.deallocate(); - this->myRespFactors->time.dimension(GFNC_combined.size(), 0.0); + // this->myRespFactors->time.dimension(GFNC_combined.size(), 0.0); this->myRespFactors->LNTTS.dimension(GFNC_combined.size(), 0.0); this->myRespFactors->GFNC.dimension(GFNC_combined.size(), 0.0); @@ -1460,7 +1454,7 @@ void GLHEVert::readCacheFileAndCompareWithThisGLHECache(EnergyPlusData &state) if (gFunctionsExist) { // Populate the time array - this->myRespFactors->time = Array1D(myCacheData["Response Factors"]["time"].get>()); + this->myRespFactors->time = std::vector(myCacheData["Response Factors"]["time"].get>()); // Populate the lntts array this->myRespFactors->LNTTS = Array1D(myCacheData["Response Factors"]["LNTTS"].get>()); diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index a8b5ff2db37..2cd964a89de 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -201,7 +201,7 @@ namespace GroundHeatExchangers { int numGFuncPairs; // Number of g-function pairs Real64 gRefRatio; // Reference ratio of g-function set Real64 maxSimYears; // Maximum length of simulation in years - Array1D time; // response time in seconds + std::vector time; // response time in seconds Array1D LNTTS; // natural log of Non Dimensional Time Ln(t/ts) Array1D GFNC; // G-function ( Non Dimensional temperature response factors) std::shared_ptr props; // Properties From d2d7af0b631fe70403fbfca1887cd31ab6a720ad Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 10 Sep 2024 10:43:09 -0600 Subject: [PATCH 04/99] fix time vector issues --- src/EnergyPlus/GroundHeatExchangers.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 75d1b794105..5ec4ab08c79 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -1020,7 +1020,6 @@ void GLHEVert::setupTimeVectors() } // Setup the arrays - // this->myRespFactors->time.dimension(tempLNTTS.size(), 0.0); this->myRespFactors->LNTTS.dimension(tempLNTTS.size(), 0.0); this->myRespFactors->GFNC.dimension(tempLNTTS.size(), 0.0); @@ -1374,17 +1373,16 @@ void GLHEVert::combineShortAndLongTimestepGFunctions() LNTTS_combined.push_back(this->myRespFactors->LNTTS(index_longTS)); } - // Move combined values into right data struct - // this->myRespFactors->time.deallocate(); + // Reset vectors for final usage + this->myRespFactors->time = std::vector(); this->myRespFactors->LNTTS.deallocate(); this->myRespFactors->GFNC.deallocate(); - // this->myRespFactors->time.dimension(GFNC_combined.size(), 0.0); this->myRespFactors->LNTTS.dimension(GFNC_combined.size(), 0.0); this->myRespFactors->GFNC.dimension(GFNC_combined.size(), 0.0); for (unsigned int index = 0; index < GFNC_combined.size(); ++index) { - this->myRespFactors->time[index] = exp(LNTTS_combined[index]) * t_s; + this->myRespFactors->time.push_back(exp(LNTTS_combined[index]) * t_s); this->myRespFactors->LNTTS[index] = LNTTS_combined[index]; this->myRespFactors->GFNC[index] = GFNC_combined[index]; } From ec794a7ec9e3f1a2f1161e5f4ffcc1223b34faec Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 10 Sep 2024 12:32:04 -0600 Subject: [PATCH 05/99] wip - removing vectors --- src/EnergyPlus/GroundHeatExchangers.cc | 31 +++++++++---------- src/EnergyPlus/GroundHeatExchangers.hh | 4 +-- .../unit/GroundHeatExchangers.unit.cc | 25 ++++++--------- 3 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 5ec4ab08c79..24245bff1d7 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -47,6 +47,7 @@ // C++ Headers #include +#include #include // ObjexxFCL Headers @@ -487,11 +488,10 @@ GLHEResponseFactors::GLHEResponseFactors(EnergyPlusData &state, std::string cons } this->numGFuncPairs = static_cast(tmpLntts.size()); - this->LNTTS.dimension(this->numGFuncPairs, 0.0); this->GFNC.dimension(this->numGFuncPairs, 0.0); for (int i = 1; i <= (int)tmpLntts.size(); ++i) { - this->LNTTS(i) = tmpLntts[i - 1]; + this->LNTTS.push_back(tmpLntts[i - 1]); this->GFNC(i) = tmpGvals[i - 1]; } } @@ -984,7 +984,7 @@ void GLHEVert::calcGFunctions(EnergyPlusData &state) // save data for later if (state.files.outputControl.glhe && !state.dataSysVars->DisableGLHECaching) { myCacheData["Response Factors"]["time"] = std::vector(this->myRespFactors->time); - myCacheData["Response Factors"]["LNTTS"] = std::vector(this->myRespFactors->LNTTS.begin(), this->myRespFactors->LNTTS.end()); + myCacheData["Response Factors"]["LNTTS"] = std::vector(this->myRespFactors->LNTTS); myCacheData["Response Factors"]["GFNC"] = std::vector(this->myRespFactors->GFNC.begin(), this->myRespFactors->GFNC.end()); writeGLHECacheToFile(state); } @@ -1020,13 +1020,12 @@ void GLHEVert::setupTimeVectors() } // Setup the arrays - this->myRespFactors->LNTTS.dimension(tempLNTTS.size(), 0.0); this->myRespFactors->GFNC.dimension(tempLNTTS.size(), 0.0); int index = 1; for (auto const &thisLNTTS : tempLNTTS) { this->myRespFactors->time.push_back(exp(thisLNTTS) * t_s); - this->myRespFactors->LNTTS(index) = thisLNTTS; + this->myRespFactors->LNTTS.push_back(thisLNTTS); ++index; } } @@ -1038,15 +1037,15 @@ void GLHEVert::calcUniformHeatFluxGFunctions(EnergyPlusData &state) DisplayString(state, "Initializing GroundHeatExchanger:System: " + this->name); // Calculate the g-functions - for (size_t lntts_index = 1; lntts_index <= this->myRespFactors->LNTTS.size(); ++lntts_index) { + for (size_t lntts_index = 0; lntts_index < this->myRespFactors->LNTTS.size(); ++lntts_index) { for (auto const &bh_i : this->myRespFactors->myBorholes) { Real64 sum_T_ji = 0; for (auto const &bh_j : this->myRespFactors->myBorholes) { - sum_T_ji += doubleIntegral(bh_i, bh_j, this->myRespFactors->time[lntts_index - 1]); + sum_T_ji += doubleIntegral(bh_i, bh_j, this->myRespFactors->time[lntts_index]); } - this->myRespFactors->GFNC(lntts_index) += sum_T_ji; + this->myRespFactors->GFNC[lntts_index] += sum_T_ji; } - this->myRespFactors->GFNC(lntts_index) /= (2 * this->totalTubeLength); + this->myRespFactors->GFNC[lntts_index] /= (2 * this->totalTubeLength); std::stringstream ss; ss << std::fixed << std::setprecision(1) << float(lntts_index) / this->myRespFactors->LNTTS.size() * 100; @@ -1370,20 +1369,19 @@ void GLHEVert::combineShortAndLongTimestepGFunctions() // Add the rest of the long time-step g-functions to the combined curve for (int index_longTS = this->myRespFactors->GFNC.l(); index_longTS <= this->myRespFactors->GFNC.u(); ++index_longTS) { GFNC_combined.push_back(this->myRespFactors->GFNC(index_longTS)); - LNTTS_combined.push_back(this->myRespFactors->LNTTS(index_longTS)); + LNTTS_combined.push_back(this->myRespFactors->LNTTS[index_longTS]); } // Reset vectors for final usage this->myRespFactors->time = std::vector(); - this->myRespFactors->LNTTS.deallocate(); + this->myRespFactors->LNTTS = std::vector(); this->myRespFactors->GFNC.deallocate(); - this->myRespFactors->LNTTS.dimension(GFNC_combined.size(), 0.0); this->myRespFactors->GFNC.dimension(GFNC_combined.size(), 0.0); for (unsigned int index = 0; index < GFNC_combined.size(); ++index) { this->myRespFactors->time.push_back(exp(LNTTS_combined[index]) * t_s); - this->myRespFactors->LNTTS[index] = LNTTS_combined[index]; + this->myRespFactors->LNTTS.push_back(LNTTS_combined[index]); this->myRespFactors->GFNC[index] = GFNC_combined[index]; } } @@ -1455,7 +1453,7 @@ void GLHEVert::readCacheFileAndCompareWithThisGLHECache(EnergyPlusData &state) this->myRespFactors->time = std::vector(myCacheData["Response Factors"]["time"].get>()); // Populate the lntts array - this->myRespFactors->LNTTS = Array1D(myCacheData["Response Factors"]["LNTTS"].get>()); + this->myRespFactors->LNTTS = std::vector(myCacheData["Response Factors"]["LNTTS"].get>()); // Populate the g-function array this->myRespFactors->GFNC = Array1D(myCacheData["Response Factors"]["GFNC"].get>()); @@ -1515,7 +1513,7 @@ void GLHESlinky::calcGFunctions(EnergyPlusData &state) // Allocate and setup g-function arrays this->myRespFactors->GFNC.allocate(NPairs); - this->myRespFactors->LNTTS.allocate(NPairs); + this->myRespFactors->LNTTS = std::vector (NPairs, 0.0); this->QnMonthlyAgg.allocate(static_cast(this->maxSimYears * 12)); this->QnHr.allocate(730 + this->AGG + this->SubAGG); this->QnSubHr.allocate(static_cast((this->SubAGG + 1) * maxTSinHr + 1)); @@ -1523,7 +1521,6 @@ void GLHESlinky::calcGFunctions(EnergyPlusData &state) for (int i = 1; i <= NPairs; ++i) { this->myRespFactors->GFNC(i) = 0.0; - this->myRespFactors->LNTTS(i) = 0.0; } // Calculate the number of loops (per trench) and number of trenches to be involved @@ -1645,7 +1642,7 @@ void GLHESlinky::calcGFunctions(EnergyPlusData &state) } // m1 this->myRespFactors->GFNC(NT) = (gFunc * (this->coilDiameter / 2.0)) / (4 * Constant::Pi * fraction * this->numTrenches * this->numCoils); - this->myRespFactors->LNTTS(NT) = tLg; + this->myRespFactors->LNTTS[NT - 1] = tLg; } // NT time } diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index 2cd964a89de..11c66b24bfa 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -201,8 +201,8 @@ namespace GroundHeatExchangers { int numGFuncPairs; // Number of g-function pairs Real64 gRefRatio; // Reference ratio of g-function set Real64 maxSimYears; // Maximum length of simulation in years - std::vector time; // response time in seconds - Array1D LNTTS; // natural log of Non Dimensional Time Ln(t/ts) + std::vector time; // response time in seconds + std::vector LNTTS; // natural log of Non Dimensional Time Ln(t/ts) Array1D GFNC; // G-function ( Non Dimensional temperature response factors) std::shared_ptr props; // Properties std::vector> myBorholes; // Boreholes used by this response factors object diff --git a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index 76922555e80..29927fc76af 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -87,11 +87,10 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_Interpolate) std::shared_ptr thisRF(new GLHEResponseFactors); thisGLHE.myRespFactors = thisRF; - thisGLHE.myRespFactors->LNTTS.allocate(NPairs); thisGLHE.myRespFactors->GFNC.allocate(NPairs); - thisGLHE.myRespFactors->LNTTS(1) = 0.0; - thisGLHE.myRespFactors->LNTTS(2) = 5.0; + thisGLHE.myRespFactors->LNTTS.push_back(0.0); + thisGLHE.myRespFactors->LNTTS.push_back(5.0); thisGLHE.myRespFactors->GFNC(1) = 0.0; thisGLHE.myRespFactors->GFNC(2) = 5.0; @@ -124,11 +123,10 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_Slinky_GetGFunc) std::shared_ptr thisRF(new GLHEResponseFactors); thisGLHE.myRespFactors = thisRF; - thisGLHE.myRespFactors->LNTTS.allocate(NPairs); thisGLHE.myRespFactors->GFNC.allocate(NPairs); - thisGLHE.myRespFactors->LNTTS(1) = 0.0; - thisGLHE.myRespFactors->LNTTS(2) = 5.0; + thisGLHE.myRespFactors->LNTTS.push_back(0.0); + thisGLHE.myRespFactors->LNTTS.push_back(5.0); thisGLHE.myRespFactors->GFNC(1) = 0.0; thisGLHE.myRespFactors->GFNC(2) = 5.0; @@ -152,11 +150,10 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_GetGFunc) std::shared_ptr thisRF(new GLHEResponseFactors); thisGLHE.myRespFactors = thisRF; - thisGLHE.myRespFactors->LNTTS.allocate(NPairs); thisGLHE.myRespFactors->GFNC.allocate(NPairs); - thisGLHE.myRespFactors->LNTTS(1) = 0.0; - thisGLHE.myRespFactors->LNTTS(2) = 5.0; + thisGLHE.myRespFactors->LNTTS.push_back(0.0); + thisGLHE.myRespFactors->LNTTS.push_back(5.0); thisGLHE.myRespFactors->GFNC(1) = 0.0; thisGLHE.myRespFactors->GFNC(2) = 5.0; @@ -528,9 +525,9 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Resp_Factors_IDF_Check) EXPECT_EQ(4, thisRF->numBoreholes); EXPECT_EQ(0.00043, thisRF->gRefRatio); EXPECT_EQ(76, thisRF->numGFuncPairs); - EXPECT_EQ(-15.585075, thisRF->LNTTS(1)); + EXPECT_EQ(-15.585075, thisRF->LNTTS[0]); EXPECT_EQ(-2.672011, thisRF->GFNC(1)); - EXPECT_EQ(3.003000, thisRF->LNTTS(76)); + EXPECT_EQ(3.003000, thisRF->LNTTS[75]); EXPECT_EQ(12.778359, thisRF->GFNC(76)); } @@ -1347,9 +1344,8 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcGFunction_UHF) TEST_F(EnergyPlusFixture, GHE_InterpTest1) { std::shared_ptr thisRF(new GroundHeatExchangers::GLHEResponseFactors()); - thisRF->LNTTS.allocate(11); thisRF->GFNC.allocate(11); - thisRF->LNTTS = {-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + thisRF->LNTTS = std::vector {-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; thisRF->GFNC = {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; GroundHeatExchangers::GLHEVert thisGHE = GroundHeatExchangers::GLHEVert(); @@ -1402,9 +1398,8 @@ TEST_F(EnergyPlusFixture, GHE_InterpTest1) TEST_F(EnergyPlusFixture, GHE_InterpTest2) { std::shared_ptr thisRF(new GroundHeatExchangers::GLHEResponseFactors()); - thisRF->LNTTS.allocate(8); thisRF->GFNC.allocate(8); - thisRF->LNTTS = {-15.2202, -15.083, -14.9459, -14.8087, -14.6716, -14.5344, -14.3973, -14.2601}; + thisRF->LNTTS = std::vector {-15.2202, -15.083, -14.9459, -14.8087, -14.6716, -14.5344, -14.3973, -14.2601}; thisRF->GFNC = {-2.55692, -2.48389, -2.40819, -2.32936, -2.24715, -2.16138, -2.07195, -1.97882}; GroundHeatExchangers::GLHEVert thisGHE = GroundHeatExchangers::GLHEVert(); From b55ac29716cffa8f11c1b761033b9ebc3606e3f5 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Wed, 11 Sep 2024 14:05:38 -0500 Subject: [PATCH 06/99] Clang format --- src/EnergyPlus/GroundHeatExchangers.cc | 6 +++--- tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 24245bff1d7..0dc25701ce7 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -966,8 +966,8 @@ void GLHEVert::calcUniformBHWallTempGFunctions(EnergyPlusData &state) gt::segments::adaptive adptDisc; int nSegments = adptDisc.discretize(this->bhLength, this->totalTubeLength); - this->myRespFactors->GFNC = - gt::gfunction::uniform_borehole_wall_temperature(boreholes, this->myRespFactors->time, this->soil.diffusivity, nSegments, true, state.dataGlobal->numThread); + this->myRespFactors->GFNC = gt::gfunction::uniform_borehole_wall_temperature( + boreholes, this->myRespFactors->time, this->soil.diffusivity, nSegments, true, state.dataGlobal->numThread); } //****************************************************************************** @@ -1513,7 +1513,7 @@ void GLHESlinky::calcGFunctions(EnergyPlusData &state) // Allocate and setup g-function arrays this->myRespFactors->GFNC.allocate(NPairs); - this->myRespFactors->LNTTS = std::vector (NPairs, 0.0); + this->myRespFactors->LNTTS = std::vector(NPairs, 0.0); this->QnMonthlyAgg.allocate(static_cast(this->maxSimYears * 12)); this->QnHr.allocate(730 + this->AGG + this->SubAGG); this->QnSubHr.allocate(static_cast((this->SubAGG + 1) * maxTSinHr + 1)); diff --git a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index 29927fc76af..8ffd5b58797 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -1345,7 +1345,7 @@ TEST_F(EnergyPlusFixture, GHE_InterpTest1) { std::shared_ptr thisRF(new GroundHeatExchangers::GLHEResponseFactors()); thisRF->GFNC.allocate(11); - thisRF->LNTTS = std::vector {-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + thisRF->LNTTS = std::vector{-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; thisRF->GFNC = {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; GroundHeatExchangers::GLHEVert thisGHE = GroundHeatExchangers::GLHEVert(); @@ -1399,7 +1399,7 @@ TEST_F(EnergyPlusFixture, GHE_InterpTest2) { std::shared_ptr thisRF(new GroundHeatExchangers::GLHEResponseFactors()); thisRF->GFNC.allocate(8); - thisRF->LNTTS = std::vector {-15.2202, -15.083, -14.9459, -14.8087, -14.6716, -14.5344, -14.3973, -14.2601}; + thisRF->LNTTS = std::vector{-15.2202, -15.083, -14.9459, -14.8087, -14.6716, -14.5344, -14.3973, -14.2601}; thisRF->GFNC = {-2.55692, -2.48389, -2.40819, -2.32936, -2.24715, -2.16138, -2.07195, -1.97882}; GroundHeatExchangers::GLHEVert thisGHE = GroundHeatExchangers::GLHEVert(); From 3273f969ece0af6a1e50e89b7793d96ac079b527 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Wed, 11 Sep 2024 14:19:54 -0500 Subject: [PATCH 07/99] fix array index issue --- src/EnergyPlus/GroundHeatExchangers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 0dc25701ce7..ee32538bcf1 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -1369,7 +1369,7 @@ void GLHEVert::combineShortAndLongTimestepGFunctions() // Add the rest of the long time-step g-functions to the combined curve for (int index_longTS = this->myRespFactors->GFNC.l(); index_longTS <= this->myRespFactors->GFNC.u(); ++index_longTS) { GFNC_combined.push_back(this->myRespFactors->GFNC(index_longTS)); - LNTTS_combined.push_back(this->myRespFactors->LNTTS[index_longTS]); + LNTTS_combined.push_back(this->myRespFactors->LNTTS[index_longTS - 1]); } // Reset vectors for final usage From 7712f73a57288a55b1ec8d18e39e9898470d5e10 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Thu, 12 Sep 2024 08:42:18 -0600 Subject: [PATCH 08/99] more array to vect conversions --- src/EnergyPlus/GroundHeatExchangers.cc | 45 +++++++------------ src/EnergyPlus/GroundHeatExchangers.hh | 4 +- .../unit/GroundHeatExchangers.unit.cc | 30 ++++++------- 3 files changed, 32 insertions(+), 47 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index ee32538bcf1..83a2760c7a8 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -488,11 +488,10 @@ GLHEResponseFactors::GLHEResponseFactors(EnergyPlusData &state, std::string cons } this->numGFuncPairs = static_cast(tmpLntts.size()); - this->GFNC.dimension(this->numGFuncPairs, 0.0); for (int i = 1; i <= (int)tmpLntts.size(); ++i) { this->LNTTS.push_back(tmpLntts[i - 1]); - this->GFNC(i) = tmpGvals[i - 1]; + this->GFNC.push_back(tmpGvals[i - 1]); } } @@ -1019,15 +1018,11 @@ void GLHEVert::setupTimeVectors() } } - // Setup the arrays - this->myRespFactors->GFNC.dimension(tempLNTTS.size(), 0.0); + this->myRespFactors->LNTTS = tempLNTTS; + this->myRespFactors->time = tempLNTTS; + std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c){return exp(c) * t_s;}); + this->myRespFactors->GFNC = std::vector(tempLNTTS.size(), 0.0); - int index = 1; - for (auto const &thisLNTTS : tempLNTTS) { - this->myRespFactors->time.push_back(exp(thisLNTTS) * t_s); - this->myRespFactors->LNTTS.push_back(thisLNTTS); - ++index; - } } //****************************************************************************** @@ -1367,23 +1362,17 @@ void GLHEVert::combineShortAndLongTimestepGFunctions() } // Add the rest of the long time-step g-functions to the combined curve - for (int index_longTS = this->myRespFactors->GFNC.l(); index_longTS <= this->myRespFactors->GFNC.u(); ++index_longTS) { - GFNC_combined.push_back(this->myRespFactors->GFNC(index_longTS)); - LNTTS_combined.push_back(this->myRespFactors->LNTTS[index_longTS - 1]); + for (int index_longTS = 0; index_longTS < this->myRespFactors->GFNC.size(); ++index_longTS) { + GFNC_combined.push_back(this->myRespFactors->GFNC[index_longTS]); + LNTTS_combined.push_back(this->myRespFactors->LNTTS[index_longTS]); } - // Reset vectors for final usage - this->myRespFactors->time = std::vector(); - this->myRespFactors->LNTTS = std::vector(); - this->myRespFactors->GFNC.deallocate(); + this->myRespFactors->time = LNTTS_combined; + std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c){return exp(c) * t_s;}); - this->myRespFactors->GFNC.dimension(GFNC_combined.size(), 0.0); + this->myRespFactors->LNTTS = LNTTS_combined; + this->myRespFactors->GFNC = GFNC_combined; - for (unsigned int index = 0; index < GFNC_combined.size(); ++index) { - this->myRespFactors->time.push_back(exp(LNTTS_combined[index]) * t_s); - this->myRespFactors->LNTTS.push_back(LNTTS_combined[index]); - this->myRespFactors->GFNC[index] = GFNC_combined[index]; - } } void GLHEBase::makeThisGLHECacheAndCompareWithFileCache(EnergyPlusData &state) @@ -1456,7 +1445,7 @@ void GLHEVert::readCacheFileAndCompareWithThisGLHECache(EnergyPlusData &state) this->myRespFactors->LNTTS = std::vector(myCacheData["Response Factors"]["LNTTS"].get>()); // Populate the g-function array - this->myRespFactors->GFNC = Array1D(myCacheData["Response Factors"]["GFNC"].get>()); + this->myRespFactors->GFNC = std::vector(myCacheData["Response Factors"]["GFNC"].get>()); } } @@ -1512,17 +1501,13 @@ void GLHESlinky::calcGFunctions(EnergyPlusData &state) int NPairs = static_cast((tLg_max - tLg_min) / (tLg_grid) + 1); // Allocate and setup g-function arrays - this->myRespFactors->GFNC.allocate(NPairs); + this->myRespFactors->GFNC = std::vector(NPairs, 0.0); this->myRespFactors->LNTTS = std::vector(NPairs, 0.0); this->QnMonthlyAgg.allocate(static_cast(this->maxSimYears * 12)); this->QnHr.allocate(730 + this->AGG + this->SubAGG); this->QnSubHr.allocate(static_cast((this->SubAGG + 1) * maxTSinHr + 1)); this->LastHourN.allocate(this->SubAGG + 1); - for (int i = 1; i <= NPairs; ++i) { - this->myRespFactors->GFNC(i) = 0.0; - } - // Calculate the number of loops (per trench) and number of trenches to be involved // Due to the symmetry of a slinky GHX field, we need only calculate about // on quarter of the rings' tube wall temperature perturbation to get the @@ -1641,7 +1626,7 @@ void GLHESlinky::calcGFunctions(EnergyPlusData &state) } // n1 } // m1 - this->myRespFactors->GFNC(NT) = (gFunc * (this->coilDiameter / 2.0)) / (4 * Constant::Pi * fraction * this->numTrenches * this->numCoils); + this->myRespFactors->GFNC[NT - 1] = (gFunc * (this->coilDiameter / 2.0)) / (4 * Constant::Pi * fraction * this->numTrenches * this->numCoils); this->myRespFactors->LNTTS[NT - 1] = tLg; } // NT time diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index 11c66b24bfa..45a09e150ec 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -202,8 +202,8 @@ namespace GroundHeatExchangers { Real64 gRefRatio; // Reference ratio of g-function set Real64 maxSimYears; // Maximum length of simulation in years std::vector time; // response time in seconds - std::vector LNTTS; // natural log of Non Dimensional Time Ln(t/ts) - Array1D GFNC; // G-function ( Non Dimensional temperature response factors) + std::vector LNTTS; // natural log of non-dimensional time Ln(t/ts) + std::vector GFNC; // g-function (non-dimensional temperature response factors) std::shared_ptr props; // Properties std::vector> myBorholes; // Boreholes used by this response factors object diff --git a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index 8ffd5b58797..8d9e0cc6ba5 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -87,12 +87,12 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_Interpolate) std::shared_ptr thisRF(new GLHEResponseFactors); thisGLHE.myRespFactors = thisRF; - thisGLHE.myRespFactors->GFNC.allocate(NPairs); + thisGLHE.myRespFactors->GFNC = std::vector(NPairs); thisGLHE.myRespFactors->LNTTS.push_back(0.0); thisGLHE.myRespFactors->LNTTS.push_back(5.0); - thisGLHE.myRespFactors->GFNC(1) = 0.0; - thisGLHE.myRespFactors->GFNC(2) = 5.0; + thisGLHE.myRespFactors->GFNC[0] = 0.0; + thisGLHE.myRespFactors->GFNC[1] = 5.0; // Case when extrapolating beyond lower bound thisLNTTS = -1.0; @@ -123,12 +123,12 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_Slinky_GetGFunc) std::shared_ptr thisRF(new GLHEResponseFactors); thisGLHE.myRespFactors = thisRF; - thisGLHE.myRespFactors->GFNC.allocate(NPairs); + thisGLHE.myRespFactors->GFNC = std::vector(NPairs); thisGLHE.myRespFactors->LNTTS.push_back(0.0); thisGLHE.myRespFactors->LNTTS.push_back(5.0); - thisGLHE.myRespFactors->GFNC(1) = 0.0; - thisGLHE.myRespFactors->GFNC(2) = 5.0; + thisGLHE.myRespFactors->GFNC[0] = 0.0; + thisGLHE.myRespFactors->GFNC[1] = 5.0; time = std::pow(10.0, 2.5); @@ -150,12 +150,12 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_GetGFunc) std::shared_ptr thisRF(new GLHEResponseFactors); thisGLHE.myRespFactors = thisRF; - thisGLHE.myRespFactors->GFNC.allocate(NPairs); + thisGLHE.myRespFactors->GFNC = std::vector(NPairs); thisGLHE.myRespFactors->LNTTS.push_back(0.0); thisGLHE.myRespFactors->LNTTS.push_back(5.0); - thisGLHE.myRespFactors->GFNC(1) = 0.0; - thisGLHE.myRespFactors->GFNC(2) = 5.0; + thisGLHE.myRespFactors->GFNC[0] = 0.0; + thisGLHE.myRespFactors->GFNC[1] = 5.0; time = std::pow(2.7182818284590452353602874, 2.5); @@ -233,12 +233,12 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_Slinky_CalcGroundHeatExchanger // Horizontal G-Functions thisGLHE.calcGFunctions(*state); - EXPECT_NEAR(19.08237, thisGLHE.myRespFactors->GFNC(28), 0.0001); + EXPECT_NEAR(19.08237, thisGLHE.myRespFactors->GFNC[27], 0.0001); // Vertical G-Functions thisGLHE.verticalConfig = true; thisGLHE.calcGFunctions(*state); - EXPECT_NEAR(18.91819, thisGLHE.myRespFactors->GFNC(28), 0.0001); + EXPECT_NEAR(18.91819, thisGLHE.myRespFactors->GFNC[27], 0.0001); } TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Properties_IDF_Check) @@ -526,9 +526,9 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Resp_Factors_IDF_Check) EXPECT_EQ(0.00043, thisRF->gRefRatio); EXPECT_EQ(76, thisRF->numGFuncPairs); EXPECT_EQ(-15.585075, thisRF->LNTTS[0]); - EXPECT_EQ(-2.672011, thisRF->GFNC(1)); + EXPECT_EQ(-2.672011, thisRF->GFNC[0]); EXPECT_EQ(3.003000, thisRF->LNTTS[75]); - EXPECT_EQ(12.778359, thisRF->GFNC(76)); + EXPECT_EQ(12.778359, thisRF->GFNC[75]); } TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Resp_Factors_Mismatched_Pairs) @@ -1344,7 +1344,7 @@ TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_calcGFunction_UHF) TEST_F(EnergyPlusFixture, GHE_InterpTest1) { std::shared_ptr thisRF(new GroundHeatExchangers::GLHEResponseFactors()); - thisRF->GFNC.allocate(11); + thisRF->GFNC = std::vector(11); thisRF->LNTTS = std::vector{-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; thisRF->GFNC = {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; @@ -1398,7 +1398,7 @@ TEST_F(EnergyPlusFixture, GHE_InterpTest1) TEST_F(EnergyPlusFixture, GHE_InterpTest2) { std::shared_ptr thisRF(new GroundHeatExchangers::GLHEResponseFactors()); - thisRF->GFNC.allocate(8); + thisRF->GFNC = std::vector(8); thisRF->LNTTS = std::vector{-15.2202, -15.083, -14.9459, -14.8087, -14.6716, -14.5344, -14.3973, -14.2601}; thisRF->GFNC = {-2.55692, -2.48389, -2.40819, -2.32936, -2.24715, -2.16138, -2.07195, -1.97882}; From 0469cee31ab06b84e1314f5eb94f579d4344e0e8 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 13 Sep 2024 09:35:21 -0600 Subject: [PATCH 09/99] more array to vect conversions --- src/EnergyPlus/GroundHeatExchangers.cc | 27 +++++++++++--------------- src/EnergyPlus/GroundHeatExchangers.hh | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 83a2760c7a8..a192fe2da68 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -1808,7 +1808,7 @@ inline bool GLHEBase::isEven(int const val) //****************************************************************************** -Real64 GLHESlinky::integral(int const m, int const n, int const m1, int const n1, Real64 const t, Real64 const eta, Real64 const J0) +Real64 GLHESlinky::integral(int const m, int const n, int const m1, int const n1, Real64 const t, Real64 const eta, int const J0) { // SUBROUTINE INFORMATION: // AUTHOR: Matt Mitchell @@ -1838,7 +1838,6 @@ Real64 GLHESlinky::integral(int const m, int const n, int const m1, int const n1 f(j) = nearFieldResponseFunction(m, n, m1, n1, eta, theta, t); if (j == 1 || j == J0) { - f(j) = f(j); } else if (isEven(j)) { f(j) = 4 * f(j); } else { @@ -1870,29 +1869,25 @@ Real64 GLHESlinky::doubleIntegral(int const m, int const n, int const m1, int co constexpr Real64 eta1 = 0.0; constexpr Real64 eta2 = 2 * Constant::Pi; - Real64 sumIntF = 0.0; - Array1D g(I0, 0.0); + std::vector g; Real64 h = (eta2 - eta1) / (I0 - 1); // Calculates the value of the function at various equally spaced values - for (int i = 1; i <= I0; ++i) { - - Real64 eta = eta1 + (i - 1) * h; - g(i) = integral(m, n, m1, n1, t, eta, J0); + for (int i = 0; i < I0; ++i) { + Real64 eta = eta1 + i * h; + g.push_back(integral(m, n, m1, n1, t, eta, J0)); + } - if (i == 1 || i == I0) { - g(i) = g(i); - } else if (isEven(i)) { - g(i) = 4 * g(i); + for (int i = 1; i < g.size() - 1; ++i) { + if (!isEven(i)) { + g[i] = 4 * g[i]; } else { - g(i) = 2 * g(i); + g[i] = 2 * g[i]; } - - sumIntF += g(i); } - return (h / 3) * sumIntF; + return (h / 3) * std::reduce(g.begin(), g.end()); } //****************************************************************************** diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index 45a09e150ec..eab0389fef9 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -454,7 +454,7 @@ namespace GroundHeatExchangers { Real64 doubleIntegral(int m, int n, int m1, int n1, Real64 t, int I0, int J0); - Real64 integral(int m, int n, int m1, int n1, Real64 t, Real64 eta, Real64 J0); + Real64 integral(int m, int n, int m1, int n1, Real64 t, Real64 eta, int J0); Real64 distance(int m, int n, int m1, int n1, Real64 eta, Real64 theta); From f73581d41099e3b44fa72bf2a07db01f36641959 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 13 Sep 2024 09:55:02 -0600 Subject: [PATCH 10/99] more array to vect conversions --- src/EnergyPlus/GroundHeatExchangers.cc | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index a192fe2da68..42010f5bb8d 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -1822,32 +1822,28 @@ Real64 GLHESlinky::integral(int const m, int const n, int const m1, int const n1 // Simpson's 1/3 rule of integration // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 sumIntF = 0.0; Real64 theta = 0.0; constexpr Real64 theta1 = 0.0; constexpr Real64 theta2 = 2 * Constant::Pi; - Array1D f(J0, 0.0); + std::vector f; Real64 h = (theta2 - theta1) / (J0 - 1); // Calculate the function at various equally spaced x values - for (int j = 1; j <= J0; ++j) { - - theta = theta1 + (j - 1) * h; - - f(j) = nearFieldResponseFunction(m, n, m1, n1, eta, theta, t); + for (int j = 0; j < J0; ++j) { + theta = theta1 + j * h; + f.push_back(nearFieldResponseFunction(m, n, m1, n1, eta, theta, t)); + } - if (j == 1 || j == J0) { - } else if (isEven(j)) { - f(j) = 4 * f(j); + for (int j = 1; j < J0 - 1; ++j) { + if (!isEven(j)) { + f[j] = 4 * f[j]; } else { - f(j) = 2 * f(j); + f[j] = 2 * f[j]; } - - sumIntF += f(j); } - return (h / 3) * sumIntF; + return (h / 3) * std::reduce(f.begin(), f.end()); } //****************************************************************************** From 3da596a1fc94bb73f53a3e8030a3d739a8b728b6 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 21:02:54 -0400 Subject: [PATCH 11/99] shadow --- src/EnergyPlus/OutputProcessor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 926a1d947b1..75033c16201 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -747,7 +747,7 @@ namespace OutputProcessor { } std::string meterOrVarNameUC = Util::makeUPPER(ipsc->cAlphaArgs(fldIndex + 1)); - std::string::size_type lbrackPos = index(meterOrVarNameUC, '['); + lbrackPos = index(meterOrVarNameUC, '['); if (lbrackPos != std::string::npos) meterOrVarNameUC.erase(lbrackPos); // A custom meter cannot reference another custom meter @@ -916,7 +916,7 @@ namespace OutputProcessor { for (int fldIndex = 3; fldIndex <= NumAlpha; fldIndex += 2) { // No need to check for empty fields std::string meterOrVarNameUC = Util::makeUPPER(ipsc->cAlphaArgs(fldIndex + 1)); - std::string::size_type lbrackPos = index(meterOrVarNameUC, '['); + lbrackPos = index(meterOrVarNameUC, '['); if (lbrackPos != std::string::npos) meterOrVarNameUC.erase(lbrackPos); // No need to check for custom source meters From a202452eb10685ed73c09975099b645b9ade32e1 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 21:31:19 -0400 Subject: [PATCH 12/99] const arg state --- src/EnergyPlus/OutputProcessor.cc | 2 +- src/EnergyPlus/OutputProcessor.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 75033c16201..abd2b390353 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -120,7 +120,7 @@ namespace OutputProcessor { // Functions - int DetermineMinuteForReporting(EnergyPlusData &state) + int DetermineMinuteForReporting(EnergyPlusData const &state) { // FUNCTION INFORMATION: diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index ccadcc8073f..01e976ba121 100644 --- a/src/EnergyPlus/OutputProcessor.hh +++ b/src/EnergyPlus/OutputProcessor.hh @@ -622,7 +622,7 @@ namespace OutputProcessor { Array1D_string spaceTypeName; // Array of space type names }; - int DetermineMinuteForReporting(EnergyPlusData &state); + int DetermineMinuteForReporting(EnergyPlusData const &state); void InitializeOutput(EnergyPlusData &state); From 42d2e0fdc26568231ff8a17441822558af647771 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 21:38:38 -0400 Subject: [PATCH 13/99] reduce --- src/EnergyPlus/OutputProcessor.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index abd2b390353..40a2a6ce470 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -2424,7 +2424,6 @@ namespace OutputProcessor { // and the SQL database // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - auto &op = state.dataOutputProcessor; auto &rf = state.dataResultsFramework->resultsFramework; auto &sql = state.dataSQLiteProcedures->sqlite; @@ -2449,7 +2448,7 @@ namespace OutputProcessor { if (freq == ReportFreq::Hour || freq == ReportFreq::Day || freq == ReportFreq::Month || freq == ReportFreq::Year || freq == ReportFreq::Simulation) - op->freqTrackingVariables[(int)freq] = true; + state.dataOutputProcessor->freqTrackingVariables[(int)freq] = true; if (sql) { sql->createSQLiteReportDictionaryRecord(ReportID, storeType, indexGroup, key, name, timeStepType, unitsString, freq, false, schedString); @@ -4611,9 +4610,9 @@ void ProduceRDDMDD(EnergyPlusData &state) ddVar = op->ddOutVars[ddVar->Next]; std::string_view timeStepName = timeStepTypeNames[(int)ddVar->timeStepType]; - std::string_view storeTypeName = storeTypeNames[(int)ddVar->storeType]; - std::string_view varName = ddVar->name; - std::string_view unitName = + storeTypeName = storeTypeNames[(int)ddVar->storeType]; + varName = ddVar->name; + std::string_view unFitName = (ddVar->units == Constant::Units::customEMS) ? ddVar->unitNameCustomEMS : Constant::unitNames[(int)ddVar->units]; if (op->ProduceReportVDD == ReportVDD::Yes) { From 72bb71920f8c467c4157bb9f77eff8a9b162fa49 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 21:46:54 -0400 Subject: [PATCH 14/99] reduce --- src/EnergyPlus/OutputProcessor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 40a2a6ce470..e99e3df9820 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -4363,10 +4363,10 @@ void GetVariableKeys(EnergyPlusData &state, // SUBROUTINE LOCAL VARIABLE DECLARATIONS: std::string nameUC = Util::makeUPPER(varName); - auto &op = state.dataOutputProcessor; // Select based on variable type: integer, real, or meter if (varType == VariableType::Integer || varType == VariableType::Real) { + auto &op = state.dataOutputProcessor; auto found = op->ddOutVarMap.find(nameUC); if (found == op->ddOutVarMap.end()) return; From 49b30594f3595579473597b9353e012e54fbdffd Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 22:07:41 -0400 Subject: [PATCH 15/99] shadow --- src/EnergyPlus/OutputProcessor.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index e99e3df9820..00637de4b4c 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -1080,7 +1080,7 @@ namespace OutputProcessor { } std::string meterOrVarNameUC = Util::makeUPPER(ipsc->cAlphaArgs(fldIndex + 1)); - std::string::size_type lbrackPos = index(meterOrVarNameUC, '['); + lbrackPos = index(meterOrVarNameUC, '['); if (lbrackPos != std::string::npos) meterOrVarNameUC.erase(lbrackPos); // A custom meter cannot reference another custom meter @@ -1251,7 +1251,7 @@ namespace OutputProcessor { for (int fldIndex = 4; fldIndex <= NumAlpha; fldIndex += 2) { // No need to check for empty fields std::string meterOrVarNameUC = Util::makeUPPER(ipsc->cAlphaArgs(fldIndex + 1)); - std::string::size_type lbrackPos = index(meterOrVarNameUC, '['); + lbrackPos = index(meterOrVarNameUC, '['); if (lbrackPos != std::string::npos) meterOrVarNameUC.erase(lbrackPos); // No need to check for custom source meters @@ -4305,11 +4305,11 @@ void GetVariableKeyCountandType(EnergyPlusData &state, units = ddOutVar->units; numKeys = ddOutVar->keyOutVarNums.size(); - } else if (auto found = op->meterMap.find(nameUC); found != op->meterMap.end()) { + } else if (auto found2 = op->meterMap.find(nameUC); found2 != op->meterMap.end()) { // Search Meters if not found in integers or reals // Use the GetMeterIndex function // Meters do not have keys, so only one will be found - int meterNum = found->second; + int meterNum = found2->second; numKeys = 1; varType = VariableType::Meter; units = op->meters[meterNum]->units; From e50286768b719ad081e1a3a27149a9ba4a631eeb Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 22:11:41 -0400 Subject: [PATCH 16/99] shadow --- src/EnergyPlus/OutputProcessor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 00637de4b4c..625d2fe5e30 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -4609,7 +4609,7 @@ void ProduceRDDMDD(EnergyPlusData &state) while (ddVar->Next != -1) { ddVar = op->ddOutVars[ddVar->Next]; - std::string_view timeStepName = timeStepTypeNames[(int)ddVar->timeStepType]; + timeStepName = timeStepTypeNames[(int)ddVar->timeStepType]; storeTypeName = storeTypeNames[(int)ddVar->storeType]; varName = ddVar->name; std::string_view unFitName = From bb247b6110cfa0d394c339729928be288fc22ebc Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 22:17:10 -0400 Subject: [PATCH 17/99] const, do we really want a reference for a 1 use? line 1970 and 1972 --- src/EnergyPlus/OutputProcessor.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 625d2fe5e30..afaa40cb261 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -1967,7 +1967,7 @@ namespace OutputProcessor { // in the data structure. // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - auto &op = state.dataOutputProcessor; + auto const &op = state.dataOutputProcessor; for (auto *meter : op->meters) { auto &period = meter->periodFinYrSM; @@ -3959,7 +3959,7 @@ int GetMeterIndex(EnergyPlusData &state, std::string const &name) // for the meter name. If none active for this run, a zero is returned. This is used later to // obtain a meter "value". - auto &op = state.dataOutputProcessor; + auto const &op = state.dataOutputProcessor; auto found = op->meterMap.find(name); return (found != op->meterMap.end()) ? found->second : -1; @@ -4167,7 +4167,7 @@ int GetNumMeteredVariables(EnergyPlusData &state, // FUNCTION LOCAL VARIABLE DECLARATIONS: int NumVariables = 0; - auto &op = state.dataOutputProcessor; + auto const &op = state.dataOutputProcessor; for (auto *var : op->outVars) { // Pos=INDEX(RVariableTypes(Loop)%VarName,':') @@ -4366,7 +4366,7 @@ void GetVariableKeys(EnergyPlusData &state, // Select based on variable type: integer, real, or meter if (varType == VariableType::Integer || varType == VariableType::Real) { - auto &op = state.dataOutputProcessor; + auto const &op = state.dataOutputProcessor; auto found = op->ddOutVarMap.find(nameUC); if (found == op->ddOutVarMap.end()) return; @@ -4669,7 +4669,7 @@ int AddDDOutVar(EnergyPlusData &state, using namespace OutputProcessor; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - auto &op = state.dataOutputProcessor; + auto const &op = state.dataOutputProcessor; std::string nameUC = Util::makeUPPER(name); From d28654996d6cd6c9fac7f1b0e0e58e2e761bc76c Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 22:45:32 -0400 Subject: [PATCH 18/99] const arg state --- src/EnergyPlus/OutputProcessor.cc | 2 +- src/EnergyPlus/OutputProcessor.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index afaa40cb261..2b4c0b1e54b 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -3947,7 +3947,7 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state, } // if (CumulativeIndicator) } // SetInitialMeterReportingAndOutputNames() -int GetMeterIndex(EnergyPlusData &state, std::string const &name) +int GetMeterIndex(EnergyPlusData const &state, std::string const &name) { // FUNCTION INFORMATION: diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index 01e976ba121..610ef86eda4 100644 --- a/src/EnergyPlus/OutputProcessor.hh +++ b/src/EnergyPlus/OutputProcessor.hh @@ -824,7 +824,7 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state, bool CumulativeIndicator // true if this is a Cumulative meter reporting ); -int GetMeterIndex(EnergyPlusData &state, std::string const &MeterName); +int GetMeterIndex(EnergyPlusData const &state, std::string const &MeterName); Constant::eResource GetMeterResourceType(EnergyPlusData &state, int MeterNumber); // Which Meter Number (from GetMeterIndex) From dab37fef3a5a9df83422d39d118a441772e78c5b Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 23:24:03 -0400 Subject: [PATCH 19/99] const arg state --- src/EnergyPlus/OutputProcessor.cc | 8 ++++---- src/EnergyPlus/OutputProcessor.hh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 2b4c0b1e54b..ffa725f3dee 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -3965,7 +3965,7 @@ int GetMeterIndex(EnergyPlusData const &state, std::string const &name) return (found != op->meterMap.end()) ? found->second : -1; } // GetMeterIndex() -Constant::eResource GetMeterResourceType(EnergyPlusData &state, int const MeterNumber) // Which Meter Number (from GetMeterIndex) +Constant::eResource GetMeterResourceType(EnergyPlusData const &state, int const MeterNumber) // Which Meter Number (from GetMeterIndex) { // FUNCTION INFORMATION: @@ -3978,7 +3978,7 @@ Constant::eResource GetMeterResourceType(EnergyPlusData &state, int const MeterN return (MeterNumber != -1) ? state.dataOutputProcessor->meters[MeterNumber]->resource : Constant::eResource::Invalid; } // GetMeterResourceType() -Real64 GetCurrentMeterValue(EnergyPlusData &state, int const MeterNumber) // Which Meter Number (from GetMeterIndex) +Real64 GetCurrentMeterValue(EnergyPlusData const &state, int const MeterNumber) // Which Meter Number (from GetMeterIndex) { // FUNCTION INFORMATION: @@ -4150,7 +4150,7 @@ Real64 GetInternalVariableValueExternalInterface(EnergyPlusData &state, return resultVal; } // GetInternalVariableValueExternalInterface() -int GetNumMeteredVariables(EnergyPlusData &state, +int GetNumMeteredVariables(EnergyPlusData const &state, [[maybe_unused]] std::string const &ComponentType, // Given Component Type std::string const &ComponentName // Given Component Name (user defined) ) @@ -4647,7 +4647,7 @@ void ProduceRDDMDD(EnergyPlusData &state) state.files.mdd.close(); } // ProduceRDDMDD() -int AddDDOutVar(EnergyPlusData &state, +int AddDDOutVar(EnergyPlusData const &state, std::string_view const name, // Variable Name OutputProcessor::TimeStepType const timeStepType, OutputProcessor::StoreType const storeType, diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index 610ef86eda4..3a76a6dca95 100644 --- a/src/EnergyPlus/OutputProcessor.hh +++ b/src/EnergyPlus/OutputProcessor.hh @@ -826,9 +826,9 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state, int GetMeterIndex(EnergyPlusData const &state, std::string const &MeterName); -Constant::eResource GetMeterResourceType(EnergyPlusData &state, int MeterNumber); // Which Meter Number (from GetMeterIndex) +Constant::eResource GetMeterResourceType(EnergyPlusData const &state, int MeterNumber); // Which Meter Number (from GetMeterIndex) -Real64 GetCurrentMeterValue(EnergyPlusData &state, int MeterNumber); // Which Meter Number (from GetMeterIndex) +Real64 GetCurrentMeterValue(EnergyPlusData const &state, int MeterNumber); // Which Meter Number (from GetMeterIndex) Real64 GetInstantMeterValue(EnergyPlusData &state, int MeterNumber, // Which Meter Number (from GetMeterIndex) @@ -845,7 +845,7 @@ Real64 GetInternalVariableValueExternalInterface(EnergyPlusData &state, int keyVarIndex // Array index ); -int GetNumMeteredVariables(EnergyPlusData &state, +int GetNumMeteredVariables(EnergyPlusData const &state, std::string const &ComponentType, // Given Component Type std::string const &ComponentName // Given Component Name (user defined) ); @@ -877,7 +877,7 @@ void InitPollutionMeterReporting(EnergyPlusData &state, OutputProcessor::ReportF void ProduceRDDMDD(EnergyPlusData &state); -int AddDDOutVar(EnergyPlusData &state, +int AddDDOutVar(EnergyPlusData const &state, std::string_view const nameUC, // Variable Name OutputProcessor::TimeStepType TimeStepType, OutputProcessor::StoreType StateType, From 12e0b0af048eea5a67f4d8cd5dfb46e60e44fe42 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 23:31:08 -0400 Subject: [PATCH 20/99] unused reduce --- src/EnergyPlus/OutputProcessor.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index ffa725f3dee..5a00a59c20f 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -671,11 +671,9 @@ namespace OutputProcessor { Array1D_string NamesOfKeys; // Specific key name Array1D_int IndexesForKeyVar; // Array index - std::vector onCustomMeterVarNums; Array1D_int VarsOnSourceMeter; - bool BigErrorsFound; - BigErrorsFound = false; + bool BigErrorsFound = false; int numCustomMeters = 0, numCustomDecMeters = 0; std::vector customMeterNames; @@ -2736,8 +2734,6 @@ namespace OutputProcessor { // easier maintenance and writing of data to the SQL database. // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - std::string MaxOut; // Character for Max out string - std::string MinOut; // Character for Min out string auto &rf = state.dataResultsFramework->resultsFramework; auto &sql = state.dataSQLiteProcedures->sqlite; From e54110faa3367c587a72d914e804aaa59e7242d6 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 14 Sep 2024 23:37:12 -0400 Subject: [PATCH 21/99] unused --- src/EnergyPlus/OutputProcessor.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 5a00a59c20f..ca8d7d5c251 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -4608,8 +4608,6 @@ void ProduceRDDMDD(EnergyPlusData &state) timeStepName = timeStepTypeNames[(int)ddVar->timeStepType]; storeTypeName = storeTypeNames[(int)ddVar->storeType]; varName = ddVar->name; - std::string_view unFitName = - (ddVar->units == Constant::Units::customEMS) ? ddVar->unitNameCustomEMS : Constant::unitNames[(int)ddVar->units]; if (op->ProduceReportVDD == ReportVDD::Yes) { print(state.files.rdd, "{},{},{} [{}]\n", timeStepName, storeTypeName, varName, unitName); From d738421699122cd105960a8ee7ef9a2c9803aa3f Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 11:04:32 -0400 Subject: [PATCH 22/99] reduce, const and unused --- src/EnergyPlus/OutputReportTabular.cc | 8 ++++---- src/EnergyPlus/OutputReportTabular.hh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index bbf5530f5bc..5e0c5e6cb60 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -3892,10 +3892,10 @@ void GatherBEPSResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeSt using DataStringGlobals::CharTab; auto &ort = state.dataOutRptTab; - auto &op = state.dataOutputProcessor; // if no beps report is called then skip if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) { + auto &op = state.dataOutputProcessor; // add the current time to the total elapsed time // FOLLOWING LINE MOVED TO UPDATETABULARREPORTS because used even when beps is not called // gatherElapsedTimeBEPS = gatherElapsedTimeBEPS + TimeStepZone @@ -11048,7 +11048,7 @@ void WriteVeriSumTable(EnergyPlusData &state) SIunit = "[m3]"; LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName); state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0); - SIunit = "[W/m2]"; + // SIunit = "[W/m2]"; // LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName); state.dataOutRptTab->Wm2_unitName = "[W/ft2]"; state.dataOutRptTab->Wm2_unitConv = 0.3048 * 0.3048; // ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0); @@ -16467,7 +16467,7 @@ void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLo } // make a list of the zones for the airloop component loads report -void CreateListOfZonesForAirLoop(EnergyPlusData &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop) +void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop) { int counter = 0; for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) { @@ -17750,7 +17750,7 @@ void ResetBinGathering(EnergyPlusData &state) // Reset all timebins gathering arrays to zero for multi-year simulations // so that only last year is reported in tabular reports Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized - auto &ort = state.dataOutRptTab; + auto const &ort = state.dataOutRptTab; // clear the binning arrays to zeros for (auto &e : ort->BinResults) { diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index e0b30a2a535..eb3f9c2a253 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -824,7 +824,7 @@ namespace OutputReportTabular { void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para); - void CreateListOfZonesForAirLoop(EnergyPlusData &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int curAirLoop); + void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int curAirLoop); void OutputCompLoadSummary(EnergyPlusData &state, EnergyPlus::OutputReportTabular::OutputType kind, From 267101cdf7f0a61c814cf3554ae3c2dbe14989cf Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 11:09:04 -0400 Subject: [PATCH 23/99] const memory location but values at that memory location can change --- src/EnergyPlus/OutputReportTabular.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 5e0c5e6cb60..11ff600cd24 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -17781,7 +17781,7 @@ void ResetBEPSGathering(EnergyPlusData &state) // Jason Glazer - October 2015 // Reset all ABUPS gathering arrays to zero for multi-year simulations // so that only last year is reported in tabular reports - auto &ort = state.dataOutRptTab; + auto const &ort = state.dataOutRptTab; ort->gatherTotalsBEPS = 0.0; ort->gatherEndUseBEPS = 0.0; ort->gatherEndUseSubBEPS = 0.0; From 880ee14d86f2a9128455a3af6c36fd2e6180b61f Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 11:16:01 -0400 Subject: [PATCH 24/99] more const memory location --- src/EnergyPlus/OutputReportTabular.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 11ff600cd24..641378d4c9c 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -17814,7 +17814,7 @@ void ResetSourceEnergyEndUseGathering(EnergyPlusData &state) // Jason Glazer - October 2015 // Reset all source energy end use table gathering arrays to zero for multi-year simulations // so that only last year is reported in tabular reports - auto &ort = state.dataOutRptTab; + auto const &ort = state.dataOutRptTab; ort->gatherTotalsBySourceBEPS = 0.0; ort->gatherEndUseBySourceBEPS = 0.0; } @@ -17824,7 +17824,7 @@ void ResetPeakDemandGathering(EnergyPlusData &state) // Jason Glazer - October 2015 // Reset all demand end use components table gathering arrays to zero for multi-year simulations // so that only last year is reported in tabular reports - auto &ort = state.dataOutRptTab; + auto const &ort = state.dataOutRptTab; ort->gatherDemandTotal = 0.0; ort->gatherDemandTimeStamp = 0; ort->gatherDemandEndUse = 0.0; From 44117995225e1fea929c65ff5fceb04c7ffe1aea Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 11:41:25 -0400 Subject: [PATCH 25/99] const state arg --- src/EnergyPlus/OutputReportTabular.cc | 6 +++--- src/EnergyPlus/OutputReportTabular.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 641378d4c9c..4206d0b2c0c 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -14590,7 +14590,7 @@ void AllocateLoadComponentArrays(EnergyPlusData &state) ort->AllocateLoadComponentArraysDoAllocate = false; } -void DeallocateLoadComponentArrays(EnergyPlusData &state) +void DeallocateLoadComponentArrays(EnergyPlusData const &state) { // SUBROUTINE INFORMATION: // AUTHOR Jason Glazer @@ -17744,7 +17744,7 @@ void ResetMonthlyGathering(EnergyPlusData &state) } } -void ResetBinGathering(EnergyPlusData &state) +void ResetBinGathering(EnergyPlusData const &state) { // Jason Glazer - October 2015 // Reset all timebins gathering arrays to zero for multi-year simulations @@ -17776,7 +17776,7 @@ void ResetBinGathering(EnergyPlusData &state) } } -void ResetBEPSGathering(EnergyPlusData &state) +void ResetBEPSGathering(EnergyPlusData const &state) { // Jason Glazer - October 2015 // Reset all ABUPS gathering arrays to zero for multi-year simulations diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index eb3f9c2a253..cc69db8f089 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -767,7 +767,7 @@ namespace OutputReportTabular { void AllocateLoadComponentArrays(EnergyPlusData &state); - void DeallocateLoadComponentArrays(EnergyPlusData &state); + void DeallocateLoadComponentArrays(EnergyPlusData const &state); void ComputeLoadComponentDecayCurve(EnergyPlusData &state); @@ -891,9 +891,9 @@ namespace OutputReportTabular { void ResetMonthlyGathering(EnergyPlusData &state); - void ResetBinGathering(EnergyPlusData &state); + void ResetBinGathering(EnergyPlusData const &state); - void ResetBEPSGathering(EnergyPlusData &state); + void ResetBEPSGathering(EnergyPlusData const &state); void ResetSourceEnergyEndUseGathering(EnergyPlusData &state); From 7629f2a9a4e32a721024eeee4f14ba91758a6f27 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 11:50:53 -0400 Subject: [PATCH 26/99] const state arg --- src/EnergyPlus/OutputReportTabular.cc | 4 ++-- src/EnergyPlus/OutputReportTabular.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 4206d0b2c0c..51b903382b9 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -17809,7 +17809,7 @@ void ResetBEPSGathering(EnergyPlusData const &state) ort->gatherWaterEndUseTotal = 0.0; } -void ResetSourceEnergyEndUseGathering(EnergyPlusData &state) +void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state) { // Jason Glazer - October 2015 // Reset all source energy end use table gathering arrays to zero for multi-year simulations @@ -17819,7 +17819,7 @@ void ResetSourceEnergyEndUseGathering(EnergyPlusData &state) ort->gatherEndUseBySourceBEPS = 0.0; } -void ResetPeakDemandGathering(EnergyPlusData &state) +void ResetPeakDemandGathering(EnergyPlusData const &state) { // Jason Glazer - October 2015 // Reset all demand end use components table gathering arrays to zero for multi-year simulations diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index cc69db8f089..867ad26762a 100644 --- a/src/EnergyPlus/OutputReportTabular.hh +++ b/src/EnergyPlus/OutputReportTabular.hh @@ -895,9 +895,9 @@ namespace OutputReportTabular { void ResetBEPSGathering(EnergyPlusData const &state); - void ResetSourceEnergyEndUseGathering(EnergyPlusData &state); + void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state); - void ResetPeakDemandGathering(EnergyPlusData &state); + void ResetPeakDemandGathering(EnergyPlusData const &state); void ResetHeatGainGathering(EnergyPlusData &state); From a526400cc5db1d2080d998e9691439001b2a2104 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 12:28:36 -0400 Subject: [PATCH 27/99] const and reduce --- src/EnergyPlus/OutputReportPredefined.cc | 2 +- src/EnergyPlus/OutputReportTabularAnnual.cc | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/EnergyPlus/OutputReportPredefined.cc b/src/EnergyPlus/OutputReportPredefined.cc index 91269722de7..81b83ce555f 100644 --- a/src/EnergyPlus/OutputReportPredefined.cc +++ b/src/EnergyPlus/OutputReportPredefined.cc @@ -95,7 +95,7 @@ namespace OutputReportPredefined { // Climate Summary Report - auto &s(state.dataOutRptPredefined); + auto const &s = state.dataOutRptPredefined; s->pdrClim = newPreDefReport(state, "ClimaticDataSummary", "Clim", "Climatic Data Summary"); diff --git a/src/EnergyPlus/OutputReportTabularAnnual.cc b/src/EnergyPlus/OutputReportTabularAnnual.cc index fe42ff37954..2e4db3fa451 100644 --- a/src/EnergyPlus/OutputReportTabularAnnual.cc +++ b/src/EnergyPlus/OutputReportTabularAnnual.cc @@ -96,10 +96,7 @@ void GetInputTabularAnnual(EnergyPlusData &state) int IOStat; // IO Status when calling get input subroutine // static bool ErrorsFound( false ); int objCount(0); - int indexNums(0); - std::string curVarMtr(""); - std::string curAggTyp(""); - int curNumDgts(2); + int curNumDgts; AnnualFieldSet::AggregationKind curAgg(AnnualFieldSet::AggregationKind::sumOrAvg); auto &annualTables = state.dataOutputReportTabularAnnual->annualTables; @@ -128,7 +125,7 @@ void GetInputTabularAnnual(EnergyPlusData &state) annualTables.push_back(AnnualTable(state, alphArray(1), alphArray(2), alphArray(3))); // the remaining fields are repeating in groups of three and need to be added to the data structure for (jAlpha = 4; jAlpha <= numAlphas; jAlpha += 2) { - curVarMtr = alphArray(jAlpha); + std::string curVarMtr = alphArray(jAlpha); if (curVarMtr.empty()) { ShowWarningError(state, format("{}: Blank column specified in '{}', need to provide a variable or meter or EMS variable name ", @@ -141,7 +138,7 @@ void GetInputTabularAnnual(EnergyPlusData &state) } else { curAgg = AnnualFieldSet::AggregationKind::sumOrAvg; // if missing aggregation type use SumOrAverage } - indexNums = 1 + (jAlpha - 3) / 2; // compute the corresponding field index in the numArray + int indexNums = 1 + (jAlpha - 3) / 2; // compute the corresponding field index in the numArray if (indexNums <= numNums) { curNumDgts = numArray(indexNums); } else { @@ -180,7 +177,6 @@ void AnnualTable::setupGathering(EnergyPlusData &state) // This method is used after GetInput for REPORT:TABLE:ANNUAL to set up how output variables, meters, // input fields, and ems variables are gathered. { - int keyCount = 0; OutputProcessor::VariableType typeVar = OutputProcessor::VariableType::Invalid; OutputProcessor::StoreType avgSumVar; OutputProcessor::TimeStepType stepTypeVar; @@ -195,7 +191,7 @@ void AnnualTable::setupGathering(EnergyPlusData &state) std::vector::iterator fldStIt; for (fldStIt = m_annualFields.begin(); fldStIt != m_annualFields.end(); ++fldStIt) { - keyCount = fldStIt->getVariableKeyCountandTypeFromFldSt(state, typeVar, avgSumVar, stepTypeVar, unitsVar); + int keyCount = fldStIt->getVariableKeyCountandTypeFromFldSt(state, typeVar, avgSumVar, stepTypeVar, unitsVar); fldStIt->getVariableKeysFromFldSt(state, typeVar, keyCount, fldStIt->m_namesOfKeys, fldStIt->m_indexesForKeyVar); for (std::string nm : fldStIt->m_namesOfKeys) { std::string nmUpper = nm; @@ -1294,8 +1290,6 @@ void AnnualTable::convertUnitForDeferredResults(EnergyPlusData &state, { Real64 curConversionFactor; Real64 curConversionOffset; - std::string varNameWithUnits; - int indexUnitConv; std::string curUnits; std::string energyUnitsString; Real64 curSI; @@ -1303,7 +1297,8 @@ void AnnualTable::convertUnitForDeferredResults(EnergyPlusData &state, Real64 energyUnitsConversionFactor = AnnualTable::setEnergyUnitStringAndFactor(unitsStyle, energyUnitsString); // do the unit conversions if (unitsStyle == OutputReportTabular::UnitsStyle::InchPound || unitsStyle == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) { - varNameWithUnits = format("{} [{}]", fldStIt->m_variMeter, Constant::unitNames[(int)fldStIt->m_varUnits]); + int indexUnitConv; + std::string varNameWithUnits = format("{} [{}]", fldStIt->m_variMeter, Constant::unitNames[(int)fldStIt->m_varUnits]); OutputReportTabular::LookupSItoIP(state, varNameWithUnits, indexUnitConv, curUnits); OutputReportTabular::GetUnitConversion(state, indexUnitConv, curConversionFactor, curConversionOffset, curUnits); } else { // just do the Joule conversion @@ -1342,7 +1337,6 @@ std::vector AnnualTable::calculateBins(int const numberOfBins, Real64 &timeBelowBottomBin) { std::vector returnBins(0.0); - int binNum = 0; returnBins.resize(numberOfBins); Real64 intervalSize = (topOfBins - bottomOfBins) / float(numberOfBins); timeAboveTopBin = 0.0; @@ -1357,7 +1351,7 @@ std::vector AnnualTable::calculateBins(int const numberOfBins, timeAboveTopBin += *elapsedTimeIt; } else { // determine which bin the results are in - binNum = int((*valueIt - bottomOfBins) / intervalSize); + int binNum = int((*valueIt - bottomOfBins) / intervalSize); if (binNum < numberOfBins && binNum >= 0) { returnBins[binNum] += *elapsedTimeIt; } From 3468d83718679c2a47fe8e855a2d8719e9d86a20 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 12:38:28 -0400 Subject: [PATCH 28/99] reduce, const and unused --- src/EnergyPlus/OutputReports.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/OutputReports.cc b/src/EnergyPlus/OutputReports.cc index e8876f46e42..96a2e9c698b 100644 --- a/src/EnergyPlus/OutputReports.cc +++ b/src/EnergyPlus/OutputReports.cc @@ -952,14 +952,11 @@ void DetailsForSurfaces(EnergyPlusData &state, int const RptType) // (1=Vertices // SUBROUTINE LOCAL VARIABLE DECLARATIONS: std::string BaseSurfName; std::string ConstructionName; - std::string ScheduleName; std::string IntConvCoeffCalc; std::string ExtConvCoeffCalc; Real64 NominalUwithConvCoeffs; std::string cNominalU; std::string cNominalUwithConvCoeffs; - std::string cSchedMin; - std::string cSchedMax; std::string SolarDiffusing; std::string AlgoName; @@ -1030,10 +1027,13 @@ void DetailsForSurfaces(EnergyPlusData &state, int const RptType) // (1=Vertices int surf2 = 0; for (int surf : state.dataSurface->AllSurfaceListReportOrder) { surf2 = surf; - auto &thisSurface = state.dataSurface->Surface(surf); + auto const &thisSurface = state.dataSurface->Surface(surf); if (thisSurface.Zone != 0) break; } if ((surf2 - 1) > 0) { + std::string ScheduleName; + std::string cSchedMin; + std::string cSchedMax; *eiostream << "Shading Surfaces," << "Number of Shading Surfaces," << surf2 - 1 << '\n'; for (int surf : state.dataSurface->AllSurfaceListReportOrder) { @@ -1352,7 +1352,7 @@ void CostInfoOut(EnergyPlusData &state) uniqueSurf.dimension(state.dataSurface->TotSurfaces, true); for (int surf : state.dataSurface->AllSurfaceListReportOrder) { - auto &thisSurface = state.dataSurface->Surface(surf); + auto const &thisSurface = state.dataSurface->Surface(surf); if (thisSurface.ExtBoundCond > 0) { if (thisSurface.ExtBoundCond < surf) { // already cycled through uniqueSurf(surf) = false; @@ -1425,7 +1425,6 @@ void VRMLOut(EnergyPlusData &state, const std::string &PolygonAction, const std: "WALL", "WINDOW", "FIXEDSHADE", "SUBSHADE", "ROOF", "FLOOR", "BLDGSHADE"}; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - std::string ShadeType; bool ThickPolyline(false); bool RegularPolyline(false); std::string PolylineWidth(" 0.55"); @@ -1502,10 +1501,8 @@ void VRMLOut(EnergyPlusData &state, const std::string &PolygonAction, const std: if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_F) colorindex = Color::FixedShade; if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_B) colorindex = Color::BldgShade; if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_F) { - ShadeType = "Fixed Shading"; print(wrlfile, "# Fixed Shading:{}\n", thisSurface.Name); } else if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_B) { - ShadeType = "Building Shading"; print(wrlfile, "# Building Shading:{}", thisSurface.Name); } print(wrlfile, Format_801, colorstring[static_cast(colorindex)], "Surf", surf); From 38fda30b9e84fbe99b64169418b48aea25fae061 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 12:42:31 -0400 Subject: [PATCH 29/99] always true conditionals --- src/EnergyPlus/OutsideEnergySources.cc | 2 +- src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/OutsideEnergySources.cc b/src/EnergyPlus/OutsideEnergySources.cc index 452a0703452..e43c94cc6c1 100644 --- a/src/EnergyPlus/OutsideEnergySources.cc +++ b/src/EnergyPlus/OutsideEnergySources.cc @@ -175,7 +175,7 @@ void GetOutsideEnergySourcesInput(EnergyPlusData &state) EnergyType = DataPlant::PlantEquipmentType::PurchHotWater; heatWaterIndex++; thisIndex = heatWaterIndex; - } else if (EnergySourceNum > NumDistrictUnitsHeatWater && EnergySourceNum <= NumDistrictUnitsHeatWater + NumDistrictUnitsCool) { + } else if (EnergySourceNum <= NumDistrictUnitsHeatWater + NumDistrictUnitsCool) { state.dataIPShortCut->cCurrentModuleObject = "DistrictCooling"; objType = DataLoopNode::ConnectionObjectType::DistrictCooling; nodeNames = "Chilled Water Nodes"; diff --git a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc index 222beab8b28..08a89e4dbca 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc @@ -95,7 +95,7 @@ namespace Material { Tau2 = this->deltaTempMeltingHigh; if (updatedTempTDT < TempLowPCM) { phaseChangeState = Phase::Crystallized; - } else if (updatedTempTDT >= TempLowPCM && updatedTempTDT <= TempHighPCM) { + } else if (updatedTempTDT <= TempHighPCM) { phaseChangeState = Phase::Melting; if (prevPhaseChangeState == Phase::Freezing || prevPhaseChangeState == Phase::Transition) { phaseChangeState = Phase::Transition; @@ -109,7 +109,7 @@ namespace Material { Tau2 = this->deltaTempFreezingHigh; if (updatedTempTDT < TempLowPCF) { phaseChangeState = Phase::Crystallized; - } else if (updatedTempTDT >= TempLowPCF && updatedTempTDT <= TempHighPCF) { + } else if (updatedTempTDT <= TempHighPCF) { phaseChangeState = Phase::Freezing; if (prevPhaseChangeState == Phase::Melting || prevPhaseChangeState == Phase::Transition) { phaseChangeState = Phase::Transition; @@ -266,13 +266,11 @@ namespace Material { return (Cp1 + DEta1); } else if (T == criticalTemperature) { return (EnthalpyNew - EnthalpyOld) / (temperatureCurrent - temperaturePrev); - } else if (T > criticalTemperature) { + } else { Real64 DEta2 = (this->totalLatentHeat * (T - criticalTemperature) * exp(-2 * std::abs(T - criticalTemperature) / tau2)) / (tau2 * std::abs(T - criticalTemperature)); Real64 Cp2 = this->specificHeatLiquid; return Cp2 + DEta2; - } else { - return 0; } } From b2605d5f29bb5ba594d926610fe2d29e3dc785bc Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 12:48:32 -0400 Subject: [PATCH 30/99] always true conditionals --- src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc index 08a89e4dbca..7023ee5567a 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc @@ -100,7 +100,7 @@ namespace Material { if (prevPhaseChangeState == Phase::Freezing || prevPhaseChangeState == Phase::Transition) { phaseChangeState = Phase::Transition; } - } else if (updatedTempTDT > TempHighPCM) { + } else { phaseChangeState = Phase::Liquid; } } else { // phaseChangeDeltaT > 0 @@ -114,7 +114,7 @@ namespace Material { if (prevPhaseChangeState == Phase::Melting || prevPhaseChangeState == Phase::Transition) { phaseChangeState = Phase::Transition; } - } else if (updatedTempTDT > TempHighPCF) { + } else { phaseChangeState = Phase::Liquid; } } From 0ae2b065ca3573df3393e91e9d53672de9611cc0 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 12:54:53 -0400 Subject: [PATCH 31/99] reduce and unused --- src/EnergyPlus/PhotovoltaicThermalCollectors.cc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc index 1dcca089a10..a31f14b6448 100644 --- a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc +++ b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc @@ -186,11 +186,10 @@ namespace PhotovoltaicThermalCollectors { // PURPOSE OF THIS SUBROUTINE: // Get input for PVT Simple objects - int Item; // Item to be "gotten" - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int IOStatus; // Used in GetObjectItem - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine + int Item; // Item to be "gotten" + int NumAlphas; // Number of Alphas for each GetObjectItem call + int NumNumbers; // Number of Numbers for each GetObjectItem call + int IOStatus; // Used in GetObjectItem tmpSimplePVTperf.allocate(NumSimplePVTPerform); for (Item = 1; Item <= NumSimplePVTPerform; ++Item) { @@ -219,7 +218,6 @@ namespace PhotovoltaicThermalCollectors { state.dataIPShortCut->cAlphaArgs(3), state.dataIPShortCut->cCurrentModuleObject, thisTmpSimplePVTperf.Name)); - ErrorsFound = true; } thisTmpSimplePVTperf.SurfEmissivity = state.dataIPShortCut->rNumericArgs(3); } @@ -234,8 +232,6 @@ namespace PhotovoltaicThermalCollectors { int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call int IOStatus; // Used in GetObjectItem - int Found; - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine using DataSurfaces::OSCMData; using ScheduleManager::GetScheduleIndex; using ScheduleManager::ScheduleAlwaysOn; @@ -257,14 +253,13 @@ namespace PhotovoltaicThermalCollectors { auto &thisTmpBIPVTperf = tmpBIPVTperf(Item); thisTmpBIPVTperf.Name = state.dataIPShortCut->cAlphaArgs(1); thisTmpBIPVTperf.OSCMName = state.dataIPShortCut->cAlphaArgs(2); - Found = Util::FindItemInList(thisTmpBIPVTperf.OSCMName, state.dataSurface->OSCM); + int Found = Util::FindItemInList(thisTmpBIPVTperf.OSCMName, state.dataSurface->OSCM); if (Found == 0) { ShowSevereError(state, format("GetBIPVTCollectorsInput: Invalid outside model name={}, object type={}, object name={}", thisTmpBIPVTperf.OSCMName, state.dataIPShortCut->cCurrentModuleObject, thisTmpBIPVTperf.Name)); - ErrorsFound = true; } thisTmpBIPVTperf.OSCMPtr = Found; thisTmpBIPVTperf.PVEffGapWidth = state.dataIPShortCut->rNumericArgs(1); @@ -290,7 +285,6 @@ namespace PhotovoltaicThermalCollectors { state.dataIPShortCut->cAlphaArgs(3), state.dataIPShortCut->cCurrentModuleObject, thisTmpBIPVTperf.Name)); - ErrorsFound = true; continue; } } From c2cfd784eaae24368afdc29c76dea4bbf32ee565 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 12:58:49 -0400 Subject: [PATCH 32/99] reduce --- .../PhotovoltaicThermalCollectors.cc | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc index a31f14b6448..bd71bf4c177 100644 --- a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc +++ b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc @@ -1638,16 +1638,16 @@ namespace PhotovoltaicThermalCollectors { // Solve a system of linear equations using Gaussian elimination and back substitution method. Real64 sum, dummy1, dummy2, mm, small(1.0e-10); - int i, j, ii, p, k, m(3); - bool coeff_not_zero; + int p; + int constexpr m = 3; - for (i = 0; i < m; i++) { + for (int i = 0; i < m; i++) { y[i] = 0.0; } - for (i = 0; i <= (m - 2); i++) { - coeff_not_zero = false; - for (j = i; j <= (m - 1); j++) { + for (int i = 0; i <= (m - 2); i++) { + bool coeff_not_zero = false; + for (int j = i; j <= (m - 1); j++) { if (std::abs(jj[j * m + i]) > small) { coeff_not_zero = true; p = j; @@ -1660,17 +1660,17 @@ namespace PhotovoltaicThermalCollectors { dummy2 = f[i]; f[i] = f[p]; f[p] = dummy2; - for (j = 0; j <= (m - 1); j++) { + for (int j = 0; j <= (m - 1); j++) { dummy1 = jj[i * m + j]; jj[i * m + j] = jj[p * m + j]; jj[p * m + j] = dummy1; } } - for (j = (i + 1); j <= (m - 1); j++) { + for (int j = (i + 1); j <= (m - 1); j++) { if (std::abs(jj[i * m + i]) < small) jj[i * m + i] = small; mm = jj[j * m + i] / jj[i * m + i]; f[j] = f[j] - mm * f[i]; - for (k = 0; k <= (m - 1); k++) { + for (int k = 0; k <= (m - 1); k++) { jj[j * m + k] = jj[j * m + k] - mm * jj[i * m + k]; } } @@ -1679,9 +1679,9 @@ namespace PhotovoltaicThermalCollectors { if (std::abs(jj[(m - 1) * m + m - 1]) < small) jj[(m - 1) * m + m - 1] = small; y[m - 1] = f[m - 1] / jj[(m - 1) * m + m - 1]; sum = 0.0; - for (i = 0; i <= (m - 2); i++) { - ii = m - 2 - i; - for (j = ii; j <= (m - 1); j++) { + for (int i = 0; i <= (m - 2); i++) { + int ii = m - 2 - i; + for (int j = ii; j <= (m - 1); j++) { sum = sum + jj[ii * m + j] * y[j]; } if (std::abs(jj[ii * m + ii]) < small) jj[ii * m + ii] = small; @@ -1739,25 +1739,19 @@ namespace PhotovoltaicThermalCollectors { // SUBROUTINE INFORMATION: // AUTHOR Brent Griffith // DATE WRITTEN August 2008 - // MODIFIED na - // RE-ENGINEERED na - - int InletNode; - int OutletNode; - int thisOSCM; { switch (this->WorkingFluidType) { case WorkingFluidEnum::LIQUID: { - InletNode = this->PlantInletNodeNum; - OutletNode = this->PlantOutletNodeNum; + int InletNode = this->PlantInletNodeNum; + int OutletNode = this->PlantOutletNodeNum; PlantUtilities::SafeCopyPlantNode(state, InletNode, OutletNode); state.dataLoopNodes->Node(OutletNode).Temp = this->Report.ToutletWorkFluid; } break; case WorkingFluidEnum::AIR: { - InletNode = this->HVACInletNodeNum; - OutletNode = this->HVACOutletNodeNum; + int InletNode = this->HVACInletNodeNum; + int OutletNode = this->HVACOutletNodeNum; // Set the outlet nodes for properties that just pass through & not used state.dataLoopNodes->Node(OutletNode).Quality = state.dataLoopNodes->Node(InletNode).Quality; @@ -1776,7 +1770,7 @@ namespace PhotovoltaicThermalCollectors { // update the OtherSideConditionsModel coefficients for BIPVT if (this->ModelType == PVTModelType::BIPVT) { - thisOSCM = this->BIPVT.OSCMPtr; + int thisOSCM = this->BIPVT.OSCMPtr; state.dataSurface->OSCM(thisOSCM).TConv = this->BIPVT.Tplen; state.dataSurface->OSCM(thisOSCM).HConv = this->BIPVT.HcPlen; state.dataSurface->OSCM(thisOSCM).TRad = this->BIPVT.Tcoll; From 342fe70ed67774901084a66cbc2f33a88555a49a Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:03:12 -0400 Subject: [PATCH 33/99] reduce --- src/EnergyPlus/PhotovoltaicThermalCollectors.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc index bd71bf4c177..7d0299bd248 100644 --- a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc +++ b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc @@ -1637,9 +1637,9 @@ namespace PhotovoltaicThermalCollectors { // PURPOSE OF THIS SUBROUTINE: // Solve a system of linear equations using Gaussian elimination and back substitution method. - Real64 sum, dummy1, dummy2, mm, small(1.0e-10); int p; int constexpr m = 3; + Real64 constexpr small = 1.0e-10; for (int i = 0; i < m; i++) { y[i] = 0.0; @@ -1657,18 +1657,18 @@ namespace PhotovoltaicThermalCollectors { if (coeff_not_zero) { if (p != i) { - dummy2 = f[i]; + Real64 dummy2 = f[i]; f[i] = f[p]; f[p] = dummy2; for (int j = 0; j <= (m - 1); j++) { - dummy1 = jj[i * m + j]; + Real64 dummy1 = jj[i * m + j]; jj[i * m + j] = jj[p * m + j]; jj[p * m + j] = dummy1; } } for (int j = (i + 1); j <= (m - 1); j++) { if (std::abs(jj[i * m + i]) < small) jj[i * m + i] = small; - mm = jj[j * m + i] / jj[i * m + i]; + Real64 mm = jj[j * m + i] / jj[i * m + i]; f[j] = f[j] - mm * f[i]; for (int k = 0; k <= (m - 1); k++) { jj[j * m + k] = jj[j * m + k] - mm * jj[i * m + k]; @@ -1678,7 +1678,7 @@ namespace PhotovoltaicThermalCollectors { } if (std::abs(jj[(m - 1) * m + m - 1]) < small) jj[(m - 1) * m + m - 1] = small; y[m - 1] = f[m - 1] / jj[(m - 1) * m + m - 1]; - sum = 0.0; + Real64 sum = 0.0; for (int i = 0; i <= (m - 2); i++) { int ii = m - 2 - i; for (int j = ii; j <= (m - 1); j++) { From c5875fd5c471d4150043a2bdf2cb40ea12a72bfa Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:07:47 -0400 Subject: [PATCH 34/99] reduce, const and unused --- src/EnergyPlus/PhotovoltaicThermalCollectors.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc index 7d0299bd248..2e26de32512 100644 --- a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc +++ b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc @@ -766,13 +766,13 @@ namespace PhotovoltaicThermalCollectors { } Real64 DesignVolFlowRateDes = 0.0; // Autosize design volume flow for reporting - int PltSizNum = 0; // Plant Sizing index corresponding to CurLoopNum bool ErrorsFound = false; if (this->WorkingFluidType == WorkingFluidEnum::LIQUID) { if (!allocated(state.dataSize->PlantSizData)) return; if (!allocated(state.dataPlnt->PlantLoop)) return; + int PltSizNum = 0; // Plant Sizing index corresponding to CurLoopNum if (this->WPlantLoc.loopNum > 0) { PltSizNum = state.dataPlnt->PlantLoop(this->WPlantLoc.loopNum).PlantSizNum; @@ -861,7 +861,7 @@ namespace PhotovoltaicThermalCollectors { } } else { CheckSysSizing(state, "SolarCollector:FlatPlate:PhotovoltaicThermal", this->Name); - auto &thisFinalSysSizing(state.dataSize->FinalSysSizing(state.dataSize->CurSysNum)); + auto const &thisFinalSysSizing = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum); if (state.dataSize->CurOASysNum > 0) { DesignVolFlowRateDes = thisFinalSysSizing.DesOutAirVolFlow; } else { @@ -1444,11 +1444,10 @@ namespace PhotovoltaicThermalCollectors { 110.4)); // Sutherland's formula https://www.grc.nasa.gov/www/k-12/airplane/viscosity.html Sutherland's constant = 198.72 R // converted to K =>110.4. At 273.15, Viscosity is 1.71E-5 as per Incropera, et al 6th ed. Temp range approx 273K - 373K k_air = 0.000000000015207 * std::pow(t_film + 273.15, 3.0) - 0.000000048574 * std::pow(t_film + 273.15, 2.0) + - 0.00010184 * (t_film + 273.15) - 0.00039333; // Dumas, A., and Trancossi, M., SAE Technical Papers, 2009 - prandtl_air = 0.680 + 0.000000469 * std::pow(t_film + 273.15 - 540.0, 2.0); // The Schock Absorber Handbook, 2nd Ed. John C. Dixon 2007 - density_air = 101.3 / (0.287 * (t_film + 273.15)); // Ideal gas law - diffusivity_air = k_air / (cp_amb * density_air); // definition - kin_viscosity_air = mu_air / density_air; // definition + 0.00010184 * (t_film + 273.15) - 0.00039333; // Dumas, A., and Trancossi, M., SAE Technical Papers, 2009 + density_air = 101.3 / (0.287 * (t_film + 273.15)); // Ideal gas law + diffusivity_air = k_air / (cp_amb * density_air); // definition + kin_viscosity_air = mu_air / density_air; // definition // duffie and beckman correlation for nat convection - This is for exterior raleigh = (gravity * (1.0 / (0.5 * (tamb + tpvg) + 273.15)) * (std::max((Real64)(0.000001), std::abs(tpvg - tamb))) * std::pow(dhyd, 3)) / From 44a687fcf489c9f3fa77b575391ff0f3d017d908 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:12:40 -0400 Subject: [PATCH 35/99] reduce, but really unused --- src/EnergyPlus/Photovoltaics.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index c0915d7d42a..73ecea6ae5a 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -1263,7 +1263,6 @@ namespace Photovoltaics { Real64 VA; Real64 VOCA; Real64 PA; - int CC; int K; Real64 CellTemp(0.0); // cell temperature in Kelvin Real64 CellTempC; // cell temperature in degrees C @@ -1287,7 +1286,6 @@ namespace Photovoltaics { // set initial values for eta iteration loop DummyErr = 2.0 * ERR; - CC = 1; EtaOld = EtaIni; // Begin DO WHILE loop - until the error tolerance is reached. @@ -1394,7 +1392,6 @@ namespace Photovoltaics { PM / state.dataPhotovoltaic->PVarray(PVnum).TRNSYSPVcalc.Insolation / state.dataPhotovoltaic->PVarray(PVnum).TRNSYSPVModule.Area; DummyErr = std::abs((ETA - EtaOld) / EtaOld); EtaOld = ETA; - ++CC; } // while From 38d785002e13d669d56a265b5418bad462d501f9 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:16:40 -0400 Subject: [PATCH 36/99] reduce and const reference --- src/EnergyPlus/Photovoltaics.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index 73ecea6ae5a..08df618d263 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -213,9 +213,9 @@ namespace Photovoltaics { GeneratorPower = state.dataPhotovoltaic->PVarray(GeneratorIndex).Report.DCPower; GeneratorEnergy = state.dataPhotovoltaic->PVarray(GeneratorIndex).Report.DCEnergy; - auto &thisPVarray = state.dataPhotovoltaic->PVarray; + auto const &thisPVarray = state.dataPhotovoltaic->PVarray(GeneratorIndex); // PVT may add thermal - if (thisPVarray(GeneratorIndex).CellIntegrationMode == CellIntegration::PVTSolarCollector) { + if (thisPVarray.CellIntegrationMode == CellIntegration::PVTSolarCollector) { // get result for thermal power generation GetPVTThermalPowerProduction(state, GeneratorIndex, ThermalPower, ThermalEnergy); } else { @@ -1263,7 +1263,6 @@ namespace Photovoltaics { Real64 VA; Real64 VOCA; Real64 PA; - int K; Real64 CellTemp(0.0); // cell temperature in Kelvin Real64 CellTempC; // cell temperature in degrees C @@ -1280,13 +1279,14 @@ namespace Photovoltaics { // convert ambient temperature from C to K Tambient = state.dataSurface->SurfOutDryBulbTemp(state.dataPhotovoltaic->PVarray(PVnum).SurfacePtr) + Constant::Kelvin; - auto &thisPVarray = state.dataPhotovoltaic->PVarray; + auto const &thisPVarray = state.dataPhotovoltaic->PVarray(PVnum); if ((state.dataPhotovoltaic->PVarray(PVnum).TRNSYSPVcalc.Insolation > MinInsolation) && (RunFlag)) { // set initial values for eta iteration loop DummyErr = 2.0 * ERR; EtaOld = EtaIni; + int K; // Begin DO WHILE loop - until the error tolerance is reached. ETA = 0.0; @@ -1330,7 +1330,7 @@ namespace Photovoltaics { CellTemp += Constant::Kelvin; } break; case CellIntegration::PVTSolarCollector: { - GetPVTTsColl(state, thisPVarray(PVnum).PVTPtr, CellTemp); + GetPVTTsColl(state, thisPVarray.PVTPtr, CellTemp); CellTemp += Constant::Kelvin; } break; default: @@ -1419,7 +1419,7 @@ namespace Photovoltaics { CellTemp += Constant::Kelvin; } break; case CellIntegration::PVTSolarCollector: { - GetPVTTsColl(state, thisPVarray(PVnum).PVTPtr, CellTemp); + GetPVTTsColl(state, thisPVarray.PVTPtr, CellTemp); CellTemp += Constant::Kelvin; } break; default: { From 04cbd75146bb10fd482f0d756edaf0550204bbbf Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:29:54 -0400 Subject: [PATCH 37/99] const real arg --- src/EnergyPlus/Photovoltaics.cc | 8 ++++---- src/EnergyPlus/Photovoltaics.hh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index 08df618d263..cfaefc19f7a 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -1537,10 +1537,10 @@ namespace Photovoltaics { Real64 &B, Real64 &P, int &K, - Real64 &IO, - Real64 &IL, - Real64 &RSER, - Real64 &AA, + Real64 const IO, + Real64 const IL, + Real64 const RSER, + Real64 const AA, Real64 const EPS, int const KMAX) { diff --git a/src/EnergyPlus/Photovoltaics.hh b/src/EnergyPlus/Photovoltaics.hh index fecd98cf9ad..703e606e307 100644 --- a/src/EnergyPlus/Photovoltaics.hh +++ b/src/EnergyPlus/Photovoltaics.hh @@ -149,10 +149,10 @@ namespace Photovoltaics { Real64 &B, Real64 &P, int &K, - Real64 &IO, - Real64 &IL, - Real64 &RSER, - Real64 &AA, + Real64 const IO, + Real64 const IL, + Real64 const RSER, + Real64 const AA, Real64 const EPS, int const KMAX); From b38588ba0efbf05c07bb43ee4315779921d8d422 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:36:46 -0400 Subject: [PATCH 38/99] const real args --- src/EnergyPlus/Photovoltaics.cc | 4 ++-- src/EnergyPlus/Photovoltaics.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index cfaefc19f7a..62b2526f237 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -1497,8 +1497,8 @@ namespace Photovoltaics { Real64 &XX, std::function FXX, std::function DER, - Real64 const &II, // Autodesk Aliased to XX in some calls - Real64 const &VV, // Autodesk Aliased to XX in some calls + Real64 const II, // Autodesk Aliased to XX in some calls + Real64 const VV, // Autodesk Aliased to XX in some calls Real64 const IO, Real64 const IL, Real64 const RSER, diff --git a/src/EnergyPlus/Photovoltaics.hh b/src/EnergyPlus/Photovoltaics.hh index 703e606e307..3a819a813e6 100644 --- a/src/EnergyPlus/Photovoltaics.hh +++ b/src/EnergyPlus/Photovoltaics.hh @@ -135,8 +135,8 @@ namespace Photovoltaics { Real64 &XX, std::function FXX, std::function DER, - Real64 const &II, // Autodesk Aliased to XX in some calls, this is absolutely wacky and needs to go - Real64 const &VV, // Autodesk Aliased to XX in some calls, this too + Real64 const II, // Autodesk Aliased to XX in some calls, this is absolutely wacky and needs to go + Real64 const VV, // Autodesk Aliased to XX in some calls, this too Real64 const IO, Real64 const IL, Real64 const RSER, From 4b5156d6168c2d474fc835bec19a335b75ec1334 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:44:59 -0400 Subject: [PATCH 39/99] const real arg --- src/EnergyPlus/Photovoltaics.cc | 2 +- src/EnergyPlus/Photovoltaics.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index 62b2526f237..b2d2fbcc873 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -1470,7 +1470,7 @@ namespace Photovoltaics { Real64 const AA, // passed in from CalcPV Real64 const EPS, // passed in from CalcPV Real64 &II, // current [A] - Real64 &VV, // voltage [V] + Real64 const VV, // voltage [V] Real64 &PP // power [W] ) { diff --git a/src/EnergyPlus/Photovoltaics.hh b/src/EnergyPlus/Photovoltaics.hh index 3a819a813e6..e875c56aaa5 100644 --- a/src/EnergyPlus/Photovoltaics.hh +++ b/src/EnergyPlus/Photovoltaics.hh @@ -127,7 +127,7 @@ namespace Photovoltaics { Real64 const AA, // passed in from CalcPV Real64 const EPS, // passed in from CalcPV Real64 &II, // current [A] - Real64 &VV, // voltage [V] + Real64 const VV, // voltage [V] Real64 &PP // power [W] ); From 8acf3ba1a2565ef1c08505ed9c06ab6a1f45f33c Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 13:55:53 -0400 Subject: [PATCH 40/99] std::find_if --- src/EnergyPlus/PipeHeatTransfer.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/PipeHeatTransfer.cc b/src/EnergyPlus/PipeHeatTransfer.cc index b894207c80e..679e9143fcf 100644 --- a/src/EnergyPlus/PipeHeatTransfer.cc +++ b/src/EnergyPlus/PipeHeatTransfer.cc @@ -133,11 +133,10 @@ PlantComponent *PipeHTData::factory(EnergyPlusData &state, DataPlant::PlantEquip state.dataPipeHT->GetPipeInputFlag = false; } // Now look for this particular pipe in the list - for (auto &pipe : state.dataPipeHT->PipeHT) { - if (pipe.Type == objectType && pipe.Name == objectName) { - return &pipe; - } - } + auto thisObj = std::find_if(state.dataPipeHT->PipeHT.begin(), + state.dataPipeHT->PipeHT.end(), + [&objectType, &objectName](const PipeHTData &myObj) { return myObj.Type == objectType && myObj.Name == objectName; }); + if (thisObj != state.dataPipeHT->PipeHT.end()) return thisObj; // If we didn't find it, fatal ShowFatalError(state, format("PipeHTFactory: Error getting inputs for pipe named: {}", objectName)); // Shut up the compiler @@ -226,7 +225,6 @@ void GetPipesHeatTransfer(EnergyPlusData &state) int NumOfPipeHTInt; // Number of Pipe Heat Transfer objects int NumOfPipeHTExt; // Number of Pipe Heat Transfer objects int NumOfPipeHTUG; // Number of Pipe Heat Transfer objects - int NumSections; // total number of sections in pipe auto &s_ipsc = state.dataIPShortCut; auto &s_mat = state.dataMaterial; @@ -835,7 +833,7 @@ void PipeHTData::ValidatePipeConstruction(EnergyPlusData &state, Real64 Resistance = 0.0; Real64 TotThickness = 0.0; - auto &s_mat = state.dataMaterial; + auto const &s_mat = state.dataMaterial; // CTF stuff int TotalLayers = state.dataConstruction->Construct(ConstructionNum).TotLayers; From 37c2b5ceba1efb4260e8a0d8a332fe251d4ff650 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 14:25:12 -0400 Subject: [PATCH 41/99] find_if and reduce --- src/EnergyPlus/PlantLoadProfile.cc | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/EnergyPlus/PlantLoadProfile.cc b/src/EnergyPlus/PlantLoadProfile.cc index fa976ca3efe..613e8b13fa4 100644 --- a/src/EnergyPlus/PlantLoadProfile.cc +++ b/src/EnergyPlus/PlantLoadProfile.cc @@ -96,11 +96,10 @@ PlantComponent *PlantProfileData::factory(EnergyPlusData &state, std::string con state.dataPlantLoadProfile->GetPlantLoadProfileInputFlag = false; } // Now look for this particular pipe in the list - for (auto &plp : state.dataPlantLoadProfile->PlantProfile) { - if (plp.Name == objectName) { - return &plp; - } - } + auto thisObj = std::find_if(state.dataPlantLoadProfile->PlantProfile.begin(), + state.dataPlantLoadProfile->PlantProfile.end(), + [&objectName](const PlantProfileData &plp) { return plp.Name == objectName; }); + if (thisObj != state.dataPlantLoadProfile->PlantProfile.end()) return thisObj; // If we didn't find it, fatal ShowFatalError(state, format("PlantLoadProfile::factory: Error getting inputs for pipe named: {}", objectName)); // Shut up the compiler @@ -342,10 +341,8 @@ void PlantProfileData::ReportPlantProfile(EnergyPlusData &state) } void PlantProfileData::oneTimeInit_new(EnergyPlusData &state) { - bool errFlag; - if (allocated(state.dataPlnt->PlantLoop)) { - errFlag = false; + bool errFlag = false; PlantUtilities::ScanPlantLoopsForObject(state, this->Name, this->Type, this->plantLoc, errFlag, _, _, _, _, _); if (errFlag) { ShowFatalError(state, "InitPlantProfile: Program terminated for previous conditions."); @@ -379,11 +376,6 @@ void GetPlantProfileInput(EnergyPlusData &state) using namespace DataLoopNode; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int IOStatus; // Used in GetObjectItem - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int ProfileNum; // PLANT LOAD PROFILE (PlantProfile) object number auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "LoadProfile:Plant"; @@ -391,8 +383,12 @@ void GetPlantProfileInput(EnergyPlusData &state) if (state.dataPlantLoadProfile->NumOfPlantProfile > 0) { state.dataPlantLoadProfile->PlantProfile.allocate(state.dataPlantLoadProfile->NumOfPlantProfile); + bool ErrorsFound = false; // Set to true if errors in input, fatal at end of routine + int IOStatus; // Used in GetObjectItem + int NumAlphas; // Number of Alphas for each GetObjectItem call + int NumNumbers; // Number of Numbers for each GetObjectItem call - for (ProfileNum = 1; ProfileNum <= state.dataPlantLoadProfile->NumOfPlantProfile; ++ProfileNum) { + for (int ProfileNum = 1; ProfileNum <= state.dataPlantLoadProfile->NumOfPlantProfile; ++ProfileNum) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, ProfileNum, From 6b43cd5cf0181c8fddb39fe711bfffd534754efb Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 15:22:15 -0400 Subject: [PATCH 42/99] reduce, shadow and dup conditionals --- src/EnergyPlus/PoweredInductionUnits.cc | 50 ++++++++++++------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/EnergyPlus/PoweredInductionUnits.cc b/src/EnergyPlus/PoweredInductionUnits.cc index 07523f92033..c8f3dbfc799 100644 --- a/src/EnergyPlus/PoweredInductionUnits.cc +++ b/src/EnergyPlus/PoweredInductionUnits.cc @@ -263,7 +263,7 @@ void GetPIUs(EnergyPlusData &state) state.dataPowerInductionUnits->PiuUniqueNames.reserve(static_cast(state.dataPowerInductionUnits->NumPIUs)); state.dataPowerInductionUnits->CheckEquipName.dimension(state.dataPowerInductionUnits->NumPIUs, true); - int PIUNum{0}; + int PIUNum = 0; auto &ip = state.dataInputProcessing->inputProcessor; // loop over Series PIUs; get and load the input data for (const std::string cCurrentModuleObject : {"AirTerminal:SingleDuct:SeriesPIU:Reheat", "AirTerminal:SingleDuct:ParallelPIU:Reheat"}) { @@ -556,8 +556,8 @@ void GetPIUs(EnergyPlusData &state) ShowFatalError(state, format("{} Errors found in getting input. Preceding conditions cause termination.", RoutineName)); } - for (int PIUNum = 1; PIUNum <= state.dataPowerInductionUnits->NumPIUs; ++PIUNum) { - auto &thisPIU = state.dataPowerInductionUnits->PIU(PIUNum); + for (int PIURpt = 1; PIURpt <= state.dataPowerInductionUnits->NumPIUs; ++PIURpt) { + auto &thisPIU = state.dataPowerInductionUnits->PIU(PIURpt); // Setup Report variables for the PIUs SetupOutputVariable(state, @@ -608,35 +608,35 @@ void GetPIUs(EnergyPlusData &state) thisPIU.TotMassFlowRate, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataPowerInductionUnits->PIU(PIUNum).Name); + state.dataPowerInductionUnits->PIU(PIURpt).Name); SetupOutputVariable(state, "Zone Air Terminal Primary Air Mass Flow Rate", Constant::Units::kg_s, thisPIU.PriMassFlowRate, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataPowerInductionUnits->PIU(PIUNum).Name); + state.dataPowerInductionUnits->PIU(PIURpt).Name); SetupOutputVariable(state, "Zone Air Terminal Secondary Air Mass Flow Rate", Constant::Units::kg_s, thisPIU.SecMassFlowRate, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataPowerInductionUnits->PIU(PIUNum).Name); + state.dataPowerInductionUnits->PIU(PIURpt).Name); SetupOutputVariable(state, "Zone Air Terminal Outlet Discharge Air Temperature", Constant::Units::C, thisPIU.DischargeAirTemp, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataPowerInductionUnits->PIU(PIUNum).Name); + state.dataPowerInductionUnits->PIU(PIURpt).Name); SetupOutputVariable(state, "Zone Air Terminal Current Operation Control Stage", Constant::Units::unknown, thisPIU.CurOperationControlStage, OutputProcessor::TimeStepType::System, OutputProcessor::StoreType::Average, - state.dataPowerInductionUnits->PIU(PIUNum).Name); + state.dataPowerInductionUnits->PIU(PIURpt).Name); } } @@ -1230,8 +1230,6 @@ void SizePIU(EnergyPlusData &state, int const PIUNum) ShowContinueError(state, format("Occurs in{} Object={}", thisPIU.UnitType, thisPIU.Name)); ErrorsFound = true; } - } - if (IsAutoSize) { thisPIU.MaxVolHotWaterFlow = MaxVolHotWaterFlowDes; BaseSizer::reportSizerOutput( state, thisPIU.UnitType, thisPIU.Name, "Design Size Maximum Reheat Water Flow Rate [m3/s]", MaxVolHotWaterFlowDes); @@ -1327,8 +1325,6 @@ void SizePIU(EnergyPlusData &state, int const PIUNum) ShowContinueError(state, format("Occurs in{} Object={}", thisPIU.UnitType, thisPIU.Name)); ErrorsFound = true; } - } - if (IsAutoSize) { thisPIU.MaxVolHotSteamFlow = MaxVolHotSteamFlowDes; BaseSizer::reportSizerOutput( state, thisPIU.UnitType, thisPIU.Name, "Design Size Maximum Reheat Steam Flow [m3/s]", MaxVolHotSteamFlowDes); @@ -2076,18 +2072,18 @@ void CalcParallelPIU(EnergyPlusData &state, void ReportCurOperatingControlStage(EnergyPlusData &state, int const piuNum, bool const unitOn, HeatOpModeType heaterMode, CoolOpModeType coolingMode) { - int undetermined(-1); - int off(0); - int constantVolumeCooling(1); - int constantVolumeHeating(2); - int deadband(3); - int variableSpeedFirstStageCooling(4); - int variableSpeedSecondStageCooling(5); - int variableSpeedStagedHeatFirstStageHeating(6); - int variableSpeedStagedHeatSecondStageHeating(7); - int variableSpeedModulatedHeatFirstStageHeating(8); - int variableSpeedModulatedHeatSecondStageHeating(9); - int variableSpeedModulatedHeatThirdStageHeating(10); + int constexpr undetermined = -1; + int constexpr off = 0; + int constexpr constantVolumeCooling = 1; + int constexpr constantVolumeHeating = 2; + int constexpr deadband = 3; + int constexpr variableSpeedFirstStageCooling = 4; + int constexpr variableSpeedSecondStageCooling = 5; + int constexpr variableSpeedStagedHeatFirstStageHeating = 6; + int constexpr variableSpeedStagedHeatSecondStageHeating = 7; + int constexpr variableSpeedModulatedHeatFirstStageHeating = 8; + int constexpr variableSpeedModulatedHeatSecondStageHeating = 9; + int constexpr variableSpeedModulatedHeatThirdStageHeating = 10; state.dataPowerInductionUnits->PIU(piuNum).CurOperationControlStage = undetermined; @@ -2166,13 +2162,13 @@ void CalcVariableSpeedPIUCoolingBehavior(EnergyPlusData &state, } else { // check how much cooling provided at max fan and primary air state.dataLoopNodes->Node(thisPIU.PriAirInNode).MassFlowRate = thisPIU.MaxPriAirMassFlow; - Real64 TotAirMassFlow = thisPIU.MaxTotAirMassFlow; + TotAirMassFlow = thisPIU.MaxTotAirMassFlow; state.dataLoopNodes->Node(thisPIU.SecAirInNode).MassFlowRate = max(0.0, TotAirMassFlow - thisPIU.MaxPriAirMassFlow); Real64 qdotDelivMaxFan = CalcVariableSpeedPIUQdotDelivered(state, piuNum, zoneNode, false, TotAirMassFlow, 1.0); if (zoneLoad <= qdotDelivMaxFan) { // not going to make it just run at max thisPIU.PriAirMassFlow = thisPIU.PriAirMassFlow; - Real64 TotAirMassFlow = thisPIU.MaxTotAirMassFlow; + TotAirMassFlow = thisPIU.MaxTotAirMassFlow; thisPIU.SecAirMassFlow = max(0.0, TotAirMassFlow - thisPIU.PriAirMassFlow); thisPIU.heatingOperatingMode = HeatOpModeType::HeaterOff; thisPIU.coolingOperatingMode = CoolOpModeType::CoolSecondStage; @@ -2200,7 +2196,7 @@ void CalcVariableSpeedPIUCoolingBehavior(EnergyPlusData &state, ShowFatalError(state, format("Series PIU control failed for {}:{}", thisPIU.UnitType, thisPIU.Name)); } else { thisPIU.PriAirMassFlow = coolSignal * (thisPIU.MaxPriAirMassFlow - thisPIU.MinPriAirMassFlow) + thisPIU.MinPriAirMassFlow; - Real64 TotAirMassFlow = coolSignal * (thisPIU.MaxTotAirMassFlow - thisPIU.MinTotAirMassFlow) + thisPIU.MinTotAirMassFlow; + TotAirMassFlow = coolSignal * (thisPIU.MaxTotAirMassFlow - thisPIU.MinTotAirMassFlow) + thisPIU.MinTotAirMassFlow; thisPIU.SecAirMassFlow = max(0.0, TotAirMassFlow - thisPIU.PriAirMassFlow); thisPIU.heatingOperatingMode = HeatOpModeType::HeaterOff; thisPIU.coolingOperatingMode = CoolOpModeType::CoolFirstStage; From 30826ac75f37e84ac09880349ff3c8c8b7b55a74 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 15:43:55 -0400 Subject: [PATCH 43/99] reduce and clean --- src/EnergyPlus/Psychrometrics.cc | 43 ++++++-------------------------- src/EnergyPlus/Pumps.cc | 5 ++-- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index b1698cc608d..5507c31a7f4 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -285,8 +285,6 @@ namespace Psychrometrics { // FUNCTION INFORMATION: // AUTHOR Linda Lawrie/Amir Roth // DATE WRITTEN August 2011 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // Provide a "cache" of results for the given arguments and wetbulb (twb) output result. @@ -295,29 +293,9 @@ namespace Psychrometrics { // Use grid shifting and masking to provide hash into the cache. Use Equivalence to // make Fortran ignore "types". - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - Real64 Twb_result; // result=> Temperature Wet-Bulb {C} - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - // FUNCTION PARAMETER DEFINITIONS: std::uint64_t constexpr Grid_Shift = 64 - 12 - twbprecision_bits; - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - #ifdef EP_psych_stats ++state.dataPsychCache->NumTimesCalled[static_cast(PsychrometricFunction::TwbFnTdbWPb_cache)]; #endif @@ -359,11 +337,7 @@ namespace Psychrometrics { cached_Twb[hash].Twb = PsyTwbFnTdbWPb_raw(state, Tdb_tag_r, W_tag_r, Pb_tag_r, CalledFrom); } - // Twbresult_last = cached_Twb(hash)%Twb - // Twb_result = Twbresult_last - Twb_result = cached_Twb[hash].Twb; - - return Twb_result; + return cached_Twb[hash].Twb; } Real64 PsyTwbFnTdbWPb_raw(EnergyPlusData &state, @@ -420,14 +394,13 @@ namespace Psychrometrics { Real64 PSatstar; // Saturation pressure at wet bulb temperature int iter; // Iteration counter int icvg; // Iteration convergence flag - bool FlagError; // set when errors should be flagged #ifdef EP_psych_stats ++state.dataPsychCache->NumTimesCalled[static_cast(PsychrometricFunction::TwbFnTdbWPb)]; #endif // CHECK TDB IN RANGE. - FlagError = false; + bool FlagError = false; #ifdef EP_psych_errors if (TDB <= -100.0 || TDB >= 200.0) { if (!state.dataGlobal->WarmupFlag) { @@ -963,7 +936,7 @@ namespace Psychrometrics { if (H >= 0.0) { Hloc = max(0.00001, H); - } else if (H < 0.0) { + } else { Hloc = min(-0.00001, H); } @@ -1326,16 +1299,15 @@ namespace Psychrometrics { // na // FUNCTION LOCAL VARIABLE DECLARATIONS: - bool FlagError; // set when errors should be flagged - Real64 tSat; // Water temperature guess - int iter; // Iteration counter + Real64 tSat; // Water temperature guess + int iter; // Iteration counter #ifdef EP_psych_stats ++state.dataPsychCache->NumTimesCalled[static_cast(PsychrometricFunction::TsatFnPb)]; #endif // Check press in range. - FlagError = false; + bool FlagError = false; #ifdef EP_psych_errors if (!state.dataGlobal->WarmupFlag) { if (Press <= 0.0017 || Press >= 1555000.0) { @@ -1364,18 +1336,17 @@ namespace Psychrometrics { return state.dataPsychrometrics->tSat_Save; } state.dataPsychrometrics->Press_Save = Press; + iter = 0; if (state.dataPsychrometrics->useInterpolationPsychTsatFnPb) { int n_sample = 1651; // sample bin size = 64 Pa; continous sample size = 1651 // CSpline interpolation tSat = CSplineint(n_sample, Press); // Cubic spline interpolation - iter = 0; } else { // Uses an iterative process to determine the saturation temperature at a given // pressure by correlating saturated water vapor as a function of temperature. // Initial guess of boiling temperature tSat = 100.0; - iter = 0; // If above 1555000,set value of Temp corresponding to Saturation Pressure of 1555000 Pascal. if (Press >= 1555000.0) { diff --git a/src/EnergyPlus/Pumps.cc b/src/EnergyPlus/Pumps.cc index b22f78716f8..c688f9de87c 100644 --- a/src/EnergyPlus/Pumps.cc +++ b/src/EnergyPlus/Pumps.cc @@ -1369,9 +1369,7 @@ void InitializePumps(EnergyPlusData &state, int const PumpNum) int OutletNode; // pump outlet node number Real64 TotalEffic; Real64 SteamDensity; // Density of working fluid - int DummyWaterIndex(1); Real64 TempWaterDensity; - bool errFlag; Real64 mdotMax; // local fluid mass flow rate maximum Real64 mdotMin; // local fluid mass flow rate minimum int plloopnum; @@ -1387,7 +1385,7 @@ void InitializePumps(EnergyPlusData &state, int const PumpNum) // One time inits if (thisPump.PumpOneTimeFlag) { - errFlag = false; + bool errFlag = false; ScanPlantLoopsForObject(state, thisPump.Name, thisPump.TypeOf_Num, thisPump.plantLoc, errFlag, _, _, _, _, _); plloopnum = thisPump.plantLoc.loopNum; lsnum = thisPump.plantLoc.loopSideNum; @@ -1498,6 +1496,7 @@ void InitializePumps(EnergyPlusData &state, int const PumpNum) // Begin environment inits if (thisPump.PumpInitFlag && state.dataGlobal->BeginEnvrnFlag) { if (thisPump.pumpType == PumpType::Cond) { + int DummyWaterIndex = 1; TempWaterDensity = GetDensityGlycol(state, fluidNameWater, Constant::InitConvTemp, DummyWaterIndex, RoutineName); SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, StartTemp, 1.0, thisPump.FluidIndex, RoutineName); From 610c2cfc8e92ad59964a50026af107d316807f28 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 16:22:31 -0400 Subject: [PATCH 44/99] reduce and const --- src/EnergyPlus/Pumps.cc | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/Pumps.cc b/src/EnergyPlus/Pumps.cc index c688f9de87c..d041f8492a3 100644 --- a/src/EnergyPlus/Pumps.cc +++ b/src/EnergyPlus/Pumps.cc @@ -240,7 +240,6 @@ void GetPumpInput(EnergyPlusData &state) int IOStat; // IO Status when calling get input subroutine bool ErrorsFound; int TempCurveIndex; - std::string TempCurveType; int NumVarSpeedPumps = 0; int NumConstSpeedPumps = 0; int NumCondensatePumps = 0; @@ -1365,44 +1364,38 @@ void InitializePumps(EnergyPlusData &state, int const PumpNum) static constexpr std::string_view RoutineName("PlantPumps::InitializePumps "); // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int InletNode; // pump inlet node number - int OutletNode; // pump outlet node number Real64 TotalEffic; Real64 SteamDensity; // Density of working fluid Real64 TempWaterDensity; Real64 mdotMax; // local fluid mass flow rate maximum Real64 mdotMin; // local fluid mass flow rate minimum - int plloopnum; DataPlant::LoopSideLocation lsnum; - int brnum; - int cpnum; // Set some variables for convenience auto &thisPump = state.dataPumps->PumpEquip(PumpNum); - InletNode = thisPump.InletNodeNum; - OutletNode = thisPump.OutletNodeNum; + int InletNode = thisPump.InletNodeNum; + int OutletNode = thisPump.OutletNodeNum; // One time inits if (thisPump.PumpOneTimeFlag) { bool errFlag = false; ScanPlantLoopsForObject(state, thisPump.Name, thisPump.TypeOf_Num, thisPump.plantLoc, errFlag, _, _, _, _, _); - plloopnum = thisPump.plantLoc.loopNum; + int plloopnum = thisPump.plantLoc.loopNum; lsnum = thisPump.plantLoc.loopSideNum; - brnum = thisPump.plantLoc.branchNum; - cpnum = thisPump.plantLoc.compNum; + int brnum = thisPump.plantLoc.branchNum; + int cpnum = thisPump.plantLoc.compNum; if (plloopnum > 0 && lsnum != DataPlant::LoopSideLocation::Invalid && brnum > 0 && cpnum > 0) { auto &thisPumpLoc = state.dataPlnt->PlantLoop(plloopnum).LoopSide(lsnum).Branch(brnum); - auto &thisLoopNodeID = state.dataLoopNodes->NodeID; if (thisPumpLoc.Comp(cpnum).NodeNumIn != InletNode || thisPumpLoc.Comp(cpnum).NodeNumOut != OutletNode) { ShowSevereError( state, format("InitializePumps: {}=\"{}\", non-matching nodes.", pumpTypeIDFNames[static_cast(thisPump.pumpType)], thisPump.Name)); ShowContinueError(state, format("...in Branch={}, Component referenced with:", thisPumpLoc.Name)); - ShowContinueError(state, format("...Inlet Node={}", thisLoopNodeID(thisPumpLoc.Comp(cpnum).NodeNumIn))); - ShowContinueError(state, format("...Outlet Node={}", thisLoopNodeID(thisPumpLoc.Comp(cpnum).NodeNumOut))); - ShowContinueError(state, format("...Pump Inlet Node={}", thisLoopNodeID(InletNode))); - ShowContinueError(state, format("...Pump Outlet Node={}", thisLoopNodeID(OutletNode))); + ShowContinueError(state, format("...Inlet Node={}", state.dataLoopNodes->NodeID(thisPumpLoc.Comp(cpnum).NodeNumIn))); + ShowContinueError(state, format("...Outlet Node={}", state.dataLoopNodes->NodeID(thisPumpLoc.Comp(cpnum).NodeNumOut))); + ShowContinueError(state, format("...Pump Inlet Node={}", state.dataLoopNodes->NodeID(InletNode))); + ShowContinueError(state, format("...Pump Outlet Node={}", state.dataLoopNodes->NodeID(OutletNode))); errFlag = true; } } else { // CR9292 @@ -1538,7 +1531,7 @@ void InitializePumps(EnergyPlusData &state, int const PumpNum) if (!state.dataGlobal->BeginEnvrnFlag) thisPump.PumpInitFlag = true; // zero out module level working variables - auto &daPumps = state.dataPumps; + auto const &daPumps = state.dataPumps; daPumps->PumpMassFlowRate = 0.0; daPumps->PumpHeattoFluid = 0.0; daPumps->Power = 0.0; @@ -1637,7 +1630,7 @@ void SetupPumpMinMaxFlows(EnergyPlusData &state, int const LoopNum, int const Pu // Let the user know that his input file is overconstrained } - auto &thisPumpPlant = state.dataPlnt->PlantLoop(thisPump.plantLoc.loopNum); + auto const &thisPumpPlant = state.dataPlnt->PlantLoop(thisPump.plantLoc.loopNum); switch (thisPump.pumpType) { case PumpType::VarSpeed: { @@ -2064,7 +2057,7 @@ void SizePump(EnergyPlusData &state, int const PumpNum) for (int BranchNum = 1; BranchNum <= thisPumpLoop.TotalBranches; ++BranchNum) { auto &thisPumpBranch = thisPumpLoop.Branch(BranchNum); for (int CompNum = 1; CompNum <= thisPumpBranch.TotalComponents; ++CompNum) { - auto &thisPumpComp = thisPumpBranch.Comp(CompNum); + auto const &thisPumpComp = thisPumpBranch.Comp(CompNum); if (thisPump.InletNodeNum == thisPumpComp.NodeNumIn && thisPump.OutletNodeNum == thisPumpComp.NodeNumOut) { if (thisPumpBranch.PumpSizFac > 0.0) { PumpSizFac = thisPumpBranch.PumpSizFac; @@ -2222,8 +2215,8 @@ void ReportPumps(EnergyPlusData &state, int const PumpNum) PumpType = thisPump.pumpType; OutletNode = thisPump.OutletNodeNum; - auto &thisOutNode = state.dataLoopNodes->Node(OutletNode); - auto &daPumps = state.dataPumps; + auto const &thisOutNode = state.dataLoopNodes->Node(OutletNode); + auto const &daPumps = state.dataPumps; if (daPumps->PumpMassFlowRate <= DataBranchAirLoopPlant::MassFlowTolerance) { new (&(state.dataPumps->PumpEquipReport(PumpNum))) ReportVars(); @@ -2347,7 +2340,7 @@ void GetRequiredMassFlowRate(EnergyPlusData &state, // Calculate maximum and minimum mass flow rate associated with maximun and minimum RPM if (thisPump.plantLoc.loopNum > 0) { - auto &thisPlantLoop = state.dataPlnt->PlantLoop(thisPump.plantLoc.loopNum); + auto const &thisPlantLoop = state.dataPlnt->PlantLoop(thisPump.plantLoc.loopNum); if (thisPlantLoop.UsePressureForPumpCalcs && thisPlantLoop.PressureSimType == DataPlant::PressSimType::FlowCorrection && thisPlantLoop.PressureDrop > 0.0) { thisPump.PumpMassFlowRateMaxRPM = ResolveLoopFlowVsPressure(state, @@ -2376,7 +2369,7 @@ void GetRequiredMassFlowRate(EnergyPlusData &state, // Calculate maximum and minimum mass flow rate associated with operating pressure range if (thisPump.plantLoc.loopNum > 0) { - auto &thisPlantLoop = state.dataPlnt->PlantLoop(LoopNum); + auto const &thisPlantLoop = state.dataPlnt->PlantLoop(LoopNum); if (thisPlantLoop.PressureEffectiveK > 0.0) { PumpMassFlowRateMaxPress = std::sqrt(MaxPress / thisPlantLoop.PressureEffectiveK); PumpMassFlowRateMinPress = std::sqrt(MinPress / thisPlantLoop.PressureEffectiveK); From ee7fbf0abbca2ba89234958b0b5fa9478f6a0b02 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 16:35:02 -0400 Subject: [PATCH 45/99] const and dup var --- src/EnergyPlus/ReportCoilSelection.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/EnergyPlus/ReportCoilSelection.cc b/src/EnergyPlus/ReportCoilSelection.cc index defc4a2b2d2..aa489494c27 100644 --- a/src/EnergyPlus/ReportCoilSelection.cc +++ b/src/EnergyPlus/ReportCoilSelection.cc @@ -575,7 +575,7 @@ void ReportCoilSelection::doAirLoopSetup(EnergyPlusData &state, int const coilVe int zoneIndex = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).HeatCtrlZoneNums(loopZone); // see if this zone is new or already in list bool found = false; - for (auto &z : c->zoneNum) { + for (auto const &z : c->zoneNum) { if (z == zoneIndex) { found = true; break; @@ -817,7 +817,6 @@ void ReportCoilSelection::doFinalProcessingOfCoilData(EnergyPlusData &state) c->coilDesWaterTempDiff = -999.0; c->plantDesCapacity = -999.0; c->coilCapPrcntPlantCap = -999.0; - c->coilFlowPrcntPlantFlow = -999.0; } c->cpDryAir = Psychrometrics::PsyCpAirFnW(0.0); @@ -1645,7 +1644,7 @@ void ReportCoilSelection::setCoilHeatingCapacity( } } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) { - auto &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum); + auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum); c->zoneNum.resize(1); c->zoneName.resize(1); c->zoneNum[0] = curZoneEqNum; @@ -1667,7 +1666,7 @@ void ReportCoilSelection::setCoilHeatingCapacity( c->rmSensibleAtPeak = finalZoneSizing.DesHeatLoad; - auto &zoneEqSizing = state.dataSize->ZoneEqSizing(curZoneEqNum); + auto const &zoneEqSizing = state.dataSize->ZoneEqSizing(curZoneEqNum); if (zoneEqSizing.OAVolFlow > 0.0) { c->oaPeakVolFlow = zoneEqSizing.OAVolFlow; } else if (zoneEqSizing.ATMixerVolFlow > 0.0) { @@ -1809,15 +1808,15 @@ void ReportCoilSelection::setCoilHeatingCapacity( if (state.dataSize->DataFlowUsedForSizing > 0.0) { // flow has been set in global, so use it c->coilDesVolFlow = state.dataSize->DataFlowUsedForSizing; } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) { - auto &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum); + auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum); if (finalZoneSizing.DesHeatMassFlow >= HVAC::SmallMassFlow) { c->coilDesMassFlow = finalZoneSizing.DesHeatMassFlow; c->coilDesVolFlow = c->coilDesMassFlow / state.dataEnvrn->StdRhoAir; } } else if (curSysNum > 0 && curSysNum <= int(state.dataSize->FinalSysSizing.size())) { - auto &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum); + auto const &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum); if (curOASysNum > 0 && allocated(state.dataSize->OASysEqSizing)) { - auto &oASysEqSizing = state.dataSize->OASysEqSizing(curSysNum); + auto const &oASysEqSizing = state.dataSize->OASysEqSizing(curSysNum); if (oASysEqSizing.AirFlow) { c->coilDesVolFlow = oASysEqSizing.AirVolFlow; } else if (oASysEqSizing.HeatingAirFlow) { @@ -1829,7 +1828,7 @@ void ReportCoilSelection::setCoilHeatingCapacity( if (state.dataSize->DataFlowUsedForSizing > 0.0) { c->coilDesVolFlow = state.dataSize->DataFlowUsedForSizing; } else if (curSysNum > 0 && allocated(state.dataSize->UnitarySysEqSizing)) { - auto &unitarySysEqSizing = state.dataSize->UnitarySysEqSizing(curSysNum); + auto const &unitarySysEqSizing = state.dataSize->UnitarySysEqSizing(curSysNum); if (unitarySysEqSizing.AirFlow) { c->coilDesVolFlow = unitarySysEqSizing.AirVolFlow; } else if (unitarySysEqSizing.HeatingAirFlow) { @@ -2060,7 +2059,7 @@ bool ReportCoilSelection::isCompTypeCoil(std::string const &compType // string c void ReportCoilSelection::setZoneLatentLoadCoolingIdealPeak(int const zoneIndex, Real64 const zoneCoolingLatentLoad) { // loop over all the coils and the zones in the coils and if this zone index is in the coil - for (auto &c : coilSelectionDataObjs) { + for (auto const &c : coilSelectionDataObjs) { if (c->isCooling) { for (std::size_t zoneInd = 0; zoneInd < c->zoneNum.size(); ++zoneInd) { @@ -2076,7 +2075,7 @@ void ReportCoilSelection::setZoneLatentLoadCoolingIdealPeak(int const zoneIndex, void ReportCoilSelection::setZoneLatentLoadHeatingIdealPeak(int const zoneIndex, Real64 const zoneHeatingLatentLoad) { // loop over all the coils and the zones in the coils and if this zone index is in the coil - for (auto &c : coilSelectionDataObjs) { + for (auto const &c : coilSelectionDataObjs) { if (c->isHeating) { for (std::size_t zoneInd = 0; zoneInd < c->zoneNum.size(); ++zoneInd) { From e6aa09e1db9a442dd39e68cfb23402bbb97b5132 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 16:39:59 -0400 Subject: [PATCH 46/99] reduce and unused --- src/EnergyPlus/ResultsFramework.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/EnergyPlus/ResultsFramework.cc b/src/EnergyPlus/ResultsFramework.cc index 0649abad7e9..ffa6854ee30 100644 --- a/src/EnergyPlus/ResultsFramework.cc +++ b/src/EnergyPlus/ResultsFramework.cc @@ -715,8 +715,6 @@ namespace ResultsFramework { if (data.empty()) return; updateReportFreq(reportingFrequency); std::vector indices; - std::unordered_set seen; - std::string search_string; std::string reportFrequency = data.at("ReportFrequency").get(); if (reportFrequency == "Detailed-HVAC" || reportFrequency == "Detailed-Zone") { @@ -724,7 +722,7 @@ namespace ResultsFramework { } auto const &columns = data.at("Cols"); for (auto const &column : columns) { - search_string = + std::string search_string = fmt::format("{0} [{1}]({2})", column.at("Variable").get(), column.at("Units").get(), reportFrequency); auto found = std::find(outputVariables.begin(), outputVariables.end(), search_string); if (found == outputVariables.end()) { From 2709afe94357e11752232e7688f35c3e3a9cb15b Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 16:44:52 -0400 Subject: [PATCH 47/99] reduce --- src/EnergyPlus/ReturnAirPathManager.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/EnergyPlus/ReturnAirPathManager.cc b/src/EnergyPlus/ReturnAirPathManager.cc index 701d2edc1f0..be12c864a7b 100644 --- a/src/EnergyPlus/ReturnAirPathManager.cc +++ b/src/EnergyPlus/ReturnAirPathManager.cc @@ -111,17 +111,9 @@ namespace ReturnAirPathManager { using NodeInputManager::GetOnlySingleNode; using namespace DataLoopNode; - // Locals - int PathNum; - int CompNum; - int NumAlphas; - int NumNums; - int IOStat; - int Counter; //////////// hoisted into namespace //////////////////////////////////////////////// // static bool ErrorsFound( false ); //////////////////////////////////////////////////////////////////////////////////// - bool IsNotOK; // Flag to verify name bool ErrorsFound = false; @@ -133,10 +125,13 @@ namespace ReturnAirPathManager { state.dataZoneEquip->NumReturnAirPaths = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataZoneEquip->NumReturnAirPaths > 0) { + int NumAlphas; + int NumNums; + int IOStat; state.dataZoneEquip->ReturnAirPath.allocate(state.dataZoneEquip->NumReturnAirPaths); - for (PathNum = 1; PathNum <= state.dataZoneEquip->NumReturnAirPaths; ++PathNum) { + for (int PathNum = 1; PathNum <= state.dataZoneEquip->NumReturnAirPaths; ++PathNum) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, @@ -170,13 +165,14 @@ namespace ReturnAirPathManager { state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName = ""; state.dataZoneEquip->ReturnAirPath(PathNum).ComponentIndex.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents); state.dataZoneEquip->ReturnAirPath(PathNum).ComponentIndex = 0; - Counter = 3; + int Counter = 3; - for (CompNum = 1; CompNum <= state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents; ++CompNum) { + for (int CompNum = 1; CompNum <= state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents; ++CompNum) { if ((Util::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ZoneMixer")) || (Util::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ReturnPlenum"))) { + bool IsNotOK; // Flag to verify name state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType(CompNum) = state.dataIPShortCut->cAlphaArgs(Counter); state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName(CompNum) = state.dataIPShortCut->cAlphaArgs(Counter + 1); ValidateComponent(state, From 96b6822531fb2dfeb6dad63636384992883a6975 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 16:57:13 -0400 Subject: [PATCH 48/99] reduce and const --- src/EnergyPlus/RoomAirModelAirflowNetwork.cc | 64 ++++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelAirflowNetwork.cc b/src/EnergyPlus/RoomAirModelAirflowNetwork.cc index 01fbcadae2a..5a76dd6d188 100644 --- a/src/EnergyPlus/RoomAirModelAirflowNetwork.cc +++ b/src/EnergyPlus/RoomAirModelAirflowNetwork.cc @@ -124,7 +124,7 @@ namespace RoomAir { // METHODOLOGY EMPLOYED: // calls subroutines (LOL) - auto &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(zoneNum); + auto const &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(zoneNum); // model control volume for each roomAir:node in the zone. for (int roomAirNodeNum = 1; roomAirNodeNum <= afnZoneInfo.NumOfAirNodes; ++roomAirNodeNum) { @@ -174,7 +174,6 @@ namespace RoomAir { Array1D_bool NodeFound; // True if a node is found. Array1D_bool EquipFound; - bool ErrorsFound = false; Array1D SupplyFrac; Array1D ReturnFrac; @@ -184,9 +183,9 @@ namespace RoomAir { for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) { auto &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(iZone); if (!afnZoneInfo.IsUsed) continue; - int NumSurfs = 0; + int NumSurfs = 0; // NumSurfs isn't used anywhere? for (int spaceNum : state.dataHeatBal->Zone(iZone).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); NumSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1; } @@ -231,7 +230,7 @@ namespace RoomAir { if (allocated(state.dataZoneEquip->ZoneEquipConfig) && allocated(state.dataZoneEquip->ZoneEquipList)) { int MaxNodeNum = 0; int MaxEquipNum = 0; - ErrorsFound = false; + bool ErrorsFound = false; for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) { if (!state.dataHeatBal->Zone(iZone).IsControlled) continue; MaxEquipNum = max(MaxEquipNum, state.dataZoneEquip->ZoneEquipList(iZone).NumOfEquipTypes); @@ -614,7 +613,7 @@ namespace RoomAir { // PURPOSE OF THIS SUBROUTINE: // update variables - auto &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(zoneNum); + auto const &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(zoneNum); if (!afnZoneInfo.IsUsed) return; @@ -788,7 +787,7 @@ namespace RoomAir { int surfCount = 0; for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) { ++surfCount; if (afnZoneInfo.ControlAirNodeID == roomAirNodeNum) { @@ -936,7 +935,7 @@ namespace RoomAir { int surfCount = 1; for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum, ++surfCount) { auto const &surf = state.dataSurface->Surface(SurfNum); if (surf.Class == SurfaceClass::Window) continue; @@ -952,13 +951,13 @@ namespace RoomAir { if (!afnZoneInfo.Node(roomAirNodeNum).SurfMask(surfCount)) continue; } - auto &HMassConvInFD = state.dataMstBal->HMassConvInFD; - auto &RhoVaporSurfIn = state.dataMstBal->RhoVaporSurfIn; - auto &RhoVaporAirIn = state.dataMstBal->RhoVaporAirIn; + auto const &HMassConvInFD = state.dataMstBal->HMassConvInFD(SurfNum); + auto &RhoVaporSurfIn = state.dataMstBal->RhoVaporSurfIn(SurfNum); + auto &RhoVaporAirIn = state.dataMstBal->RhoVaporAirIn(SurfNum); if (surf.HeatTransferAlgorithm == DataSurfaces::HeatTransferModel::HAMT) { UpdateHeatBalHAMT(state, SurfNum); - SumHmAW += HMassConvInFD(SurfNum) * surf.Area * (RhoVaporSurfIn(SurfNum) - RhoVaporAirIn(SurfNum)); + SumHmAW += HMassConvInFD * surf.Area * (RhoVaporSurfIn - RhoVaporAirIn); Real64 RhoAirZone = PsyRhoAirFnPbTdbW( state, @@ -966,35 +965,34 @@ namespace RoomAir { state.dataZoneTempPredictorCorrector->zoneHeatBalance(surf.Zone).MAT, PsyRhFnTdbRhov(state, state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataSurface->Surface(SurfNum).Zone).MAT, - RhoVaporAirIn(SurfNum), + RhoVaporAirIn, "RhoAirZone")); - Real64 Wsurf = - PsyWFnTdbRhPb(state, - state.dataHeatBalSurf->SurfTempInTmp(SurfNum), - PsyRhFnTdbRhov(state, state.dataHeatBalSurf->SurfTempInTmp(SurfNum), RhoVaporSurfIn(SurfNum), "Wsurf"), - state.dataEnvrn->OutBaroPress); + Real64 Wsurf = PsyWFnTdbRhPb(state, + state.dataHeatBalSurf->SurfTempInTmp(SurfNum), + PsyRhFnTdbRhov(state, state.dataHeatBalSurf->SurfTempInTmp(SurfNum), RhoVaporSurfIn, "Wsurf"), + state.dataEnvrn->OutBaroPress); - SumHmARa += HMassConvInFD(SurfNum) * surf.Area * RhoAirZone; - SumHmARaW += HMassConvInFD(SurfNum) * surf.Area * RhoAirZone * Wsurf; + SumHmARa += HMassConvInFD * surf.Area * RhoAirZone; + SumHmARaW += HMassConvInFD * surf.Area * RhoAirZone * Wsurf; } else if (surf.HeatTransferAlgorithm == DataSurfaces::HeatTransferModel::EMPD) { UpdateMoistureBalanceEMPD(state, SurfNum); - RhoVaporSurfIn(SurfNum) = state.dataMstBalEMPD->RVSurface(SurfNum); - - SumHmAW += HMassConvInFD(SurfNum) * surf.Area * (RhoVaporSurfIn(SurfNum) - RhoVaporAirIn(SurfNum)); - SumHmARa += HMassConvInFD(SurfNum) * surf.Area * - PsyRhoAirFnPbTdbW( - state, - state.dataEnvrn->OutBaroPress, - state.dataHeatBalSurf->SurfTempInTmp(SurfNum), - PsyWFnTdbRhPb(state, - state.dataHeatBalSurf->SurfTempInTmp(SurfNum), - PsyRhFnTdbRhovLBnd0C(state, state.dataHeatBalSurf->SurfTempInTmp(SurfNum), RhoVaporAirIn(SurfNum)), - state.dataEnvrn->OutBaroPress)); - SumHmARaW += HMassConvInFD(SurfNum) * surf.Area * RhoVaporSurfIn(SurfNum); + RhoVaporSurfIn = state.dataMstBalEMPD->RVSurface(SurfNum); + + SumHmAW += HMassConvInFD * surf.Area * (RhoVaporSurfIn - RhoVaporAirIn); + SumHmARa += + HMassConvInFD * surf.Area * + PsyRhoAirFnPbTdbW(state, + state.dataEnvrn->OutBaroPress, + state.dataHeatBalSurf->SurfTempInTmp(SurfNum), + PsyWFnTdbRhPb(state, + state.dataHeatBalSurf->SurfTempInTmp(SurfNum), + PsyRhFnTdbRhovLBnd0C(state, state.dataHeatBalSurf->SurfTempInTmp(SurfNum), RhoVaporAirIn), + state.dataEnvrn->OutBaroPress)); + SumHmARaW += HMassConvInFD * surf.Area * RhoVaporSurfIn; } } // for (SurfNum) } // for (spaceNum) From ad5337a6b531f6abf72d3efe04fb50e49d181c44 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 17:15:22 -0400 Subject: [PATCH 49/99] const and reduce --- src/EnergyPlus/RoomAirModelManager.cc | 48 ++++++++++++--------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 4d4057c42af..7edcb321faf 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -346,7 +346,7 @@ namespace RoomAir { // figure number of surfaces for this zone airPatternZoneInfo.totNumSurfs = 0; for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); airPatternZoneInfo.totNumSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1; } // allocate nested derived type for surface info @@ -355,7 +355,7 @@ namespace RoomAir { // Fill in what we know for nested structure for surfaces int thisSurfinZone = 0; for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int thisHBsurfID = thisSpace.HTSurfaceFirst; thisHBsurfID <= thisSpace.HTSurfaceLast; ++thisHBsurfID) { ++thisSurfinZone; if (state.dataSurface->Surface(thisHBsurfID).Class == DataSurfaces::SurfaceClass::IntMass) { @@ -696,7 +696,7 @@ namespace RoomAir { } else { int NumOfSurfs = 0; for (int spaceNum : state.dataHeatBal->Zone(airNode.ZonePtr).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); NumOfSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1; } airNode.SurfMask.allocate(NumOfSurfs); @@ -744,7 +744,7 @@ namespace RoomAir { auto const &zone = state.dataHeatBal->Zone(airNode.ZonePtr); int NumOfSurfs = 0; for (int spaceNum : zone.spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); NumOfSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1; } @@ -763,7 +763,7 @@ namespace RoomAir { for (int ListSurfNum = 4; ListSurfNum <= NumAlphas; ++ListSurfNum) { int thisSurfinZone = 0; for (int spaceNum : zone.spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) { ++thisSurfinZone; if (ipsc->cAlphaArgs(ListSurfNum) == state.dataSurface->Surface(SurfNum).Name) { @@ -1339,7 +1339,7 @@ namespace RoomAir { roomAFNZoneInfo.totNumSurfs = 0; for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); roomAFNZoneInfo.totNumSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1; } } // for (Loop) @@ -1429,7 +1429,7 @@ namespace RoomAir { int NumSurfsThisNode = NumAlphas - 1; int NumOfSurfs = 0; // What is this used for? for (int spaceNum : state.dataHeatBal->Zone(iZone).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); NumOfSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1; } @@ -1451,7 +1451,7 @@ namespace RoomAir { int thisSurfinZone = 0; for (int ListSurfNum = 2; ListSurfNum <= NumAlphas; ++ListSurfNum) { for (int spaceNum : state.dataHeatBal->Zone(iZone).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) { ++thisSurfinZone; if (ipsc->cAlphaArgs(ListSurfNum) == state.dataSurface->Surface(SurfNum).Name) { @@ -1648,13 +1648,11 @@ namespace RoomAir { roomAFNNodeHVAC.SupplyFraction = ipsc->rNumericArgs(iEquipArg); roomAFNNodeHVAC.ReturnFraction = ipsc->rNumericArgs(iEquipArg); - // get equipment index - int EquipIndex = 0; + // get equipment type for (int thisZoneEquipNum = 1; thisZoneEquipNum <= state.dataZoneEquip->ZoneEquipList(iZone).NumOfEquipTypes; ++thisZoneEquipNum) { if (Util::SameString(state.dataZoneEquip->ZoneEquipList(iZone).EquipName(thisZoneEquipNum), roomAFNNodeHVAC.Name) && roomAFNNodeHVAC.zoneEquipType == state.dataZoneEquip->ZoneEquipList(iZone).EquipType(thisZoneEquipNum)) { - EquipIndex = state.dataZoneEquip->ZoneEquipList(iZone).EquipIndex(thisZoneEquipNum); break; } } @@ -1841,18 +1839,16 @@ namespace RoomAir { state.dataRoomAir->HDoor = 0.0; int contWall = 0, contFloor = 0, contCeiling = 0, contWindow = 0, contInternal = 0, contDoor = 0; - int contWallBeg = 0, contFloorBeg = 0, contCeilingBeg = 0, contWindowBeg = 0, contInternalBeg = 0, contDoorBeg = 0; - int contWallLast = 0, contFloorLast = 0, contCeilingLast = 0, contWindowLast = 0, contInternalLast = 0, contDoorLast = 0; // Put the surface and zone information in Apos and PosZ arrays for (int ZNum = 1; ZNum <= state.dataGlobal->NumOfZones; ++ZNum) { // advance ONE position in the arrays PosZ because this is a new zone - contWallBeg = contWall + 1; - contFloorBeg = contFloor + 1; - contCeilingBeg = contCeiling + 1; - contWindowBeg = contWindow + 1; - contInternalBeg = contInternal + 1; - contDoorBeg = contDoor + 1; + int contWallBeg = contWall + 1; + int contFloorBeg = contFloor + 1; + int contCeilingBeg = contCeiling + 1; + int contWindowBeg = contWindow + 1; + int contInternalBeg = contInternal + 1; + int contDoorBeg = contDoor + 1; SetZoneAux = true; Real64 Z1ofZone = std::numeric_limits::max(); @@ -1860,7 +1856,7 @@ namespace RoomAir { // cycle in this zone for all the surfaces for (int spaceNum : state.dataHeatBal->Zone(ZNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) { auto const &surf = state.dataSurface->Surface(SurfNum); @@ -1900,12 +1896,12 @@ namespace RoomAir { } } // for (SurfNum) - contWallLast = contWall; - contFloorLast = contFloor; - contCeilingLast = contCeiling; - contWindowLast = contWindow; - contDoorLast = contDoor; - contInternalLast = contInternal; + int contWallLast = contWall; + int contFloorLast = contFloor; + int contCeilingLast = contCeiling; + int contWindowLast = contWindow; + int contDoorLast = contDoor; + int contInternalLast = contInternal; // PosZ_Wall (... + 1) has the Begin Wall reference in Apos_Wall for the ZNum // PosZ_Wall (... + 2) has the End Wall reference in Apos_Wall for the ZNum state.dataRoomAir->PosZ_Wall(ZNum).beg = contWallBeg; From 2e0e6a78e7ca63ff6d63981b02fd4177b91df0c3 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 17:22:55 -0400 Subject: [PATCH 50/99] shadow, reduce and unused --- src/EnergyPlus/RoomAirModelManager.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 7edcb321faf..5eea48174f5 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -1699,7 +1699,7 @@ namespace RoomAir { for (int iGain = 1; iGain <= roomAFNNode.NumIntGains; ++iGain) { auto &intGain = roomAFNNode.IntGain(iGain); if (intGain.FractionCheck) continue; - Real64 SumFraction = roomAFNNode.IntGainsFractions(iGain); + SumFraction = roomAFNNode.IntGainsFractions(iGain); intGain.FractionCheck = true; for (int iRoomAFNNode2 = 1; iRoomAFNNode2 <= roomAFNZoneInfo.NumOfAirNodes; ++iRoomAFNNode2) { @@ -1781,11 +1781,8 @@ namespace RoomAir { Real64 constexpr BaseDischargeCoef(0.62); // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool SetZoneAux; Array1D_int AuxSurf; - int MaxSurf; Array2D_int AuxAirflowNetworkSurf; - int ZoneEquipConfigNum; // counter // Do the one time initializations if (state.dataRoomAir->MyOneTimeFlag) { @@ -1849,7 +1846,6 @@ namespace RoomAir { int contWindowBeg = contWindow + 1; int contInternalBeg = contInternal + 1; int contDoorBeg = contDoor + 1; - SetZoneAux = true; Real64 Z1ofZone = std::numeric_limits::max(); Real64 Z2ofZone = std::numeric_limits::lowest(); @@ -1944,7 +1940,7 @@ namespace RoomAir { } } // calculate maximum number of airflow network surfaces in a single zone - MaxSurf = AuxSurf(1); + int MaxSurf = AuxSurf(1); for (int iZone = 2; iZone <= state.dataGlobal->NumOfZones; ++iZone) { if (AuxSurf(iZone) > MaxSurf) MaxSurf = AuxSurf(iZone); } @@ -2452,7 +2448,7 @@ namespace RoomAir { if (state.dataRoomAir->AirModel(iZone).AirModel != RoomAirModel::CrossVent) continue; // don't set these up if they don't make sense - ZoneEquipConfigNum = ZoneNum; // Where does this ZoneNum come from? + int ZoneEquipConfigNum = ZoneNum; // Where does this ZoneNum come from? auto const &zone = state.dataHeatBal->Zone(iZone); // check whether this zone is a controlled zone or not From 8ef0a65f16910fd3a065a3c1907de754c280a5d7 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 17:26:46 -0400 Subject: [PATCH 51/99] const --- src/EnergyPlus/RoomAirModelUserTempPattern.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelUserTempPattern.cc b/src/EnergyPlus/RoomAirModelUserTempPattern.cc index 6a0738ea74e..e59bb9cab2d 100644 --- a/src/EnergyPlus/RoomAirModelUserTempPattern.cc +++ b/src/EnergyPlus/RoomAirModelUserTempPattern.cc @@ -357,7 +357,7 @@ void FigureTwoGradInterpPattern(EnergyPlusData &state, int const PattrnID, int c Real64 Grad; // vertical temperature gradient C/m auto &patternZoneInfo = state.dataRoomAir->AirPatternZoneInfo(ZoneNum); - auto &pattern = state.dataRoomAir->AirPattern(PattrnID); + auto const &pattern = state.dataRoomAir->AirPattern(PattrnID); if (state.dataRoomAirModelTempPattern->MyOneTimeFlag2) { state.dataRoomAirModelTempPattern->SetupOutputFlag.dimension(state.dataGlobal->NumOfZones, true); // init @@ -491,7 +491,7 @@ void FigureConstGradPattern(EnergyPlusData &state, int const PattrnID, int const // DATE WRITTEN August 2005 auto &patternZoneInfo = state.dataRoomAir->AirPatternZoneInfo(ZoneNum); - auto &pattern = state.dataRoomAir->AirPattern(PattrnID); + auto const &pattern = state.dataRoomAir->AirPattern(PattrnID); Real64 Tmean = patternZoneInfo.TairMean; // MAT Real64 Grad = pattern.GradPatrn.Gradient; // Vertical temperature gradient @@ -539,7 +539,7 @@ Real64 FigureNDheightInZone(EnergyPlusData &state, int const thisHBsurf) // inde Real64 ZMin = 0.0; int Count = 0; for (int spaceNum : zone.spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) { auto const &surf = state.dataSurface->Surface(SurfNum); if (surf.Class == DataSurfaces::SurfaceClass::Floor) { @@ -644,7 +644,7 @@ void SetSurfHBDataForTempDistModel(EnergyPlusData &state, int const ZoneNum) // // What if ZoneNodeID is 0? auto &zoneNode = state.dataLoopNodes->Node(patternZoneInfo.ZoneNodeID); - auto &zone = state.dataHeatBal->Zone(ZoneNum); + auto const &zone = state.dataHeatBal->Zone(ZoneNum); auto &zoneHeatBal = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); int ZoneMult = zone.Multiplier * zone.ListMultiplier; @@ -673,7 +673,7 @@ void SetSurfHBDataForTempDistModel(EnergyPlusData &state, int const ZoneNum) // if (zone.HasAirFlowWindowReturn) { for (int spaceNum : zone.spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) { if (state.dataSurface->SurfWinAirflowThisTS(SurfNum) > 0.0 && state.dataSurface->SurfWinAirflowDestination(SurfNum) == DataSurfaces::WindowAirFlowDestination::Return) { @@ -772,7 +772,7 @@ void SetSurfHBDataForTempDistModel(EnergyPlusData &state, int const ZoneNum) // // set results for all surface for (int spaceNum : zone.spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int i = thisSpace.HTSurfaceFirst, j = 0; i <= thisSpace.HTSurfaceLast; ++i) { state.dataHeatBal->SurfTempEffBulkAir(i) = patternZoneInfo.Surf(++j).TadjacentAir; } @@ -780,7 +780,7 @@ void SetSurfHBDataForTempDistModel(EnergyPlusData &state, int const ZoneNum) // // set flag for reference air temperature mode for (int spaceNum : zone.spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); for (int i = thisSpace.HTSurfaceFirst; i <= thisSpace.HTSurfaceLast; ++i) { state.dataSurface->SurfTAirRef(i) = DataSurfaces::RefAirTemp::AdjacentAirTemp; state.dataSurface->SurfTAirRefRpt(i) = DataSurfaces::SurfTAirRefReportVals[state.dataSurface->SurfTAirRef(i)]; From 15be37a991ac2b8bdb2e033cdddc439e1d2b53dc Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 17:46:51 -0400 Subject: [PATCH 52/99] reduce and conditionals always true --- src/EnergyPlus/RuntimeLanguageProcessor.cc | 40 +++++++--------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index 55dc9cd6380..2f5bbbeda96 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.cc +++ b/src/EnergyPlus/RuntimeLanguageProcessor.cc @@ -118,10 +118,10 @@ void InitializeRuntimeLanguage(EnergyPlusData &state) // value(7) Seconds (0-59) // value(8) Milliseconds (0-999) - std::string datestring; // supposedly returns blank when no date available. - if (state.dataRuntimeLangProcessor->InitializeOnce) { + std::string datestring; // supposedly returns blank when no date available. + state.dataRuntimeLang->emsVarBuiltInStart = state.dataRuntimeLang->NumErlVariables + 1; state.dataRuntimeLang->False = SetErlValueNumber(0.0); @@ -278,11 +278,9 @@ void BeginEnvrnInitializeRuntimeLanguage(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ActuatorUsedLoop; - int EMSActuatorVariableNum; int ErlVariableNum; int TrendVarNum; int SensorNum; - int TrendDepth; int loop; bool CycleThisVariable; @@ -319,7 +317,7 @@ void BeginEnvrnInitializeRuntimeLanguage(EnergyPlusData &state) // reinitialize state of actuators for (ActuatorUsedLoop = 1; ActuatorUsedLoop <= state.dataRuntimeLang->numActuatorsUsed + state.dataRuntimeLang->NumExternalInterfaceActuatorsUsed; ++ActuatorUsedLoop) { - EMSActuatorVariableNum = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop).ActuatorVariableNum; + int EMSActuatorVariableNum = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop).ActuatorVariableNum; ErlVariableNum = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop).ErlVariableNum; state.dataRuntimeLang->ErlVariable(ErlVariableNum).Value.Type = Value::Null; *state.dataRuntimeLang->EMSActuatorAvailable(EMSActuatorVariableNum).Actuated = false; @@ -340,7 +338,7 @@ void BeginEnvrnInitializeRuntimeLanguage(EnergyPlusData &state) // reinitialize trend variables so old data are purged for (TrendVarNum = 1; TrendVarNum <= state.dataRuntimeLang->NumErlTrendVariables; ++TrendVarNum) { - TrendDepth = state.dataRuntimeLang->TrendVariable(TrendVarNum).LogDepth; + int TrendDepth = state.dataRuntimeLang->TrendVariable(TrendVarNum).LogDepth; state.dataRuntimeLang->TrendVariable(TrendVarNum).TrendValARR({1, TrendDepth}) = 0.0; } @@ -1035,32 +1033,19 @@ void ParseExpression(EnergyPlusData &state, // AUTHOR Peter Graham Ellis // DATE WRITTEN June 2006 // MODIFIED Brent Griffith, May 2009 - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Parsing string into a series of tokens - // METHODOLOGY EMPLOYED: - - // Using/Aliasing - - // Locals // SUBROUTINE PARAMETER DEFINITIONS: int constexpr MaxDoLoopCounts(500); - // SUBROUTINE ARGUMENT DEFINITIONS: - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: // CHARACTER(len=120), DIMENSION(MaxErrors) :: Error ! Errors should be stored with the stack int NumErrors; std::string::size_type Pos; std::string StringToken; - char NextChar; bool PeriodFound; - bool MinusFound; - bool PlusFound; - bool MultFound; - bool DivFound; bool ErrorFlag; bool OperatorProcessing; int CountDoLooping; @@ -1088,9 +1073,9 @@ void ParseExpression(EnergyPlusData &state, std::string::size_type LastPos(String.length()); Pos = 0; OperatorProcessing = false; // true when an operator is found until terminated by non-operator - MinusFound = false; - MultFound = false; - DivFound = false; + bool MinusFound = false; + bool MultFound = false; + bool DivFound = false; while (Pos < LastPos) { ++CountDoLooping; if (CountDoLooping > MaxDoLoopCounts) { @@ -1099,7 +1084,7 @@ void ParseExpression(EnergyPlusData &state, ShowContinueError(state, format("...Failed to process String=\"{}\".", String)); ShowFatalError(state, "...program terminates due to preceding condition."); } - NextChar = String[Pos]; + char NextChar = String[Pos]; if (NextChar == ' ') { ++Pos; continue; @@ -1111,7 +1096,7 @@ void ParseExpression(EnergyPlusData &state, // Get the next token StringToken = ""; PeriodFound = false; - PlusFound = false; + bool PlusFound = false; ErrorFlag = false; LastED = false; if (is_any_of(NextChar, "0123456789.")) { @@ -1243,7 +1228,7 @@ void ParseExpression(EnergyPlusData &state, ShowContinueError(state, "...Use parenthesis to wrap appropriate variables. For example, X / ( -Y )."); ++NumErrors; DivFound = false; - } else if (OperatorProcessing && (NextChar == '-')) { + } else if (OperatorProcessing) { // if operator was deterined last pass and this character is a -, then insert a 0 before the minus and treat as subtraction // example: change "Var == -1" to "Var == 0-1" OperatorProcessing = false; @@ -1591,7 +1576,7 @@ int ProcessTokens( state.dataRuntimeLang->ErlExpression(ExpressionNum).Operand(5).Number = Token(Pos + 5).Number; state.dataRuntimeLang->ErlExpression(ExpressionNum).Operand(5).Expression = Token(Pos + 5).Expression; state.dataRuntimeLang->ErlExpression(ExpressionNum).Operand(5).Variable = Token(Pos + 5).Variable; - if ((NumOperands == 5) && (NumTokens - 6 > 0)) { // too many tokens for this non-binary operator + if ((NumTokens - 6) > 0) { // too many tokens for this non-binary operator ShowFatalError(state, "EMS error parsing tokens, too many for built-in function"); } } @@ -2865,8 +2850,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); - } else if (GlobalNum > state.dataRuntimeLang->NumUserGlobalVariables && - GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables) { + } else if (GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables) { cCurrentModuleObject = "ExternalInterface:Variable"; state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, From 0a73ab6ebff0066a02b6b1a3c319eed295581bf5 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 18:10:51 -0400 Subject: [PATCH 53/99] reduce and conditional always true --- src/EnergyPlus/RuntimeLanguageProcessor.cc | 50 +++++++++------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index 2f5bbbeda96..834e0d961b9 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.cc +++ b/src/EnergyPlus/RuntimeLanguageProcessor.cc @@ -1427,7 +1427,6 @@ int ProcessTokens( int LastPos; int TokenNum; int NumTokens; - int Depth; int NumSubTokens; int NewNumTokens; int OperatorNum; @@ -1454,7 +1453,7 @@ int ProcessTokens( while ((Pos > 0) && (ParenthWhileCounter < 50)) { ++ParenthWhileCounter; - Depth = 0; + int Depth = 0; for (TokenNum = 1; TokenNum <= NumTokens; ++TokenNum) { if (Token(TokenNum).Type == Token::Parenthesis) { if (Token(TokenNum).Parenthesis == Token::ParenthesisLeft) { @@ -1718,15 +1717,10 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, // FUNCTION ARGUMENT DEFINITIONS: // FUNCTION LOCAL VARIABLE DECLARATIONS: - int thisTrend; // local temporary - int thisIndex; // local temporary - Real64 thisAverage; // local temporary - int loop; // local temporary - Real64 thisSlope; // local temporary - Real64 thisMax; // local temporary - Real64 thisMin; // local temporary - int OperandNum; - int SeedN; // number of digits in the number used to seed the generator + Real64 thisAverage; // local temporary + Real64 thisSlope; // local temporary + Real64 thisMax; // local temporary + Real64 thisMin; // local temporary Array1D_int SeedIntARR; // local temporary for random seed Real64 tmpRANDU1; // local temporary for uniform random number Real64 tmpRANDU2; // local temporary for uniform random number @@ -1747,7 +1741,7 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, // is there a way to keep these and not allocate and deallocate all the time? Operand.allocate(thisErlExpression.NumOperands); // Reduce operands down to literals - for (OperandNum = 1; OperandNum <= thisErlExpression.NumOperands; ++OperandNum) { + for (int OperandNum = 1; OperandNum <= thisErlExpression.NumOperands; ++OperandNum) { auto &thisOperand = Operand(OperandNum); thisOperand = thisErlExpression.Operand(OperandNum); if (thisOperand.Type == Value::Expression) { @@ -1778,6 +1772,8 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, } if (ReturnValue.Type != Value::Error) { + int thisTrend; // local temporary + int thisIndex; // local temporary // Perform the operation @@ -2025,10 +2021,11 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, break; case ErlFunc::RandSeed: + int SeedN; // number of digits in the number used to seed the generator // convert arg to an integer array for the seed. RANDOM_SEED(SeedN); // obtains processor's use size as output SeedIntARR.allocate(SeedN); - for (loop = 1; loop <= SeedN; ++loop) { + for (int loop = 1; loop <= SeedN; ++loop) { if (loop == 1) { SeedIntARR(loop) = std::floor(Operand(1).Number); } else { @@ -2319,7 +2316,7 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, if (thisIndex == 1) { thisMax = state.dataRuntimeLang->TrendVariable(thisTrend).TrendValARR(1); } else { - for (loop = 2; loop <= thisIndex; ++loop) { + for (int loop = 2; loop <= thisIndex; ++loop) { if (loop == 2) { thisMax = max(state.dataRuntimeLang->TrendVariable(thisTrend).TrendValARR(1), state.dataRuntimeLang->TrendVariable(thisTrend).TrendValARR(2)); @@ -2353,7 +2350,7 @@ ErlValueType EvaluateExpression(EnergyPlusData &state, int const ExpressionNum, if (thisIndex == 1) { thisMin = state.dataRuntimeLang->TrendVariable(thisTrend).TrendValARR(1); } else { - for (loop = 2; loop <= thisIndex; ++loop) { + for (int loop = 2; loop <= thisIndex; ++loop) { if (loop == 2) { thisMin = min(state.dataRuntimeLang->TrendVariable(thisTrend).TrendValARR(1), state.dataRuntimeLang->TrendVariable(thisTrend).TrendValARR(2)); @@ -2707,13 +2704,6 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) constexpr std::string_view RoutineName = "GetRuntimeLanguageUserInput: "; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int GlobalNum; - int StackNum; - int ErrorNum; - int NumAlphas; // Number of elements in the alpha array - int NumNums; // Number of elements in the numeric array - int IOStat; // IO Status when calling get input subroutine - bool ErrorsFound(false); int VariableNum(0); // temporary int RuntimeReportVarNum; bool Found; @@ -2746,6 +2736,11 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) if (state.dataRuntimeLangProcessor->GetInput) { // GetInput check is redundant with the InitializeRuntimeLanguage routine state.dataRuntimeLangProcessor->GetInput = false; + int StackNum; + int NumAlphas; // Number of elements in the alpha array + int NumNums; // Number of elements in the numeric array + int IOStat; // IO Status when calling get input subroutine + bool ErrorsFound = false; cCurrentModuleObject = "EnergyManagementSystem:Sensor"; state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); @@ -2829,7 +2824,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitExportGlobalVariables > 0) { - for (GlobalNum = 1; + for (int GlobalNum = 1; GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitExportGlobalVariables; @@ -2864,8 +2859,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) lAlphaFieldBlanks, cAlphaFieldNames, cNumericFieldNames); - } else if (GlobalNum > state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables && - GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables + + } else if (GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables) { cCurrentModuleObject = "ExternalInterface:FunctionalMockupUnitImport:To:Variable"; state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -2882,9 +2876,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) cAlphaFieldNames, cNumericFieldNames); - } else if (GlobalNum > state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables + - state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables && - GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables + + } else if (GlobalNum <= state.dataRuntimeLang->NumUserGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitExportGlobalVariables) { cCurrentModuleObject = "ExternalInterface:FunctionalMockupUnitExport:To:Variable"; @@ -3224,7 +3216,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) ShowSevereError( state, format("Errors found parsing EMS Runtime Language program or subroutine = {}", state.dataRuntimeLang->ErlStack(StackNum).Name)); - for (ErrorNum = 1; ErrorNum <= state.dataRuntimeLang->ErlStack(StackNum).NumErrors; ++ErrorNum) { + for (int ErrorNum = 1; ErrorNum <= state.dataRuntimeLang->ErlStack(StackNum).NumErrors; ++ErrorNum) { ShowContinueError(state, state.dataRuntimeLang->ErlStack(StackNum).Error(ErrorNum)); } ErrorsFound = true; From f70c84f72b612135ce34446e0a6e2da1a3706713 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 18:56:39 -0400 Subject: [PATCH 54/99] reduce --- src/EnergyPlus/RuntimeLanguageProcessor.cc | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index 834e0d961b9..6f73e1a7d43 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.cc +++ b/src/EnergyPlus/RuntimeLanguageProcessor.cc @@ -2704,16 +2704,9 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) constexpr std::string_view RoutineName = "GetRuntimeLanguageUserInput: "; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int VariableNum(0); // temporary - int RuntimeReportVarNum; - bool Found; OutputProcessor::TimeStepType sovTimeStepType; // temporary OutputProcessor::StoreType sovStoreType; // temporary - std::string EndUseSubCatString; - int TrendNum; - int NumTrendSteps; - int loop; int ErlVarLoop; int CurveIndexNum; int MaxNumAlphas(0); // argument for call to GetObjectDefMaxArgs @@ -2741,6 +2734,8 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine bool ErrorsFound = false; + int VariableNum = 0; // temporary + int RuntimeReportVarNum; cCurrentModuleObject = "EnergyManagementSystem:Sensor"; state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); @@ -2939,7 +2934,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) state.dataRuntimeLang->NumEMSCurveIndices = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataRuntimeLang->NumEMSCurveIndices > 0) { state.dataRuntimeLangProcessor->CurveIndexVariableNums.dimension(state.dataRuntimeLang->NumEMSCurveIndices, 0); - for (loop = 1; loop <= state.dataRuntimeLang->NumEMSCurveIndices; ++loop) { + for (int loop = 1; loop <= state.dataRuntimeLang->NumEMSCurveIndices; ++loop) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, loop, @@ -2999,7 +2994,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) state.dataRuntimeLang->NumEMSConstructionIndices = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataRuntimeLang->NumEMSConstructionIndices > 0) { state.dataRuntimeLangProcessor->ConstructionIndexVariableNums.dimension(state.dataRuntimeLang->NumEMSConstructionIndices, 0); - for (loop = 1; loop <= state.dataRuntimeLang->NumEMSConstructionIndices; ++loop) { + for (int loop = 1; loop <= state.dataRuntimeLang->NumEMSConstructionIndices; ++loop) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, loop, @@ -3137,7 +3132,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) state.dataRuntimeLang->NumErlTrendVariables = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataRuntimeLang->NumErlTrendVariables > 0) { state.dataRuntimeLang->TrendVariable.allocate(state.dataRuntimeLang->NumErlTrendVariables); - for (TrendNum = 1; TrendNum <= state.dataRuntimeLang->NumErlTrendVariables; ++TrendNum) { + for (int TrendNum = 1; TrendNum <= state.dataRuntimeLang->NumErlTrendVariables; ++TrendNum) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, TrendNum, @@ -3172,7 +3167,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) state.dataRuntimeLang->ErlVariable(VariableNum).Value.initialized = true; // Cannot figure out how to get around needing this, } - NumTrendSteps = std::floor(rNumericArgs(1)); + int NumTrendSteps = std::floor(rNumericArgs(1)); if (NumTrendSteps > 0) { state.dataRuntimeLang->TrendVariable(TrendNum).LogDepth = NumTrendSteps; // setup data arrays using NumTrendSteps @@ -3185,7 +3180,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) // current time is zero, each value in trend log array is one zone timestep further back in time // units are hours. all terms negative, getting increasingly negative the further back in time // further back in time is higher index in array - for (loop = 1; loop <= NumTrendSteps; ++loop) { + for (int loop = 1; loop <= NumTrendSteps; ++loop) { if (loop == 1) { state.dataRuntimeLang->TrendVariable(TrendNum).TimeARR(loop) = -state.dataGlobal->TimeStepZone; continue; @@ -3309,7 +3304,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) if (!lAlphaFieldBlanks(5)) { // Lookup the Runtime Language Context, i.e., PROGRAM, FUNCTION, or global - Found = false; + bool Found = false; for (StackNum = 1; StackNum <= state.dataRuntimeLang->NumErlStacks; ++StackNum) { if (state.dataRuntimeLang->ErlStack(StackNum).Name == cAlphaArgs(5)) { Found = true; @@ -3405,7 +3400,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) if (state.dataRuntimeLang->NumEMSMeteredOutputVariables > 0) { cCurrentModuleObject = "EnergyManagementSystem:MeteredOutputVariable"; - for (loop = 1; loop <= state.dataRuntimeLang->NumEMSMeteredOutputVariables; ++loop) { + for (int loop = 1; loop <= state.dataRuntimeLang->NumEMSMeteredOutputVariables; ++loop) { RuntimeReportVarNum = state.dataRuntimeLang->NumEMSOutputVariables + loop; state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, @@ -3482,7 +3477,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) if (!lAlphaFieldBlanks(4)) { // Lookup the Runtime Language Context, i.e., PROGRAM, FUNCTION, or global - Found = false; + bool Found = false; for (StackNum = 1; StackNum <= state.dataRuntimeLang->NumErlStacks; ++StackNum) { if (state.dataRuntimeLang->ErlStack(StackNum).Name == cAlphaArgs(4)) { Found = true; @@ -3626,7 +3621,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) } if (!lAlphaFieldBlanks(8)) { - EndUseSubCatString = cAlphaArgs(8); + std::string EndUseSubCatString = cAlphaArgs(8); SetupOutputVariable(state, cAlphaArgs(1), From 4f8867b07b66f3858999a3d25b1bde21abe5a1e0 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 19:16:47 -0400 Subject: [PATCH 55/99] reduce --- src/EnergyPlus/RuntimeLanguageProcessor.cc | 55 +++++----------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index 6f73e1a7d43..47894f1dd31 100644 --- a/src/EnergyPlus/RuntimeLanguageProcessor.cc +++ b/src/EnergyPlus/RuntimeLanguageProcessor.cc @@ -2707,23 +2707,13 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) OutputProcessor::TimeStepType sovTimeStepType; // temporary OutputProcessor::StoreType sovStoreType; // temporary - int ErlVarLoop; - int CurveIndexNum; - int MaxNumAlphas(0); // argument for call to GetObjectDefMaxArgs - int MaxNumNumbers(0); // argument for call to GetObjectDefMaxArgs - int TotalArgs(0); // argument for call to GetObjectDefMaxArgs Array1D_string cAlphaFieldNames; Array1D_string cNumericFieldNames; Array1D_bool lNumericFieldBlanks; Array1D_bool lAlphaFieldBlanks; Array1D_string cAlphaArgs; Array1D rNumericArgs; - std::string cCurrentModuleObject; - int ConstructNum; - bool errFlag; std::string::size_type lbracket; - std::string UnitsA; - std::string UnitsB; Constant::Units curUnit(Constant::Units::None); std::string::size_type ptr; @@ -2734,13 +2724,17 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) int NumNums; // Number of elements in the numeric array int IOStat; // IO Status when calling get input subroutine bool ErrorsFound = false; + int TotalArgs = 0; // argument for call to GetObjectDefMaxArgs int VariableNum = 0; // temporary int RuntimeReportVarNum; + bool errFlag; + std::string UnitsA; + std::string UnitsB; - cCurrentModuleObject = "EnergyManagementSystem:Sensor"; + std::string cCurrentModuleObject = "EnergyManagementSystem:Sensor"; state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); - MaxNumNumbers = NumNums; - MaxNumAlphas = NumAlphas; + int MaxNumNumbers = NumNums; + int MaxNumAlphas = NumAlphas; cCurrentModuleObject = "EnergyManagementSystem:Actuator"; state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums); MaxNumNumbers = max(MaxNumNumbers, NumNums); @@ -2892,7 +2886,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) } // loop over each alpha and register variable named as global Erl variable - for (ErlVarLoop = 1; ErlVarLoop <= NumAlphas; ++ErlVarLoop) { + for (int ErlVarLoop = 1; ErlVarLoop <= NumAlphas; ++ErlVarLoop) { if ((cCurrentModuleObject.compare("ExternalInterface:FunctionalMockupUnitImport:To:Variable") == 0)) { if (ErlVarLoop == 1) { // Only validate first field of object ExternalInterface:FunctionalMockupUnitImport:To:Variable. @@ -2970,7 +2964,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) } } - CurveIndexNum = GetCurveIndex(state, cAlphaArgs(2)); // curve name + int CurveIndexNum = GetCurveIndex(state, cAlphaArgs(2)); // curve name if (CurveIndexNum == 0) { if (lAlphaFieldBlanks(2)) { ShowSevereError(state, format("{}{}=\"{} blank field.", RoutineName, cCurrentModuleObject, cAlphaArgs(1))); @@ -3032,7 +3026,7 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) continue; } - ConstructNum = Util::FindItemInList(cAlphaArgs(2), state.dataConstruction->Construct); + int ConstructNum = Util::FindItemInList(cAlphaArgs(2), state.dataConstruction->Construct); if (ConstructNum == 0) { if (lAlphaFieldBlanks(2)) { @@ -3251,12 +3245,6 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) lbracket = index(cAlphaArgs(1), '['); if (lbracket == std::string::npos) { - UnitsA = ""; - // if (lAlphaFieldBlanks(6)) then - // CALL ShowWarningError(state, RoutineName//TRIM(cCurrentModuleObject)//'="'//TRIM(cAlphaArgs(1))//' no units - // indicated.') CALL ShowContinueError(state, '...no units indicated for this variable. [] is assumed.') - // cAlphaArgs(1)=TRIM(cAlphaArgs(1))//' []' - // endif UnitsB = cAlphaArgs(6); lbracket = index(UnitsB, '['); ptr = index(UnitsB, ']'); @@ -3424,12 +3412,6 @@ void GetRuntimeLanguageUserInput(EnergyPlusData &state) lbracket = index(cAlphaArgs(1), '['); if (lbracket == std::string::npos) { - UnitsA = ""; - // if (lAlphaFieldBlanks(9)) then - // CALL ShowWarningError(state, RoutineName//TRIM(cCurrentModuleObject)//'="'//TRIM(cAlphaArgs(1))//' no units - // indicated.') CALL ShowContinueError(state, '...no units indicated for this variable. [] is assumed.') - // cAlphaArgs(1)=TRIM(cAlphaArgs(1))//' []' - // endif UnitsB = cAlphaArgs(9); lbracket = index(UnitsB, '['); ptr = index(UnitsB, ']'); @@ -3669,24 +3651,11 @@ void ReportRuntimeLanguage(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR Peter Graham Ellis // DATE WRITTEN June 2006 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - - // METHODOLOGY EMPLOYED: - - // USE STATEMENTS: - - // Locals - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int RuntimeReportVarNum; - int VariableNum; - for (RuntimeReportVarNum = 1; + for (int RuntimeReportVarNum = 1; RuntimeReportVarNum <= state.dataRuntimeLang->NumEMSOutputVariables + state.dataRuntimeLang->NumEMSMeteredOutputVariables; ++RuntimeReportVarNum) { - VariableNum = state.dataRuntimeLangProcessor->RuntimeReportVar(RuntimeReportVarNum).VariableNum; + int VariableNum = state.dataRuntimeLangProcessor->RuntimeReportVar(RuntimeReportVarNum).VariableNum; if (state.dataRuntimeLang->ErlVariable(VariableNum).Value.Type == Value::Number) { state.dataRuntimeLangProcessor->RuntimeReportVar(RuntimeReportVarNum).Value = state.dataRuntimeLang->ErlVariable(VariableNum).Value.Number; From 3a2bcdcce99ebaa583acd7e59b3e0b953176ab07 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 15 Sep 2024 19:24:30 -0400 Subject: [PATCH 56/99] reduce, const and unused --- src/EnergyPlus/SQLiteProcedures.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 731e3ece0d8..b6a1944ffa3 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -104,8 +104,6 @@ bool ParseSQLiteInput(EnergyPlusData &state, bool &writeOutputToSQLite, bool &wr return input; }; - auto &sql_ort = state.dataOutRptTab; - // There can only be 1 "Output:SQLite" auto const instance = instances.value().begin(); auto const &fields = instance.value(); @@ -123,6 +121,8 @@ bool ParseSQLiteInput(EnergyPlusData &state, bool &writeOutputToSQLite, bool &wr } { // "unit_conversion_for_tabular_data" std::string tabularDataUnitConversion = find_input(fields, "unit_conversion_for_tabular_data"); + auto const &sql_ort = state.dataOutRptTab; + if ("UseOutputControlTableStyles" == tabularDataUnitConversion) { // Jan 2021 Note: Since here we do not know weather sql_ort->unitsStyle has been processed or not, // the value "NotFound" is used for the option "UseOutputControlTableStyles" at this point; @@ -1577,7 +1577,6 @@ void SQLite::createSQLiteTimeIndexRecord(OutputProcessor::ReportFreq const repor bool const warmupFlag) { if (m_writeOutputToSQLite) { - int intStartMinute = 0; int intervalInMinutes = 60; static std::vector lastDayOfMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; @@ -1595,7 +1594,7 @@ void SQLite::createSQLiteTimeIndexRecord(OutputProcessor::ReportFreq const repor ++m_sqlDBTimeIndex; int intEndMinute = static_cast(endMinute + 0.5); - intStartMinute = static_cast(startMinute + 0.5); + int intStartMinute = static_cast(startMinute + 0.5); int t_hour = hour; intervalInMinutes = intEndMinute - intStartMinute; adjustReportingHourAndMinutes(t_hour, intEndMinute); @@ -2611,7 +2610,7 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr { sqlite3 *m_connection = nullptr; if (m_writeOutputToSQLite) { - int rc = -1; + int rc; bool ok = true; std::string const dbName_utf8 = FileSystem::toGenericString(dbName); From 42f793aa2348ac79df113fba1f3578470de1c655 Mon Sep 17 00:00:00 2001 From: rraustad Date: Mon, 16 Sep 2024 10:49:08 -0400 Subject: [PATCH 57/99] Revert argument change for NEWTON function --- src/EnergyPlus/Photovoltaics.cc | 4 ++-- src/EnergyPlus/Photovoltaics.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index b2d2fbcc873..71bd03b907d 100644 --- a/src/EnergyPlus/Photovoltaics.cc +++ b/src/EnergyPlus/Photovoltaics.cc @@ -1497,8 +1497,8 @@ namespace Photovoltaics { Real64 &XX, std::function FXX, std::function DER, - Real64 const II, // Autodesk Aliased to XX in some calls - Real64 const VV, // Autodesk Aliased to XX in some calls + Real64 const &II, // Autodesk Aliased to XX in some calls + Real64 const &VV, // Autodesk Aliased to XX in some calls Real64 const IO, Real64 const IL, Real64 const RSER, diff --git a/src/EnergyPlus/Photovoltaics.hh b/src/EnergyPlus/Photovoltaics.hh index e875c56aaa5..7bc631f5bea 100644 --- a/src/EnergyPlus/Photovoltaics.hh +++ b/src/EnergyPlus/Photovoltaics.hh @@ -135,8 +135,8 @@ namespace Photovoltaics { Real64 &XX, std::function FXX, std::function DER, - Real64 const II, // Autodesk Aliased to XX in some calls, this is absolutely wacky and needs to go - Real64 const VV, // Autodesk Aliased to XX in some calls, this too + Real64 const &II, // Autodesk Aliased to XX in some calls, this is absolutely wacky and needs to go + Real64 const &VV, // Autodesk Aliased to XX in some calls, this too Real64 const IO, Real64 const IL, Real64 const RSER, From 013c03bd2eaf2b2c456b64656820ed82fa393aa0 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 20:42:58 -0400 Subject: [PATCH 58/99] reduce, unused, clean --- src/EnergyPlus/ScheduleManager.cc | 60 +++++-------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 83184a58b25..dd22b14e98b 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -199,8 +199,6 @@ namespace ScheduleManager { bool ErrorsFound(false); bool NumErrorFlag; int SchedTypePtr; - std::string CFld; // Character field for error message - // CHARACTER(len=20) CFld1 ! Character field for error message int NumHrDaySchedules; // Number of "hourly" dayschedules int NumIntDaySchedules; // Number of "interval" dayschedules int NumExternalInterfaceSchedules; // Number of "PtolemyServer ExternalInterface" "compact" Schedules @@ -229,8 +227,6 @@ namespace ScheduleManager { int CurMinute; int MinutesPerItem; int NumExpectedItems; - int MaxNums; - int MaxAlps; int AddWeekSch; int AddDaySch; Array1D_bool AllDays(maxDayTypes); @@ -252,14 +248,12 @@ namespace ScheduleManager { int kdy; // for SCHEDULE:FILE int rowCnt; - std::string subString; int iDay; int hDay; int jHour; int kDayType; Real64 curHrVal; std::string::size_type sPos; - std::string CurrentModuleObject; // for ease in getting objects int MaxNums1; char ColumnSep; bool FileIntervalInterpolated; @@ -276,10 +270,10 @@ namespace ScheduleManager { } state.dataScheduleMgr->ScheduleInputProcessed = true; - MaxNums = 1; // Need at least 1 number because it's used as a local variable in the Schedule Types loop - MaxAlps = 0; + int MaxNums = 1; // Need at least 1 number because it's used as a local variable in the Schedule Types loop + int MaxAlps = 0; - CurrentModuleObject = "ScheduleTypeLimits"; + std::string CurrentModuleObject = "ScheduleTypeLimits"; state.dataScheduleMgr->NumScheduleTypes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); if (state.dataScheduleMgr->NumScheduleTypes > 0) { state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, Count, NumAlphas, NumNumbers); @@ -531,7 +525,7 @@ namespace ScheduleManager { if (rowCnt != rowLimitCount) { if (rowCnt < rowLimitCount) { ShowSevereError(state, format("{}{}=\"{}\" {} data values read.", RoutineName, CurrentModuleObject, Alphas(1), rowCnt)); - } else if (rowCnt > rowLimitCount) { + } else { ShowSevereError(state, format("{}{}=\"{}\" too many data values read.", RoutineName, CurrentModuleObject, Alphas(1))); } ShowContinueError( @@ -1847,14 +1841,6 @@ namespace ScheduleManager { "{}{}=\"{}\" less than {} hourly values read from file.", RoutineName, CurrentModuleObject, Alphas(1), numHourlyValues)); ShowContinueError(state, format("..Number read={}.", (rowCnt * 60) / MinutesPerItem)); } - if (rowCnt < rowLimitCount) { - ShowWarningError( - state, format("{}{}=\"{}\" less than specified hourly values read from file.", RoutineName, CurrentModuleObject, Alphas(1))); - ShowContinueError(state, - format("..Specified Number of Hourly Values={} Actual number of hourly values included={}", - numHourlyValues, - (rowCnt * 60) / MinutesPerItem)); - } // process the data into the normal schedule data structures // note -- schedules are ALWAYS 366 days so some special measures have to be done at 29 Feb "day of year" (60) @@ -3786,7 +3772,6 @@ namespace ScheduleManager { SetScheduleMinMax(state, ScheduleIndex); } MinValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; - MinValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; } // Min/max for schedule has been set. Test. @@ -4133,8 +4118,6 @@ namespace ScheduleManager { // FUNCTION LOCAL VARIABLE DECLARATIONS: Real64 MinValue(0.0); // For total minimum Real64 MaxValue(0.0); // For total maximum - bool MinValueOk; - bool MaxValueOk; if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { MinValue = 1.0; @@ -4152,8 +4135,8 @@ namespace ScheduleManager { } // Min/max for schedule has been set. Test. - MinValueOk = true; - MaxValueOk = true; + bool MinValueOk; + bool MaxValueOk; if (exclusiveMin) { MinValueOk = (MinValue > Minimum); @@ -4181,8 +4164,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function checks the indicated schedule values for validity. Uses the ScheduleIndex @@ -4193,29 +4174,8 @@ namespace ScheduleManager { // looks up minimum and maximum values for the schedule and then sets result of function based on // requested minimum/maximum checks. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - bool CheckDayScheduleValueMinMax; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); // For total minimum + Real64 MinValue = 0.0; // For total minimum bool MinValueOk; if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { @@ -4231,17 +4191,13 @@ namespace ScheduleManager { } // Min/max for schedule has been set. Test. - MinValueOk = true; - if (exclusiveMin) { MinValueOk = (MinValue > Minimum); } else { MinValueOk = (FLT_EPSILON >= Minimum - MinValue); } - CheckDayScheduleValueMinMax = MinValueOk; - - return CheckDayScheduleValueMinMax; + return MinValueOk; } bool HasFractionalScheduleValue(EnergyPlusData &state, int const ScheduleIndex) // Which Schedule being tested From 7d43f6db1611d84dc071b29b85296d0978cf83ab Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 20:52:49 -0400 Subject: [PATCH 59/99] reduce and clean --- src/EnergyPlus/ScheduleManager.cc | 77 ++++--------------------------- 1 file changed, 9 insertions(+), 68 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index dd22b14e98b..b0c6a3b6b65 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -2840,8 +2840,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the internal pointer to Schedule "ScheduleName". @@ -2849,10 +2847,6 @@ namespace ScheduleManager { // Return value int GetScheduleIndex; - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int DayCtr; - int WeekCtr; - if (!state.dataScheduleMgr->ScheduleInputProcessed) { ProcessScheduleInput(state); state.dataScheduleMgr->ScheduleInputProcessed = true; @@ -2863,11 +2857,11 @@ namespace ScheduleManager { if (GetScheduleIndex > 0) { if (!state.dataScheduleMgr->Schedule(GetScheduleIndex).Used) { state.dataScheduleMgr->Schedule(GetScheduleIndex).Used = true; - for (WeekCtr = 1; WeekCtr <= 366; ++WeekCtr) { + for (int WeekCtr = 1; WeekCtr <= 366; ++WeekCtr) { if (state.dataScheduleMgr->Schedule(GetScheduleIndex).WeekSchedulePointer(WeekCtr) > 0) { state.dataScheduleMgr->WeekSchedule(state.dataScheduleMgr->Schedule(GetScheduleIndex).WeekSchedulePointer(WeekCtr)).Used = true; - for (DayCtr = 1; DayCtr <= maxDayTypes; ++DayCtr) { + for (int DayCtr = 1; DayCtr <= maxDayTypes; ++DayCtr) { state.dataScheduleMgr ->DaySchedule(state.dataScheduleMgr ->WeekSchedule(state.dataScheduleMgr->Schedule(GetScheduleIndex).WeekSchedulePointer(WeekCtr)) @@ -2890,45 +2884,20 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Jason Glazer // DATE WRITTEN July 2007 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the internal pointer to Schedule "ScheduleName" (actually, it doesn't do that) - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // Return value std::string TypeOfSchedule; - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int curSchType; - if (!state.dataScheduleMgr->ScheduleInputProcessed) { ProcessScheduleInput(state); state.dataScheduleMgr->ScheduleInputProcessed = true; } if ((ScheduleIndex > 0) && (ScheduleIndex <= state.dataScheduleMgr->NumSchedules)) { - curSchType = state.dataScheduleMgr->Schedule(ScheduleIndex).ScheduleTypePtr; + int curSchType = state.dataScheduleMgr->Schedule(ScheduleIndex).ScheduleTypePtr; if ((curSchType > 0) && (curSchType <= state.dataScheduleMgr->NumScheduleTypes)) { TypeOfSchedule = state.dataScheduleMgr->ScheduleType(curSchType).Name; } else { @@ -3364,43 +3333,13 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda K Lawrie // DATE WRITTEN January 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: - // This subroutine decodes a hhmm date field input as part of the "until" time in a schedule - // representation. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 rRetHH; // real Returned "hour" - Real64 rRetMM; // real Returned "minute" - bool nonIntegral; - std::string hHour; - std::string mMinute; + // This subroutine decodes a hhmm date field input as part of the "until" time in a schedule representation. std::string String = stripped(FieldValue); std::string::size_type const Pos = index(String, ':'); - nonIntegral = false; + bool nonIntegral = false; if (Pos == std::string::npos) { ShowSevereError(state, format("ProcessScheduleInput: DecodeHHMMField, Invalid \"until\" field submitted (no : separator in hh:mm)={}", @@ -3412,7 +3351,7 @@ namespace ScheduleManager { RetHH = 0; } else { bool error = false; - rRetHH = Util::ProcessNumber(String.substr(0, Pos), error); + Real64 rRetHH = Util::ProcessNumber(String.substr(0, Pos), error); RetHH = int(rRetHH); if (double(RetHH) != rRetHH || error || rRetHH < 0.0) { if (double(RetHH) != rRetHH && rRetHH >= 0.0) { @@ -3435,7 +3374,7 @@ namespace ScheduleManager { String.erase(0, Pos + 1); bool error = false; - rRetMM = Util::ProcessNumber(String, error); + Real64 rRetMM = Util::ProcessNumber(String, error); RetMM = int(rRetMM); if (double(RetMM) != rRetMM || error || rRetMM < 0.0) { if (double(RetMM) != rRetMM && rRetMM >= 0.0) { @@ -3456,6 +3395,8 @@ namespace ScheduleManager { } if (nonIntegral) { + std::string hHour; // these haven't been initialized? + std::string mMinute; ShowContinueError(state, format("Until value to be used will be: {:2.2F}:{:2.2F}", hHour, mMinute)); } if (interpolationKind == ScheduleInterpolation::No) { From 00365e5bf8f1fc2dcce79db1631d8498507845f6 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 20:58:45 -0400 Subject: [PATCH 60/99] reduce and clean --- src/EnergyPlus/ScheduleManager.cc | 53 ++++++------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index b0c6a3b6b65..83bfd4cc095 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -3463,7 +3463,6 @@ namespace ScheduleManager { // na // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int DayT; bool OneValid; bool DupAssignment; @@ -3612,7 +3611,7 @@ namespace ScheduleManager { OneValid = true; } if (has(ForDayField, "ALLOTHERDAY")) { - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { + for (int DayT = 1; DayT <= maxDayTypes; ++DayT) { if (AlReady(DayT)) continue; TheseDays(DayT) = true; AlReady(DayT) = true; @@ -4237,43 +4236,13 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: - // This function returns the minimum value used by a schedule over - // the entire year. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - Real64 MinimumValue; // Minimum value for schedule - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na + // This function returns the minimum value used by a schedule over the entire year. // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); - Real64 MaxValue(0.0); - int WkSch; - int DayT; - int Loop; + Real64 MinValue = 0.0; + Real64 MaxValue = 0.0; if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { MinValue = 1.0; @@ -4287,10 +4256,10 @@ namespace ScheduleManager { if (ScheduleIndex > 0) { if (!state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet) { // Set Minimum/Maximums for this schedule - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); + int WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); MinValue = minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); MaxValue = maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); - for (DayT = 2; DayT <= maxDayTypes; ++DayT) { + for (int DayT = 2; DayT <= maxDayTypes; ++DayT) { MinValue = min(MinValue, minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); @@ -4299,10 +4268,10 @@ namespace ScheduleManager { maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); } int prevWkSch = -999; // set to a value that would never occur - for (Loop = 2; Loop <= 366; ++Loop) { + for (int Loop = 2; Loop <= 366; ++Loop) { WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); if (WkSch != prevWkSch) { // skip if same as previous week (very common) - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { + for (int DayT = 1; DayT <= maxDayTypes; ++DayT) { MinValue = min( MinValue, minval( @@ -4321,12 +4290,10 @@ namespace ScheduleManager { } // Min/max for schedule has been set. - MinimumValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; + return state.dataScheduleMgr->Schedule(ScheduleIndex).MinValue; } else { - MinimumValue = MinValue; + return MinValue; } - - return MinimumValue; } Real64 GetScheduleMaxValue(EnergyPlusData &state, int const ScheduleIndex) // Which Schedule being tested From e1dc26df2fec3513f3b0088a8c666fba7f0dfd31 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 21:05:07 -0400 Subject: [PATCH 61/99] reduce and clean --- src/EnergyPlus/ScheduleManager.cc | 50 ++++++------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 83bfd4cc095..9688424a1dd 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -4301,43 +4301,13 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: - // This function returns the maximum value used by a schedule over - // the entire year. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - Real64 MaximumValue; // Maximum value for schedule - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na + // This function returns the maximum value used by a schedule over the entire year. // FUNCTION LOCAL VARIABLE DECLARATIONS: - Real64 MinValue(0.0); - Real64 MaxValue(0.0); - int WkSch; - int DayT; - int Loop; + Real64 MinValue = 0.0; + Real64 MaxValue = 0.0; if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { MinValue = 1.0; @@ -4351,10 +4321,10 @@ namespace ScheduleManager { if (ScheduleIndex > 0) { if (!state.dataScheduleMgr->Schedule(ScheduleIndex).MaxMinSet) { // Set Minimum/Maximums for this schedule - WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); + int WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(1); MinValue = minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); MaxValue = maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(1)).TSValue); - for (DayT = 2; DayT <= maxDayTypes; ++DayT) { + for (int DayT = 2; DayT <= maxDayTypes; ++DayT) { MinValue = min(MinValue, minval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); @@ -4363,10 +4333,10 @@ namespace ScheduleManager { maxval(state.dataScheduleMgr->DaySchedule(state.dataScheduleMgr->WeekSchedule(WkSch).DaySchedulePointer(DayT)).TSValue)); } int prevWkSch = -999; // set to a value that would never occur - for (Loop = 2; Loop <= 366; ++Loop) { + for (int Loop = 2; Loop <= 366; ++Loop) { WkSch = state.dataScheduleMgr->Schedule(ScheduleIndex).WeekSchedulePointer(Loop); if (WkSch != prevWkSch) { // skip if same as previous week (very common) - for (DayT = 1; DayT <= maxDayTypes; ++DayT) { + for (int DayT = 1; DayT <= maxDayTypes; ++DayT) { MinValue = min( MinValue, minval( @@ -4386,12 +4356,10 @@ namespace ScheduleManager { // Min/max for schedule has been set. - MaximumValue = state.dataScheduleMgr->Schedule(ScheduleIndex).MaxValue; + return state.dataScheduleMgr->Schedule(ScheduleIndex).MaxValue; } else { - MaximumValue = MaxValue; + return MaxValue; } - - return MaximumValue; } std::pair getScheduleMinMaxByDayType(EnergyPlusData &state, int const ScheduleIndex, DayTypeGroup const days) From db632fc9982f2fb76c326e4d87245963803b73e6 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 21:13:51 -0400 Subject: [PATCH 62/99] reduce, clean and shadow --- src/EnergyPlus/ScheduleManager.cc | 44 +++++++------------------------ 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 9688424a1dd..4bd2f466af7 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -3430,44 +3430,18 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine processes a field "For: day types" and returns // those day types (can be multiple) from field. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Argument array dimensioning EP_SIZE_CHECK(TheseDays, maxDayTypes); EP_SIZE_CHECK(AlReady, maxDayTypes); - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool OneValid; - bool DupAssignment; - - OneValid = false; - DupAssignment = false; + bool OneValid = false; + bool DupAssignment = false; // Just test for specific days if (has(ForDayField, "WEEKDAY")) { TheseDays({2, 6}) = true; @@ -3650,19 +3624,19 @@ namespace ScheduleManager { Real64 MinValue = daySched.TSValMin; Real64 MaxValue = daySched.TSValMax; for (int DayT = 2; DayT <= maxDayTypes; ++DayT) { - auto const &daySched = state.dataScheduleMgr->DaySchedule(wkSched.DaySchedulePointer(DayT)); - MinValue = min(MinValue, daySched.TSValMin); - MaxValue = max(MaxValue, daySched.TSValMax); + auto const &daySched2 = state.dataScheduleMgr->DaySchedule(wkSched.DaySchedulePointer(DayT)); + MinValue = min(MinValue, daySched2.TSValMin); + MaxValue = max(MaxValue, daySched2.TSValMax); } int prevWkSch = -999; // set to a value that would never occur for (int Loop = 2; Loop <= 366; ++Loop) { int WkSch = sched.WeekSchedulePointer(Loop); if (WkSch != prevWkSch) { // skip if same as previous week (very common) - auto const &wkSched = state.dataScheduleMgr->WeekSchedule(WkSch); + auto const &wkSched2 = state.dataScheduleMgr->WeekSchedule(WkSch); for (int DayT = 1; DayT <= maxDayTypes; ++DayT) { - auto const &daySched = state.dataScheduleMgr->DaySchedule(wkSched.DaySchedulePointer(DayT)); - MinValue = min(MinValue, daySched.TSValMin); - MaxValue = max(MaxValue, daySched.TSValMax); + auto const &daySched3 = state.dataScheduleMgr->DaySchedule(wkSched2.DaySchedulePointer(DayT)); + MinValue = min(MinValue, daySched3.TSValMin); + MaxValue = max(MaxValue, daySched3.TSValMax); } prevWkSch = WkSch; } From e4c5a04abffe8686236e81314ae37c6e2f186d70 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 21:42:43 -0400 Subject: [PATCH 63/99] const arg and clean --- src/EnergyPlus/ScheduleManager.cc | 31 +++---------------------------- src/EnergyPlus/ScheduleManager.hh | 2 +- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 4bd2f466af7..97309dd43ec 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -3050,14 +3050,12 @@ namespace ScheduleManager { void ExternalInterfaceSetSchedule(EnergyPlusData &state, int &ScheduleIndex, - Real64 &Value // The new value for the schedule + Real64 const Value // The new value for the schedule ) { // FUNCTION INFORMATION: // AUTHOR Michael Wetter // DATE WRITTEN February 2010 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine sets all values of the schedule referenced by 'ScheduleIndex' @@ -3067,32 +3065,9 @@ namespace ScheduleManager { // for supervisory controls or internal gains obtained from real-time occupancy // measurements. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // Using/Aliasing - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int TS; // Counter for Num Of Time Steps in Hour - int Hr; // Hour Counter - // Assign the value of the variable - for (Hr = 1; Hr <= 24; ++Hr) { - for (TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { + for (int Hr = 1; Hr <= 24; ++Hr) { + for (int TS = 1; TS <= state.dataGlobal->NumOfTimeStepInHour; ++TS) { state.dataScheduleMgr->DaySchedule(ScheduleIndex).TSValue(TS, Hr) = Value; } } diff --git a/src/EnergyPlus/ScheduleManager.hh b/src/EnergyPlus/ScheduleManager.hh index 72343930f4a..1ff21fadb33 100644 --- a/src/EnergyPlus/ScheduleManager.hh +++ b/src/EnergyPlus/ScheduleManager.hh @@ -253,7 +253,7 @@ namespace ScheduleManager { void ExternalInterfaceSetSchedule(EnergyPlusData &state, int &ScheduleIndex, - Real64 &Value // The new value for the schedule + Real64 const Value // The new value for the schedule ); void ProcessIntervalFields(EnergyPlusData &state, From 72c2e346cea07b0b6d9ea5c598b2f69f19578374 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 21:46:53 -0400 Subject: [PATCH 64/99] unused, const and clean --- src/EnergyPlus/ScheduleManager.cc | 39 +++---------------------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 97309dd43ec..057cf26ef23 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -223,7 +223,6 @@ namespace ScheduleManager { int NumFields; int SCount; // LOGICAL RptSchedule - int RptLevel; int CurMinute; int MinutesPerItem; int NumExpectedItems; @@ -2316,7 +2315,6 @@ namespace ScheduleManager { NumFields = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); // RptSchedule=.FALSE. - RptLevel = 1; for (Count = 1; Count <= NumFields; ++Count) { state.dataInputProcessing->inputProcessor->getObjectItem( state, CurrentModuleObject, Count, Alphas, NumAlphas, Numbers, NumNumbers, Status); @@ -3720,7 +3718,7 @@ namespace ScheduleManager { MinValueOk = (Minimum == 0.0); MaxValueOk = (Maximum == 0.0); } else if (schedNum > 0 && schedNum <= state.dataScheduleMgr->NumSchedules) { - auto &sched = state.dataScheduleMgr->Schedule(schedNum); + auto const &sched = state.dataScheduleMgr->Schedule(schedNum); if (!sched.MaxMinSet) { SetScheduleMinMax(state, schedNum); } @@ -4359,7 +4357,7 @@ namespace ScheduleManager { auto &weekSch = state.dataScheduleMgr->WeekSchedule(WkSch); for (int jType = 1; jType <= maxDayTypes; ++jType) { if (dayTypeFilter[jType - 1]) { - auto &daySch = state.dataScheduleMgr->DaySchedule(weekSch.DaySchedulePointer(jType)); + auto const &daySch = state.dataScheduleMgr->DaySchedule(weekSch.DaySchedulePointer(jType)); // use precalcuated min and max from SetScheduleMinMax MinValue = min(MinValue, daySch.TSValMin); MaxValue = max(MaxValue, daySch.TSValMax); @@ -4700,42 +4698,11 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Greg Stark // DATE WRITTEN September 2008 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the number of schedules. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - int NumberOfSchedules; - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - - NumberOfSchedules = state.dataScheduleMgr->NumSchedules; - - return NumberOfSchedules; + return state.dataScheduleMgr->NumSchedules; } } // namespace ScheduleManager From 895df00cd9baab69abf319a57b9b35447e5f56e7 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 22:01:27 -0400 Subject: [PATCH 65/99] const --- src/EnergyPlus/ScheduleManager.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/ScheduleManager.hh b/src/EnergyPlus/ScheduleManager.hh index 1ff21fadb33..009aa5d5966 100644 --- a/src/EnergyPlus/ScheduleManager.hh +++ b/src/EnergyPlus/ScheduleManager.hh @@ -380,7 +380,7 @@ namespace ScheduleManager { bool const isItLeapYear // true if it is a leap year containing February 29 ); - int GetNumberOfSchedules(EnergyPlusData &state); + int GetNumberOfSchedules(EnergyPlusData const &state); } // namespace ScheduleManager From 4b723497f5f127a118cf482c0b38517ae4be7484 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 22:40:47 -0400 Subject: [PATCH 66/99] const arg --- src/EnergyPlus/ScheduleManager.cc | 254 ++---------------------------- src/EnergyPlus/ScheduleManager.hh | 2 +- 2 files changed, 10 insertions(+), 246 deletions(-) diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 057cf26ef23..b11ffe98c98 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -151,7 +151,6 @@ namespace ScheduleManager { // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 // MODIFIED Rui Zhang February 2010 - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine processes the schedules input for EnergyPlus. @@ -2663,7 +2662,6 @@ namespace ScheduleManager { // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 // MODIFIED August 2011; adapt Autodesk changes (time reduction) - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the hourly schedule value for the current day. @@ -2673,29 +2671,6 @@ namespace ScheduleManager { // input will equate to 0 indices in arrays -- which has been set up to return legally with // 0.0 values. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Return value - - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - // Checking if valid index is passed is necessary if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { return 1.0; @@ -2714,8 +2689,6 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN August 2011; adapted from Autodesk (time reduction) - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This routine calculates all the scheduled values as a time reduction measure and @@ -2723,28 +2696,7 @@ namespace ScheduleManager { // METHODOLOGY EMPLOYED: // Use internal Schedule data structure to calculate current value. Note that missing values in - // input will equate to 0 indices in arrays -- which has been set up to return legally with - // 0.0 values. - - // REFERENCES: - // na - - // Using/Aliasing - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + // input will equate to 0 indices in arrays -- which has been set up to return legally with 0.0 values. if (!state.dataScheduleMgr->ScheduleInputProcessed) { ProcessScheduleInput(state); @@ -2912,8 +2864,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN August 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the internal pointer to Day Schedule "ScheduleName". @@ -2947,8 +2897,6 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN September 1997 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine returns an entire day's worth of schedule values. @@ -3005,38 +2953,10 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN August 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine returns an entire day's worth of schedule values for a specified Day Schedule Index item. - // METHODOLOGY EMPLOYED: - // Use internal data to fill DayValues array. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Argument array dimensioning - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // na - if (!state.dataScheduleMgr->ScheduleInputProcessed) { ProcessScheduleInput(state); state.dataScheduleMgr->ScheduleInputProcessed = true; @@ -3087,38 +3007,14 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR // DATE WRITTEN - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: - // This subroutine processes the "interval" fields with/without optional "until" in front of - // time (hh:mm). - - // METHODOLOGY EMPLOYED: - // na. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na + // This subroutine processes the "interval" fields with/without optional "until" in front of time (hh:mm). // Argument array dimensioning MinuteValue.dim(60, 24); SetMinuteValue.dim(60, 24); - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int Count; std::string::size_type Pos; @@ -3126,22 +3022,17 @@ namespace ScheduleManager { int MMField; int Hr; int Min; - int SHr; // starting hour - int SMin; // starting minute - int EHr; // ending hour - int EMin; // ending minute - std::string::size_type sFld; int totalMinutes; Real64 incrementPerMinute; Real64 curValue; MinuteValue = 0.0; SetMinuteValue = false; - SHr = 1; - SMin = 1; - EHr = 0; - EMin = 0; - sFld = 0; + int SHr = 1; + int SMin = 1; + int EHr = 0; + int EMin = 0; + std::string::size_type sFld = 0; Real64 StartValue = 0; Real64 EndValue = 0; @@ -3628,8 +3519,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function checks the indicated schedule values for validity. Uses the ScheduleIndex @@ -3822,8 +3711,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN November 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function checks the indicated schedule value for validity. Uses the ScheduleIndex @@ -3833,27 +3720,9 @@ namespace ScheduleManager { // This routine is best used with "discrete" schedules. The routine must traverse all values // in the schedule and compares by equality. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Return value bool CheckScheduleValue; - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: int Loop; // Loop Control variable int DayT; // Day Type Loop control @@ -3895,8 +3764,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN November 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function checks the indicated schedule value for validity. Uses the ScheduleIndex @@ -3906,27 +3773,9 @@ namespace ScheduleManager { // This routine is best used with "discrete" schedules. The routine must traverse all values // in the schedule and compares by equality. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Return value bool CheckScheduleValue; - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: int Loop; // Loop Control variable int DayT; // Day Type Loop control @@ -3969,8 +3818,6 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2003 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function checks the indicated schedule values for validity. Uses the ScheduleIndex @@ -3981,27 +3828,9 @@ namespace ScheduleManager { // looks up minimum and maximum values for the schedule and then sets result of function based on // requested minimum/maximum checks. - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Return value bool CheckDayScheduleValueMinMax; - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: Real64 MinValue(0.0); // For total minimum Real64 MaxValue(0.0); // For total maximum @@ -4092,37 +3921,13 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN March 2008 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: - // This function returns true if the schedule contains fractional - // values [>0, <1]. - - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na + // This function returns true if the schedule contains fractional values [>0, <1]. // Return value bool HasFractions; // True if the schedule has fractional values - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: int WkSch; int DayT; @@ -4394,39 +4199,13 @@ namespace ScheduleManager { // FUNCTION INFORMATION: // AUTHOR Linda K. Lawrie // DATE WRITTEN February 2008 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // This function returns the schedule name from the Schedule Index. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - // Return value std::string ScheduleName; - // Locals - // FUNCTION ARGUMENT DEFINITIONS: - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // FUNCTION LOCAL VARIABLE DECLARATIONS: - // na - if (!state.dataScheduleMgr->ScheduleInputProcessed) { ProcessScheduleInput(state); state.dataScheduleMgr->ScheduleInputProcessed = true; @@ -4450,8 +4229,6 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN February 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine puts the proper current schedule values into the "reporting" @@ -4486,8 +4263,6 @@ namespace ScheduleManager { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN April 2008 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // In response to CR7498, report orphan (unused) schedule items. @@ -4623,13 +4398,9 @@ namespace ScheduleManager { // AUTHOR Linda K. Lawrie // DATE WRITTEN August 2006 // MODIFIED September 2012; Glazer - CR8849 - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: - // This function returns the "average" hours per week for a schedule over - // the entire year. - - // Return value + // This function returns the "average" hours per week for a schedule over the entire year. Real64 WeeksInYear; @@ -4695,13 +4466,6 @@ namespace ScheduleManager { int GetNumberOfSchedules(EnergyPlusData &state) { - // FUNCTION INFORMATION: - // AUTHOR Greg Stark - // DATE WRITTEN September 2008 - - // PURPOSE OF THIS FUNCTION: - // This function returns the number of schedules. - return state.dataScheduleMgr->NumSchedules; } diff --git a/src/EnergyPlus/ScheduleManager.hh b/src/EnergyPlus/ScheduleManager.hh index 009aa5d5966..1ff21fadb33 100644 --- a/src/EnergyPlus/ScheduleManager.hh +++ b/src/EnergyPlus/ScheduleManager.hh @@ -380,7 +380,7 @@ namespace ScheduleManager { bool const isItLeapYear // true if it is a leap year containing February 29 ); - int GetNumberOfSchedules(EnergyPlusData const &state); + int GetNumberOfSchedules(EnergyPlusData &state); } // namespace ScheduleManager From 6d509519c97ccd101d61d9932e38905d29e060af Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 23:38:13 -0400 Subject: [PATCH 67/99] reduce --- src/EnergyPlus/SimAirServingZones.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index 5a8ccc20e53..3edf04c50b6 100644 --- a/src/EnergyPlus/SimAirServingZones.cc +++ b/src/EnergyPlus/SimAirServingZones.cc @@ -172,7 +172,7 @@ void ManageAirLoops(EnergyPlusData &state, // Call the AirLoop Simulation if (state.dataGlobal->SysSizingCalc) { SizeAirLoops(state); - } else if (!state.dataGlobal->SysSizingCalc) { + } else { SimAirLoops(state, FirstHVACIteration, SimZoneEquipment); } @@ -285,16 +285,15 @@ void GetAirPathData(EnergyPlusData &state) int NumParams; int MaxNumbers; int MaxAlphas; - Array1D_string Alphas; // alpha strings returned by GetObjectItem - Array1D_string cAlphaFields; // Alpha field names - Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE. - std::string CurrentModuleObject; // Object type for getting and error messages - int NumNodes; // number of nodes returned by GetNodeNums - Array1D_int NodeNums; // node numbers returned by GetNodeNums - int NodeNum; // a node number - int AirSysNum; // an air system (air loop) number - int OANum; // outside air system index - int NumInList; + Array1D_string Alphas; // alpha strings returned by GetObjectItem + Array1D_string cAlphaFields; // Alpha field names + Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE. + std::string CurrentModuleObject; // Object type for getting and error messages + int NumNodes; // number of nodes returned by GetNodeNums + Array1D_int NodeNums; // node numbers returned by GetNodeNums + int NodeNum; // a node number + int AirSysNum; // an air system (air loop) number + int OANum; // outside air system index int OAMixNum; // outside air mixer index int IOStat; // status number returned by GetObjectItem int NumControllers; // number of controllers @@ -1348,7 +1347,7 @@ void GetAirPathData(EnergyPlusData &state) OANum = GetNumOASystems(state); for (int OASysNum = 1; OASysNum <= OANum; ++OASysNum) { - NumInList = GetOACompListNumber(state, OASysNum); + int NumInList = GetOACompListNumber(state, OASysNum); for (int OACompNum = 1; OACompNum <= NumInList; ++OACompNum) { CompType_Num = GetOACompTypeNum(state, OASysNum, OACompNum); if (CompType_Num == CompType::WaterCoil_DetailedCool || CompType_Num == CompType::WaterCoil_SimpleHeat || From 8a9483a3b9b6a77260b2f6f77b2c977f3397ba6e Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 21 Sep 2024 23:50:11 -0400 Subject: [PATCH 68/99] reduce and clean --- src/EnergyPlus/SimAirServingZones.cc | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index 3edf04c50b6..37bf2c27046 100644 --- a/src/EnergyPlus/SimAirServingZones.cc +++ b/src/EnergyPlus/SimAirServingZones.cc @@ -128,8 +128,7 @@ namespace EnergyPlus::SimAirServingZones { // air systems. // METHODOLOGY EMPLOYED: -// Successive iteration forward from the return air inlet -// to the supply air outlets. +// Successive iteration forward from the return air inlet to the supply air outlets. using namespace DataLoopNode; using namespace DataAirLoop; @@ -2778,7 +2777,6 @@ void SolveAirLoopControllers( // SUBROUTINE INFORMATION // AUTHOR: Dimitri Curtil (LBNL) // DATE WRITTEN: Feb 2006 - // MODIFIED: // RE-ENGINEERED: This is reengineered code that used to be in SimAirLoops() // PURPOSE OF THIS SUBROUTINE: @@ -2792,8 +2790,6 @@ void SolveAirLoopControllers( // (2) The controllers and their actions are simulated. // (3) Steps 2 and 3 are repeated until the control criteria are satisfied. - // REFERENCES: None - // Using/Aliasing using namespace DataHVACControllers; using General::CreateSysTimeIntervalString; @@ -2813,10 +2809,6 @@ void SolveAirLoopControllers( // Maximum iterations of an air system/controllers simulation sequence int constexpr MaxIter(50); - // INTERFACE BLOCK DEFINITIONS: None - - // DERIVED TYPE DEFINITIONS: None - // SUBROUTINE LOCAL VARIABLE DEFINITIONS // TRUE if controller supports speculative warm restart bool AllowWarmRestartFlag; @@ -3224,7 +3216,6 @@ void ReSolveAirLoopControllers( // SUBROUTINE INFORMATION // AUTHOR: Dimitri Curtil (LBNL) // DATE WRITTEN: Feb 2006 - // MODIFIED: // RE-ENGINEERED: This is new code // PURPOSE OF THIS SUBROUTINE: @@ -3336,8 +3327,6 @@ void SimAirLoopComponents(EnergyPlusData &state, // SUBROUTINE INFORMATION // AUTHOR: Dimitri Curtil (LBNL) // DATE WRITTEN: Feb 2006 - // MODIFIED: - // RE-ENGINEERED: // PURPOSE OF THIS SUBROUTINE: // This simulates all components on a particular air loop in the primary air system. @@ -3353,16 +3342,9 @@ void SimAirLoopComponents(EnergyPlusData &state, // Sets duct type of current branch to CurDuctType defined in MODULE DataSizing // Upon exiting, resets both counters to 0. - // SUBROUTINE LOCAL VARIABLE DEFINITIONS: None - int BranchNum; // Branch DO loop index - int CompNum; // Component DO loop index - // std::string CompType; // Component type - // std::string CompName; // Component name - CompType CompType_Num; // Numeric equivalent for CompType - auto &PrimaryAirSystems = state.dataAirSystemsData->PrimaryAirSystems; - for (BranchNum = 1; BranchNum <= PrimaryAirSystems(AirLoopNum).NumBranches; ++BranchNum) { // loop over all branches in air system + for (int BranchNum = 1; BranchNum <= PrimaryAirSystems(AirLoopNum).NumBranches; ++BranchNum) { // loop over all branches in air system UpdateBranchConnections(state, AirLoopNum, BranchNum, BeforeBranchSim); @@ -3370,10 +3352,10 @@ void SimAirLoopComponents(EnergyPlusData &state, state.dataSize->CurDuctType = PrimaryAirSystems(AirLoopNum).Branch(BranchNum).DuctType; // Loop over components in branch - for (CompNum = 1; CompNum <= PrimaryAirSystems(AirLoopNum).Branch(BranchNum).TotalComponents; ++CompNum) { + for (int CompNum = 1; CompNum <= PrimaryAirSystems(AirLoopNum).Branch(BranchNum).TotalComponents; ++CompNum) { // CompType = PrimaryAirSystem( AirLoopNum ).Branch( BranchNum ).Comp( CompNum ).TypeOf; // CompName = PrimaryAirSystem( AirLoopNum ).Branch( BranchNum ).Comp( CompNum ).Name; - CompType_Num = PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).CompType_Num; + CompType CompType_Num = PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).CompType_Num; // Simulate each component on PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Name SimAirLoopComponent(state, From 41e60f5c4b8c3d7e98ff1ae7c98f1ee52dec77ff Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 16:17:46 -0400 Subject: [PATCH 69/99] const arg, const and unused --- src/EnergyPlus/SetPointManager.cc | 36 ++++++++++++++----------------- src/EnergyPlus/SetPointManager.hh | 2 +- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/EnergyPlus/SetPointManager.cc b/src/EnergyPlus/SetPointManager.cc index 3a186e22279..8bdca7554d1 100644 --- a/src/EnergyPlus/SetPointManager.cc +++ b/src/EnergyPlus/SetPointManager.cc @@ -284,7 +284,7 @@ void ManageSetPoints(EnergyPlusData &state) } } // ManageSetPoints() -int GetSetPointManagerIndex(EnergyPlusData &state, std::string const &Name) +int GetSetPointManagerIndex(EnergyPlusData const &state, std::string const &Name) { auto found = state.dataSetPointManager->spmMap.find(Name); return (found != state.dataSetPointManager->spmMap.end()) ? found->second : 0; @@ -1728,7 +1728,6 @@ void InitSetPointManagers(EnergyPlusData &state) int MixedAirNode = 0; int InletBranchNum = 0; int LoopInNode = 0; - bool LookForFan = false; // find the index in the ZoneEquipConfig array of the control zone (the one with the main or only thermostat) int ConZoneNum = 0; @@ -1774,6 +1773,7 @@ void InitSetPointManagers(EnergyPlusData &state) LoopInNode = primaryAirSystem.Branch(InletBranchNum).NodeNumIn; // get the supply fan inlet and outlet nodes if (MixedAirNode > 0) { + bool LookForFan = false; for (auto const &branch : primaryAirSystem.Branch) { for (auto const &comp : branch.Comp) { if (MixedAirNode == comp.NodeNumIn) { @@ -1871,7 +1871,7 @@ void InitSetPointManagers(EnergyPlusData &state) ErrorsFound = true; } - auto &primaryAirSystem = state.dataAirSystemsData->PrimaryAirSystems(spmRAB->airLoopNum); + auto const &primaryAirSystem = state.dataAirSystemsData->PrimaryAirSystems(spmRAB->airLoopNum); if (primaryAirSystem.RABExists) { spmRAB->rabMixInNodeNum = primaryAirSystem.RABMixInNode; spmRAB->supMixInNodeNum = primaryAirSystem.SupMixInNode; @@ -1985,7 +1985,7 @@ void InitSetPointManagers(EnergyPlusData &state) auto &branch = plantLoop.LoopSide(LoopSideLocation::Demand).Branch(BranchNum); for (int CompNum = 1; CompNum <= branch.TotalComponents; ++CompNum) { - auto &comp = branch.Comp(CompNum); + auto const &comp = branch.Comp(CompNum); switch (comp.Type) { case PlantEquipmentType::Chiller_Absorption: @@ -2093,7 +2093,7 @@ void InitSetPointManagers(EnergyPlusData &state) for (int BranchNum2 = 1; BranchNum2 <= supplySide2.TotalBranches; ++BranchNum2) { auto &branch2 = supplySide2.Branch(BranchNum2); for (int CompNum2 = 1; CompNum2 <= branch2.TotalComponents; ++CompNum2) { - auto &comp2 = branch2.Comp(CompNum2); + auto const &comp2 = branch2.Comp(CompNum2); InitType = comp2.Type; if (InitType == ChillerType) { ++NumChiller; @@ -2102,7 +2102,7 @@ void InitSetPointManagers(EnergyPlusData &state) for (int BranchNum3 = 1; BranchNum3 <= supplySide2.TotalBranches; ++BranchNum3) { auto &branch3 = supplySide2.Branch(BranchNum3); for (int CompNum3 = 1; CompNum3 <= branch3.TotalComponents; ++CompNum3) { - auto &comp3 = branch3.Comp(CompNum3); + auto const &comp3 = branch3.Comp(CompNum3); InitType = comp3.Type; if (InitType == PlantEquipmentType::PumpVariableSpeed || InitType == PlantEquipmentType::PumpConstantSpeed) { @@ -2936,8 +2936,8 @@ void SPMMixedAir::calculate(EnergyPlusData &state) this->setPt = refNode.TempSetPoint - (fanOutNode.Temp - fanInNode.Temp); if (this->coolCoilInNodeNum > 0 && this->coolCoilOutNodeNum > 0) { - auto &coolCoilInNode = state.dataLoopNodes->Node(this->coolCoilInNodeNum); - auto &coolCoilOutNode = state.dataLoopNodes->Node(this->coolCoilOutNodeNum); + auto const &coolCoilInNode = state.dataLoopNodes->Node(this->coolCoilInNodeNum); + auto const &coolCoilOutNode = state.dataLoopNodes->Node(this->coolCoilOutNodeNum); Real64 dtFan = fanOutNode.Temp - fanInNode.Temp; Real64 dtCoolCoil = coolCoilInNode.Temp - coolCoilOutNode.Temp; if (dtCoolCoil > 0.0 && this->minCoolCoilOutTemp > state.dataEnvrn->OutDryBulbTemp) { @@ -3088,7 +3088,7 @@ void SPMTempest::calculate(EnergyPlusData &state) for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) { int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum); auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum)); - auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); + auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax; Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired; @@ -3118,7 +3118,7 @@ void SPMTempest::calculate(EnergyPlusData &state) for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesHeated; ++iZoneNum) { int CtrlZoneNum = airToZoneNode.HeatCtrlZoneNums(iZoneNum); auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.HeatZoneInletNodes(iZoneNum)); - auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); + auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax; Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired; Real64 ZoneTemp = zoneNode.Temp; @@ -3137,7 +3137,7 @@ void SPMTempest::calculate(EnergyPlusData &state) for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) { int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum); auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum)); - auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); + auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax; Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired; Real64 ZoneTemp = zoneNode.Temp; @@ -3193,7 +3193,7 @@ void SPMWarmestTempFlow::calculate(EnergyPlusData &state) for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) { int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum); auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum)); - auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); + auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax; Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired; @@ -3377,9 +3377,9 @@ void SPMMultiZoneHum::calculate(EnergyPlusData &state) for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) { int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum); - auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum)); - auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); - auto &zoneMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(CtrlZoneNum); + auto const &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum)); + auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode); + auto const &zoneMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(CtrlZoneNum); Real64 ZoneMassFlowRate = zoneInletNode.MassFlowRate; Real64 MoistureLoad = (this->type == SPMType::MZMinHum || this->type == SPMType::MZMinHumAverage) ? zoneMoistureDemand.OutputRequiredToHumidifyingSP @@ -3935,18 +3935,14 @@ void SPMIdealCondenserEnteringTemp::SetupMeteredVarsForSetPt(EnergyPlusData &sta using namespace DataPlant; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - std::string TypeOfComp; - std::string NameOfComp; - Array1D meteredVars; - int NumVariables; auto &plantLoop = state.dataPlnt->PlantLoop(this->chillerPloc.loopNum); auto &supplySide = plantLoop.LoopSide(this->chillerPloc.loopSideNum); auto &chillerBranch = supplySide.Branch(this->chillerPloc.branchNum); auto &chillerComp = chillerBranch.Comp(this->chillerPloc.compNum); - NumVariables = GetNumMeteredVariables(state, chillerComp.TypeOf, chillerComp.Name); + int NumVariables = GetNumMeteredVariables(state, chillerComp.TypeOf, chillerComp.Name); meteredVars.allocate(NumVariables); GetMeteredVariables(state, chillerComp.Name, meteredVars); diff --git a/src/EnergyPlus/SetPointManager.hh b/src/EnergyPlus/SetPointManager.hh index d3ddac62ea3..8945fce0089 100644 --- a/src/EnergyPlus/SetPointManager.hh +++ b/src/EnergyPlus/SetPointManager.hh @@ -459,7 +459,7 @@ namespace SetPointManager { void calculate(EnergyPlusData &state) override; }; - int GetSetPointManagerIndex(EnergyPlusData &state, std::string const &Name); + int GetSetPointManagerIndex(EnergyPlusData const &state, std::string const &Name); void ManageSetPoints(EnergyPlusData &state); From e61048190ffbd41d35d7a7b8a47ed185e81735a6 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 16:50:32 -0400 Subject: [PATCH 70/99] reduce and const arg --- src/EnergyPlus/SimulationManager.cc | 44 +++++++++++++---------------- src/EnergyPlus/SimulationManager.hh | 4 +-- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 4f5808e0f65..40982c42f2e 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -178,7 +178,6 @@ namespace SimulationManager { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool ErrorsFound(false); - bool TerminalError(false); bool oneTimeUnderwaterBoundaryCheck = true; bool AnyUnderwaterBoundaries = false; @@ -280,9 +279,10 @@ namespace SimulationManager { state.dataReportFlag->DoWeatherInitReporting = true; // Note: All the inputs have been 'gotten' by the time we get here. - bool ErrFound = false; if (state.dataGlobal->DoOutputReporting) { DisplayString(state, "Reporting Surfaces"); + bool ErrFound = false; + bool TerminalError = false; ReportSurfaces(state); @@ -1539,8 +1539,6 @@ namespace SimulationManager { // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN January 2009 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // EnergyPlus does not automatically produce any results files. Because of this, users may not request @@ -1548,26 +1546,22 @@ namespace SimulationManager { // results should be produced (either sizing periods or weather files are run) but no reports are // requested. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool SimPeriods; - bool ReportingRequested; - - ReportingRequested = false; - SimPeriods = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod") > 0); + bool SimPeriods = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod") > 0); if ((state.dataGlobal->DoDesDaySim || state.dataGlobal->DoWeathSim || state.dataGlobal->DoPureLoadCalc) && SimPeriods) { - ReportingRequested = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:SummaryReports") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:TimeBins") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Monthly") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Annual") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Variable") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:MeterFileOnly") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative") > 0 || - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative:MeterFileOnly") > 0); + bool ReportingRequested = + (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:SummaryReports") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:TimeBins") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Monthly") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Annual") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Variable") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:MeterFileOnly") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative") > 0 || + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative:MeterFileOnly") > 0); // Not testing for : Output:SQLite or Output:EnvironmentalImpactFactors if (!ReportingRequested) { ShowWarningError(state, "No reporting elements have been requested. No simulation results produced."); @@ -2650,9 +2644,9 @@ namespace SimulationManager { // EXTERNAL SUBROUTINES: void Resimulate(EnergyPlusData &state, - bool &ResimExt, // Flag to resimulate the exterior energy use simulation - bool &ResimHB, // Flag to resimulate the heat balance simulation (including HVAC) - bool &ResimHVAC // Flag to resimulate the HVAC simulation + bool const ResimExt, // Flag to resimulate the exterior energy use simulation + bool const ResimHB, // Flag to resimulate the heat balance simulation (including HVAC) + bool &ResimHVAC // Flag to resimulate the HVAC simulation ) { diff --git a/src/EnergyPlus/SimulationManager.hh b/src/EnergyPlus/SimulationManager.hh index 86f23c4a5d7..b483d230c51 100644 --- a/src/EnergyPlus/SimulationManager.hh +++ b/src/EnergyPlus/SimulationManager.hh @@ -115,8 +115,8 @@ struct SimulationManagerData : BaseGlobalStruct }; void Resimulate(EnergyPlusData &state, - bool &ResimExt, // Flag to resimulate the exterior energy use simulation - bool &ResimHB, // Flag to resimulate the heat balance simulation (including HVAC) + bool const ResimExt, // Flag to resimulate the exterior energy use simulation + bool const ResimHB, // Flag to resimulate the heat balance simulation (including HVAC) bool &ResimHVAC // Flag to resimulate the HVAC simulation ); From c2bbc70abeb9ef225db7256ac77cbeecb03234cd Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 16:57:48 -0400 Subject: [PATCH 71/99] reduce and duplicate conditional --- src/EnergyPlus/SingleDuct.cc | 41 +++++++++++++++--------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 69f03474ac6..e46478b6e7f 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -2457,7 +2457,6 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; - int SysIndex; // static Array1D_bool MyEnvrnFlag; // static Array1D_bool MySizeFlag; // static Array1D_bool GetGasElecHeatCoilCap; // Gets autosized value of coil capacity @@ -2507,7 +2506,7 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI if (!state.dataSingleDuct->ZoneEquipmentListChecked && state.dataZoneEquip->ZoneEquipInputsFilled) { state.dataSingleDuct->ZoneEquipmentListChecked = true; // Check to see if there is a Air Distribution Unit on the Zone Equipment List - for (SysIndex = 1; SysIndex <= state.dataSingleDuct->NumSDAirTerminal; ++SysIndex) { + for (int SysIndex = 1; SysIndex <= state.dataSingleDuct->NumSDAirTerminal; ++SysIndex) { if (state.dataSingleDuct->sd_airterminal(SysIndex).ADUNum == 0) continue; if (CheckZoneEquipmentList(state, "ZoneHVAC:AirDistributionUnit", @@ -3541,8 +3540,6 @@ void SingleDuctAirTerminal::SizeSys(EnergyPlusData &state) ShowContinueError(state, format("Occurs in AirTerminal Object={}", this->SysName)); ErrorsFound = true; } - } - if (IsAutoSize) { this->MaxReheatWaterVolFlow = MaxReheatWaterVolFlowDes; BaseSizer::reportSizerOutput( state, this->sysType, this->SysName, "Design Size Maximum Reheat Water Flow Rate [m3/s]", MaxReheatWaterVolFlowDes); @@ -3661,8 +3658,6 @@ void SingleDuctAirTerminal::SizeSys(EnergyPlusData &state) ShowContinueError(state, format("Occurs in AirTerminal:SingleDuct:ConstantVolume:Reheat Object={}", this->SysName)); ErrorsFound = true; } - } - if (IsAutoSize) { this->MaxReheatSteamVolFlow = MaxReheatSteamVolFlowDes; BaseSizer::reportSizerOutput( state, this->sysType, this->SysName, "Design Size Maximum Reheat Steam Flow Rate [m3/s]", MaxReheatSteamVolFlowDes); @@ -3801,7 +3796,6 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt Real64 DeltaTemp; int SysOutletNode; // The node number of the terminal unit outlet node int SysInletNode; // the node number of the terminal unit inlet node - int WaterControlNode; // This is the Actuated Reheat Control Node Real64 MaxFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not Real64 MinFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not Real64 QActualHeating; // the heating load seen by the reheat coil @@ -4045,7 +4039,7 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt MaxFlowWater = this->MaxReheatWaterFlow; MinFlowWater = this->MinReheatWaterFlow; } else { - WaterControlNode = this->ReheatControlNode; + int WaterControlNode = this->ReheatControlNode; MaxFlowWater = state.dataLoopNodes->Node(WaterControlNode).MassFlowRateMaxAvail; MinFlowWater = state.dataLoopNodes->Node(WaterControlNode).MassFlowRateMinAvail; } @@ -4341,20 +4335,19 @@ void SingleDuctAirTerminal::SimCBVAV(EnergyPlusData &state, bool const FirstHVAC // na // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 MassFlow; // Total Mass Flow Rate from Hot & Cold Inlets [kg/sec] - Real64 QTotLoad; // Total load based on thermostat setpoint temperature [Watts] - Real64 QZnReq; // Total load to be met by terminal heater [Watts] - Real64 QToHeatSetPt; // Remaining load to heating setpoint [W] - Real64 QSupplyAir; // Zone load met by VAVHeatandCool system - Real64 CpAirZn; // Specific heat of zone air [J/kg-C] - Real64 CpAirSysIn; // Specific heat of VAVHeatandCool box entering air [J/kg-C] - Real64 DeltaTemp; // Temperature difference multiplied by specific heat [J/kg] - Real64 MaxFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not - Real64 MinFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not - Real64 LeakLoadMult; // Load multiplier to adjust for downstream leaks - int SysOutletNode; // The node number of the terminal unit outlet node - int SysInletNode; // The node number of the terminal unit inlet node - int WaterControlNode; // This is the Actuated Reheat Control Node + Real64 MassFlow; // Total Mass Flow Rate from Hot & Cold Inlets [kg/sec] + Real64 QTotLoad; // Total load based on thermostat setpoint temperature [Watts] + Real64 QZnReq; // Total load to be met by terminal heater [Watts] + Real64 QToHeatSetPt; // Remaining load to heating setpoint [W] + Real64 QSupplyAir; // Zone load met by VAVHeatandCool system + Real64 CpAirZn; // Specific heat of zone air [J/kg-C] + Real64 CpAirSysIn; // Specific heat of VAVHeatandCool box entering air [J/kg-C] + Real64 DeltaTemp; // Temperature difference multiplied by specific heat [J/kg] + Real64 MaxFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not + Real64 MinFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not + Real64 LeakLoadMult; // Load multiplier to adjust for downstream leaks + int SysOutletNode; // The node number of the terminal unit outlet node + int SysInletNode; // The node number of the terminal unit inlet node Real64 DummyMdot; Real64 QActualHeating; Real64 MinFlowFrac; // minimum flow fraction (and minimum damper position) @@ -4500,7 +4493,7 @@ void SingleDuctAirTerminal::SimCBVAV(EnergyPlusData &state, bool const FirstHVAC MaxFlowWater = this->MaxReheatWaterFlow; MinFlowWater = this->MinReheatWaterFlow; } else { - WaterControlNode = this->ReheatControlNode; + int WaterControlNode = this->ReheatControlNode; MaxFlowWater = state.dataLoopNodes->Node(WaterControlNode).MassFlowRateMaxAvail; MinFlowWater = state.dataLoopNodes->Node(WaterControlNode).MassFlowRateMinAvail; } @@ -4724,7 +4717,6 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC int SolFlag; Real64 ErrTolerance; Real64 MaxSteamCap; // steam coil capacity at full load - bool ErrorsFound; // returned from mining function call // The calculated load from the Heat Balance QTotLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputRequired; @@ -4785,6 +4777,7 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC // region 1: active cooling with fan on FanOp = 1; if (HCType == HeatingCoilType::SteamAirHeating) { + bool ErrorsFound; // returned from mining function call this->CalcVAVVS(state, FirstHVACIteration, ZoneNodeNum, MinFlowSteam, 0.0, fanType, MaxCoolMassFlow, FanOp, QCoolFanOnMax); this->CalcVAVVS(state, FirstHVACIteration, ZoneNodeNum, MinFlowSteam, 0.0, fanType, MinMassFlow, FanOp, QCoolFanOnMin); // region 2: active heating with fan on From dc07a3eaabd78cee3a2fdacdd60d835786b603bf Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 17:08:58 -0400 Subject: [PATCH 72/99] reduce ref --- src/EnergyPlus/SingleDuct.cc | 77 ++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index e46478b6e7f..14332da6b13 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -6261,7 +6261,6 @@ void setATMixerSizingProperties(EnergyPlusData &state, ) { auto &ZoneEqSizing(state.dataSize->ZoneEqSizing); - auto &FinalSysSizing(state.dataSize->FinalSysSizing); auto &FinalZoneSizing(state.dataSize->FinalZoneSizing); if (inletATMixerIndex == 0) return; // protect this function from bad inputs @@ -6309,6 +6308,7 @@ void setATMixerSizingProperties(EnergyPlusData &state, CheckThisAirSystemForSizing(state, airLoopIndex, SizingDesRunThisAirSys); // check for Sizing:System object if (SizingDesRunThisAirSys) { + auto &finalSysSizing = state.dataSize->FinalSysSizing(airLoopIndex); // set ATMixer outlet air flow rate in ZoneEqSizing array for ATMixer. If this value > 0, then the Sizer will know an ATMixer exists ZoneEqSizing(curZoneEqNum).ATMixerVolFlow = state.dataSingleDuct->SysATMixer(inletATMixerIndex).DesignPrimaryAirVolRate; @@ -6316,29 +6316,27 @@ void setATMixerSizingProperties(EnergyPlusData &state, // If air loop has heating coil use SA conditions, else if OA sys has coils then use precool conditions, else use OA conditions if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).CentralHeatCoilExists) { // if central heating coil exists, ATMixer outlet is assumed to be at supply air conditions described in sizing input - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = FinalSysSizing(airLoopIndex).HeatSupTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = FinalSysSizing(airLoopIndex).HeatSupHumRat; + ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = finalSysSizing.HeatSupTemp; + ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = finalSysSizing.HeatSupHumRat; } else if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).NumOAHeatCoils > 0) { // if no central heating coil exists and an outdoor air coil does exist, then ATMixer outlet is mixture of preheat and return - if (FinalSysSizing(airLoopIndex).DesMainVolFlow == 0.0) { // protect divide by 0 + if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = FinalSysSizing(airLoopIndex).PreheatTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = FinalSysSizing(airLoopIndex).PreheatHumRat; + ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = finalSysSizing.PreheatTemp; + ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = finalSysSizing.PreheatHumRat; } else { // mix preheat condition with return air condition based on OA frac. OA frac should nearly always be 1. // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers - Real64 OutAirFrac = FinalSysSizing(airLoopIndex).DesOutAirVolFlow / FinalSysSizing(airLoopIndex).DesMainVolFlow; + Real64 OutAirFrac = finalSysSizing.DesOutAirVolFlow / finalSysSizing.DesMainVolFlow; OutAirFrac = min(1.0, max(0.0, OutAirFrac)); // calculate humrat based on simple mixing - Real64 CoilInHumRatForSizing = - OutAirFrac * FinalSysSizing(airLoopIndex).PreheatHumRat + (1 - OutAirFrac) * FinalSysSizing(airLoopIndex).HeatRetHumRat; + Real64 CoilInHumRatForSizing = OutAirFrac * finalSysSizing.PreheatHumRat + (1 - OutAirFrac) * finalSysSizing.HeatRetHumRat; // calculate enthalpy based on simple mixing Real64 CoilInEnthalpyForSizing = - OutAirFrac * Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).PreheatTemp, FinalSysSizing(airLoopIndex).PreheatHumRat) + - (1 - OutAirFrac) * - Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).HeatRetTemp, FinalSysSizing(airLoopIndex).HeatRetHumRat); + OutAirFrac * Psychrometrics::PsyHFnTdbW(finalSysSizing.PreheatTemp, finalSysSizing.PreheatHumRat) + + (1 - OutAirFrac) * Psychrometrics::PsyHFnTdbW(finalSysSizing.HeatRetTemp, finalSysSizing.HeatRetHumRat); // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); @@ -6348,24 +6346,22 @@ void setATMixerSizingProperties(EnergyPlusData &state, } } else { // else no coils exist in air loop so mix OA condition with return air condition - if (FinalSysSizing(airLoopIndex).DesMainVolFlow == 0.0) { // protect divide by 0 + if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = FinalSysSizing(airLoopIndex).HeatOutTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = FinalSysSizing(airLoopIndex).HeatOutHumRat; + ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = finalSysSizing.HeatOutTemp; + ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = finalSysSizing.HeatOutHumRat; } else { // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers - Real64 OutAirFrac = FinalSysSizing(airLoopIndex).DesOutAirVolFlow / FinalSysSizing(airLoopIndex).DesMainVolFlow; + Real64 OutAirFrac = finalSysSizing.DesOutAirVolFlow / finalSysSizing.DesMainVolFlow; OutAirFrac = min(1.0, max(0.0, OutAirFrac)); // calculate humrat based on simple mixing - Real64 CoilInHumRatForSizing = - OutAirFrac * FinalSysSizing(airLoopIndex).HeatOutHumRat + (1 - OutAirFrac) * FinalSysSizing(airLoopIndex).HeatRetHumRat; + Real64 CoilInHumRatForSizing = OutAirFrac * finalSysSizing.HeatOutHumRat + (1 - OutAirFrac) * finalSysSizing.HeatRetHumRat; // calculate enthalpy based on simple mixing Real64 CoilInEnthalpyForSizing = - OutAirFrac * Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).HeatOutTemp, FinalSysSizing(airLoopIndex).HeatOutHumRat) + - (1 - OutAirFrac) * - Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).HeatRetTemp, FinalSysSizing(airLoopIndex).HeatRetHumRat); + OutAirFrac * Psychrometrics::PsyHFnTdbW(finalSysSizing.HeatOutTemp, finalSysSizing.HeatOutHumRat) + + (1 - OutAirFrac) * Psychrometrics::PsyHFnTdbW(finalSysSizing.HeatRetTemp, finalSysSizing.HeatRetHumRat); // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); @@ -6378,29 +6374,27 @@ void setATMixerSizingProperties(EnergyPlusData &state, // If air loop has cooling coil use SA conditions, else if OA sys has coils then use precool conditions, else use OA conditions if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).CentralCoolCoilExists) { // if central cooling coil exists, ATMixer outlet is assumed to be at supply air conditions described in sizing input - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = FinalSysSizing(airLoopIndex).CoolSupTemp; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = FinalSysSizing(airLoopIndex).CoolSupHumRat; + ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = finalSysSizing.CoolSupTemp; + ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = finalSysSizing.CoolSupHumRat; } else if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).NumOACoolCoils > 0) { // if no central cooling coil exists and an outdoor air coil does exist, then ATMixer outlet is mixture of precool and return - if (FinalSysSizing(airLoopIndex).DesMainVolFlow == 0.0) { // protect divide by 0 + if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = FinalSysSizing(airLoopIndex).PrecoolTemp; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = FinalSysSizing(airLoopIndex).PrecoolHumRat; + ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = finalSysSizing.PrecoolTemp; + ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = finalSysSizing.PrecoolHumRat; } else { // mix precool condition with return air condition based on OA frac. OA frac should nearly always be 1. // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers - Real64 OutAirFrac = FinalSysSizing(airLoopIndex).DesOutAirVolFlow / FinalSysSizing(airLoopIndex).DesMainVolFlow; + Real64 OutAirFrac = finalSysSizing.DesOutAirVolFlow / finalSysSizing.DesMainVolFlow; OutAirFrac = min(1.0, max(0.0, OutAirFrac)); // calculate humrat based on simple mixing - Real64 CoilInHumRatForSizing = - OutAirFrac * FinalSysSizing(airLoopIndex).PrecoolHumRat + (1 - OutAirFrac) * FinalSysSizing(airLoopIndex).RetHumRatAtCoolPeak; + Real64 CoilInHumRatForSizing = OutAirFrac * finalSysSizing.PrecoolHumRat + (1 - OutAirFrac) * finalSysSizing.RetHumRatAtCoolPeak; // calculate enthalpy based on simple mixing Real64 CoilInEnthalpyForSizing = - OutAirFrac * Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).PrecoolTemp, FinalSysSizing(airLoopIndex).PrecoolHumRat) + - (1 - OutAirFrac) * - Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).RetTempAtCoolPeak, FinalSysSizing(airLoopIndex).RetHumRatAtCoolPeak); + OutAirFrac * Psychrometrics::PsyHFnTdbW(finalSysSizing.PrecoolTemp, finalSysSizing.PrecoolHumRat) + + (1 - OutAirFrac) * Psychrometrics::PsyHFnTdbW(finalSysSizing.RetTempAtCoolPeak, finalSysSizing.RetHumRatAtCoolPeak); // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); @@ -6410,24 +6404,23 @@ void setATMixerSizingProperties(EnergyPlusData &state, } } else { // else no coils exist in air loop so mix OA condition with return air condition - if (FinalSysSizing(airLoopIndex).DesMainVolFlow == 0.0) { // protect divide by 0 + if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = FinalSysSizing(airLoopIndex).OutTempAtCoolPeak; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = FinalSysSizing(airLoopIndex).OutHumRatAtCoolPeak; + ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = finalSysSizing.OutTempAtCoolPeak; + ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = finalSysSizing.OutHumRatAtCoolPeak; } else { // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers - Real64 OutAirFrac = FinalSysSizing(airLoopIndex).DesOutAirVolFlow / FinalSysSizing(airLoopIndex).DesMainVolFlow; + Real64 OutAirFrac = finalSysSizing.DesOutAirVolFlow / finalSysSizing.DesMainVolFlow; OutAirFrac = min(1.0, max(0.0, OutAirFrac)); // calculate humrat based on simple mixing - Real64 CoilInHumRatForSizing = OutAirFrac * FinalSysSizing(airLoopIndex).OutHumRatAtCoolPeak + - (1 - OutAirFrac) * FinalSysSizing(airLoopIndex).RetHumRatAtCoolPeak; + Real64 CoilInHumRatForSizing = + OutAirFrac * finalSysSizing.OutHumRatAtCoolPeak + (1 - OutAirFrac) * finalSysSizing.RetHumRatAtCoolPeak; // calculate enthalpy based on simple mixing - Real64 CoilInEnthalpyForSizing = OutAirFrac * Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).OutTempAtCoolPeak, - FinalSysSizing(airLoopIndex).OutHumRatAtCoolPeak) + - (1 - OutAirFrac) * Psychrometrics::PsyHFnTdbW(FinalSysSizing(airLoopIndex).RetTempAtCoolPeak, - FinalSysSizing(airLoopIndex).RetHumRatAtCoolPeak); + Real64 CoilInEnthalpyForSizing = + OutAirFrac * Psychrometrics::PsyHFnTdbW(finalSysSizing.OutTempAtCoolPeak, finalSysSizing.OutHumRatAtCoolPeak) + + (1 - OutAirFrac) * Psychrometrics::PsyHFnTdbW(finalSysSizing.RetTempAtCoolPeak, finalSysSizing.RetHumRatAtCoolPeak); // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); From 7d05d2f25e34c53c749acb9a99ab695ea6b53148 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 17:13:58 -0400 Subject: [PATCH 73/99] reduce ref --- src/EnergyPlus/SingleDuct.cc | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 14332da6b13..3511b45d3db 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -6260,7 +6260,6 @@ void setATMixerSizingProperties(EnergyPlusData &state, int const curZoneEqNum // current zone equipment being simulated ) { - auto &ZoneEqSizing(state.dataSize->ZoneEqSizing); auto &FinalZoneSizing(state.dataSize->FinalZoneSizing); if (inletATMixerIndex == 0) return; // protect this function from bad inputs @@ -6309,21 +6308,22 @@ void setATMixerSizingProperties(EnergyPlusData &state, if (SizingDesRunThisAirSys) { auto &finalSysSizing = state.dataSize->FinalSysSizing(airLoopIndex); + auto &zoneEqSizing = state.dataSize->ZoneEqSizing(curZoneEqNum); // set ATMixer outlet air flow rate in ZoneEqSizing array for ATMixer. If this value > 0, then the Sizer will know an ATMixer exists - ZoneEqSizing(curZoneEqNum).ATMixerVolFlow = state.dataSingleDuct->SysATMixer(inletATMixerIndex).DesignPrimaryAirVolRate; + zoneEqSizing.ATMixerVolFlow = state.dataSingleDuct->SysATMixer(inletATMixerIndex).DesignPrimaryAirVolRate; // If air loop has heating coil use SA conditions, else if OA sys has coils then use precool conditions, else use OA conditions if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).CentralHeatCoilExists) { // if central heating coil exists, ATMixer outlet is assumed to be at supply air conditions described in sizing input - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = finalSysSizing.HeatSupTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = finalSysSizing.HeatSupHumRat; + zoneEqSizing.ATMixerHeatPriDryBulb = finalSysSizing.HeatSupTemp; + zoneEqSizing.ATMixerHeatPriHumRat = finalSysSizing.HeatSupHumRat; } else if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).NumOAHeatCoils > 0) { // if no central heating coil exists and an outdoor air coil does exist, then ATMixer outlet is mixture of preheat and return if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = finalSysSizing.PreheatTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = finalSysSizing.PreheatHumRat; + zoneEqSizing.ATMixerHeatPriDryBulb = finalSysSizing.PreheatTemp; + zoneEqSizing.ATMixerHeatPriHumRat = finalSysSizing.PreheatHumRat; } else { // mix preheat condition with return air condition based on OA frac. OA frac should nearly always be 1. // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers @@ -6341,15 +6341,15 @@ void setATMixerSizingProperties(EnergyPlusData &state, // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = CoilInTempForSizing; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = CoilInHumRatForSizing; + zoneEqSizing.ATMixerHeatPriDryBulb = CoilInTempForSizing; + zoneEqSizing.ATMixerHeatPriHumRat = CoilInHumRatForSizing; } } else { // else no coils exist in air loop so mix OA condition with return air condition if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = finalSysSizing.HeatOutTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = finalSysSizing.HeatOutHumRat; + zoneEqSizing.ATMixerHeatPriDryBulb = finalSysSizing.HeatOutTemp; + zoneEqSizing.ATMixerHeatPriHumRat = finalSysSizing.HeatOutHumRat; } else { // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers Real64 OutAirFrac = finalSysSizing.DesOutAirVolFlow / finalSysSizing.DesMainVolFlow; @@ -6366,22 +6366,22 @@ void setATMixerSizingProperties(EnergyPlusData &state, // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriDryBulb = CoilInTempForSizing; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = CoilInHumRatForSizing; + zoneEqSizing.ATMixerHeatPriDryBulb = CoilInTempForSizing; + zoneEqSizing.ATMixerHeatPriHumRat = CoilInHumRatForSizing; } } // If air loop has cooling coil use SA conditions, else if OA sys has coils then use precool conditions, else use OA conditions if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).CentralCoolCoilExists) { // if central cooling coil exists, ATMixer outlet is assumed to be at supply air conditions described in sizing input - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = finalSysSizing.CoolSupTemp; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = finalSysSizing.CoolSupHumRat; + zoneEqSizing.ATMixerCoolPriDryBulb = finalSysSizing.CoolSupTemp; + zoneEqSizing.ATMixerCoolPriHumRat = finalSysSizing.CoolSupHumRat; } else if (state.dataAirSystemsData->PrimaryAirSystems(airLoopIndex).NumOACoolCoils > 0) { // if no central cooling coil exists and an outdoor air coil does exist, then ATMixer outlet is mixture of precool and return if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = finalSysSizing.PrecoolTemp; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = finalSysSizing.PrecoolHumRat; + zoneEqSizing.ATMixerCoolPriDryBulb = finalSysSizing.PrecoolTemp; + zoneEqSizing.ATMixerCoolPriHumRat = finalSysSizing.PrecoolHumRat; } else { // mix precool condition with return air condition based on OA frac. OA frac should nearly always be 1. // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers @@ -6399,15 +6399,15 @@ void setATMixerSizingProperties(EnergyPlusData &state, // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = CoilInTempForSizing; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = CoilInHumRatForSizing; + zoneEqSizing.ATMixerCoolPriDryBulb = CoilInTempForSizing; + zoneEqSizing.ATMixerCoolPriHumRat = CoilInHumRatForSizing; } } else { // else no coils exist in air loop so mix OA condition with return air condition if (finalSysSizing.DesMainVolFlow == 0.0) { // protect divide by 0 // doesn't matter, just pick a condition - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = finalSysSizing.OutTempAtCoolPeak; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = finalSysSizing.OutHumRatAtCoolPeak; + zoneEqSizing.ATMixerCoolPriDryBulb = finalSysSizing.OutTempAtCoolPeak; + zoneEqSizing.ATMixerCoolPriHumRat = finalSysSizing.OutHumRatAtCoolPeak; } else { // OA frac is based on air loop fraction, not ATMixer flow fraction since air loop can serve multiple ATMixers Real64 OutAirFrac = finalSysSizing.DesOutAirVolFlow / finalSysSizing.DesMainVolFlow; @@ -6425,8 +6425,8 @@ void setATMixerSizingProperties(EnergyPlusData &state, // back calculate temperature based on humrat and enthalpy state points Real64 CoilInTempForSizing = Psychrometrics::PsyTdbFnHW(CoilInEnthalpyForSizing, CoilInHumRatForSizing); - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = CoilInTempForSizing; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = CoilInHumRatForSizing; + zoneEqSizing.ATMixerCoolPriDryBulb = CoilInTempForSizing; + zoneEqSizing.ATMixerCoolPriHumRat = CoilInHumRatForSizing; } } From d18f0be612f6a7097057831ee6688de66a0b34a5 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 17:22:06 -0400 Subject: [PATCH 74/99] reduce ref --- src/EnergyPlus/SingleDuct.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 3511b45d3db..3202175b73e 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -6260,7 +6260,6 @@ void setATMixerSizingProperties(EnergyPlusData &state, int const curZoneEqNum // current zone equipment being simulated ) { - auto &FinalZoneSizing(state.dataSize->FinalZoneSizing); if (inletATMixerIndex == 0) return; // protect this function from bad inputs if (controlledZoneNum == 0) return; @@ -6270,28 +6269,29 @@ void setATMixerSizingProperties(EnergyPlusData &state, // ATMixer properties only affect coil sizing when the mixer is on the inlet side of zone equipment if (state.dataSingleDuct->SysATMixer(inletATMixerIndex).type == HVAC::MixerType::SupplySide) { // check if user has selected No to account for DOAS system - if (FinalZoneSizing.allocated() && state.dataSingleDuct->SysATMixer(inletATMixerIndex).printWarning) { - if (!FinalZoneSizing(curZoneEqNum).AccountForDOAS && FinalZoneSizing(curZoneEqNum).DOASControlStrategy != DOASControl::NeutralSup) { + if (state.dataSize->FinalZoneSizing.allocated() && state.dataSingleDuct->SysATMixer(inletATMixerIndex).printWarning) { + auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum); + if (!finalZoneSizing.AccountForDOAS && finalZoneSizing.DOASControlStrategy != DOASControl::NeutralSup) { ShowWarningError(state, format("AirTerminal:SingleDuct:Mixer: {}", state.dataSingleDuct->SysATMixer(inletATMixerIndex).Name)); ShowContinueError( state, " Supply side Air Terminal Mixer does not adjust zone equipment coil sizing and may result in inappropriately sized coils."); - ShowContinueError(state, - format(" Set Account for Dedicated Outdoor Air System = Yes in Sizing:Zone object for zone = {}", - FinalZoneSizing(curZoneEqNum).ZoneName)); + ShowContinueError( + state, + format(" Set Account for Dedicated Outdoor Air System = Yes in Sizing:Zone object for zone = {}", finalZoneSizing.ZoneName)); } state.dataSingleDuct->SysATMixer(inletATMixerIndex).printWarning = false; } return; // do nothing else if this is a supply side ATMixer } // check if user has selected Yes to account for DOAS system - if (FinalZoneSizing.allocated() && state.dataSingleDuct->SysATMixer(inletATMixerIndex).printWarning) { - if (FinalZoneSizing(curZoneEqNum).AccountForDOAS && FinalZoneSizing(curZoneEqNum).DOASControlStrategy != DOASControl::NeutralSup) { + if (state.dataSize->FinalZoneSizing.allocated() && state.dataSingleDuct->SysATMixer(inletATMixerIndex).printWarning) { + auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum); + if (finalZoneSizing.AccountForDOAS && finalZoneSizing.DOASControlStrategy != DOASControl::NeutralSup) { ShowWarningError(state, format("AirTerminal:SingleDuct:Mixer: {}", state.dataSingleDuct->SysATMixer(inletATMixerIndex).Name)); ShowContinueError(state, " Inlet side Air Terminal Mixer automatically adjusts zone equipment coil sizing."); - ShowContinueError(state, - format(" Set Account for Dedicated Outdoor Air System = No in Sizing:Zone object for zone = {}", - FinalZoneSizing(curZoneEqNum).ZoneName)); + ShowContinueError( + state, format(" Set Account for Dedicated Outdoor Air System = No in Sizing:Zone object for zone = {}", finalZoneSizing.ZoneName)); state.dataSingleDuct->SysATMixer(inletATMixerIndex).printWarning = false; } } From 062183775740b66320dc67d8e9d84b3806a25a2c Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 17:27:11 -0400 Subject: [PATCH 75/99] clean and reduce --- src/EnergyPlus/SingleDuct.cc | 45 +++++++++++------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 3202175b73e..d1da16d2011 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -5092,33 +5092,17 @@ void SingleDuctAirTerminal::SimConstVol(EnergyPlusData &state, bool const FirstH using SteamCoils::SimulateSteamCoilComponents; using WaterCoils::SimulateWaterCoilComponents; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 MassFlow; // [kg/sec] Total Mass Flow Rate from Hot & Cold Inlets - Real64 QZnReq; // [Watts] - Real64 QToHeatSetPt; // [W] remaining load to heating setpoint - Real64 CpAir; - int WaterControlNode; // This is the Actuated Reheat Control Node - Real64 MaxFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not - Real64 MinFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not - Real64 QActualHeating; // the heating load seen by the reheat coil - Real64 DummyMdot; // local fluid mass flow rate - - QToHeatSetPt = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; // The calculated load from the Heat Balance - MassFlow = this->sd_airterminalInlet.AirMassFlowRateMaxAvail; // System massflow is set to the Available + Real64 MaxFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not + Real64 MinFlowWater; // This is the value passed to the Controller depending if FirstHVACIteration or not + Real64 DummyMdot; // local fluid mass flow rate + + Real64 QToHeatSetPt = + state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP; // The calculated load from the Heat Balance + Real64 MassFlow = this->sd_airterminalInlet.AirMassFlowRateMaxAvail; // System massflow is set to the Available state.dataSingleDuct->QMax2SCV = QToHeatSetPt; state.dataSingleDuct->ZoneTempSCV = state.dataLoopNodes->Node(ZoneNodeNum).Temp; - CpAir = PsyCpAirFnW(state.dataLoopNodes->Node(ZoneNodeNum).HumRat); // zone air specific heat + Real64 CpAir = PsyCpAirFnW(state.dataLoopNodes->Node(ZoneNodeNum).HumRat); // zone air specific heat if (this->MaxReheatTempSetByUser) { state.dataSingleDuct->TAirMaxSCV = this->MaxReheatTemp; state.dataSingleDuct->QMaxSCV = CpAir * MassFlow * (state.dataSingleDuct->TAirMaxSCV - state.dataSingleDuct->ZoneTempSCV); @@ -5144,11 +5128,13 @@ void SingleDuctAirTerminal::SimConstVol(EnergyPlusData &state, bool const FirstH this->sd_airterminalOutlet.AirMassFlowRateMinAvail = this->sd_airterminalInlet.AirMassFlowRateMinAvail; this->UpdateSys(state); - QActualHeating = QToHeatSetPt - MassFlow * CpAir * (this->sd_airterminalInlet.AirTemp - state.dataSingleDuct->ZoneTempSCV); // reheat needed + Real64 QActualHeating = + QToHeatSetPt - MassFlow * CpAir * (this->sd_airterminalInlet.AirTemp - state.dataSingleDuct->ZoneTempSCV); // reheat needed // Now the massflow for reheating has been determined. If it is zero, or in SetBack, or the // system scheduled OFF then not operational and shut the system down. if ((MassFlow > SmallMassFlow) && (QActualHeating > 0.0) && (state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleCooling)) { + Real64 QZnReq; // [Watts] switch (this->ReheatComp_Num) { case HeatingCoilType::SimpleHeating: { // COIL:WATER:SIMPLEHEATING @@ -5168,7 +5154,7 @@ void SingleDuctAirTerminal::SimConstVol(EnergyPlusData &state, bool const FirstH MaxFlowWater = this->MaxReheatWaterFlow; MinFlowWater = this->MinReheatWaterFlow; } else { - WaterControlNode = this->ReheatControlNode; + int WaterControlNode = this->ReheatControlNode; MaxFlowWater = state.dataLoopNodes->Node(WaterControlNode).MassFlowRateMaxAvail; MinFlowWater = state.dataLoopNodes->Node(WaterControlNode).MassFlowRateMinAvail; } @@ -6230,8 +6216,6 @@ void SetATMixerPriFlow(EnergyPlusData &state, // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN April 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This Subroutine sets the primary air mass flow rate on the primary air inlet @@ -6242,11 +6226,8 @@ void SetATMixerPriFlow(EnergyPlusData &state, // parameter is present, or to the maximum available mass flow rate of the primary // air inlet node. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int PriAirNode; // air terminal mixer primary air inlet node number - if (ATMixerNum <= 0) return; - PriAirNode = state.dataSingleDuct->SysATMixer(ATMixerNum).PriInNode; + int const PriAirNode = state.dataSingleDuct->SysATMixer(ATMixerNum).PriInNode; // air terminal mixer primary air inlet node number if (present(PriAirMassFlowRate)) { state.dataLoopNodes->Node(PriAirNode).MassFlowRate = PriAirMassFlowRate; } else { From 89e86c17161f70179f6e1ee04175d038458cc2ac Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 17:49:04 -0400 Subject: [PATCH 76/99] reduce and unused --- src/EnergyPlus/SingleDuct.cc | 78 +++++++++++------------------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index d1da16d2011..19aec487d9a 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -2800,63 +2800,38 @@ void SingleDuctAirTerminal::SizeSys(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int PltSizHeatNum; // index of plant sizing object for 1st heating loop - Real64 DesMassFlow; Real64 TempSteamIn; Real64 EnthSteamOutWet; Real64 EnthSteamInDry; Real64 LatentHeatSteam; Real64 SteamDensity; - bool ErrorsFound; bool PlantSizingErrorsFound; Real64 rho; // local fluid density Real64 Cp; // local fluid specific heat - bool IsAutoSize; - bool IsMaxFlowAutoSize; // Indicate if the maximum terminal flow is autosize - int AirLoopNum; // Air loop number - int SysSizNum; // System sizing number - Real64 MinMinFlowRatio(0.0); // the minimum minimum flow ratio - Real64 MaxAirVolFlowRateDes; // Autosized maximum air flow rate for reporting - Real64 MaxAirVolFlowRateUser; // Hardsized maximum air flow rate for reporting - Real64 MaxHeatAirVolFlowRateDes; // Autosized maximum heating air flow rate for reporting - Real64 MaxHeatAirVolFlowRateUser; // Hardsized maximum heating air flow rate for reporting - Real64 MinAirFlowFracDes; // Autosized minimum cooling air flow fraction for reporting - Real64 MinAirFlowFracUser; // User input minimum cooling air flow fraction for reporting - Real64 FixedMinAirDes; // Autosized minimum cooling air flow rate for reporting [m3/s] - Real64 FixedMinAirUser; // User input minimum cooling air flow rate for reporting [m3/s] - Real64 MaxAirVolFlowRateDuringReheatDes; // Autosized maximum air flow durign reheat for reporting - Real64 MaxAirVolFlowRateDuringReheatUser; // Hardsized maximum air flow durign reheat for reporting - Real64 MaxAirVolFractionDuringReheatDes; // Autosized maximum air fraction durign reheat for reporting - Real64 MaxAirVolFractionDuringReheatUser; // Hardsized maximum air flow durign reheat for reporting - Real64 MaxReheatWaterVolFlowDes; // Autosized reheat water flow or reporting - Real64 MaxReheatWaterVolFlowUser; // Hardsized reheat water flow for reporting - Real64 MaxReheatSteamVolFlowDes; // Autosized reheat steam flow for reporting - Real64 MaxReheatSteamVolFlowUser; // Hardsized reheat steam flow for reporting - - PltSizHeatNum = 0; - DesMassFlow = 0.0; - ErrorsFound = false; - IsAutoSize = false; - IsMaxFlowAutoSize = false; - MaxAirVolFlowRateDes = 0.0; - MaxAirVolFlowRateUser = 0.0; - MaxHeatAirVolFlowRateDes = 0.0; - MaxHeatAirVolFlowRateUser = 0.0; - MinAirFlowFracDes = 0.0; - MinAirFlowFracUser = 0.0; - FixedMinAirDes = 0.0; - FixedMinAirUser = 0.0; - MaxAirVolFlowRateDuringReheatDes = 0.0; - MaxAirVolFlowRateDuringReheatUser = 0.0; - MaxAirVolFractionDuringReheatDes = 0.0; - MaxAirVolFractionDuringReheatUser = 0.0; - MaxReheatWaterVolFlowDes = 0.0; - MaxReheatWaterVolFlowUser = 0.0; - MaxReheatSteamVolFlowDes = 0.0; - MaxReheatSteamVolFlowUser = 0.0; - MinMinFlowRatio = 0.0; - AirLoopNum = 0; - SysSizNum = 0; + + Real64 DesMassFlow = 0.0; + bool ErrorsFound = false; + bool IsAutoSize = false; + bool IsMaxFlowAutoSize = false; + Real64 MaxAirVolFlowRateDes = 0.0; // Autosized maximum air flow rate for reporting + Real64 MaxAirVolFlowRateUser = 0.0; // Hardsized maximum air flow rate for reporting + Real64 MaxHeatAirVolFlowRateDes = 0.0; // Autosized maximum heating air flow rate for reporting + Real64 MaxHeatAirVolFlowRateUser = 0.0; // Hardsized maximum heating air flow rate for reporting + Real64 MinAirFlowFracDes = 0.0; // Autosized minimum cooling air flow fraction for reporting + Real64 MinAirFlowFracUser = 0.0; // User input minimum cooling air flow fraction for reporting + Real64 FixedMinAirDes = 0.0; // Autosized minimum cooling air flow rate for reporting [m3/s] + Real64 FixedMinAirUser = 0.0; // User input minimum cooling air flow rate for reporting [m3/s] + Real64 MaxAirVolFlowRateDuringReheatDes = 0.0; // Autosized maximum air flow durign reheat for reporting + Real64 MaxAirVolFlowRateDuringReheatUser = 0.0; // Hardsized maximum air flow durign reheat for reporting + Real64 MaxAirVolFractionDuringReheatDes = 0.0; // Autosized maximum air fraction durign reheat for reporting + Real64 MaxAirVolFractionDuringReheatUser = 0.0; // Hardsized maximum air flow durign reheat for reporting + Real64 MaxReheatWaterVolFlowDes = 0.0; // Autosized reheat water flow or reporting + Real64 MaxReheatWaterVolFlowUser = 0.0; // Hardsized reheat water flow for reporting + Real64 MaxReheatSteamVolFlowDes = 0.0; // Autosized reheat steam flow for reporting + Real64 MaxReheatSteamVolFlowUser = 0.0; // Hardsized reheat steam flow for reporting + Real64 MinMinFlowRatio = 0.0; // the minimum minimum flow ratio + int SysSizNum = 0; // System sizing number int ZoneNum = this->CtrlZoneNum; @@ -2975,7 +2950,7 @@ void SingleDuctAirTerminal::SizeSys(EnergyPlusData &state) // if a sizing run has been done, check if system sizing has been done for this system bool SizingDesRunThisAirSys = false; if (state.dataSize->SysSizingRunDone) { - AirLoopNum = state.dataZoneEquip->ZoneEquipConfig(this->CtrlZoneNum).InletNodeAirLoopNum(this->CtrlZoneInNodeIndex); + int AirLoopNum = state.dataZoneEquip->ZoneEquipConfig(this->CtrlZoneNum).InletNodeAirLoopNum(this->CtrlZoneInNodeIndex); if (AirLoopNum > 0) { CheckThisAirSystemForSizing(state, AirLoopNum, SizingDesRunThisAirSys); } @@ -4706,7 +4681,6 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC Real64 QNoHeatFanOff; // min heating - fan off, hot water at min flow [W] HeatingCoilType HCType; // heating coil type HVAC::FanType fanType; // fan type (as a number) - Real64 HCLoad; // load passed to a gas or electric heating coil [W] int FanOp; // 1 if fan is on; 0 if off. Real64 MaxCoolMassFlow; // air flow at max cooling [kg/s] Real64 MaxHeatMassFlow; // air flow at max heating [kg/s] @@ -4740,7 +4714,6 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC if (HCType == HeatingCoilType::SimpleHeating) { WaterControlNode = this->ReheatControlNode; - HCLoad = 0.0; if (FirstHVACIteration) { MaxFlowWater = this->MaxReheatWaterFlow; MinFlowWater = this->MinReheatWaterFlow; @@ -4751,14 +4724,12 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC } } else { WaterControlNode = 0; - HCLoad = BigLoad; MaxFlowWater = 0.0; MinFlowWater = 0.0; } if (HCType == HeatingCoilType::SteamAirHeating) { SteamControlNode = this->ReheatControlNode; - HCLoad = 0.0; if (FirstHVACIteration) { MaxFlowSteam = this->MaxReheatSteamFlow; MinFlowSteam = this->MinReheatSteamFlow; @@ -4768,7 +4739,6 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC } } else { SteamControlNode = 0; - HCLoad = BigLoad; MaxFlowSteam = 0.0; MinFlowSteam = 0.0; } From b0c330c4d158fade7e0b555a6c2d6008f89642e7 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 18:08:48 -0400 Subject: [PATCH 77/99] clean and unused --- src/EnergyPlus/SingleDuct.cc | 183 +---------------------------------- src/EnergyPlus/SingleDuct.hh | 1 - 2 files changed, 2 insertions(+), 182 deletions(-) diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 19aec487d9a..e11a6eaf949 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -98,8 +98,6 @@ namespace EnergyPlus::SingleDuct { // MODULE INFORMATION: // AUTHOR Richard J. Liesen // DATE WRITTEN January 2000 -// MODIFIED na -// RE-ENGINEERED na // PURPOSE OF THIS MODULE: // To encapsulate the data and algorithms required to @@ -128,16 +126,12 @@ void SimulateSingleDuct( // SUBROUTINE INFORMATION: // AUTHOR Richard Liesen // DATE WRITTEN January 2000 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine manages Sys system simulation. // It is called from the ManageZoneEquip // at the system time step. - // Using/Aliasing - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int SysNum; // The Sys that you are currently loading input into @@ -222,8 +216,6 @@ void GetSysInput(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR Richard Liesen // DATE WRITTEN April 1998 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine is the main routine to call other input routines and Get routines @@ -2434,8 +2426,6 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI // SUBROUTINE INFORMATION: // AUTHOR Richard J. Liesen // DATE WRITTEN January 2000 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine is for initializations of the Sys Components. @@ -2457,9 +2447,6 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int InletNode; int OutletNode; - // static Array1D_bool MyEnvrnFlag; - // static Array1D_bool MySizeFlag; - // static Array1D_bool GetGasElecHeatCoilCap; // Gets autosized value of coil capacity Real64 SteamTemp; Real64 SteamDensity; Real64 rho; @@ -2468,19 +2455,6 @@ void SingleDuctAirTerminal::InitSys(EnergyPlusData &state, bool const FirstHVACI // static Array1D_bool PlantLoopScanFlag; // Do the Begin Simulation initializations - if (state.dataSingleDuct->InitSysFlag) { - - // MyEnvrnFlag.allocate(NumSDAirTerminal); - // MySizeFlag.allocate(NumSDAirTerminal); - // PlantLoopScanFlag.allocate(NumSDAirTerminal); - // GetGasElecHeatCoilCap.allocate(NumSDAirTerminal); - // MyEnvrnFlag = true; - // MySizeFlag = true; - // PlantLoopScanFlag = true; - // GetGasElecHeatCoilCap = true; - state.dataSingleDuct->InitSysFlag = false; - } - if (this->PlantLoopScanFlag && allocated(state.dataPlnt->PlantLoop)) { if ((this->ReheatComp_PlantType == DataPlant::PlantEquipmentType::CoilWaterSimpleHeating) || (this->ReheatComp_PlantType == DataPlant::PlantEquipmentType::CoilSteamAirHeating)) { @@ -3731,7 +3705,6 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt // TH 3/2012: added supply air flow adjustment based on zone maximum outdoor // air fraction - a TRACE feature // Brent Griffith, 5/2012, general cleanup, fix negatives CR 8767, fix phantom coil flows CR 8854 - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine simulates the simple single duct volume VAV. @@ -3739,9 +3712,6 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt // METHODOLOGY EMPLOYED: // There is method to this madness. - // REFERENCES: - // na - // Using/Aliasing using namespace DataZoneEnergyDemands; // unused USE DataHeatBalFanSys, ONLY: Mat @@ -3751,17 +3721,6 @@ void SingleDuctAirTerminal::SimVAV(EnergyPlusData &state, bool const FirstHVACIt using SteamCoils::SimulateSteamCoilComponents; using WaterCoils::SimulateWaterCoilComponents; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 MassFlow; // [kg/sec] Total Mass Flow Rate from Hot & Cold Inlets Real64 QTotLoad; // [Watts] Remaining load required for this zone @@ -4214,7 +4173,6 @@ void SingleDuctAirTerminal::CalcOAMassFlow(EnergyPlusData &state, // AUTHOR R. Raustad (FSEC) // DATE WRITTEN Jan 2010 // MODIFIED Mangesh Basarkar, 06/2011: Modifying outside air based on airloop DCV flag - // RE-ENGINEERED na // PURPOSE OF THIS FUNCTION: // Calculates the amount of outside air required based on optional user input. @@ -4223,26 +4181,12 @@ void SingleDuctAirTerminal::CalcOAMassFlow(EnergyPlusData &state, // METHODOLOGY EMPLOYED: // User input defines method used to calculate OA. - // REFERENCES: - // Using/Aliasing using Psychrometrics::PsyRhoAirFnPbTdbW; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // FUNCTION PARAMETER DEFINITIONS: bool constexpr UseMinOASchFlag(true); // Always use min OA schedule in calculations. - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: Real64 OAVolumeFlowRate; // outside air volume flow rate (m3/s) Real64 OAMassFlow; // outside air mass flow rate (kg/s) @@ -4276,18 +4220,11 @@ void SingleDuctAirTerminal::SimCBVAV(EnergyPlusData &state, bool const FirstHVAC // AUTHOR Richard Raustad // DATE WRITTEN August 2006 // MODIFIED KHL/TH 10/2010: added maximum supply air temperature leaving reheat coil - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine simulates the VAV box with varying airflow in heating and cooling. // Modified version of SimVAV. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - // Using/Aliasing using namespace DataZoneEnergyDemands; using HVAC::SmallLoad; @@ -4298,17 +4235,6 @@ void SingleDuctAirTerminal::SimCBVAV(EnergyPlusData &state, bool const FirstHVAC // unused USE DataHeatBalFanSys, ONLY: ZoneThermostatSetPointHi, ZoneThermostatSetPointLo using PlantUtilities::SetActuatedBranchFlowRate; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 MassFlow; // Total Mass Flow Rate from Hot & Cold Inlets [kg/sec] Real64 QTotLoad; // Total load based on thermostat setpoint temperature [Watts] @@ -4637,8 +4563,6 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN July 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine simulates a single duct VAV terminal unit with a variable-speed fan upstream @@ -5043,17 +4967,10 @@ void SingleDuctAirTerminal::SimConstVol(EnergyPlusData &state, bool const FirstH // AUTHOR Richard J. Liesen // DATE WRITTEN February 2000 // MODIFIED FB/KHL/TH 2/2011: added maximum supply air temperature leaving reheat coil - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine simulates the simple single duct constant volume systems. - // METHODOLOGY EMPLOYED: - // There is method to this madness. - - // REFERENCES: - // na - // Using/Aliasing using namespace DataZoneEnergyDemands; // unused USE DataHeatBalFanSys, ONLY: Mat @@ -5238,8 +5155,6 @@ void SingleDuctAirTerminal::CalcVAVVS(EnergyPlusData &state, // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN July 2004 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Simulate the components making up the VAV terminal unit with variable speed fan. @@ -5247,27 +5162,12 @@ void SingleDuctAirTerminal::CalcVAVVS(EnergyPlusData &state, // METHODOLOGY EMPLOYED: // Simulates the unit components sequentially in the air flow direction. - // REFERENCES: - // na - // Using/Aliasing using HeatingCoils::SimulateHeatingCoilComponents; using PlantUtilities::SetComponentFlowRate; using SteamCoils::SimulateSteamCoilComponents; using WaterCoils::SimulateWaterCoilComponents; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int FanInNode; // unit air inlet node (fan inlet) int FanOutNode; // fan outlet node (heating coil inlet node) @@ -5339,18 +5239,12 @@ void SingleDuctAirTerminal::UpdateSys(EnergyPlusData &state) const // SUBROUTINE INFORMATION: // AUTHOR Richard J. Liesen // DATE WRITTEN january 2000 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine updates the Syss. - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int OutletNode; - int InletNode; - - OutletNode = this->OutletNodeNum; - InletNode = this->InletNodeNum; + int OutletNode = this->OutletNodeNum; + int InletNode = this->InletNodeNum; if (this->SysType_Num == SysType::SingleDuctVAVReheat || this->SysType_Num == SysType::SingleDuctCBVAVReheat || this->SysType_Num == SysType::SingleDuctCBVAVNoReheat || this->SysType_Num == SysType::SingleDuctVAVNoReheat || @@ -5390,40 +5284,6 @@ void SingleDuctAirTerminal::UpdateSys(EnergyPlusData &state) const void SingleDuctAirTerminal::ReportSys(EnergyPlusData &state) // unused1208 { - // SUBROUTINE INFORMATION: - // AUTHOR Unknown - // DATE WRITTEN Unknown - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This subroutine updates the Sys report variables. - - // METHODOLOGY EMPLOYED: - // There is method to this madness. - - // REFERENCES: - // na - - // USE STATEMENTS: - // na - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - - // Still needs to report the Sys power from this component - // set zone OA volume flow rate this->CalcOutdoorAirVolumeFlowRate(state); } @@ -5441,8 +5301,6 @@ void GetHVACSingleDuctSysIndex(EnergyPlusData &state, // SUBROUTINE INFORMATION: // AUTHOR Lixing Gu // DATE WRITTEN February 2006 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine sets an index for a given single duct system -- issues error message if that system @@ -5483,16 +5341,11 @@ void SimATMixer(EnergyPlusData &state, std::string const &SysName, bool const Fi { // SUBROUTINE INFORMATION: - // AUTHOR // DATE WRITTEN March 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE // Simulate an Air Terminal Mixer component - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - if (state.dataSingleDuct->GetATMixerFlag) { state.dataSingleDuct->GetATMixerFlag = false; } @@ -5518,10 +5371,7 @@ void GetATMixers(EnergyPlusData &state) { // SUBROUTINE INFORMATION: - // AUTHOR // DATE WRITTEN March 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE // Get input for inlet side air terminal mixers and store it in the inlet side air terminal mixer array @@ -5975,34 +5825,14 @@ void CalcATMixer(EnergyPlusData &state, int const SysNum) { // SUBROUTINE INFORMATION: - // AUTHOR // DATE WRITTEN March 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE // Calculate the mixed air flow and conditions in the air terminal mixer - // METHODOLOGY EMPLOYED: - - // REFERENCES: - // Using/Aliasing using Psychrometrics::PsyTdbFnHW; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS - - // SUBROUTINE PARAMETER DEFINITIONS: - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - state.dataSingleDuct->PriEnthalpyCATM = state.dataLoopNodes->Node(state.dataSingleDuct->SysATMixer(SysNum).PriInNode).Enthalpy; state.dataSingleDuct->PriHumRatCATM = state.dataLoopNodes->Node(state.dataSingleDuct->SysATMixer(SysNum).PriInNode).HumRat; state.dataSingleDuct->PriTempCATM = state.dataLoopNodes->Node(state.dataSingleDuct->SysATMixer(SysNum).PriInNode).Temp; @@ -6057,18 +5887,11 @@ void UpdateATMixer(EnergyPlusData &state, int const SysNum) { // SUBROUTINE INFORMATION: - // AUTHOR // DATE WRITTEN March 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE // Move the results of CalcATMixer to the affected nodes - // METHODOLOGY EMPLOYED: - - // REFERENCES: - // Using/Aliasing using namespace DataLoopNode; @@ -6128,8 +5951,6 @@ void GetATMixer(EnergyPlusData &state, // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN April 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // This subroutine gets: 1) the index of the named AT Mixer in the SysATMixer data array diff --git a/src/EnergyPlus/SingleDuct.hh b/src/EnergyPlus/SingleDuct.hh index 049d30498da..406a7d00708 100644 --- a/src/EnergyPlus/SingleDuct.hh +++ b/src/EnergyPlus/SingleDuct.hh @@ -368,7 +368,6 @@ struct SingleDuctData : BaseGlobalStruct int NumSDAirTerminal = 0; // The Number of single duct air terminals found in the Input bool GetInputFlag = true; // Flag set to make sure you get input once bool GetATMixerFlag = true; // Flag set to make sure you get input once - bool InitSysFlag = true; // Flag set to make sure you do begin simulation initializaztions once bool InitATMixerFlag = true; // Flag set to make sure you do begin simulation initializaztions once for mixer bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items From 711bf5cad7e849d626d89ef4b9956c946e13e664 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 18:14:34 -0400 Subject: [PATCH 78/99] reduce and const --- src/EnergyPlus/SizingAnalysisObjects.cc | 35 +++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/SizingAnalysisObjects.cc b/src/EnergyPlus/SizingAnalysisObjects.cc index ee6eb9d8ab8..86857cdd323 100644 --- a/src/EnergyPlus/SizingAnalysisObjects.cc +++ b/src/EnergyPlus/SizingAnalysisObjects.cc @@ -175,17 +175,14 @@ int SizingLog::GetSysStepZtStepIndex(ZoneTimestepObject tmpztStepStamp) void SizingLog::FillSysStep(ZoneTimestepObject tmpztStepStamp, SystemTimestepObject tmpSysStepStamp) { - int ztIndex(0); - int oldNumSubSteps(0); - int newNumSubSteps(0); + int newNumSubSteps; Real64 constexpr MinutesPerHour(60.0); - Real64 ZoneStepStartMinutes(0.0); - ztIndex = GetSysStepZtStepIndex(tmpztStepStamp); + int ztIndex = GetSysStepZtStepIndex(tmpztStepStamp); if (ztStepObj[ztIndex].hasSystemSubSteps) { - oldNumSubSteps = ztStepObj[ztIndex].numSubSteps; + int oldNumSubSteps = ztStepObj[ztIndex].numSubSteps; newNumSubSteps = round(tmpztStepStamp.timeStepDuration / tmpSysStepStamp.TimeStepDuration); if (newNumSubSteps != oldNumSubSteps) { ztStepObj[ztIndex].subSteps.resize(newNumSubSteps); @@ -199,7 +196,7 @@ void SizingLog::FillSysStep(ZoneTimestepObject tmpztStepStamp, SystemTimestepObj } // figure out which index this substep needs to go into - ZoneStepStartMinutes = tmpztStepStamp.stepStartMinute; + Real64 ZoneStepStartMinutes = tmpztStepStamp.stepStartMinute; tmpSysStepStamp.stStepsIntoZoneStep = round((((tmpSysStepStamp.CurMinuteStart - ZoneStepStartMinutes) / MinutesPerHour) / tmpSysStepStamp.TimeStepDuration)); @@ -220,7 +217,7 @@ void SizingLog::AverageSysTimeSteps() for (auto &zt : ztStepObj) { if (zt.numSubSteps > 0) { RunningSum = 0.0; - for (auto &SysT : zt.subSteps) { + for (auto const &SysT : zt.subSteps) { RunningSum += SysT.LogDataValue; } zt.logDataValue = RunningSum / double(zt.numSubSteps); @@ -254,15 +251,14 @@ void SizingLog::ProcessRunningAverage() ZoneTimestepObject SizingLog::GetLogVariableDataMax(EnergyPlusData &state) { - Real64 MaxVal; ZoneTimestepObject tmpztStepStamp; - MaxVal = 0.0; + Real64 MaxVal = 0.0; if (!ztStepObj.empty()) { tmpztStepStamp = ztStepObj[0]; } - for (auto &zt : ztStepObj) { + for (auto const &zt : ztStepObj) { if (zt.envrnNum > 0 && zt.kindOfSim != Constant::KindOfSim::Invalid && zt.runningAvgDataValue > MaxVal) { MaxVal = zt.runningAvgDataValue; tmpztStepStamp = zt; @@ -276,10 +272,7 @@ ZoneTimestepObject SizingLog::GetLogVariableDataMax(EnergyPlusData &state) Real64 SizingLog::GetLogVariableDataAtTimestamp(ZoneTimestepObject tmpztStepStamp) { int const index = GetZtStepIndex(tmpztStepStamp); - - Real64 const val = ztStepObj[index].runningAvgDataValue; - - return val; + return ztStepObj[index].runningAvgDataValue; } void SizingLog::ReInitLogForIteration() @@ -364,7 +357,7 @@ ZoneTimestepObject SizingLoggerFramework::PrepareZoneTimestepStamp(EnergyPlusDat // prepare current timing data once and then pass into fill routines // function used by both zone and system frequency log updates - int locDayOfSim(1); + int locDayOfSim; if (state.dataGlobal->WarmupFlag) { // DayOfSim not okay during warmup, keeps incrementing up during warmup days locDayOfSim = 1; @@ -386,9 +379,7 @@ ZoneTimestepObject SizingLoggerFramework::PrepareZoneTimestepStamp(EnergyPlusDat void SizingLoggerFramework::UpdateSizingLogValuesZoneStep(EnergyPlusData &state) { - ZoneTimestepObject tmpztStepStamp; - - tmpztStepStamp = PrepareZoneTimestepStamp(state); + ZoneTimestepObject tmpztStepStamp = PrepareZoneTimestepStamp(state); for (auto &l : logObjs) { l.FillZoneStep(tmpztStepStamp); @@ -397,12 +388,10 @@ void SizingLoggerFramework::UpdateSizingLogValuesZoneStep(EnergyPlusData &state) void SizingLoggerFramework::UpdateSizingLogValuesSystemStep(EnergyPlusData &state) { - Real64 constexpr MinutesPerHour(60.0); - ZoneTimestepObject tmpztStepStamp; + Real64 constexpr MinutesPerHour = 60.0; + ZoneTimestepObject tmpztStepStamp = PrepareZoneTimestepStamp(state); SystemTimestepObject tmpSysStepStamp; - tmpztStepStamp = PrepareZoneTimestepStamp(state); - // prepare system timestep stamp tmpSysStepStamp.CurMinuteEnd = state.dataOutputProcessor->TimeValue[(int)OutputProcessor::TimeStepType::System].CurMinute; if (tmpSysStepStamp.CurMinuteEnd == 0.0) { From f1aaafba357721c1f68facb309b4d059a63e6284 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 22 Sep 2024 19:33:30 -0400 Subject: [PATCH 79/99] clang, unused function, std::fill, reduce --- src/EnergyPlus/SimulationManager.hh | 2 +- src/EnergyPlus/SingleDuct.cc | 28 ------------------------- src/EnergyPlus/SingleDuct.hh | 5 ----- src/EnergyPlus/SizingAnalysisObjects.cc | 10 +++------ 4 files changed, 4 insertions(+), 41 deletions(-) diff --git a/src/EnergyPlus/SimulationManager.hh b/src/EnergyPlus/SimulationManager.hh index b483d230c51..e39446e60fb 100644 --- a/src/EnergyPlus/SimulationManager.hh +++ b/src/EnergyPlus/SimulationManager.hh @@ -117,7 +117,7 @@ struct SimulationManagerData : BaseGlobalStruct void Resimulate(EnergyPlusData &state, bool const ResimExt, // Flag to resimulate the exterior energy use simulation bool const ResimHB, // Flag to resimulate the heat balance simulation (including HVAC) - bool &ResimHVAC // Flag to resimulate the HVAC simulation + bool &ResimHVAC // Flag to resimulate the HVAC simulation ); } // namespace EnergyPlus diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index e11a6eaf949..14cbe633149 100644 --- a/src/EnergyPlus/SingleDuct.cc +++ b/src/EnergyPlus/SingleDuct.cc @@ -5998,34 +5998,6 @@ void GetATMixer(EnergyPlusData &state, } } -void SetATMixerPriFlow(EnergyPlusData &state, - int const ATMixerNum, // Air terminal mixer index - ObjexxFCL::Optional PriAirMassFlowRate // Air terminal mixer primary air mass flow rate [kg/s] -) -{ - - // SUBROUTINE INFORMATION: - // AUTHOR Fred Buhl - // DATE WRITTEN April 2012 - - // PURPOSE OF THIS SUBROUTINE: - // This Subroutine sets the primary air mass flow rate on the primary air inlet - // node of a terminal unit mixer component. - - // METHODOLOGY EMPLOYED: - // The flow is set to either the input PriAirMassFlowRate if this optional input - // parameter is present, or to the maximum available mass flow rate of the primary - // air inlet node. - - if (ATMixerNum <= 0) return; - int const PriAirNode = state.dataSingleDuct->SysATMixer(ATMixerNum).PriInNode; // air terminal mixer primary air inlet node number - if (present(PriAirMassFlowRate)) { - state.dataLoopNodes->Node(PriAirNode).MassFlowRate = PriAirMassFlowRate; - } else { - state.dataLoopNodes->Node(PriAirNode).MassFlowRate = state.dataLoopNodes->Node(PriAirNode).MassFlowRateMaxAvail; - } -} - void setATMixerSizingProperties(EnergyPlusData &state, int const inletATMixerIndex, // index to ATMixer at inlet of zone equipment int const controlledZoneNum, // controlled zone number diff --git a/src/EnergyPlus/SingleDuct.hh b/src/EnergyPlus/SingleDuct.hh index 406a7d00708..1110c5ac2aa 100644 --- a/src/EnergyPlus/SingleDuct.hh +++ b/src/EnergyPlus/SingleDuct.hh @@ -343,11 +343,6 @@ namespace SingleDuct { int ZoneEquipOutletNode // zone equipment outlet node (used with inlet side mixers) ); - void SetATMixerPriFlow(EnergyPlusData &state, - int ATMixerNum, // Air terminal mixer index - ObjexxFCL::Optional PriAirMassFlowRate = _ // Air terminal mixer primary air mass flow rate [kg/s] - ); - void setATMixerSizingProperties(EnergyPlusData &state, int inletATMixerIndex, // index to ATMixer at inlet of zone equipment int controlledZoneNum, // controlled zone number diff --git a/src/EnergyPlus/SizingAnalysisObjects.cc b/src/EnergyPlus/SizingAnalysisObjects.cc index 86857cdd323..8bfed4b4a09 100644 --- a/src/EnergyPlus/SizingAnalysisObjects.cc +++ b/src/EnergyPlus/SizingAnalysisObjects.cc @@ -278,10 +278,7 @@ Real64 SizingLog::GetLogVariableDataAtTimestamp(ZoneTimestepObject tmpztStepStam void SizingLog::ReInitLogForIteration() { ZoneTimestepObject tmpNullztStepObj; - - for (auto &zt : ztStepObj) { - zt = tmpNullztStepObj; - } + std::fill(ztStepObj.begin(), ztStepObj.end(), tmpNullztStepObj); } void SizingLog::SetupNewEnvironment(int const seedEnvrnNum, int const newEnvrnNum) @@ -291,8 +288,7 @@ void SizingLog::SetupNewEnvironment(int const seedEnvrnNum, int const newEnvrnNu int SizingLoggerFramework::SetupVariableSizingLog(EnergyPlusData &state, Real64 &rVariable, int stepsInAverage) { - int VectorLength(0); - int constexpr HoursPerDay(24); + int constexpr HoursPerDay = 24; SizingLog tmpLog(rVariable); tmpLog.NumOfEnvironmentsInLogSet = 0; @@ -333,7 +329,7 @@ int SizingLoggerFramework::SetupVariableSizingLog(EnergyPlusData &state, Real64 tmpLog.timeStepsInAverage = stepsInAverage; - VectorLength = stepSum; + int VectorLength = stepSum; tmpLog.NumOfStepsInLogSet = VectorLength; tmpLog.ztStepObj.resize(VectorLength); From f98fc5cf55e7fe3ca94347a0a19aa4f35a5a1140 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 00:12:27 -0400 Subject: [PATCH 80/99] reduce class ref --- src/EnergyPlus/SizingManager.cc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index 0b76cbd122e..56bccde82cf 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -127,7 +127,6 @@ void ManageSizing(EnergyPlusData &state) // Design day simulations are run again with central air systems supplied by // purchased hot and cold water, yielding central heating and cooling capacities. - auto &CalcSysSizing = state.dataSize->CalcSysSizing; auto &SysSizPeakDDNum = state.dataSize->SysSizPeakDDNum; // Using/Aliasing @@ -225,9 +224,6 @@ void ManageSizing(EnergyPlusData &state) if ((state.dataSize->NumZoneSizingInput > 0) && (state.dataGlobal->DoZoneSizing || state.dataGlobal->DoSystemSizing || state.dataGlobal->DoPlantSizing)) { - if (state.dataGlobal->DoDesDaySim || state.dataGlobal->DoWeathSim) { - state.dataGlobal->DoOutputReporting = false; - } state.dataGlobal->DoOutputReporting = false; state.dataGlobal->ZoneSizingCalc = true; Available = true; @@ -624,9 +620,10 @@ void ManageSizing(EnergyPlusData &state) if (state.dataSize->SysSizingRunDone) { for (AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { + auto &calcSysSizing = state.dataSize->CalcSysSizing(AirLoopNum); curName = FinalSysSizing(AirLoopNum).AirPriLoopName; - PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcClAir, curName, CalcSysSizing(AirLoopNum).DesCoolVolFlow); - if (std::abs(CalcSysSizing(AirLoopNum).DesCoolVolFlow) <= 1.e-8) { + PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcClAir, curName, calcSysSizing.DesCoolVolFlow); + if (std::abs(calcSysSizing.DesCoolVolFlow) <= 1.e-8) { ShowWarningError(state, format("{}Calculated Cooling Design Air Flow Rate for System={} is zero.", RoutineName, @@ -634,8 +631,8 @@ void ManageSizing(EnergyPlusData &state) ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs."); } PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserClAir, curName, FinalSysSizing(AirLoopNum).DesCoolVolFlow); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcHtAir, curName, CalcSysSizing(AirLoopNum).DesHeatVolFlow); - if (std::abs(CalcSysSizing(AirLoopNum).DesHeatVolFlow) <= 1.e-8) { + PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcHtAir, curName, calcSysSizing.DesHeatVolFlow); + if (std::abs(calcSysSizing.DesHeatVolFlow) <= 1.e-8) { ShowWarningError(state, format("{}Calculated Heating Design Air Flow Rate for System={} is zero.", RoutineName, @@ -670,7 +667,7 @@ void ManageSizing(EnergyPlusData &state) "Cooling", coolPeakLoadKind, coolCap, - CalcSysSizing(AirLoopNum).DesCoolVolFlow, + calcSysSizing.DesCoolVolFlow, FinalSysSizing(AirLoopNum).DesCoolVolFlow, FinalSysSizing(AirLoopNum).CoolDesDay, coolPeakDDDate, @@ -681,7 +678,7 @@ void ManageSizing(EnergyPlusData &state) "Cooling", coolPeakLoadKind, coolCap, - CalcSysSizing(AirLoopNum).DesCoolVolFlow, + calcSysSizing.DesCoolVolFlow, FinalSysSizing(AirLoopNum).DesCoolVolFlow, FinalSysSizing(AirLoopNum).CoolDesDay, coolPeakDDDate, @@ -694,7 +691,7 @@ void ManageSizing(EnergyPlusData &state) "Heating", "Sensible", FinalSysSizing(AirLoopNum).HeatCap, - CalcSysSizing(AirLoopNum).DesHeatVolFlow, + calcSysSizing.DesHeatVolFlow, FinalSysSizing(AirLoopNum).DesHeatVolFlow, FinalSysSizing(AirLoopNum).HeatDesDay, SysSizPeakDDNum(AirLoopNum).cHeatPeakDDDate, @@ -705,7 +702,7 @@ void ManageSizing(EnergyPlusData &state) "Heating", "Sensible", FinalSysSizing(AirLoopNum).HeatCap, - CalcSysSizing(AirLoopNum).DesHeatVolFlow, + calcSysSizing.DesHeatVolFlow, FinalSysSizing(AirLoopNum).DesHeatVolFlow, FinalSysSizing(AirLoopNum).HeatDesDay, SysSizPeakDDNum(AirLoopNum).cHeatPeakDDDate, From d658b677f2554d8b3821db2364352e24b1f8f79e Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 00:21:58 -0400 Subject: [PATCH 81/99] reduce class reference --- src/EnergyPlus/SizingManager.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index 56bccde82cf..da0fce8c791 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -127,8 +127,6 @@ void ManageSizing(EnergyPlusData &state) // Design day simulations are run again with central air systems supplied by // purchased hot and cold water, yielding central heating and cooling capacities. - auto &SysSizPeakDDNum = state.dataSize->SysSizPeakDDNum; - // Using/Aliasing using SimAirServingZones::ManageAirLoops; using SimAirServingZones::UpdateSysSizing; @@ -621,6 +619,8 @@ void ManageSizing(EnergyPlusData &state) if (state.dataSize->SysSizingRunDone) { for (AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { auto &calcSysSizing = state.dataSize->CalcSysSizing(AirLoopNum); + auto &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(AirLoopNum); + curName = FinalSysSizing(AirLoopNum).AirPriLoopName; PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcClAir, curName, calcSysSizing.DesCoolVolFlow); if (std::abs(calcSysSizing.DesCoolVolFlow) <= 1.e-8) { @@ -646,20 +646,20 @@ void ManageSizing(EnergyPlusData &state) int timeStepIndexAtPeakCoolLoad = 0; if (FinalSysSizing(AirLoopNum).coolingPeakLoad == DataSizing::PeakLoad::SensibleCooling) { coolPeakLoadKind = "Sensible"; - coolPeakDDDate = SysSizPeakDDNum(AirLoopNum).cSensCoolPeakDDDate; - coolPeakDD = SysSizPeakDDNum(AirLoopNum).SensCoolPeakDD; + coolPeakDDDate = sysSizPeakDDNum.cSensCoolPeakDDDate; + coolPeakDD = sysSizPeakDDNum.SensCoolPeakDD; coolCap = FinalSysSizing(AirLoopNum).SensCoolCap; - if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = SysSizPeakDDNum(AirLoopNum).TimeStepAtSensCoolPk(coolPeakDD); + if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolPeakDD); } else if (FinalSysSizing(AirLoopNum).coolingPeakLoad == DataSizing::PeakLoad::TotalCooling) { if (FinalSysSizing(AirLoopNum).loadSizingType == DataSizing::LoadSizing::Latent && state.dataHeatBal->DoLatentSizing) { coolPeakLoadKind = "Total Based on Latent"; } else { coolPeakLoadKind = "Total"; } - coolPeakDDDate = SysSizPeakDDNum(AirLoopNum).cTotCoolPeakDDDate; - coolPeakDD = SysSizPeakDDNum(AirLoopNum).TotCoolPeakDD; + coolPeakDDDate = sysSizPeakDDNum.cTotCoolPeakDDDate; + coolPeakDD = sysSizPeakDDNum.TotCoolPeakDD; coolCap = FinalSysSizing(AirLoopNum).TotCoolCap; - if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = SysSizPeakDDNum(AirLoopNum).TimeStepAtTotCoolPk(coolPeakDD); + if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolPeakDD); } if (coolPeakDD > 0) { ReportSysSizing(state, @@ -684,7 +684,7 @@ void ManageSizing(EnergyPlusData &state) coolPeakDDDate, 0); } - int heatPeakDD = SysSizPeakDDNum(AirLoopNum).HeatPeakDD; + int heatPeakDD = sysSizPeakDDNum.HeatPeakDD; if (heatPeakDD > 0) { ReportSysSizing(state, curName, @@ -694,8 +694,8 @@ void ManageSizing(EnergyPlusData &state) calcSysSizing.DesHeatVolFlow, FinalSysSizing(AirLoopNum).DesHeatVolFlow, FinalSysSizing(AirLoopNum).HeatDesDay, - SysSizPeakDDNum(AirLoopNum).cHeatPeakDDDate, - SysSizPeakDDNum(AirLoopNum).TimeStepAtHeatPk(heatPeakDD)); + sysSizPeakDDNum.cHeatPeakDDDate, + sysSizPeakDDNum.TimeStepAtHeatPk(heatPeakDD)); } else { ReportSysSizing(state, curName, @@ -705,7 +705,7 @@ void ManageSizing(EnergyPlusData &state) calcSysSizing.DesHeatVolFlow, FinalSysSizing(AirLoopNum).DesHeatVolFlow, FinalSysSizing(AirLoopNum).HeatDesDay, - SysSizPeakDDNum(AirLoopNum).cHeatPeakDDDate, + sysSizPeakDDNum.cHeatPeakDDDate, 0); } PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserHtAir, curName, FinalSysSizing(AirLoopNum).DesHeatVolFlow); From b327afeeea8f765550bfa30b5b032893c159d45d Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 00:31:21 -0400 Subject: [PATCH 82/99] reduce class reference --- src/EnergyPlus/SizingManager.cc | 50 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index da0fce8c791..f7f096ce3af 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -152,15 +152,11 @@ void ManageSizing(EnergyPlusData &state) int TimeStepInDay(0); // time step number int LastMonth(0); int LastDayOfMonth(0); - int AirLoopNum(0); // air loop index std::string curName; int NumSizingPeriodsPerformed; int numZoneSizeIter; // number of times to repeat zone sizing calcs. 1 normal, 2 load component reporting - int iZoneCalcIter; // index for repeating the zone sizing calcs bool isUserReqCompLoadReport; - auto &FinalSysSizing = state.dataSize->FinalSysSizing; - TimeStepInDay = 0; state.dataSize->SysSizingRunDone = false; state.dataSize->ZoneSizingRunDone = false; @@ -252,7 +248,7 @@ void ManageSizing(EnergyPlusData &state) SetupZoneSizing(state, ErrorsFound); // Should only be done ONCE state.dataGlobal->KickOffSizing = false; - for (iZoneCalcIter = 1; iZoneCalcIter <= numZoneSizeIter; ++iZoneCalcIter) { // normally this is performed once but if load component + for (int iZoneCalcIter = 1; iZoneCalcIter <= numZoneSizeIter; ++iZoneCalcIter) { // normally this is performed once but if load component // report is requested, these are repeated with a pulse in // each zone. @@ -617,26 +613,28 @@ void ManageSizing(EnergyPlusData &state) } if (state.dataSize->SysSizingRunDone) { - for (AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { + for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { auto &calcSysSizing = state.dataSize->CalcSysSizing(AirLoopNum); auto &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(AirLoopNum); + auto &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); + - curName = FinalSysSizing(AirLoopNum).AirPriLoopName; + curName = finalSysSizing.AirPriLoopName; PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcClAir, curName, calcSysSizing.DesCoolVolFlow); if (std::abs(calcSysSizing.DesCoolVolFlow) <= 1.e-8) { ShowWarningError(state, format("{}Calculated Cooling Design Air Flow Rate for System={} is zero.", RoutineName, - FinalSysSizing(AirLoopNum).AirPriLoopName)); + finalSysSizing.AirPriLoopName)); ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs."); } - PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserClAir, curName, FinalSysSizing(AirLoopNum).DesCoolVolFlow); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserClAir, curName, finalSysSizing.DesCoolVolFlow); PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcHtAir, curName, calcSysSizing.DesHeatVolFlow); if (std::abs(calcSysSizing.DesHeatVolFlow) <= 1.e-8) { ShowWarningError(state, format("{}Calculated Heating Design Air Flow Rate for System={} is zero.", RoutineName, - FinalSysSizing(AirLoopNum).AirPriLoopName)); + finalSysSizing.AirPriLoopName)); ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs."); } std::string_view coolPeakLoadKind; @@ -644,21 +642,21 @@ void ManageSizing(EnergyPlusData &state) int coolPeakDD = 0; Real64 coolCap = 0.; int timeStepIndexAtPeakCoolLoad = 0; - if (FinalSysSizing(AirLoopNum).coolingPeakLoad == DataSizing::PeakLoad::SensibleCooling) { + if (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::SensibleCooling) { coolPeakLoadKind = "Sensible"; coolPeakDDDate = sysSizPeakDDNum.cSensCoolPeakDDDate; coolPeakDD = sysSizPeakDDNum.SensCoolPeakDD; - coolCap = FinalSysSizing(AirLoopNum).SensCoolCap; + coolCap = finalSysSizing.SensCoolCap; if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolPeakDD); - } else if (FinalSysSizing(AirLoopNum).coolingPeakLoad == DataSizing::PeakLoad::TotalCooling) { - if (FinalSysSizing(AirLoopNum).loadSizingType == DataSizing::LoadSizing::Latent && state.dataHeatBal->DoLatentSizing) { + } else if (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::TotalCooling) { + if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Latent && state.dataHeatBal->DoLatentSizing) { coolPeakLoadKind = "Total Based on Latent"; } else { coolPeakLoadKind = "Total"; } coolPeakDDDate = sysSizPeakDDNum.cTotCoolPeakDDDate; coolPeakDD = sysSizPeakDDNum.TotCoolPeakDD; - coolCap = FinalSysSizing(AirLoopNum).TotCoolCap; + coolCap = finalSysSizing.TotCoolCap; if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolPeakDD); } if (coolPeakDD > 0) { @@ -668,8 +666,8 @@ void ManageSizing(EnergyPlusData &state) coolPeakLoadKind, coolCap, calcSysSizing.DesCoolVolFlow, - FinalSysSizing(AirLoopNum).DesCoolVolFlow, - FinalSysSizing(AirLoopNum).CoolDesDay, + finalSysSizing.DesCoolVolFlow, + finalSysSizing.CoolDesDay, coolPeakDDDate, timeStepIndexAtPeakCoolLoad); } else { @@ -679,8 +677,8 @@ void ManageSizing(EnergyPlusData &state) coolPeakLoadKind, coolCap, calcSysSizing.DesCoolVolFlow, - FinalSysSizing(AirLoopNum).DesCoolVolFlow, - FinalSysSizing(AirLoopNum).CoolDesDay, + finalSysSizing.DesCoolVolFlow, + finalSysSizing.CoolDesDay, coolPeakDDDate, 0); } @@ -690,10 +688,10 @@ void ManageSizing(EnergyPlusData &state) curName, "Heating", "Sensible", - FinalSysSizing(AirLoopNum).HeatCap, + finalSysSizing.HeatCap, calcSysSizing.DesHeatVolFlow, - FinalSysSizing(AirLoopNum).DesHeatVolFlow, - FinalSysSizing(AirLoopNum).HeatDesDay, + finalSysSizing.DesHeatVolFlow, + finalSysSizing.HeatDesDay, sysSizPeakDDNum.cHeatPeakDDDate, sysSizPeakDDNum.TimeStepAtHeatPk(heatPeakDD)); } else { @@ -701,14 +699,14 @@ void ManageSizing(EnergyPlusData &state) curName, "Heating", "Sensible", - FinalSysSizing(AirLoopNum).HeatCap, + finalSysSizing.HeatCap, calcSysSizing.DesHeatVolFlow, - FinalSysSizing(AirLoopNum).DesHeatVolFlow, - FinalSysSizing(AirLoopNum).HeatDesDay, + finalSysSizing.DesHeatVolFlow, + finalSysSizing.HeatDesDay, sysSizPeakDDNum.cHeatPeakDDDate, 0); } - PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserHtAir, curName, FinalSysSizing(AirLoopNum).DesHeatVolFlow); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserHtAir, curName, finalSysSizing.DesHeatVolFlow); } // Deallocate arrays no longer needed state.dataSize->SysSizing.deallocate(); From 83bd182efda8172cc6542fb12c4358d8270a3e67 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 01:33:12 -0400 Subject: [PATCH 83/99] reduce class reference --- src/EnergyPlus/SizingManager.cc | 63 +++++++++++++++++---------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index f7f096ce3af..b003248ca38 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -618,23 +618,18 @@ void ManageSizing(EnergyPlusData &state) auto &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(AirLoopNum); auto &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); - curName = finalSysSizing.AirPriLoopName; PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcClAir, curName, calcSysSizing.DesCoolVolFlow); if (std::abs(calcSysSizing.DesCoolVolFlow) <= 1.e-8) { - ShowWarningError(state, - format("{}Calculated Cooling Design Air Flow Rate for System={} is zero.", - RoutineName, - finalSysSizing.AirPriLoopName)); + ShowWarningError( + state, format("{}Calculated Cooling Design Air Flow Rate for System={} is zero.", RoutineName, finalSysSizing.AirPriLoopName)); ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs."); } PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizUserClAir, curName, finalSysSizing.DesCoolVolFlow); PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcHtAir, curName, calcSysSizing.DesHeatVolFlow); if (std::abs(calcSysSizing.DesHeatVolFlow) <= 1.e-8) { - ShowWarningError(state, - format("{}Calculated Heating Design Air Flow Rate for System={} is zero.", - RoutineName, - finalSysSizing.AirPriLoopName)); + ShowWarningError( + state, format("{}Calculated Heating Design Air Flow Rate for System={} is zero.", RoutineName, finalSysSizing.AirPriLoopName)); ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs."); } std::string_view coolPeakLoadKind; @@ -773,7 +768,6 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // Also store zone level flow information for Standard 62.1 calculations, Vpz, Vpz_min, Vdz, and Vdz_min for both cooling and heating - auto &AirDistUnit = state.dataDefineEquipment->AirDistUnit; auto &FinalSysSizing = state.dataSize->FinalSysSizing; auto &sd_airterminal = state.dataSingleDuct->sd_airterminal; @@ -795,8 +789,9 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up heating and max flows for any single duct systems, store 62.1 values by zone if (allocated(sd_airterminal) && state.dataSingleDuct->NumSDAirTerminal > 0) { for (int singleDuctATUNum = 1; singleDuctATUNum <= state.dataSingleDuct->NumSDAirTerminal; ++singleDuctATUNum) { + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(sd_airterminal(singleDuctATUNum).ADUNum); if (AirLoopNum == sd_airterminal(singleDuctATUNum).AirLoopNum) { - int termUnitSizingIndex = AirDistUnit(sd_airterminal(singleDuctATUNum).ADUNum).TermUnitSizingNum; + int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopMaxFlowRateSum += sd_airterminal(singleDuctATUNum).MaxAirVolFlowRate; state.dataSize->VpzClgByZone(termUnitSizingIndex) = @@ -866,7 +861,8 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) if (allocated(state.dataDualDuct->dd_airterminal) && state.dataDualDuct->NumDDAirTerminal > 0) { for (int dualDuctATUNum = 1; dualDuctATUNum <= state.dataDualDuct->NumDDAirTerminal; ++dualDuctATUNum) { if (AirLoopNum == state.dataDualDuct->dd_airterminal(dualDuctATUNum).AirLoopNum) { - int termUnitSizingIndex = AirDistUnit(state.dataDualDuct->dd_airterminal(dualDuctATUNum).ADUNum).TermUnitSizingNum; + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataDualDuct->dd_airterminal(dualDuctATUNum).ADUNum); + int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopMaxFlowRateSum += state.dataDualDuct->dd_airterminal(dualDuctATUNum).MaxAirVolFlowRate; state.dataSize->VpzClgByZone(termUnitSizingIndex) = state.dataDualDuct->dd_airterminal(dualDuctATUNum).MaxAirVolFlowRate; // store std 62.1 value @@ -931,8 +927,9 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up heating and max flows for any PIU air terminals if (allocated(state.dataPowerInductionUnits->PIU) && state.dataPowerInductionUnits->NumPIUs > 0) { for (int pIUATUNum = 1; pIUATUNum <= state.dataPowerInductionUnits->NumPIUs; ++pIUATUNum) { + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataPowerInductionUnits->PIU(pIUATUNum).ADUNum); if (AirLoopNum == state.dataPowerInductionUnits->PIU(pIUATUNum).AirLoopNum) { - int termUnitSizingIndex = AirDistUnit(state.dataPowerInductionUnits->PIU(pIUATUNum).ADUNum).TermUnitSizingNum; + int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; auto &thisTermUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(termUnitSizingIndex); airLoopMaxFlowRateSum += state.dataPowerInductionUnits->PIU(pIUATUNum).MaxPriAirVolFlow; if (state.dataPowerInductionUnits->PIU(pIUATUNum).UnitType_Num == @@ -1022,8 +1019,9 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // dual path for std 62.1 if (allocated(IndUnit) && (NumIndUnits > 0)) { for (int indUnitNum = 1; indUnitNum <= NumIndUnits; ++indUnitNum) { + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(IndUnit(indUnitNum).ADUNum); if (AirLoopNum == IndUnit(indUnitNum).AirLoopNum) { - int termUnitSizingIndex = AirDistUnit(IndUnit(indUnitNum).ADUNum).TermUnitSizingNum; + int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopHeatingMaximumFlowRateSum += IndUnit(indUnitNum).MaxPriAirMassFlow / state.dataEnvrn->StdRhoAir; airLoopHeatingMinimumFlowRateSum += IndUnit(indUnitNum).MaxPriAirMassFlow / state.dataEnvrn->StdRhoAir; airLoopMaxFlowRateSum += IndUnit(indUnitNum).MaxPriAirMassFlow / state.dataEnvrn->StdRhoAir; @@ -1043,8 +1041,9 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up heating and max flows for any two pipe constant volume cooled beam terminal units if (allocated(state.dataHVACCooledBeam->CoolBeam) && (state.dataHVACCooledBeam->NumCB > 0)) { for (int coolBeamNum = 1; coolBeamNum <= state.dataHVACCooledBeam->NumCB; ++coolBeamNum) { + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataHVACCooledBeam->CoolBeam(coolBeamNum).ADUNum); if (AirLoopNum == state.dataHVACCooledBeam->CoolBeam(coolBeamNum).AirLoopNum) { - int termUnitSizingIndex = AirDistUnit(state.dataHVACCooledBeam->CoolBeam(coolBeamNum).ADUNum).TermUnitSizingNum; + int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopHeatingMaximumFlowRateSum += state.dataHVACCooledBeam->CoolBeam(coolBeamNum).MaxAirVolFlow; airLoopHeatingMinimumFlowRateSum += state.dataHVACCooledBeam->CoolBeam(coolBeamNum).MaxAirVolFlow; airLoopMaxFlowRateSum += state.dataHVACCooledBeam->CoolBeam(coolBeamNum).MaxAirVolFlow; @@ -1064,23 +1063,24 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) } // sum up heating and max flows for any four pipe cooled beam terminal units (the only one using the airTerminalPtr at this point) - if (allocated(AirDistUnit) && (int)state.dataDefineEquipment->AirDistUnit.size() > 0) { + if (allocated(state.dataDefineEquipment->AirDistUnit) && (int)state.dataDefineEquipment->AirDistUnit.size() > 0) { for (int aDUNum = 1; aDUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++aDUNum) { - if (AirDistUnit(aDUNum).airTerminalPtr.get() != nullptr) { - if (AirLoopNum == AirDistUnit(aDUNum).airTerminalPtr->getAirLoopNum()) { - airLoopHeatingMaximumFlowRateSum += AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - airLoopHeatingMinimumFlowRateSum += AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - airLoopMaxFlowRateSum += AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(aDUNum); + if (airDistUnit.airTerminalPtr.get() != nullptr) { + if (AirLoopNum == airDistUnit.airTerminalPtr->getAirLoopNum()) { + airLoopHeatingMaximumFlowRateSum += airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + airLoopHeatingMinimumFlowRateSum += airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + airLoopMaxFlowRateSum += airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); // store Std 62.1 values, have no modeling of secondary flow rates for induced flow from beam - int termUnitSizingIndex = AirDistUnit(aDUNum).airTerminalPtr->getTermUnitSizingIndex(); - state.dataSize->VpzClgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VpzMinClgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VpzHtgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VpzMinHtgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VdzClgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VdzMinClgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VdzHtgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); - state.dataSize->VdzMinHtgByZone(termUnitSizingIndex) = AirDistUnit(aDUNum).airTerminalPtr->getPrimAirDesignVolFlow(); + int termUnitSizingIndex = airDistUnit.airTerminalPtr->getTermUnitSizingIndex(); + state.dataSize->VpzClgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VpzMinClgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VpzHtgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VpzMinHtgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VdzClgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VdzMinClgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VdzHtgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); + state.dataSize->VdzMinHtgByZone(termUnitSizingIndex) = airDistUnit.airTerminalPtr->getPrimAirDesignVolFlow(); } } } @@ -1089,8 +1089,9 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up flows for any air terminal mixers if (allocated(state.dataSingleDuct->SysATMixer) && (state.dataSingleDuct->NumATMixers > 0)) { for (int aTMixerNum = 1; aTMixerNum <= state.dataSingleDuct->NumATMixers; ++aTMixerNum) { + auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->SysATMixer(aTMixerNum).ADUNum); if (AirLoopNum == state.dataSingleDuct->SysATMixer(aTMixerNum).AirLoopNum) { - int termUnitSizingIndex = AirDistUnit(state.dataSingleDuct->SysATMixer(aTMixerNum).ADUNum).TermUnitSizingNum; + int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopHeatingMaximumFlowRateSum += state.dataSingleDuct->SysATMixer(aTMixerNum).DesignPrimaryAirVolRate; airLoopHeatingMinimumFlowRateSum += state.dataSingleDuct->SysATMixer(aTMixerNum).DesignPrimaryAirVolRate; airLoopMaxFlowRateSum += state.dataSingleDuct->SysATMixer(aTMixerNum).DesignPrimaryAirVolRate; From c8d79d69850891981f3c1edad49643b859b33417 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 01:41:44 -0400 Subject: [PATCH 84/99] reduce class reference --- src/EnergyPlus/SizingManager.cc | 85 ++++++++++++++++----------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index b003248ca38..63244a626b0 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -768,7 +768,6 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // Also store zone level flow information for Standard 62.1 calculations, Vpz, Vpz_min, Vdz, and Vdz_min for both cooling and heating - auto &FinalSysSizing = state.dataSize->FinalSysSizing; auto &sd_airterminal = state.dataSingleDuct->sd_airterminal; if ((state.dataSize->NumSysSizInput > 0) && (state.dataGlobal->DoSystemSizing)) { // only if there is system sizing @@ -781,6 +780,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) state.dataGlobal->BeginEnvrnFlag = false; for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { + auto &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); // Mine data from ATUs to find new design heating flow rates and new maximum flow rates Real64 airLoopMaxFlowRateSum(0.0); Real64 airLoopHeatingMinimumFlowRateSum(0.0); @@ -1109,7 +1109,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) } } - std::string curName = FinalSysSizing(AirLoopNum).AirPriLoopName; + std::string curName = finalSysSizing.AirPriLoopName; BaseSizer::reportSizerOutput( state, "AirLoopHVAC", curName, "Sum of Air Terminal Maximum Heating Flow Rates [m3/s]", airLoopHeatingMaximumFlowRateSum); BaseSizer::reportSizerOutput( @@ -1117,77 +1117,74 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) BaseSizer::reportSizerOutput(state, "AirLoopHVAC", curName, "Sum of Air Terminal Maximum Flow Rates [m3/s]", airLoopMaxFlowRateSum); // Adjust system sizing info - if (allocated(FinalSysSizing)) { + if (allocated(state.dataSize->FinalSysSizing)) { // correct sizing design heating volume flow rate based on finalized air terminal unit operation - if (FinalSysSizing(AirLoopNum).SizingOption == + if (finalSysSizing.SizingOption == DataSizing::SizingConcurrence::NonCoincident) { // If non-coincident sizing method for this air loop, the we can use these sum's // from // air terminals directly - FinalSysSizing(AirLoopNum).DesHeatVolFlow = max(airLoopHeatingMaximumFlowRateSum, FinalSysSizing(AirLoopNum).DesHeatVolFlow); - FinalSysSizing(AirLoopNum).DesMainVolFlow = max(airLoopMaxFlowRateSum, FinalSysSizing(AirLoopNum).DesMainVolFlow); - if (FinalSysSizing(AirLoopNum).sysSizeCoolingDominant) { - FinalSysSizing(AirLoopNum).DesCoolVolFlow = FinalSysSizing(AirLoopNum).DesMainVolFlow; - FinalSysSizing(AirLoopNum).MassFlowAtCoolPeak = FinalSysSizing(AirLoopNum).DesCoolVolFlow * state.dataEnvrn->StdRhoAir; - } else if (FinalSysSizing(AirLoopNum).sysSizeHeatingDominant) { // make sure cooling is at least at minimum. - FinalSysSizing(AirLoopNum).DesCoolVolFlow = max(airLoopHeatingMinimumFlowRateSum, FinalSysSizing(AirLoopNum).DesCoolVolFlow); - FinalSysSizing(AirLoopNum).MassFlowAtCoolPeak = FinalSysSizing(AirLoopNum).DesCoolVolFlow * state.dataEnvrn->StdRhoAir; + finalSysSizing.DesHeatVolFlow = max(airLoopHeatingMaximumFlowRateSum, finalSysSizing.DesHeatVolFlow); + finalSysSizing.DesMainVolFlow = max(airLoopMaxFlowRateSum, finalSysSizing.DesMainVolFlow); + if (finalSysSizing.sysSizeCoolingDominant) { + finalSysSizing.DesCoolVolFlow = finalSysSizing.DesMainVolFlow; + finalSysSizing.MassFlowAtCoolPeak = finalSysSizing.DesCoolVolFlow * state.dataEnvrn->StdRhoAir; + } else if (finalSysSizing.sysSizeHeatingDominant) { // make sure cooling is at least at minimum. + finalSysSizing.DesCoolVolFlow = max(airLoopHeatingMinimumFlowRateSum, finalSysSizing.DesCoolVolFlow); + finalSysSizing.MassFlowAtCoolPeak = finalSysSizing.DesCoolVolFlow * state.dataEnvrn->StdRhoAir; } - } else if (FinalSysSizing(AirLoopNum).SizingOption == DataSizing::SizingConcurrence::Coincident) { + } else if (finalSysSizing.SizingOption == DataSizing::SizingConcurrence::Coincident) { - if (FinalSysSizing(AirLoopNum).sysSizeCoolingDominant) { // use minimum heating flow sum from air terminals + if (finalSysSizing.sysSizeCoolingDominant) { // use minimum heating flow sum from air terminals // know that minimum heating flow is a hard minimum regardless of concurrence situation, so make sure that design is at // least that high. - FinalSysSizing(AirLoopNum).DesHeatVolFlow = max(airLoopHeatingMinimumFlowRateSum, FinalSysSizing(AirLoopNum).DesHeatVolFlow); - FinalSysSizing(AirLoopNum).DesMainVolFlow = max(airLoopHeatingMinimumFlowRateSum, FinalSysSizing(AirLoopNum).DesMainVolFlow); - FinalSysSizing(AirLoopNum).DesCoolVolFlow = FinalSysSizing(AirLoopNum).DesMainVolFlow; - FinalSysSizing(AirLoopNum).MassFlowAtCoolPeak = FinalSysSizing(AirLoopNum).DesCoolVolFlow * state.dataEnvrn->StdRhoAir; - } else if (FinalSysSizing(AirLoopNum).sysSizeHeatingDominant) { // use maximum heating flow sum from air terminals - FinalSysSizing(AirLoopNum).DesHeatVolFlow = max(airLoopHeatingMaximumFlowRateSum, FinalSysSizing(AirLoopNum).DesHeatVolFlow); - FinalSysSizing(AirLoopNum).DesMainVolFlow = max(airLoopHeatingMaximumFlowRateSum, FinalSysSizing(AirLoopNum).DesMainVolFlow); + finalSysSizing.DesHeatVolFlow = max(airLoopHeatingMinimumFlowRateSum, finalSysSizing.DesHeatVolFlow); + finalSysSizing.DesMainVolFlow = max(airLoopHeatingMinimumFlowRateSum, finalSysSizing.DesMainVolFlow); + finalSysSizing.DesCoolVolFlow = finalSysSizing.DesMainVolFlow; + finalSysSizing.MassFlowAtCoolPeak = finalSysSizing.DesCoolVolFlow * state.dataEnvrn->StdRhoAir; + } else if (finalSysSizing.sysSizeHeatingDominant) { // use maximum heating flow sum from air terminals + finalSysSizing.DesHeatVolFlow = max(airLoopHeatingMaximumFlowRateSum, finalSysSizing.DesHeatVolFlow); + finalSysSizing.DesMainVolFlow = max(airLoopHeatingMaximumFlowRateSum, finalSysSizing.DesMainVolFlow); // make sure cooling is at least at minimum. - FinalSysSizing(AirLoopNum).DesCoolVolFlow = max(airLoopHeatingMinimumFlowRateSum, FinalSysSizing(AirLoopNum).DesCoolVolFlow); - FinalSysSizing(AirLoopNum).MassFlowAtCoolPeak = FinalSysSizing(AirLoopNum).DesCoolVolFlow * state.dataEnvrn->StdRhoAir; + finalSysSizing.DesCoolVolFlow = max(airLoopHeatingMinimumFlowRateSum, finalSysSizing.DesCoolVolFlow); + finalSysSizing.MassFlowAtCoolPeak = finalSysSizing.DesCoolVolFlow * state.dataEnvrn->StdRhoAir; } } // report out adjusted design flow rates BaseSizer::reportSizerOutput( - state, "AirLoopHVAC", curName, "Adjusted Heating Design Air Flow Rate [m3/s]", FinalSysSizing(AirLoopNum).DesHeatVolFlow); + state, "AirLoopHVAC", curName, "Adjusted Heating Design Air Flow Rate [m3/s]", finalSysSizing.DesHeatVolFlow); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchSysSizAdjustedHtAir, curName, FinalSysSizing(AirLoopNum).DesHeatVolFlow, 4); + state, state.dataOutRptPredefined->pdchSysSizAdjustedHtAir, curName, finalSysSizing.DesHeatVolFlow, 4); BaseSizer::reportSizerOutput( - state, "AirLoopHVAC", curName, "Adjusted Cooling Design Air Flow Rate [m3/s]", FinalSysSizing(AirLoopNum).DesCoolVolFlow); + state, "AirLoopHVAC", curName, "Adjusted Cooling Design Air Flow Rate [m3/s]", finalSysSizing.DesCoolVolFlow); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchSysSizAdjustedClAir, curName, FinalSysSizing(AirLoopNum).DesCoolVolFlow, 4); + state, state.dataOutRptPredefined->pdchSysSizAdjustedClAir, curName, finalSysSizing.DesCoolVolFlow, 4); BaseSizer::reportSizerOutput( - state, "AirLoopHVAC", curName, "Adjusted Main Design Air Flow Rate [m3/s]", FinalSysSizing(AirLoopNum).DesMainVolFlow); + state, "AirLoopHVAC", curName, "Adjusted Main Design Air Flow Rate [m3/s]", finalSysSizing.DesMainVolFlow); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchSysSizAdjustedMainAir, curName, FinalSysSizing(AirLoopNum).DesMainVolFlow, 4); + state, state.dataOutRptPredefined->pdchSysSizAdjustedMainAir, curName, finalSysSizing.DesMainVolFlow, 4); // Autosize central heating min system air flow rate, using corrected design heating flow, using maximum heating flow summation - if (FinalSysSizing(AirLoopNum).SysAirMinFlowRatWasAutoSized) { - if (FinalSysSizing(AirLoopNum).DesMainVolFlow > 0.0) { // protect div by zero - FinalSysSizing(AirLoopNum).SysAirMinFlowRat = - FinalSysSizing(AirLoopNum).DesHeatVolFlow / FinalSysSizing(AirLoopNum).DesMainVolFlow; + if (finalSysSizing.SysAirMinFlowRatWasAutoSized) { + if (finalSysSizing.DesMainVolFlow > 0.0) { // protect div by zero + finalSysSizing.SysAirMinFlowRat = finalSysSizing.DesHeatVolFlow / finalSysSizing.DesMainVolFlow; } else { // big trouble anyway. - FinalSysSizing(AirLoopNum).SysAirMinFlowRat = 1.0; + finalSysSizing.SysAirMinFlowRat = 1.0; } BaseSizer::reportSizerOutput( - state, "AirLoopHVAC", curName, "Calculated Heating Air Flow Ratio []", FinalSysSizing(AirLoopNum).SysAirMinFlowRat); + state, "AirLoopHVAC", curName, "Calculated Heating Air Flow Ratio []", finalSysSizing.SysAirMinFlowRat); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchSysSizCalcHeatFlowRatio, curName, FinalSysSizing(AirLoopNum).SysAirMinFlowRat, 4); - BaseSizer::reportSizerOutput( - state, "AirLoopHVAC", curName, "User Heating Air Flow Ratio []", FinalSysSizing(AirLoopNum).SysAirMinFlowRat); + state, state.dataOutRptPredefined->pdchSysSizCalcHeatFlowRatio, curName, finalSysSizing.SysAirMinFlowRat, 4); + BaseSizer::reportSizerOutput(state, "AirLoopHVAC", curName, "User Heating Air Flow Ratio []", finalSysSizing.SysAirMinFlowRat); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchSysSizUserHeatFlowRatio, curName, FinalSysSizing(AirLoopNum).SysAirMinFlowRat, 4); + state, state.dataOutRptPredefined->pdchSysSizUserHeatFlowRatio, curName, finalSysSizing.SysAirMinFlowRat, 4); } else { - BaseSizer::reportSizerOutput( - state, "AirLoopHVAC", curName, "User Heating Air Flow Ratio []", FinalSysSizing(AirLoopNum).SysAirMinFlowRat); + BaseSizer::reportSizerOutput(state, "AirLoopHVAC", curName, "User Heating Air Flow Ratio []", finalSysSizing.SysAirMinFlowRat); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchSysSizUserHeatFlowRatio, curName, FinalSysSizing(AirLoopNum).SysAirMinFlowRat, 4); + state, state.dataOutRptPredefined->pdchSysSizUserHeatFlowRatio, curName, finalSysSizing.SysAirMinFlowRat, 4); Real64 calcSysAirMinFlowRat(0.0); - if (FinalSysSizing(AirLoopNum).DesMainVolFlow > 0.0) { // protect div by zero - calcSysAirMinFlowRat = FinalSysSizing(AirLoopNum).DesHeatVolFlow / FinalSysSizing(AirLoopNum).DesMainVolFlow; + if (finalSysSizing.DesMainVolFlow > 0.0) { // protect div by zero + calcSysAirMinFlowRat = finalSysSizing.DesHeatVolFlow / finalSysSizing.DesMainVolFlow; } BaseSizer::reportSizerOutput(state, "AirLoopHVAC", curName, "Calculated Heating Air Flow Ratio []", calcSysAirMinFlowRat); OutputReportPredefined::PreDefTableEntry( From c44ac2315cc738d10bfba97b08a0fcc8e2cac450 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 02:03:04 -0400 Subject: [PATCH 85/99] reduce --- src/EnergyPlus/SizingManager.cc | 48 ++++++++++++++------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index 63244a626b0..cc9a42c3540 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -2171,11 +2171,9 @@ void GetOARequirements(EnergyPlusData &state) static constexpr std::string_view RoutineName("GetOARequirements: "); // include trailing blank space - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int TotalArgs; // Total number of alpha and numeric arguments (max) for a - int IOStatus; // Used in GetObjectItem - bool ErrorsFound(false); // If errors detected in input + int NumAlphas; // Number of Alphas for each GetObjectItem call + int NumNumbers; // Number of Numbers for each GetObjectItem call + int TotalArgs; // Total number of alpha and numeric arguments (max) for a std::string CurrentModuleObject; // for ease in getting objects Array1D_string Alphas; // Alpha input items for object @@ -2200,6 +2198,8 @@ void GetOARequirements(EnergyPlusData &state) lNumericBlanks.dimension(NumNumbers, true); if (state.dataSize->NumOARequirements > 0) { + int IOStatus; // Used in GetObjectItem + bool ErrorsFound(false); // If errors detected in input state.dataSize->OARequirements.allocate(state.dataSize->NumOARequirements); // Start Loading the System Input @@ -2466,9 +2466,6 @@ void GetZoneAirDistribution(EnergyPlusData &state) int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call int TotalArgs; // Total number of alpha and numeric arguments (max) for a - int IOStatus; // Used in GetObjectItem - int ZADIndex; - bool ErrorsFound(false); // If errors detected in input std::string CurrentModuleObject; // for ease in getting objects Array1D_string Alphas; // Alpha input items for object @@ -2490,10 +2487,12 @@ void GetZoneAirDistribution(EnergyPlusData &state) lNumericBlanks.dimension(NumNumbers, true); if (state.dataSize->NumZoneAirDistribution > 0) { + int IOStatus; // Used in GetObjectItem + bool ErrorsFound(false); // If errors detected in input state.dataSize->ZoneAirDistribution.allocate(state.dataSize->NumZoneAirDistribution); // Start Loading the zone air distribution input - for (ZADIndex = 1; ZADIndex <= state.dataSize->NumZoneAirDistribution; ++ZADIndex) { + for (int ZADIndex = 1; ZADIndex <= state.dataSize->NumZoneAirDistribution; ++ZADIndex) { state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, @@ -2717,25 +2716,17 @@ void GetZoneSizingInput(EnergyPlusData &state) // Using/Aliasing // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneSizIndex; // loop index int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int NumDesDays; // Number of design days in input int NumSizingZoneStatements; int Item; int Item1; - int ZLItem; bool errFlag; Array1D_string ZoneNames; int NumZones; int NumZoneLists; - int OAIndex; // Index of design specification object - int ObjIndex; // Index of zone air distribution effectiveness object name - bool DesHeatMaxAirFlowPerAreaUsrInp; - bool DesHeatMaxAirFlowUsrInp; - bool DesHeatMaxAirFlowFracUsrInp; struct GlobalMiscObject { @@ -2786,7 +2777,7 @@ void GetZoneSizingInput(EnergyPlusData &state) SizingZoneObjects(Item).Name = state.dataIPShortCut->cAlphaArgs(1); Item1 = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(1), ZoneNames, NumZones); - ZLItem = 0; + int ZLItem = 0; if (Item1 == 0 && NumZoneLists > 0) ZLItem = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(1), ZoneListNames); if (Item1 > 0) { SizingZoneObjects(Item).StartPtr = state.dataSize->NumZoneSizingInput + 1; @@ -2818,16 +2809,16 @@ void GetZoneSizingInput(EnergyPlusData &state) } if (state.dataSize->NumZoneSizingInput > 0) { - NumDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") + - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") + - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType"); + int NumDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") + + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") + + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType"); if (NumDesDays == 0 && (state.dataGlobal->DoZoneSizing || state.dataGlobal->DoSystemSizing || state.dataGlobal->DoPlantSizing)) { ShowSevereError(state, "Zone Sizing calculations need SizingPeriod:* input. None found."); ErrorsFound = true; } state.dataSize->ZoneSizingInput.allocate(state.dataSize->NumZoneSizingInput); - ZoneSizIndex = 0; + int ZoneSizIndex = 0; for (Item = 1; Item <= NumSizingZoneStatements; ++Item) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -3003,7 +2994,8 @@ void GetZoneSizingInput(EnergyPlusData &state) // Getting zone OA parameters from Design Specification object if (!state.dataIPShortCut->lAlphaFieldBlanks(4)) { - OAIndex = Util::FindItemInList(state.dataSize->ZoneSizingInput(ZoneSizIndex).DesignSpecOAObjName, state.dataSize->OARequirements); + int OAIndex = + Util::FindItemInList(state.dataSize->ZoneSizingInput(ZoneSizIndex).DesignSpecOAObjName, state.dataSize->OARequirements); if (OAIndex > 0) { state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneDesignSpecOAIndex = OAIndex; } else { @@ -3146,7 +3138,7 @@ void GetZoneSizingInput(EnergyPlusData &state) // \default .002032 // \note default is .40 cfm/ft2 // \note This input is not currently used for autosizing any of the components. - DesHeatMaxAirFlowPerAreaUsrInp = false; + bool DesHeatMaxAirFlowPerAreaUsrInp = false; if (state.dataIPShortCut->lNumericFieldBlanks(14)) { if (state.dataIPShortCut->rNumericArgs(14) <= 0.0) { // in case someone changes the default in the IDD state.dataSize->ZoneSizingInput(ZoneSizIndex).DesHeatMaxAirFlowPerArea = 0.002032; @@ -3171,7 +3163,7 @@ void GetZoneSizingInput(EnergyPlusData &state) // \default .1415762 // \note default is 300 cfm // \note This input is not currently used for autosizing any of the components. - DesHeatMaxAirFlowUsrInp = false; + bool DesHeatMaxAirFlowUsrInp = false; if (state.dataIPShortCut->lNumericFieldBlanks(15)) { if (state.dataIPShortCut->rNumericArgs(15) <= 0.0) { // in case someone changes the default in the IDD state.dataSize->ZoneSizingInput(ZoneSizIndex).DesHeatMaxAirFlow = 0.1415762; @@ -3195,7 +3187,7 @@ void GetZoneSizingInput(EnergyPlusData &state) // \type real // \minimum 0 // \default 0.3 - DesHeatMaxAirFlowFracUsrInp = false; + bool DesHeatMaxAirFlowFracUsrInp = false; if (state.dataIPShortCut->lNumericFieldBlanks(16)) { if (state.dataIPShortCut->rNumericArgs(16) <= 0.0) { // in case someone changes the default in the IDD state.dataSize->ZoneSizingInput(ZoneSizIndex).DesHeatMaxAirFlowFrac = 0.3; @@ -3229,8 +3221,8 @@ void GetZoneSizingInput(EnergyPlusData &state) // A7, \field Zone Air Distribution Object Name and add its inputs if (!state.dataIPShortCut->lAlphaFieldBlanks(7)) { state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneAirDistEffObjName = state.dataIPShortCut->cAlphaArgs(7); - ObjIndex = Util::FindItemInList(state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneAirDistEffObjName, - state.dataSize->ZoneAirDistribution); + int ObjIndex = Util::FindItemInList(state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneAirDistEffObjName, + state.dataSize->ZoneAirDistribution); if (ObjIndex > 0) { state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneADEffCooling = state.dataSize->ZoneAirDistribution(ObjIndex).ZoneADEffCooling; From 409b251111fc0706610d9f9b709806764d7da3a4 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 02:09:30 -0400 Subject: [PATCH 86/99] reduce --- src/EnergyPlus/SizingManager.cc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index cc9a42c3540..e9ad8de1fb3 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -3517,7 +3517,6 @@ void GetSystemSizingInput(EnergyPlusData &state) int NumNumbers; // Number of Numbers for each GetObjectItem call int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int NumDesDays; // Number of design days in input auto &SysSizInput = state.dataSize->SysSizInput; @@ -3527,9 +3526,9 @@ void GetSystemSizingInput(EnergyPlusData &state) state.dataSize->NumSysSizInput = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataSize->NumSysSizInput > 0) { - NumDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") + - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") + - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType"); + int NumDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") + + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") + + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType"); if (NumDesDays == 0 && (state.dataGlobal->DoSystemSizing || state.dataGlobal->DoPlantSizing)) { ShowSevereError(state, "System Sizing calculations need SizingPeriod:* input. None found."); ErrorsFound = true; @@ -4062,15 +4061,14 @@ void GetPlantSizingInput(EnergyPlusData &state) int NumNumbers; // Number of Numbers for each GetObjectItem call int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - int NumDesDays; // Number of design days in input auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "Sizing:Plant"; state.dataSize->NumPltSizInput = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (state.dataSize->NumPltSizInput > 0) { - NumDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") + - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") + - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType"); + int NumDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") + + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") + + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType"); if (NumDesDays == 0 && state.dataGlobal->DoPlantSizing) { ShowSevereError(state, "Plant Sizing calculations need SizingPeriod:* input"); ErrorsFound = true; @@ -4636,8 +4634,6 @@ void GetZoneHVACSizing(EnergyPlusData &state) int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call int TotalArgs; // Total number of alpha and numeric arguments (max) for a - int IOStatus; // Used in GetObjectItem - int zSIndex; // index of "DesignSpecification:ZoneHVAC:Sizing" objects bool ErrorsFound(false); // If errors detected in input // REAL(r64) :: CalcAmt @@ -4661,10 +4657,11 @@ void GetZoneHVACSizing(EnergyPlusData &state) lNumericBlanks.dimension(NumNumbers, true); if (state.dataSize->NumZoneHVACSizing > 0) { + int IOStatus; // Used in GetObjectItem state.dataSize->ZoneHVACSizing.allocate(state.dataSize->NumZoneHVACSizing); // Start Loading the System Input - for (zSIndex = 1; zSIndex <= state.dataSize->NumZoneHVACSizing; ++zSIndex) { + for (int zSIndex = 1; zSIndex <= state.dataSize->NumZoneHVACSizing; ++zSIndex) { Alphas = ""; cAlphaFields = ""; @@ -5220,7 +5217,6 @@ void GetAirTerminalSizing(EnergyPlusData &state) int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call int TotalArgs; // Total number of alpha and numeric arguments (max) for a - int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // If errors detected in input auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "DesignSpecification:AirTerminal:Sizing"; @@ -5228,6 +5224,7 @@ void GetAirTerminalSizing(EnergyPlusData &state) state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNumbers); if (state.dataSize->NumAirTerminalSizingSpec > 0) { + int IOStatus; // Used in GetObjectItem state.dataSize->AirTerminalSizingSpec.allocate(state.dataSize->NumAirTerminalSizingSpec); // Start Loading the System Input From 848cde53e59140f483fce7be3eaf5430273c7ec5 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 02:19:36 -0400 Subject: [PATCH 87/99] const --- src/EnergyPlus/SizingManager.cc | 14 +++++++------- src/EnergyPlus/SizingManager.hh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index e9ad8de1fb3..a54ebf05933 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -734,7 +734,7 @@ void ManageSizing(EnergyPlusData &state) } } -bool CalcdoLoadComponentPulseNow(EnergyPlusData &state, +bool CalcdoLoadComponentPulseNow(EnergyPlusData const &state, bool const isPulseZoneSizing, bool const WarmupFlag, int const HourOfDay, @@ -789,7 +789,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up heating and max flows for any single duct systems, store 62.1 values by zone if (allocated(sd_airterminal) && state.dataSingleDuct->NumSDAirTerminal > 0) { for (int singleDuctATUNum = 1; singleDuctATUNum <= state.dataSingleDuct->NumSDAirTerminal; ++singleDuctATUNum) { - auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(sd_airterminal(singleDuctATUNum).ADUNum); + auto const &airDistUnit = state.dataDefineEquipment->AirDistUnit(sd_airterminal(singleDuctATUNum).ADUNum); if (AirLoopNum == sd_airterminal(singleDuctATUNum).AirLoopNum) { int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopMaxFlowRateSum += sd_airterminal(singleDuctATUNum).MaxAirVolFlowRate; @@ -861,7 +861,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) if (allocated(state.dataDualDuct->dd_airterminal) && state.dataDualDuct->NumDDAirTerminal > 0) { for (int dualDuctATUNum = 1; dualDuctATUNum <= state.dataDualDuct->NumDDAirTerminal; ++dualDuctATUNum) { if (AirLoopNum == state.dataDualDuct->dd_airterminal(dualDuctATUNum).AirLoopNum) { - auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataDualDuct->dd_airterminal(dualDuctATUNum).ADUNum); + auto const &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataDualDuct->dd_airterminal(dualDuctATUNum).ADUNum); int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopMaxFlowRateSum += state.dataDualDuct->dd_airterminal(dualDuctATUNum).MaxAirVolFlowRate; state.dataSize->VpzClgByZone(termUnitSizingIndex) = @@ -927,7 +927,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up heating and max flows for any PIU air terminals if (allocated(state.dataPowerInductionUnits->PIU) && state.dataPowerInductionUnits->NumPIUs > 0) { for (int pIUATUNum = 1; pIUATUNum <= state.dataPowerInductionUnits->NumPIUs; ++pIUATUNum) { - auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataPowerInductionUnits->PIU(pIUATUNum).ADUNum); + auto const &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataPowerInductionUnits->PIU(pIUATUNum).ADUNum); if (AirLoopNum == state.dataPowerInductionUnits->PIU(pIUATUNum).AirLoopNum) { int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; auto &thisTermUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(termUnitSizingIndex); @@ -1019,7 +1019,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // dual path for std 62.1 if (allocated(IndUnit) && (NumIndUnits > 0)) { for (int indUnitNum = 1; indUnitNum <= NumIndUnits; ++indUnitNum) { - auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(IndUnit(indUnitNum).ADUNum); + auto const &airDistUnit = state.dataDefineEquipment->AirDistUnit(IndUnit(indUnitNum).ADUNum); if (AirLoopNum == IndUnit(indUnitNum).AirLoopNum) { int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopHeatingMaximumFlowRateSum += IndUnit(indUnitNum).MaxPriAirMassFlow / state.dataEnvrn->StdRhoAir; @@ -1041,7 +1041,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up heating and max flows for any two pipe constant volume cooled beam terminal units if (allocated(state.dataHVACCooledBeam->CoolBeam) && (state.dataHVACCooledBeam->NumCB > 0)) { for (int coolBeamNum = 1; coolBeamNum <= state.dataHVACCooledBeam->NumCB; ++coolBeamNum) { - auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataHVACCooledBeam->CoolBeam(coolBeamNum).ADUNum); + auto const &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataHVACCooledBeam->CoolBeam(coolBeamNum).ADUNum); if (AirLoopNum == state.dataHVACCooledBeam->CoolBeam(coolBeamNum).AirLoopNum) { int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopHeatingMaximumFlowRateSum += state.dataHVACCooledBeam->CoolBeam(coolBeamNum).MaxAirVolFlow; @@ -1089,7 +1089,7 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // sum up flows for any air terminal mixers if (allocated(state.dataSingleDuct->SysATMixer) && (state.dataSingleDuct->NumATMixers > 0)) { for (int aTMixerNum = 1; aTMixerNum <= state.dataSingleDuct->NumATMixers; ++aTMixerNum) { - auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->SysATMixer(aTMixerNum).ADUNum); + auto const &airDistUnit = state.dataDefineEquipment->AirDistUnit(state.dataSingleDuct->SysATMixer(aTMixerNum).ADUNum); if (AirLoopNum == state.dataSingleDuct->SysATMixer(aTMixerNum).AirLoopNum) { int termUnitSizingIndex = airDistUnit.TermUnitSizingNum; airLoopHeatingMaximumFlowRateSum += state.dataSingleDuct->SysATMixer(aTMixerNum).DesignPrimaryAirVolRate; diff --git a/src/EnergyPlus/SizingManager.hh b/src/EnergyPlus/SizingManager.hh index edcd461b46d..0d14448a1a6 100644 --- a/src/EnergyPlus/SizingManager.hh +++ b/src/EnergyPlus/SizingManager.hh @@ -81,7 +81,7 @@ namespace SizingManager { void ManageSizing(EnergyPlusData &state); bool CalcdoLoadComponentPulseNow( - EnergyPlusData &state, bool isPulseZoneSizing, bool WarmupFlag, int HourOfDay, int TimeStep, Constant::KindOfSim KindOfSim); + EnergyPlusData const &state, bool isPulseZoneSizing, bool WarmupFlag, int HourOfDay, int TimeStep, Constant::KindOfSim KindOfSim); void ManageSystemSizingAdjustments(EnergyPlusData &state); From e1b13c34e9f596804ea67fbd5531dedf88ea96e3 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 02:31:17 -0400 Subject: [PATCH 88/99] reduce class reference --- src/EnergyPlus/SizingManager.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index a54ebf05933..d1226ca1983 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -2010,7 +2010,6 @@ void ManageSystemVentilationAdjustments(EnergyPlusData &state) void DetermineSystemPopulationDiversity(EnergyPlusData &state) { - auto &FinalSysSizing = state.dataSize->FinalSysSizing; auto &SysSizInput = state.dataSize->SysSizInput; // determine Pz sum, Ps, and D for each air system for standard 62.1 @@ -2018,18 +2017,19 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) // first determine if any airloops use VRP, if not then don't need to march thru year of schedules for performance bool anyVRPinModel(false); for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { - if (FinalSysSizing(AirLoopNum).SystemOAMethod == SysOAMethod::VRP || FinalSysSizing(AirLoopNum).SystemOAMethod == SysOAMethod::SP) { + auto const &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); + if (finalSysSizing.SystemOAMethod == SysOAMethod::VRP || finalSysSizing.SystemOAMethod == SysOAMethod::SP) { anyVRPinModel = true; break; } } // First get the design (max) level of people in all zones connected to air loop for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { - int SysSizNum = - Util::FindItemInList(FinalSysSizing(AirLoopNum).AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); + auto const &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); + int SysSizNum = Util::FindItemInList(finalSysSizing.AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); if (SysSizNum == 0) SysSizNum = 1; // use first when none applicable // only retrieve data if the occupant density is set to be autosized - if (FinalSysSizing(AirLoopNum).OAAutoSized && SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { + if (finalSysSizing.OAAutoSized && SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { auto &pzSumBySys = state.dataSize->PzSumBySys(AirLoopNum); pzSumBySys = 0.0; state.dataSize->PsBySys(AirLoopNum) = 0.0; @@ -2072,10 +2072,11 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) Real64 TSfraction(0.0); if (state.dataGlobal->NumOfTimeStepInHour > 0.0) TSfraction = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour); for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { // loop over all the air systems - int SysSizNum = Util::FindItemInList( - FinalSysSizing(AirLoopNum).AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); + auto const &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); + int SysSizNum = + Util::FindItemInList(finalSysSizing.AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); if (SysSizNum == 0) SysSizNum = 1; // use first when none applicable - if (FinalSysSizing(AirLoopNum).OAAutoSized && SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { + if (finalSysSizing.OAAutoSized && SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { // Loop over all zones connected to air loop Real64 TotConcurrentPeopleOnSys = 0.0; @@ -2120,8 +2121,8 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) // compute D for standard 62.1 by system for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { - int SysSizNum = - Util::FindItemInList(FinalSysSizing(AirLoopNum).AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); + auto const &finalSysSizing = state.dataSize->FinalSysSizing(AirLoopNum); + int SysSizNum = Util::FindItemInList(finalSysSizing.AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); if (SysSizNum == 0) SysSizNum = 1; // use first when none applicable // compute D if set to autosize @@ -2144,7 +2145,7 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) state, format("The {} air loop serves a single zone. The Occupant Diversity was calculated or set to a value less than 1.0. Single-zone air " "loops should have an Occupant Diversity of 1.0. The Occupant Diversity value for that air loop has been reset to 1.0", - FinalSysSizing(AirLoopNum).AirPriLoopName)); + finalSysSizing.AirPriLoopName)); } } } From 32a990f11b951792ecd75e912a31d1098e745da6 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 02:36:03 -0400 Subject: [PATCH 89/99] reduce class reference --- src/EnergyPlus/SizingManager.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index d1226ca1983..c2a9766ca5c 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -2010,8 +2010,6 @@ void ManageSystemVentilationAdjustments(EnergyPlusData &state) void DetermineSystemPopulationDiversity(EnergyPlusData &state) { - auto &SysSizInput = state.dataSize->SysSizInput; - // determine Pz sum, Ps, and D for each air system for standard 62.1 // first determine if any airloops use VRP, if not then don't need to march thru year of schedules for performance @@ -2029,7 +2027,7 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) int SysSizNum = Util::FindItemInList(finalSysSizing.AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); if (SysSizNum == 0) SysSizNum = 1; // use first when none applicable // only retrieve data if the occupant density is set to be autosized - if (finalSysSizing.OAAutoSized && SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { + if (finalSysSizing.OAAutoSized && state.dataSize->SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { auto &pzSumBySys = state.dataSize->PzSumBySys(AirLoopNum); pzSumBySys = 0.0; state.dataSize->PsBySys(AirLoopNum) = 0.0; @@ -2076,7 +2074,7 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) int SysSizNum = Util::FindItemInList(finalSysSizing.AirPriLoopName, state.dataSize->SysSizInput, &SystemSizingInputData::AirPriLoopName); if (SysSizNum == 0) SysSizNum = 1; // use first when none applicable - if (finalSysSizing.OAAutoSized && SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { + if (finalSysSizing.OAAutoSized && state.dataSize->SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { // Loop over all zones connected to air loop Real64 TotConcurrentPeopleOnSys = 0.0; @@ -2126,7 +2124,7 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) if (SysSizNum == 0) SysSizNum = 1; // use first when none applicable // compute D if set to autosize - if (SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { + if (state.dataSize->SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { if (state.dataSize->PzSumBySys(AirLoopNum) > 0.0) { state.dataSize->DBySys(AirLoopNum) = state.dataSize->PsBySys(AirLoopNum) / state.dataSize->PzSumBySys(AirLoopNum); } else { @@ -2135,7 +2133,7 @@ void DetermineSystemPopulationDiversity(EnergyPlusData &state) state.dataSize->DBySys(AirLoopNum) = min(1.0, state.dataSize->DBySys(AirLoopNum)); } else { // set the occupant diversity based on user-specified value - state.dataSize->DBySys(AirLoopNum) = SysSizInput(SysSizNum).OccupantDiversity; + state.dataSize->DBySys(AirLoopNum) = state.dataSize->SysSizInput(SysSizNum).OccupantDiversity; } // For single zone systems, D should be 1.0. From dd3919b00cdd53b8bd1116e1669f840b3d7d1296 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 02:46:27 -0400 Subject: [PATCH 90/99] reduce and const --- src/EnergyPlus/SizingManager.cc | 4 +--- src/EnergyPlus/SizingManager.hh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index c2a9766ca5c..c040b0f4913 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -3389,9 +3389,7 @@ void GetZoneAndZoneListNames( int NumAlphas; int NumNumbers; int IOStatus; - bool InErrFlag; // Preserve (no current use) the input status of ErrorsFound - InErrFlag = ErrorsFound; auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "Zone"; NumZones = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); @@ -4544,7 +4542,7 @@ void ReportSysSizing(EnergyPlusData &state, } // convert an index for the timestep of the day into a hour minute string in the format 00:00 -std::string TimeIndexToHrMinString(EnergyPlusData &state, int timeIndex) +std::string TimeIndexToHrMinString(EnergyPlusData const &state, int timeIndex) { int tMinOfDay = timeIndex * state.dataGlobal->MinutesPerTimeStep; int tHr = int(tMinOfDay / 60.); diff --git a/src/EnergyPlus/SizingManager.hh b/src/EnergyPlus/SizingManager.hh index 0d14448a1a6..3a16f84b4bc 100644 --- a/src/EnergyPlus/SizingManager.hh +++ b/src/EnergyPlus/SizingManager.hh @@ -166,7 +166,7 @@ namespace SizingManager { int TimeStepIndex // time step of the peak ); - std::string TimeIndexToHrMinString(EnergyPlusData &state, int timeIndex); + std::string TimeIndexToHrMinString(EnergyPlusData const &state, int timeIndex); void UpdateFacilitySizing(EnergyPlusData &state, Constant::CallIndicator CallIndicator); From f93c075ab829955ba401ea40f398901149e2c0fc Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sun, 20 Oct 2024 03:00:44 -0400 Subject: [PATCH 91/99] cleanup --- src/EnergyPlus/SizingManager.cc | 65 ++++----------------------------- 1 file changed, 7 insertions(+), 58 deletions(-) diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index c040b0f4913..4f5b83f2d5e 100644 --- a/src/EnergyPlus/SizingManager.cc +++ b/src/EnergyPlus/SizingManager.cc @@ -86,12 +86,9 @@ namespace EnergyPlus::SizingManager { // MODULE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN December 2000 -// MODIFIED na -// RE-ENGINEERED na // PURPOSE OF THIS MODULE: -// This module contains the data and routines relating to managing the sizing -// simulations. +// This module contains the data and routines relating to managing the sizing simulations. // Using/Aliasing using namespace HeatBalanceManager; @@ -2306,8 +2303,6 @@ void ProcessInputOARequirements(EnergyPlusData &state, // SUBROUTINE INFORMATION: // AUTHOR R. Raustad - FSEC // DATE WRITTEN February 2010 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for the OA Requirements object and stores it in @@ -2318,26 +2313,13 @@ void ProcessInputOARequirements(EnergyPlusData &state, // This object requires only a name where the default values are assumed // if subsequent fields are not entered. - // REFERENCES: - // na - using ScheduleManager::CheckScheduleValueMinMax; using ScheduleManager::GetScheduleIndex; using ScheduleManager::GetScheduleMaxValue; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // na - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetOARequirements: "); // include trailing blank space - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - auto &thisOARequirements(state.dataSize->OARequirements(OAIndex)); if (NumAlphas > 1) { @@ -2442,8 +2424,6 @@ void GetZoneAirDistribution(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR T. Hong - LBNL // DATE WRITTEN March 2012 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for the zone air distribution objects and stores it in @@ -2582,8 +2562,6 @@ void GetSizingParams(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN January 2002 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for the Sizing Parameters object and stores it in @@ -2592,17 +2570,14 @@ void GetSizingParams(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses InputProcessor "Get" routines to obtain data. - // Using/Aliasing - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call int IOStatus; // Used in GetObjectItem - int NumSizParams; - int Temp; + auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "Sizing:Parameters"; - NumSizParams = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + int NumSizParams = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (NumSizParams == 1) { state.dataInputProcessing->inputProcessor->getObjectItem(state, @@ -2655,7 +2630,7 @@ void GetSizingParams(EnergyPlusData &state) } cCurrentModuleObject = "OutputControl:Sizing:Style"; - Temp = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + int Temp = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (Temp == 0) { state.dataIPShortCut->cAlphaArgs(1) = "Comma"; @@ -2703,17 +2678,11 @@ void GetZoneSizingInput(EnergyPlusData &state) // AUTHOR Fred Buhl // DATE WRITTEN December 2000 // MODIFIED Mangesh Basarkar, 06/2011: Specifying zone outside air based on design specification object - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for zone sizing objects and stores it in // appropriate data structures. - // METHODOLOGY EMPLOYED: - // Uses InputProcessor "Get" routines to obtain data. - - // Using/Aliasing - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int NumAlphas; // Number of Alphas for each GetObjectItem call int NumNumbers; // Number of Numbers for each GetObjectItem call @@ -3372,20 +3341,14 @@ void GetZoneAndZoneListNames( // SUBROUTINE INFORMATION: // AUTHOR Linda Lawrie // DATE WRITTEN October 2010 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Get Zone and ZoneList Names so Sizing:Zone can use global ZoneList. // This is not a full validation of these objects -- only enough to fill // structures for the Sizing:Zone object. - // Using/Aliasing - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Item; int Found; - int Item1; int NumAlphas; int NumNumbers; int IOStatus; @@ -3395,7 +3358,7 @@ void GetZoneAndZoneListNames( NumZones = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); ZoneNames.allocate(NumZones); - for (Item = 1; Item <= NumZones; ++Item) { + for (int Item = 1; Item <= NumZones; ++Item) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, Item, @@ -3421,7 +3384,7 @@ void GetZoneAndZoneListNames( NumZoneLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); ZoneListNames.allocate(NumZoneLists); - for (Item = 1; Item <= NumZoneLists; ++Item) { + for (int Item = 1; Item <= NumZoneLists; ++Item) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, Item, @@ -3443,7 +3406,7 @@ void GetZoneAndZoneListNames( } ZoneListNames(Item).Zones.allocate(NumAlphas - 1); ZoneListNames(Item).NumOfZones = NumAlphas - 1; - for (Item1 = 2; Item1 <= NumAlphas; ++Item1) { + for (int Item1 = 2; Item1 <= NumAlphas; ++Item1) { Found = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(Item1), ZoneNames, NumZones); ZoneListNames(Item).Zones(Item1 - 1) = Found; } @@ -3456,8 +3419,6 @@ void GetSystemSizingInput(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN January 2001 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for System Sizing objects and stores it in @@ -3466,8 +3427,6 @@ void GetSystemSizingInput(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses InputProcessor "Get" routines to obtain data. - // Using/Aliasing - // Sizing:System; constexpr int iNameAlphaNum = 1; // A1, \field AirLoop Name constexpr int iLoadTypeSizeAlphaNum = 2; // A2, \field Type of Load to Size On @@ -4040,8 +3999,6 @@ void GetPlantSizingInput(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl // DATE WRITTEN October 2001 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for Plant Sizing objects and stores it in @@ -4050,8 +4007,6 @@ void GetPlantSizingInput(EnergyPlusData &state) // METHODOLOGY EMPLOYED: // Uses InputProcessor "Get" routines to obtain data. - // Using/Aliasing - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int PltSizIndex; // loop index int NumAlphas; // Number of Alphas for each GetObjectItem call @@ -4162,8 +4117,6 @@ void SetupZoneSizing(EnergyPlusData &state, bool &ErrorsFound) // SUBROUTINE INFORMATION: // AUTHOR L. Lawrie/F. Buhl // DATE WRITTEN March 2010 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // execute a few (1) time steps of a simulation to facilitate setting up model for zone sizing @@ -4555,8 +4508,6 @@ void GetZoneHVACSizing(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR B. Nigusse - FSEC // DATE WRITTEN July 2014 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Obtains input data for the ZoneHVAC sizing methods object and stores it in @@ -4567,8 +4518,6 @@ void GetZoneHVACSizing(EnergyPlusData &state) // This object requires only a name where the default values are assumed // if subsequent fields are not entered. - // Using/Aliasing - // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetZoneHVACSizing: "); // include trailing blank space From c1e6890ff13ecf881389395fdbb7307a4e965a76 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 29 Oct 2024 08:30:25 -0500 Subject: [PATCH 92/99] Preliminary GT modeling refactor --- src/EnergyPlus/GroundHeatExchangers.cc | 10 +- src/EnergyPlus/GroundHeatExchangers.hh | 10 +- .../BaseGroundTemperatureModel.hh | 12 +- .../FiniteDifferenceGroundTemperatureModel.cc | 454 ++++++++---------- .../FiniteDifferenceGroundTemperatureModel.hh | 105 ++-- .../GroundTemperatureModelManager.cc | 43 +- .../GroundTemperatureModelManager.hh | 13 +- .../KusudaAchenbachGroundTemperatureModel.cc | 59 ++- .../KusudaAchenbachGroundTemperatureModel.hh | 26 +- .../SiteBuildingSurfaceGroundTemperatures.cc | 42 +- .../SiteBuildingSurfaceGroundTemperatures.hh | 24 +- .../SiteDeepGroundTemperatures.cc | 34 +- .../SiteDeepGroundTemperatures.hh | 23 +- .../SiteFCFactorMethodGroundTemperatures.cc | 59 ++- .../SiteFCFactorMethodGroundTemperatures.hh | 23 +- .../SiteShallowGroundTemperatures.cc | 31 +- .../SiteShallowGroundTemperatures.hh | 24 +- .../XingGroundTemperatureModel.cc | 59 +-- .../XingGroundTemperatureModel.hh | 14 +- src/EnergyPlus/PipeHeatTransfer.hh | 2 +- src/EnergyPlus/PlantPipingSystemsManager.hh | 2 +- src/EnergyPlus/WeatherManager.hh | 13 +- ...teDifferenceGroundTemperatureModel.unit.cc | 120 ++--- tst/EnergyPlus/unit/SiteGroundDomain.unit.cc | 2 +- 24 files changed, 548 insertions(+), 656 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 42010f5bb8d..750867c6d95 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -1020,9 +1020,10 @@ void GLHEVert::setupTimeVectors() this->myRespFactors->LNTTS = tempLNTTS; this->myRespFactors->time = tempLNTTS; - std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c){return exp(c) * t_s;}); + std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c) { + return exp(c) * t_s; + }); this->myRespFactors->GFNC = std::vector(tempLNTTS.size(), 0.0); - } //****************************************************************************** @@ -1368,11 +1369,12 @@ void GLHEVert::combineShortAndLongTimestepGFunctions() } this->myRespFactors->time = LNTTS_combined; - std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c){return exp(c) * t_s;}); + std::transform(this->myRespFactors->time.begin(), this->myRespFactors->time.end(), this->myRespFactors->time.begin(), [&t_s](auto &c) { + return exp(c) * t_s; + }); this->myRespFactors->LNTTS = LNTTS_combined; this->myRespFactors->GFNC = GFNC_combined; - } void GLHEBase::makeThisGLHECacheAndCompareWithFileCache(EnergyPlusData &state) diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index eab0389fef9..e686f94d61f 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -249,11 +249,11 @@ namespace GroundHeatExchangers { bool myEnvrnFlag; bool gFunctionsExist; Real64 lastQnSubHr; - Real64 HXResistance; // The thermal resistance of the GHX, (K per W/m) - Real64 totalTubeLength; // The total length of pipe. NumBoreholes * BoreholeDepth OR Pi * Dcoil * NumCoils - Real64 timeSS; // Steady state time - Real64 timeSSFactor; // Steady state time factor for calculation - std::shared_ptr groundTempModel; + Real64 HXResistance; // The thermal resistance of the GHX, (K per W/m) + Real64 totalTubeLength; // The total length of pipe. NumBoreholes * BoreholeDepth OR Pi * Dcoil * NumCoils + Real64 timeSS; // Steady state time + Real64 timeSSFactor; // Steady state time factor for calculation + BaseGroundTempsModel *groundTempModel; // non-owning pointer // some statics pulled out into member variables bool firstTime; diff --git a/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh index bb06d658b56..bafa79ddbff 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh @@ -75,26 +75,22 @@ class BaseGroundTempsModel { public: // Public Members - GroundTempObjType objectType; + GroundTempObjType objectType = GroundTempObjType::Invalid; std::string objectName; + BaseGroundTempsModel() = default; virtual ~BaseGroundTempsModel() = default; BaseGroundTempsModel(const BaseGroundTempsModel &) = delete; BaseGroundTempsModel(BaseGroundTempsModel &&) = delete; BaseGroundTempsModel &operator=(const BaseGroundTempsModel &) = delete; BaseGroundTempsModel &operator=(BaseGroundTempsModel &&) = delete; - // Default Constructor - BaseGroundTempsModel() : objectType(GroundTempObjType::Invalid) - { - } - // Virtual method for retrieving the ground temp virtual Real64 getGroundTemp(EnergyPlusData &state) = 0; - virtual Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const, Real64 const) = 0; + virtual Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64, Real64) = 0; - virtual Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const, int const) = 0; + virtual Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64, int) = 0; protected: static void write_ground_temps(InputOutputFile &os, const std::string &name, const Array1D &data) diff --git a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc index 7cb4a0bb2b1..5e50a53107c 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc @@ -47,11 +47,9 @@ // C++ Headers #include -#include // ObjexxFCL Headers #include -#include // EnergyPlus Headers #include @@ -72,7 +70,7 @@ namespace EnergyPlus { //****************************************************************************** // Finite difference model factory -std::shared_ptr FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(EnergyPlusData &state, std::string objectName) +FiniteDiffGroundTempsModel *FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -88,13 +86,13 @@ std::shared_ptr FiniteDiffGroundTempsModel::FiniteDi int IOStat; // New shared pointer for this model object - std::shared_ptr thisModel(new FiniteDiffGroundTempsModel()); + auto *thisModel = new FiniteDiffGroundTempsModel(); GroundTempObjType objType = GroundTempObjType::FiniteDiffGroundTemp; // Search through finite diff models here std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { @@ -126,12 +124,12 @@ std::shared_ptr FiniteDiffGroundTempsModel::FiniteDi // Return the pointer return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -143,13 +141,13 @@ void FiniteDiffGroundTempsModel::initAndSim(EnergyPlusData &state) // DATE WRITTEN Summer 2015 // PURPOSE OF THIS SUBROUTINE: - // Initalizes and simulated finite difference ground temps model + // Initializes and simulates finite difference ground temps model - FiniteDiffGroundTempsModel::getWeatherData(state); + getWeatherData(state); - FiniteDiffGroundTempsModel::developMesh(); + developMesh(); - FiniteDiffGroundTempsModel::performSimulation(state); + performSimulation(state); } //****************************************************************************** @@ -165,31 +163,24 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) // and data structure containing daily average of required weather data. // SUBROUTINE ARGUMENT DEFINITIONS: - bool Available; // an environment is available to process - bool ErrorsFound; - Real64 outDryBulbTemp_num; - Real64 relHum_num; - Real64 windSpeed_num; - Real64 horizSolarRad_num; - Real64 airDensity_num; - Real64 annualAveAirTemp_num; + // an environment is available to process // Save current environment so we can revert back when done - int Envrn_reset = state.dataWeather->Envrn; - Constant::KindOfSim KindOfSim_reset = state.dataGlobal->KindOfSim; - int TimeStep_reset = state.dataGlobal->TimeStep; - int HourOfDay_reset = state.dataGlobal->HourOfDay; - bool BeginEnvrnFlag_reset = state.dataGlobal->BeginEnvrnFlag; - bool EndEnvrnFlag_reset = state.dataGlobal->EndEnvrnFlag; - bool EndMonthFlag_reset = state.dataEnvrn->EndMonthFlag; - bool WarmupFlag_reset = state.dataGlobal->WarmupFlag; - int DayOfSim_reset = state.dataGlobal->DayOfSim; - std::string DayOfSimChr_reset = state.dataGlobal->DayOfSimChr; - int NumOfWarmupDays_reset = state.dataReportFlag->NumOfWarmupDays; - bool BeginDayFlag_reset = state.dataGlobal->BeginDayFlag; - bool EndDayFlag_reset = state.dataGlobal->EndDayFlag; - bool BeginHourFlag_reset = state.dataGlobal->BeginHourFlag; - bool EndHourFlag_reset = state.dataGlobal->EndHourFlag; + const int Envrn_reset = state.dataWeather->Envrn; + const Constant::KindOfSim KindOfSim_reset = state.dataGlobal->KindOfSim; + const int TimeStep_reset = state.dataGlobal->TimeStep; + const int HourOfDay_reset = state.dataGlobal->HourOfDay; + const bool BeginEnvrnFlag_reset = state.dataGlobal->BeginEnvrnFlag; + const bool EndEnvrnFlag_reset = state.dataGlobal->EndEnvrnFlag; + const bool EndMonthFlag_reset = state.dataEnvrn->EndMonthFlag; + const bool WarmupFlag_reset = state.dataGlobal->WarmupFlag; + const int DayOfSim_reset = state.dataGlobal->DayOfSim; + const std::string DayOfSimChr_reset = state.dataGlobal->DayOfSimChr; + const int NumOfWarmupDays_reset = state.dataReportFlag->NumOfWarmupDays; + const bool BeginDayFlag_reset = state.dataGlobal->BeginDayFlag; + const bool EndDayFlag_reset = state.dataGlobal->EndDayFlag; + const bool BeginHourFlag_reset = state.dataGlobal->BeginHourFlag; + const bool EndHourFlag_reset = state.dataGlobal->EndHourFlag; if (!state.dataWeather->WeatherFileExists) { ShowSevereError(state, "Site:GroundTemperature:Undisturbed:FiniteDifference -- using this model requires specification of a weather file."); @@ -199,7 +190,7 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) } // We add a new period to force running all weather data - int originalNumOfEnvn = state.dataWeather->NumOfEnvrn; + int originalNumOfEnvrn = state.dataWeather->NumOfEnvrn; ++state.dataWeather->NumOfEnvrn; ++state.dataWeather->TotRunPers; state.dataWeather->Environment.redimension(state.dataWeather->NumOfEnvrn); @@ -213,9 +204,9 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) Weather::SetupEnvironmentTypes(state); // We reset the counter to the original number of run periods, so that GetNextEnvironment will fetch the one we added - state.dataWeather->Envrn = originalNumOfEnvn; - Available = true; - ErrorsFound = false; + state.dataWeather->Envrn = originalNumOfEnvrn; + bool Available = true; + bool ErrorsFound = false; Weather::GetNextEnvironment(state, Available, ErrorsFound); if (ErrorsFound) { ShowFatalError(state, "Site:GroundTemperature:Undisturbed:FiniteDifference: error in reading weather file data"); @@ -236,18 +227,18 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) state.dataGlobal->DayOfSimChr = "0"; state.dataReportFlag->NumOfWarmupDays = 0; - annualAveAirTemp_num = 0.0; + Real64 annualAveAirTemp_num = 0.0; while ((state.dataGlobal->DayOfSim < state.dataWeather->NumDaysInYear) || (state.dataGlobal->WarmupFlag)) { // Begin day loop ... ++state.dataGlobal->DayOfSim; // Reset daily values - outDryBulbTemp_num = 0.0; - relHum_num = 0.0; - windSpeed_num = 0.0; - horizSolarRad_num = 0.0; - airDensity_num = 0.0; + Real64 outDryBulbTemp_num = 0.0; + Real64 relHum_num = 0.0; + Real64 windSpeed_num = 0.0; + Real64 horizSolarRad_num = 0.0; + Real64 airDensity_num = 0.0; int denominator = 0; auto &tdwd = weatherDataArray(state.dataGlobal->DayOfSim); // "This day weather data" @@ -322,10 +313,10 @@ void FiniteDiffGroundTempsModel::getWeatherData(EnergyPlusData &state) } // ... End day loop. - annualAveAirTemp = annualAveAirTemp_num / state.dataWeather->NumDaysInYear; // Used for initalizing domain + annualAveAirTemp = annualAveAirTemp_num / state.dataWeather->NumDaysInYear; // Used for initializing domain - // Reset Envrionment when done reading data - --state.dataWeather->NumOfEnvrn; // May need better way of eliminating the extra envrionment that was added to read the data + // Reset Environment when done reading data + --state.dataWeather->NumOfEnvrn; // May need better way of eliminating the extra environment that was added to read the data --state.dataWeather->TotRunPers; state.dataGlobal->KindOfSim = KindOfSim_reset; state.dataWeather->RPReadAllWeatherData = false; @@ -359,18 +350,17 @@ void FiniteDiffGroundTempsModel::developMesh() // Creates static mesh used for model // Surface layer parameters - Real64 surfaceLayerThickness = 2.0; - Real64 surfaceLayerCellThickness = 0.015; - int surfaceLayerNumCells = surfaceLayerThickness / surfaceLayerCellThickness; + constexpr Real64 surfaceLayerThickness = 2.0; + constexpr Real64 surfaceLayerCellThickness = 0.015; + constexpr int surfaceLayerNumCells = static_cast(surfaceLayerThickness / surfaceLayerCellThickness); // Center layer parameters - Real64 centerLayerExpansionCoeff = 1.10879; - int centerLayerNumCells = 80; + constexpr int centerLayerNumCells = 80; // Deep layer parameters - Real64 deepLayerThickness = 0.2; - Real64 deepLayerCellThickness = surfaceLayerCellThickness; - int deepLayerNumCells = deepLayerThickness / deepLayerCellThickness; + constexpr Real64 deepLayerThickness = 0.2; + constexpr Real64 deepLayerCellThickness = surfaceLayerCellThickness; + constexpr int deepLayerNumCells = static_cast(deepLayerThickness / deepLayerCellThickness); // Other Real64 currentCellDepth = 0.0; @@ -399,6 +389,7 @@ void FiniteDiffGroundTempsModel::developMesh() int numCenterCell = i - surfaceLayerNumCells; if (numCenterCell <= (centerLayerNumCells / 2)) { + Real64 centerLayerExpansionCoeff = 1.10879; thisCell.thickness = surfaceLayerCellThickness * std::pow(centerLayerExpansionCoeff, numCenterCell); } else { thisCell.thickness = @@ -493,7 +484,7 @@ void FiniteDiffGroundTempsModel::performSimulation(EnergyPlusData &state) //****************************************************************************** -void FiniteDiffGroundTempsModel::updateSurfaceCellTemperature(EnergyPlusData &state) +void FiniteDiffGroundTempsModel::updateSurfaceCellTemperature(const EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -506,84 +497,63 @@ void FiniteDiffGroundTempsModel::updateSurfaceCellTemperature(EnergyPlusData &st Real64 numerator = 0.0; Real64 denominator = 0.0; Real64 resistance = 0.0; - Real64 incidentHeatGain; - Real64 incidentSolar_MJhrmin; - Real64 evapotransHeatLoss_Wm2; - Real64 absorbedIncidentSolar_MJhrmin; - Real64 vaporPressureSaturated_kPa; - Real64 vaporPressureActual_kPa; - Real64 currAirTempK; - Real64 QRAD_NL; - Real64 netIncidentRadiation_MJhr; - Real64 netIncidentRadiation_Wm2; - Real64 slope_S; - Real64 CN; Real64 G_hr; Real64 Cd; - Real64 pressure; - Real64 psychrometricConstant; - Real64 evapotransFluidLoss_mmhr; - Real64 evapotransFluidLoss_mhr; - Real64 latentHeatVaporization; - Real64 evapotransHeatLoss_MJhrmin; - - Real64 constexpr rho_water = 998.0; // [kg/m3] - Real64 constexpr airSpecificHeat = 1003; // '[J/kg-K] + + Real64 constexpr rho_water = 998.0; // [kg/m3] // evapotranspiration parameters Real64 constexpr absor_Corrected = 0.77; - Real64 const convert_Wm2_To_MJhrmin = 3600.0 / 1000000.0; - Real64 const convert_MJhrmin_To_Wm2 = 1.0 / convert_Wm2_To_MJhrmin; + constexpr Real64 convert_Wm2_To_MJhrmin = 3600.0 / 1000000.0; + constexpr Real64 convert_MJhrmin_To_Wm2 = 1.0 / convert_Wm2_To_MJhrmin; - auto &thisCell = cellArray(1); - auto &cellBelow_thisCell = cellArray(2); - auto &cwd = weatherDataArray(state.dataGlobal->FDsimDay); // "Current Weather Day" + const auto &thisCell = cellArray(1); + const auto &cellBelow_thisCell = cellArray(2); + const auto &cwd = weatherDataArray(state.dataGlobal->FDsimDay); // "Current Weather Day" // Add effect from previous time step numerator += thisCell.temperature_prevTimeStep; ++denominator; // Conduction to lower cell - resistance = (thisCell.thickness / 2.0) / (thisCell.props.conductivity * thisCell.conductionArea) + - (cellBelow_thisCell.thickness / 2.0) / (cellBelow_thisCell.props.conductivity * cellBelow_thisCell.conductionArea); - numerator += (thisCell.beta / resistance) * cellBelow_thisCell.temperature; - denominator += (thisCell.beta / resistance); + resistance = thisCell.thickness / 2.0 / (thisCell.props.conductivity * thisCell.conductionArea) + + cellBelow_thisCell.thickness / 2.0 / (cellBelow_thisCell.props.conductivity * cellBelow_thisCell.conductionArea); + numerator += thisCell.beta / resistance * cellBelow_thisCell.temperature; + denominator += thisCell.beta / resistance; // Convection to atmosphere if (cwd.windSpeed > 0.1) { + Real64 constexpr airSpecificHeat = 1003; // '[J/kg-K] resistance = 208.0 / (cwd.airDensity * airSpecificHeat * cwd.windSpeed * thisCell.conductionArea); } else { // Future development should include additional natural convection effects here } - numerator += (thisCell.beta / resistance) * cwd.dryBulbTemp; - denominator += (thisCell.beta / resistance); - - // Initialize, this variable is used for both evapotranspiration and non-ET cases, [W] - incidentHeatGain = 0.0; + numerator += thisCell.beta / resistance * cwd.dryBulbTemp; + denominator += thisCell.beta / resistance; // For convenience convert to Kelvin once - currAirTempK = cwd.dryBulbTemp + 273.15; + const Real64 currAirTempK = cwd.dryBulbTemp + 273.15; // Convert input solar radiation [w/m2] into units for ET model, [MJ/hr-min] - // Diffuse + Direct Beam Radation - incidentSolar_MJhrmin = cwd.horizontalRadiation * convert_Wm2_To_MJhrmin; + // Diffuse + Direct Beam Radiation + const Real64 incidentSolar_MJhrmin = cwd.horizontalRadiation * convert_Wm2_To_MJhrmin; // Absorbed solar radiation, [MJ/hr-min] - absorbedIncidentSolar_MJhrmin = absor_Corrected * incidentSolar_MJhrmin; + const Real64 absorbedIncidentSolar_MJhrmin = absor_Corrected * incidentSolar_MJhrmin; // Calculate saturated vapor pressure, [kPa] - vaporPressureSaturated_kPa = 0.6108 * std::exp(17.27 * cwd.dryBulbTemp / (cwd.dryBulbTemp + 237.3)); + const Real64 vaporPressureSaturated_kPa = 0.6108 * std::exp(17.27 * cwd.dryBulbTemp / (cwd.dryBulbTemp + 237.3)); // Calculate actual vapor pressure, [kPa] - vaporPressureActual_kPa = vaporPressureSaturated_kPa * cwd.relativeHumidity; + const Real64 vaporPressureActual_kPa = vaporPressureSaturated_kPa * cwd.relativeHumidity; // Calculate another Q term, [MJ/m2-hr] - QRAD_NL = 2.042E-10 * pow_4(currAirTempK) * (0.34 - 0.14 * std::sqrt(vaporPressureActual_kPa)); + const Real64 QRAD_NL = 2.042E-10 * pow_4(currAirTempK) * (0.34 - 0.14 * std::sqrt(vaporPressureActual_kPa)); // Calculate another Q term, [MJ/hr] - netIncidentRadiation_MJhr = absorbedIncidentSolar_MJhrmin - QRAD_NL; + const Real64 netIncidentRadiation_MJhr = absorbedIncidentSolar_MJhrmin - QRAD_NL; // constant - CN = 37.0; + constexpr Real64 CN = 37.0; // Check whether there was sun if (netIncidentRadiation_MJhr < 0.0) { @@ -594,37 +564,37 @@ void FiniteDiffGroundTempsModel::updateSurfaceCellTemperature(EnergyPlusData &st Cd = 0.24; } - slope_S = 2503.0 * std::exp(17.27 * cwd.dryBulbTemp / (cwd.dryBulbTemp + 237.3)) / pow_2(cwd.dryBulbTemp + 237.3); - pressure = 98.0; - psychrometricConstant = 0.665e-3 * pressure; + const Real64 slope_S = 2503.0 * std::exp(17.27 * cwd.dryBulbTemp / (cwd.dryBulbTemp + 237.3)) / pow_2(cwd.dryBulbTemp + 237.3); + constexpr Real64 pressure = 98.0; + constexpr Real64 psychrometricConstant = 0.665e-3 * pressure; // Evapotranspiration constant, [mm/hr] - evapotransFluidLoss_mmhr = + const Real64 evapotransFluidLoss_mmhr = (evapotransCoeff * slope_S * (netIncidentRadiation_MJhr - G_hr) + psychrometricConstant * (CN / currAirTempK) * cwd.windSpeed * (vaporPressureSaturated_kPa - vaporPressureActual_kPa)) / (slope_S + psychrometricConstant * (1 + Cd * cwd.windSpeed)); // Convert units, [m/hr] - evapotransFluidLoss_mhr = evapotransFluidLoss_mmhr / 1000.0; + const Real64 evapotransFluidLoss_mhr = evapotransFluidLoss_mmhr / 1000.0; // Calculate latent heat, [MJ/kg] // Full formulation is cubic: L(T) = -0.0000614342 * T**3 + 0.00158927 * T**2 - 2.36418 * T + 2500.79[5] // In: Cubic fit to Table 2.1,p.16, Textbook: R.R.Rogers & M.K. Yau, A Short Course in Cloud Physics, 3e,(1989), Pergamon press // But a linear relation should suffice; // note-for now using the previous time step temperature as an approximation to help ensure stability - latentHeatVaporization = 2.501 - 2.361e-3 * thisCell.temperature_prevTimeStep; + const Real64 latentHeatVaporization = 2.501 - 2.361e-3 * thisCell.temperature_prevTimeStep; // Calculate evapotranspiration heat loss, [MJ/m2-hr] - evapotransHeatLoss_MJhrmin = rho_water * evapotransFluidLoss_mhr * latentHeatVaporization; + const Real64 evapotransHeatLoss_MJhrmin = rho_water * evapotransFluidLoss_mhr * latentHeatVaporization; // Convert net incident solar units, [W/m2] - netIncidentRadiation_Wm2 = netIncidentRadiation_MJhr * convert_MJhrmin_To_Wm2; + const Real64 netIncidentRadiation_Wm2 = netIncidentRadiation_MJhr * convert_MJhrmin_To_Wm2; // Convert evapotranspiration units, [W/m2] - evapotransHeatLoss_Wm2 = evapotransHeatLoss_MJhrmin * convert_MJhrmin_To_Wm2; + const Real64 evapotransHeatLoss_Wm2 = evapotransHeatLoss_MJhrmin * convert_MJhrmin_To_Wm2; // Calculate overall net heat ?gain? into the cell, [W] - incidentHeatGain = (netIncidentRadiation_Wm2 - evapotransHeatLoss_Wm2) * thisCell.conductionArea; + const Real64 incidentHeatGain = (netIncidentRadiation_Wm2 - evapotransHeatLoss_Wm2) * thisCell.conductionArea; // Add any solar/evapotranspiration heat gain here numerator += thisCell.beta * incidentHeatGain; @@ -650,28 +620,28 @@ void FiniteDiffGroundTempsModel::updateGeneralDomainCellTemperature(int const ce Real64 resistance = 0.0; auto &thisCell = cellArray(cell); - auto &cellAbove_thisCell = cellArray(cell - 1); - auto &cellBelow_thisCell = cellArray(cell + 1); + const auto &cellAbove_thisCell = cellArray(cell - 1); + const auto &cellBelow_thisCell = cellArray(cell + 1); // add effect from cell history numerator += thisCell.temperature_prevTimeStep; ++denominator; // Conduction resistance between this cell and above cell - resistance = ((thisCell.thickness / 2.0) / (thisCell.conductionArea * thisCell.props.conductivity)) + - ((cellAbove_thisCell.thickness / 2.0) / (cellAbove_thisCell.conductionArea * cellAbove_thisCell.props.conductivity)); + resistance = thisCell.thickness / 2.0 / (thisCell.conductionArea * thisCell.props.conductivity) + + cellAbove_thisCell.thickness / 2.0 / (cellAbove_thisCell.conductionArea * cellAbove_thisCell.props.conductivity); - numerator += (thisCell.beta / resistance) * cellAbove_thisCell.temperature; + numerator += thisCell.beta / resistance * cellAbove_thisCell.temperature; denominator += thisCell.beta / resistance; - // Conduction resitance between this cell and below cell - resistance = ((thisCell.thickness / 2.0) / (thisCell.conductionArea * thisCell.props.conductivity)) + - ((cellBelow_thisCell.thickness / 2.0) / (cellBelow_thisCell.conductionArea * cellBelow_thisCell.props.conductivity)); + // Conduction resistance between this cell and below cell + resistance = thisCell.thickness / 2.0 / (thisCell.conductionArea * thisCell.props.conductivity) + + cellBelow_thisCell.thickness / 2.0 / (cellBelow_thisCell.conductionArea * cellBelow_thisCell.props.conductivity); - numerator += (thisCell.beta / resistance) * cellBelow_thisCell.temperature; + numerator += thisCell.beta / resistance * cellBelow_thisCell.temperature; denominator += thisCell.beta / resistance; - //'now that we have passed all directions, update the temperature + // now that we have passed all directions, update the temperature thisCell.temperature = numerator / denominator; } @@ -721,7 +691,7 @@ void FiniteDiffGroundTempsModel::updateBottomCellTemperature() //****************************************************************************** -bool FiniteDiffGroundTempsModel::checkFinalTemperatureConvergence(EnergyPlusData &state) +bool FiniteDiffGroundTempsModel::checkFinalTemperatureConvergence(const EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -787,7 +757,7 @@ void FiniteDiffGroundTempsModel::initDomain(EnergyPlusData &state) // DATE WRITTEN Summer 2015 // PURPOSE OF THIS SUBROUTINE: - // Initalizes model using Kusuda-Achenbach model. + // Initializes model using Kusuda-Achenbach model. // Average ground temp initialized to average annual air temperature // Temporary KA model for initialization @@ -799,7 +769,7 @@ void FiniteDiffGroundTempsModel::initDomain(EnergyPlusData &state) tempModel->aveGroundTempAmplitude = (maxDailyAirTemp - minDailyAirTemp) / 4.0; // Rough estimate here. Ground temps will not swing as far as the air temp. tempModel->phaseShiftInSecs = dayOfMinDailyAirTemp * Constant::SecsInDay; - tempModel->groundThermalDiffisivity = baseConductivity / (baseDensity * baseSpecificHeat); + tempModel->groundThermalDiffusivity = baseConductivity / (baseDensity * baseSpecificHeat); // Initialize temperatures and volume for (int cell = 1; cell <= totalNumCells; ++cell) { @@ -820,7 +790,7 @@ void FiniteDiffGroundTempsModel::initDomain(EnergyPlusData &state) } // Initialize freezing calculation variables - evaluateSoilRhoCp(_, true); + evaluateSoilRhoCpInit(); // Initialize the groundTemps array groundTemps.dimension({1, state.dataWeather->NumDaysInYear}, {1, totalNumCells}, 0.0); @@ -846,7 +816,7 @@ void FiniteDiffGroundTempsModel::updateIterationTemperatures() //****************************************************************************** -void FiniteDiffGroundTempsModel::updateTimeStepTemperatures(EnergyPlusData &state) +void FiniteDiffGroundTempsModel::updateTimeStepTemperatures(const EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -881,7 +851,7 @@ void FiniteDiffGroundTempsModel::doStartOfTimeStepInits() auto &thisCell = cellArray(cell); - evaluateSoilRhoCp(cell); + evaluateSoilRhoCpCell(cell); thisCell.beta = (timeStepInSeconds / (thisCell.props.rhoCp * thisCell.volume)); } @@ -908,16 +878,16 @@ Real64 FiniteDiffGroundTempsModel::getGroundTemp(EnergyPlusData &state) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: // Interpolation variables - int i0; // First day - int i1; // Next day - int j1; // Next cell index (with depth greater than y-depth - Real64 T_i0_j0; // Temp at int( x-day ); cell lower_bound( y-depth ) - Real64 T_i1_j0; // Temp at int( x-day ) + 1; cell lower_bound( y-depth ) - Real64 T_i0_j1; // Temp at int( x-day ); cell lower_bound( y-depth ) + 1 - Real64 T_i1_j1; // Temp at int( x-day ) + 1; cell lower_bound( y-depth ) + 1 - Real64 T_ix_j0; // Temp at x-day; cell lower_bound( y-depth ) - Real64 T_ix_j1; // Temp at x-day; cell lower_bound( y-depth ) + 1 - Real64 T_ix_jy; // Final Temperature--Temp at x-day; y-depth + int i0; // First day + int i1; // Next day + int j1; // Next cell index (with depth greater than y-depth + // Real64 T_i0_j0; // Temp at int( x-day ); cell lower_bound( y-depth ) + // Real64 T_i1_j0; // Temp at int( x-day ) + 1; cell lower_bound( y-depth ) + // Real64 T_i0_j1; // Temp at int( x-day ); cell lower_bound( y-depth ) + 1 + // Real64 T_i1_j1; // Temp at int( x-day ) + 1; cell lower_bound( y-depth ) + 1 + // Real64 T_ix_j0; // Temp at x-day; cell lower_bound( y-depth ) + // Real64 T_ix_j1; // Temp at x-day; cell lower_bound( y-depth ) + 1 + // RETURNS: Final Temperature--Temp at x-day; y-depth if (depth < 0.0) { depth = 0.0; @@ -925,13 +895,13 @@ Real64 FiniteDiffGroundTempsModel::getGroundTemp(EnergyPlusData &state) // Get index of nearest cell with depth less than depth auto it = std::lower_bound(cellDepths.begin(), cellDepths.end(), depth); - int j0 = std::distance(cellDepths.begin(), it); // Cell index with depth less than y-depth + int j0 = static_cast(std::distance(cellDepths.begin(), it)); // Cell index with depth less than y-depth // Compensate for 1-based array ++j0; // Fraction of day - Real64 dayFrac = simTimeInDays - int(simTimeInDays); // Fraction of day + const Real64 dayFrac = simTimeInDays - static_cast(simTimeInDays); // Fraction of day if (j0 < totalNumCells - 1) { // All depths within domain @@ -944,70 +914,65 @@ Real64 FiniteDiffGroundTempsModel::getGroundTemp(EnergyPlusData &state) i1 = 1; // Lookup ground temps - T_i0_j0 = groundTemps(i0, j0); - T_i0_j1 = groundTemps(i0, j1); - T_i1_j0 = groundTemps(i1, j0); - T_i1_j1 = groundTemps(i1, j1); + const Real64 T_i0_j0 = groundTemps(i0, j0); + const Real64 T_i0_j1 = groundTemps(i0, j1); + const Real64 T_i1_j0 = groundTemps(i1, j0); + const Real64 T_i1_j1 = groundTemps(i1, j1); // Interpolate between days holding depth constant - T_ix_j0 = interpolate(dayFrac, 1, 0, T_i1_j0, T_i0_j0); - T_ix_j1 = interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); + const Real64 T_ix_j0 = interpolate(dayFrac, 1, 0, T_i1_j0, T_i0_j0); + const Real64 T_ix_j1 = interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); // Interpolate to correct depth now that we're at the right time - T_ix_jy = interpolate(depth, cellDepths(j1), cellDepths(j0), T_ix_j1, T_ix_j0); + return interpolate(depth, cellDepths(j1), cellDepths(j0), T_ix_j1, T_ix_j0); + } - } else { - // All other days - i0 = int(simTimeInDays); - i1 = i0 + 1; + // All other days + i0 = static_cast(simTimeInDays); + i1 = i0 + 1; - // Lookup ground temps - T_i0_j0 = groundTemps(i0, j0); - T_i0_j1 = groundTemps(i0, j1); - T_i1_j0 = groundTemps(i1, j0); - T_i1_j1 = groundTemps(i1, j1); + // Lookup ground temps + const Real64 T_i0_j0 = groundTemps(i0, j0); + const Real64 T_i0_j1 = groundTemps(i0, j1); + const Real64 T_i1_j0 = groundTemps(i1, j0); + const Real64 T_i1_j1 = groundTemps(i1, j1); - // Interpolate between days holding depth constant - T_ix_j0 = interpolate(dayFrac, 1, 0, T_i1_j0, T_i0_j0); - T_ix_j1 = interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); + // Interpolate between days holding depth constant + const Real64 T_ix_j0 = interpolate(dayFrac, 1, 0, T_i1_j0, T_i0_j0); + const Real64 T_ix_j1 = interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); - // Interpolate to correct depth now that we're at the right time - T_ix_jy = interpolate(depth, cellDepths(j1), cellDepths(j0), T_ix_j1, T_ix_j0); - } + // Interpolate to correct depth now that we're at the right time + return interpolate(depth, cellDepths(j1), cellDepths(j0), T_ix_j1, T_ix_j0); + } - } else { - // Requesting a temperature deeper than domain. Pass deepest point in domain. - j0 = totalNumCells; - j1 = j0; + // Requesting a temperature deeper than domain. Pass deepest point in domain. + j0 = totalNumCells; + j1 = j0; - if (simTimeInDays <= 1 || simTimeInDays >= state.dataWeather->NumDaysInYear) { - // First day of year, last day of year, and leap day - // Interpolate between first and last day - i0 = state.dataWeather->NumDaysInYear; - i1 = 1; - - // Lookup ground temps - T_i0_j1 = groundTemps(i0, j1); - T_i1_j1 = groundTemps(i1, j1); + if (simTimeInDays <= 1 || simTimeInDays >= state.dataWeather->NumDaysInYear) { + // First day of year, last day of year, and leap day + // Interpolate between first and last day + i0 = state.dataWeather->NumDaysInYear; + i1 = 1; - // Interpolate between days holding depth constant - T_ix_jy = interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); + // Lookup ground temps + const Real64 T_i0_j1 = groundTemps(i0, j1); + const Real64 T_i1_j1 = groundTemps(i1, j1); - } else { - // All other days - i0 = int(simTimeInDays); - i1 = i0 + 1; + // Interpolate between days holding depth constant + return interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); + } - // Lookup ground temps - T_i0_j1 = groundTemps(i0, j1); - T_i1_j1 = groundTemps(i1, j1); + // All other days + i0 = static_cast(simTimeInDays); + i1 = i0 + 1; - // Interpolate between days holding depth constant - T_ix_jy = interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); - } - } + // Lookup ground temps + const Real64 T_i0_j1 = groundTemps(i0, j1); + const Real64 T_i1_j1 = groundTemps(i1, j1); - return T_ix_jy; + // Interpolate between days holding depth constant + return interpolate(dayFrac, 1, 0, T_i1_j1, T_i0_j1); } //****************************************************************************** @@ -1019,7 +984,7 @@ Real64 FiniteDiffGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData & // DATE WRITTEN Summer 2015 // PURPOSE OF THIS SUBROUTINE: - // Retrieves ground tempeature when input time is in seconds + // Retrieves ground temperature when input time is in seconds depth = _depth; @@ -1044,6 +1009,7 @@ Real64 FiniteDiffGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &s // Returns ground temperature when input time is in months // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + // TODO: Fixing this to be floating point 12.0 causes diffs and failed tests Real64 const aveDaysInMonth = state.dataWeather->NumDaysInYear / 12; depth = _depth; @@ -1061,75 +1027,77 @@ Real64 FiniteDiffGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &s //****************************************************************************** -void FiniteDiffGroundTempsModel::evaluateSoilRhoCp(ObjexxFCL::Optional cell, ObjexxFCL::Optional_bool_const InitOnly) +void FiniteDiffGroundTempsModel::evaluateSoilRhoCpCell(int const cell) { // SUBROUTINE INFORMATION: // AUTHOR Edwin Lee // DATE WRITTEN Summer 2011 // PURPOSE OF THIS SUBROUTINE: - // Evaluates the soil properties + // Evaluates the soil properties on a single cell - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 rho_ice; - Real64 rho_liq; - Real64 CP_liq; - Real64 CP_ice; - Real64 Lat_fus; - Real64 Cp_transient; - // other variables - Real64 rhoCP_soil; + // Real64 rhoCP_soil; // These vary by domain now, so we must be careful to retrieve them every time - Real64 Theta_liq = waterContent; - Real64 Theta_sat = saturatedWaterContent; - - // Assumption - Real64 Theta_ice = Theta_liq; - - if (present(InitOnly)) { - //'Cp (freezing) calculations - rho_ice = 917.0; //'Kg / m3 - rho_liq = 1000.0; //'kg / m3 - rhoCp_soil_liq_1 = 1225000.0 / (1.0 - Theta_sat); //'J/m3K - //'from( " An improved model for predicting soil thermal conductivity from water content at room temperature, Fig 4" ) - CP_liq = 4180.0; //'J / KgK - CP_ice = 2066.0; //'J / KgK - Lat_fus = 334000.0; //'J / Kg - Cp_transient = Lat_fus / 0.4 + (0.5 * CP_ice - (CP_liq + CP_ice) / 2.0 * 0.1) / 0.4; - //'from( " Numerical and experimental investigation of melting and freezing processes in phase change material storage" ) - rhoCP_soil_liq = rhoCp_soil_liq_1 * (1.0 - Theta_sat) + rho_liq * CP_liq * Theta_liq; - rhoCP_soil_transient = rhoCp_soil_liq_1 * (1.0 - Theta_sat) + ((rho_liq + rho_ice) / 2.0) * Cp_transient * Theta_ice; - rhoCP_soil_ice = rhoCp_soil_liq_1 * (1.0 - Theta_sat) + rho_ice * CP_ice * Theta_ice; //'!J / m3K - return; - } auto &thisCell = cellArray(cell); - //'set some temperatures here for generalization -- these could be set in the input file - Real64 frzAllIce = -0.5; - Real64 frzIceTrans = -0.4; - Real64 frzLiqTrans = -0.1; - Real64 frzAllLiq = 0.0; - - //'calculate this cell's new Cp value based on the cell temperature - if (thisCell.temperature >= frzAllLiq) { - rhoCP_soil = rhoCp_soil_liq_1; - } else if (thisCell.temperature <= frzAllIce) { - rhoCP_soil = rhoCP_soil_ice; - } else if (thisCell.temperature > frzLiqTrans) { - rhoCP_soil = rhoCp_soil_liq_1 + (rhoCP_soil_transient - rhoCP_soil_liq) / (frzAllLiq - frzLiqTrans) * (frzAllLiq - thisCell.temperature); - } else if (thisCell.temperature >= frzIceTrans) { - rhoCP_soil = rhoCP_soil_transient; - } else { - rhoCP_soil = rhoCP_soil_ice + (rhoCP_soil_transient - rhoCP_soil_ice) / (frzIceTrans - frzAllIce) * (thisCell.temperature - frzAllIce); - } - + // set some temperatures here for generalization -- these could be set in the input file + // constexpr Real64 frzAllIce = -0.5; + // constexpr Real64 frzIceTrans = -0.4; + // constexpr Real64 frzLiqTrans = -0.1; + // constexpr Real64 frzAllLiq = 0.0; + + // calculate this cell's new Cp value based on the cell temperature + // if (thisCell.temperature >= frzAllLiq) { + // rhoCP_soil = rhoCp_soil_liq_1; + // } else if (thisCell.temperature <= frzAllIce) { + // rhoCP_soil = rhoCP_soil_ice; + // } else if (thisCell.temperature > frzLiqTrans) { + // rhoCP_soil = rhoCp_soil_liq_1 + (rhoCP_soil_transient - rhoCP_soil_liq) / (frzAllLiq - frzLiqTrans) * (frzAllLiq - thisCell.temperature); + // } else if (thisCell.temperature >= frzIceTrans) { + // rhoCP_soil = rhoCP_soil_transient; + // } else { + // rhoCP_soil = rhoCP_soil_ice + (rhoCP_soil_transient - rhoCP_soil_ice) / (frzIceTrans - frzAllIce) * (thisCell.temperature - frzAllIce); + // } + + // TODO: The calculated rhoCP_soil is commented on this line and never used. Curious. thisCell.props.rhoCp = baseDensity * baseSpecificHeat; // rhoCP_soil; thisCell.props.specificHeat = thisCell.props.rhoCp / thisCell.props.density; } +void FiniteDiffGroundTempsModel::evaluateSoilRhoCpInit() +{ + // SUBROUTINE INFORMATION: + // AUTHOR Edwin Lee + // DATE WRITTEN Summer 2011 + + // PURPOSE OF THIS SUBROUTINE: + // Evaluates the soil properties + + // These vary by domain now, so we must be careful to retrieve them every time + const Real64 Theta_liq = waterContent; + const Real64 Theta_sat = saturatedWaterContent; + + // Assumption + const Real64 Theta_ice = Theta_liq; + + //'Cp (freezing) calculations + constexpr Real64 rho_ice = 917.0; //'Kg / m3 + constexpr Real64 rho_liq = 1000.0; //'kg / m3 + rhoCp_soil_liq_1 = 1225000.0 / (1.0 - Theta_sat); // J/m3K + // from( " An improved model for predicting soil thermal conductivity from water content at room temperature, Fig 4" ) + constexpr Real64 CP_liq = 4180.0; //'J / KgK + constexpr Real64 CP_ice = 2066.0; //'J / KgK + constexpr Real64 Lat_fus = 334000.0; //'J / Kg + constexpr Real64 Cp_transient = Lat_fus / 0.4 + (0.5 * CP_ice - (CP_liq + CP_ice) / 2.0 * 0.1) / 0.4; + // from( " Numerical and experimental investigation of melting and freezing processes in phase change material storage" ) + rhoCP_soil_liq = rhoCp_soil_liq_1 * (1.0 - Theta_sat) + rho_liq * CP_liq * Theta_liq; + rhoCP_soil_transient = rhoCp_soil_liq_1 * (1.0 - Theta_sat) + ((rho_liq + rho_ice) / 2.0) * Cp_transient * Theta_ice; + rhoCP_soil_ice = rhoCp_soil_liq_1 * (1.0 - Theta_sat) + rho_ice * CP_ice * Theta_ice; //'!J / m3K +} + //****************************************************************************** } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.hh index 83422a21780..8ff7c8cf13a 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.hh @@ -48,13 +48,9 @@ #ifndef FiniteDifferenceGroundTemperatureModel_hh_INCLUDED #define FiniteDifferenceGroundTemperatureModel_hh_INCLUDED -// C++ Headers -#include - // ObjexxFCL Headers #include #include -#include // EnergyPlus Headers #include @@ -71,56 +67,51 @@ class FiniteDiffGroundTempsModel : public BaseGroundTempsModel static int constexpr maxYearsToIterate = 10; - Real64 rhoCp_soil_liq_1; - Real64 rhoCP_soil_liq; - Real64 rhoCP_soil_transient; - Real64 rhoCP_soil_ice; + Real64 rhoCp_soil_liq_1 = 0.0; + Real64 rhoCP_soil_liq = 0.0; + Real64 rhoCP_soil_transient = 0.0; + Real64 rhoCP_soil_ice = 0.0; public: - Real64 baseConductivity; - Real64 baseDensity; - Real64 baseSpecificHeat; - int totalNumCells; - Real64 timeStepInSeconds; - Real64 evapotransCoeff; - Real64 saturatedWaterContent; - Real64 waterContent; - Real64 annualAveAirTemp; - Real64 minDailyAirTemp; // Set hi. Will be reset later - Real64 maxDailyAirTemp; // Set low. Will be reset later - Real64 dayOfMinDailyAirTemp; - Real64 depth; - Real64 simTimeInDays; - - // Default constructor - FiniteDiffGroundTempsModel() : minDailyAirTemp(100.0), maxDailyAirTemp(-100.0), dayOfMinDailyAirTemp(1) - { - } + Real64 baseConductivity = 0.0; + Real64 baseDensity = 0.0; + Real64 baseSpecificHeat = 0.0; + int totalNumCells = 0; + Real64 timeStepInSeconds = 0.0; + Real64 evapotransCoeff = 0.0; + Real64 saturatedWaterContent = 0.0; + Real64 waterContent = 0.0; + Real64 annualAveAirTemp = 0.0; + Real64 minDailyAirTemp = 100.0; // Set hi. Will be reset later + Real64 maxDailyAirTemp = -100.0; // Set low. Will be reset later + Real64 dayOfMinDailyAirTemp = 1; + Real64 depth = 0.0; + Real64 simTimeInDays = 0.0; struct instanceOfCellData { struct properties { - Real64 conductivity; - Real64 density; - Real64 specificHeat; - Real64 diffusivity; - Real64 rhoCp; + Real64 conductivity = 0.0; + Real64 density = 0.0; + Real64 specificHeat = 0.0; + Real64 diffusivity = 0.0; + Real64 rhoCp = 0.0; }; properties props; - int index; - Real64 thickness; - Real64 minZValue; - Real64 maxZValue; - Real64 temperature; - Real64 temperature_prevIteration; - Real64 temperature_prevTimeStep; - Real64 temperature_finalConvergence; - Real64 beta; - Real64 volume; + int index = 0; + Real64 thickness = 0.0; + Real64 minZValue = 0.0; + Real64 maxZValue = 0.0; + Real64 temperature = 0.0; + Real64 temperature_prevIteration = 0.0; + Real64 temperature_prevTimeStep = 0.0; + Real64 temperature_finalConvergence = 0.0; + Real64 beta = 0.0; + Real64 volume = 0.0; Real64 conductionArea = 1.0; // Assumes 1 m2 }; @@ -128,16 +119,16 @@ public: struct instanceOfWeatherData { - Real64 dryBulbTemp; - Real64 relativeHumidity; - Real64 windSpeed; - Real64 horizontalRadiation; - Real64 airDensity; + Real64 dryBulbTemp = 0.0; + Real64 relativeHumidity = 0.0; + Real64 windSpeed = 0.0; + Real64 horizontalRadiation = 0.0; + Real64 airDensity = 0.0; }; Array1D weatherDataArray; - static std::shared_ptr FiniteDiffGTMFactory(EnergyPlusData &state, std::string objectName); + static FiniteDiffGroundTempsModel *FiniteDiffGTMFactory(EnergyPlusData &state, const std::string &objectName); void getWeatherData(EnergyPlusData &state); @@ -147,33 +138,35 @@ public: void performSimulation(EnergyPlusData &state); - void updateSurfaceCellTemperature(EnergyPlusData &state); + void updateSurfaceCellTemperature(const EnergyPlusData &state); - void updateGeneralDomainCellTemperature(int const cell); + void updateGeneralDomainCellTemperature(int cell); void updateBottomCellTemperature(); void initDomain(EnergyPlusData &state); - bool checkFinalTemperatureConvergence(EnergyPlusData &state); + bool checkFinalTemperatureConvergence(const EnergyPlusData &state); bool checkIterationTemperatureConvergence(); void updateIterationTemperatures(); - void updateTimeStepTemperatures(EnergyPlusData &state); + void updateTimeStepTemperatures(const EnergyPlusData &state); void doStartOfTimeStepInits(); Real64 getGroundTemp(EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; + + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + void evaluateSoilRhoCpInit(); - void evaluateSoilRhoCp(ObjexxFCL::Optional cell = _, ObjexxFCL::Optional_bool_const InitOnly = _); + void evaluateSoilRhoCpCell(int cell); - Real64 interpolate(Real64 const x, Real64 const x_hi, Real64 const x_low, Real64 const y_hi, Real64 const y_low); + static Real64 interpolate(Real64 x, Real64 x_hi, Real64 x_low, Real64 y_hi, Real64 y_low); Array2D groundTemps; diff --git a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc index 913d2c0403e..4c4f3e6ec88 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc @@ -46,7 +46,6 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers -#include #include // EnergyPlus Headers @@ -85,8 +84,7 @@ namespace GroundTemperatureManager { "Site:GroundTemperature:FCfactorMethod", "Site:GroundTemperature:Undisturbed:Xing"}; - std::shared_ptr - GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const objectType_str, std::string const &objectName) + BaseGroundTempsModel *GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const type, std::string const &name) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -96,37 +94,38 @@ namespace GroundTemperatureManager { // Called by objects requiring ground temperature models. Determines type and calls appropriate factory method. // Set object type - GroundTempObjType objectType = static_cast(getEnumValue(groundTempModelNamesUC, Util::makeUPPER(objectType_str))); + const auto objectType = static_cast(getEnumValue(groundTempModelNamesUC, Util::makeUPPER(type))); assert(objectType != GroundTempObjType::Invalid); - int numGTMs = state.dataGrndTempModelMgr->groundTempModels.size(); + const int numGTMs = static_cast(state.dataGrndTempModelMgr->groundTempModels.size()); // Check if this instance of this model has already been retrieved for (int i = 0; i < numGTMs; ++i) { - auto currentModel = state.dataGrndTempModelMgr->groundTempModels[i]; // (AUTO_OK_UNIQUE_PTR) + auto currentModel = state.dataGrndTempModelMgr->groundTempModels[i]; // Check if the type and name match - if (objectType == currentModel->objectType && objectName == currentModel->objectName) { + if (objectType == currentModel->objectType && name == currentModel->objectName) { return state.dataGrndTempModelMgr->groundTempModels[i]; } } // If not found, create new instance of the model - if (objectType == GroundTempObjType::KusudaGroundTemp) { - return KusudaGroundTempsModel::KusudaGTMFactory(state, objectName); - } else if (objectType == GroundTempObjType::FiniteDiffGroundTemp) { - return FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(state, objectName); - } else if (objectType == GroundTempObjType::SiteBuildingSurfaceGroundTemp) { - return SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(state, objectName); - } else if (objectType == GroundTempObjType::SiteShallowGroundTemp) { - return SiteShallowGroundTemps::ShallowGTMFactory(state, objectName); - } else if (objectType == GroundTempObjType::SiteDeepGroundTemp) { - return SiteDeepGroundTemps::DeepGTMFactory(state, objectName); - } else if (objectType == GroundTempObjType::SiteFCFactorMethodGroundTemp) { - return SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(state, objectName); - } else if (objectType == GroundTempObjType::XingGroundTemp) { - return XingGroundTempsModel::XingGTMFactory(state, objectName); - } else { + switch (objectType) { + case GroundTempObjType::KusudaGroundTemp: + return KusudaGroundTempsModel::KusudaGTMFactory(state, name); + case GroundTempObjType::FiniteDiffGroundTemp: + return FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(state, name); + case GroundTempObjType::SiteBuildingSurfaceGroundTemp: + return SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(state, name); + case GroundTempObjType::SiteShallowGroundTemp: + return SiteShallowGroundTemps::ShallowGTMFactory(state, name); + case GroundTempObjType::SiteDeepGroundTemp: + return SiteDeepGroundTemps::DeepGTMFactory(state, name); + case GroundTempObjType::SiteFCFactorMethodGroundTemp: + return SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(state, name); + case GroundTempObjType::XingGroundTemp: + return XingGroundTempsModel::XingGTMFactory(state, name); + default: assert(false); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh index a905559976b..a411e93987b 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh @@ -48,16 +48,11 @@ #ifndef GroundTemperatureModelManager_hh_INCLUDED #define GroundTemperatureModelManager_hh_INCLUDED -// C++ Headers -#include - // ObjexxFCL Headers #include // EnergyPlus Headers #include -#include -#include #include namespace EnergyPlus { @@ -72,13 +67,13 @@ namespace GroundTemperatureManager { extern const std::array(GroundTempObjType::Num)> groundTempModelNames; - std::shared_ptr GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const type, std::string const &name); + BaseGroundTempsModel *GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view type, std::string const &name); } // namespace GroundTemperatureManager -struct GroundTemperatureManagerData : BaseGlobalStruct +struct GroundTemperatureManagerData final : BaseGlobalStruct { - std::vector> groundTempModels; + std::vector groundTempModels; void init_state([[maybe_unused]] EnergyPlusData &state) override { @@ -88,6 +83,8 @@ struct GroundTemperatureManagerData : BaseGlobalStruct { new (this) GroundTemperatureManagerData(); } + + virtual ~GroundTemperatureManagerData() = default; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc index 950331d122b..fe827b17419 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc @@ -45,11 +45,6 @@ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -// C++ Headers -#include - -// ObjexxFCL Headers - // EnergyPlus Headers #include #include @@ -64,7 +59,7 @@ namespace EnergyPlus { //****************************************************************************** // Kusuda model factory -std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory(EnergyPlusData &state, std::string objectName) +KusudaGroundTempsModel *KusudaGroundTempsModel::KusudaGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -81,28 +76,32 @@ std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory int IOStat; // New shared pointer for this model object - std::shared_ptr thisModel(new KusudaGroundTempsModel()); + auto *thisModel = new KusudaGroundTempsModel(); + + std::string lookingForName = objectName; GroundTempObjType objType = GroundTempObjType::KusudaGroundTemp; std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { state.dataInputProcessing->inputProcessor->getObjectItem( state, cCurrentModuleObject, modelNum, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); - if (objectName == state.dataIPShortCut->cAlphaArgs(1)) { + if (lookingForName == state.dataIPShortCut->cAlphaArgs(1)) { // Read input into object here thisModel->objectName = state.dataIPShortCut->cAlphaArgs(1); thisModel->objectType = objType; - thisModel->groundThermalDiffisivity = + thisModel->groundThermalDiffusivity = state.dataIPShortCut->rNumericArgs(1) / (state.dataIPShortCut->rNumericArgs(2) * state.dataIPShortCut->rNumericArgs(3)); - bool useGroundTempDataForKusuda = - state.dataIPShortCut->rNumericArgs(4) || state.dataIPShortCut->rNumericArgs(5) || state.dataIPShortCut->rNumericArgs(6); + std::array flags = { + state.dataIPShortCut->rNumericArgs(4), state.dataIPShortCut->rNumericArgs(5), state.dataIPShortCut->rNumericArgs(6)}; + const bool useGroundTempDataForKusuda = + std::any_of(flags.begin(), flags.end(), [](Real64 const flag) { return static_cast(flag); }); if (useGroundTempDataForKusuda) { // Use Kusuda Parameters @@ -112,23 +111,22 @@ std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory } else { // Use data from Site:GroundTemperature:Shallow to generate parameters - int monthsInYear(12); - int avgDaysInMonth(30); + constexpr int monthsInYear(12); + constexpr int avgDaysInMonth(30); int monthOfMinSurfTemp(0); Real64 averageGroundTemp(0); Real64 amplitudeOfGroundTemp(0); Real64 phaseShiftOfMinGroundTempDays(0); - Real64 minSurfTemp(100); // Set high month 1 temp will be lower and actually get updated + Real64 minSurfTemp(100); // Set high; month 1 temp will be lower than that and actually get updated Real64 maxSurfTemp(-100); // Set low initially but will get updated - std::shared_ptr shallowObj = GroundTemperatureManager::GetGroundTempModelAndInit( + BaseGroundTempsModel *shallowObj = GroundTemperatureManager::GetGroundTempModelAndInit( state, - static_cast( - GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteShallowGroundTemp)]), - ""); + GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteShallowGroundTemp)], + ""); // TODO: OK, so this is grabbing the surface temperatures, whether default (13) or user defined. for (int monthIndex = 1; monthIndex <= 12; ++monthIndex) { - Real64 currMonthTemp = shallowObj->getGroundTempAtTimeInMonths(state, 0.0, monthIndex); + const Real64 currMonthTemp = shallowObj->getGroundTempAtTimeInMonths(state, 0.0, monthIndex); // Calculate Average Ground Temperature for all 12 months of the year: averageGroundTemp += currMonthTemp; @@ -164,12 +162,12 @@ std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory if (found) { state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -187,9 +185,9 @@ Real64 KusudaGroundTempsModel::getGroundTemp(EnergyPlusData &state) Real64 const secsInYear = Constant::SecsInDay * state.dataWeather->NumDaysInYear; - Real64 term1 = -depth * std::sqrt(Constant::Pi / (secsInYear * groundThermalDiffisivity)); - Real64 term2 = (2 * Constant::Pi / secsInYear) * - (simTimeInSeconds - phaseShiftInSecs - (depth / 2) * std::sqrt(secsInYear / (Constant::Pi * groundThermalDiffisivity))); + const Real64 term1 = -depth * std::sqrt(Constant::Pi / (secsInYear * groundThermalDiffusivity)); + const Real64 term2 = (2 * Constant::Pi / secsInYear) * + (simTimeInSeconds - phaseShiftInSecs - (depth / 2) * std::sqrt(secsInYear / (Constant::Pi * groundThermalDiffusivity))); return aveGroundTemp - aveGroundTempAmplitude * std::exp(term1) * std::cos(term2); } @@ -232,12 +230,13 @@ Real64 KusudaGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state // Returns the ground temperature when input time is in months // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 const aveSecondsInMonth = (state.dataWeather->NumDaysInYear / 12) * Constant::SecsInDay; + // TODO: Taking out the int static cast causes diffs and failed tests + Real64 const aveSecondsInMonth = static_cast(state.dataWeather->NumDaysInYear / 12.0) * Constant::SecsInDay; Real64 const secondsPerYear = state.dataWeather->NumDaysInYear * Constant::SecsInDay; depth = _depth; - simTimeInSeconds = aveSecondsInMonth * ((_month - 1) + 0.5); + simTimeInSeconds = aveSecondsInMonth * (_month - 1 + 0.5); if (simTimeInSeconds > secondsPerYear) { simTimeInSeconds = remainder(simTimeInSeconds, secondsPerYear); diff --git a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.hh index 0a7156bfc72..8c61107bd32 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.hh @@ -48,12 +48,8 @@ #ifndef KusudaAchenbachGroundTemperatureModel_hh_INCLUDED #define KusudaAchenbachGroundTemperatureModel_hh_INCLUDED -// C++ Headers -#include - // EnergyPlus Headers #include -#include #include #include @@ -63,24 +59,22 @@ namespace EnergyPlus { struct EnergyPlusData; // Derived class for Kusuda-Achenbach model -class KusudaGroundTempsModel : public BaseGroundTempsModel +struct KusudaGroundTempsModel final : BaseGroundTempsModel { -public: - // Public Members - Real64 depth; - Real64 groundThermalDiffisivity; - Real64 simTimeInSeconds; - Real64 aveGroundTemp; - Real64 aveGroundTempAmplitude; - Real64 phaseShiftInSecs; + Real64 depth = 0.0; + Real64 groundThermalDiffusivity = 0.0; + Real64 simTimeInSeconds = 0.0; + Real64 aveGroundTemp = 0.0; + Real64 aveGroundTempAmplitude = 0.0; + Real64 phaseShiftInSecs = 0.0; - static std::shared_ptr KusudaGTMFactory(EnergyPlusData &state, std::string objectName); + static KusudaGroundTempsModel *KusudaGTMFactory(EnergyPlusData &state, const std::string &objectName); Real64 getGroundTemp(EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc index 90d687cd7b2..1eacf7108f1 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc @@ -45,9 +45,6 @@ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -// C++ Headers -#include - // EnergyPlus Headers #include #include @@ -61,11 +58,8 @@ namespace EnergyPlus { -//****************************************************************************** - // Site:GroundTemperature:BuildingSurface factory -std::shared_ptr SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(EnergyPlusData &state, - std::string objectName) +SiteBuildingSurfaceGroundTemps *SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -78,12 +72,12 @@ std::shared_ptr SiteBuildingSurfaceGroundTemps:: bool errorsFound = false; // New shared pointer for this model object - std::shared_ptr thisModel(new SiteBuildingSurfaceGroundTemps()); + const auto thisModel = new SiteBuildingSurfaceGroundTemps(); - GroundTempObjType objType = GroundTempObjType::SiteBuildingSurfaceGroundTemp; + auto objType = GroundTempObjType::SiteBuildingSurfaceGroundTemp; std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -107,11 +101,11 @@ std::shared_ptr SiteBuildingSurfaceGroundTemps:: // Assign the ground temps to the variable for (int i = 1; i <= 12; ++i) { - thisModel->buildingSurfaceGroundTemps(i) = state.dataIPShortCut->rNumericArgs(i); - if (thisModel->buildingSurfaceGroundTemps(i) < 15.0 || thisModel->buildingSurfaceGroundTemps(i) > 25.0) genErrorMessage = true; + thisModel->buildingSurfaceGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); + if (thisModel->buildingSurfaceGroundTemps[i - 1] < 15.0 || thisModel->buildingSurfaceGroundTemps[i - 1] > 25.0) genErrorMessage = true; } - state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::BuildingSurface] = true; + state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::BuildingSurface)] = true; if (genErrorMessage) { ShowWarningError(state, @@ -126,7 +120,7 @@ std::shared_ptr SiteBuildingSurfaceGroundTemps:: GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); errorsFound = true; } else { - thisModel->buildingSurfaceGroundTemps = 18.0; + std::fill(thisModel->buildingSurfaceGroundTemps.begin(), thisModel->buildingSurfaceGroundTemps.end(), 18.0); } // Write Final Ground Temp Information to the initialization output file @@ -135,12 +129,12 @@ std::shared_ptr SiteBuildingSurfaceGroundTemps:: if (!errorsFound) { state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -154,7 +148,7 @@ Real64 SiteBuildingSurfaceGroundTemps::getGroundTemp([[maybe_unused]] EnergyPlus // PURPOSE OF THIS SUBROUTINE: // Returns the ground temperature for Site:GroundTemperature:BuildingSurface - return buildingSurfaceGroundTemps(timeOfSimInMonths); + return buildingSurfaceGroundTemps[timeOfSimInMonths - 1]; } //****************************************************************************** @@ -171,15 +165,15 @@ SiteBuildingSurfaceGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &sta // USE STATEMENTS: // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + const Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; // Convert secs to months - int month = ceil(_seconds / secPerMonth); + const int month = ceil(_seconds / secPerMonth); if (month >= 1 && month <= 12) { timeOfSimInMonths = month; } else { - timeOfSimInMonths = remainder(month, 12); + timeOfSimInMonths = month % 12; } // Get and return ground temp @@ -201,7 +195,7 @@ Real64 SiteBuildingSurfaceGroundTemps::getGroundTempAtTimeInMonths(EnergyPlusDat if (_month >= 1 && _month <= 12) { timeOfSimInMonths = _month; } else { - timeOfSimInMonths = remainder(_month, 12); + timeOfSimInMonths = _month % 12; } // Get and return ground temp diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh index 6fedf548608..ee1185ac65f 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh @@ -48,11 +48,7 @@ #ifndef SiteBuildingSurfaceGroundTemperatures_hh_INCLUDED #define SiteBuildingSurfaceGroundTemperatures_hh_INCLUDED -// C++ Headers -#include - -// ObjexxFCL Headers -#include +#include // EnergyPlus Headers #include @@ -65,24 +61,18 @@ namespace EnergyPlus { struct EnergyPlusData; // Derived class for Site:GroundTemperature:BuildingSurface -class SiteBuildingSurfaceGroundTemps : public BaseGroundTempsModel +struct SiteBuildingSurfaceGroundTemps final : BaseGroundTempsModel { -public: - int timeOfSimInMonths; - Array1D buildingSurfaceGroundTemps; - - // Default Constructor - SiteBuildingSurfaceGroundTemps() : timeOfSimInMonths(0), buildingSurfaceGroundTemps(12, 13.0) - { - } + int timeOfSimInMonths = 0; + std::array buildingSurfaceGroundTemps = {13}; - static std::shared_ptr BuildingSurfaceGTMFactory(EnergyPlusData &state, std::string objectName); + static SiteBuildingSurfaceGroundTemps *BuildingSurfaceGTMFactory(EnergyPlusData &state, const std::string &objectName); Real64 getGroundTemp(EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc index 236eb1f79d3..54b9f75529e 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc @@ -64,7 +64,7 @@ namespace EnergyPlus { //****************************************************************************** // Site:GroundTemperature:Deep factory -std::shared_ptr SiteDeepGroundTemps::DeepGTMFactory(EnergyPlusData &state, std::string objectName) +SiteDeepGroundTemps *SiteDeepGroundTemps::DeepGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -77,12 +77,12 @@ std::shared_ptr SiteDeepGroundTemps::DeepGTMFactory(EnergyP bool errorsFound = false; // New shared pointer for this model object - std::shared_ptr thisModel(new SiteDeepGroundTemps()); + auto *thisModel = new SiteDeepGroundTemps(); - GroundTempObjType objType = GroundTempObjType::SiteDeepGroundTemp; + auto objType = GroundTempObjType::SiteDeepGroundTemp; std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -105,10 +105,10 @@ std::shared_ptr SiteDeepGroundTemps::DeepGTMFactory(EnergyP // overwrite values read from weather file for the 0.5m set ground temperatures for (int i = 1; i <= 12; ++i) { - thisModel->deepGroundTemps(i) = state.dataIPShortCut->rNumericArgs(i); + thisModel->deepGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); } - state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::Deep] = true; + state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::Deep)] = true; } else if (numCurrObjects > 1) { ShowSevereError(state, @@ -117,7 +117,7 @@ std::shared_ptr SiteDeepGroundTemps::DeepGTMFactory(EnergyP errorsFound = true; } else { - thisModel->deepGroundTemps = 16.0; + std::fill(thisModel->deepGroundTemps.begin(), thisModel->deepGroundTemps.end(), 16.0); } // Write Final Ground Temp Information to the initialization output file @@ -126,12 +126,12 @@ std::shared_ptr SiteDeepGroundTemps::DeepGTMFactory(EnergyP if (!errorsFound) { state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -145,7 +145,7 @@ Real64 SiteDeepGroundTemps::getGroundTemp([[maybe_unused]] EnergyPlusData &state // PURPOSE OF THIS SUBROUTINE: // Returns the ground temperature for Site:GroundTemperature:Deep - return deepGroundTemps(timeOfSimInMonths); + return deepGroundTemps[timeOfSimInMonths - 1]; } //****************************************************************************** @@ -160,15 +160,15 @@ Real64 SiteDeepGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &state, // Returns the ground temperature when input time is in seconds // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + const Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; // Convert secs to months - int month = ceil(_seconds / secPerMonth); + const int month = ceil(_seconds / secPerMonth); if (month >= 1 && month <= 12) { timeOfSimInMonths = month; } else { - timeOfSimInMonths = remainder(month, 12); + timeOfSimInMonths = month % 12; } // Get and return ground temp @@ -190,7 +190,7 @@ Real64 SiteDeepGroundTemps::getGroundTempAtTimeInMonths(EnergyPlusData &state, [ if (_month >= 1 && _month <= 12) { timeOfSimInMonths = _month; } else { - timeOfSimInMonths = remainder(_month, 12); + timeOfSimInMonths = _month % 12; } // Get and return ground temp diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh index 1c899f46518..4c0e73272ea 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh @@ -49,10 +49,7 @@ #define SiteDeepGroundTemperatures_hh_INCLUDED // C++ Headers -#include - -// ObjexxFCL Headers -#include +#include // EnergyPlus Headers #include @@ -65,24 +62,18 @@ namespace EnergyPlus { struct EnergyPlusData; // Derived class for Site:GroundTemperature:Deep -class SiteDeepGroundTemps : public BaseGroundTempsModel +struct SiteDeepGroundTemps final : BaseGroundTempsModel { -public: - int timeOfSimInMonths; - Array1D deepGroundTemps; - - // Default Constructor - SiteDeepGroundTemps() : timeOfSimInMonths(0), deepGroundTemps(12, 13.0) - { - } + int timeOfSimInMonths = 12; + std::array deepGroundTemps = {13.0}; - static std::shared_ptr DeepGTMFactory(EnergyPlusData &state, std::string objectName); + static SiteDeepGroundTemps *DeepGTMFactory(EnergyPlusData &state, const std::string &objectName); Real64 getGroundTemp([[maybe_unused]] EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc index 55e08254873..6b0770f56b9 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc @@ -46,7 +46,6 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers -#include // EnergyPlus Headers #include @@ -64,7 +63,7 @@ namespace EnergyPlus { //****************************************************************************** // Site:GroundTemperature:FCFactorMethod factory -std::shared_ptr SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, std::string objectName) +SiteFCFactorMethodGroundTemps *SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -75,15 +74,14 @@ std::shared_ptr SiteFCFactorMethodGroundTemps::FC // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool found = false; - bool errorsFound = false; // New shared pointer for this model object - std::shared_ptr thisModel(new SiteFCFactorMethodGroundTemps()); + auto *thisModel = new SiteFCFactorMethodGroundTemps(); - GroundTempObjType objType = GroundTempObjType::SiteFCFactorMethodGroundTemp; + auto objType = GroundTempObjType::SiteFCFactorMethodGroundTemp; std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -101,51 +99,50 @@ std::shared_ptr SiteFCFactorMethodGroundTemps::FC if (NumNums < 12) { ShowSevereError( state, fmt::format("{}: Less than 12 values entered.", GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - errorsFound = true; + // found stays false + } else { + // overwrite values read from weather file for the 0.5m set ground temperatures + for (int i = 1; i <= 12; ++i) { + thisModel->fcFactorGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); + } + + state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::FCFactorMethod)] = true; + found = true; } - // overwrite values read from weather file for the 0.5m set ground temperatures - for (int i = 1; i <= 12; ++i) { - thisModel->fcFactorGroundTemps(i) = state.dataIPShortCut->rNumericArgs(i); - } - - state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::FCFactorMethod] = true; - found = true; - } else if (numCurrObjects > 1) { ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - errorsFound = true; + // found stays false } else if (state.dataWeather->wthFCGroundTemps) { for (int i = 1; i <= 12; ++i) { - thisModel->fcFactorGroundTemps(i) = state.dataWeather->GroundTempsFCFromEPWHeader(i); + thisModel->fcFactorGroundTemps[i - 1] = state.dataWeather->GroundTempsFCFromEPWHeader(i); } - state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::FCFactorMethod] = true; + state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::FCFactorMethod)] = true; found = true; } else { - thisModel->fcFactorGroundTemps = 0.0; + std::fill(thisModel->fcFactorGroundTemps.begin(), thisModel->fcFactorGroundTemps.end(), 0.0); found = true; } // Write Final Ground Temp Information to the initialization output file - if (state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::FCFactorMethod]) { + if (state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::FCFactorMethod)]) { write_ground_temps(state.files.eio, "FCfactorMethod", thisModel->fcFactorGroundTemps); } - if (found && !errorsFound) { + if (found) { state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -159,7 +156,7 @@ Real64 SiteFCFactorMethodGroundTemps::getGroundTemp([[maybe_unused]] EnergyPlusD // PURPOSE OF THIS SUBROUTINE: // Returns the ground temperature for Site:GroundTemperature:FCFactorMethod - return fcFactorGroundTemps(timeOfSimInMonths); + return fcFactorGroundTemps[timeOfSimInMonths - 1]; } //****************************************************************************** @@ -174,15 +171,15 @@ Real64 SiteFCFactorMethodGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusDat // Returns the ground temperature when input time is in seconds // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; + const Real64 secPerMonth = state.dataWeather->NumDaysInYear * Constant::SecsInDay / 12; // Convert secs to months - int month = ceil(_seconds / secPerMonth); + const int month = ceil(_seconds / secPerMonth); if (month >= 1 && month <= 12) { timeOfSimInMonths = month; } else { - timeOfSimInMonths = remainder(month, 12); + timeOfSimInMonths = month % 12; } // Get and return ground temp @@ -204,7 +201,7 @@ Real64 SiteFCFactorMethodGroundTemps::getGroundTempAtTimeInMonths(EnergyPlusData if (_month >= 1 && _month <= 12) { timeOfSimInMonths = _month; } else { - timeOfSimInMonths = remainder(_month, 12); + timeOfSimInMonths = _month % 12; } // Get and return ground temp diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh index 6e59240ff8c..c66e4392f3b 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh @@ -49,10 +49,7 @@ #define SiteFCFactorMethodTemperatures_hh_INCLUDED // C++ Headers -#include - -// ObjexxFCL Headers -#include +#include // EnergyPlus Headers #include @@ -65,24 +62,18 @@ namespace EnergyPlus { struct EnergyPlusData; // Derived class for Site:GroundTemperature:FCFactorMethod -class SiteFCFactorMethodGroundTemps : public BaseGroundTempsModel +struct SiteFCFactorMethodGroundTemps final : BaseGroundTempsModel { -public: - int timeOfSimInMonths; - Array1D fcFactorGroundTemps; - - // Default Constructor - SiteFCFactorMethodGroundTemps() : timeOfSimInMonths(0), fcFactorGroundTemps(12, 13.0) - { - } + int timeOfSimInMonths = 0; + std::array fcFactorGroundTemps = {13.0}; - static std::shared_ptr FCFactorGTMFactory(EnergyPlusData &state, std::string objectName); + static SiteFCFactorMethodGroundTemps *FCFactorGTMFactory(EnergyPlusData &state, const std::string &objectName); Real64 getGroundTemp([[maybe_unused]] EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc index a430cc98fce..2ed6aaf9eec 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc @@ -46,7 +46,6 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers -#include // EnergyPlus Headers #include @@ -64,7 +63,7 @@ namespace EnergyPlus { //****************************************************************************** // Site:GroundTemperature:Shallow factory -std::shared_ptr SiteShallowGroundTemps::ShallowGTMFactory(EnergyPlusData &state, std::string objectName) +SiteShallowGroundTemps *SiteShallowGroundTemps::ShallowGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -77,12 +76,12 @@ std::shared_ptr SiteShallowGroundTemps::ShallowGTMFactor bool errorsFound = false; // New shared pointer for this model object - std::shared_ptr thisModel(new SiteShallowGroundTemps()); + auto *thisModel = new SiteShallowGroundTemps(); - GroundTempObjType objType = GroundTempObjType::SiteShallowGroundTemp; + auto objType = GroundTempObjType::SiteShallowGroundTemp; std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -105,10 +104,10 @@ std::shared_ptr SiteShallowGroundTemps::ShallowGTMFactor // Assign the ground temps to the variable for (int i = 1; i <= 12; ++i) { - thisModel->surfaceGroundTemps(i) = state.dataIPShortCut->rNumericArgs(i); + thisModel->surfaceGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); } - state.dataEnvrn->GroundTempInputs[(int)DataEnvironment::GroundTempType::Shallow] = true; + state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::Shallow)] = true; } else if (numCurrObjects > 1) { ShowSevereError(state, @@ -116,7 +115,7 @@ std::shared_ptr SiteShallowGroundTemps::ShallowGTMFactor GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); errorsFound = true; } else { - thisModel->surfaceGroundTemps = 13.0; + std::fill(thisModel->surfaceGroundTemps.begin(), thisModel->surfaceGroundTemps.end(), 13.0); } // Write Final Ground Temp Information to the initialization output file @@ -125,12 +124,12 @@ std::shared_ptr SiteShallowGroundTemps::ShallowGTMFactor if (!errorsFound) { state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -144,7 +143,7 @@ Real64 SiteShallowGroundTemps::getGroundTemp([[maybe_unused]] EnergyPlusData &st // PURPOSE OF THIS SUBROUTINE: // Return the ground temperature from Site:GroundTemperature:Shallow - return surfaceGroundTemps(timeOfSimInMonths); + return surfaceGroundTemps[timeOfSimInMonths - 1]; } //****************************************************************************** @@ -168,7 +167,7 @@ Real64 SiteShallowGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &stat if (month >= 1 && month <= 12) { timeOfSimInMonths = month; } else { - timeOfSimInMonths = remainder(month, 12); + timeOfSimInMonths = month % 12; } // Get and return ground temp @@ -190,7 +189,7 @@ Real64 SiteShallowGroundTemps::getGroundTempAtTimeInMonths(EnergyPlusData &state if (_month >= 1 && _month <= 12) { timeOfSimInMonths = _month; } else { - timeOfSimInMonths = remainder(_month, 12); + timeOfSimInMonths = _month % 12; } // Get and return ground temp diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh index 9334d00489b..5f5f4c4d935 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh @@ -49,11 +49,7 @@ #define SiteShallowGroundTemperatures_hh_INCLUDED // C++ Headers -#include - -// ObjexxFCL Headers -#include -#include +#include // EnergyPlus Headers #include @@ -66,24 +62,18 @@ namespace EnergyPlus { struct EnergyPlusData; // Derived class for Site:GroundTemperature:Shallow -class SiteShallowGroundTemps : public BaseGroundTempsModel +struct SiteShallowGroundTemps final : BaseGroundTempsModel { -public: - int timeOfSimInMonths; - Array1D surfaceGroundTemps; - - // Default Constructor - SiteShallowGroundTemps() : timeOfSimInMonths(0), surfaceGroundTemps(12, 13.0) - { - } + int timeOfSimInMonths = 0; + std::array surfaceGroundTemps = {13.0}; - static std::shared_ptr ShallowGTMFactory(EnergyPlusData &state, std::string objectName); + static SiteShallowGroundTemps *ShallowGTMFactory(EnergyPlusData &state, const std::string &objectName); Real64 getGroundTemp([[maybe_unused]] EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc index 3f9701fb3c2..0c5dc6c7e78 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc @@ -64,7 +64,7 @@ namespace EnergyPlus { //****************************************************************************** // Xing model factory -std::shared_ptr XingGroundTempsModel::XingGTMFactory(EnergyPlusData &state, std::string objectName) +XingGroundTempsModel *XingGroundTempsModel::XingGTMFactory(EnergyPlusData &state, const std::string &objectName) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -80,12 +80,12 @@ std::shared_ptr XingGroundTempsModel::XingGTMFactory(Energ int IOStat; // New shared pointer for this model object - std::shared_ptr thisModel(new XingGroundTempsModel()); + auto *thisModel = new XingGroundTempsModel(); - GroundTempObjType objType = GroundTempObjType::XingGroundTemp; + auto objType = GroundTempObjType::XingGroundTemp; std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { @@ -97,7 +97,7 @@ std::shared_ptr XingGroundTempsModel::XingGTMFactory(Energ thisModel->objectName = state.dataIPShortCut->cAlphaArgs(1); thisModel->objectType = objType; - thisModel->groundThermalDiffisivity = state.dataIPShortCut->rNumericArgs(1) / + thisModel->groundThermalDiffusivity = state.dataIPShortCut->rNumericArgs(1) / (state.dataIPShortCut->rNumericArgs(2) * state.dataIPShortCut->rNumericArgs(3)) * Constant::SecsInDay; thisModel->aveGroundTemp = state.dataIPShortCut->rNumericArgs(4); @@ -114,12 +114,12 @@ std::shared_ptr XingGroundTempsModel::XingGTMFactory(Energ if (found) { state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; - } else { - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); - return nullptr; } + + ShowFatalError(state, + fmt::format("{}--Errors getting input for ground temperature model", + GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -134,32 +134,32 @@ Real64 XingGroundTempsModel::getGroundTemp(EnergyPlusData &state) // Returns the ground temperature for the Site:GroundTemperature:Undisturbed:Xing // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 tp = state.dataWeather->NumDaysInYear; // Period of soil temperature cycle + const Real64 tp = state.dataWeather->NumDaysInYear; // Period of soil temperature cycle // Inits - Real64 Ts_1 = surfTempAmplitude_1; // Amplitude of surface temperature - Real64 PL_1 = phaseShift_1; // Phase shift of surface temperature - Real64 Ts_2 = surfTempAmplitude_2; // Amplitude of surface temperature - Real64 PL_2 = phaseShift_2; // Phase shift of surface temperature + const Real64 Ts_1 = surfTempAmplitude_1; // Amplitude of surface temperature + const Real64 PL_1 = phaseShift_1; // Phase shift of surface temperature + const Real64 Ts_2 = surfTempAmplitude_2; // Amplitude of surface temperature + const Real64 PL_2 = phaseShift_2; // Phase shift of surface temperature - int n = 1; - Real64 gamma1 = std::sqrt((n * Constant::Pi) / (groundThermalDiffisivity * tp)); - Real64 exp1 = -depth * gamma1; - Real64 cos1 = (2 * Constant::Pi * n) / tp * (simTimeInDays - PL_1) - depth * gamma1; + constexpr int n1 = 1; + const Real64 gamma1 = std::sqrt((n1 * Constant::Pi) / (groundThermalDiffusivity * tp)); + const Real64 exp1 = -depth * gamma1; + const Real64 cos1 = 2 * Constant::Pi * n1 / tp * (simTimeInDays - PL_1) - depth * gamma1; - n = 2; - Real64 gamma2 = std::sqrt((n * Constant::Pi) / (groundThermalDiffisivity * tp)); - Real64 exp2 = -depth * gamma2; - Real64 cos2 = (2 * Constant::Pi * n) / tp * (simTimeInDays - PL_2) - depth * gamma2; + constexpr int n2 = 2; + const Real64 gamma2 = std::sqrt((n2 * Constant::Pi) / (groundThermalDiffusivity * tp)); + const Real64 exp2 = -depth * gamma2; + const Real64 cos2 = 2 * Constant::Pi * n2 / tp * (simTimeInDays - PL_2) - depth * gamma2; - Real64 summation = std::exp(exp1) * Ts_1 * std::cos(cos1) + std::exp(exp2) * Ts_2 * std::cos(cos2); + const Real64 summation = std::exp(exp1) * Ts_1 * std::cos(cos1) + std::exp(exp2) * Ts_2 * std::cos(cos2); return aveGroundTemp - summation; } //****************************************************************************** -Real64 XingGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 _depth, int _month) +Real64 XingGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state, const Real64 _depth, const int _month) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -169,16 +169,17 @@ Real64 XingGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state, // Returns ground temperature when input time is in months // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + // TODO: Fixing this to be floating point 12.0 causes diffs and failed tests Real64 const aveDaysInMonth = state.dataWeather->NumDaysInYear / 12; depth = _depth; // Set month if (_month >= 1 && _month <= 12) { - simTimeInDays = aveDaysInMonth * ((_month - 1) + 0.5); + simTimeInDays = aveDaysInMonth * (_month - 1 + 0.5); } else { - int monthIndex = remainder(_month, 12); - simTimeInDays = aveDaysInMonth * ((monthIndex - 1) + 0.5); + const int monthIndex = _month % 12; + simTimeInDays = aveDaysInMonth * (monthIndex - 1 + 0.5); } // Get and return ground temp @@ -187,7 +188,7 @@ Real64 XingGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state, //****************************************************************************** -Real64 XingGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 _depth, Real64 seconds) +Real64 XingGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData &state, const Real64 _depth, const Real64 seconds) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell diff --git a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh index 924f6566a0c..d1fbabaf5ec 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh @@ -48,9 +48,6 @@ #ifndef XingGroundTemperatureManager_hh_INCLUDED #define XingGroundTemperatureManager_hh_INCLUDED -// C++ Headers -#include - // EnergyPlus Headers #include #include @@ -61,11 +58,10 @@ namespace EnergyPlus { // Forward declarations struct EnergyPlusData; -class XingGroundTempsModel : public BaseGroundTempsModel +struct XingGroundTempsModel final : BaseGroundTempsModel { -public: Real64 depth = 0.0; - Real64 groundThermalDiffisivity = 0.0; + Real64 groundThermalDiffusivity = 0.0; Real64 simTimeInDays = 0.0; Real64 aveGroundTemp = 0.0; Real64 surfTempAmplitude_1 = 0.0; @@ -73,13 +69,13 @@ public: Real64 surfTempAmplitude_2 = 0.0; Real64 phaseShift_2 = 0.0; - static std::shared_ptr XingGTMFactory(EnergyPlusData &state, std::string objectName); + static XingGroundTempsModel *XingGTMFactory(EnergyPlusData &state, const std::string &objectName); Real64 getGroundTemp(EnergyPlusData &state) override; - Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 const depth, Real64 const timeInSecondsOfSim) override; + Real64 getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 depth, Real64 timeInSecondsOfSim) override; - Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 const depth, int const monthOfSim) override; + Real64 getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 depth, int monthOfSim) override; }; } // namespace EnergyPlus diff --git a/src/EnergyPlus/PipeHeatTransfer.hh b/src/EnergyPlus/PipeHeatTransfer.hh index 3eb9c5f4de8..17eeca3516c 100644 --- a/src/EnergyPlus/PipeHeatTransfer.hh +++ b/src/EnergyPlus/PipeHeatTransfer.hh @@ -183,7 +183,7 @@ namespace PipeHeatTransfer { Real64 ZoneHeatGainRate; // Lagged energy summation for zone heat gain {W} PlantLocation plantLoc; bool CheckEquipName; - std::shared_ptr groundTempModel; + BaseGroundTempsModel *groundTempModel; // non-owning pointer // Report data Real64 FluidInletTemp; // inlet temperature [C] diff --git a/src/EnergyPlus/PlantPipingSystemsManager.hh b/src/EnergyPlus/PlantPipingSystemsManager.hh index 2fe66bd9068..5c5ed478763 100644 --- a/src/EnergyPlus/PlantPipingSystemsManager.hh +++ b/src/EnergyPlus/PlantPipingSystemsManager.hh @@ -774,7 +774,7 @@ namespace PlantPipingSystemsManager { BaseThermalPropertySet HorizInsProperties; BaseThermalPropertySet VertInsProperties; SimulationControl SimControls; - std::shared_ptr groundTempModel; + BaseGroundTempsModel *groundTempModel; // non-owning pointer BasementZoneInfo BasementZone; MoistureInfo Moisture; // "Internal" data structure variables diff --git a/src/EnergyPlus/WeatherManager.hh b/src/EnergyPlus/WeatherManager.hh index 78dc5e60ae8..ab8c567395e 100644 --- a/src/EnergyPlus/WeatherManager.hh +++ b/src/EnergyPlus/WeatherManager.hh @@ -907,10 +907,10 @@ struct WeatherManagerData : BaseGlobalStruct EPVector SpecialDays; // NOLINT(cert-err58-cpp) EPVector DataPeriods; // NOLINT(cert-err58-cpp) - std::shared_ptr siteShallowGroundTempsPtr; - std::shared_ptr siteBuildingSurfaceGroundTempsPtr; - std::shared_ptr siteFCFactorMethodGroundTempsPtr; - std::shared_ptr siteDeepGroundTempsPtr; + BaseGroundTempsModel *siteShallowGroundTempsPtr; // non-owning pointer + BaseGroundTempsModel *siteBuildingSurfaceGroundTempsPtr; // non-owning pointer + BaseGroundTempsModel *siteFCFactorMethodGroundTempsPtr; // non-owning pointer + BaseGroundTempsModel *siteDeepGroundTempsPtr; // non-owning pointer std::vector underwaterBoundaries; Weather::AnnualMonthlyDryBulbWeatherData OADryBulbAverage; // processes outside air drybulb temperature @@ -937,11 +937,6 @@ struct WeatherManagerData : BaseGlobalStruct void clear_state() override { - this->siteShallowGroundTempsPtr.reset(); - this->siteBuildingSurfaceGroundTempsPtr.reset(); - this->siteFCFactorMethodGroundTempsPtr.reset(); - this->siteDeepGroundTempsPtr.reset(); - new (this) WeatherManagerData(); } }; diff --git a/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc b/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc index 93ae904eea1..d0a87161d60 100644 --- a/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc +++ b/tst/EnergyPlus/unit/FiniteDifferenceGroundTemperatureModel.unit.cc @@ -69,23 +69,23 @@ using namespace EnergyPlus; TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModelTest) { - std::shared_ptr thisModel(new FiniteDiffGroundTempsModel()); + FiniteDiffGroundTempsModel thisModel; - thisModel->objectType = GroundTempObjType::FiniteDiffGroundTemp; - thisModel->objectName = "Test"; - thisModel->baseConductivity = 1.08; - thisModel->baseDensity = 962.0; - thisModel->baseSpecificHeat = 2576.0; - thisModel->waterContent = 30.0 / 100.0; - thisModel->saturatedWaterContent = 50.0 / 100.0; - thisModel->evapotransCoeff = 0.408; + thisModel.objectType = GroundTempObjType::FiniteDiffGroundTemp; + thisModel.objectName = "Test"; + thisModel.baseConductivity = 1.08; + thisModel.baseDensity = 962.0; + thisModel.baseSpecificHeat = 2576.0; + thisModel.waterContent = 30.0 / 100.0; + thisModel.saturatedWaterContent = 50.0 / 100.0; + thisModel.evapotransCoeff = 0.408; - EXPECT_NEAR(2.0, thisModel->interpolate(2.0, 3.0, 1.0, 3.0, 1.0), 0.0000001); + EXPECT_NEAR(2.0, thisModel.interpolate(2.0, 3.0, 1.0, 3.0, 1.0), 0.0000001); - thisModel->developMesh(); + thisModel.developMesh(); // Setting weather data manually here - thisModel->weatherDataArray.dimension(state->dataWeather->NumDaysInYear); + thisModel.weatherDataArray.dimension(state->dataWeather->NumDaysInYear); Real64 drybulb_minTemp = 5; Real64 drybulb_amp = 10; @@ -95,7 +95,7 @@ TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModelTest) Real64 solar_amp = 100; for (int day = 1; day <= state->dataWeather->NumDaysInYear; ++day) { - auto &tdwd = thisModel->weatherDataArray(day); // "This day weather data" + auto &tdwd = thisModel.weatherDataArray(day); // "This day weather data" Real64 theta = 2 * Constant::Pi * day / state->dataWeather->NumDaysInYear; Real64 omega = 2 * Constant::Pi * 130 / state->dataWeather->NumDaysInYear; // Shifts min to around the end of Jan @@ -108,56 +108,56 @@ TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModelTest) tdwd.airDensity = 1.2; } - thisModel->annualAveAirTemp = 15.0; - thisModel->maxDailyAirTemp = 25.0; - thisModel->minDailyAirTemp = 5.0; - thisModel->dayOfMinDailyAirTemp = 30; + thisModel.annualAveAirTemp = 15.0; + thisModel.maxDailyAirTemp = 25.0; + thisModel.minDailyAirTemp = 5.0; + thisModel.dayOfMinDailyAirTemp = 30; - thisModel->performSimulation(*state); + thisModel.performSimulation(*state); - EXPECT_NEAR(4.51, thisModel->getGroundTempAtTimeInMonths(*state, 0.0, 1), 0.01); - EXPECT_NEAR(19.14, thisModel->getGroundTempAtTimeInMonths(*state, 0.0, 6), 0.01); - EXPECT_NEAR(7.96, thisModel->getGroundTempAtTimeInMonths(*state, 0.0, 12), 0.01); - EXPECT_NEAR(3.46, thisModel->getGroundTempAtTimeInMonths(*state, 0.0, 14), 0.01); + EXPECT_NEAR(4.51, thisModel.getGroundTempAtTimeInMonths(*state, 0.0, 1), 0.01); + EXPECT_NEAR(19.14, thisModel.getGroundTempAtTimeInMonths(*state, 0.0, 6), 0.01); + EXPECT_NEAR(7.96, thisModel.getGroundTempAtTimeInMonths(*state, 0.0, 12), 0.01); + EXPECT_NEAR(3.46, thisModel.getGroundTempAtTimeInMonths(*state, 0.0, 14), 0.01); - EXPECT_NEAR(14.36, thisModel->getGroundTempAtTimeInMonths(*state, 3.0, 1), 0.01); - EXPECT_NEAR(11.78, thisModel->getGroundTempAtTimeInMonths(*state, 3.0, 6), 0.01); - EXPECT_NEAR(15.57, thisModel->getGroundTempAtTimeInMonths(*state, 3.0, 12), 0.01); + EXPECT_NEAR(14.36, thisModel.getGroundTempAtTimeInMonths(*state, 3.0, 1), 0.01); + EXPECT_NEAR(11.78, thisModel.getGroundTempAtTimeInMonths(*state, 3.0, 6), 0.01); + EXPECT_NEAR(15.57, thisModel.getGroundTempAtTimeInMonths(*state, 3.0, 12), 0.01); - EXPECT_NEAR(14.58, thisModel->getGroundTempAtTimeInMonths(*state, 25.0, 1), 0.01); - EXPECT_NEAR(14.55, thisModel->getGroundTempAtTimeInMonths(*state, 25.0, 6), 0.01); - EXPECT_NEAR(14.53, thisModel->getGroundTempAtTimeInMonths(*state, 25.0, 12), 0.01); + EXPECT_NEAR(14.58, thisModel.getGroundTempAtTimeInMonths(*state, 25.0, 1), 0.01); + EXPECT_NEAR(14.55, thisModel.getGroundTempAtTimeInMonths(*state, 25.0, 6), 0.01); + EXPECT_NEAR(14.53, thisModel.getGroundTempAtTimeInMonths(*state, 25.0, 12), 0.01); - EXPECT_NEAR(5.04, thisModel->getGroundTempAtTimeInSeconds(*state, 0.0, 0.0), 0.01); - EXPECT_NEAR(19.28, thisModel->getGroundTempAtTimeInSeconds(*state, 0.0, 14342400), 0.01); - EXPECT_NEAR(7.32, thisModel->getGroundTempAtTimeInSeconds(*state, 0.0, 30153600), 0.01); - EXPECT_NEAR(3.53, thisModel->getGroundTempAtTimeInSeconds(*state, 0.0, 35510400), 0.01); + EXPECT_NEAR(5.04, thisModel.getGroundTempAtTimeInSeconds(*state, 0.0, 0.0), 0.01); + EXPECT_NEAR(19.28, thisModel.getGroundTempAtTimeInSeconds(*state, 0.0, 14342400), 0.01); + EXPECT_NEAR(7.32, thisModel.getGroundTempAtTimeInSeconds(*state, 0.0, 30153600), 0.01); + EXPECT_NEAR(3.53, thisModel.getGroundTempAtTimeInSeconds(*state, 0.0, 35510400), 0.01); - EXPECT_NEAR(14.36, thisModel->getGroundTempAtTimeInSeconds(*state, 3.0, 1296000), 0.01); - EXPECT_NEAR(11.80, thisModel->getGroundTempAtTimeInSeconds(*state, 3.0, 14342400), 0.01); - EXPECT_NEAR(15.46, thisModel->getGroundTempAtTimeInSeconds(*state, 3.0, 30153600), 0.01); + EXPECT_NEAR(14.36, thisModel.getGroundTempAtTimeInSeconds(*state, 3.0, 1296000), 0.01); + EXPECT_NEAR(11.80, thisModel.getGroundTempAtTimeInSeconds(*state, 3.0, 14342400), 0.01); + EXPECT_NEAR(15.46, thisModel.getGroundTempAtTimeInSeconds(*state, 3.0, 30153600), 0.01); - EXPECT_NEAR(14.52, thisModel->getGroundTempAtTimeInSeconds(*state, 25.0, 0.0), 0.01); - EXPECT_NEAR(14.55, thisModel->getGroundTempAtTimeInSeconds(*state, 25.0, 14342400), 0.01); - EXPECT_NEAR(14.52, thisModel->getGroundTempAtTimeInSeconds(*state, 25.0, 30153600), 0.01); + EXPECT_NEAR(14.52, thisModel.getGroundTempAtTimeInSeconds(*state, 25.0, 0.0), 0.01); + EXPECT_NEAR(14.55, thisModel.getGroundTempAtTimeInSeconds(*state, 25.0, 14342400), 0.01); + EXPECT_NEAR(14.52, thisModel.getGroundTempAtTimeInSeconds(*state, 25.0, 30153600), 0.01); } TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModel_GetWeather_NoWeather) { - std::shared_ptr thisModel(new EnergyPlus::FiniteDiffGroundTempsModel()); + FiniteDiffGroundTempsModel thisModel; - thisModel->objectType = EnergyPlus::GroundTempObjType::FiniteDiffGroundTemp; - thisModel->objectName = "Test"; - thisModel->baseConductivity = 1.08; - thisModel->baseDensity = 962.0; - thisModel->baseSpecificHeat = 2576.0; - thisModel->waterContent = 30.0 / 100.0; - thisModel->saturatedWaterContent = 50.0 / 100.0; - thisModel->evapotransCoeff = 0.408; + thisModel.objectType = EnergyPlus::GroundTempObjType::FiniteDiffGroundTemp; + thisModel.objectName = "Test"; + thisModel.baseConductivity = 1.08; + thisModel.baseDensity = 962.0; + thisModel.baseSpecificHeat = 2576.0; + thisModel.waterContent = 30.0 / 100.0; + thisModel.saturatedWaterContent = 50.0 / 100.0; + thisModel.evapotransCoeff = 0.408; // No Weather file specified, so we expect it to fail - ASSERT_THROW(thisModel->getWeatherData(*state), std::runtime_error); + ASSERT_THROW(thisModel.getWeatherData(*state), std::runtime_error); std::string const error_string = delimited_string( {" ** Severe ** Site:GroundTemperature:Undisturbed:FiniteDifference -- using this model requires specification of a weather file.", @@ -290,19 +290,19 @@ TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModel_GetWeather_Weather) EXPECT_EQ(state->dataEnvrn->TotDesDays, 2); EXPECT_EQ(state->dataWeather->TotRunPers, 1); - std::shared_ptr thisModel(new EnergyPlus::FiniteDiffGroundTempsModel()); + FiniteDiffGroundTempsModel thisModel; - thisModel->objectType = EnergyPlus::GroundTempObjType::FiniteDiffGroundTemp; - thisModel->objectName = "Test"; - thisModel->baseConductivity = 1.08; - thisModel->baseDensity = 962.0; - thisModel->baseSpecificHeat = 2576.0; - thisModel->waterContent = 30.0 / 100.0; - thisModel->saturatedWaterContent = 50.0 / 100.0; - thisModel->evapotransCoeff = 0.408; + thisModel.objectType = EnergyPlus::GroundTempObjType::FiniteDiffGroundTemp; + thisModel.objectName = "Test"; + thisModel.baseConductivity = 1.08; + thisModel.baseDensity = 962.0; + thisModel.baseSpecificHeat = 2576.0; + thisModel.waterContent = 30.0 / 100.0; + thisModel.saturatedWaterContent = 50.0 / 100.0; + thisModel.evapotransCoeff = 0.408; // Shouldn't throw - thisModel->getWeatherData(*state); + thisModel.getWeatherData(*state); // It should have reverted the added period EXPECT_EQ(state->dataWeather->NumOfEnvrn, 3); @@ -310,10 +310,10 @@ TEST_F(EnergyPlusFixture, FiniteDiffGroundTempModel_GetWeather_Weather) EXPECT_EQ(state->dataWeather->TotRunPers, 1); // And should have populated a 365-day array of averages - EXPECT_EQ(365u, thisModel->weatherDataArray.size()); + EXPECT_EQ(365u, thisModel.weatherDataArray.size()); // Checking the first day against manually calculated value from EPW (24-hour averages for Jan 1) - auto &firstDay = thisModel->weatherDataArray(1); + auto &firstDay = thisModel.weatherDataArray(1); EXPECT_DOUBLE_EQ(firstDay.dryBulbTemp, -5.4); EXPECT_NEAR(firstDay.relativeHumidity, 0.7083, 0.005); EXPECT_NEAR(firstDay.windSpeed, 2.8083, 0.001); diff --git a/tst/EnergyPlus/unit/SiteGroundDomain.unit.cc b/tst/EnergyPlus/unit/SiteGroundDomain.unit.cc index 61cdaaaa2fc..656ae4ec099 100644 --- a/tst/EnergyPlus/unit/SiteGroundDomain.unit.cc +++ b/tst/EnergyPlus/unit/SiteGroundDomain.unit.cc @@ -89,5 +89,5 @@ TEST_F(EnergyPlusFixture, SiteGroundDomainSlabAndBasementModelsIndexChecking) state->dataPlantPipingSysMgr->domains[1].groundTempModel = GetGroundTempModelAndInit(*state, "Site:GroundTemperature:Undisturbed:KusudaAchenbach", "KA2"); - EXPECT_NE(state->dataPlantPipingSysMgr->domains[0].groundTempModel.get(), state->dataPlantPipingSysMgr->domains[1].groundTempModel.get()); + EXPECT_NE(state->dataPlantPipingSysMgr->domains[0].groundTempModel, state->dataPlantPipingSysMgr->domains[1].groundTempModel); } From 1980d22a4354bb7570925dd2f30d90a4edd3529b Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Fri, 8 Nov 2024 08:59:32 -0600 Subject: [PATCH 93/99] Overhaul ground temperature code a bit --- dictionary.dic | 32 ++++++ src/EnergyPlus/Data/BaseData.hh | 1 + src/EnergyPlus/Data/CommonIncludes.hh | 1 - src/EnergyPlus/Data/EnergyPlusData.hh | 2 - .../BaseGroundTemperatureModel.hh | 39 +++++++ .../FiniteDifferenceGroundTemperatureModel.cc | 7 +- .../GroundTemperatureModelManager.cc | 102 +++++++----------- .../GroundTemperatureModelManager.hh | 37 +------ .../KusudaAchenbachGroundTemperatureModel.cc | 22 ++-- .../SiteBuildingSurfaceGroundTemperatures.cc | 17 +-- .../SiteBuildingSurfaceGroundTemperatures.hh | 1 - .../SiteDeepGroundTemperatures.cc | 14 +-- .../SiteDeepGroundTemperatures.hh | 1 - .../SiteFCFactorMethodGroundTemperatures.cc | 14 +-- .../SiteFCFactorMethodGroundTemperatures.hh | 1 - .../SiteShallowGroundTemperatures.cc | 14 +-- .../SiteShallowGroundTemperatures.hh | 1 - .../XingGroundTemperatureModel.cc | 8 +- .../XingGroundTemperatureModel.hh | 1 - src/EnergyPlus/WeatherManager.cc | 8 +- 20 files changed, 151 insertions(+), 172 deletions(-) create mode 100644 dictionary.dic diff --git a/dictionary.dic b/dictionary.dic new file mode 100644 index 00000000000..81124bc4dda --- /dev/null +++ b/dictionary.dic @@ -0,0 +1,32 @@ +AirLoopHVAC +AirToAir +BalancedFlow +Celdek +CeldekPad +CoilSystem +ComponentModel +ConstantVolume +DetailedGeometry +Evaporative +EvaporativeCooler +FlatPlate +HeatExchanger +HeatExchangerAssisted +HVACDOAS +Liesen +NoFans +OutdoorAir +OutdoorAirSystem +PhotovoltaicThermal +ResearchSpecial +SensibleAndLatent +SolarCollector +SystemModel +TerminalUnit +UnglazedTranspired +UnitarySystem +UserDefined +VariableRefrigerantFlow +VariableVolume +WetCoil +ZoneHVAC diff --git a/src/EnergyPlus/Data/BaseData.hh b/src/EnergyPlus/Data/BaseData.hh index 17d248e66d0..0367c29cbcd 100644 --- a/src/EnergyPlus/Data/BaseData.hh +++ b/src/EnergyPlus/Data/BaseData.hh @@ -54,6 +54,7 @@ struct EnergyPlusData; // Forward declaration struct BaseGlobalStruct { + virtual ~BaseGlobalStruct() = default; virtual void init_state([[maybe_unused]] EnergyPlusData &state) = 0; virtual void clear_state() = 0; }; diff --git a/src/EnergyPlus/Data/CommonIncludes.hh b/src/EnergyPlus/Data/CommonIncludes.hh index a7ba5bc5042..d880105ca97 100644 --- a/src/EnergyPlus/Data/CommonIncludes.hh +++ b/src/EnergyPlus/Data/CommonIncludes.hh @@ -159,7 +159,6 @@ #include #include #include -#include #include #include #include diff --git a/src/EnergyPlus/Data/EnergyPlusData.hh b/src/EnergyPlus/Data/EnergyPlusData.hh index bfe3499577e..ec08c29bc93 100644 --- a/src/EnergyPlus/Data/EnergyPlusData.hh +++ b/src/EnergyPlus/Data/EnergyPlusData.hh @@ -50,8 +50,6 @@ // C++ Headers #include -#include -#include // EnergyPlus Headers #include diff --git a/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh index bafa79ddbff..d131a8391e0 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh @@ -70,6 +70,24 @@ enum class GroundTempObjType Num }; +constexpr std::array(GroundTempObjType::Num)> groundTempModelNamesUC = { + "SITE:GROUNDTEMPERATURE:UNDISTURBED:KUSUDAACHENBACH", + "SITE:GROUNDTEMPERATURE:UNDISTURBED:FINITEDIFFERENCE", + "SITE:GROUNDTEMPERATURE:BUILDINGSURFACE", + "SITE:GROUNDTEMPERATURE:SHALLOW", + "SITE:GROUNDTEMPERATURE:DEEP", + "SITE:GROUNDTEMPERATURE:FCFACTORMETHOD", + "SITE:GROUNDTEMPERATURE:UNDISTURBED:XING"}; + +constexpr std::array(GroundTempObjType::Num)> groundTempModelNames = { + "Site:GroundTemperature:Undisturbed:KusudaAchenbach", + "Site:GroundTemperature:Undisturbed:FiniteDifference", + "Site:GroundTemperature:BuildingSurface", + "Site:GroundTemperature:Shallow", + "Site:GroundTemperature:Deep", + "Site:GroundTemperature:FCfactorMethod", + "Site:GroundTemperature:Undisturbed:Xing"}; + // Base class class BaseGroundTempsModel { @@ -104,6 +122,27 @@ protected: } }; +struct GroundTemperatureManagerData final : BaseGlobalStruct +{ + // all ground temperature model instances are owned here + // client component models can get pointers to the instances inside this vector, but they don't own them + std::vector groundTempModels; + + void init_state([[maybe_unused]] EnergyPlusData &state) override + { + } + + void clear_state() override + { + for (const auto &groundTempModel : groundTempModels) { + delete groundTempModel; + } + new (this) GroundTemperatureManagerData(); + } + + virtual ~GroundTemperatureManagerData() = default; +}; + } // namespace EnergyPlus #endif diff --git a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc index 5e50a53107c..119b036d2d6 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,7 @@ FiniteDiffGroundTempsModel *FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(Ene GroundTempObjType objType = GroundTempObjType::FiniteDiffGroundTemp; // Search through finite diff models here - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { @@ -126,9 +125,7 @@ FiniteDiffGroundTempsModel *FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(Ene return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc index 4c4f3e6ec88..22758c9e589 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.cc @@ -62,75 +62,53 @@ #include #include -namespace EnergyPlus { +namespace EnergyPlus::GroundTemperatureManager { -namespace GroundTemperatureManager { +BaseGroundTempsModel *GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const type, std::string const &name) +{ + // SUBROUTINE INFORMATION: + // AUTHOR Matt Mitchell + // DATE WRITTEN Summer 2015 - constexpr std::array(GroundTempObjType::Num)> groundTempModelNamesUC = { - "SITE:GROUNDTEMPERATURE:UNDISTURBED:KUSUDAACHENBACH", - "SITE:GROUNDTEMPERATURE:UNDISTURBED:FINITEDIFFERENCE", - "SITE:GROUNDTEMPERATURE:BUILDINGSURFACE", - "SITE:GROUNDTEMPERATURE:SHALLOW", - "SITE:GROUNDTEMPERATURE:DEEP", - "SITE:GROUNDTEMPERATURE:FCFACTORMETHOD", - "SITE:GROUNDTEMPERATURE:UNDISTURBED:XING"}; + // PURPOSE OF THIS SUBROUTINE: + // Called by objects requiring ground temperature models. Determines type and calls appropriate factory method. - constexpr std::array(GroundTempObjType::Num)> groundTempModelNames = { - "Site:GroundTemperature:Undisturbed:KusudaAchenbach", - "Site:GroundTemperature:Undisturbed:FiniteDifference", - "Site:GroundTemperature:BuildingSurface", - "Site:GroundTemperature:Shallow", - "Site:GroundTemperature:Deep", - "Site:GroundTemperature:FCfactorMethod", - "Site:GroundTemperature:Undisturbed:Xing"}; + // Set object type + const auto objectType = static_cast(getEnumValue(groundTempModelNamesUC, Util::makeUPPER(type))); - BaseGroundTempsModel *GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const type, std::string const &name) - { - // SUBROUTINE INFORMATION: - // AUTHOR Matt Mitchell - // DATE WRITTEN Summer 2015 + assert(objectType != GroundTempObjType::Invalid); - // PURPOSE OF THIS SUBROUTINE: - // Called by objects requiring ground temperature models. Determines type and calls appropriate factory method. + const int numGTMs = static_cast(state.dataGrndTempModelMgr->groundTempModels.size()); - // Set object type - const auto objectType = static_cast(getEnumValue(groundTempModelNamesUC, Util::makeUPPER(type))); - - assert(objectType != GroundTempObjType::Invalid); - - const int numGTMs = static_cast(state.dataGrndTempModelMgr->groundTempModels.size()); - - // Check if this instance of this model has already been retrieved - for (int i = 0; i < numGTMs; ++i) { - auto currentModel = state.dataGrndTempModelMgr->groundTempModels[i]; - // Check if the type and name match - if (objectType == currentModel->objectType && name == currentModel->objectName) { - return state.dataGrndTempModelMgr->groundTempModels[i]; - } - } - - // If not found, create new instance of the model - switch (objectType) { - case GroundTempObjType::KusudaGroundTemp: - return KusudaGroundTempsModel::KusudaGTMFactory(state, name); - case GroundTempObjType::FiniteDiffGroundTemp: - return FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(state, name); - case GroundTempObjType::SiteBuildingSurfaceGroundTemp: - return SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(state, name); - case GroundTempObjType::SiteShallowGroundTemp: - return SiteShallowGroundTemps::ShallowGTMFactory(state, name); - case GroundTempObjType::SiteDeepGroundTemp: - return SiteDeepGroundTemps::DeepGTMFactory(state, name); - case GroundTempObjType::SiteFCFactorMethodGroundTemp: - return SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(state, name); - case GroundTempObjType::XingGroundTemp: - return XingGroundTempsModel::XingGTMFactory(state, name); - default: - assert(false); - return nullptr; + // Check if this instance of this model has already been retrieved + for (int i = 0; i < numGTMs; ++i) { + auto currentModel = state.dataGrndTempModelMgr->groundTempModels[i]; + // Check if the type and name match + if (objectType == currentModel->objectType && name == currentModel->objectName) { + return state.dataGrndTempModelMgr->groundTempModels[i]; } } -} // namespace GroundTemperatureManager + // If not found, create new instance of the model + switch (objectType) { + case GroundTempObjType::KusudaGroundTemp: + return KusudaGroundTempsModel::KusudaGTMFactory(state, name); + case GroundTempObjType::FiniteDiffGroundTemp: + return FiniteDiffGroundTempsModel::FiniteDiffGTMFactory(state, name); + case GroundTempObjType::SiteBuildingSurfaceGroundTemp: + return SiteBuildingSurfaceGroundTemps::BuildingSurfaceGTMFactory(state, name); + case GroundTempObjType::SiteShallowGroundTemp: + return SiteShallowGroundTemps::ShallowGTMFactory(state, name); + case GroundTempObjType::SiteDeepGroundTemp: + return SiteDeepGroundTemps::DeepGTMFactory(state, name); + case GroundTempObjType::SiteFCFactorMethodGroundTemp: + return SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(state, name); + case GroundTempObjType::XingGroundTemp: + return XingGroundTempsModel::XingGTMFactory(state, name); + default: + assert(false); + return nullptr; + } +} -} // namespace EnergyPlus +} // namespace EnergyPlus::GroundTemperatureManager diff --git a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh index a411e93987b..804a6df2c1e 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh @@ -48,45 +48,14 @@ #ifndef GroundTemperatureModelManager_hh_INCLUDED #define GroundTemperatureModelManager_hh_INCLUDED -// ObjexxFCL Headers -#include - // EnergyPlus Headers #include #include -namespace EnergyPlus { - -// Forward declarations -struct EnergyPlusData; -class BaseGroundTempsModel; - -namespace GroundTemperatureManager { - - extern const std::array(GroundTempObjType::Num)> groundTempModelNamesUC; - - extern const std::array(GroundTempObjType::Num)> groundTempModelNames; - - BaseGroundTempsModel *GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view type, std::string const &name); - -} // namespace GroundTemperatureManager - -struct GroundTemperatureManagerData final : BaseGlobalStruct -{ - std::vector groundTempModels; - - void init_state([[maybe_unused]] EnergyPlusData &state) override - { - } - - void clear_state() override - { - new (this) GroundTemperatureManagerData(); - } +namespace EnergyPlus::GroundTemperatureManager { - virtual ~GroundTemperatureManagerData() = default; -}; +BaseGroundTempsModel *GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view type, std::string const &name); -} // namespace EnergyPlus +} // namespace EnergyPlus::GroundTemperatureManager #endif diff --git a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc index fe827b17419..dc16e3edc16 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc @@ -48,8 +48,8 @@ // EnergyPlus Headers #include #include -#include #include +#include #include #include #include @@ -78,11 +78,15 @@ KusudaGroundTempsModel *KusudaGroundTempsModel::KusudaGTMFactory(EnergyPlusData // New shared pointer for this model object auto *thisModel = new KusudaGroundTempsModel(); - std::string lookingForName = objectName; + // There was some **spooky** behavior here. One of the calling sites for this factory was passing in a reference + // to a dataIPShortCuts item as the objectName argument. Inside here, we make a second call to getObjectItem + // which then overwrites the value. So objectName gets overwritten. I made a copy of the string here to ensure + // it persists. + const std::string lookingForName = objectName; // NOLINT(*-unnecessary-copy-initialization) - GroundTempObjType objType = GroundTempObjType::KusudaGroundTemp; + auto objType = GroundTempObjType::KusudaGroundTemp; - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { @@ -120,10 +124,8 @@ KusudaGroundTempsModel *KusudaGroundTempsModel::KusudaGTMFactory(EnergyPlusData Real64 minSurfTemp(100); // Set high; month 1 temp will be lower than that and actually get updated Real64 maxSurfTemp(-100); // Set low initially but will get updated - BaseGroundTempsModel *shallowObj = GroundTemperatureManager::GetGroundTempModelAndInit( - state, - GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteShallowGroundTemp)], - ""); // TODO: OK, so this is grabbing the surface temperatures, whether default (13) or user defined. + // get a non-owning pointer to the shallow ground temperature object, whether user-input or defaults + BaseGroundTempsModel *shallowObj = SiteShallowGroundTemps::ShallowGTMFactory(state, ""); for (int monthIndex = 1; monthIndex <= 12; ++monthIndex) { const Real64 currMonthTemp = shallowObj->getGroundTempAtTimeInMonths(state, 0.0, monthIndex); @@ -164,9 +166,7 @@ KusudaGroundTempsModel *KusudaGroundTempsModel::KusudaGTMFactory(EnergyPlusData return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc index 1eacf7108f1..72082808834 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -76,7 +75,7 @@ SiteBuildingSurfaceGroundTemps *SiteBuildingSurfaceGroundTemps::BuildingSurfaceG auto objType = GroundTempObjType::SiteBuildingSurfaceGroundTemp; - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; @@ -94,8 +93,7 @@ SiteBuildingSurfaceGroundTemps *SiteBuildingSurfaceGroundTemps::BuildingSurfaceG state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); if (NumNums < 12) { - ShowSevereError( - state, fmt::format("{}: Less than 12 values entered.", GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", groundTempModelNames[static_cast(objType)])); errorsFound = true; } @@ -109,15 +107,12 @@ SiteBuildingSurfaceGroundTemps *SiteBuildingSurfaceGroundTemps::BuildingSurfaceG if (genErrorMessage) { ShowWarningError(state, - fmt::format("{}: Some values fall outside the range of 15-25C.", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + fmt::format("{}: Some values fall outside the range of 15-25C.", groundTempModelNames[static_cast(objType)])); ShowContinueError(state, "These values may be inappropriate. Please consult the Input Output Reference for more details."); } } else if (numCurrObjects > 1) { - ShowSevereError(state, - fmt::format("{}: Too many objects entered. Only one allowed.", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", groundTempModelNames[static_cast(objType)])); errorsFound = true; } else { std::fill(thisModel->buildingSurfaceGroundTemps.begin(), thisModel->buildingSurfaceGroundTemps.end(), 18.0); @@ -131,9 +126,7 @@ SiteBuildingSurfaceGroundTemps *SiteBuildingSurfaceGroundTemps::BuildingSurfaceG return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh index ee1185ac65f..9eac477a77a 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh @@ -51,7 +51,6 @@ #include // EnergyPlus Headers -#include #include #include diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc index 54b9f75529e..252118909e4 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -81,7 +80,7 @@ SiteDeepGroundTemps *SiteDeepGroundTemps::DeepGTMFactory(EnergyPlusData &state, auto objType = GroundTempObjType::SiteDeepGroundTemp; - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; @@ -98,8 +97,7 @@ SiteDeepGroundTemps *SiteDeepGroundTemps::DeepGTMFactory(EnergyPlusData &state, state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); if (NumNums < 12) { - ShowSevereError( - state, fmt::format("{}: Less than 12 values entered.", GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", groundTempModelNames[static_cast(objType)])); errorsFound = true; } @@ -111,9 +109,7 @@ SiteDeepGroundTemps *SiteDeepGroundTemps::DeepGTMFactory(EnergyPlusData &state, state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::Deep)] = true; } else if (numCurrObjects > 1) { - ShowSevereError(state, - fmt::format("{}: Too many objects entered. Only one allowed.", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", groundTempModelNames[static_cast(objType)])); errorsFound = true; } else { @@ -128,9 +124,7 @@ SiteDeepGroundTemps *SiteDeepGroundTemps::DeepGTMFactory(EnergyPlusData &state, return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh index 4c0e73272ea..059ae85c301 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh @@ -52,7 +52,6 @@ #include // EnergyPlus Headers -#include #include #include diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc index 6b0770f56b9..d3a053d5f48 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -80,7 +79,7 @@ SiteFCFactorMethodGroundTemps *SiteFCFactorMethodGroundTemps::FCFactorGTMFactory auto objType = GroundTempObjType::SiteFCFactorMethodGroundTemp; - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; @@ -97,8 +96,7 @@ SiteFCFactorMethodGroundTemps *SiteFCFactorMethodGroundTemps::FCFactorGTMFactory state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); if (NumNums < 12) { - ShowSevereError( - state, fmt::format("{}: Less than 12 values entered.", GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", groundTempModelNames[static_cast(objType)])); // found stays false } else { // overwrite values read from weather file for the 0.5m set ground temperatures @@ -111,9 +109,7 @@ SiteFCFactorMethodGroundTemps *SiteFCFactorMethodGroundTemps::FCFactorGTMFactory } } else if (numCurrObjects > 1) { - ShowSevereError(state, - fmt::format("{}: Too many objects entered. Only one allowed.", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", groundTempModelNames[static_cast(objType)])); // found stays false } else if (state.dataWeather->wthFCGroundTemps) { @@ -139,9 +135,7 @@ SiteFCFactorMethodGroundTemps *SiteFCFactorMethodGroundTemps::FCFactorGTMFactory state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel); return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh index c66e4392f3b..ff9b476598e 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh @@ -52,7 +52,6 @@ #include // EnergyPlus Headers -#include #include #include diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc index 2ed6aaf9eec..b6ccf86d4c0 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -80,7 +79,7 @@ SiteShallowGroundTemps *SiteShallowGroundTemps::ShallowGTMFactory(EnergyPlusData auto objType = GroundTempObjType::SiteShallowGroundTemp; - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; @@ -97,8 +96,7 @@ SiteShallowGroundTemps *SiteShallowGroundTemps::ShallowGTMFactory(EnergyPlusData state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); if (NumNums < 12) { - ShowSevereError( - state, fmt::format("{}: Less than 12 values entered.", GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", groundTempModelNames[static_cast(objType)])); errorsFound = true; } @@ -110,9 +108,7 @@ SiteShallowGroundTemps *SiteShallowGroundTemps::ShallowGTMFactory(EnergyPlusData state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::Shallow)] = true; } else if (numCurrObjects > 1) { - ShowSevereError(state, - fmt::format("{}: Too many objects entered. Only one allowed.", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", groundTempModelNames[static_cast(objType)])); errorsFound = true; } else { std::fill(thisModel->surfaceGroundTemps.begin(), thisModel->surfaceGroundTemps.end(), 13.0); @@ -126,9 +122,7 @@ SiteShallowGroundTemps *SiteShallowGroundTemps::ShallowGTMFactory(EnergyPlusData return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh index 5f5f4c4d935..30909d9aa83 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh @@ -52,7 +52,6 @@ #include // EnergyPlus Headers -#include #include #include diff --git a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc index 0c5dc6c7e78..5ea41267dec 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc @@ -51,9 +51,7 @@ // EnergyPlus headers #include #include -#include #include -#include #include #include #include @@ -84,7 +82,7 @@ XingGroundTempsModel *XingGroundTempsModel::XingGTMFactory(EnergyPlusData &state auto objType = GroundTempObjType::XingGroundTemp; - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { @@ -116,9 +114,7 @@ XingGroundTempsModel *XingGroundTempsModel::XingGTMFactory(EnergyPlusData &state return thisModel; } - ShowFatalError(state, - fmt::format("{}--Errors getting input for ground temperature model", - GroundTemperatureManager::groundTempModelNames[static_cast(objType)])); + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", groundTempModelNames[static_cast(objType)])); return nullptr; } diff --git a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh index d1fbabaf5ec..38d5a9197aa 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh @@ -49,7 +49,6 @@ #define XingGroundTemperatureManager_hh_INCLUDED // EnergyPlus Headers -#include #include #include diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 3738697f0c8..4c5f9964ad4 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -6707,19 +6707,19 @@ namespace Weather { // Initialize Site:GroundTemperature:BuildingSurface object state.dataWeather->siteBuildingSurfaceGroundTempsPtr = GroundTemperatureManager::GetGroundTempModelAndInit( - state, GroundTemperatureManager::groundTempModelNamesUC[(int)GroundTempObjType::SiteBuildingSurfaceGroundTemp], ""); + state, groundTempModelNamesUC[(int)GroundTempObjType::SiteBuildingSurfaceGroundTemp], ""); // Initialize Site:GroundTemperature:FCFactorMethod object state.dataWeather->siteFCFactorMethodGroundTempsPtr = GroundTemperatureManager::GetGroundTempModelAndInit( - state, GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteFCFactorMethodGroundTemp)], ""); + state, groundTempModelNamesUC[static_cast(GroundTempObjType::SiteFCFactorMethodGroundTemp)], ""); // Initialize Site:GroundTemperature:Shallow object state.dataWeather->siteShallowGroundTempsPtr = GroundTemperatureManager::GetGroundTempModelAndInit( - state, GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteShallowGroundTemp)], ""); + state, groundTempModelNamesUC[static_cast(GroundTempObjType::SiteShallowGroundTemp)], ""); // Initialize Site:GroundTemperature:Deep object state.dataWeather->siteDeepGroundTempsPtr = GroundTemperatureManager::GetGroundTempModelAndInit( - state, GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteDeepGroundTemp)], ""); + state, groundTempModelNamesUC[static_cast(GroundTempObjType::SiteDeepGroundTemp)], ""); } void GetGroundReflectances(EnergyPlusData &state, bool &ErrorsFound) From 4f510299475c560f779734ae7114a0d2aae260f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 06:57:28 +0000 Subject: [PATCH 94/99] Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.12.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.3...v1.12.2) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 405e19732d3..094aaf0f082 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -47,7 +47,7 @@ jobs: path: ./dist - name: Deploy on Test PyPi - uses: pypa/gh-action-pypi-publish@v1.10.3 + uses: pypa/gh-action-pypi-publish@v1.12.2 with: repository-url: https://test.pypi.org/legacy/ user: __token__ From 9f87d4e7c15105aada2285a4844f6808b5f4d148 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 19 Nov 2024 11:00:33 -0600 Subject: [PATCH 95/99] Bump GCC version for Decent CI --- .decent_ci-Linux.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 28de42f0898..5632db2785b 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -1,13 +1,13 @@ compilers: - name: "gcc" - version: "11.4" + version: "13.2" cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DBUILD_PERFORMANCE_TESTS:BOOL=ON -DVALGRIND_ANALYZE_PERFORMANCE_TESTS:BOOL=ON -DENABLE_PCH:BOOL=OFF collect_performance_results: true skip_regression: true s3_upload_bucket: energyplus - name: "gcc" - version: "11.4" + version: "13.2" build_type: RelWithDebInfo cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF coverage_enabled: true @@ -21,7 +21,7 @@ compilers: skip_packaging: true - name: "gcc" - version: "11.4" + version: "13.2" build_type: RelWithDebInfo cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF coverage_enabled: true From facb90bf48142027294d8754e90d91e4e880200c Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 19 Nov 2024 12:26:05 -0600 Subject: [PATCH 96/99] Hacky workaround in FMT to avoid build warning, limit CI CPU to 16 to avoid swap --- .decent_ci-Linux.yaml | 3 +++ third_party/fmt-8.0.1/include/fmt/format.h | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 5632db2785b..028a51d9e61 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -5,6 +5,7 @@ compilers: collect_performance_results: true skip_regression: true s3_upload_bucket: energyplus + num_parallel_builds: 16 - name: "gcc" version: "13.2" @@ -19,6 +20,7 @@ compilers: ctest_filter: -E "integration.*" skip_regression: true skip_packaging: true + num_parallel_builds: 16 - name: "gcc" version: "13.2" @@ -33,3 +35,4 @@ compilers: ctest_filter: -R "integration.*" skip_regression: true skip_packaging: true + num_parallel_builds: 16 diff --git a/third_party/fmt-8.0.1/include/fmt/format.h b/third_party/fmt-8.0.1/include/fmt/format.h index 82ddb407d09..2b886a1be63 100644 --- a/third_party/fmt-8.0.1/include/fmt/format.h +++ b/third_party/fmt-8.0.1/include/fmt/format.h @@ -316,8 +316,10 @@ template <> constexpr auto num_bits() -> int { FMT_INLINE void assume(bool condition) { (void)condition; -#if FMT_HAS_BUILTIN(__builtin_assume) +#if FMT_HAS_BUILTIN(__builtin_assume) && !FMT_ICC_VERSION __builtin_assume(condition); +#elif FMT_GCC_VERSION + if (!condition) __builtin_unreachable(); #endif } @@ -751,8 +753,18 @@ void basic_memory_buffer::grow(size_t size) { T* new_data = std::allocator_traits::allocate(alloc_, new_capacity); // The following code doesn't throw, so the raw pointer above doesn't leak. - std::uninitialized_copy(old_data, old_data + this->size(), - detail::make_checked(new_data, new_capacity)); + // std::uninitialized_copy(old_data, old_data + this->size(), + // detail::make_checked(new_data, new_capacity)); + // ****** MYOLDMOPAR MANUAL EDIT + // I manually applied some of the changes from this commit + // https://github.com/fmtlib/fmt/commit/fb97cb2318dd14b5c791699232e1e73782be7e57 + // Because of a GCC 13 false positive issuing a string overflow warning + // fmt issue: https://github.com/fmtlib/fmt/issues/3533 + // upstream report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109717 + // An updated FMT version could mute this with the FMT_SYSTEM_HEADERS CMake flag turned on, but it seems fmt-8.0.1 doesn't respond to that + detail::assume(this->size() <= new_capacity); + std::uninitialized_copy_n(old_data, this->size(), new_data); + // ****** this->set(new_data, new_capacity); // deallocate must not throw according to the standard, but even if it does, // the buffer already uses the new storage and will deallocate it in From 9481231faa2a610aed5d182e3e622816252b4ef9 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 19 Nov 2024 15:14:45 -0600 Subject: [PATCH 97/99] Pointing EnergyPlusRegressionTool back to main since the PR was merged a while ago --- .decent_ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.decent_ci.yaml b/.decent_ci.yaml index 011ef0a2485..a80d9aee629 100644 --- a/.decent_ci.yaml +++ b/.decent_ci.yaml @@ -2,7 +2,7 @@ results_repository : Myoldmopar/EnergyPlusBuildResults results_path : _posts results_base_url : https://myoldmopar.github.io/EnergyPlusBuildResults regression_repository : NREL/EnergyPlusRegressionTool -regression_branch : BumpToBoto3 # this is the branch of NREL/EnergyPlusRegressionTool to use (usually main) +regression_branch : main # this is the branch of NREL/EnergyPlusRegressionTool to use (usually main) regression_baseline_default : develop # this is the NREL/EnergyPlus branch to use as the baseline for regressions regression_baseline_develop : "" regression_baseline_master : "" From c12ba5aa1a4d392bbb7d48b76ceebdff07c9f0d9 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Tue, 19 Nov 2024 17:09:41 -0600 Subject: [PATCH 98/99] Looks like peak memory usage was well under, bumping cores to 18 --- .decent_ci-Linux.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 028a51d9e61..5e2ad156e5d 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -5,7 +5,7 @@ compilers: collect_performance_results: true skip_regression: true s3_upload_bucket: energyplus - num_parallel_builds: 16 + num_parallel_builds: 18 - name: "gcc" version: "13.2" @@ -20,7 +20,7 @@ compilers: ctest_filter: -E "integration.*" skip_regression: true skip_packaging: true - num_parallel_builds: 16 + num_parallel_builds: 18 - name: "gcc" version: "13.2" @@ -35,4 +35,4 @@ compilers: ctest_filter: -R "integration.*" skip_regression: true skip_packaging: true - num_parallel_builds: 16 + num_parallel_builds: 18 From b0a9c4e52d98c8e24fdca0e188b2f7d10eae11bc Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Thu, 21 Nov 2024 12:13:12 -0600 Subject: [PATCH 99/99] Pull CPUs back down to 16 --- .decent_ci-Linux.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 5e2ad156e5d..028a51d9e61 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -5,7 +5,7 @@ compilers: collect_performance_results: true skip_regression: true s3_upload_bucket: energyplus - num_parallel_builds: 18 + num_parallel_builds: 16 - name: "gcc" version: "13.2" @@ -20,7 +20,7 @@ compilers: ctest_filter: -E "integration.*" skip_regression: true skip_packaging: true - num_parallel_builds: 18 + num_parallel_builds: 16 - name: "gcc" version: "13.2" @@ -35,4 +35,4 @@ compilers: ctest_filter: -R "integration.*" skip_regression: true skip_packaging: true - num_parallel_builds: 18 + num_parallel_builds: 16