From a7c6b9fbf65cba077eecff5f286eb87b729e7e2e Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 21:03:46 -0400 Subject: [PATCH 01/16] reduce --- src/EnergyPlus/WindowManager.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index ba62fe8f54e..be9a2c06343 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -1598,7 +1598,6 @@ namespace Window { Real64 GlWidth; // Width of glazed part of window {m} int NumHorDividers; // Number of horizontal divider elements int NumVertDividers; // Number of vertical divider elements - int BaseSurfNum; // Base surface number int MatNum; // Material number int DifOverrideCount; // Count the number of SolarDiffusing material overrides @@ -1661,7 +1660,7 @@ namespace Window { GlWidth = surf.Width; NumVertDividers = frdiv.VertDividers; NumHorDividers = frdiv.HorDividers; - BaseSurfNum = surf.BaseSurf; + int BaseSurfNum = surf.BaseSurf; state.dataSurface->SurfWinFrameConductance(SurfNum) = frdiv.FrameConductance; state.dataSurface->SurfWinFrameSolAbsorp(SurfNum) = frdiv.FrameSolAbsorp; state.dataSurface->SurfWinFrameVisAbsorp(SurfNum) = frdiv.FrameVisAbsorp; @@ -2128,7 +2127,6 @@ namespace Window { Real64 dT1(0.0); Real64 SurfOutsideEmiss; // temporary for result of outside surface emissivity Real64 Tsout; // temporary for result of outside surface temp in Kelvin - int temp; Array1D deltaTemp(100, 0.0); Array1D_int iMinDT(1, 0); @@ -2142,7 +2140,7 @@ namespace Window { if (state.dataSurface->SurfWinWindowModelType(SurfNum) == WindowModel::BSDF) { - temp = 0; + int temp = 0; // Simon: Complex fenestration state works only with tarcog CalcComplexWindowThermal( @@ -2239,7 +2237,6 @@ namespace Window { } // end new TC code - TotLay = state.dataConstruction->Construct(ConstrNum).TotLayers; TotGlassLay = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; wm->ngllayer = TotGlassLay; wm->nglface = 2 * wm->ngllayer; @@ -3399,7 +3396,6 @@ namespace Window { Real64 TauShIR = 0.0; // Long-wave transmittance of isolated shade/blind Real64 sconsh = 0.0; // shade/blind conductance (W/m2-K) - WinShadingType ShadeFlag = WinShadingType::NoShade; // Shading flag // radiation from lights and zone equipment absorbed by faces of shade/blind (W/m2) Real64 ShadeArea = 0.0; // shade/blind area (m2) // Real64 CondHeatGainGlass = 0.0; // Conduction through inner glass layer, outside to inside (W) @@ -3424,7 +3420,7 @@ namespace Window { Array1D_int indx(2 * maxGlassLayers); // Vector of row permutations in LU decomposition wm->nglfacep = wm->nglface; - ShadeFlag = state.dataSurface->SurfWinShadingFlag(SurfNum); + WinShadingType ShadeFlag = state.dataSurface->SurfWinShadingFlag(SurfNum); ZoneNum = state.dataSurface->Surface(SurfNum).Zone; AbsRadShadeFace = 0.0; From 496afc33659a7138ba971cc1c7e0153ae39ca623 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 21:21:57 -0400 Subject: [PATCH 02/16] reduce --- src/EnergyPlus/WindowManager.cc | 40 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index be9a2c06343..0801c52af06 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -4027,7 +4027,6 @@ namespace Window { Real64 pr; // Gap gas Prandtl number Real64 nu; // Gap gas Nusselt number WinShadingType ShadeFlag; // Shading flag - int BlNum; // Blind number int IGapInc; // Gap increment (0 or 1) auto &wm = state.dataWindowManager; @@ -4091,7 +4090,7 @@ namespace Window { AHolesGap = thisMaterialShade->WinShadeAirFlowPermeability * GapHeight * state.dataSurface->Surface(SurfNum).Width; } else { // Blind on - BlNum = state.dataSurface->SurfWinBlindNumber(SurfNum); + int BlNum = state.dataSurface->SurfWinBlindNumber(SurfNum); auto const &blind = state.dataMaterial->Blind(BlNum); ATopGap = blind.BlindTopOpeningMult * AGap; ABotGap = blind.BlindBottomOpeningMult * AGap; @@ -4501,13 +4500,11 @@ namespace Window { // b is also output as the solution, x // b is also output as the solution, x - int ii; // Intermediate variables - int ll; Real64 sum; // Summation variable - ii = 0; + int ii = 0; for (int i = 1; i <= n; ++i) { - ll = indx(i); + int ll = indx(i); sum = b(ll); b(ll) = b(i); if (ii != 0) { @@ -4827,7 +4824,6 @@ namespace Window { Real64 ressum; // Resistance sum (m2-K/W) int StormWinFlagPrevDay; // Previous time step value (day) of storm window flag int StormWinFlagThisDay; // Current time step value (day) of storm window flag - int nglfacePrevDay; // Previous time step value (dya) of number of glass faces (may differ // current time step value, nglface, if storm window was // added or removed during the current time step). @@ -4886,7 +4882,7 @@ namespace Window { // temperature values, although calculated here, are not used. The shade/blind face numbers // during the previous time step depend on whether a storm window glass layer was added to // or removed from the window during the current time step. - nglfacePrevDay = wm->nglface; + int nglfacePrevDay = wm->nglface; if (StormWinFlagPrevDay == 0 && StormWinFlagThisDay == 1) nglfacePrevDay = wm->nglface - 2; if (StormWinFlagPrevDay == 1 && StormWinFlagThisDay == 0) nglfacePrevDay = wm->nglface + 2; wm->thetas[wm->nglface] = state.dataSurface->SurfaceWindow(SurfNum).thetaFace[nglfacePrevDay + 1]; @@ -5603,7 +5599,6 @@ namespace Window { Array2D D(6, 16); // Powers of independent variable Real64 ACON; // Intermediate variables Real64 SUM; - int KP1; int LP1; int NM1; @@ -5637,7 +5632,7 @@ namespace Window { // Solve the simultaneous equations using Gauss elimination NM1 = N - 1; for (int K = 1; K <= NM1; ++K) { - KP1 = K + 1; + int KP1 = K + 1; for (int i = KP1; i <= N; ++i) { ACON = A(K, i) / A(K, K); B(i) -= B(K) * ACON; @@ -5698,7 +5693,6 @@ namespace Window { Array2D D(6, 16); // Powers of independent variable Real64 ACON; // Intermediate variables Real64 SUM; - int KP1; int LP1; int NM1; @@ -5732,7 +5726,7 @@ namespace Window { // Solve the simultaneous equations using Gauss elimination NM1 = N - 1; for (int K = 1; K <= NM1; ++K) { - KP1 = K + 1; + int KP1 = K + 1; for (int i = KP1; i <= N; ++i) { ACON = A(K, i) / A(K, K); B(i) -= B(K) * ACON; @@ -6933,8 +6927,6 @@ namespace Window { Real64 TempVar(0.0); // just temporary usage for complex fenestration int ThisNum; - int Layer; - int BlNum; // Blind number Real64 NominalConductanceWinter; // Nominal center-of-glass conductance of a window construction // for ASHRAE winter conditions (W/m2-K): // Inside air temperature = 21.1C (70F) @@ -6950,13 +6942,9 @@ namespace Window { Real64 SHGCWinter(0.0); // Center-of-glass solar heat gain coefficient for ASHRAE Real64 SHGCSummer(0.0); // winter and summer conditions - Real64 TransSolNorm; // Window construction solar transmittance at normal incidence - Real64 TransVisNorm; // Window construction visible transmittance at normal incidence - int errFlag; // Error flag - std::string SolarDiffusing; // 'Yes' if glass is solar diffusing; otherwise 'No' (clear glass) - std::string SpectralDataName; - std::string OpticalDataType; - std::string SlateOrientation; + Real64 TransSolNorm; // Window construction solar transmittance at normal incidence + Real64 TransVisNorm; // Window construction visible transmittance at normal incidence + int errFlag; // Error flag auto &wm = state.dataWindowManager; @@ -7156,8 +7144,10 @@ namespace Window { // Write(OutputFileConstrainParams, 705) TRIM(Construct(ThisNum)%Name), SHGCSummer ,TransVisNorm for (int i = 1; i <= construct.TotLayers; ++i) { - Layer = construct.LayerPoint(i); + int Layer = construct.LayerPoint(i); auto const *mat = state.dataMaterial->Material(Layer); + std::string SpectralDataName; + std::string OpticalDataType; switch (mat->group) { case Material::Group::WindowGas: { @@ -7185,7 +7175,7 @@ namespace Window { case Material::Group::WindowBlind: { auto const *thisMaterial = dynamic_cast(mat); assert(thisMaterial != nullptr); - BlNum = thisMaterial->BlindDataPtr; + int BlNum = thisMaterial->BlindDataPtr; auto const &blind = state.dataMaterial->Blind(BlNum); static constexpr std::string_view Format_704( " WindowMaterial:Blind,{},{:.4R},{:.4R},{:.4R},{:.3R},{:.3R},{:.3R},{:.3R}\n"); @@ -7227,7 +7217,7 @@ namespace Window { case Material::Group::WindowSimpleGlazing: { auto const *thisMaterial = dynamic_cast(mat); assert(thisMaterial != nullptr); - SolarDiffusing = "No"; + std::string SolarDiffusing = "No"; if (thisMaterial->SolarDiffusing) SolarDiffusing = "Yes"; OpticalDataType = "SpectralAverage"; SpectralDataName = ""; @@ -7352,7 +7342,7 @@ namespace Window { case Material::Group::BlindEquivalentLayer: { auto const *thisMaterial = dynamic_cast(mat); assert(thisMaterial != nullptr); - SlateOrientation = "Horizontal"; + std::string SlateOrientation = "Horizontal"; if (thisMaterial->SlatOrientation == DataWindowEquivalentLayer::Orientation::Vertical) { SlateOrientation = "Vertical"; } From 06df6fd7fff7ec6e796437ca584ada25656ac50f Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 21:28:53 -0400 Subject: [PATCH 03/16] reduce --- src/EnergyPlus/WindowManager.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 0801c52af06..cb383f07ce1 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -8726,15 +8726,10 @@ namespace Window { int NumAlphas; // Number of Alphas for each GetobjectItem call int NumNumbers; // Number of Numbers for each GetobjectItem call int NumArgs; - int IOStatus; Array1D_string cAlphaArgs; // Alpha input items for object Array1D rNumericArgs; // Numeric input items for object std::string cCurrentModuleObject; - std::string cSolarSpectrum; - std::string cVisibleSpectrum; - int iSolarSpectrum(0); - int iVisibleSpectrum(0); int NumSiteSpectrum(0); int Loop; int iTmp; @@ -8764,6 +8759,7 @@ namespace Window { rNumericArgs.dimension(NumNumbers, 0.0); if (NumSiteSpectrum == 1) { + int IOStatus; state.dataInputProcessing->inputProcessor->getObjectItem(state, cCurrentModuleObject, 1, @@ -8780,8 +8776,8 @@ namespace Window { } // now read custom solar and visible spectrum data - cSolarSpectrum = state.dataIPShortCut->cAlphaArgs(3); - cVisibleSpectrum = state.dataIPShortCut->cAlphaArgs(4); + std::string cSolarSpectrum = state.dataIPShortCut->cAlphaArgs(3); + std::string cVisibleSpectrum = state.dataIPShortCut->cAlphaArgs(4); cCurrentModuleObject = "Site:SpectrumData"; NumSiteSpectrum = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); @@ -8797,8 +8793,8 @@ namespace Window { cAlphaArgs.allocate(NumAlphas); rNumericArgs.dimension(NumNumbers, 0.0); - iSolarSpectrum = 0; - iVisibleSpectrum = 0; + int iSolarSpectrum = 0; + int iVisibleSpectrum = 0; for (int Loop = 1; Loop <= NumSiteSpectrum; ++Loop) { // Step 2 - read user-defined spectrum data state.dataInputProcessing->inputProcessor->getObjectItem(state, From 5350c73bbfdfee0f6f95eea57afeedb8fea809cc Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 21:39:37 -0400 Subject: [PATCH 04/16] unused --- src/EnergyPlus/WindowManager.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index cb383f07ce1..615a6e4c9cc 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -7885,8 +7885,6 @@ namespace Window { Array1D fEdgeA(2); // Average slat edge correction factor for upper and lower quadrants // seen by window blind Real64 gamma; // phib - phis - int Iphis; // Source elevation counter - int IUpDown; // =1 for source in upper quadrant, =2 for source in lower quadrant Real64 fEdge; // Slat edge correction factor Real64 fEdge1; Array1D j(6); // Slat section radiosity vector @@ -7895,11 +7893,9 @@ namespace Window { Array2D F(6, 6); // View factor array Array2D X(4, 4); // Exchange matrix Array2D Xinv(4, 4); // Inverse of exchange matrix - int k; // Array indices - int m; - Array1D_int indx(4); // LU decomposition indices - Real64 BlindIRreflFront; // Blind front IR reflectance - Real64 BlindIRreflBack; // Blind back IR reflectance + Array1D_int indx(4); // LU decomposition indices + Real64 BlindIRreflFront; // Blind front IR reflectance + Real64 BlindIRreflBack; // Blind back IR reflectance // The slat input properties are: // c(1) 0. (unused) @@ -8731,8 +8727,6 @@ namespace Window { std::string cCurrentModuleObject; int NumSiteSpectrum(0); - int Loop; - int iTmp; auto &wm = state.dataWindowManager; From ff2f5c56aeecfeb5cbc7ce510096e2bbe2779f38 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 21:51:13 -0400 Subject: [PATCH 05/16] unused --- src/EnergyPlus/WindowManager.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 615a6e4c9cc..02e24010948 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -179,10 +179,7 @@ namespace Window { using WindowEquivalentLayer::InitEquivalentLayerWindowCalculations; - int CoefNum; // Polynomial coefficient number - int j; // Wavelength counter int TotLay; // Total solid and gas layers in a window construction - int ConstrNum; // Construction number int ConstrNumSh; // Shaded construction number int ShadeLayNum; // Layer number for shade or blind, if present int ShadeLayPtr; // Material number for shade or blind @@ -287,7 +284,6 @@ namespace Window { int LayPtr; // Material number corresponding to LayNum Real64 Phi; // Incidence angle (deg) Real64 CosPhi; // Cosine of incidence angle - int ILam; // Wavelength counter Real64 tsolDiff; // Glazing system diffuse solar transmittance Real64 tvisDiff; // Glazing system diffuse visible transmittance int IGlassBack; // Glass layer number counted from back of window @@ -1589,7 +1585,6 @@ namespace Window { // Initializes variables used in the window optical and thermal calculation. int ConstrNum; // Construction number - int FrDivNum; // Pointer to frame/divider Real64 FrWidth; // Window frame width {m} Real64 FrEdgeWidth; // Frame edge width {m} Real64 DivWidth; // Window divider width {m} @@ -2096,10 +2091,8 @@ namespace Window { int TotLay; // Total number of layers in a construction // (sum of solid layers and gap layers) int TotGlassLay; // Total number of glass layers in a construction - int Lay; // Layer number int LayPtr; // Material number for a layer WinShadingType ShadeFlag; // Flag indicating whether shade or blind is on, and shade/blind position - int k; // Layer counter // REAL(r64) :: tsky ! Sky temperature [K] int ShadeLayPtr; // Material number corresponding to a shade layer Real64 dth1; // Temperature difference across glass layers [K] @@ -6188,7 +6181,6 @@ namespace Window { int TotLay; // Total number of layers in a construction // (sum of solid layers and gap layers) int TotGlassLay; // Total number of glass layers in a construction - int Lay; // Layer number int LayPtr; // Material number for a layer Real64 BeamSolarInc; // Incident beam radiation at zero angle of incidence (W/m2) @@ -6208,10 +6200,8 @@ namespace Window { int MatShade; // Material number of shade layer Array1D AbsBeamNorm(maxGlassLayers); // Beam absorptance at normal incidence for each glass layer Real64 AbsBeamShadeNorm; // Shade solar absorptance at normal incidence - int ConstrNum1; // Construction counter int ConstrNumBare; // Construction without shading device int BlNum; // Blind number - int ScNum; // Screen number bool VarSlats; // True if slats in blind are variable angle Real64 SlatAng; // Slat angle (rad) int LayPtrSh; // Layer pointer of blind @@ -6926,7 +6916,6 @@ namespace Window { Real64 TempVar(0.0); // just temporary usage for complex fenestration - int ThisNum; Real64 NominalConductanceWinter; // Nominal center-of-glass conductance of a window construction // for ASHRAE winter conditions (W/m2-K): // Inside air temperature = 21.1C (70F) @@ -7450,7 +7439,6 @@ namespace Window { Array1D sun_el_deg(Material::MaxProfAngs); // Solar profile angle (deg) corresponding to sun_el values Real64 bld_el; // Slat angle (elevation of slat normal vector in plane // perpendicular to window and containing the slat normal vector) (radians) - int IProfAng; // Profile angle index for (int BlindNum = 1; BlindNum <= state.dataHeatBal->TotBlinds; ++BlindNum) { auto &blind = state.dataMaterial->Blind(BlindNum); @@ -7623,7 +7611,6 @@ namespace Window { Real64 SumReflect; // Integration variable for reflectance Real64 SumReflectVis; // Integration variable for visible reflectance Real64 SumArea; // Integration variable for area of quarter hemisphere - bool FoundMaterial; // Flag to avoid printing screen transmittance data multiple times when Material:WindowScreen // is used on multiple surfaces bool PrintTransMap; // Flag used to print transmittance map From e9221f4ef8b777ac38116bbe69cb7bf0002309a0 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 21:57:09 -0400 Subject: [PATCH 06/16] reduce --- src/EnergyPlus/WindowManager.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 02e24010948..9afe0d794cf 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -280,7 +280,6 @@ namespace Window { Real64 EpsGlIR; // IR absorptance of front or back of isolated glass Real64 RhoGlIR; // IR reflectance of inside face of inside glass int NGlass; // Number of glass layers in a construction - int LayNum; // Layer number for a glass layer int LayPtr; // Material number corresponding to LayNum Real64 Phi; // Incidence angle (deg) Real64 CosPhi; // Cosine of incidence angle @@ -501,7 +500,7 @@ namespace Window { // Loop over glass layers in the construction for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { - LayNum = 1 + 2 * (IGlass - 1); + int LayNum = 1 + 2 * (IGlass - 1); if (ExtShade || ExtBlind || ExtScreen) LayNum = 2 + 2 * (IGlass - 1); if (BGShade || BGBlind) { LayNum = 1; @@ -795,7 +794,7 @@ namespace Window { // Loop over glass layers in the construction. for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { - LayNum = 1 + (NGlass - IGlass) * 2; + int LayNum = 1 + (NGlass - IGlass) * 2; if (ExtShade || ExtBlind || ExtScreen) LayNum = 2 + (NGlass - IGlass) * 2; if (BGShade || BGBlind) { if (NGlass == 2) { @@ -1584,7 +1583,6 @@ namespace Window { { // Initializes variables used in the window optical and thermal calculation. - int ConstrNum; // Construction number Real64 FrWidth; // Window frame width {m} Real64 FrEdgeWidth; // Frame edge width {m} Real64 DivWidth; // Window divider width {m} @@ -1702,7 +1700,7 @@ namespace Window { state.dataSurface->SurfWinStormWinConstr(SurfNum) != 0) continue; - ConstrNum = surf.Construction; + int ConstrNum = surf.Construction; MatNum = state.dataConstruction->Construct(ConstrNum).LayerPoint(state.dataConstruction->Construct(ConstrNum).TotLayers); auto const *thisMaterial = dynamic_cast(state.dataMaterial->Material(MatNum)); assert(thisMaterial != nullptr); From 9a140503df2efe3246218fe3b2388f427242dda8 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:05:33 -0400 Subject: [PATCH 07/16] shadow --- src/EnergyPlus/WindowManager.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 9afe0d794cf..b4d289d06da 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -2433,9 +2433,9 @@ namespace Window { if (SurfNumAdj > 0) { // Interzone window ZoneNumAdj = state.dataSurface->Surface(SurfNumAdj).Zone; - Real64 RefAirTemp = state.dataSurface->Surface(SurfNumAdj).getInsideAirTemperature(state, SurfNumAdj); - state.dataHeatBal->SurfTempEffBulkAir(SurfNumAdj) = RefAirTemp; - wm->tout = RefAirTemp + Constant::Kelvin; // outside air temperature + Real64 RefAirTempAdj = state.dataSurface->Surface(SurfNumAdj).getInsideAirTemperature(state, SurfNumAdj); + state.dataHeatBal->SurfTempEffBulkAir(SurfNumAdj) = RefAirTempAdj; + wm->tout = RefAirTempAdj + Constant::Kelvin; // outside air temperature // Add long-wave radiation from adjacent zone absorbed by glass layer closest to the adjacent zone. wm->AbsRadGlassFace[0] += state.dataHeatBal->SurfQdotRadIntGainsInPerArea(SurfNumAdj); @@ -4399,8 +4399,6 @@ namespace Window { // SUBROUTINE INFORMATION: // AUTHOR F. Winkelmann, adapted from Numerical Recipes // DATE WRITTEN February 2000 - // MODIFIED na - // RE-ENGINEERED na // PURPOSE OF THIS SUBROUTINE: // Performs LU decomposition of a matrix. @@ -4412,8 +4410,6 @@ namespace Window { int imax; // Temporary variable // as output: decomposed matrix - Real64 aamax; // Absolute value of largest element of matrix - assert(n <= 10); // vv sizing std::array vv = {0.0}; // Stores the implicit scaling of each row @@ -4434,7 +4430,7 @@ namespace Window { } ajac(j, i) = sum; } - aamax = 0.0; + Real64 aamax = 0.0; for (int i = j; i <= n; ++i) { Real64 sum = ajac(j, i); for (int k = 1; k <= j - 1; ++k) { From 09392272047661f51674ba3ea6a00fe360230541 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:10:46 -0400 Subject: [PATCH 08/16] const --- src/EnergyPlus/WindowManager.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index b4d289d06da..4c17659a119 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -1786,7 +1786,7 @@ namespace Window { // back reflectance at angle of incidence std::array, maxGlassLayers> rbadjPhi = {0.0}; - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; // For each glass layer find tPhi, rfPhi, and rbPhi at each wavelength for (int in = 1; in <= ngllayer; ++in) { @@ -1927,7 +1927,7 @@ namespace Window { { Real64 num = 0.0; Real64 denom = 0.0; - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; for (int i = 1; i <= nume - 1; ++i) { Real64 const esol = (wm->wle[i] - wm->wle[i - 1]) * 0.5 * (wm->e[i - 1] + wm->e[i]); @@ -1951,7 +1951,7 @@ namespace Window { Real64 y30new = 0.0; Real64 y30ils1 = 0.0; - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; for (int i = 2; i <= nume; ++i) { // Autodesk:BoundsViolation e|wle|p(i-1) @ i=1: Changed start index from 1 to 2: wle // values prevented this violation from occurring in practice @@ -2017,7 +2017,7 @@ namespace Window { // // PURPOSE OF THIS SUBROUTINE: // Subroutine to direct whether to use exterior or interior window routines - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; if (state.dataGlobal->KickOffSizing || state.dataGlobal->KickOffSimulation) return; From 7071b95ba4dc1146c7ad22e0e98262c9c454d998 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:25:32 -0400 Subject: [PATCH 09/16] const --- src/EnergyPlus/WindowManager.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 4c17659a119..3faf12d6704 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -2743,7 +2743,7 @@ namespace Window { Real64 pr; // Gap gas Prandtl number Real64 nu; // Gap gas Nusselt number - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; if (nglasslayer == 1) { Bface(1) = wm->Outir * wm->emis[0] + wm->hcout * wm->tout + wm->AbsRadGlassFace[0]; @@ -4204,7 +4204,7 @@ namespace Window { // Dens dDens/dT Con dCon/dT Vis dVis/dT Prandtl dPrandtl/dT // DATA AirProps / 1.29, -0.4d-2, 2.41d-2, 7.6d-5, 1.73d-5, 1.0d-7, 0.72, 1.8d-3 / - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; ConstrNum = state.dataSurface->Surface(SurfNum).Construction; NGlass = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; @@ -4315,7 +4315,7 @@ namespace Window { int IGapInc; // Gap increment; =0, double glass, =1, triple glass // REAL(r64) :: AirProps(8) ! Air properties - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; // Air properties // Dens dDens/dT Con dCon/dT Vis dVis/dT Prandtl dPrandtl/dT @@ -4719,7 +4719,7 @@ namespace Window { Array1D fvis(10); // Viscosity of each gas in a mixture (g/m-s) Array1D fdens(10); // Density of each gas in a mixture (kg/m3) - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; NMix = wm->gaps[IGap - 1].numGases; @@ -4814,7 +4814,7 @@ namespace Window { // current time step value, nglface, if storm window was // added or removed during the current time step). - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; StormWinFlagPrevDay = state.dataSurface->SurfWinStormWinFlagPrevDay(SurfNum); StormWinFlagThisDay = state.dataSurface->SurfWinStormWinFlag(SurfNum); @@ -4953,7 +4953,7 @@ namespace Window { Real64 g; Real64 ang; - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; if (SurfNum > 0) { asp = state.dataSurface->Surface(SurfNum).Height / wm->gaps[IGap - 1].width; From 25f9262d10f650c4a83d34feca242839115298e5 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:33:41 -0400 Subject: [PATCH 10/16] const and const arg --- src/EnergyPlus/WindowManager.cc | 4 ++-- src/EnergyPlus/WindowManager.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 3faf12d6704..f2643589620 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -6579,7 +6579,7 @@ namespace Window { // init the surface convective and radiative adjustment ratio for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) { for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { - auto &thisSpace = state.dataHeatBal->space(spaceNum); + auto const &thisSpace = state.dataHeatBal->space(spaceNum); int const firstSurfWin = thisSpace.WindowSurfaceFirst; int const lastSurfWin = thisSpace.WindowSurfaceLast; for (int SurfNum = firstSurfWin; SurfNum <= lastSurfWin; ++SurfNum) { @@ -6604,7 +6604,7 @@ namespace Window { Array1D const hgap, // Conductive gap conductance [W/m2-K] Real64 &NominalConductance, // Nominal center-of-glass conductance, including air films Real64 &SHGC, // Nominal center-of-glass solar heat gain coefficient for - Real64 &TSolNorm // Overall beam solar transmittance at normal incidence + Real64 const TSolNorm // Overall beam solar transmittance at normal incidence ) { Array1D hGapTot(5); // Combined radiative and conductive gap conductance [W/m2-K] diff --git a/src/EnergyPlus/WindowManager.hh b/src/EnergyPlus/WindowManager.hh index b455e9ca144..b2120566fa4 100644 --- a/src/EnergyPlus/WindowManager.hh +++ b/src/EnergyPlus/WindowManager.hh @@ -323,7 +323,7 @@ namespace Window { Array1D hgap, // Conductive gap conductance [W/m2-K] Real64 &NominalConductance, // Nominal center-of-glass conductance, including air films Real64 &SHGC, // Nominal center-of-glass solar heat gain coefficient for - Real64 &TSolNorm // Overall beam solar transmittance at normal incidence + Real64 TSolNorm // Overall beam solar transmittance at normal incidence ); void WindowTempsForNominalCond(EnergyPlusData &state, From 3c298690152b17249cbe85a55b068099f26d876d Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:41:03 -0400 Subject: [PATCH 11/16] const --- src/EnergyPlus/WindowManager.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index f2643589620..47aa571bc1b 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -6609,7 +6609,7 @@ namespace Window { { Array1D hGapTot(5); // Combined radiative and conductive gap conductance [W/m2-K] - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; Real64 hOutRad = wm->emis[0] * Constant::StefanBoltzmann * 0.5 * pow_3(wm->tout + wm->thetas[0]); Real64 rOut = 1.0 / (hOutRad + wm->hcout); Real64 hInRad = wm->emis[wm->nglface - 1] * Constant::StefanBoltzmann * 0.5 * pow_3(wm->tin + wm->thetas[wm->nglface - 1]); @@ -6859,7 +6859,7 @@ namespace Window { Real64 temdiff; // Inside/outside air temperature difference (K) Real64 ressum; // Resistance sum (m2-K/W) - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; rguess(1) = 1.0 / (wm->hcout + hrad); rguess(wm->nglface + 1) = 1.0 / (hcinStartValue + hrad); @@ -7917,7 +7917,7 @@ namespace Window { // p(15) IR emissivity back // p(16) 0.0 (unused) - auto &blind = state.dataMaterial->Blind(BlindNum); + auto const &blind = state.dataMaterial->Blind(BlindNum); // Calculate view factors between slat sections (slat is divided longitudinally into two equal parts) ViewFac(c(2), c(3), b_el, Constant::PiOvr2, F); @@ -8709,7 +8709,7 @@ namespace Window { std::string cCurrentModuleObject; int NumSiteSpectrum(0); - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; if (wm->RunMeOnceFlag) return; From 60066bfaf6a159763238170bfc76b89805655df2 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:48:31 -0400 Subject: [PATCH 12/16] const class why? --- src/EnergyPlus/WindowManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 47aa571bc1b..ecf353042fa 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -8842,7 +8842,7 @@ namespace Window { void initWindowModel(EnergyPlusData &state) { const std::string objectName = "WindowsCalculationEngine"; - auto &wm = state.dataWindowManager; + auto const &wm = state.dataWindowManager; wm->inExtWindowModel = CWindowModel::WindowModelFactory(state, objectName); wm->winOpticalModel = CWindowOpticalModel::WindowOpticalModelFactory(state); } // InitWindowModel() From 1b197835a902bf2e6e12c8e380a7247b38469e69 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:53:10 -0400 Subject: [PATCH 13/16] unused --- src/EnergyPlus/WindowManager.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index ecf353042fa..4782243df7f 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -4291,7 +4291,6 @@ namespace Window { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ConstrNumSh; // Shaded construction number - int MatNumSh; // Material number of shade/blind layer // In the following, "gaps" refer to the gaps on either side of the shade/blind Array1D TGlassFace(2); // Temperature of glass surfaces facing gaps (K) Array1D TShadeFace(2); // Temperature of shade surfaces facing gaps (K) @@ -4325,14 +4324,12 @@ namespace Window { ShadeFlag = state.dataSurface->SurfWinShadingFlag(SurfNum); if (state.dataConstruction->Construct(ConstrNumSh).TotGlassLayers == 2) { // Double glazing - MatNumSh = state.dataConstruction->Construct(ConstrNumSh).LayerPoint(3); IGapInc = 0; for (int IGap = 1; IGap <= 2; ++IGap) { TGlassFace(IGap) = wm->thetas[IGap]; TShadeFace(IGap) = wm->thetas[IGap + 3]; } } else { // Triple glazing - MatNumSh = state.dataConstruction->Construct(ConstrNumSh).LayerPoint(5); IGapInc = 1; for (int IGap = 1; IGap <= 2; ++IGap) { TGlassFace(IGap) = wm->thetas[IGap + 2]; From 5ddf16b3e38a0afcfd6fc7e3f126752a7e91fba8 Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 22:58:39 -0400 Subject: [PATCH 14/16] unused --- src/EnergyPlus/WindowManager.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 4782243df7f..d6ad399768c 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -1653,7 +1653,6 @@ namespace Window { GlWidth = surf.Width; NumVertDividers = frdiv.VertDividers; NumHorDividers = frdiv.HorDividers; - int BaseSurfNum = surf.BaseSurf; state.dataSurface->SurfWinFrameConductance(SurfNum) = frdiv.FrameConductance; state.dataSurface->SurfWinFrameSolAbsorp(SurfNum) = frdiv.FrameSolAbsorp; state.dataSurface->SurfWinFrameVisAbsorp(SurfNum) = frdiv.FrameVisAbsorp; @@ -2088,7 +2087,6 @@ namespace Window { int ZoneNumAdj; // An interzone surface's adjacent zone number int TotLay; // Total number of layers in a construction // (sum of solid layers and gap layers) - int TotGlassLay; // Total number of glass layers in a construction int LayPtr; // Material number for a layer WinShadingType ShadeFlag; // Flag indicating whether shade or blind is on, and shade/blind position // REAL(r64) :: tsky ! Sky temperature [K] @@ -2137,7 +2135,6 @@ namespace Window { CalcComplexWindowThermal( state, SurfNum, temp, HextConvCoeff, SurfInsideTemp, SurfOutsideTemp, SurfOutsideEmiss, DataBSDFWindow::Condition::Invalid); - TotGlassLay = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; wm->ngllayer = state.dataConstruction->Construct(ConstrNum).TotSolidLayers; // Simon: This is necessary to keep for frame calculations // Simon: need to transfer surface temperatures because of frames calculation @@ -2228,7 +2225,7 @@ namespace Window { } // end new TC code - TotGlassLay = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; + int TotGlassLay = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; wm->ngllayer = TotGlassLay; wm->nglface = 2 * wm->ngllayer; ShadeFlag = state.dataSurface->SurfWinShadingFlag(SurfNum); From 2cdd1ef0c7d11c1bc65d5991343da49918e3a10b Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Sat, 31 Aug 2024 23:07:17 -0400 Subject: [PATCH 15/16] unused and reduce --- src/EnergyPlus/WindowManager.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index d6ad399768c..ea03c2909b2 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -2084,7 +2084,6 @@ namespace Window { int BlNum; // Window blind number int SurfNumAdj; // An interzone surface's number in the adjacent zone - int ZoneNumAdj; // An interzone surface's adjacent zone number int TotLay; // Total number of layers in a construction // (sum of solid layers and gap layers) int LayPtr; // Material number for a layer @@ -2429,7 +2428,6 @@ namespace Window { if (SurfNumAdj > 0) { // Interzone window - ZoneNumAdj = state.dataSurface->Surface(SurfNumAdj).Zone; Real64 RefAirTempAdj = state.dataSurface->Surface(SurfNumAdj).getInsideAirTemperature(state, SurfNumAdj); state.dataHeatBal->SurfTempEffBulkAir(SurfNumAdj) = RefAirTempAdj; wm->tout = RefAirTempAdj + Constant::Kelvin; // outside air temperature @@ -3394,7 +3392,6 @@ namespace Window { Real64 CpAirOutlet = 0.0; // Heat capacity of air from window gap (J/kg-K) Real64 CpAirZone = 0.0; // Heat capacity of zone air (J/kg-K) Real64 InletAirHumRat = 0.0; // Humidity ratio of air from window gap entering fan - int InsideFaceIndex = 0; // intermediate variable for index of inside face in thetas Array1D hr = Array1D(2 * maxGlassLayers); // Radiative conductance (W/m2-K) Array1D AbsRadShadeFace(2); // Solar radiation, short-wave radiation from lights, and long-wave @@ -3458,6 +3455,7 @@ namespace Window { (state.dataSurface->surfIntConv(SurfNum).model == Convect::HcInt::ASHRAETARP)) { // coef model is "detailed" and not prescribed by user // need to find inside face index, varies with shade/blind etc. + int InsideFaceIndex; // intermediate variable for index of inside face in thetas if (ANY_INTERIOR_SHADE_BLIND(ShadeFlag)) { InsideFaceIndex = wm->nglfacep; } else { @@ -3977,7 +3975,6 @@ namespace Window { int ConstrNumSh; // Shaded construction number int MatNumSh; // Material number of shade/blind layer - int nglassfaces; // Number of glass faces in contruction // In the following, "gaps" refer to the gaps on either side of the shade/blind Array1D TGlassFace(2); // Temperature of glass surfaces facing gaps (K) Array1D TShadeFace(2); // Temperature of shade surfaces facing gaps (K) @@ -4021,7 +4018,6 @@ namespace Window { ConstrNumSh = state.dataSurface->Surface(SurfNum).activeShadedConstruction; ShadeFlag = state.dataSurface->SurfWinShadingFlag(SurfNum); - nglassfaces = 2 * state.dataConstruction->Construct(ConstrNumSh).TotGlassLayers; if (state.dataConstruction->Construct(ConstrNumSh).TotGlassLayers == 2) { // Double glazing MatNumSh = state.dataConstruction->Construct(ConstrNumSh).LayerPoint(3); From ae1fa3ba41704a536343ec185f41e96ccc3966ec Mon Sep 17 00:00:00 2001 From: Richard Raustad Date: Tue, 10 Sep 2024 16:38:30 -0400 Subject: [PATCH 16/16] revert shortcut to fix crash and reduce more code --- src/EnergyPlus/WindowManager.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 82f1ba0842f..793ca54ed47 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -2072,7 +2072,6 @@ namespace Window { // (temperature of innermost face) [C] int SurfNumAdj; // An interzone surface's number in the adjacent zone - int TotLay; // Total number of layers in a construction // (sum of solid layers and gap layers) int TotGlassLay; // Total number of glass layers in a construction int LayPtr; // Material number for a layer @@ -2119,7 +2118,7 @@ namespace Window { CalcComplexWindowThermal( state, SurfNum, temp, HextConvCoeff, SurfInsideTemp, SurfOutsideTemp, SurfOutsideEmiss, DataBSDFWindow::Condition::Invalid); - auto &constr = state.dataConstruction->Construct(ConstrNum); + auto const &constr = state.dataConstruction->Construct(ConstrNum); wm->ngllayer = constr.TotSolidLayers; // Simon: This is necessary to keep for frame calculations // Simon: need to transfer surface temperatures because of frames calculation @@ -2166,7 +2165,7 @@ namespace Window { } else { // regular window, not BSDF, not EQL Window // Added for thermochromic windows - auto &constr = state.dataConstruction->Construct(ConstrNum); + auto const &constr = state.dataConstruction->Construct(ConstrNum); wm->locTCFlag = (constr.isTCWindow); if (wm->locTCFlag) { @@ -2264,7 +2263,7 @@ namespace Window { if (ANY_SHADE_SCREEN(ShadeFlag) || ANY_BLIND(ShadeFlag)) { IConst = s_surf->SurfWinActiveShadedConstruction(SurfNum); } - TotLay = constr.TotLayers; + int TotLay = state.dataConstruction->Construct(IConst).TotLayers; int IGlass = 0; int IGap = 0; @@ -4119,7 +4118,7 @@ namespace Window { auto &s_surf = state.dataSurface; auto const &wm = state.dataWindowManager; - auto &surf = s_surf->Surface(SurfNum); + auto const &surf = s_surf->Surface(SurfNum); ConstrNum = surf.Construction; NGlass = state.dataConstruction->Construct(ConstrNum).TotGlassLayers; @@ -4867,10 +4866,10 @@ namespace Window { Real64 g; Real64 ang; - auto &s_surf = state.dataSurface; auto const &wm = state.dataWindowManager; if (SurfNum > 0) { + auto const &s_surf = state.dataSurface; asp = s_surf->Surface(SurfNum).Height / wm->gaps[IGap - 1].width; } else { // SurfNum = 0 when NusseltNumber is called from CalcNominalWindowCond, which applies to a // particular construction. So window height is not known and we assume 5 ft (1.524 m) @@ -6764,7 +6763,6 @@ namespace Window { Real64 TransVisNorm; // Window construction visible transmittance at normal incidence int errFlag; // Error flag - auto &s_mat = state.dataMaterial; auto &wm = state.dataWindowManager; ScanForReports(state, "Constructions", wm->DoReport, "Constructions"); @@ -6782,6 +6780,7 @@ namespace Window { [](Construction::ConstructionProps const &e) { return e.WindowTypeEQL; })) wm->HasEQLWindows = true; // for reporting purpose only if (wm->DoReport && (wm->HasWindows || wm->HasComplexWindows || wm->HasEQLWindows)) { + auto const &s_mat = state.dataMaterial; // Write Descriptions print(state.files.eio, "{}\n", @@ -6966,7 +6965,6 @@ namespace Window { int Layer = construct.LayerPoint(i); auto const *mat = s_mat->materials(Layer); std::string SpectralDataName; - std::string OpticalDataType; switch (mat->group) { @@ -7078,7 +7076,7 @@ namespace Window { case Material::Group::GlassEQL: { auto const *matEQL = dynamic_cast(mat); assert(matEQL != nullptr); - OpticalDataType = "SpectralAverage"; + std::string OpticalDataType = "SpectralAverage"; SpectralDataName = ""; static constexpr std::string_view Format_708( " WindowMaterial:Glazing:EquivalentLayer,{},{},{},{:.5R},{:.5R},{:.5R},{:.5R},{:.5R}"