diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 28de42f0898..028a51d9e61 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -1,13 +1,14 @@ 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 + num_parallel_builds: 16 - 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 @@ -19,9 +20,10 @@ compilers: ctest_filter: -E "integration.*" skip_regression: true skip_packaging: true + num_parallel_builds: 16 - 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 @@ -33,3 +35,4 @@ compilers: ctest_filter: -R "integration.*" skip_regression: true skip_packaging: true + num_parallel_builds: 16 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 : "" 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__ 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/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 7c86b973419..750867c6d95 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -47,6 +47,7 @@ // C++ Headers #include +#include #include // ObjexxFCL Headers @@ -487,12 +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->GFNC(i) = tmpGvals[i - 1]; + this->LNTTS.push_back(tmpLntts[i - 1]); + this->GFNC.push_back(tmpGvals[i - 1]); } } @@ -649,7 +648,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; @@ -962,18 +961,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); + this->myRespFactors->GFNC = gt::gfunction::uniform_borehole_wall_temperature( + boreholes, this->myRespFactors->time, this->soil.diffusivity, nSegments, true, state.dataGlobal->numThread); } //****************************************************************************** @@ -989,8 +982,8 @@ 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"]["LNTTS"] = std::vector(this->myRespFactors->LNTTS.begin(), this->myRespFactors->LNTTS.end()); + myCacheData["Response Factors"]["time"] = std::vector(this->myRespFactors->time); + 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); } @@ -1025,17 +1018,12 @@ 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); - - int index = 1; - for (auto const &thisLNTTS : tempLNTTS) { - this->myRespFactors->time(index) = exp(thisLNTTS) * t_s; - this->myRespFactors->LNTTS(index) = thisLNTTS; - ++index; - } + 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); } //****************************************************************************** @@ -1045,15 +1033,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)); + 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; @@ -1375,25 +1363,18 @@ 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)); + 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]); } - // Move combined values into right data struct - this->myRespFactors->time.deallocate(); - this->myRespFactors->LNTTS.deallocate(); - 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->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->LNTTS[index] = LNTTS_combined[index]; - this->myRespFactors->GFNC[index] = GFNC_combined[index]; - } + this->myRespFactors->LNTTS = LNTTS_combined; + this->myRespFactors->GFNC = GFNC_combined; } void GLHEBase::makeThisGLHECacheAndCompareWithFileCache(EnergyPlusData &state) @@ -1460,13 +1441,13 @@ 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>()); + 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>()); } } @@ -1522,18 +1503,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->LNTTS.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; - this->myRespFactors->LNTTS(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 @@ -1652,8 +1628,8 @@ 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->LNTTS(NT) = tLg; + 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 } @@ -1834,7 +1810,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 @@ -1848,33 +1824,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) { - f(j) = f(j); - } 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()); } //****************************************************************************** @@ -1896,29 +1867,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 a8b5ff2db37..e686f94d61f 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -201,9 +201,9 @@ 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 - Array1D LNTTS; // natural log of Non Dimensional Time Ln(t/ts) - Array1D GFNC; // G-function ( Non Dimensional temperature response factors) + std::vector time; // response time in seconds + 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 @@ -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; @@ -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); diff --git a/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh b/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh index bb06d658b56..d131a8391e0 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/BaseGroundTemperatureModel.hh @@ -70,31 +70,45 @@ 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 { 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) @@ -108,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 b8c1de403df..119b036d2d6 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 @@ -61,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -72,7 +69,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 +85,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); + 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,12 +123,10 @@ 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", groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -143,13 +138,13 @@ void FiniteDiffGroundTempsModel::initAndSim(EnergyPlusData &state) // DATE WRITTEN Summer 2015 // PURPOSE OF THIS SUBROUTINE: - // Initializes 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 +160,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 +187,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 +201,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 +224,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" @@ -359,18 +347,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 +386,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 +481,7 @@ void FiniteDiffGroundTempsModel::performSimulation(EnergyPlusData &state) //****************************************************************************** -void FiniteDiffGroundTempsModel::updateSurfaceCellTemperature(EnergyPlusData &state) +void FiniteDiffGroundTempsModel::updateSurfaceCellTemperature(const EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -506,84 +494,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 Radiation - incidentSolar_MJhrmin = cwd.horizontalRadiation * convert_Wm2_To_MJhrmin; + 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 +561,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 +617,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 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)); + 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 +688,7 @@ void FiniteDiffGroundTempsModel::updateBottomCellTemperature() //****************************************************************************** -bool FiniteDiffGroundTempsModel::checkFinalTemperatureConvergence(EnergyPlusData &state) +bool FiniteDiffGroundTempsModel::checkFinalTemperatureConvergence(const EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -799,7 +766,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 +787,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 +813,7 @@ void FiniteDiffGroundTempsModel::updateIterationTemperatures() //****************************************************************************** -void FiniteDiffGroundTempsModel::updateTimeStepTemperatures(EnergyPlusData &state) +void FiniteDiffGroundTempsModel::updateTimeStepTemperatures(const EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Matt Mitchell @@ -881,7 +848,7 @@ void FiniteDiffGroundTempsModel::doStartOfTimeStepInits() auto &thisCell = cellArray(cell); - evaluateSoilRhoCp(cell); + evaluateSoilRhoCpCell(cell); thisCell.beta = (timeStepInSeconds / (thisCell.props.rhoCp * thisCell.volume)); } @@ -908,16 +875,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 +892,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 +911,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); } //****************************************************************************** @@ -1044,6 +1006,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 +1024,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..22758c9e589 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 @@ -63,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))); - std::shared_ptr - GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const objectType_str, std::string const &objectName) - { - // 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 - GroundTempObjType objectType = static_cast(getEnumValue(groundTempModelNamesUC, Util::makeUPPER(objectType_str))); - - assert(objectType != GroundTempObjType::Invalid); - - int numGTMs = 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) - // Check if the type and name match - if (objectType == currentModel->objectType && objectName == 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 { - 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 a905559976b..804a6df2c1e 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh @@ -48,48 +48,14 @@ #ifndef GroundTemperatureModelManager_hh_INCLUDED #define GroundTemperatureModelManager_hh_INCLUDED -// C++ Headers -#include - -// ObjexxFCL Headers -#include - // EnergyPlus Headers #include -#include -#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; - - std::shared_ptr GetGroundTempModelAndInit(EnergyPlusData &state, std::string_view const type, std::string const &name); - -} // namespace GroundTemperatureManager - -struct GroundTemperatureManagerData : BaseGlobalStruct -{ - std::vector> groundTempModels; - - void init_state([[maybe_unused]] EnergyPlusData &state) override - { - } +namespace EnergyPlus::GroundTemperatureManager { - void clear_state() override - { - new (this) GroundTemperatureManagerData(); - } -}; +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 950331d122b..dc16e3edc16 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc @@ -45,16 +45,11 @@ // 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 -#include #include +#include #include #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,36 @@ std::shared_ptr KusudaGroundTempsModel::KusudaGTMFactory int IOStat; // New shared pointer for this model object - std::shared_ptr thisModel(new KusudaGroundTempsModel()); + auto *thisModel = new KusudaGroundTempsModel(); - GroundTempObjType objType = GroundTempObjType::KusudaGroundTemp; + // 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) - std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast(objType)]; - int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + auto objType = GroundTempObjType::KusudaGroundTemp; + + 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) { 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 +115,20 @@ 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( - state, - static_cast( - GroundTemperatureManager::groundTempModelNamesUC[static_cast(GroundTempObjType::SiteShallowGroundTemp)]), - ""); + // 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) { - 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 +164,10 @@ 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", 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..72082808834 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc @@ -45,15 +45,11 @@ // 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 #include #include -#include #include #include #include @@ -61,11 +57,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 +71,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); + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -100,33 +93,29 @@ std::shared_ptr SiteBuildingSurfaceGroundTemps:: 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; } // 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, - 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 { - 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 +124,10 @@ 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", groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -154,7 +141,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 +158,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 +188,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..9eac477a77a 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.hh @@ -48,14 +48,9 @@ #ifndef SiteBuildingSurfaceGroundTemperatures_hh_INCLUDED #define SiteBuildingSurfaceGroundTemperatures_hh_INCLUDED -// C++ Headers -#include - -// ObjexxFCL Headers -#include +#include // EnergyPlus Headers -#include #include #include @@ -65,24 +60,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..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 @@ -64,7 +63,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 +76,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); + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -98,26 +97,23 @@ std::shared_ptr SiteDeepGroundTemps::DeepGTMFactory(EnergyP 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; } // 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, - 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 { - 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 +122,10 @@ 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", groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -145,7 +139,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 +154,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 +184,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..059ae85c301 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.hh @@ -49,13 +49,9 @@ #define SiteDeepGroundTemperatures_hh_INCLUDED // C++ Headers -#include - -// ObjexxFCL Headers -#include +#include // EnergyPlus Headers -#include #include #include @@ -65,24 +61,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..d3a053d5f48 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc @@ -46,14 +46,12 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers -#include // EnergyPlus Headers #include #include #include #include -#include #include #include #include @@ -64,7 +62,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 +73,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); + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -99,53 +96,47 @@ std::shared_ptr SiteFCFactorMethodGroundTemps::FC 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)])); - errorsFound = true; + 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 + 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; + ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", groundTempModelNames[static_cast(objType)])); + // 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", groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -159,7 +150,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 +165,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 +195,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..ff9b476598e 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh @@ -49,13 +49,9 @@ #define SiteFCFactorMethodTemperatures_hh_INCLUDED // C++ Headers -#include - -// ObjexxFCL Headers -#include +#include // EnergyPlus Headers -#include #include #include @@ -65,24 +61,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..b6ccf86d4c0 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc @@ -46,14 +46,12 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers -#include // EnergyPlus Headers #include #include #include #include -#include #include #include #include @@ -64,7 +62,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 +75,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); + std::string_view const cCurrentModuleObject = groundTempModelNamesUC[static_cast(objType)]; + const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->objectType = objType; thisModel->objectName = objectName; @@ -98,25 +96,22 @@ std::shared_ptr SiteShallowGroundTemps::ShallowGTMFactor 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; } // 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, - 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 { - 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 +120,10 @@ 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", groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -144,7 +137,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 +161,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 +183,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..30909d9aa83 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.hh @@ -49,14 +49,9 @@ #define SiteShallowGroundTemperatures_hh_INCLUDED // C++ Headers -#include - -// ObjexxFCL Headers -#include -#include +#include // EnergyPlus Headers -#include #include #include @@ -66,24 +61,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..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 @@ -64,7 +62,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 +78,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); + 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) { @@ -97,7 +95,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 +112,10 @@ 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", groundTempModelNames[static_cast(objType)])); + return nullptr; } //****************************************************************************** @@ -134,32 +130,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 +165,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 +184,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..38d5a9197aa 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.hh @@ -48,11 +48,7 @@ #ifndef XingGroundTemperatureManager_hh_INCLUDED #define XingGroundTemperatureManager_hh_INCLUDED -// C++ Headers -#include - // EnergyPlus Headers -#include #include #include @@ -61,11 +57,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 +68,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/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 455ab0c4c3c..c797e026cc6 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: @@ -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; @@ -747,7 +745,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 @@ -915,7 +913,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 @@ -1079,7 +1077,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 @@ -1250,7 +1248,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 @@ -1966,7 +1964,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; @@ -2423,7 +2421,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; @@ -2448,7 +2445,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); @@ -2736,8 +2733,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; @@ -3947,7 +3942,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: @@ -3959,13 +3954,13 @@ 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; } // 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 +3973,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 +4145,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) ) @@ -4167,7 +4162,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,':') @@ -4305,11 +4300,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; @@ -4363,10 +4358,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 const &op = state.dataOutputProcessor; auto found = op->ddOutVarMap.find(nameUC); if (found == op->ddOutVarMap.end()) return; @@ -4609,11 +4604,9 @@ void ProduceRDDMDD(EnergyPlusData &state) while (ddVar->Next != -1) { 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 = - (ddVar->units == Constant::Units::customEMS) ? ddVar->unitNameCustomEMS : Constant::unitNames[(int)ddVar->units]; + timeStepName = timeStepTypeNames[(int)ddVar->timeStepType]; + storeTypeName = storeTypeNames[(int)ddVar->storeType]; + varName = ddVar->name; if (op->ProduceReportVDD == ReportVDD::Yes) { print(state.files.rdd, "{},{},{} [{}]\n", timeStepName, storeTypeName, varName, unitName); @@ -4647,7 +4640,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, @@ -4669,7 +4662,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); diff --git a/src/EnergyPlus/OutputProcessor.hh b/src/EnergyPlus/OutputProcessor.hh index ccadcc8073f..3a76a6dca95 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); @@ -824,11 +824,11 @@ 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) +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, 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/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index 948aaca07e0..0767378e1d5 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); @@ -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 @@ -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) { @@ -17744,13 +17744,13 @@ 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 // 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) { @@ -17776,12 +17776,12 @@ 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 // 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; @@ -17809,22 +17809,22 @@ void ResetBEPSGathering(EnergyPlusData &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 // 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; } -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 // 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; diff --git a/src/EnergyPlus/OutputReportTabular.hh b/src/EnergyPlus/OutputReportTabular.hh index e0b30a2a535..867ad26762a 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); @@ -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, @@ -891,13 +891,13 @@ 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); + void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state); - void ResetPeakDemandGathering(EnergyPlusData &state); + void ResetPeakDemandGathering(EnergyPlusData const &state); void ResetHeatGainGathering(EnergyPlusData &state); 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; } 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); 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..7023ee5567a 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc @@ -95,12 +95,12 @@ 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; } - } else if (updatedTempTDT > TempHighPCM) { + } else { phaseChangeState = Phase::Liquid; } } else { // phaseChangeDeltaT > 0 @@ -109,12 +109,12 @@ 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; } - } else if (updatedTempTDT > TempHighPCF) { + } else { phaseChangeState = Phase::Liquid; } } @@ -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; } } diff --git a/src/EnergyPlus/PhotovoltaicThermalCollectors.cc b/src/EnergyPlus/PhotovoltaicThermalCollectors.cc index 1dcca089a10..2e26de32512 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; } } @@ -772,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; @@ -867,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 { @@ -1450,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)) / @@ -1643,17 +1636,17 @@ 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 i, j, ii, p, k, m(3); - bool coeff_not_zero; + int p; + int constexpr m = 3; + Real64 constexpr small = 1.0e-10; - 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; @@ -1663,20 +1656,20 @@ namespace PhotovoltaicThermalCollectors { if (coeff_not_zero) { if (p != i) { - dummy2 = f[i]; + Real64 dummy2 = f[i]; f[i] = f[p]; f[p] = dummy2; - for (j = 0; j <= (m - 1); j++) { - dummy1 = jj[i * m + j]; + for (int j = 0; j <= (m - 1); j++) { + Real64 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]; + Real64 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]; } } @@ -1684,10 +1677,10 @@ 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++) { + 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++) { sum = sum + jj[ii * m + j] * y[j]; } if (std::abs(jj[ii * m + ii]) < small) jj[ii * m + ii] = small; @@ -1745,25 +1738,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; @@ -1782,7 +1769,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; diff --git a/src/EnergyPlus/Photovoltaics.cc b/src/EnergyPlus/Photovoltaics.cc index 9e7f958d900..1d6ef197143 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,8 +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 @@ -1281,14 +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; - CC = 1; EtaOld = EtaIni; + int K; // Begin DO WHILE loop - until the error tolerance is reached. ETA = 0.0; @@ -1332,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: @@ -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 @@ -1422,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: { @@ -1473,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] ) { @@ -1540,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..7bc631f5bea 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] ); @@ -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); 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; 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/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, 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/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; 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..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,46 +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 - 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; 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) { - errFlag = false; + 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 @@ -1498,6 +1489,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); @@ -1539,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; @@ -1638,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: { @@ -2065,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; @@ -2223,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(); @@ -2348,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, @@ -2377,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); 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) { 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()) { 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, 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) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 4d4057c42af..5eea48174f5 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; } } @@ -1701,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) { @@ -1783,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) { @@ -1841,26 +1836,23 @@ 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; - SetZoneAux = true; + int contWallBeg = contWall + 1; + int contFloorBeg = contFloor + 1; + int contCeilingBeg = contCeiling + 1; + int contWindowBeg = contWindow + 1; + int contInternalBeg = contInternal + 1; + int contDoorBeg = contDoor + 1; Real64 Z1ofZone = std::numeric_limits::max(); Real64 Z2ofZone = std::numeric_limits::lowest(); // 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 +1892,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; @@ -1948,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); } @@ -2456,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 diff --git a/src/EnergyPlus/RoomAirModelUserTempPattern.cc b/src/EnergyPlus/RoomAirModelUserTempPattern.cc index 7217e1e9778..f6f7a6d42a7 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)]; diff --git a/src/EnergyPlus/RuntimeLanguageProcessor.cc b/src/EnergyPlus/RuntimeLanguageProcessor.cc index 361d19b5b4f..923bfd3c204 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); @@ -213,7 +213,7 @@ void InitializeRuntimeLanguage(EnergyPlusData &state) state.dataRuntimeLang->ErlVariable(state.dataRuntimeLangProcessor->CurrentTimeVariableNum).Value = SetErlValueNumber(tmpCurrentTime); tmpMinutes = ((tmpCurrentTime - double(state.dataGlobal->HourOfDay - 1)) * 60.0); // -1.0 // off by 1 state.dataRuntimeLang->ErlVariable(state.dataRuntimeLangProcessor->MinuteVariableNum).Value = SetErlValueNumber(tmpMinutes); - // Subtract 7 from HolidayIndex to maintain compatibility for EMS where 1=Holiday,2=SummerDesignDay, 3=WinterDesignDay, 4=CustomDay1, + // Subtract 7 from HolidayIndex to maintain compatability for EMS where 1=Holiday,2=SummerDesignDay, 3=WinterDesignDay, 4=CustomDay1, // 5=CustomDay2, but not <0 if (state.dataEnvrn->HolidayIndex == 0) { state.dataRuntimeLang->ErlVariable(state.dataRuntimeLangProcessor->HolidayVariableNum).Value = SetErlValueNumber(0.0); @@ -248,7 +248,7 @@ void BeginEnvrnInitializeRuntimeLanguage(EnergyPlusData &state) // SUBROUTINE INFORMATION: // AUTHOR B. Griffith // DATE WRITTEN March 2010 - // MODIFIED B. Griffith, added Sensor initialization + // MODIFIED B. Griffith, added Sensor initialation // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: @@ -344,7 +344,7 @@ void BeginEnvrnInitializeRuntimeLanguage(EnergyPlusData &state) state.dataRuntimeLang->TrendVariable(TrendVarNum).TrendValARR({1, TrendDepth}) = 0.0; } - // reinitialize sensors + // reinitilize sensors for (SensorNum = 1; SensorNum <= state.dataRuntimeLang->NumSensors; ++SensorNum) { SetInternalVariableValue( state, state.dataRuntimeLang->Sensor(SensorNum).VariableType, state.dataRuntimeLang->Sensor(SensorNum).Index, 0.0, 0); @@ -599,7 +599,7 @@ void ParseStack(EnergyPlusData &state, int const StackNum) } if (!ReadyForEndif(NestedIfDepth)) { - AddError(state, StackNum, LineNum, "ENDIF statement without corresponding IF statement."); + AddError(state, StackNum, LineNum, "ENDIF statement without corresponding IF stetement."); } ReadyForEndif(NestedIfDepth) = false; ReadyForElse(NestedIfDepth) = false; @@ -944,7 +944,7 @@ void WriteTrace(EnergyPlusData &state, int const StackNum, int const Instruction // AUTHOR Peter Graham Ellis // DATE WRITTEN June 2006 // MODIFIED Brent Griffith, May 2009 - // Brent Griffith, May 2016, added bool and fatal error messages for runtime problems with math and uninitiated vars + // Brent Griffith, May 2016, added bool and fatal error messages for runtime problems with math and unitialized vars // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: @@ -1244,7 +1244,7 @@ void ParseExpression(EnergyPlusData &state, ++NumErrors; DivFound = false; } else if (OperatorProcessing && (NextChar == '-')) { - // if operator was determined last pass and this character is a -, then insert a 0 before the minus and treat as subtraction + // 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; String.insert(Pos, "0"); @@ -1285,7 +1285,7 @@ void ParseExpression(EnergyPlusData &state, std::string const cc(String.substr(Pos, 2)); if (parse("==", ErlFunc::Equal, false) || parse("<>", ErlFunc::NotEqual, false) || parse("<=", ErlFunc::LessOrEqual, false) || parse(">=", ErlFunc::GreaterOrEqual, false) || parse("||", ErlFunc::LogicalOR, false) || parse("&&", ErlFunc::LogicalAND, false)) { - // One of the comparison / logical operators + // One of the comparision / logical operators OperatorProcessing = true; } else if (String[Pos] == '@') { // next check for builtin functions signaled by "@" @@ -1613,7 +1613,7 @@ int ProcessTokens( state.dataRuntimeLang->ErlExpression(ExpressionNum).NumOperands = NumOperands; state.dataRuntimeLang->ErlExpression(ExpressionNum).Operand.allocate(NumOperands); - // PE comment: Need a right-hand and left-hand check for these, not just number of operators + // PE commment: Need a right-hand and left-hand check for these, not just number of operators // Unification of TYPEs would turn these into one-liners state.dataRuntimeLang->ErlExpression(ExpressionNum).Operand(1).Type = static_cast(static_cast(Token(Pos - 1).Type)); @@ -3749,7 +3749,7 @@ ErlValueType StringValue(std::string const &String) { // FUNCTION INFORMATION: // AUTHOR P. Ellis - // DATE WRITTEN unknown + // DATE WRITTEN unkown // MODIFIED na // RE-ENGINEERED na @@ -3936,7 +3936,7 @@ int NewEMSVariable(EnergyPlusData &state, std::string const &VariableName, int c void ExternalInterfaceSetErlVariable(EnergyPlusData &state, int const varNum, // The variable index to be written during run time - Real64 const value // The real time value of the variable to be set + Real64 const value // The real time value of the vairable to be set ) { 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); diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 3a3d17350ab..b3eee89fcce 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. @@ -199,8 +198,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 @@ -225,12 +222,9 @@ namespace ScheduleManager { int NumFields; int SCount; // LOGICAL RptSchedule - int RptLevel; int CurMinute; int MinutesPerItem; int NumExpectedItems; - int MaxNums; - int MaxAlps; int AddWeekSch; int AddDaySch; Array1D_bool AllDays(maxDayTypes); @@ -252,14 +246,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 +268,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 +523,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 +1839,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) @@ -2330,7 +2314,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); @@ -2679,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. @@ -2689,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; @@ -2730,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 @@ -2739,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); @@ -2854,8 +2790,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". @@ -2863,10 +2797,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; @@ -2877,11 +2807,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)) @@ -2904,45 +2834,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 { @@ -2959,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". @@ -2994,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. @@ -3052,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; @@ -3095,14 +2968,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' @@ -3112,32 +2983,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; } } @@ -3159,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; @@ -3198,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; @@ -3378,43 +3197,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)={}", @@ -3426,7 +3215,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) { @@ -3449,7 +3238,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) { @@ -3470,6 +3259,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) { @@ -3503,45 +3294,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: - int DayT; - 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; @@ -3685,7 +3449,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; @@ -3724,19 +3488,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; } @@ -3755,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 @@ -3786,7 +3548,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. @@ -3846,7 +3607,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); } @@ -3950,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 @@ -3961,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 @@ -4023,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 @@ -4034,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 @@ -4097,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 @@ -4109,32 +3828,12 @@ 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 - bool MinValueOk; - bool MaxValueOk; if (ScheduleIndex == ScheduleManager::ScheduleAlwaysOn) { MinValue = 1.0; @@ -4152,8 +3851,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 +3880,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 +3890,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 +3907,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 @@ -4249,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; @@ -4340,43 +3988,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; @@ -4390,10 +4008,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)); @@ -4402,10 +4020,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( @@ -4424,12 +4042,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 @@ -4437,43 +4053,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; @@ -4487,10 +4073,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)); @@ -4499,10 +4085,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( @@ -4522,12 +4108,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) @@ -4578,7 +4162,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 precalculated min and max from SetScheduleMinMax MinValue = min(MinValue, daySch.TSValMin); MaxValue = max(MaxValue, daySch.TSValMax); @@ -4615,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; @@ -4671,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" @@ -4707,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. @@ -4844,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; @@ -4916,45 +4466,7 @@ namespace ScheduleManager { int GetNumberOfSchedules(EnergyPlusData &state) { - // 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 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, diff --git a/src/EnergyPlus/SetPointManager.cc b/src/EnergyPlus/SetPointManager.cc index b0e93ac5492..f594a07824f 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); diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index 5a8ccc20e53..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; @@ -172,7 +171,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 +284,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 +1346,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 || @@ -2779,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: @@ -2793,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; @@ -2814,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; @@ -3225,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: @@ -3337,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. @@ -3354,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); @@ -3371,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, diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 916a84cb646..b6c54c469bd 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 7fd0146c9f5..88a5b4a52aa 100644 --- a/src/EnergyPlus/SimulationManager.hh +++ b/src/EnergyPlus/SimulationManager.hh @@ -115,9 +115,9 @@ 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 &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 ); } // namespace EnergyPlus diff --git a/src/EnergyPlus/SingleDuct.cc b/src/EnergyPlus/SingleDuct.cc index 69f03474ac6..14cbe633149 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,10 +2447,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 Real64 SteamTemp; Real64 SteamDensity; Real64 rho; @@ -2469,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)) { @@ -2507,7 +2480,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", @@ -2801,63 +2774,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; @@ -2976,7 +2924,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); } @@ -3541,8 +3489,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 +3607,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); @@ -3761,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. @@ -3769,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 @@ -3781,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 @@ -3801,7 +3730,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 +3973,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; } @@ -4245,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. @@ -4254,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) @@ -4307,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; @@ -4329,32 +4235,20 @@ 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] - 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 +4394,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; } @@ -4669,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 @@ -4713,7 +4605,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] @@ -4724,7 +4615,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; @@ -4748,7 +4638,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; @@ -4759,14 +4648,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; @@ -4776,7 +4663,6 @@ void SingleDuctAirTerminal::SimVAVVS(EnergyPlusData &state, bool const FirstHVAC } } else { SteamControlNode = 0; - HCLoad = BigLoad; MaxFlowSteam = 0.0; MinFlowSteam = 0.0; } @@ -4785,6 +4671,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 @@ -5080,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 @@ -5099,33 +4979,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); @@ -5151,11 +5015,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 @@ -5175,7 +5041,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; } @@ -5289,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. @@ -5298,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) @@ -5390,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 || @@ -5441,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); } @@ -5492,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 @@ -5534,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; } @@ -5569,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 @@ -6026,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; @@ -6108,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; @@ -6179,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 @@ -6228,48 +5998,12 @@ 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 - // MODIFIED na - // RE-ENGINEERED na - - // 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. - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int PriAirNode; // air terminal mixer primary air inlet node number - - if (ATMixerNum <= 0) return; - PriAirNode = state.dataSingleDuct->SysATMixer(ATMixerNum).PriInNode; - 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 int const curZoneEqNum // current zone equipment being simulated ) { - 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 if (controlledZoneNum == 0) return; @@ -6279,28 +6013,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; } } @@ -6316,131 +6051,126 @@ void setATMixerSizingProperties(EnergyPlusData &state, CheckThisAirSystemForSizing(state, airLoopIndex, SizingDesRunThisAirSys); // check for Sizing:System object 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(airLoopIndex).HeatSupTemp; - ZoneEqSizing(curZoneEqNum).ATMixerHeatPriHumRat = FinalSysSizing(airLoopIndex).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(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.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 - 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); - 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(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.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(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); - 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(airLoopIndex).CoolSupTemp; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = FinalSysSizing(airLoopIndex).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(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.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 - 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); - 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(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.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(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); - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriDryBulb = CoilInTempForSizing; - ZoneEqSizing(curZoneEqNum).ATMixerCoolPriHumRat = CoilInHumRatForSizing; + zoneEqSizing.ATMixerCoolPriDryBulb = CoilInTempForSizing; + zoneEqSizing.ATMixerCoolPriHumRat = CoilInHumRatForSizing; } } diff --git a/src/EnergyPlus/SingleDuct.hh b/src/EnergyPlus/SingleDuct.hh index 049d30498da..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 @@ -368,7 +363,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 diff --git a/src/EnergyPlus/SizingAnalysisObjects.cc b/src/EnergyPlus/SizingAnalysisObjects.cc index 1ab21946264..df10be7299b 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,19 +272,13 @@ 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() { ZoneTimestepObject tmpNullztStepObj; - - for (auto &zt : ztStepObj) { - zt = tmpNullztStepObj; - } + std::fill(ztStepObj.begin(), ztStepObj.end(), tmpNullztStepObj); } void SizingLog::SetupNewEnvironment(int const seedEnvrnNum, int const newEnvrnNum) @@ -298,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; @@ -340,7 +329,7 @@ int SizingLoggerFramework::SetupVariableSizingLog(EnergyPlusData &state, Real64 tmpLog.timeStepsInAverage = stepsInAverage; - VectorLength = stepSum; + int VectorLength = stepSum; tmpLog.NumOfStepsInLogSet = VectorLength; tmpLog.ztStepObj.resize(VectorLength); @@ -364,7 +353,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 +375,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 +384,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) { diff --git a/src/EnergyPlus/SizingManager.cc b/src/EnergyPlus/SizingManager.cc index a6e7b85e5a5..49917601e50 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; @@ -127,9 +124,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 using SimAirServingZones::ManageAirLoops; using SimAirServingZones::UpdateSysSizing; @@ -155,15 +149,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; @@ -225,9 +215,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; @@ -258,7 +245,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. @@ -623,23 +610,23 @@ void ManageSizing(EnergyPlusData &state) } if (state.dataSize->SysSizingRunDone) { - for (AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) { - curName = FinalSysSizing(AirLoopNum).AirPriLoopName; - PreDefTableEntry(state, state.dataOutRptPredefined->pdchSysSizCalcClAir, curName, CalcSysSizing(AirLoopNum).DesCoolVolFlow); - if (std::abs(CalcSysSizing(AirLoopNum).DesCoolVolFlow) <= 1.e-8) { - ShowWarningError(state, - format("{}Calculated Cooling Design Air Flow Rate for System={} is zero.", - RoutineName, - FinalSysSizing(AirLoopNum).AirPriLoopName)); + 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.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)); 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) { - ShowWarningError(state, - format("{}Calculated Heating Design Air Flow Rate for System={} is zero.", - RoutineName, - FinalSysSizing(AirLoopNum).AirPriLoopName)); + 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)); ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs."); } std::string_view coolPeakLoadKind; @@ -647,22 +634,22 @@ 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(AirLoopNum).cSensCoolPeakDDDate; - coolPeakDD = SysSizPeakDDNum(AirLoopNum).SensCoolPeakDD; - coolCap = FinalSysSizing(AirLoopNum).SensCoolCap; - if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = SysSizPeakDDNum(AirLoopNum).TimeStepAtSensCoolPk(coolPeakDD); - } else if (FinalSysSizing(AirLoopNum).coolingPeakLoad == DataSizing::PeakLoad::TotalCooling) { - if (FinalSysSizing(AirLoopNum).loadSizingType == DataSizing::LoadSizing::Latent && state.dataHeatBal->DoLatentSizing) { + coolPeakDDDate = sysSizPeakDDNum.cSensCoolPeakDDDate; + coolPeakDD = sysSizPeakDDNum.SensCoolPeakDD; + coolCap = finalSysSizing.SensCoolCap; + if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolPeakDD); + } 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(AirLoopNum).cTotCoolPeakDDDate; - coolPeakDD = SysSizPeakDDNum(AirLoopNum).TotCoolPeakDD; - coolCap = FinalSysSizing(AirLoopNum).TotCoolCap; - if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = SysSizPeakDDNum(AirLoopNum).TimeStepAtTotCoolPk(coolPeakDD); + coolPeakDDDate = sysSizPeakDDNum.cTotCoolPeakDDDate; + coolPeakDD = sysSizPeakDDNum.TotCoolPeakDD; + coolCap = finalSysSizing.TotCoolCap; + if (coolPeakDD > 0) timeStepIndexAtPeakCoolLoad = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolPeakDD); } if (coolPeakDD > 0) { ReportSysSizing(state, @@ -670,9 +657,9 @@ void ManageSizing(EnergyPlusData &state) "Cooling", coolPeakLoadKind, coolCap, - CalcSysSizing(AirLoopNum).DesCoolVolFlow, - FinalSysSizing(AirLoopNum).DesCoolVolFlow, - FinalSysSizing(AirLoopNum).CoolDesDay, + calcSysSizing.DesCoolVolFlow, + finalSysSizing.DesCoolVolFlow, + finalSysSizing.CoolDesDay, coolPeakDDDate, timeStepIndexAtPeakCoolLoad); } else { @@ -681,37 +668,37 @@ void ManageSizing(EnergyPlusData &state) "Cooling", coolPeakLoadKind, coolCap, - CalcSysSizing(AirLoopNum).DesCoolVolFlow, - FinalSysSizing(AirLoopNum).DesCoolVolFlow, - FinalSysSizing(AirLoopNum).CoolDesDay, + calcSysSizing.DesCoolVolFlow, + finalSysSizing.DesCoolVolFlow, + finalSysSizing.CoolDesDay, coolPeakDDDate, 0); } - int heatPeakDD = SysSizPeakDDNum(AirLoopNum).HeatPeakDD; + int heatPeakDD = sysSizPeakDDNum.HeatPeakDD; if (heatPeakDD > 0) { ReportSysSizing(state, curName, "Heating", "Sensible", - FinalSysSizing(AirLoopNum).HeatCap, - CalcSysSizing(AirLoopNum).DesHeatVolFlow, - FinalSysSizing(AirLoopNum).DesHeatVolFlow, - FinalSysSizing(AirLoopNum).HeatDesDay, - SysSizPeakDDNum(AirLoopNum).cHeatPeakDDDate, - SysSizPeakDDNum(AirLoopNum).TimeStepAtHeatPk(heatPeakDD)); + finalSysSizing.HeatCap, + calcSysSizing.DesHeatVolFlow, + finalSysSizing.DesHeatVolFlow, + finalSysSizing.HeatDesDay, + sysSizPeakDDNum.cHeatPeakDDDate, + sysSizPeakDDNum.TimeStepAtHeatPk(heatPeakDD)); } else { ReportSysSizing(state, curName, "Heating", "Sensible", - FinalSysSizing(AirLoopNum).HeatCap, - CalcSysSizing(AirLoopNum).DesHeatVolFlow, - FinalSysSizing(AirLoopNum).DesHeatVolFlow, - FinalSysSizing(AirLoopNum).HeatDesDay, - SysSizPeakDDNum(AirLoopNum).cHeatPeakDDDate, + finalSysSizing.HeatCap, + calcSysSizing.DesHeatVolFlow, + 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(); @@ -744,7 +731,7 @@ void ManageSizing(EnergyPlusData &state) } } -bool CalcdoLoadComponentPulseNow(EnergyPlusData &state, +bool CalcdoLoadComponentPulseNow(EnergyPlusData const &state, bool const isPulseZoneSizing, bool const WarmupFlag, int const HourOfDay, @@ -778,8 +765,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; if ((state.dataSize->NumSysSizInput > 0) && (state.dataGlobal->DoSystemSizing)) { // only if there is system sizing @@ -792,6 +777,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); @@ -800,8 +786,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 const &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) = @@ -871,7 +858,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 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) = state.dataDualDuct->dd_airterminal(dualDuctATUNum).MaxAirVolFlowRate; // store std 62.1 value @@ -936,8 +924,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 const &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 == @@ -1027,8 +1016,9 @@ void ManageSystemSizingAdjustments(EnergyPlusData &state) // dual path for std 62.1 if (allocated(IndUnit) && (NumIndUnits > 0)) { for (int indUnitNum = 1; indUnitNum <= NumIndUnits; ++indUnitNum) { + auto const &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; @@ -1048,8 +1038,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 const &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; @@ -1069,23 +1060,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(); } } } @@ -1094,8 +1086,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 const &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; @@ -1113,7 +1106,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( @@ -1121,77 +1114,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( @@ -2017,26 +2007,24 @@ 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 // 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 && state.dataSize->SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { auto &pzSumBySys = state.dataSize->PzSumBySys(AirLoopNum); pzSumBySys = 0.0; state.dataSize->PsBySys(AirLoopNum) = 0.0; @@ -2079,10 +2067,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 && state.dataSize->SysSizInput(SysSizNum).OccupantDiversity == AutoSize) { // Loop over all zones connected to air loop Real64 TotConcurrentPeopleOnSys = 0.0; @@ -2127,12 +2116,12 @@ 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 - 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 { @@ -2141,7 +2130,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. @@ -2151,7 +2140,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)); } } } @@ -2178,11 +2167,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 @@ -2207,6 +2194,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 @@ -2314,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 @@ -2326,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) { @@ -2450,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 @@ -2473,9 +2445,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 @@ -2497,10 +2466,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, @@ -2591,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 @@ -2601,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, @@ -2664,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"; @@ -2712,37 +2678,23 @@ 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 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 { @@ -2793,7 +2745,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; @@ -2825,16 +2777,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, @@ -3010,7 +2962,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 { @@ -3153,7 +3106,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; @@ -3178,7 +3131,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; @@ -3202,7 +3155,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; @@ -3236,8 +3189,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; @@ -3388,32 +3341,24 @@ 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; - 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); ZoneNames.allocate(NumZones); - for (Item = 1; Item <= NumZones; ++Item) { + for (int Item = 1; Item <= NumZones; ++Item) { state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, Item, @@ -3439,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, @@ -3461,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; } @@ -3474,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 @@ -3484,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 @@ -3532,7 +3473,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; @@ -3542,9 +3482,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; @@ -4059,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 @@ -4069,23 +4007,20 @@ 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 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; @@ -4182,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 @@ -4562,7 +4495,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.); @@ -4575,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 @@ -4587,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 @@ -4651,8 +4580,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 @@ -4676,10 +4603,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 = ""; @@ -5235,7 +5163,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"; @@ -5243,6 +5170,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 diff --git a/src/EnergyPlus/SizingManager.hh b/src/EnergyPlus/SizingManager.hh index edcd461b46d..3a16f84b4bc 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); @@ -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); 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) 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/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 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/GroundHeatExchangers.unit.cc b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc index cbb8b7c7eb3..8d9e0cc6ba5 100644 --- a/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc +++ b/tst/EnergyPlus/unit/GroundHeatExchangers.unit.cc @@ -87,13 +87,12 @@ 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->GFNC = std::vector(NPairs); - thisGLHE.myRespFactors->LNTTS(1) = 0.0; - thisGLHE.myRespFactors->LNTTS(2) = 5.0; - thisGLHE.myRespFactors->GFNC(1) = 0.0; - thisGLHE.myRespFactors->GFNC(2) = 5.0; + thisGLHE.myRespFactors->LNTTS.push_back(0.0); + thisGLHE.myRespFactors->LNTTS.push_back(5.0); + thisGLHE.myRespFactors->GFNC[0] = 0.0; + thisGLHE.myRespFactors->GFNC[1] = 5.0; // Case when extrapolating beyond lower bound thisLNTTS = -1.0; @@ -124,13 +123,12 @@ 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->GFNC = std::vector(NPairs); - thisGLHE.myRespFactors->LNTTS(1) = 0.0; - thisGLHE.myRespFactors->LNTTS(2) = 5.0; - thisGLHE.myRespFactors->GFNC(1) = 0.0; - thisGLHE.myRespFactors->GFNC(2) = 5.0; + thisGLHE.myRespFactors->LNTTS.push_back(0.0); + thisGLHE.myRespFactors->LNTTS.push_back(5.0); + thisGLHE.myRespFactors->GFNC[0] = 0.0; + thisGLHE.myRespFactors->GFNC[1] = 5.0; time = std::pow(10.0, 2.5); @@ -152,13 +150,12 @@ 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->GFNC = std::vector(NPairs); - thisGLHE.myRespFactors->LNTTS(1) = 0.0; - thisGLHE.myRespFactors->LNTTS(2) = 5.0; - thisGLHE.myRespFactors->GFNC(1) = 0.0; - thisGLHE.myRespFactors->GFNC(2) = 5.0; + thisGLHE.myRespFactors->LNTTS.push_back(0.0); + thisGLHE.myRespFactors->LNTTS.push_back(5.0); + thisGLHE.myRespFactors->GFNC[0] = 0.0; + thisGLHE.myRespFactors->GFNC[1] = 5.0; time = std::pow(2.7182818284590452353602874, 2.5); @@ -236,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) @@ -528,10 +525,10 @@ 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(-2.672011, thisRF->GFNC(1)); - EXPECT_EQ(3.003000, thisRF->LNTTS(76)); - EXPECT_EQ(12.778359, thisRF->GFNC(76)); + EXPECT_EQ(-15.585075, thisRF->LNTTS[0]); + EXPECT_EQ(-2.672011, thisRF->GFNC[0]); + EXPECT_EQ(3.003000, thisRF->LNTTS[75]); + EXPECT_EQ(12.778359, thisRF->GFNC[75]); } TEST_F(EnergyPlusFixture, GroundHeatExchangerTest_System_Resp_Factors_Mismatched_Pairs) @@ -942,6 +939,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", @@ -964,7 +967,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]); @@ -979,6 +982,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); } @@ -1340,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->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}; GroundHeatExchangers::GLHEVert thisGHE = GroundHeatExchangers::GLHEVert(); @@ -1395,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->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}; GroundHeatExchangers::GLHEVert thisGHE = GroundHeatExchangers::GLHEVert(); 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); }