diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index aaf68614a46..53b5ace1295 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -107,7 +107,7 @@ namespace Psychrometrics { #endif #ifdef EP_psych_stats - Array1D_string const PsyRoutineNames(NumPsychMonitors, +Array1D_string const PsyRoutineNames(NumPsychMonitors, {"PsyTdpFnTdbTwbPb", "PsyRhFnTdbWPb", "PsyTwbFnTdbWPb", @@ -157,16 +157,11 @@ namespace Psychrometrics { // PsyWFnTdbTwbPb 16 - HR | PsyTsatFnPb 17 - max iter | PsyTwbFnTdbWPb_cache 18 - // PsyTwbFnTdbWPb_raw (raw calc) | PsyPsatFnTemp_cache 19 - PsyPsatFnTemp_raw (raw calc) #endif - + // MODULE VARIABLE DECLARATIONS: // na // MODULE VARIABLE DEFINITIONS: - Array1D_int iPsyErrIndex(NumPsychMonitors, 0); // Number of times error occurred -#ifdef EP_psych_stats - Array1D NumTimesCalled(NumPsychMonitors, 0); - Array1D_int NumIterations(NumPsychMonitors, 0); -#endif // Subroutine Specifications for the Module @@ -174,11 +169,7 @@ namespace Psychrometrics { void clear_state() { - iPsyErrIndex = Array1D_int(NumPsychMonitors, 0); -#ifdef EP_psych_stats - NumTimesCalled = Array1D(NumPsychMonitors, 0); - NumIterations = Array1D_int(NumPsychMonitors, 0); -#endif + #ifdef EP_cache_PsyTwbFnTdbWPb cached_Twb.deallocate(); #endif @@ -286,13 +277,13 @@ namespace Psychrometrics { Real64 AverageIterations; if (!auditFile.good()) return; - if (any_gt(NumTimesCalled, 0)) { + if (any_gt(state.dataPsychrometrics->NumTimesCalled, 0)) { print(auditFile, "RoutineName,#times Called,Avg Iterations\n"); for (Loop = 1; Loop <= NumPsychMonitors; ++Loop) { if (!PsyReportIt(Loop)) continue; - const auto istring = fmt::to_string(NumTimesCalled(Loop)); - if (NumIterations(Loop) > 0) { - AverageIterations = double(NumIterations(Loop)) / double(NumTimesCalled(Loop)); + const auto istring = fmt::to_string(state.dataPsychrometrics->NumTimesCalled(Loop)); + if (state.dataPsychrometrics->NumIterations(Loop) > 0) { + AverageIterations = double(state.dataPsychrometrics->NumIterations(Loop)) / double(state.dataPsychrometrics->NumTimesCalled(Loop)); print(auditFile, "{},{},{:.2R}\n", PsyRoutineNames(Loop), istring, AverageIterations); } else { print(auditFile, "{},{}\n", PsyRoutineNames(Loop), istring); @@ -336,7 +327,7 @@ namespace Psychrometrics { { if (RHValue > 1.01) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Rhovapor= {:.3T} Calculated Relative Humidity [%]= {:.2T}", Tdb, Rhovapor, RHValue * 100.0); ShowWarningMessage(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhovLBnd0C) "); if (!CalledFrom.empty()) { @@ -348,7 +339,7 @@ namespace Psychrometrics { ShowContinueError(state, "Relative Humidity being reset to 100.0%"); } ShowRecurringWarningErrorAtEnd(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhovLBnd0C)", - iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C), + state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C), RHValue * 100.0, RHValue * 100.0, _, @@ -357,7 +348,7 @@ namespace Psychrometrics { } } else if (RHValue < -0.05) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Rhovapor= {:.3T} Calculated Relative Humidity [%]= {:.2T}", Tdb, Rhovapor, RHValue * 100.0); ShowWarningMessage(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhovLBnd0C) "); if (!CalledFrom.empty()) { @@ -369,7 +360,7 @@ namespace Psychrometrics { ShowContinueError(state, "Relative Humidity being reset to 1%"); } ShowRecurringWarningErrorAtEnd(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhovLBnd0C)", - iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C), + state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhovLBnd0C), RHValue * 100.0, RHValue * 100.0, _, @@ -434,7 +425,7 @@ namespace Psychrometrics { Real64 Pb_tag_r; #ifdef EP_psych_stats - ++NumTimesCalled(iPsyTwbFnTdbWPb_cache); + ++state.dataPsychrometrics->NumTimesCalled(iPsyTwbFnTdbWPb_cache); #endif Tdb_tag = bit_transfer(Tdb, Tdb_tag); @@ -536,7 +527,7 @@ namespace Psychrometrics { bool FlagError; // set when errors should be flagged #ifdef EP_psych_stats - ++NumTimesCalled(iPsyTwbFnTdbWPb); + ++state.dataPsychrometrics->NumTimesCalled(iPsyTwbFnTdbWPb); #endif // CHECK TDB IN RANGE. @@ -544,7 +535,7 @@ namespace Psychrometrics { #ifdef EP_psych_errors if (TDB <= -100.0 || TDB >= 200.0) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyTwbFnTdbWPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTwbFnTdbWPb) == 0) { ShowWarningMessage(state, "Temperature out of range [-100. to 200.] (PsyTwbFnTdbWPb)"); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -555,7 +546,7 @@ namespace Psychrometrics { FlagError = true; } ShowRecurringWarningErrorAtEnd(state, - "Temperature out of range [-100. to 200.] (PsyTwbFnTdbWPb)", iPsyErrIndex(iPsyTwbFnTdbWPb), TDB, TDB, _, "C", "C"); + "Temperature out of range [-100. to 200.] (PsyTwbFnTdbWPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTwbFnTdbWPb), TDB, TDB, _, "C", "C"); } } #endif @@ -565,7 +556,7 @@ namespace Psychrometrics { #ifdef EP_psych_errors if (W <= -0.0001) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyTwbFnTdbWPb2) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTwbFnTdbWPb2) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Humidity Ratio= {:.3T} Pressure= {:.2T}", TDB, W, Patm); ShowWarningMessage(state, "Entered Humidity Ratio invalid (PsyTwbFnTdbWPb)"); if (!CalledFrom.empty()) { @@ -578,7 +569,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String + " ... Humidity Ratio set to .00001"); } ShowRecurringWarningErrorAtEnd(state, - "Entered Humidity Ratio invalid (PsyTwbFnTdbWPb)", iPsyErrIndex(iPsyTwbFnTdbWPb2), W, W, _, "[]", "[]"); + "Entered Humidity Ratio invalid (PsyTwbFnTdbWPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTwbFnTdbWPb2), W, W, _, "[]", "[]"); } } #endif @@ -636,7 +627,7 @@ namespace Psychrometrics { } // End of Iteration Loop #ifdef EP_psych_stats - NumIterations(iPsyTwbFnTdbWPb) += iter; + state.dataPsychrometrics->NumIterations(iPsyTwbFnTdbWPb) += iter; #endif // Wet bulb temperature has not converged after maximum specified @@ -644,7 +635,7 @@ namespace Psychrometrics { #ifdef EP_psych_errors if (iter > itmax) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyTwbFnTdbWPb3) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTwbFnTdbWPb3) == 0) { ShowWarningMessage(state, format("WetBulb not converged after {} iterations(PsyTwbFnTdbWPb)", iter)); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -656,7 +647,7 @@ namespace Psychrometrics { ShowContinueError(state, format(" Input Pressure = {:.2T}", Patm)); FlagError = true; } - ShowRecurringWarningErrorAtEnd(state, "WetBulb not converged after max iterations(PsyTwbFnTdbWPb)", iPsyErrIndex(iPsyTwbFnTdbWPb3)); + ShowRecurringWarningErrorAtEnd(state, "WetBulb not converged after max iterations(PsyTwbFnTdbWPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTwbFnTdbWPb3)); } } #endif @@ -693,7 +684,7 @@ namespace Psychrometrics { { if (V <= -0.01) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyVFnTdbWPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyVFnTdbWPb) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Humidity Ratio= {:.3T} Pressure= {:.2T}", TDB, w, PB); ShowWarningMessage(state, "Calculated Specific Volume out of range (PsyVFnTdbWPb)"); if (!CalledFrom.empty()) { @@ -706,7 +697,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String + " ... Since Calculated Volume < 0.0, it is set to .83"); } ShowRecurringWarningErrorAtEnd(state, - "Calculated Specific Volume out of range (PsyVFnTdbWPb)", iPsyErrIndex(iPsyVFnTdbWPb), V, V, _, "m3/kg", "m3/kg"); + "Calculated Specific Volume out of range (PsyVFnTdbWPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyVFnTdbWPb), V, V, _, "m3/kg", "m3/kg"); } } } @@ -722,7 +713,7 @@ namespace Psychrometrics { { if (W < -0.0001) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyWFnTdbH) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbH) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Enthalpy= {:.3T}", TDB, H); ShowWarningMessage(state, "Calculated Humidity Ratio invalid (PsyWFnTdbH)"); if (!CalledFrom.empty()) { @@ -734,7 +725,7 @@ namespace Psychrometrics { state.dataPsychrometrics->String = format("Calculated Humidity Ratio= {:.4T}", W); ShowContinueError(state, state.dataPsychrometrics->String + " ... Humidity Ratio set to .00001"); } - ShowRecurringWarningErrorAtEnd(state, "Calculated Humidity Ratio invalid (PsyWFnTdbH)", iPsyErrIndex(iPsyWFnTdbH), W, W, _, "[]", "[]"); + ShowRecurringWarningErrorAtEnd(state, "Calculated Humidity Ratio invalid (PsyWFnTdbH)", state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbH), W, W, _, "[]", "[]"); } } } @@ -791,14 +782,14 @@ namespace Psychrometrics { // FUNCTION LOCAL VARIABLE DECLARATIONS: #ifdef EP_psych_stats - ++NumTimesCalled(iPsyPsatFnTemp); + ++state.dataPsychrometrics->NumTimesCalled(iPsyPsatFnTemp); #endif // CHECK T IN RANGE. #ifdef EP_psych_errors if (!state.dataGlobal->WarmupFlag) { if (T <= -100.0 || T >= 200.0) { - if (iPsyErrIndex(iPsyPsatFnTemp) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyPsatFnTemp) == 0) { ShowWarningMessage(state, "Temperature out of range [-100. to 200.] (PsyPsatFnTemp)"); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -808,7 +799,7 @@ namespace Psychrometrics { ShowContinueError(state, format(" Input Temperature={:.2T}", T)); } ShowRecurringWarningErrorAtEnd(state, - "Temperature out of range [-100. to 200.] (PsyPsatFnTemp)", iPsyErrIndex(iPsyPsatFnTemp), T, T, _, "C", "C"); + "Temperature out of range [-100. to 200.] (PsyPsatFnTemp)", state.dataPsychrometrics->iPsyErrIndex(iPsyPsatFnTemp), T, T, _, "C", "C"); } } #endif @@ -879,7 +870,7 @@ namespace Psychrometrics { { if (TWB > (TDB + 0.01)) { if (state.dataPsychrometrics->ReportErrors && !state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyWFnTdbTwbPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbTwbPb) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Pressure= {:.2T}", TDB, PB); ShowWarningMessage(state, "Given Wet Bulb Temperature invalid (PsyWFnTdbTwbPb)"); if (!CalledFrom.empty()) { @@ -892,7 +883,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String + " ... Since Dry Bulb < Wet Bulb, Wet Bulb set = to Dry Bulb"); } ShowRecurringWarningErrorAtEnd(state, - "Given Wet Bulb Temperature invalid (PsyWFnTdbTwbPb)", iPsyErrIndex(iPsyWFnTdbTwbPb), TWB, TWB, _, "C", "C"); + "Given Wet Bulb Temperature invalid (PsyWFnTdbTwbPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbTwbPb), TWB, TWB, _, "C", "C"); } } } @@ -910,7 +901,7 @@ namespace Psychrometrics { if (W < 0.0) { if (state.dataPsychrometrics->ReportErrors && !state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyWFnTdbTwbPb2) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbTwbPb2) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Wet-Bulb= {:.2T} Pressure= {:.2T}", TDB, TWB, PB); ShowWarningMessage(state, "Calculated Humidity Ratio Invalid (PsyWFnTdbTwbPb)"); if (!CalledFrom.empty()) { @@ -923,7 +914,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String + " using Relative Humidity .01% (and Dry-Bulb and Pressure as shown)"); } ShowRecurringWarningErrorAtEnd(state, - "Calculated Humidity Ratio Invalid (PsyWFnTdbTwbPb)", iPsyErrIndex(iPsyWFnTdbTwbPb2), W, W, _, "[]", "[]"); + "Calculated Humidity Ratio Invalid (PsyWFnTdbTwbPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbTwbPb2), W, W, _, "[]", "[]"); } } } @@ -941,7 +932,7 @@ namespace Psychrometrics { { if (TDP > TWB + 0.1) { if (!state.dataGlobal->WarmupFlag) { // Display error message - if (iPsyErrIndex(iPsyTdpFnTdbTwbPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTdpFnTdbTwbPb) == 0) { ShowWarningMessage(state, "Calculated Dew Point Temperature being reset (PsyTdpFnTdbTwbPb)"); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -954,7 +945,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String); } ShowRecurringWarningErrorAtEnd(state, - "Calculated Dew Point Temperature being reset (PsyTdpFnTdbTwbPb)", iPsyErrIndex(iPsyTdpFnTdbTwbPb), TDP, TDP, _, "C", "C"); + "Calculated Dew Point Temperature being reset (PsyTdpFnTdbTwbPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTdpFnTdbTwbPb), TDP, TDP, _, "C", "C"); } } } @@ -1014,7 +1005,7 @@ namespace Psychrometrics { } #ifdef EP_psych_stats - ++NumTimesCalled(iPsyTsatFnHPb); + ++state.dataPsychrometrics->NumTimesCalled(iPsyTsatFnHPb); #endif @@ -1022,7 +1013,7 @@ namespace Psychrometrics { #ifdef EP_psych_errors if (HH <= -4.24E4 || HH >= 4.5866E7) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyTsatFnHPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTsatFnHPb) == 0) { ShowWarningMessage(state, "Enthalpy out of range (PsyTsatFnHPb)"); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -1033,7 +1024,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String); FlagError = true; } - ShowRecurringWarningErrorAtEnd(state, "Enthalpy out of range (PsyTsatFnHPb)", iPsyErrIndex(iPsyTsatFnHPb), HH, HH, _, "J/kg", "J/kg"); + ShowRecurringWarningErrorAtEnd(state, "Enthalpy out of range (PsyTsatFnHPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTsatFnHPb), HH, HH, _, "J/kg", "J/kg"); } } #endif @@ -1137,7 +1128,7 @@ namespace Psychrometrics { { if (RHValue > 1.01) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyRhFnTdbRhov) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhov) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Rhovapor= {:.3T} Calculated Relative Humidity [%]= {:.2T}", Tdb, Rhovapor, RHValue * 100.0); ShowWarningMessage(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhov) "); if (!CalledFrom.empty()) { @@ -1149,7 +1140,7 @@ namespace Psychrometrics { ShowContinueError(state, "Relative Humidity being reset to 100.0 %"); } ShowRecurringWarningErrorAtEnd(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhov)", - iPsyErrIndex(iPsyRhFnTdbRhov), + state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhov), RHValue * 100.0, RHValue * 100.0, _, @@ -1158,7 +1149,7 @@ namespace Psychrometrics { } } else if (RHValue < -0.05) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyRhFnTdbRhov) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhov) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Rhovapor= {:.3T} Calculated Relative Humidity [%]= {:.2T}", Tdb, Rhovapor, RHValue * 100.0); ShowWarningMessage(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhov) "); if (!CalledFrom.empty()) { @@ -1170,7 +1161,7 @@ namespace Psychrometrics { ShowContinueError(state, "Relative Humidity being reset to 1%"); } ShowRecurringWarningErrorAtEnd(state, "Calculated Relative Humidity out of range (PsyRhFnTdbRhov)", - iPsyErrIndex(iPsyRhFnTdbRhov), + state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbRhov), RHValue * 100.0, RHValue * 100.0, _, @@ -1191,7 +1182,7 @@ namespace Psychrometrics { { if (RHValue > 1.01) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyRhFnTdbWPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbWPb) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Humidity Ratio= {:.3T} Calculated Relative Humidity [%]= {:.2T}", TDB, W, RHValue * 100.0); ShowWarningMessage(state, "Calculated Relative Humidity out of range (PsyRhFnTdbWPb) "); if (!CalledFrom.empty()) { @@ -1203,7 +1194,7 @@ namespace Psychrometrics { ShowContinueError(state, "Relative Humidity being reset to 100.0%"); } ShowRecurringWarningErrorAtEnd(state, "Calculated Relative Humidity out of range (PsyRhFnTdbWPb)", - iPsyErrIndex(iPsyRhFnTdbWPb), + state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbWPb), RHValue * 100.0, RHValue * 100.0, _, @@ -1212,7 +1203,7 @@ namespace Psychrometrics { } } else if (RHValue < -0.05) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyRhFnTdbWPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbWPb) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Humidity Ratio= {:.3T} Calculated Relative Humidity [%]= {:.2T}", TDB, W, RHValue * 100.0); ShowWarningMessage(state, "Calculated Relative Humidity out of range (PsyRhFnTdbWPb) "); if (!CalledFrom.empty()) { @@ -1224,7 +1215,7 @@ namespace Psychrometrics { ShowContinueError(state, "Relative Humidity being reset to 1%"); } ShowRecurringWarningErrorAtEnd(state, "Calculated Relative Humidity out of range (PsyRhFnTdbWPb)", - iPsyErrIndex(iPsyRhFnTdbWPb), + state.dataPsychrometrics->iPsyErrIndex(iPsyRhFnTdbWPb), RHValue * 100.0, RHValue * 100.0, _, @@ -1245,7 +1236,7 @@ namespace Psychrometrics { ) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyWFnTdpPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdpPb) == 0) { state.dataPsychrometrics->String = format(" Dew-Point= {:.2T} Barometric Pressure= {:.2T}", TDP, PB); ShowWarningMessage(state, "Calculated partial vapor pressure is greater than the barometric pressure, so that calculated humidity ratio is invalid (PsyWFnTdpPb)."); if (!CalledFrom.empty()) { @@ -1257,7 +1248,7 @@ namespace Psychrometrics { state.dataPsychrometrics->String = format("Instead, calculated Humidity Ratio at {:.1T} ({} degree less) = {:.4T}", TDP - DeltaT, static_cast(DeltaT), W); ShowContinueError(state, state.dataPsychrometrics->String + " will be used. Simulation continues."); } - ShowRecurringWarningErrorAtEnd(state, "Entered Humidity Ratio invalid (PsyWFnTdpPb)", iPsyErrIndex(iPsyWFnTdpPb), W, W, _, "[]", "[]"); + ShowRecurringWarningErrorAtEnd(state, "Entered Humidity Ratio invalid (PsyWFnTdpPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdpPb), W, W, _, "[]", "[]"); } } #endif @@ -1273,7 +1264,7 @@ namespace Psychrometrics { { if (W <= -0.0001) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyWFnTdbRhPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbRhPb) == 0) { state.dataPsychrometrics->String = format(" Dry-Bulb= {:.2T} Relative Humidity [%]= {:.2T} Pressure= {:.2T}", TDB, RH * 100.0, PB); ShowWarningMessage(state, "Calculated Humidity Ratio is invalid (PsyWFnTdbRhPb)"); if (!CalledFrom.empty()) { @@ -1286,7 +1277,7 @@ namespace Psychrometrics { ShowContinueError(state, state.dataPsychrometrics->String + " ... Humidity Ratio set to .00001"); } ShowRecurringWarningErrorAtEnd(state, - "Calculated Humidity Ratio Invalid (PsyWFnTdbTwbPb)", iPsyErrIndex(iPsyWFnTdbRhPb), W, W, _, "[]", "[]"); + "Calculated Humidity Ratio Invalid (PsyWFnTdbTwbPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyWFnTdbRhPb), W, W, _, "[]", "[]"); } } } @@ -1348,7 +1339,7 @@ namespace Psychrometrics { int iter; // Iteration counter #ifdef EP_psych_stats - ++NumTimesCalled(iPsyTsatFnPb); + ++state.dataPsychrometrics->NumTimesCalled(iPsyTsatFnPb); #endif // Check press in range. @@ -1356,7 +1347,7 @@ namespace Psychrometrics { #ifdef EP_psych_errors if (!state.dataGlobal->WarmupFlag) { if (Press <= 0.0017 || Press >= 1555000.0) { - if (iPsyErrIndex(iPsyTsatFnPb) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTsatFnPb) == 0) { ShowWarningMessage(state, "Pressure out of range (PsyTsatFnPb)"); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -1366,7 +1357,7 @@ namespace Psychrometrics { ShowContinueError(state, format(" Input Pressure= {:.2T}", Press)); FlagError = true; } - ShowRecurringWarningErrorAtEnd(state, "Pressure out of range (PsyTsatFnPb)", iPsyErrIndex(iPsyTsatFnPb), Press, Press, _, "Pa", "Pa"); + ShowRecurringWarningErrorAtEnd(state, "Pressure out of range (PsyTsatFnPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTsatFnPb), Press, Press, _, "Pa", "Pa"); } } #endif @@ -1428,13 +1419,13 @@ namespace Psychrometrics { } // End If for the Pressure Range Checking #ifdef EP_psych_stats - NumIterations(iPsyTsatFnPb) += iter; + state.dataPsychrometrics->NumIterations(iPsyTsatFnPb) += iter; #endif #ifdef EP_psych_errors if (iter > itmax) { if (!state.dataGlobal->WarmupFlag) { - if (iPsyErrIndex(iPsyTsatFnPb2) == 0) { + if (state.dataPsychrometrics->iPsyErrIndex(iPsyTsatFnPb2) == 0) { ShowWarningMessage(state, format("Saturation Temperature not converged after {} iterations (PsyTsatFnPb)", iter)); if (!CalledFrom.empty()) { ShowContinueErrorTimeStamp(state, " Routine=" + CalledFrom + ','); @@ -1445,7 +1436,7 @@ namespace Psychrometrics { FlagError = true; } ShowRecurringWarningErrorAtEnd(state, - "Saturation Temperature not converged after max iterations (PsyTsatFnPb)", iPsyErrIndex(iPsyTsatFnPb2), tSat, tSat, _, "C", "C"); + "Saturation Temperature not converged after max iterations (PsyTsatFnPb)", state.dataPsychrometrics->iPsyErrIndex(iPsyTsatFnPb2), tSat, tSat, _, "C", "C"); } } #endif diff --git a/src/EnergyPlus/Psychrometrics.hh b/src/EnergyPlus/Psychrometrics.hh index 6175a5b2ef6..fd24561e109 100644 --- a/src/EnergyPlus/Psychrometrics.hh +++ b/src/EnergyPlus/Psychrometrics.hh @@ -107,8 +107,9 @@ namespace Psychrometrics { constexpr int NumPsychMonitors = 19; // Parameterization of Number of psychrometric routines that std::string const blank_string; + #ifdef EP_psych_stats - extern Array1D_string const PsyRoutineNames; // 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 - HR | 15 - max iter | 16 - HR | 17 - +extern Array1D_string const PsyRoutineNames; // 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 - HR | 15 - max iter | 16 - HR | 17 - // max iter | 18 - PsyTwbFnTdbWPb_raw (raw calc) | 19 - PsyPsatFnTemp_raw (raw calc) extern Array1D_bool const PsyReportIt; // PsyTdpFnTdbTwbPb 1 | PsyRhFnTdbWPb 2 | PsyTwbFnTdbWPb 3 | PsyVFnTdbWPb 4 | @@ -146,12 +147,6 @@ namespace Psychrometrics { // MODULE VARIABLE DEFINITIONS: -extern Array1D_int iPsyErrIndex; // Number of times error occurred -#ifdef EP_psych_stats - extern Array1D NumTimesCalled; - extern Array1D_int NumIterations; -#endif - // DERIVED TYPE DEFINITIONS // Types @@ -1396,6 +1391,13 @@ extern Array1D_int iPsyErrIndex; // Number of times error occurred struct PsychrometricsData : BaseGlobalStruct { +#ifdef EP_psych_stats + Array1D NumTimesCalled = Array1D(NumPsychMonitors, 0); + Array1D_int NumIterations = Array1D_int(NumPsychMonitors, 0); +#endif + + Array1D_int iPsyErrIndex = Array1D_int(Psychrometrics::NumPsychMonitors, 0); // Number of times error occurred + std::string String; bool ReportErrors = true; @@ -1406,6 +1408,7 @@ struct PsychrometricsData : BaseGlobalStruct void clear_state() override { + iPsyErrIndex = Array1D_int(Psychrometrics::NumPsychMonitors, 0); last_Patm = -99999.0; // barometric pressure {Pascals} (last) last_tBoil = -99999.0; // Boiling temperature of water at given pressure (last) Press_Save = -99999.0; @@ -1413,6 +1416,11 @@ struct PsychrometricsData : BaseGlobalStruct String = ""; ReportErrors = true; + +#ifdef EP_psych_stats + NumTimesCalled = Array1D(NumPsychMonitors, 0); + NumIterations = Array1D_int(NumPsychMonitors, 0); +#endif } };