diff --git a/.github/workflows/test_pull_requests.yml b/.github/workflows/test_pull_requests.yml index 153b38d8f89..83e0ae8dd98 100644 --- a/.github/workflows/test_pull_requests.yml +++ b/.github/workflows/test_pull_requests.yml @@ -200,6 +200,8 @@ jobs: const script = require('${{ github.workspace }}/regressions/summary.js') console.log(script({github, context})) + - uses: lhotari/action-upterm@v1 + - name: Fail on Regressions from Forked Repository if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure' && github.event.pull_request.head.repo.full_name != 'NREL/EnergyPlus' run: | diff --git a/src/EnergyPlus/Construction.cc b/src/EnergyPlus/Construction.cc index 267e9f56ed5..ba748b49c83 100644 --- a/src/EnergyPlus/Construction.cc +++ b/src/EnergyPlus/Construction.cc @@ -2025,18 +2025,6 @@ void ConstructionProps::setArraysBasedOnMaxSolidWinLayers(EnergyPlusData &state) this->rbBareVisCoef.allocate(state.dataHeatBal->MaxSolidWinLayers); this->afBareSolCoef.allocate(state.dataHeatBal->MaxSolidWinLayers); this->abBareSolCoef.allocate(state.dataHeatBal->MaxSolidWinLayers); - for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { - this->AbsBeamCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->AbsBeamBackCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->tBareSolCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->tBareVisCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->rfBareSolCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->rfBareVisCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->rbBareSolCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->rbBareVisCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->afBareSolCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - this->abBareSolCoef(Layer).allocate(DataSurfaces::MaxPolyCoeff); - } for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { this->AbsDiff(Layer) = 0.0; @@ -2053,18 +2041,16 @@ void ConstructionProps::setArraysBasedOnMaxSolidWinLayers(EnergyPlusData &state) } } for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { - for (int Index = 1; Index <= DataSurfaces::MaxPolyCoeff; ++Index) { - this->AbsBeamCoef(Layer)(Index) = 0.0; - this->AbsBeamBackCoef(Layer)(Index) = 0.0; - this->tBareSolCoef(Layer)(Index) = 0.0; - this->tBareVisCoef(Layer)(Index) = 0.0; - this->rfBareSolCoef(Layer)(Index) = 0.0; - this->rfBareVisCoef(Layer)(Index) = 0.0; - this->rbBareSolCoef(Layer)(Index) = 0.0; - this->rbBareVisCoef(Layer)(Index) = 0.0; - this->afBareSolCoef(Layer)(Index) = 0.0; - this->abBareSolCoef(Layer)(Index) = 0.0; - } + std::fill(this->AbsBeamCoef(Layer).begin(), this->AbsBeamCoef(Layer).end(), 0.0); + std::fill(this->AbsBeamBackCoef(Layer).begin(), this->AbsBeamBackCoef(Layer).end(), 0.0); + std::fill(this->tBareSolCoef(Layer).begin(), this->tBareSolCoef(Layer).end(), 0.0); + std::fill(this->tBareVisCoef(Layer).begin(), this->tBareVisCoef(Layer).end(), 0.0); + std::fill(this->rfBareSolCoef(Layer).begin(), this->rfBareSolCoef(Layer).end(), 0.0); + std::fill(this->rfBareVisCoef(Layer).begin(), this->rfBareVisCoef(Layer).end(), 0.0); + std::fill(this->rbBareSolCoef(Layer).begin(), this->rbBareSolCoef(Layer).end(), 0.0); + std::fill(this->rbBareVisCoef(Layer).begin(), this->rbBareVisCoef(Layer).end(), 0.0); + std::fill(this->afBareSolCoef(Layer).begin(), this->afBareSolCoef(Layer).end(), 0.0); + std::fill(this->abBareSolCoef(Layer).begin(), this->abBareSolCoef(Layer).end(), 0.0); } } diff --git a/src/EnergyPlus/Construction.hh b/src/EnergyPlus/Construction.hh index 1c95c7b513a..4315d1a0283 100644 --- a/src/EnergyPlus/Construction.hh +++ b/src/EnergyPlus/Construction.hh @@ -55,6 +55,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -212,46 +213,42 @@ namespace Construction { // Sol diffuse absorptance per glass layer with blind on Array1D> layerSlatBlindDfAbs; - Array1D AbsDiffBack; // Diffuse back solar absorptance for each glass layer - Real64 AbsDiffShade = 0.0; // Diffuse solar absorptance for shade - Real64 AbsDiffBackShade = 0.0; // Diffuse back solar absorptance for shade - Real64 ShadeAbsorpThermal = 0.0; // Diffuse back thermal absorptance of shade - Array1D> AbsBeamCoef; // Coefficients of incidence-angle polynomial for solar + Array1D AbsDiffBack; // Diffuse back solar absorptance for each glass layer + Real64 AbsDiffShade = 0.0; // Diffuse solar absorptance for shade + Real64 AbsDiffBackShade = 0.0; // Diffuse back solar absorptance for shade + Real64 ShadeAbsorpThermal = 0.0; // Diffuse back thermal absorptance of shade + Array1D> AbsBeamCoef; // Coefficients of incidence-angle polynomial for solar // absorptance for each solid glazing layer - Array1D> AbsBeamBackCoef; // As for AbsBeamCoef but for back-incident solar - Array1D AbsBeamShadeCoef; // Coefficients of incidence-angle polynomial for solar - // absorptance of shade + Array1D> AbsBeamBackCoef; // As for AbsBeamCoef but for back-incident solar + std::array AbsBeamShadeCoef = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // Shade abs inc-angle coefs Real64 TransDiff = 0.0; // Diffuse solar transmittance, bare glass or shade on Real64 TransDiffVis; // Diffuse visible transmittance, bare glass or shade on Real64 ReflectSolDiffBack = 0.0; // Diffuse back solar reflectance, bare glass or shade on Real64 ReflectSolDiffFront = 0.0; // Diffuse front solar reflectance, bare glass or shade on Real64 ReflectVisDiffBack = 0.0; // Diffuse back visible reflectance, bare glass or shade on Real64 ReflectVisDiffFront = 0.0; // Diffuse front visible reflectance, bare glass or shade on - Array1D TransSolBeamCoef; // Coeffs of incidence-angle polynomial for beam sol trans, - // bare glass or shade on - Array1D TransVisBeamCoef; // Coeffs of incidence-angle polynomial for beam vis trans, - // bare glass or shade on - Array1D ReflSolBeamFrontCoef; // Coeffs of incidence-angle polynomial for beam sol front refl, - // bare glass or shade on - Array1D ReflSolBeamBackCoef; // Like ReflSolBeamFrontCoef, but for back-incident beam solar - Array1D> tBareSolCoef; // Isolated glass solar transmittance coeffs of inc. angle polynomial - Array1D> tBareVisCoef; // Isolated glass visible transmittance coeffs of inc. angle polynomial - Array1D> rfBareSolCoef; // Isolated glass front solar reflectance coeffs of inc. angle polynomial - Array1D> rfBareVisCoef; // Isolated glass front visible reflectance coeffs of inc. angle polynomial - Array1D> rbBareSolCoef; // Isolated glass back solar reflectance coeffs of inc. angle polynomial - Array1D> rbBareVisCoef; // Isolated glass back visible reflectance coeffs of inc. angle polynomial - Array1D> afBareSolCoef; // Isolated glass front solar absorptance coeffs of inc. angle polynomial - Array1D> abBareSolCoef; // Isolated glass back solar absorptance coeffs of inc. angle polynomial - Array1D tBareSolDiff; // Isolated glass diffuse solar transmittance - Array1D tBareVisDiff; // Isolated glass diffuse visible transmittance - Array1D rfBareSolDiff; // Isolated glass diffuse solar front reflectance - Array1D rfBareVisDiff; // Isolated glass diffuse visible front reflectance - Array1D rbBareSolDiff; // Isolated glass diffuse solar back reflectance - Array1D rbBareVisDiff; // Isolated glass diffuse visible back reflectance - Array1D afBareSolDiff; // Isolated glass diffuse solar front absorptance - Array1D abBareSolDiff; // Isolated glass diffuse solar back absorptance - bool FromWindow5DataFile = false; // True if this is a window construction extracted from the Window5 data file - Real64 W5FileMullionWidth = 0.0; // Width of mullion for construction from Window5 data file (m) + std::array TransSolBeamCoef = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // beam sol trans inc-angle coefs + std::array TransVisBeamCoef = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // beam vis trans inc-angle coefs + std::array ReflSolBeamFrontCoef = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // beam sol ref front inc-angle coefs + std::array ReflSolBeamBackCoef = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // beam sol ref back inc-angle coefs + Array1D> tBareSolCoef; // Isolated glass solar transmittance coeffs of inc. angle polynomial + Array1D> tBareVisCoef; // Isolated glass visible transmittance coeffs of inc. angle polynomial + Array1D> rfBareSolCoef; // Isolated glass front solar reflectance coeffs of inc. angle polynomial + Array1D> rfBareVisCoef; // Isolated glass front visible reflectance coeffs of inc. angle polynomial + Array1D> rbBareSolCoef; // Isolated glass back solar reflectance coeffs of inc. angle polynomial + Array1D> rbBareVisCoef; // Isolated glass back visible reflectance coeffs of inc. angle polynomial + Array1D> afBareSolCoef; // Isolated glass front solar absorptance coeffs of inc. angle polynomial + Array1D> abBareSolCoef; // Isolated glass back solar absorptance coeffs of inc. angle polynomial + Array1D tBareSolDiff; // Isolated glass diffuse solar transmittance + Array1D tBareVisDiff; // Isolated glass diffuse visible transmittance + Array1D rfBareSolDiff; // Isolated glass diffuse solar front reflectance + Array1D rfBareVisDiff; // Isolated glass diffuse visible front reflectance + Array1D rbBareSolDiff; // Isolated glass diffuse solar back reflectance + Array1D rbBareVisDiff; // Isolated glass diffuse visible back reflectance + Array1D afBareSolDiff; // Isolated glass diffuse solar front absorptance + Array1D abBareSolDiff; // Isolated glass diffuse solar back absorptance + bool FromWindow5DataFile = false; // True if this is a window construction extracted from the Window5 data file + Real64 W5FileMullionWidth = 0.0; // Width of mullion for construction from Window5 data file (m) DataWindowEquivalentLayer::Orientation W5FileMullionOrientation = DataWindowEquivalentLayer::Orientation::Invalid; // Orientation of mullion, if present, for Window5 data file construction, Real64 W5FileGlazingSysWidth = 0.0; // Glass width for construction from Window5 data file (m) @@ -325,8 +322,7 @@ namespace Construction { // Default Constructor ConstructionProps() - : LayerPoint(MaxLayersInConstruct, 0), AbsBeamShadeCoef(6, 0.0), TransDiffVis(0.0), TransSolBeamCoef(6, 0.0), TransVisBeamCoef(6, 0.0), - ReflSolBeamFrontCoef(6, 0.0), ReflSolBeamBackCoef(6, 0.0), tBareSolDiff(5, 0.0), tBareVisDiff(5, 0.0), rfBareSolDiff(5, 0.0), + : LayerPoint(MaxLayersInConstruct, 0), TransDiffVis(0.0), tBareSolDiff(5, 0.0), tBareVisDiff(5, 0.0), rfBareSolDiff(5, 0.0), rfBareVisDiff(5, 0.0), rbBareSolDiff(5, 0.0), rbBareVisDiff(5, 0.0), afBareSolDiff(5, 0.0), abBareSolDiff(5, 0.0), AbsDiffFrontEQL(DataWindowEquivalentLayer::CFSMAXNL, 0.0), AbsDiffBackEQL(DataWindowEquivalentLayer::CFSMAXNL, 0.0) { diff --git a/src/EnergyPlus/DElightManagerF.cc b/src/EnergyPlus/DElightManagerF.cc index 1be42160c7e..4b73aa71e0a 100644 --- a/src/EnergyPlus/DElightManagerF.cc +++ b/src/EnergyPlus/DElightManagerF.cc @@ -687,12 +687,12 @@ namespace DElightManagerF { iWndoConstIndexes(iconst) + 10000, state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransDiffVis, state.dataConstruction->Construct(iWndoConstIndexes(iconst)).ReflectVisDiffBack, - state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef(1), - state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef(2), - state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef(3), - state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef(4), - state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef(5), - state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef(6)); + state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef[0], + state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef[1], + state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef[2], + state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef[3], + state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef[4], + state.dataConstruction->Construct(iWndoConstIndexes(iconst)).TransVisBeamCoef[5]); } // Glass Type loop diff --git a/src/EnergyPlus/DataSurfaces.hh b/src/EnergyPlus/DataSurfaces.hh index c1c96b5beb2..c9d83ac1755 100644 --- a/src/EnergyPlus/DataSurfaces.hh +++ b/src/EnergyPlus/DataSurfaces.hh @@ -80,9 +80,6 @@ namespace DataSurfaces { using DataBSDFWindow::BSDFWindowDescript; using DataVectorTypes::Vector; - // MODULE PARAMETER DEFINITIONS: - constexpr int MaxPolyCoeff(6); - // Not sure this is the right module for this stuff, may move it later enum class Compass4 { diff --git a/src/EnergyPlus/DaylightingDevices.cc b/src/EnergyPlus/DaylightingDevices.cc index 2766b34a142..4da5536cde6 100644 --- a/src/EnergyPlus/DaylightingDevices.cc +++ b/src/EnergyPlus/DaylightingDevices.cc @@ -1328,9 +1328,6 @@ namespace Dayltg { // Swift, P. D., and Smith, G. B. "Cylindrical Mirror Light Pipes", // Solar Energy Materials and Solar Cells 36 (1995), pp. 159-168. - // Using/Aliasing - using General::POLYF; - // Return value Real64 TransTDD; @@ -1353,7 +1350,7 @@ namespace Dayltg { // Get the transmittance of each component and of total TDD switch (RadiationType) { case RadType::VisibleBeam: { - transDome = POLYF(COSI, state.dataConstruction->Construct(constDome).TransVisBeamCoef); + transDome = Window::POLYF(COSI, state.dataConstruction->Construct(constDome).TransVisBeamCoef); transPipe = InterpolatePipeTransBeam(state, COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransVisBeam); transDiff = state.dataConstruction->Construct(constDiff).TransDiffVis; // May want to change to POLYF also! @@ -1361,7 +1358,7 @@ namespace Dayltg { } break; case RadType::SolarBeam: { - transDome = POLYF(COSI, state.dataConstruction->Construct(constDome).TransSolBeamCoef); + transDome = Window::POLYF(COSI, state.dataConstruction->Construct(constDome).TransSolBeamCoef); transPipe = InterpolatePipeTransBeam(state, COSI, state.dataDaylightingDevicesData->TDDPipe(PipeNum).PipeTransSolBeam); transDiff = state.dataConstruction->Construct(constDiff).TransDiff; // May want to change to POLYF also! diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index 8718da982b4..d1c54d7262b 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -1526,7 +1526,7 @@ void FigureDayltgCoeffsAtPointsSetupForWindow(EnergyPlusData &state, LSHCAL = 0; // Visible transmittance at normal incidence - s_surf->SurfWinVisTransSelected(IWin) = General::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; + s_surf->SurfWinVisTransSelected(IWin) = Window::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; // For windows with switchable glazing, ratio of visible transmittance at normal // incidence for fully switched (dark) state to that of unswitched state s_surf->SurfWinVisTransRatio(IWin) = 1.0; @@ -1534,8 +1534,8 @@ void FigureDayltgCoeffsAtPointsSetupForWindow(EnergyPlusData &state, if (ShType == WinShadingType::SwitchableGlazing) { int IConstShaded = surf.activeShadedConstruction; // Shaded construction counter s_surf->SurfWinVisTransRatio(IWin) = - General::SafeDivide(General::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef), - General::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef)); + General::SafeDivide(Window::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef), + Window::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef)); } } @@ -1929,7 +1929,7 @@ void FigureDayltgCoeffsAtPointsForWindowElements( } else { // Regular window if (s_surf->SurfWinWindowModelType(IWin) != WindowModel::BSDF) { // Vis trans of glass for COSB incidence angle - TVISB = General::POLYF(COSB, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; + TVISB = Window::POLYF(COSB, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; } else { // Complex fenestration needs to use different equation for visible transmittance. That will be calculated later // in the code since it depends on different incoming directions. For now, just put zero to differentiate from @@ -1963,7 +1963,7 @@ void FigureDayltgCoeffsAtPointsForWindowElements( IntWinHitNum = 0; continue; } - TVISIntWin = General::POLYF(COSBIntWin, state.dataConstruction->Construct(surfIntWin.Construction).TransVisBeamCoef); + TVISIntWin = Window::POLYF(COSBIntWin, state.dataConstruction->Construct(surfIntWin.Construction).TransVisBeamCoef); TVISB *= TVISIntWin; break; // Ray passes thru interior window; exit from DO loop } @@ -3114,7 +3114,7 @@ void FigureDayltgCoeffsAtPointsForSunPosition( continue; } TVISIntWinDisk = - General::POLYF(COSBIntWin, state.dataConstruction->Construct(surfIntWinDisk.Construction).TransVisBeamCoef); + Window::POLYF(COSBIntWin, state.dataConstruction->Construct(surfIntWinDisk.Construction).TransVisBeamCoef); break; } // for (IntWinDisk) } // for (spaceNum) @@ -3170,7 +3170,7 @@ void FigureDayltgCoeffsAtPointsForSunPosition( TVISS = 0.0; } else { // Beam transmittance for bare window and all types of blinds - TVISS = General::POLYF(COSI, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac * + TVISS = Window::POLYF(COSI, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; if (extWinType == ExtWinType::AdjZone && hitIntWinDisk) TVISS *= TVISIntWinDisk; } @@ -3343,15 +3343,15 @@ void FigureDayltgCoeffsAtPointsForSunPosition( if (s_surf->Surface(ReflSurfNum).Class == SurfaceClass::Window) { int const ConstrNumRefl = s_surf->SurfActiveConstruction(ReflSurfNum); SpecReflectance = - General::POLYF(std::abs(CosIncAngRefl), state.dataConstruction->Construct(ConstrNumRefl).ReflSolBeamFrontCoef); + Window::POLYF(std::abs(CosIncAngRefl), state.dataConstruction->Construct(ConstrNumRefl).ReflSolBeamFrontCoef); } if (s_surf->Surface(ReflSurfNum).IsShadowing && s_surf->SurfShadowGlazingConstruct(ReflSurfNum) > 0) SpecReflectance = s_surf->SurfShadowGlazingFrac(ReflSurfNum) * - General::POLYF( + Window::POLYF( std::abs(CosIncAngRefl), state.dataConstruction->Construct(s_surf->SurfShadowGlazingConstruct(ReflSurfNum)).ReflSolBeamFrontCoef); - TVisRefl = General::POLYF(CosIncAngRec, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac * + TVisRefl = Window::POLYF(CosIncAngRec, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; dl->dirIllum(iHour)[iWinCover_Bare].sunDisk += SunVecMir.z * SpecReflectance * TVisRefl; // Bare window @@ -5809,8 +5809,8 @@ void DayltgInteriorIllum(EnergyPlusData &state, // based on the master construction. They need to be adjusted by the VTRatio, including: // ZoneDaylight()%DaylIllFacSky, DaylIllFacSun, DaylIllFacSunDisk; DaylBackFacSky, // DaylBackFacSun, DaylBackFacSunDisk, DaylSourceFacSky, DaylSourceFacSun, DaylSourceFacSunDisk - VTNow = General::POLYF(1.0, construction.TransVisBeamCoef); - VTMaster = General::POLYF(1.0, state.dataConstruction->Construct(construction.TCMasterConstrNum).TransVisBeamCoef); + VTNow = Window::POLYF(1.0, construction.TransVisBeamCoef); + VTMaster = Window::POLYF(1.0, state.dataConstruction->Construct(construction.TCMasterConstrNum).TransVisBeamCoef); VTRatio = VTNow / VTMaster; } } @@ -6084,12 +6084,12 @@ void DayltgInteriorIllum(EnergyPlusData &state, int const IConst = s_surf->SurfActiveConstruction(IWin); // Vis trans at normal incidence of unswitched glass shadeGroupLums.unswitchedTvis = - General::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; + Window::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; // Vis trans at normal incidence of fully switched glass int const IConstShaded = s_surf->Surface(IWin).activeShadedConstruction; shadeGroupLums.switchedTvis = - General::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac; + Window::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac; // Reset shading flag to indicate that window is shaded by being partially or fully switched s_surf->SurfWinShadingFlag(IWin) = WinShadingType::SwitchableGlazing; @@ -6304,12 +6304,12 @@ void DayltgInteriorIllum(EnergyPlusData &state, int const IConst = s_surf->SurfActiveConstruction(IWin); // Vis trans at normal incidence of unswitched glass shadeGroupLums.unswitchedTvis = - General::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; + Window::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; // Vis trans at normal incidence of fully switched glass int const IConstShaded = s_surf->Surface(IWin).activeShadedConstruction; shadeGroupLums.switchedTvis = - General::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac; + Window::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac; } // if (switchableGlazing) } // if (GlareControlIsActive) } // for (IWin) @@ -7287,7 +7287,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, } else { // Bare window // Transmittance of bare window for this sky/ground element - TVISBR = General::POLYF(COSB, construct.TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; + TVISBR = Window::POLYF(COSB, construct.TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; if (InShelfSurf > 0) { // Inside daylighting shelf // Daylighting shelf simplification: All light is diffuse @@ -7313,8 +7313,8 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, if (hitObs) { // disk passes thru // cosine of incidence angle of light from sky or ground element for COSBintWin = SPH * std::sin(surfIntWin.phi) + CPH * std::cos(surfIntWin.phi) * std::cos(TH - surfIntWin.theta); - TVISBR *= General::POLYF(COSBintWin, - state.dataConstruction->Construct(s_surf->Surface(IntWinNum).Construction).TransVisBeamCoef); + TVISBR *= Window::POLYF(COSBintWin, + state.dataConstruction->Construct(s_surf->Surface(IntWinNum).Construction).TransVisBeamCoef); break; } } @@ -7387,7 +7387,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, transMult = TransTDD(state, PipeNum, COSB, RadType::VisibleBeam) * surfWin.glazedFrac; } else { // Shade only, no TDD // Calculate transmittance of the combined window and shading device for this sky/ground element - transMult = General::POLYF(COSB, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac * + transMult = Window::POLYF(COSB, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; } @@ -7448,7 +7448,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, (1.0 - ReflGlDiffDiffFront * ReflBlDiffDiffBack) * surfWin.lightWellEff; } else { // Between-glass blind - Real64 t1 = General::POLYF(COSB, construct.tBareVisCoef(1)); + Real64 t1 = Window::POLYF(COSB, construct.tBareVisCoef(1)); td2 = construct.tBareVisDiff(2); rbd1 = construct.rbBareVisDiff(1); rfd2 = construct.rfBareVisDiff(2); @@ -7459,7 +7459,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, if (construct.TotGlassLayers == 2) { // 2 glass layers transMult = t1 * (tfshBd * (1.0 + rfd2 * rbshd) + rfshB * rbd1 * tfshd) * td2 * surfWin.lightWellEff; } else { // 3 glass layers; blind between layers 2 and 3 - Real64 t2 = General::POLYF(COSB, construct.tBareVisCoef(2)); + Real64 t2 = Window::POLYF(COSB, construct.tBareVisCoef(2)); td3 = construct.tBareVisDiff(3); rfd3 = construct.rfBareVisDiff(3); rbd2 = construct.rbBareVisDiff(2); @@ -7470,7 +7470,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, transBmBmMult = TVISBR * matBlind->BeamBeamTrans(ProfAng, surfShade.blind.slatAng); } else { // Diffusing glass - transMult = General::POLYF(COSB, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac * + transMult = Window::POLYF(COSB, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; } // End of check if shade, blind or diffusing glass @@ -7594,7 +7594,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, FLCW[iWinCover_Bare].sun += ZSU1 * TVISBSun * surfWin.fractionUpgoing; } else { // Bare window - TVISBSun = General::POLYF(COSBSun, construct.TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; + TVISBSun = Window::POLYF(COSBSun, construct.TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; // Daylighting shelf simplification: No beam makes it past end of shelf, all light is diffuse if (InShelfSurf > 0) { // Inside daylighting shelf @@ -7640,7 +7640,7 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, } else { int IConstShaded = s_surf->SurfWinActiveShadedConstruction(IWin); if (s_surf->SurfWinSolarDiffusing(IWin)) IConstShaded = surf.Construction; - transMult = General::POLYF(COSBSun, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac * + transMult = Window::POLYF(COSBSun, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac * surfWin.lightWellEff; } @@ -7675,13 +7675,13 @@ void DayltgInterReflectedIllum(EnergyPlusData &state, surfWin.glazedFrac * surfWin.lightWellEff; } else { // Between-glass blind - Real64 t1 = General::POLYF(COSBSun, construct.tBareVisCoef(1)); + Real64 t1 = Window::POLYF(COSBSun, construct.tBareVisCoef(1)); Real64 tfshBd = Interp(btar.Vis.Ft.Bm[idxLo].DfTra, btar.Vis.Ft.Bm[idxHi].DfTra, interpFac); Real64 rfshB = Interp(btar.Vis.Ft.Bm[idxLo].DfRef, btar.Vis.Ft.Bm[idxHi].DfRef, interpFac); if (construct.TotGlassLayers == 2) { // 2 glass layers transMult = t1 * (tfshBd * (1.0 + rfd2 * rbshd) + rfshB * rbd1 * tfshd) * td2 * surfWin.lightWellEff; } else { // 3 glass layers; blind between layers 2 and 3 - Real64 t2 = General::POLYF(COSBSun, construct.tBareVisCoef(2)); + Real64 t2 = Window::POLYF(COSBSun, construct.tBareVisCoef(2)); transMult = t1 * t2 * (tfshBd * (1.0 + rfd3 * rbshd) + rfshB * (rbd2 * tfshd + td2 * rbd1 * td2 * tfshd)) * td3 * surfWin.lightWellEff; } @@ -8684,8 +8684,8 @@ void DayltgInteriorMapIllum(EnergyPlusData &state) // based on the master construction. They need to be adjusted by the VTRatio, including: // ZoneDaylight()%DaylIllFacSky, DaylIllFacSun, DaylIllFacSunDisk; DaylBackFacSky, // DaylBackFacSun, DaylBackFacSunDisk, DaylSourceFacSky, DaylSourceFacSun, DaylSourceFacSunDisk - Real64 VTNow = General::POLYF(1.0, construction.TransVisBeamCoef); - Real64 VTMaster = General::POLYF(1.0, state.dataConstruction->Construct(construction.TCMasterConstrNum).TransVisBeamCoef); + Real64 VTNow = Window::POLYF(1.0, construction.TransVisBeamCoef); + Real64 VTMaster = Window::POLYF(1.0, state.dataConstruction->Construct(construction.TCMasterConstrNum).TransVisBeamCoef); VTRatio = VTNow / VTMaster; } } @@ -8793,7 +8793,7 @@ void DayltgInteriorMapIllum(EnergyPlusData &state) int IConstShaded = s_surf->Surface(IWin).activeShadedConstruction; if (IConstShaded > 0) { // Visible transmittance (VT) of electrochromic (EC) windows in fully dark state - Real64 VTDark = General::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac; + Real64 VTDark = Window::POLYF(1.0, state.dataConstruction->Construct(IConstShaded).TransVisBeamCoef) * surfWin.glazedFrac; if (VTDark > 0) VTMULT = s_surf->SurfWinVisTransSelected(IWin) / VTDark; } } diff --git a/src/EnergyPlus/General.hh b/src/EnergyPlus/General.hh index 31f26cdf9f4..4890eb21287 100644 --- a/src/EnergyPlus/General.hh +++ b/src/EnergyPlus/General.hh @@ -82,17 +82,6 @@ namespace General { Real64 X_0, // 1st bound of interval that contains the solution Real64 X_1); // 2nd bound of interval that contains the solution - constexpr Real64 POLYF(Real64 const X, // Cosine of angle of incidence - Array1D const &A // Polynomial coefficients - ) - { - if (X < 0.0 || X > 1.0) { - return 0.0; - } else { - return X * (A(1) + X * (A(2) + X * (A(3) + X * (A(4) + X * (A(5) + X * A(6)))))); - } - } - void MovingAvg(Array1D &DataIn, int NumItemsInAvg); void ProcessDateString(EnergyPlusData &state, diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index a4c2d6ceed3..79c91b27d9f 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -79,7 +79,6 @@ #include #include #include -#include #include #include #include @@ -3592,7 +3591,6 @@ namespace HeatBalanceManager { // Using/Aliasing using namespace DataStringGlobals; using DataSystemVariables::CheckForActualFilePath; - using General::POLYF; // POLYF ! Polynomial in cosine of angle of incidence // SUBROUTINE PARAMETER DEFINITIONS: Array1D_string const NumName(5, {"1", "2", "3", "4", "5"}); @@ -3624,26 +3622,31 @@ namespace HeatBalanceManager { int FrDivNum; // FrameDivider number Array1D WinHeight(2); // Height, width for glazing system (m) Array1D WinWidth(2); - Array1D UValCenter(2); // Center of glass U-value (W/m2-K) for glazing system - Array1D SCCenter(2); // Center of glass shading coefficient for glazing system - Array1D SHGCCenter(2); // Center of glass solar heat gain coefficient for glazing system - Array1D TVisCenter(2); // Center of glass visible transmittance for glazing system - Array1D Tsol(11); // Solar transmittance vs incidence angle; diffuse trans. - Array2D AbsSol(11, 5); // Solar absorptance vs inc. angle in each glass layer - Array1D Rfsol(11); // Front solar reflectance vs inc. angle - Array1D Rbsol(11); // Back solar reflectance vs inc. angle - Array1D Tvis(11); // Visible transmittance vs inc. angle - Array1D Rfvis(11); // Front visible reflectance vs inc. angle - Array1D Rbvis(11); // Back visible reflectance vs inc. angle - Array1D CosPhiIndepVar(10); // Cosine of incidence angle from 0 to 90 deg in 10 deg increments - int IPhi; // Incidence angle counter - Real64 Phi; // Incidence angle (deg) - Array1D CosPhi(10); // Cosine of incidence angle - Array1D tsolFit(10); // Fitted solar transmittance vs incidence angle - Array1D tvisFit(10); // Fitted visible transmittance vs incidence angle - Array1D rfsolFit(10); // Fitted solar front reflectance vs incidence angle - Array2D solabsFit(5, 10); // Fitted solar absorptance vs incidence angle for each glass layer - Array1D_string DividerType(2); // Divider type: DividedLite or Suspended + Array1D UValCenter(2); // Center of glass U-value (W/m2-K) for glazing system + Array1D SCCenter(2); // Center of glass shading coefficient for glazing system + Array1D SHGCCenter(2); // Center of glass solar heat gain coefficient for glazing system + Array1D TVisCenter(2); // Center of glass visible transmittance for glazing system + Array1D TsolTemp(Window::numPhis + 1); // Solar transmittance vs incidence angle; diffuse trans. + std::array Tsol; + Array2D AbsSolTemp(Window::maxGlassLayers, Window::numPhis + 1); // Solar absorptance vs inc. angle in each glass layer + Array1D> AbsSol(Window::maxGlassLayers); // Solar absorptance vs inc. angle in each glass layer + Array1D RfsolTemp(Window::numPhis + 1); // Front solar reflectance vs inc. angle + std::array Rfsol; + Array1D RbsolTemp(Window::numPhis + 1); // Back solar reflectance vs inc. angle + std::array Rbsol; + Array1D TvisTemp(Window::numPhis + 1); // Visible transmittance vs inc. angle + std::array Tvis; + Array1D RfvisTemp(Window::numPhis + 1); // Front visible reflectance vs inc. angle + std::array Rfvis; + Array1D RbvisTemp(Window::numPhis + 1); // Back visible reflectance vs inc. angle + std::array Rbvis; + + std::array tsolFit; // Fitted solar transmittance vs incidence angle + std::array tvisFit; // Fitted visible transmittance vs incidence angle + std::array rfsolFit; // Fitted solar front reflectance vs incidence angle + Array1D> solabsFit( + Window::maxGlassLayers); // Fitted solar absorptance vs incidence angle for each glass layer + Array1D_string DividerType(2); // Divider type: DividedLite or Suspended Real64 FrameWidth; Real64 MullionWidth; Real64 FrameProjectionOut; @@ -4134,18 +4137,6 @@ namespace HeatBalanceManager { if (NextLine.eof) goto Label1000; ++FileLineCount; - // Pre-calculate constants - for (IPhi = 1; IPhi <= 10; ++IPhi) { - CosPhiIndepVar(IPhi) = std::cos((IPhi - 1) * 10.0 * Constant::DegToRadians); - } - - // Pre-calculate constants - for (IPhi = 1; IPhi <= 10; ++IPhi) { - Phi = double(IPhi - 1) * 10.0; - CosPhi(IPhi) = std::cos(Phi * Constant::DegToRadians); - if (std::abs(CosPhi(IPhi)) < 0.0001) CosPhi(IPhi) = 0.0; - } - for (IGlSys = 1; IGlSys <= NGlSys; ++IGlSys) { ConstrNum = state.dataHeatBal->TotConstructs - NGlSys + IGlSys; auto &thisConstruct = state.dataConstruction->Construct(ConstrNum); @@ -4186,7 +4177,7 @@ namespace HeatBalanceManager { thisConstruct.AbsDiffShade = 0.0; thisConstruct.AbsDiffBackShade = 0.0; thisConstruct.ShadeAbsorpThermal = 0.0; - thisConstruct.AbsBeamShadeCoef = 0.0; + std::fill(thisConstruct.AbsBeamShadeCoef.begin(), thisConstruct.AbsBeamShadeCoef.end(), 0.0); thisConstruct.AbsDiffIn = 0.0; thisConstruct.AbsDiffOut = 0.0; thisConstruct.TransDiff = 0.0; @@ -4195,20 +4186,18 @@ namespace HeatBalanceManager { thisConstruct.ReflectSolDiffFront = 0.0; thisConstruct.ReflectVisDiffBack = 0.0; thisConstruct.ReflectVisDiffFront = 0.0; - thisConstruct.TransSolBeamCoef = 0.0; - thisConstruct.TransVisBeamCoef = 0.0; - thisConstruct.ReflSolBeamFrontCoef = 0.0; - thisConstruct.ReflSolBeamBackCoef = 0.0; + std::fill(thisConstruct.TransSolBeamCoef.begin(), thisConstruct.TransSolBeamCoef.end(), 0.0); + std::fill(thisConstruct.TransVisBeamCoef.begin(), thisConstruct.TransVisBeamCoef.end(), 0.0); + std::fill(thisConstruct.ReflSolBeamFrontCoef.begin(), thisConstruct.ReflSolBeamFrontCoef.end(), 0.0); + std::fill(thisConstruct.ReflSolBeamBackCoef.begin(), thisConstruct.ReflSolBeamBackCoef.end(), 0.0); thisConstruct.W5FrameDivider = 0; thisConstruct.TotLayers = NGlass(IGlSys) + NGaps(IGlSys); thisConstruct.TotGlassLayers = NGlass(IGlSys); thisConstruct.TotSolidLayers = NGlass(IGlSys); for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { - for (int index = 1; index <= DataSurfaces::MaxPolyCoeff; ++index) { - thisConstruct.AbsBeamCoef(Layer)(index) = 0.0; - thisConstruct.AbsBeamBackCoef(Layer)(index) = 0.0; - } + std::fill(thisConstruct.AbsBeamCoef(Layer).begin(), thisConstruct.AbsBeamCoef(Layer).end(), 0.0); + std::fill(thisConstruct.AbsBeamBackCoef(Layer).begin(), thisConstruct.AbsBeamBackCoef(Layer).end(), 0.0); } for (IGlass = 1; IGlass <= NGlass(IGlSys); ++IGlass) { @@ -4242,25 +4231,26 @@ namespace HeatBalanceManager { NextLine = W5DataFile.readLine(); if (NextLine.eof) goto Label1000; ++FileLineCount; - if (!readItem(NextLine.data.substr(5), Tsol)) { + if (!readItem(NextLine.data.substr(5), TsolTemp)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of TSol values."); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount, NextLine.data.substr(0, 100))); ErrorsFound = true; - } else if (any_lt(Tsol, 0.0) || any_gt(Tsol, 1.0)) { + } else if (any_lt(TsolTemp, 0.0) || any_gt(TsolTemp, 1.0)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of TSol values. (out of range [0,1])"); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount, NextLine.data.substr(0, 100))); ErrorsFound = true; } + for (IGlass = 1; IGlass <= NGlass(IGlSys); ++IGlass) { NextLine = W5DataFile.readLine(); ++FileLineCount; - if (!readItem(NextLine.data.substr(5), AbsSol(_, IGlass))) { + if (!readItem(NextLine.data.substr(5), AbsSolTemp(IGlass, _))) { ShowSevereError(state, format("HeatBalanceManager: SearchWindow5DataFile: Error in Read of AbsSol values. For Glass={}", IGlass)); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount, NextLine.data.substr(0, 100))); ErrorsFound = true; - } else if (any_lt(AbsSol(_, IGlass), 0.0) || any_gt(AbsSol(_, IGlass), 1.0)) { + } else if (any_lt(AbsSolTemp(IGlass, _), 0.0) || any_gt(AbsSolTemp(IGlass, _), 1.0)) { ShowSevereError( state, format("HeatBalanceManager: SearchWindow5DataFile: Error in Read of AbsSol values. (out of range [0,1]) For Glass={}", @@ -4275,48 +4265,48 @@ namespace HeatBalanceManager { DataLine(ILine) = NextLine.data; } - if (!readItem(DataLine(1).substr(5), Rfsol)) { + if (!readItem(DataLine(1).substr(5), RfsolTemp)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of RfSol values."); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 1, DataLine(1).substr(0, 100))); ErrorsFound = true; - } else if (any_lt(Rfsol, 0.0) || any_gt(Rfsol, 1.0)) { + } else if (any_lt(RfsolTemp, 0.0) || any_gt(RfsolTemp, 1.0)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of RfSol values. (out of range [0,1])"); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 1, DataLine(1).substr(0, 100))); ErrorsFound = true; } - if (!readItem(DataLine(2).substr(5), Rbsol)) { + if (!readItem(DataLine(2).substr(5), RbsolTemp)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of RbSol values."); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 2, DataLine(2).substr(0, 100))); ErrorsFound = true; - } else if (any_lt(Rbsol, 0.0) || any_gt(Rbsol, 1.0)) { + } else if (any_lt(RbsolTemp, 0.0) || any_gt(RbsolTemp, 1.0)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of RbSol values. (out of range [0,1])"); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 2, DataLine(2).substr(0, 100))); ErrorsFound = true; } - if (!readItem(DataLine(3).substr(5), Tvis)) { + if (!readItem(DataLine(3).substr(5), TvisTemp)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of Tvis values."); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 3, DataLine(3).substr(0, 100))); ErrorsFound = true; - } else if (any_lt(Tvis, 0.0) || any_gt(Tvis, 1.0)) { + } else if (any_lt(TvisTemp, 0.0) || any_gt(TvisTemp, 1.0)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of Tvis values. (out of range [0,1])"); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 3, DataLine(3).substr(0, 100))); ErrorsFound = true; } - if (!readItem(DataLine(4).substr(5), Rfvis)) { + if (!readItem(DataLine(4).substr(5), RfvisTemp)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of Rfvis values."); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 4, DataLine(4).substr(0, 100))); ErrorsFound = true; - } else if (any_lt(Rfvis, 0.0) || any_gt(Rfvis, 1.0)) { + } else if (any_lt(RfvisTemp, 0.0) || any_gt(RfvisTemp, 1.0)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of Rfvis values. (out of range [0,1])"); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 4, DataLine(4).substr(0, 100))); ErrorsFound = true; } - if (!readItem(DataLine(5).substr(5), Rbvis)) { + if (!readItem(DataLine(5).substr(5), RbvisTemp)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of Rbvis values."); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 5, DataLine(5).substr(0, 100))); ErrorsFound = true; - } else if (any_lt(Rbvis, 0.0) || any_gt(Rbvis, 1.0)) { + } else if (any_lt(RbvisTemp, 0.0) || any_gt(RbvisTemp, 1.0)) { ShowSevereError(state, "HeatBalanceManager: SearchWindow5DataFile: Error in Read of Rbvis values. (out of range [0,1])"); ShowContinueError(state, format("Line (~{}) in error (first 100 characters)={}", FileLineCount + 5, DataLine(5).substr(0, 100))); ErrorsFound = true; @@ -4330,28 +4320,44 @@ namespace HeatBalanceManager { "of above errors", DesiredConstructionName)); + for (int iPhi = 0; iPhi < Window::numPhis; ++iPhi) { + Tsol[iPhi] = TsolTemp(iPhi + 1); + Tvis[iPhi] = TvisTemp(iPhi + 1); + Rfsol[iPhi] = RfsolTemp(iPhi + 1); + Rbsol[iPhi] = RbsolTemp(iPhi + 1); + Rfvis[iPhi] = RfvisTemp(iPhi + 1); + Rbvis[iPhi] = RbvisTemp(iPhi + 1); + } + + for (IGlass = 1; IGlass <= NGlass(IGlSys); ++IGlass) { + for (int iPhi = 0; iPhi < Window::numPhis; ++iPhi) { + AbsSol(IGlass)[iPhi] = AbsSolTemp(IGlass, iPhi + 1); + } + } + // Hemis - thisConstruct.TransDiff = Tsol(11); - thisConstruct.TransDiffVis = Tvis(11); - thisConstruct.ReflectSolDiffFront = Rfsol(11); - thisConstruct.ReflectSolDiffBack = Rbsol(11); - thisConstruct.ReflectVisDiffFront = Rfvis(11); - thisConstruct.ReflectVisDiffBack = Rbvis(11); - - Window::W5LsqFit(CosPhiIndepVar, Tsol, 6, 1, 10, thisConstruct.TransSolBeamCoef); - Window::W5LsqFit(CosPhiIndepVar, Tvis, 6, 1, 10, thisConstruct.TransVisBeamCoef); - Window::W5LsqFit(CosPhiIndepVar, Rfsol, 6, 1, 10, thisConstruct.ReflSolBeamFrontCoef); + thisConstruct.TransDiff = TsolTemp(11); + thisConstruct.TransDiffVis = TvisTemp(11); + thisConstruct.ReflectSolDiffFront = RfsolTemp(11); + thisConstruct.ReflectSolDiffBack = RbsolTemp(11); + thisConstruct.ReflectVisDiffFront = RfvisTemp(11); + thisConstruct.ReflectVisDiffBack = RbvisTemp(11); + + // Using pre-calculated/hard-coded cosPhis in this module is okay. Shrug. + Window::W5LsqFit(Window::cosPhis, Tsol, thisConstruct.TransSolBeamCoef); + Window::W5LsqFit(Window::cosPhis, Tvis, thisConstruct.TransVisBeamCoef); + Window::W5LsqFit(Window::cosPhis, Rfsol, thisConstruct.ReflSolBeamFrontCoef); for (IGlass = 1; IGlass <= NGlass(IGlSys); ++IGlass) { - Window::W5LsqFit(CosPhiIndepVar, AbsSol(_, IGlass), 6, 1, 10, thisConstruct.AbsBeamCoef(IGlass)); + Window::W5LsqFit(Window::cosPhis, AbsSol(IGlass), thisConstruct.AbsBeamCoef(IGlass)); } // For comparing fitted vs. input distribution in incidence angle - for (IPhi = 1; IPhi <= 10; ++IPhi) { - tsolFit(IPhi) = POLYF(CosPhi(IPhi), thisConstruct.TransSolBeamCoef); - tvisFit(IPhi) = POLYF(CosPhi(IPhi), thisConstruct.TransVisBeamCoef); - rfsolFit(IPhi) = POLYF(CosPhi(IPhi), thisConstruct.ReflSolBeamFrontCoef); + for (int iPhi = 0; iPhi < Window::numPhis; ++iPhi) { + tsolFit[iPhi] = Window::POLYF(Window::cosPhis[iPhi], thisConstruct.TransSolBeamCoef); + tvisFit[iPhi] = Window::POLYF(Window::cosPhis[iPhi], thisConstruct.TransVisBeamCoef); + rfsolFit[iPhi] = Window::POLYF(Window::cosPhis[iPhi], thisConstruct.ReflSolBeamFrontCoef); for (IGlass = 1; IGlass <= NGlass(IGlSys); ++IGlass) { - solabsFit(IGlass, IPhi) = POLYF(CosPhi(IPhi), thisConstruct.AbsBeamCoef(IGlass)); + solabsFit(IGlass)[iPhi] = Window::POLYF(Window::cosPhis[iPhi], thisConstruct.AbsBeamCoef(IGlass)); } } // end diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 385ca236569..656d30a38a3 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -88,7 +88,6 @@ #include #include #include -#include #include #include #include @@ -2427,7 +2426,6 @@ void InitSolarHeatGains(EnergyPlusData &state) // Using/Aliasing using Dayltg::TransTDD; - using General::POLYF; using SolarShading::CalcInteriorSolarDistribution; using namespace DataWindowEquivalentLayer; using SolarShading::SurfaceScheduledSolarInc; @@ -3341,13 +3339,13 @@ void InitSolarHeatGains(EnergyPlusData &state) // Beam solar on outside of frame FrIncSolarOut += (BeamFrHorFaceInc + BeamFrVertFaceInc) * FrProjOut; if (FrProjIn > 0.0) { - Real64 TransGl = General::POLYF(CosInc, thisConstruct.TransSolBeamCoef); + Real64 TransGl = Window::POLYF(CosInc, thisConstruct.TransSolBeamCoef); TransDiffGl = thisConstruct.TransDiff; if (ShadeFlag == DataSurfaces::WinShadingType::SwitchableGlazing) { // Switchable glazing Real64 SwitchFac = state.dataSurface->SurfWinSwitchingFactor(SurfNum); int ConstrNumSh = Surface(SurfNum).activeShadedConstruction; auto const &constructionSh = state.dataConstruction->Construct(ConstrNumSh); - Real64 TransGlSh = General::POLYF(CosInc, constructionSh.TransSolBeamCoef); + Real64 TransGlSh = Window::POLYF(CosInc, constructionSh.TransSolBeamCoef); TransGl = Window::InterpSw(SwitchFac, TransGl, TransGlSh); Real64 TransDiffGlSh = constructionSh.TransDiff; TransDiffGl = Window::InterpSw(SwitchFac, TransDiffGl, TransDiffGlSh); @@ -3433,14 +3431,14 @@ void InitSolarHeatGains(EnergyPlusData &state) DivIncSolarOutBm = BeamFaceInc + BeamDivHorFaceInc + BeamDivVertFaceInc; DivIncSolarOutDif = DifSolarFaceInc * (1.0 + state.dataSurface->SurfWinProjCorrDivOut(SurfNum)); if (DivProjIn > 0.0) { - Real64 TransGl = General::POLYF(CosInc, thisConstruct.TransSolBeamCoef); + Real64 TransGl = Window::POLYF(CosInc, thisConstruct.TransSolBeamCoef); Real64 TransDiffGl = thisConstruct.TransDiff; // Diffuse solar transmittance if (ShadeFlag == DataSurfaces::WinShadingType::SwitchableGlazing) { // Switchable glazing Real64 SwitchFac = state.dataSurface->SurfWinSwitchingFactor(SurfNum); int ConstrNumSh = Surface(SurfNum).activeShadedConstruction; auto const &constructionSh = state.dataConstruction->Construct(ConstrNumSh); - Real64 TransGlSh = General::POLYF(CosInc, constructionSh.TransSolBeamCoef); + Real64 TransGlSh = Window::POLYF(CosInc, constructionSh.TransSolBeamCoef); // Outer glass solar trans, refl, absorptance if switched TransGl = Window::InterpSw(SwitchFac, TransGl, TransGlSh); Real64 TransDiffGlSh = constructionSh.TransDiff; diff --git a/src/EnergyPlus/SolarReflectionManager.cc b/src/EnergyPlus/SolarReflectionManager.cc index 8cbecf1b3c9..588fa58cd75 100644 --- a/src/EnergyPlus/SolarReflectionManager.cc +++ b/src/EnergyPlus/SolarReflectionManager.cc @@ -891,9 +891,6 @@ namespace SolarReflectionManager { // REFERENCES: // na - // Using/Aliasing - using General::POLYF; - // Locals // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Array1D ReflBmToDiffSolObs(state.dataSurface->MaxRecPts); // Irradiance at a receiving point for @@ -1034,7 +1031,7 @@ namespace SolarReflectionManager { state.dataSolarReflectionManager->SpecReflectance = 0.0; if (state.dataSurface->Surface(ReflSurfNum).Class == SurfaceClass::Window) { state.dataSolarReflectionManager->ConstrNumRefl = state.dataSurface->Surface(ReflSurfNum).Construction; - state.dataSolarReflectionManager->SpecReflectance = POLYF( + state.dataSolarReflectionManager->SpecReflectance = Window::POLYF( std::abs(state.dataSolarReflectionManager->CosIncAngRefl), state.dataConstruction->Construct(state.dataSolarReflectionManager->ConstrNumRefl).ReflSolBeamFrontCoef); } @@ -1043,7 +1040,7 @@ namespace SolarReflectionManager { state.dataSolarReflectionManager->ConstrNumRefl = state.dataSurface->SurfShadowGlazingConstruct(ReflSurfNum); state.dataSolarReflectionManager->SpecReflectance = state.dataSurface->SurfShadowGlazingFrac(ReflSurfNum) * - POLYF( + Window::POLYF( std::abs(state.dataSolarReflectionManager->CosIncAngRefl), state.dataConstruction->Construct(state.dataSolarReflectionManager->ConstrNumRefl).ReflSolBeamFrontCoef); } diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 9ffe7a922e9..fb2dab04c3f 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -80,7 +80,7 @@ #include #include #include -#include +// #include #include #include #include @@ -6323,7 +6323,6 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) // surfaces and interior solar radiation distribution using Dayltg::TransTDD; - using General::POLYF; using ScheduleManager::GetCurrentScheduleValue; using namespace DataWindowEquivalentLayer; @@ -6509,7 +6508,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) int NGlass = thisConstruct.TotGlassLayers; Array1D AbWin(NGlass); // Factor for front beam radiation absorbed in window glass layer for (int Lay = 1; Lay <= NGlass; ++Lay) { - AbWin(Lay) = POLYF(CosInc, thisConstruct.AbsBeamCoef(Lay)) * CosInc * SunLitFract * + AbWin(Lay) = Window::POLYF(CosInc, thisConstruct.AbsBeamCoef(Lay)) * CosInc * SunLitFract * s_surf->SurfaceWindow(SurfNum).OutProjSLFracMult[state.dataGlobal->HourOfDay]; } if (!IS_SHADED_NO_GLARE_CTRL(ShadeFlag)) { @@ -6534,13 +6533,13 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) auto const &thisConstructSh = state.dataConstruction->Construct(ConstrNumSh); // Shade or switchable glazing on for (int Lay = 1; Lay <= NGlass; ++Lay) { - AbWinSh(Lay) = POLYF(CosInc, thisConstructSh.AbsBeamCoef(Lay)) * CosInc * FracSunLit; + AbWinSh(Lay) = Window::POLYF(CosInc, thisConstructSh.AbsBeamCoef(Lay)) * CosInc * FracSunLit; ADiffWinSh(Lay) = thisConstructSh.AbsDiff(Lay); } if (ShadeFlag == WinShadingType::IntShade) { // Exterior beam absorbed by INTERIOR SHADE // Note that AbsBeamShadeCoef includes effect of shade/glazing inter-reflection - Real64 AbsShade = POLYF(CosInc, - thisConstructSh.AbsBeamShadeCoef); // Interior shade or blind beam solar absorptance + Real64 AbsShade = Window::POLYF(CosInc, + thisConstructSh.AbsBeamShadeCoef); // Interior shade or blind beam solar absorptance state.dataSolarShading->SurfWinExtBeamAbsByShadFac(SurfNum) = (AbsShade * CosInc * SunLitFract * InOutProjSLFracMult + s_surf->SurfWinOutsRevealDiffOntoGlazing(SurfNum) * thisConstructSh.AbsDiffShade) * @@ -6549,7 +6548,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } else if (ShadeFlag == WinShadingType::ExtShade) { // Exterior beam absorbed by EXTERIOR SHADE state.dataSolarShading->SurfWinExtBeamAbsByShadFac(SurfNum) = thisConstructSh.AbsDiffShade * CosInc * SunLitFract; } else if (ShadeFlag == WinShadingType::BGShade) { // Exterior beam absorbed by BETWEEN-GLASS SHADE - Real64 AbsShade = POLYF(CosInc, thisConstructSh.AbsBeamShadeCoef); + Real64 AbsShade = Window::POLYF(CosInc, thisConstructSh.AbsBeamShadeCoef); state.dataSolarShading->SurfWinExtBeamAbsByShadFac(SurfNum) = AbsShade * CosInc * SunLitFract + s_surf->SurfWinOutsRevealDiffOntoGlazing(SurfNum) * thisConstructSh.AbsDiffShade; @@ -6560,7 +6559,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) ProfAng = surfShade.blind.profAng; if (ShadeFlag == WinShadingType::IntBlind) { // Interior blind on - Real64 TBmBm = POLYF(CosInc, thisConstruct.TransSolBeamCoef); + Real64 TBmBm = Window::POLYF(CosInc, thisConstruct.TransSolBeamCoef); Real64 RGlDiffBack = thisConstruct.ReflectSolDiffBack; // Glazing system back diffuse solar reflectance Real64 RhoBlFront = FrontBeamDiffRefl; // Blind solar front beam reflectance Real64 RhoBlDiffFront = FrontDiffDiffRefl; // Blind solar front diffuse reflectance @@ -6597,8 +6596,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RhoBlBack = BackBeamDiffRefl; // Blind solar back beam-diffuse reflectance Real64 RhoBlDiffBack = BackDiffDiffRefl; // Blind solar back diffuse reflectance Real64 RGlFront = - POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Glazing system solar front beam-beam reflectance - Real64 RGlDiffFront = thisConstruct.ReflectSolDiffFront; // Glazing system front diffuse solar reflectance + Window::POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Glazing system solar front beam-beam reflectance + Real64 RGlDiffFront = thisConstruct.ReflectSolDiffFront; // Glazing system front diffuse solar reflectance for (int Lay = 1; Lay <= NGlass; ++Lay) { Real64 ADiffWin = thisConstruct.AbsDiff(Lay); // Diffuse solar absorptance of glass layer, bare window Real64 AGlDiffFront = thisConstruct.AbsDiff(Lay); // Glass layer front diffuse solar absorptance @@ -6649,9 +6648,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RScDifBack = screen->DfRef; Real64 RGlFront = - POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Glazing system solar front beam-beam reflectance - Real64 RGlDiffFront = thisConstruct.ReflectSolDiffFront; // Glazing system front diffuse solar reflectance - Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass + Window::POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Glazing system solar front beam-beam reflectance + Real64 RGlDiffFront = thisConstruct.ReflectSolDiffFront; // Glazing system front diffuse solar reflectance + Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass // Reduce the bare window absorbed beam by the screen beam transmittance and then account for // interreflections for (int Lay = 1; Lay <= NGlass; ++Lay) { @@ -6678,9 +6677,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RScDifBack = screen->DfRef; Real64 RGlFront = - POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Glazing system solar front beam-beam reflectance - Real64 RGlDiffFront = thisConstruct.ReflectSolDiffFront; // Glazing system front diffuse solar reflectance - Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass + Window::POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Glazing system solar front beam-beam reflectance + Real64 RGlDiffFront = thisConstruct.ReflectSolDiffFront; // Glazing system front diffuse solar reflectance + Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass // Reduce the bare window absorbed beam by the screen beam transmittance and then account for // interreflections for (int Lay = 1; Lay <= NGlass; ++Lay) { @@ -6700,18 +6699,18 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } else if (ShadeFlag == WinShadingType::BGBlind) { // Between-glass blind o // Isolated glass and blind properties at current incidence angle, profile angle and slat angle - Real64 t1 = POLYF(CosInc, - thisConstruct.tBareSolCoef(1)); // Bare-glass beam solar transmittance for glass layers 1,2 and 3 - Real64 t2 = POLYF(CosInc, thisConstruct.tBareSolCoef(2)); + Real64 t1 = Window::POLYF(CosInc, + thisConstruct.tBareSolCoef(1)); // Bare-glass beam solar trans for glass layers 1,2 and 3 + Real64 t2 = Window::POLYF(CosInc, thisConstruct.tBareSolCoef(2)); Real64 af1 = - POLYF(CosInc, - thisConstruct.afBareSolCoef(1)); // Bare-glass beam solar front absorptance for glass layers 1,2 and 3 - Real64 af2 = POLYF(CosInc, thisConstruct.afBareSolCoef(2)); - Real64 ab1 = - POLYF(CosInc, - thisConstruct.abBareSolCoef(1)); // Bare-glass beam solar back absorptance for glass layers 1,2 and 3 - Real64 ab2 = POLYF(CosInc, thisConstruct.abBareSolCoef(2)); - Real64 rf2 = POLYF(CosInc, thisConstruct.rfBareSolCoef(2)); + Window::POLYF(CosInc, + thisConstruct.afBareSolCoef(1)); // Bare-glass beam solar front abs for glass layers 1,2 and 3 + Real64 af2 = Window::POLYF(CosInc, thisConstruct.afBareSolCoef(2)); + Real64 ab1 = Window::POLYF( + CosInc, + thisConstruct.abBareSolCoef(1)); // Bare-glass beam solar back absorptance for glass layers 1,2 and 3 + Real64 ab2 = Window::POLYF(CosInc, thisConstruct.abBareSolCoef(2)); + Real64 rf2 = Window::POLYF(CosInc, thisConstruct.rfBareSolCoef(2)); Real64 td1 = thisConstruct.tBareSolDiff(1); // Bare-glass diffuse solar transmittance for glass layers 1,2 and 3 Real64 td2 = thisConstruct.tBareSolDiff(2); Real64 afd1 = thisConstruct.afBareSolDiff(1); // Bare-glass diffuse solar front absorptance for glass layers 1,2 and 3 @@ -6756,8 +6755,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } else if (NGlass == 3) { Real64 t1t2 = t1 * t2; // t1*t2 Real64 td1td2 = td1 * td2; - Real64 af3 = POLYF(CosInc, thisConstruct.afBareSolCoef(3)); - Real64 rf3 = POLYF(CosInc, thisConstruct.rfBareSolCoef(3)); + Real64 af3 = Window::POLYF(CosInc, thisConstruct.afBareSolCoef(3)); + Real64 rf3 = Window::POLYF(CosInc, thisConstruct.rfBareSolCoef(3)); Real64 afd3 = thisConstruct.afBareSolDiff(3); Real64 rfd3 = thisConstruct.rfBareSolDiff(3); Real64 td2 = thisConstruct.tBareSolDiff(2); @@ -7001,9 +7000,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) state.dataDaylightingDevicesData->TDDPipe(PipeNum).TransSolBeam = TBmDif; // Report variable } else if (s_surf->SurfWinWindowModelType(SurfNum) == WindowModel::Detailed) { // Regular window if (!s_surf->SurfWinSolarDiffusing(SurfNum)) { // Clear glazing - TBmBm = POLYF(CosInc, thisConstruct.TransSolBeamCoef); //[-] + TBmBm = Window::POLYF(CosInc, thisConstruct.TransSolBeamCoef); //[-] } else { // Diffusing glazing - TBmDif = POLYF(CosInc, thisConstruct.TransSolBeamCoef); //[-] + TBmDif = Window::POLYF(CosInc, thisConstruct.TransSolBeamCoef); //[-] } } else if (s_surf->SurfWinWindowModelType(SurfNum) == WindowModel::BSDF) { // Need to check what effect, if any, defining these here has @@ -7047,10 +7046,10 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) if (s_surf->SurfWinWindowModelType(SurfNum) != WindowModel::EQL) { if (IS_SHADED_NO_GLARE_CTRL(ShadeFlag)) { // Shade or screen or blind on, or switchable glazing - // (note in the following that diffusing glass is not allowed in a window with shade, blind or switchable glazing) + // (note in the following that diffusing glass is not oallowed in a window with shade, blind or switchable glazing) if (ANY_SHADE(ShadeFlag) || ShadeFlag == WinShadingType::SwitchableGlazing) { // Shade on or switchable glazing - TBmAllShBlSc = POLYF(CosInc, thisConstructSh.TransSolBeamCoef); + TBmAllShBlSc = Window::POLYF(CosInc, thisConstructSh.TransSolBeamCoef); } else { // Blind or Screen on Real64 TScBmDif; // Beam-diffuse solar transmittance of screen @@ -7084,8 +7083,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RScBack = BilinearInterp(b11.RefSolFront, b12.RefSolFront, b21.RefSolFront, b22.RefSolFront, coeffs); Real64 RScDifBack = screen->DfRef; - Real64 RGlBmFr = POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Beam front reflectance of glass - Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass + Real64 RGlBmFr = Window::POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Beam front reflectance of glass + Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass // beam transmittance (written in subroutine CalcScreenTransmittance each time step) TScBmBm = BilinearInterp(b11.BmTrans, b12.BmTrans, b21.BmTrans, b22.BmTrans, coeffs); TBmBmSc = TBmBm * TScBmBm; @@ -7106,8 +7105,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RScBack = btar.RefSolFront; Real64 RScDifBack = screen->DfRef; - Real64 RGlBmFr = POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Beam front reflectance of glass - Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass + Real64 RGlBmFr = Window::POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); // Beam front reflectance of glass + Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // Diffuse front reflectance of glass // beam transmittance (written in subroutine CalcScreenTransmittance each time step) TScBmBm = btar.BmTrans; TBmBmSc = TBmBm * TScBmBm; @@ -7140,7 +7139,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } else if (ShadeFlag == WinShadingType::ExtBlind) { Real64 RhoBlBmDifBk = BackBeamDiffRefl; // Beam-diffuse back reflectance of blind Real64 RhoBlDifDifBk = BackDiffDiffRefl; // Diffuse-diffuse back reflectance of blind - Real64 RGlBmFr = POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); + Real64 RGlBmFr = Window::POLYF(CosInc, thisConstruct.ReflSolBeamFrontCoef); Real64 RGlDifFr = thisConstruct.ReflectSolDiffFront; // beam-beam and diffuse transmittance of exterior beam TBmBmBl = TBmBm * TBlBmBm; @@ -7157,11 +7156,11 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 rfshd = FrontDiffDiffRefl; Real64 rbshd = BackDiffDiffRefl; Real64 tfshBd = FrontBeamDiffTrans; - Real64 t1 = POLYF(CosInc, thisConstruct.tBareSolCoef(1)); - Real64 t2 = POLYF(CosInc, thisConstruct.tBareSolCoef(2)); + Real64 t1 = Window::POLYF(CosInc, thisConstruct.tBareSolCoef(1)); + Real64 t2 = Window::POLYF(CosInc, thisConstruct.tBareSolCoef(2)); Real64 tfshBB = surfShade.blind.bmBmTrans; if (NGlass == 2) { - Real64 rf2 = POLYF(CosInc, thisConstruct.rfBareSolCoef(2)); + Real64 rf2 = Window::POLYF(CosInc, thisConstruct.rfBareSolCoef(2)); Real64 rfshB = FrontBeamDiffRefl; Real64 rfd2 = thisConstruct.rfBareSolDiff(2); TBmBmBl = t1 * tfshBB * t2; @@ -7169,9 +7168,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) t1 * (tfshBB * rf2 * rbshB + tfshBd * (1.0 + rfd2 * rbshd) + rfshB * rbd1 * rfshd) * td2; } else { // NGlass = 3 Real64 t1t2 = t1 * t2; - Real64 t3 = POLYF(CosInc, thisConstruct.tBareSolCoef(3)); + Real64 t3 = Window::POLYF(CosInc, thisConstruct.tBareSolCoef(3)); Real64 td3 = thisConstruct.tBareSolDiff(3); - Real64 rf3 = POLYF(CosInc, thisConstruct.rfBareSolCoef(3)); + Real64 rf3 = Window::POLYF(CosInc, thisConstruct.rfBareSolCoef(3)); Real64 rbd2 = thisConstruct.rbBareSolDiff(2); Real64 rfd3 = thisConstruct.rfBareSolDiff(3); Real64 tfshd = FrontDiffDiffTrans; @@ -7390,8 +7389,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) auto &surfShadeBack = s_surf->surfShades(BackSurfNum); int ConstrNumBack = s_surf->SurfActiveConstruction(BackSurfNum); + auto const &constrBack = state.dataConstruction->Construct(ConstrNumBack); - int NBackGlass = state.dataConstruction->Construct(ConstrNumBack).TotGlassLayers; + int NBackGlass = constrBack.TotGlassLayers; // Irradiated (overlap) area for this back surface, projected onto window plane // (includes effect of shadowing on exterior window) Real64 AOverlap = @@ -7399,7 +7399,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) // Back surface area irradiated by beam solar from an exterior window, projected onto window plane Real64 BOverlap = TBm * AOverlap * CosInc; //[m2] // AOverlap multiplied by exterior window beam transmittance and cosine of incidence angle - if (state.dataConstruction->Construct(ConstrNumBack).TransDiff <= 0.0) { + if (constrBack.TransDiff <= 0.0) { // Back surface is opaque interior or exterior wall // Interior solar absorptance of opaque surface @@ -7434,10 +7434,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) // or interior window WITHOUT SHADING this timestep if (NOT_SHADED(ShadeFlagBack)) { for (int Lay = 1; Lay <= NBackGlass; ++Lay) { - state.dataSolarShading->SurfWinAbsBeam(Lay) = - POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).AbsBeamBackCoef(Lay)); + state.dataSolarShading->SurfWinAbsBeam(Lay) = Window::POLYF(CosIncBack, constrBack.AbsBeamBackCoef(Lay)); } - TransBeamWin = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).TransSolBeamCoef); + TransBeamWin = Window::POLYF(CosIncBack, constrBack.TransSolBeamCoef); } // Interior beam absorptance of glass layers and beam transmittance @@ -7445,9 +7444,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) if (ANY_SHADE(ShadeFlagBack)) { for (int Lay = 1; Lay <= state.dataConstruction->Construct(ConstrNumBackSh).TotGlassLayers; ++Lay) { state.dataSolarShading->SurfWinAbsBeam(Lay) = - POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).AbsBeamBackCoef(Lay)); + Window::POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).AbsBeamBackCoef(Lay)); } - TransBeamWin = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).TransSolBeamCoef); + TransBeamWin = Window::POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).TransSolBeamCoef); } // Interior beam absorbed by INTERIOR SHADE of back exterior window @@ -7460,15 +7459,14 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) // Interior beam absorbed by EXTERIOR SHADE of back exterior window } else if (ShadeFlagBack == WinShadingType::ExtShade) { - Real64 RGlFront = state.dataConstruction->Construct(ConstrNumBack).ReflectSolDiffFront; + Real64 RGlFront = constrBack.ReflectSolDiffFront; auto const *matSh = s_mat->materials(state.dataConstruction->Construct(ConstrNumBackSh).LayerPoint(1)); auto const *matFenSh = dynamic_cast(matSh); assert(matFenSh != nullptr); Real64 AbsSh = matFenSh->AbsorpSolar; Real64 RhoSh = 1.0 - AbsSh - matFenSh->Trans; - Real64 AShBack = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).TransSolBeamCoef) * AbsSh / - (1.0 - RGlFront * RhoSh); + Real64 AShBack = Window::POLYF(CosIncBack, constrBack.TransSolBeamCoef) * AbsSh / (1.0 - RGlFront * RhoSh); BABSZone += BOverlap * AShBack; backSurfBeamSolInTrans += BOverlap * AShBack; state.dataSolarShading->SurfWinIntBeamAbsByShadFac(BackSurfNum) = @@ -7476,11 +7474,11 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) // Interior beam absorbed by BETWEEN-GLASS SHADE of back exterior window } else if (ShadeFlagBack == WinShadingType::BGShade) { - Real64 rbd1k = state.dataConstruction->Construct(ConstrNumBack).rbBareSolDiff(1); - Real64 rfd2k = state.dataConstruction->Construct(ConstrNumBack).rfBareSolDiff(2); + Real64 rbd1k = constrBack.rbBareSolDiff(1); + Real64 rfd2k = constrBack.rfBareSolDiff(2); Real64 AShBack; // System shade absorptance for interior beam solar if (NBackGlass == 2) { - Real64 t2k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).tBareSolCoef(2)); + Real64 t2k = Window::POLYF(CosIncBack, constrBack.tBareSolCoef(2)); auto const *matShade = dynamic_cast( s_mat->materials(state.dataConstruction->Construct(ConstrNumBackSh).LayerPoint(3))); assert(matShade != nullptr); @@ -7489,10 +7487,10 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 AbsSh = min(1.0, max(0.0, 1 - TrSh - RhoSh)); // Shade material solar absorptance AShBack = t2k * (1 + RhoSh * rfd2k + TrSh * rbd1k) * AbsSh; } else { // NBackGlass = 3 - Real64 t3k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).tBareSolCoef(3)); - Real64 td2k = state.dataConstruction->Construct(ConstrNumBack).tBareSolDiff(2); - Real64 rbd2k = state.dataConstruction->Construct(ConstrNumBack).rbBareSolDiff(2); - Real64 rfd3k = state.dataConstruction->Construct(ConstrNumBack).rfBareSolDiff(3); + Real64 t3k = Window::POLYF(CosIncBack, constrBack.tBareSolCoef(3)); + Real64 td2k = constrBack.tBareSolDiff(2); + Real64 rbd2k = constrBack.rbBareSolDiff(2); + Real64 rfd3k = constrBack.rfBareSolDiff(3); auto const *matShade = dynamic_cast( s_mat->materials(state.dataConstruction->Construct(ConstrNumBackSh).LayerPoint(5))); assert(matShade != nullptr); @@ -7522,7 +7520,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) int profIdxHiBack = surfShadeBack.blind.profAngIdxHi; Real64 profInterpFacBack = surfShadeBack.blind.profAngInterpFac; - Real64 TGlBmBack = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).TransSolBeamCoef); + Real64 TGlBmBack = Window::POLYF(CosIncBack, constrBack.TransSolBeamCoef); Real64 TBlBmBmBack = matBlindBack->BeamBeamTrans(profAngBack, Constant::Pi - slatAngBack); // Blind solar back beam-diffuse transmittance @@ -7542,25 +7540,21 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Interp(btar.Sol.Bk.Bm[profIdxLoBack].Abs, btar.Sol.Bk.Bm[profIdxHiBack].Abs, profInterpFacBack); Real64 RhoBlDiffFront = FrontDiffDiffRefl; // Glazing system solar back beam-beam reflectance - Real64 RGlBack = POLYF(CosIncBack, - state.dataConstruction->Construct(ConstrNumBack) - .ReflSolBeamBackCoef); // Glazing system back diffuse solar reflectance - Real64 RGlDiffBack = state.dataConstruction->Construct(ConstrNumBack).ReflectSolDiffBack; + Real64 RGlBack = Window::POLYF( + CosIncBack, constrBack.ReflSolBeamBackCoef); // Glazing system back diffuse solar reflectance + Real64 RGlDiffBack = constrBack.ReflectSolDiffBack; for (int Lay = 1; Lay <= NBackGlass; ++Lay) { - Real64 AbWinBack = - POLYF(CosIncBack, - state.dataConstruction->Construct(ConstrNumBack) - .AbsBeamBackCoef(Lay)); // Factor for back beam radiation absorbed in window glass layer - Real64 AGlDiffBack = state.dataConstruction->Construct(ConstrNumBack) - .AbsDiffBack(Lay); // Glass layer back diffuse solar absorptance + Real64 AbWinBack = Window::POLYF( + CosIncBack, + constrBack.AbsBeamBackCoef(Lay)); // Factor for back beam radiation absorbed in window glass layer + Real64 AGlDiffBack = constrBack.AbsDiffBack(Lay); // Glass layer back diffuse solar absorptance state.dataSolarShading->SurfWinAbsBeam(Lay) = TBlBmBmBack * AbWinBack + ((TBlBmBmBack * RGlBack * RhoBlFront + TBlBmDiffBack) * AGlDiffBack / (1.0 - RGlDiffBack * RhoBlDiffFront)); } // Interior beam transmitted by exterior back window with INTERIOR BLIND - Real64 TGlDif = - state.dataConstruction->Construct(ConstrNumBack).TransDiff; // Bare diffuse transmittance of back window + Real64 TGlDif = constrBack.TransDiff; // Bare diffuse transmittance of back window TransBeamWin = TBlBmBmBack * (TGlBmBack + TGlDif * RGlBack * RhoBlFront / (1.0 - RGlDiffBack * RhoBlDiffFront)) + TBlBmDiffBack * TGlDif / (1.0 - RGlDiffBack * RhoBlDiffFront); @@ -7593,9 +7587,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Interp(btar.Sol.Bk.Bm[profIdxLoBack].Abs, btar.Sol.Bk.Bm[profIdxHiBack].Abs, profInterpFacBack); for (int Lay = 1; Lay <= NBackGlass; ++Lay) { - Real64 AbWinBack = - POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).AbsBeamBackCoef(Lay)); - Real64 AGlDiffFront = state.dataConstruction->Construct(ConstrNumBack).AbsDiff(Lay); + Real64 AbWinBack = Window::POLYF(CosIncBack, constrBack.AbsBeamBackCoef(Lay)); + Real64 AGlDiffFront = constrBack.AbsDiff(Lay); state.dataSolarShading->SurfWinAbsBeam(Lay) = AbWinBack + (TGlBmBack * AGlDiffFront * RhoBlBack / (1.0 - RhoBlBack * RGlDiffFront)); } @@ -7617,21 +7610,21 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } else { // ShadeFlagBack == BGBlindOn - Real64 t1k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).tBareSolCoef(1)); - Real64 t2k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).tBareSolCoef(2)); - Real64 af2k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).afBareSolCoef(2)); - Real64 ab1k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).abBareSolCoef(1)); - Real64 ab2k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).abBareSolCoef(2)); - Real64 rb1k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).rbBareSolCoef(1)); - Real64 rb2k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).rbBareSolCoef(2)); - Real64 td1k = state.dataConstruction->Construct(ConstrNumBack).tBareSolDiff(1); - Real64 td2k = state.dataConstruction->Construct(ConstrNumBack).tBareSolDiff(2); - Real64 afd2k = state.dataConstruction->Construct(ConstrNumBack).afBareSolDiff(2); - Real64 abd1k = state.dataConstruction->Construct(ConstrNumBack).abBareSolDiff(1); - Real64 abd2k = state.dataConstruction->Construct(ConstrNumBack).abBareSolDiff(2); - Real64 rfd2k = state.dataConstruction->Construct(ConstrNumBack).rfBareSolDiff(2); - Real64 rbd1k = state.dataConstruction->Construct(ConstrNumBack).rbBareSolDiff(1); - Real64 rbd2k = state.dataConstruction->Construct(ConstrNumBack).rbBareSolDiff(2); + Real64 t1k = Window::POLYF(CosIncBack, constrBack.tBareSolCoef(1)); + Real64 t2k = Window::POLYF(CosIncBack, constrBack.tBareSolCoef(2)); + Real64 af2k = Window::POLYF(CosIncBack, constrBack.afBareSolCoef(2)); + Real64 ab1k = Window::POLYF(CosIncBack, constrBack.abBareSolCoef(1)); + Real64 ab2k = Window::POLYF(CosIncBack, constrBack.abBareSolCoef(2)); + Real64 rb1k = Window::POLYF(CosIncBack, constrBack.rbBareSolCoef(1)); + Real64 rb2k = Window::POLYF(CosIncBack, constrBack.rbBareSolCoef(2)); + Real64 td1k = constrBack.tBareSolDiff(1); + Real64 td2k = constrBack.tBareSolDiff(2); + Real64 afd2k = constrBack.afBareSolDiff(2); + Real64 abd1k = constrBack.abBareSolDiff(1); + Real64 abd2k = constrBack.abBareSolDiff(2); + Real64 rfd2k = constrBack.rfBareSolDiff(2); + Real64 rbd1k = constrBack.rbBareSolDiff(1); + Real64 rbd2k = constrBack.rbBareSolDiff(2); Real64 tfshBBk = matBlindBack->BeamBeamTrans(profAngBack, slatAngBack); Real64 tbshBBk = matBlindBack->BeamBeamTrans(profAngBack, Constant::Pi - slatAngBack); @@ -7669,11 +7662,11 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) // Interior beam absorbed by BLIND on exterior back window with BETWEEN-GLASS BLIND ABlBack = t2k * (abshBk + tbshBBk * rb1k * afshBk + rbshBk * rfd2k * abshdk + tbshBdk * rbd1k * afshdk); } else { // NBackGlass = 3 - Real64 t3k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).tBareSolCoef(3)); - Real64 af3k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).afBareSolCoef(3)); - Real64 ab3k = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).abBareSolCoef(3)); - Real64 afd3k = state.dataConstruction->Construct(ConstrNumBack).afBareSolDiff(3); - Real64 rfd3k = state.dataConstruction->Construct(ConstrNumBack).rfBareSolDiff(3); + Real64 t3k = Window::POLYF(CosIncBack, constrBack.tBareSolCoef(3)); + Real64 af3k = Window::POLYF(CosIncBack, constrBack.afBareSolCoef(3)); + Real64 ab3k = Window::POLYF(CosIncBack, constrBack.abBareSolCoef(3)); + Real64 afd3k = constrBack.afBareSolDiff(3); + Real64 rfd3k = constrBack.rfBareSolDiff(3); state.dataSolarShading->SurfWinAbsBeam(3) = ab3k + t3k * tbshBBk * (rb2k + t2k * rb1k * t2k) * tfshBBk * af3k + t3k * @@ -7706,8 +7699,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } else if (ShadeFlagBack == WinShadingType::ExtScreen) { // Interior beam absorptance of GLASS LAYERS of exterior back window with EXTERIOR SCREEN - Real64 TGlBmBack = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).TransSolBeamCoef); - Real64 RGlDiffFront = state.dataConstruction->Construct(ConstrNumBack).ReflectSolDiffFront; + Real64 TGlBmBack = Window::POLYF(CosIncBack, constrBack.TransSolBeamCoef); + Real64 RGlDiffFront = constrBack.ReflectSolDiffFront; auto const *screen = dynamic_cast(s_mat->materials(ScNum)); assert(screen != nullptr); @@ -7736,8 +7729,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RScBack = BilinearInterp(b11.RefSolFront, b12.RefSolFront, b21.RefSolFront, b22.RefSolFront, coeffs); Real64 RScDifBack = screen->DfRef; for (int Lay = 1; Lay <= NBackGlass; ++Lay) { - Real64 AbWinBack = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).AbsBeamBackCoef(Lay)); - Real64 AGlDiffFront = state.dataConstruction->Construct(ConstrNumBack).AbsDiff(Lay); + Real64 AbWinBack = Window::POLYF(CosIncBack, constrBack.AbsBeamBackCoef(Lay)); + Real64 AGlDiffFront = constrBack.AbsDiff(Lay); state.dataSolarShading->SurfWinAbsBeam(Lay) = AbWinBack + (TGlBmBack * AGlDiffFront * RScBack / (1.0 - RScDifBack * RGlDiffFront)); } @@ -7771,8 +7764,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 RScBack = btar.RefSolFront; Real64 RScDifBack = screen->DfRef; for (int Lay = 1; Lay <= NBackGlass; ++Lay) { - Real64 AbWinBack = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBack).AbsBeamBackCoef(Lay)); - Real64 AGlDiffFront = state.dataConstruction->Construct(ConstrNumBack).AbsDiff(Lay); + Real64 AbWinBack = Window::POLYF(CosIncBack, constrBack.AbsBeamBackCoef(Lay)); + Real64 AGlDiffFront = constrBack.AbsDiff(Lay); state.dataSolarShading->SurfWinAbsBeam(Lay) = AbWinBack + (TGlBmBack * AGlDiffFront * RScBack / (1.0 - RScDifBack * RGlDiffFront)); } @@ -7805,12 +7798,14 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) Real64 SwitchFac = s_surf->SurfWinSwitchingFactor(SurfNum); // Switching factor for a window Real64 AbsBeamWinSh; // Glass layer beam solar absorptance of a shaded window for (int Lay = 1; Lay <= NBackGlass; ++Lay) { - AbsBeamWinSh = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).AbsBeamBackCoef(Lay)); + AbsBeamWinSh = + Window::POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).AbsBeamBackCoef(Lay)); state.dataSolarShading->SurfWinAbsBeam(Lay) = Window::InterpSw(SwitchFac, state.dataSolarShading->SurfWinAbsBeam(Lay), AbsBeamWinSh); } // Beam solar transmittance of a shaded window - Real64 TransBeamWinSh = POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).TransSolBeamCoef); + Real64 TransBeamWinSh = + Window::POLYF(CosIncBack, state.dataConstruction->Construct(ConstrNumBackSh).TransSolBeamCoef); TransBeamWin = Window::InterpSw(SwitchFac, TransBeamWin, TransBeamWinSh); } @@ -7900,6 +7895,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) for (int IBack = 1; IBack <= NBkSurf; ++IBack) { int BackSurfaceNumber = state.dataShadowComb->ShadowComb(BaseSurf).BackSurf(IBack); int ConstrNumBack = s_surf->Surface(BackSurfaceNumber).Construction; + auto const &constrBack = state.dataConstruction->Construct(ConstrNumBack); // Do not perform any calculation if surface is scheduled for incoming solar radiation int SurfSolIncPtr = SurfaceScheduledSolarInc(state, BackSurfaceNumber, ConstrNumBack); @@ -7951,15 +7947,15 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) babs * state.dataEnvrn->BeamSolarRad; //[W] // Absorptance from current back direction - int TotSolidLay = state.dataConstruction->Construct(ConstrNumBack).TotSolidLayers; + int TotSolidLay = constrBack.TotSolidLayers; for (int Lay = 1; Lay <= TotSolidLay; ++Lay) { // IF (ALLOCATED(Construct(ConstrNumBack)%BSDFInput)) THEN // CFDirBoverlap is energy transmitted for current basis beam. It is important to note that // AWinOverlap array needs to contain flux and not absorbed energy because later in the code // this will be multiplied with window area s_surf->SurfWinACFOverlap(BackSurfaceNumber, Lay) += - state.dataConstruction->Construct(ConstrNumBack).BSDFInput.Layer(Lay).BkAbs(bestBackTrn, 1) * - CFDirBoverlap(IBack, CurTrnDir) / s_surf->Surface(BackSurfaceNumber).Area; + constrBack.BSDFInput.Layer(Lay).BkAbs(bestBackTrn, 1) * CFDirBoverlap(IBack, CurTrnDir) / + s_surf->Surface(BackSurfaceNumber).Area; // END IF } @@ -7985,9 +7981,9 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) } } } else { - if (state.dataConstruction->Construct(ConstrNumBack).TransDiff <= 0.0) { + if (constrBack.TransDiff <= 0.0) { // Do not take into account this window if it is scheduled for surface gains - Real64 AbsIntSurf = state.dataConstruction->Construct(ConstrNumBack).InsideAbsorpSolar; + Real64 AbsIntSurf = constrBack.InsideAbsorpSolar; s_surf->SurfOpaqAI(BackSurfaceNumber) += CFBoverlap(IBack) * AbsIntSurf / s_surf->Surface(BackSurfaceNumber).Area; BABSZone += CFBoverlap(IBack) * AbsIntSurf; @@ -8012,7 +8008,8 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) if (s_surf->SurfWinWindowModelType(IBack) != WindowModel::EQL) continue; // only EQL back window is allowed int ConstrNumBack = s_surf->Surface(BackSurfNum).Construction; - int NBackGlass = state.dataConstruction->Construct(ConstrNumBack).TotGlassLayers; + auto const &constrBack = state.dataConstruction->Construct(ConstrNumBack); + int NBackGlass = constrBack.TotGlassLayers; // Irradiated (overlap) area for this back surface, projected onto window plane // (includes effect of shadowing on exterior window) @@ -8020,7 +8017,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) state.dataHeatBal->SurfWinOverlapAreas(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, IBack, SurfNum); Real64 BOverlap = TBm * AOverlap * CosInc; //[m2] - if (state.dataConstruction->Construct(ConstrNumBack).TransDiff <= 0.0) { + if (constrBack.TransDiff <= 0.0) { // Back surface is opaque interior or exterior wall Real64 AbsIntSurf = state.dataHeatBalSurf->SurfAbsSolarInt(BackSurfNum); @@ -8046,7 +8043,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state) WindowEquivalentLayer::CalcEQLOpticalProperty( state, BackSurfNum, SolarArrays::BEAM, state.dataSolarShading->SurfWinAbsSolBeamBackEQL); auto &CFS = state.dataWindowEquivLayer->CFS; - int EQLNum = state.dataConstruction->Construct(ConstrNumBack).EQLConsPtr; + int EQLNum = constrBack.EQLConsPtr; state.dataSolarShading->SurfWinAbsBeamEQL({1, CFS(EQLNum).NL}) = state.dataSolarShading->SurfWinAbsSolBeamBackEQL(1, {1, CFS(EQLNum).NL}); // get the interior beam transmitted through back exterior or interior EQL window @@ -8595,13 +8592,14 @@ void CalcInteriorSolarDistributionWCESimple(EnergyPlusData &state) if (BackSurfNum == 0) break; // No more irradiated back surfaces for this exterior window int ConstrNumBack = s_surf->Surface(BackSurfNum).Construction; + auto const &constrBack = state.dataConstruction->Construct(ConstrNumBack); // NBackGlass = Construct( ConstrNumBack ).TotGlassLayers; // Irradiated (overlap) area for this back surface, projected onto window plane // (includes effect of shadowing on exterior window) Real64 AOverlap = state.dataHeatBal->SurfWinOverlapAreas(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, IBack, SurfNum); Real64 BOverlap = TBm * AOverlap * CosInc; //[m2] - if (state.dataConstruction->Construct(ConstrNumBack).TransDiff <= 0.0) { + if (constrBack.TransDiff <= 0.0) { // Back surface is opaque interior or exterior wall Real64 AbsIntSurf = state.dataHeatBalSurf->SurfAbsSolarInt(BackSurfNum); @@ -9324,7 +9322,6 @@ void WindowShadingManager(EnergyPlusData &state) // na // Using/Aliasing - using General::POLYF; using ScheduleManager::GetCurrentScheduleValue; int IConst; // Construction @@ -9407,7 +9404,7 @@ void WindowShadingManager(EnergyPlusData &state) // Vis trans at normal incidence of unswitched glass. Counting the GlazedFrac if (IConst > 0) s_surf->SurfWinVisTransSelected(ISurf) = - POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; + Window::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; // Window has shading control // select the active window shading control and corresponding constructions @@ -9763,7 +9760,7 @@ void WindowShadingManager(EnergyPlusData &state) // Vis trans at normal incidence of fully switched glass IConst = s_surf->Surface(ISurf).activeShadedConstruction; s_surf->SurfWinVisTransSelected(ISurf) = - POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; + Window::POLYF(1.0, state.dataConstruction->Construct(IConst).TransVisBeamCoef) * surfWin.glazedFrac; } // Slat angle control for blinds @@ -10756,10 +10753,6 @@ void CalcBeamSolarOnWinRevealSurface(EnergyPlusData &state) // REFERENCES // na - // USE STATEMENTS - // Using/Aliasing - using General::POLYF; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS:na @@ -10880,8 +10873,8 @@ void CalcBeamSolarOnWinRevealSurface(EnergyPlusData &state) ConstrNumSh = s_surf->SurfWinActiveShadedConstruction(SurfNum); auto const &thisConstruct = state.dataConstruction->Construct(ConstrNum); - SolTransGlass = POLYF(state.dataHeatBal->SurfCosIncAng(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, SurfNum), - thisConstruct.TransSolBeamCoef); + SolTransGlass = Window::POLYF(state.dataHeatBal->SurfCosIncAng(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, SurfNum), + thisConstruct.TransSolBeamCoef); TanProfileAngVert = s_surf->SurfWinTanProfileAngVert(SurfNum); TanProfileAngHor = s_surf->SurfWinTanProfileAngHor(SurfNum); FrameDivNum = surf.FrameDivider; @@ -11110,8 +11103,8 @@ void CalcBeamSolarOnWinRevealSurface(EnergyPlusData &state) if (ShadeFlag == WinShadingType::SwitchableGlazing) { auto const &thisConstructSh = state.dataConstruction->Construct(ConstrNumSh); SolTransGlassSh = - POLYF(state.dataHeatBal->SurfCosIncAng(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, SurfNum), - thisConstructSh.TransSolBeamCoef); + Window::POLYF(state.dataHeatBal->SurfCosIncAng(state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep, SurfNum), + thisConstructSh.TransSolBeamCoef); SolTransGlass = Window::InterpSw(s_surf->SurfWinSwitchingFactor(SurfNum), SolTransGlass, SolTransGlassSh); DiffReflGlassSh = thisConstructSh.ReflectSolDiffBack; DiffReflGlass = Window::InterpSw(s_surf->SurfWinSwitchingFactor(SurfNum), DiffReflGlass, DiffReflGlassSh); diff --git a/src/EnergyPlus/SurfaceGeometry.cc b/src/EnergyPlus/SurfaceGeometry.cc index faf30f55f0c..64d87f2c11c 100644 --- a/src/EnergyPlus/SurfaceGeometry.cc +++ b/src/EnergyPlus/SurfaceGeometry.cc @@ -13273,17 +13273,17 @@ namespace SurfaceGeometry { thisConstructNewSh.AbsDiffShade = 0.0; thisConstructNewSh.AbsDiffBackShade = 0.0; thisConstructNewSh.ShadeAbsorpThermal = 0.0; - thisConstructNewSh.AbsBeamShadeCoef = 0.0; + std::fill(thisConstructNewSh.AbsBeamShadeCoef.begin(), thisConstructNewSh.AbsBeamShadeCoef.end(), 0.0); thisConstructNewSh.TransDiff = 0.0; thisConstructNewSh.TransDiffVis = 0.0; thisConstructNewSh.ReflectSolDiffBack = 0.0; thisConstructNewSh.ReflectSolDiffFront = 0.0; thisConstructNewSh.ReflectVisDiffBack = 0.0; thisConstructNewSh.ReflectVisDiffFront = 0.0; - thisConstructNewSh.TransSolBeamCoef = 0.0; - thisConstructNewSh.TransVisBeamCoef = 0.0; - thisConstructNewSh.ReflSolBeamFrontCoef = 0.0; - thisConstructNewSh.ReflSolBeamBackCoef = 0.0; + std::fill(thisConstructNewSh.TransSolBeamCoef.begin(), thisConstructNewSh.TransSolBeamCoef.end(), 0.0); + std::fill(thisConstructNewSh.TransVisBeamCoef.begin(), thisConstructNewSh.TransVisBeamCoef.end(), 0.0); + std::fill(thisConstructNewSh.ReflSolBeamFrontCoef.begin(), thisConstructNewSh.ReflSolBeamFrontCoef.end(), 0.0); + std::fill(thisConstructNewSh.ReflSolBeamBackCoef.begin(), thisConstructNewSh.ReflSolBeamBackCoef.end(), 0.0); thisConstructNewSh.W5FrameDivider = 0; thisConstructNewSh.FromWindow5DataFile = false; @@ -13295,10 +13295,8 @@ namespace SurfaceGeometry { thisConstructNewSh.IsUsed = true; for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { - for (int index = 1; index <= DataSurfaces::MaxPolyCoeff; ++index) { - thisConstructNewSh.AbsBeamCoef(Layer)(index) = 0.0; - thisConstructNewSh.AbsBeamBackCoef(Layer)(index) = 0.0; - } + std::fill(thisConstructNewSh.AbsBeamCoef(Layer).begin(), thisConstructNewSh.AbsBeamCoef(Layer).end(), 0.0); + std::fill(thisConstructNewSh.AbsBeamBackCoef(Layer).begin(), thisConstructNewSh.AbsBeamBackCoef(Layer).end(), 0.0); } } } @@ -13475,17 +13473,17 @@ namespace SurfaceGeometry { thisConstruct.AbsDiffShade = 0.0; thisConstruct.AbsDiffBackShade = 0.0; thisConstruct.ShadeAbsorpThermal = 0.0; - thisConstruct.AbsBeamShadeCoef = 0.0; + std::fill(thisConstruct.AbsBeamShadeCoef.begin(), thisConstruct.AbsBeamShadeCoef.end(), 0.0); thisConstruct.TransDiff = 0.0; thisConstruct.TransDiffVis = 0.0; thisConstruct.ReflectSolDiffBack = 0.0; thisConstruct.ReflectSolDiffFront = 0.0; thisConstruct.ReflectVisDiffBack = 0.0; thisConstruct.ReflectVisDiffFront = 0.0; - thisConstruct.TransSolBeamCoef = 0.0; - thisConstruct.TransVisBeamCoef = 0.0; - thisConstruct.ReflSolBeamFrontCoef = 0.0; - thisConstruct.ReflSolBeamBackCoef = 0.0; + std::fill(thisConstruct.TransSolBeamCoef.begin(), thisConstruct.TransSolBeamCoef.end(), 0.0); + std::fill(thisConstruct.TransVisBeamCoef.begin(), thisConstruct.TransVisBeamCoef.end(), 0.0); + std::fill(thisConstruct.ReflSolBeamFrontCoef.begin(), thisConstruct.ReflSolBeamFrontCoef.end(), 0.0); + std::fill(thisConstruct.ReflSolBeamBackCoef.begin(), thisConstruct.ReflSolBeamBackCoef.end(), 0.0); thisConstruct.W5FrameDivider = 0; thisConstruct.FromWindow5DataFile = false; thisConstruct.W5FileMullionWidth = 0.0; @@ -13493,10 +13491,8 @@ namespace SurfaceGeometry { thisConstruct.W5FileGlazingSysWidth = 0.0; thisConstruct.W5FileGlazingSysHeight = 0.0; for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { - for (int index = 1; index <= DataSurfaces::MaxPolyCoeff; ++index) { - thisConstruct.AbsBeamCoef(Layer)(index) = 0.0; - thisConstruct.AbsBeamBackCoef(Layer)(index) = 0.0; - } + std::fill(thisConstruct.AbsBeamCoef(Layer).begin(), thisConstruct.AbsBeamCoef(Layer).end(), 0.0); + std::fill(thisConstruct.AbsBeamBackCoef(Layer).begin(), thisConstruct.AbsBeamBackCoef(Layer).end(), 0.0); } } return (newConstruct); diff --git a/src/EnergyPlus/WindowEquivalentLayer.hh b/src/EnergyPlus/WindowEquivalentLayer.hh index affd940c6fc..14910db93c3 100644 --- a/src/EnergyPlus/WindowEquivalentLayer.hh +++ b/src/EnergyPlus/WindowEquivalentLayer.hh @@ -60,6 +60,7 @@ // EnergyPlus Headers #include +#include #include #include diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 47ac924d445..f186f5f8684 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -54,7 +54,6 @@ // ObjexxFCL Headers #include -#include // EnergyPlus Headers #include @@ -66,16 +65,10 @@ #include #include #include -#include -#include #include -#include -#include -#include #include #include #include -#include #include #include #include @@ -203,49 +196,48 @@ namespace Window { // Glazing system layer solar absorptance for each glass layer Array1D solabsDiff(maxGlassLayers); // Glazing system solar absorptance for a layer at each incidence angle - Array1D solabsPhiLay(maxIncidentAngles); + std::array solabsPhiLay; // Glazing system solar transmittance from fit at each incidence angle - Array1D tsolPhiFit(maxIncidentAngles); + std::array tsolPhiFit; // Glazing system visible transmittance from fit at each incidence angle - Array1D tvisPhiFit(maxIncidentAngles); + std::array tvisPhiFit; // Isolated glass solar transmittance for each incidence angle - Array2D tBareSolPhi(maxGlassLayers, maxIncidentAngles); + Array1D> tBareSolPhi(maxGlassLayers); Real64 t1; // = tBareSolPhi(,1)(,2) Real64 t2; // Isolated glass visible transmittance for each incidence angle - Array2D tBareVisPhi(maxGlassLayers, maxIncidentAngles); + Array1D> tBareVisPhi(maxGlassLayers); Real64 t1v; // = tBareVisPhi(,1)(,2) Real64 t2v; // Isolated glass front solar reflectance for each incidence angle - Array2D rfBareSolPhi(maxGlassLayers, maxIncidentAngles); + Array1D> rfBareSolPhi(maxGlassLayers); // Isolated glass front visible reflectance for each incidence angle - Array2D rfBareVisPhi(maxGlassLayers, maxIncidentAngles); + Array1D> rfBareVisPhi(maxGlassLayers); // Isolated glass back solar reflectance for each incidence angle - Array2D rbBareSolPhi(maxGlassLayers, maxIncidentAngles); + Array1D> rbBareSolPhi(maxGlassLayers); // Isolated glass back visible reflectance for each incidence angle - Array2D rbBareVisPhi(maxGlassLayers, maxIncidentAngles); + Array1D> rbBareVisPhi(maxGlassLayers); // Isolated glass front solar absorptance for each incidence angle - Array2D afBareSolPhi(maxGlassLayers, maxIncidentAngles); + Array1D> afBareSolPhi(maxGlassLayers); Real64 af1; // = afBareSolPhi(,1)(,2) Real64 af2; Real64 rbmf2; // Isolated glass #2 front beam reflectance // Isolated glass back solar absorptance for each incidence angle - Array2D abBareSolPhi(maxGlassLayers, maxIncidentAngles); + Array1D> abBareSolPhi(maxGlassLayers); // Glazing system solar absorptance for each angle of incidence - Array2D solabsPhi(maxGlassLayers, maxIncidentAngles); + Array1D> solabsPhi(maxGlassLayers); // Glazing system back solar absorptance for each angle of incidence - Array2D solabsBackPhi(maxGlassLayers, maxIncidentAngles); + Array1D> solabsBackPhi(maxGlassLayers); // Glazing system interior shade solar absorptance for each angle of incidence - Array1D solabsShadePhi(maxIncidentAngles); + std::array solabsShadePhi; // These need to stay as Array1D for a little longer because changing them spreads into many source files - Array1D tsolPhi(maxIncidentAngles); // Glazing system solar transmittance for each angle of incidence - Array1D rfsolPhi(maxIncidentAngles); // Glazing system solar front reflectance for each angle of incidence - Array1D rbsolPhi(maxIncidentAngles); // Glazing system solar back reflectance for each angle of incidence - Array1D tvisPhi(maxIncidentAngles); // Glazing system visible transmittance for each angle of incidence - Array1D rfvisPhi(maxIncidentAngles); // Glazing system visible front reflectance for each angle of incidence - Array1D rbvisPhi(maxIncidentAngles); // Glazing system visible back reflectance for each angle of incidence - Array1D CosPhiIndepVar(maxIncidentAngles); // Cos of incidence angles at 10-deg increments for curve fits + std::array tsolPhi; // Glazing system solar transmittance for each angle of incidence + std::array rfsolPhi; // Glazing system solar front reflectance for each angle of incidence + std::array rbsolPhi; // Glazing system solar back reflectance for each angle of incidence + std::array tvisPhi; // Glazing system visible transmittance for each angle of incidence + std::array rfvisPhi; // Glazing system visible front reflectance for each angle of incidence + std::array rbvisPhi; // Glazing system visible back reflectance for each angle of incidence Real64 ab1; // = abBareSolPhi(,1)(,2) Real64 ab2; @@ -280,8 +272,6 @@ namespace Window { Real64 RhoGlIR; // IR reflectance of inside face of inside glass int NGlass; // Number of glass layers in a construction int LayPtr; // Material number corresponding to LayNum - Real64 Phi; // Incidence angle (deg) - Real64 CosPhi; // Cosine of incidence angle Real64 tsolDiff; // Glazing system diffuse solar transmittance Real64 tvisDiff; // Glazing system diffuse visible transmittance int IGlassBack; // Glass layer number counted from back of window @@ -363,10 +353,6 @@ namespace Window { if (thisConstruct.WindowTypeEQL) continue; // skip Equivalent Layer Fenestration // handling of optical properties - for (int IPhi = 1; IPhi <= 10; ++IPhi) { - CosPhiIndepVar(IPhi) = std::cos((IPhi - 1) * 10.0 * Constant::DegToRadians); - } - TotLay = thisConstruct.TotLayers; auto const *mat = s_mat->materials(thisConstruct.LayerPoint(1)); @@ -496,7 +482,6 @@ namespace Window { lquasi = false; AllGlassIsSpectralAverage = true; - int constexpr TotalIPhi = 10; wm->LayerNum = {0}; // Loop over glass layers in the construction @@ -642,27 +627,18 @@ namespace Window { } } // End of loop over glass layers in the construction for front calculation - if (TotalIPhi > maxIncidentAngles) { - ShowSevereError(state, - format("WindowManage::InitGlassOpticalCalculations = {}, Invalid maximum value of common incident angles = {}.", - thisConstruct.Name, - TotalIPhi)); - ShowContinueError( - state, - format("The maximum number of incident angles for each construct is {}. Please rearrange the dataset.", maxIncidentAngles)); - ShowFatalError(state, "Errors found getting inputs. Previous error(s) cause program termination."); - } - // Loop over incidence angle from 0 to 90 deg in 10 deg increments. // Get glass layer properties, then glazing system properties (which include the // effect of inter-reflection among glass layers) at each incidence angle. - for (int IPhi = 1; IPhi <= TotalIPhi; ++IPhi) { - // 10 degree increment for incident angle is only value for a construction without a layer = SpectralAndAngle - Phi = double(IPhi - 1) * 10.0; - CosPhi = std::cos(Phi * Constant::DegToRadians); - if (std::abs(CosPhi) < 0.0001) CosPhi = 0.0; + // Apparently, using pre-calcaulated and hard-coded cosPhis (e.g., Window::cosPhis) causes a bunch of + // diffs, including some big ones + std::array cosPhisLocal; + + for (int iPhi = 0; iPhi < numPhis; ++iPhi) + cosPhisLocal[iPhi] = std::cos((double)iPhi * dPhiDeg * Constant::DegToRad); + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { // For each wavelength, get glass layer properties at this angle of incidence // from properties at normal incidence for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { @@ -671,7 +647,7 @@ namespace Window { assert(matGlass != nullptr); if (matGlass->windowOpticalData != Window::OpticalDataModel::SpectralAndAngle) { for (int ILam = 1; ILam <= numpt[IGlass - 1]; ++ILam) { - TransAndReflAtPhi(CosPhi, + TransAndReflAtPhi(cosPhisLocal[iPhi], t[IGlass - 1][ILam - 1], rff[IGlass - 1][ILam - 1], rbb[IGlass - 1][ILam - 1], @@ -686,23 +662,23 @@ namespace Window { for (int ILam = 1; ILam <= (int)wm->wle.size(); ++ILam) { Real64 lam = wm->wle[ILam - 1]; wlt[IGlass - 1][ILam - 1] = lam; - tPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngTransDataPtr, Phi, lam); - rfPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngFRefleDataPtr, Phi, lam); - rbPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngBRefleDataPtr, Phi, lam); + tPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngTransDataPtr, iPhi * dPhiDeg, lam); + rfPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngFRefleDataPtr, iPhi * dPhiDeg, lam); + rbPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngBRefleDataPtr, iPhi * dPhiDeg, lam); } } // For use with between-glass shade/blind, save angular properties of isolated glass // for case that all glass layers were input with spectral-average properties // only used by between-glass shades or blinds if (AllGlassIsSpectralAverage) { - tBareSolPhi(IGlass, IPhi) = tPhi[IGlass - 1][0]; - tBareVisPhi(IGlass, IPhi) = tPhi[IGlass - 1][1]; - rfBareSolPhi(IGlass, IPhi) = rfPhi[IGlass - 1][0]; - rfBareVisPhi(IGlass, IPhi) = rfPhi[IGlass - 1][1]; - rbBareSolPhi(IGlass, IPhi) = rbPhi[IGlass - 1][0]; - rbBareVisPhi(IGlass, IPhi) = rbPhi[IGlass - 1][1]; - afBareSolPhi(IGlass, IPhi) = max(0.0, 1.0 - (tBareSolPhi(IGlass, IPhi) + rfBareSolPhi(IGlass, IPhi))); - abBareSolPhi(IGlass, IPhi) = max(0.0, 1.0 - (tBareSolPhi(IGlass, IPhi) + rbBareSolPhi(IGlass, IPhi))); + tBareSolPhi(IGlass)[iPhi] = tPhi[IGlass - 1][0]; + tBareVisPhi(IGlass)[iPhi] = tPhi[IGlass - 1][1]; + rfBareSolPhi(IGlass)[iPhi] = rfPhi[IGlass - 1][0]; + rfBareVisPhi(IGlass)[iPhi] = rfPhi[IGlass - 1][1]; + rbBareSolPhi(IGlass)[iPhi] = rbPhi[IGlass - 1][0]; + rbBareVisPhi(IGlass)[iPhi] = rbPhi[IGlass - 1][1]; + afBareSolPhi(IGlass)[iPhi] = max(0.0, 1.0 - (tBareSolPhi(IGlass)[iPhi] + rfBareSolPhi(IGlass)[iPhi])); + abBareSolPhi(IGlass)[iPhi] = max(0.0, 1.0 - (tBareSolPhi(IGlass)[iPhi] + rbBareSolPhi(IGlass)[iPhi])); } } @@ -721,15 +697,15 @@ namespace Window { // Get solar properties of system by integrating over solar irradiance spectrum. // For now it is assumed that the exterior and interior irradiance spectra are the same. - tsolPhi(IPhi) = solarSpectrumAverage(state, stPhi); - rfsolPhi(IPhi) = solarSpectrumAverage(state, srfPhi); - rbsolPhi(IPhi) = solarSpectrumAverage(state, srbPhi); + tsolPhi[iPhi] = solarSpectrumAverage(state, stPhi); + rfsolPhi[iPhi] = solarSpectrumAverage(state, srfPhi); + rbsolPhi[iPhi] = solarSpectrumAverage(state, srbPhi); for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { for (int ILam = 1; ILam <= nume; ++ILam) { sabsPhi(ILam) = saPhi(IGlass, ILam); } - solabsPhi(IGlass, IPhi) = solarSpectrumAverage(state, sabsPhi); + solabsPhi(IGlass)[iPhi] = solarSpectrumAverage(state, sabsPhi); } // Get visible properties of system by integrating over solar irradiance @@ -740,23 +716,23 @@ namespace Window { // without spectral data, as indicated by the argument "2". if (lquasi) SystemSpectralPropertiesAtPhi(state, 2, NGlass, 0.37, 0.78, numpt, wlt, tPhi, rfPhi, rbPhi, stPhi, srfPhi, srbPhi, saPhi); - tvisPhi(IPhi) = visibleSpectrumAverage(state, stPhi); - rfvisPhi(IPhi) = visibleSpectrumAverage(state, srfPhi); - rbvisPhi(IPhi) = visibleSpectrumAverage(state, srbPhi); + tvisPhi[iPhi] = visibleSpectrumAverage(state, stPhi); + rfvisPhi[iPhi] = visibleSpectrumAverage(state, srfPhi); + rbvisPhi[iPhi] = visibleSpectrumAverage(state, srbPhi); } // End of loop over incidence angles for front calculation // only used by between-glass shades or blinds if (AllGlassIsSpectralAverage) { for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { - W5LsqFit(CosPhiIndepVar, tBareSolPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.tBareSolCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, tBareVisPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.tBareVisCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, rfBareSolPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.rfBareSolCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, rfBareVisPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.rfBareVisCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, rbBareSolPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.rbBareSolCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, rbBareVisPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.rbBareVisCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, afBareSolPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.afBareSolCoef(IGlass)); - W5LsqFit(CosPhiIndepVar, abBareSolPhi(IGlass, _), 6, 1, TotalIPhi, thisConstruct.abBareSolCoef(IGlass)); + W5LsqFit(cosPhisLocal, tBareSolPhi(IGlass), thisConstruct.tBareSolCoef(IGlass)); + W5LsqFit(cosPhisLocal, tBareVisPhi(IGlass), thisConstruct.tBareVisCoef(IGlass)); + W5LsqFit(cosPhisLocal, rfBareSolPhi(IGlass), thisConstruct.rfBareSolCoef(IGlass)); + W5LsqFit(cosPhisLocal, rfBareVisPhi(IGlass), thisConstruct.rfBareVisCoef(IGlass)); + W5LsqFit(cosPhisLocal, rbBareSolPhi(IGlass), thisConstruct.rbBareSolCoef(IGlass)); + W5LsqFit(cosPhisLocal, rbBareVisPhi(IGlass), thisConstruct.rbBareVisCoef(IGlass)); + W5LsqFit(cosPhisLocal, afBareSolPhi(IGlass), thisConstruct.afBareSolCoef(IGlass)); + W5LsqFit(cosPhisLocal, abBareSolPhi(IGlass), thisConstruct.abBareSolCoef(IGlass)); } } @@ -770,7 +746,7 @@ namespace Window { thisConstruct.TransDiff = tsolDiff; thisConstruct.TransDiffVis = tvisDiff; for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { - solabsPhiLay({1, TotalIPhi}) = solabsPhi(IGlass, {1, TotalIPhi}); + solabsPhiLay = solabsPhi(IGlass); // Is this a deep copy? solabsDiff(IGlass) = DiffuseAverage(solabsPhiLay); thisConstruct.AbsDiff(IGlass) = solabsDiff(IGlass); @@ -778,12 +754,12 @@ namespace Window { // all glass layers were input with spectral-average properties // only used by between-glass shades or blinds if (AllGlassIsSpectralAverage) { - thisConstruct.tBareSolDiff(IGlass) = DiffuseAverage(tBareSolPhi(IGlass, {1, TotalIPhi})); - thisConstruct.tBareVisDiff(IGlass) = DiffuseAverage(tBareVisPhi(IGlass, {1, TotalIPhi})); - thisConstruct.rfBareSolDiff(IGlass) = DiffuseAverage(rfBareSolPhi(IGlass, {1, TotalIPhi})); - thisConstruct.rfBareVisDiff(IGlass) = DiffuseAverage(rfBareVisPhi(IGlass, {1, TotalIPhi})); - thisConstruct.rbBareSolDiff(IGlass) = DiffuseAverage(rbBareSolPhi(IGlass, {1, TotalIPhi})); - thisConstruct.rbBareVisDiff(IGlass) = DiffuseAverage(rbBareVisPhi(IGlass, {1, TotalIPhi})); + thisConstruct.tBareSolDiff(IGlass) = DiffuseAverage(tBareSolPhi(IGlass)); + thisConstruct.tBareVisDiff(IGlass) = DiffuseAverage(tBareVisPhi(IGlass)); + thisConstruct.rfBareSolDiff(IGlass) = DiffuseAverage(rfBareSolPhi(IGlass)); + thisConstruct.rfBareVisDiff(IGlass) = DiffuseAverage(rfBareVisPhi(IGlass)); + thisConstruct.rbBareSolDiff(IGlass) = DiffuseAverage(rbBareSolPhi(IGlass)); + thisConstruct.rbBareVisDiff(IGlass) = DiffuseAverage(rbBareVisPhi(IGlass)); thisConstruct.afBareSolDiff(IGlass) = max(0.0, 1.0 - (thisConstruct.tBareSolDiff(IGlass) + thisConstruct.rfBareSolDiff(IGlass))); thisConstruct.abBareSolDiff(IGlass) = max(0.0, 1.0 - (thisConstruct.tBareSolDiff(IGlass) + thisConstruct.rbBareSolDiff(IGlass))); } @@ -858,11 +834,7 @@ namespace Window { // The glazing system properties include the effect of inter-reflection among glass layers, // but exclude the effect of a shade or blind if present in the construction. // When a construction has a layer = SpectralAndAngle, the 10 degree increment will be overridden. - for (int IPhi = 1; IPhi <= TotalIPhi; ++IPhi) { - Phi = double(IPhi - 1) * 10.0; - CosPhi = std::cos(Phi * Constant::DegToRadians); - if (std::abs(CosPhi) < 0.0001) CosPhi = 0.0; - + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { // For each wavelength, get glass layer properties at this angle of incidence // from properties at normal incidence for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { @@ -872,7 +844,7 @@ namespace Window { if (matGlass->windowOpticalData != Window::OpticalDataModel::SpectralAndAngle) { for (int ILam = 1; ILam <= numpt[IGlass - 1]; ++ILam) { - TransAndReflAtPhi(CosPhi, + TransAndReflAtPhi(cosPhisLocal[iPhi], t[IGlass - 1][ILam - 1], rff[IGlass - 1][ILam - 1], rbb[IGlass - 1][ILam - 1], @@ -888,9 +860,9 @@ namespace Window { for (int ILam = 1; ILam <= (int)wm->wle.size(); ++ILam) { Real64 lam = wm->wle[ILam - 1]; wlt[IGlass - 1][ILam - 1] = lam; - tPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngTransDataPtr, Phi, lam); - rfPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngFRefleDataPtr, Phi, lam); - rbPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngBRefleDataPtr, Phi, lam); + tPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngTransDataPtr, iPhi * dPhiDeg, lam); + rfPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngFRefleDataPtr, iPhi * dPhiDeg, lam); + rbPhi[IGlass - 1][ILam - 1] = Curve::CurveValue(state, matGlass->GlassSpecAngBRefleDataPtr, iPhi * dPhiDeg, lam); } } } @@ -912,14 +884,14 @@ namespace Window { for (int j = 1; j <= nume; ++j) { sabsPhi(j) = saPhi(IGlass, j); } - solabsBackPhi(IGlass, IPhi) = solarSpectrumAverage(state, sabsPhi); + solabsBackPhi(IGlass)[iPhi] = solarSpectrumAverage(state, sabsPhi); } } // End of loop over incidence angles for back calculation for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { IGlassBack = NGlass - IGlass + 1; - thisConstruct.AbsDiffBack(IGlass) = DiffuseAverage(solabsBackPhi(IGlassBack, {1, 10})); + thisConstruct.AbsDiffBack(IGlass) = DiffuseAverage(solabsBackPhi(IGlassBack)); } //----------------------------------------------------------------------- @@ -957,13 +929,13 @@ namespace Window { ShadeReflFacVis = 1.0 / (1.0 - ShadeReflVis * constr.ReflectVisDiffBack); // Front incident solar, beam, interior shade - for (int IPhi = 1; IPhi <= 10; ++IPhi) { + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { - solabsPhi(IGlass, IPhi) += tsolPhi(IPhi) * ShadeRefl * ShadeReflFac * constr.AbsDiffBack(IGlass); + solabsPhi(IGlass)[iPhi] += tsolPhi[iPhi] * ShadeRefl * ShadeReflFac * constr.AbsDiffBack(IGlass); } - solabsShadePhi(IPhi) = tsolPhi(IPhi) * ShadeReflFac * ShadeAbs; - tsolPhi(IPhi) *= ShadeReflFac * ShadeTrans; - tvisPhi(IPhi) *= ShadeReflFacVis * ShadeTransVis; + solabsShadePhi[iPhi] = tsolPhi[iPhi] * ShadeReflFac * ShadeAbs; + tsolPhi[iPhi] *= ShadeReflFac * ShadeTrans; + tvisPhi[iPhi] *= ShadeReflFacVis * ShadeTransVis; } // Front incident solar, diffuse, interior shade @@ -1006,13 +978,13 @@ namespace Window { ShadeReflFac = 1.0 / (1.0 - ShadeRefl * constr.ReflectSolDiffFront); ShadeReflFacVis = 1.0 / (1.0 - ShadeReflVis * constr.ReflectVisDiffFront); - for (int IPhi = 1; IPhi <= 10; ++IPhi) { + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { - solabsPhi(IGlass, IPhi) = ShadeTrans * solabsDiff(IGlass) * ShadeReflFac; + solabsPhi(IGlass)[iPhi] = ShadeTrans * solabsDiff(IGlass) * ShadeReflFac; } - tsolPhi(IPhi) = ShadeTrans * ShadeReflFac * tsolDiff; - tvisPhi(IPhi) = ShadeTransVis * ShadeReflFacVis * tvisDiff; - solabsShadePhi(IPhi) = ShadeAbs * (1.0 + ShadeTrans * ShadeReflFac * constr.ReflectSolDiffFront); + tsolPhi[iPhi] = ShadeTrans * ShadeReflFac * tsolDiff; + tvisPhi[iPhi] = ShadeTransVis * ShadeReflFacVis * tvisDiff; + solabsShadePhi[iPhi] = ShadeAbs * (1.0 + ShadeTrans * ShadeReflFac * constr.ReflectSolDiffFront); } // Front incident solar, diffuse, exterior shade/screen/blind @@ -1074,16 +1046,16 @@ namespace Window { // Front incident solar, beam, between-glass shade, NGlass = 2 - for (int IPhi = 1; IPhi <= 10; ++IPhi) { - t1 = tBareSolPhi(1, IPhi); - t1v = tBareVisPhi(1, IPhi); - af1 = afBareSolPhi(1, IPhi); - ab1 = abBareSolPhi(1, IPhi); - tsolPhi(IPhi) = t1 * (tsh + rsh * rb1 * tsh + tsh * rf2 * rsh) * td2; - tvisPhi(IPhi) = t1v * (tshv + rshv * rb1v * tshv + tshv * rf2v * rshv) * td2v; - solabsShadePhi(IPhi) = t1 * (ash + rsh * rb1 + tsh * rf2) * ash; - solabsPhi(1, IPhi) = af1 + t1 * (rsh + rsh * rb1 * rsh + tsh * rf2 * tsh) * abd1; - solabsPhi(2, IPhi) = t1 * (tsh + rsh * rb1 * tsh + tsh * rf2 * rsh) * afd2; + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { + t1 = tBareSolPhi(1)[iPhi]; + t1v = tBareVisPhi(1)[iPhi]; + af1 = afBareSolPhi(1)[iPhi]; + ab1 = abBareSolPhi(1)[iPhi]; + tsolPhi[iPhi] = t1 * (tsh + rsh * rb1 * tsh + tsh * rf2 * rsh) * td2; + tvisPhi[iPhi] = t1v * (tshv + rshv * rb1v * tshv + tshv * rf2v * rshv) * td2v; + solabsShadePhi[iPhi] = t1 * (ash + rsh * rb1 + tsh * rf2) * ash; + solabsPhi(1)[iPhi] = af1 + t1 * (rsh + rsh * rb1 * rsh + tsh * rf2 * tsh) * abd1; + solabsPhi(2)[iPhi] = t1 * (tsh + rsh * rb1 * tsh + tsh * rf2 * rsh) * afd2; } // End of loop over incidence angles // Front incident solar, diffuse, between-glass shade, NGlass = 2 @@ -1117,23 +1089,23 @@ namespace Window { // Front incident solar, beam, between-glass shade, NGlass = 3 - for (int IPhi = 1; IPhi <= 10; ++IPhi) { - t1 = tBareSolPhi(1, IPhi); - t1v = tBareVisPhi(1, IPhi); - t2 = tBareSolPhi(2, IPhi); - t2v = tBareVisPhi(2, IPhi); - af1 = afBareSolPhi(1, IPhi); - af2 = afBareSolPhi(2, IPhi); - ab1 = abBareSolPhi(1, IPhi); - ab2 = abBareSolPhi(2, IPhi); + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { + t1 = tBareSolPhi(1)[iPhi]; + t1v = tBareVisPhi(1)[iPhi]; + t2 = tBareSolPhi(2)[iPhi]; + t2v = tBareVisPhi(2)[iPhi]; + af1 = afBareSolPhi(1)[iPhi]; + af2 = afBareSolPhi(2)[iPhi]; + ab1 = abBareSolPhi(1)[iPhi]; + ab2 = abBareSolPhi(2)[iPhi]; rbmf2 = max(0.0, 1.0 - (t2 + af2)); - tsolPhi(IPhi) = t1 * t2 * (tsh + tsh * rf3 * rsh + rsh * td2 * rb1 * td2 * tsh + rsh * rb2 * tsh) * td3; - tvisPhi(IPhi) = t1v * t2v * (tshv + tshv * rf3v * rshv + rshv * td2v * rb1v * td2v * tshv + rshv * rb2v * tshv) * td3v; - solabsShadePhi(IPhi) = t1 * t2 * (1 + rsh * td2 * rb1 * td2 + rsh * rb2) * ash; - solabsPhi(1, IPhi) = af1 + rbmf2 * ab1 + t1 * t2 * rsh * (1 + rf3 * tsh + rb2 * rsh + td2 * rb1 * td2 * rsh) * td2 * abd1; - solabsPhi(2, IPhi) = t1 * af2 + t1 * t2 * ((rsh + tsh * rf3 * tsh + rsh * rb2 * rsh) * abd2 + rsh * td2 * rb1 * afd2); - solabsPhi(3, IPhi) = t1 * t2 * (tsh + rsh * (rb2 * tsh + td2 * rb2 * td2 * tsh + rf3 * rsh)) * afd3; + tsolPhi[iPhi] = t1 * t2 * (tsh + tsh * rf3 * rsh + rsh * td2 * rb1 * td2 * tsh + rsh * rb2 * tsh) * td3; + tvisPhi[iPhi] = t1v * t2v * (tshv + tshv * rf3v * rshv + rshv * td2v * rb1v * td2v * tshv + rshv * rb2v * tshv) * td3v; + solabsShadePhi[iPhi] = t1 * t2 * (1 + rsh * td2 * rb1 * td2 + rsh * rb2) * ash; + solabsPhi(1)[iPhi] = af1 + rbmf2 * ab1 + t1 * t2 * rsh * (1 + rf3 * tsh + rb2 * rsh + td2 * rb1 * td2 * rsh) * td2 * abd1; + solabsPhi(2)[iPhi] = t1 * af2 + t1 * t2 * ((rsh + tsh * rf3 * tsh + rsh * rb2 * rsh) * abd2 + rsh * td2 * rb1 * afd2); + solabsPhi(3)[iPhi] = t1 * t2 * (tsh + rsh * (rb2 * tsh + td2 * rb2 * td2 * tsh + rf3 * rsh)) * afd3; } // End of loop over incidence angle // Front incident solar, diffuse, between-glass shade, NGlass = 3 @@ -1438,44 +1410,34 @@ namespace Window { // visible transmittance as polynomials in cosine of incidence angle if (!BlindOn && !ScreenOn) { // Bare glass or shade on - W5LsqFit(CosPhiIndepVar, tsolPhi, 6, 1, TotalIPhi, thisConstruct.TransSolBeamCoef); - W5LsqFit(CosPhiIndepVar, rfsolPhi, 6, 1, TotalIPhi, thisConstruct.ReflSolBeamFrontCoef); - W5LsqFit(CosPhiIndepVar, rbsolPhi, 6, 1, TotalIPhi, thisConstruct.ReflSolBeamBackCoef); - W5LsqFit(CosPhiIndepVar, tvisPhi, 6, 1, TotalIPhi, thisConstruct.TransVisBeamCoef); - Array1D DepVarCurveFit(TotalIPhi); - Array1D CoeffsCurveFit(6); + W5LsqFit(cosPhisLocal, tsolPhi, thisConstruct.TransSolBeamCoef); + W5LsqFit(cosPhisLocal, rfsolPhi, thisConstruct.ReflSolBeamFrontCoef); + W5LsqFit(cosPhisLocal, rbsolPhi, thisConstruct.ReflSolBeamBackCoef); + W5LsqFit(cosPhisLocal, tvisPhi, thisConstruct.TransVisBeamCoef); for (int IGlass = 1; IGlass <= NGlass; ++IGlass) { // Front absorptance coefficients for glass layers - DepVarCurveFit = solabsPhi(IGlass, {1, TotalIPhi}); - W5LsqFit(CosPhiIndepVar, DepVarCurveFit, 6, 1, TotalIPhi, CoeffsCurveFit); - thisConstruct.AbsBeamCoef(IGlass) = CoeffsCurveFit; + W5LsqFit(cosPhisLocal, solabsPhi(IGlass), thisConstruct.AbsBeamCoef(IGlass)); + // Back absorptance coefficients for glass layers IGlassBack = NGlass - IGlass + 1; - DepVarCurveFit = solabsBackPhi(IGlassBack, {1, TotalIPhi}); - W5LsqFit(CosPhiIndepVar, DepVarCurveFit, 6, 1, TotalIPhi, CoeffsCurveFit); - thisConstruct.AbsBeamBackCoef(IGlass) = CoeffsCurveFit; + W5LsqFit(cosPhisLocal, solabsBackPhi(IGlassBack), thisConstruct.AbsBeamBackCoef(IGlass)); } // To check goodness of fit //Tuned - for (int IPhi = 1; IPhi <= TotalIPhi; ++IPhi) { - tsolPhiFit(IPhi) = 0.0; - tvisPhiFit(IPhi) = 0.0; - - Phi = double(IPhi - 1) * 10.0; - CosPhi = std::cos(Phi * Constant::DegToRadians); - if (std::abs(CosPhi) < 0.0001) CosPhi = 0.0; - Real64 cos_pow(1.0); - for (int CoefNum = 1; CoefNum <= 6; ++CoefNum) { - cos_pow *= CosPhi; - tsolPhiFit(IPhi) += thisConstruct.TransSolBeamCoef(CoefNum) * cos_pow; - tvisPhiFit(IPhi) += thisConstruct.TransVisBeamCoef(CoefNum) * cos_pow; + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { + tsolPhiFit[iPhi] = 0.0; + tvisPhiFit[iPhi] = 0.0; + + for (int CoefNum = 0; CoefNum < maxPolyCoef; ++CoefNum) { + tsolPhiFit[iPhi] += thisConstruct.TransSolBeamCoef[CoefNum] * cosPhisLocal[iPhi]; + tvisPhiFit[iPhi] += thisConstruct.TransVisBeamCoef[CoefNum] * cosPhisLocal[iPhi]; } } } - if (ShadeOn) W5LsqFit(CosPhiIndepVar, solabsShadePhi, 6, 1, TotalIPhi, thisConstruct.AbsBeamShadeCoef); + if (ShadeOn) W5LsqFit(cosPhisLocal, solabsShadePhi, thisConstruct.AbsBeamShadeCoef); } // End of loop over constructions @@ -1604,28 +1566,28 @@ namespace Window { auto &s_mat = state.dataMaterial; auto &s_surf = state.dataSurface; - for (int ConstrNum = 1; ConstrNum <= state.dataHeatBal->TotConstructs; ++ConstrNum) { - auto &thisConstruct = state.dataConstruction->Construct(ConstrNum); - if (thisConstruct.FromWindow5DataFile) continue; - if (thisConstruct.WindowTypeBSDF) continue; - thisConstruct.TransDiff = 0.0; - thisConstruct.TransDiffVis = 0.0; - thisConstruct.AbsDiffBackShade = 0.0; - thisConstruct.ShadeAbsorpThermal = 0.0; - thisConstruct.ReflectSolDiffBack = 0.0; - thisConstruct.ReflectSolDiffFront = 0.0; - thisConstruct.ReflectVisDiffFront = 0.0; - thisConstruct.AbsBeamShadeCoef = 0.0; - thisConstruct.TransSolBeamCoef = 0.0; - thisConstruct.ReflSolBeamFrontCoef = 0.0; - thisConstruct.ReflSolBeamBackCoef = 0.0; - thisConstruct.TransVisBeamCoef = 0.0; - thisConstruct.AbsDiff = 0.0; - thisConstruct.AbsDiffBack = 0.0; + for (auto &constr : state.dataConstruction->Construct) { + if (constr.FromWindow5DataFile) continue; + if (constr.WindowTypeBSDF) continue; + constr.TransDiff = 0.0; + constr.TransDiffVis = 0.0; + constr.AbsDiffBackShade = 0.0; + constr.ShadeAbsorpThermal = 0.0; + constr.ReflectSolDiffBack = 0.0; + constr.ReflectSolDiffFront = 0.0; + constr.ReflectVisDiffFront = 0.0; + + std::fill(constr.AbsBeamShadeCoef.begin(), constr.AbsBeamShadeCoef.end(), 0.0); + std::fill(constr.TransSolBeamCoef.begin(), constr.TransSolBeamCoef.end(), 0.0); + std::fill(constr.ReflSolBeamFrontCoef.begin(), constr.ReflSolBeamFrontCoef.end(), 0.0); + std::fill(constr.ReflSolBeamBackCoef.begin(), constr.ReflSolBeamBackCoef.begin(), 0.0); + std::fill(constr.TransVisBeamCoef.begin(), constr.TransVisBeamCoef.end(), 0.0); + constr.AbsDiff = 0.0; + constr.AbsDiffBack = 0.0; for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { - for (int index = 1; index <= DataSurfaces::MaxPolyCoeff; ++index) { - state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).AbsBeamCoef(Layer)(index) = 0.0; - state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).AbsBeamBackCoef(Layer)(index) = 0.0; + for (int index = 0; index < maxPolyCoef; ++index) { + state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).AbsBeamCoef(Layer)[index] = 0.0; + state.dataConstruction->Construct(state.dataHeatBal->TotConstructs).AbsBeamBackCoef(Layer)[index] = 0.0; } } } @@ -2432,9 +2394,6 @@ namespace Window { wm->thetas = {0.0}; wm->thetasPrev = {0.0}; -#ifdef GET_OUT - wm->fvec = {0.0}; -#endif // GET_OUT // Calculate window face temperatures @@ -2545,122 +2504,6 @@ namespace Window { //**************************************************************************** -#ifdef GET_OUT - void WindowHeatBalanceEquations(EnergyPlusData &state, int const SurfNum) // Surface number - { - - // SUBROUTINE INFORMATION: - // AUTHOR F. Winkelmann - // DATE WRITTEN February 2000 - - // PURPOSE OF THIS SUBROUTINE: - // Evaluates heat balance functions at each glass face. - // Also evaluates Jacobian. - // Currently limited to three glass layers. - - Array1D hgap(maxGlassLayers); // Gap gas conductance - Real64 gr; // Gap gas Grashof number - Real64 con; // Gap gas conductivity - Real64 pr; // Gap gas Prandtl number - Real64 nu; // Gap gas Nusselt number - Real64 thetas_2_3_4; - Real64 thetas_4_5_4; - Real64 thetas_6_7_4; - - auto &wm = state.dataWindowManager; - auto &s_surf = state.dataSurface; - - auto const &surfWin = s_surf->SurfaceWindow(SurfNum); - - // Have to zero fvec each time since LUdecompostion and LUsolution may - // add values to this array in unexpected places - - wm->fvec = {0.0}; - - switch (wm->ngllayer) { - - case 1: { // single pane - wm->fvec[0] = wm->Outir * wm->emis[0] - wm->emis[0] * Constant::StefanBoltzmann * pow_4(wm->thetas[0]) + - wm->scon[0] * (wm->thetas[1] - wm->thetas[0]) + wm->hcout * (wm->tout - wm->thetas[0]) + wm->AbsRadGlassFace[0]; - wm->fvec[1] = wm->Rmir * wm->emis[1] - wm->emis[1] * Constant::StefanBoltzmann * pow_4(wm->thetas[1]) + - wm->scon[0] * (wm->thetas[0] - wm->thetas[1]) + wm->hcin * (wm->tin - wm->thetas[1]) + wm->AbsRadGlassFace[1]; - } break; - case 2: { // double pane - WindowGasConductance(state, wm->thetas[1], wm->thetas[2], 1, con, pr, gr); - NusseltNumber(state, SurfNum, wm->thetas[1], wm->thetas[2], 1, gr, pr, nu); - hgap(1) = (con / wm->gaps[0].width * nu) * surfWin.edgeGlassCorrFac; - - wm->fvec[0] = wm->Outir * wm->emis[0] - wm->emis[0] * Constant::StefanBoltzmann * pow_4(wm->thetas[0]) + - wm->scon[0] * (wm->thetas[1] - wm->thetas[0]) + wm->hcout * (wm->tout - wm->thetas[0]) + wm->AbsRadGlassFace[0]; - thetas_2_3_4 = pow_4(wm->thetas[1]) - pow_4(wm->thetas[2]); - wm->fvec[1] = wm->scon[0] * (wm->thetas[0] - wm->thetas[1]) + hgap(1) * (wm->thetas[2] - wm->thetas[1]) + wm->A23 * thetas_2_3_4 + - wm->AbsRadGlassFace[1]; - wm->fvec[2] = hgap(1) * (wm->thetas[1] - wm->thetas[2]) + wm->scon[1] * (wm->thetas[3] - wm->thetas[2]) - wm->A23 * thetas_2_3_4 + - wm->AbsRadGlassFace[2]; - wm->fvec[3] = wm->Rmir * wm->emis[3] - wm->emis[3] * Constant::StefanBoltzmann * pow_4(wm->thetas[3]) + - wm->scon[1] * (wm->thetas[2] - wm->thetas[3]) + wm->hcin * (wm->tin - wm->thetas[3]) + wm->AbsRadGlassFace[3]; - } break; - case 3: { // Triple Pane - WindowGasConductance(state, wm->thetas[1], wm->thetas[2], 1, con, pr, gr); - NusseltNumber(state, SurfNum, wm->thetas[1], wm->thetas[2], 1, gr, pr, nu); - hgap(1) = con / wm->gaps[0].width * nu * surfWin.edgeGlassCorrFac; - - WindowGasConductance(state, wm->thetas[3], wm->thetas[4], 2, con, pr, gr); - NusseltNumber(state, SurfNum, wm->thetas[3], wm->thetas[4], 2, gr, pr, nu); - hgap(2) = con / wm->gaps[1].width * nu * surfWin.edgeGlassCorrFac; - - thetas_2_3_4 = pow_4(wm->thetas[1]) - pow_4(wm->thetas[2]); - thetas_4_5_4 = pow_4(wm->thetas[3]) - pow_4(wm->thetas[4]); - wm->fvec[0] = wm->Outir * wm->emis[0] - wm->emis[0] * Constant::StefanBoltzmann * pow_4(wm->thetas[0]) + - wm->scon[0] * (wm->thetas[1] - wm->thetas[0]) + wm->hcout * (wm->tout - wm->thetas[0]) + wm->AbsRadGlassFace[0]; - wm->fvec[1] = wm->scon[0] * (wm->thetas[0] - wm->thetas[1]) + hgap(1) * (wm->thetas[2] - wm->thetas[1]) + wm->A23 * thetas_2_3_4 + - wm->AbsRadGlassFace[1]; - wm->fvec[2] = hgap(1) * (wm->thetas[1] - wm->thetas[2]) + wm->scon[1] * (wm->thetas[3] - wm->thetas[2]) - wm->A23 * thetas_2_3_4 + - wm->AbsRadGlassFace[2]; - wm->fvec[3] = wm->scon[1] * (wm->thetas[2] - wm->thetas[3]) + hgap(2) * (wm->thetas[4] - wm->thetas[3]) + wm->A45 * thetas_4_5_4 + - wm->AbsRadGlassFace[3]; - wm->fvec[4] = hgap(2) * (wm->thetas[3] - wm->thetas[4]) + wm->scon[2] * (wm->thetas[5] - wm->thetas[4]) - wm->A45 * thetas_4_5_4 + - wm->AbsRadGlassFace[4]; - wm->fvec[5] = wm->Rmir * wm->emis[5] - wm->emis[5] * Constant::StefanBoltzmann * pow_4(wm->thetas[5]) + - wm->scon[2] * (wm->thetas[4] - wm->thetas[5]) + wm->hcin * (wm->tin - wm->thetas[5]) + wm->AbsRadGlassFace[5]; - } break; - case 4: { // Quad Pane - WindowGasConductance(state, wm->thetas[1], wm->thetas[2], 1, con, pr, gr); - NusseltNumber(state, SurfNum, wm->thetas[1], wm->thetas[2], 1, gr, pr, nu); - hgap(1) = con / wm->gaps[0].width * nu * surfWin.edgeGlassCorrFac; - - WindowGasConductance(state, wm->thetas[3], wm->thetas[4], 2, con, pr, gr); - NusseltNumber(state, SurfNum, wm->thetas[3], wm->thetas[4], 2, gr, pr, nu); - hgap(2) = con / wm->gaps[1].width * nu * surfWin.edgeGlassCorrFac; - - WindowGasConductance(state, wm->thetas[5], wm->thetas[6], 3, con, pr, gr); - NusseltNumber(state, SurfNum, wm->thetas[5], wm->thetas[6], 3, gr, pr, nu); - hgap(3) = con / wm->gaps[2].width * nu * surfWin.edgeGlassCorrFac; - - thetas_2_3_4 = pow_4(wm->thetas[1]) - pow_4(wm->thetas[2]); - thetas_4_5_4 = pow_4(wm->thetas[3]) - pow_4(wm->thetas[4]); - thetas_6_7_4 = pow_4(wm->thetas[5]) - pow_4(wm->thetas[6]); - wm->fvec[0] = wm->Outir * wm->emis[0] - wm->emis[0] * Constant::StefanBoltzmann * pow_4(wm->thetas[0]) + - wm->scon[0] * (wm->thetas[1] - wm->thetas[0]) + wm->hcout * (wm->tout - wm->thetas[0]) + wm->AbsRadGlassFace[0]; - wm->fvec[1] = wm->scon[0] * (wm->thetas[0] - wm->thetas[1]) + hgap(1) * (wm->thetas[2] - wm->thetas[1]) + wm->A23 * thetas_2_3_4 + - wm->AbsRadGlassFace[1]; - wm->fvec[2] = hgap(1) * (wm->thetas[1] - wm->thetas[2]) + wm->scon[1] * (wm->thetas[3] - wm->thetas[2]) - wm->A23 * thetas_2_3_4 + - wm->AbsRadGlassFace[2]; - wm->fvec[3] = wm->scon[1] * (wm->thetas[2] - wm->thetas[3]) + hgap(2) * (wm->thetas[4] - wm->thetas[3]) + wm->A45 * thetas_4_5_4 + - wm->AbsRadGlassFace[3]; - wm->fvec[4] = hgap(2) * (wm->thetas[3] - wm->thetas[4]) + wm->scon[2] * (wm->thetas[5] - wm->thetas[4]) - wm->A45 * thetas_4_5_4 + - wm->AbsRadGlassFace[4]; - wm->fvec[5] = wm->scon[2] * (wm->thetas[4] - wm->thetas[5]) + hgap(3) * (wm->thetas[6] - wm->thetas[5]) + wm->A67 * thetas_6_7_4 + - wm->AbsRadGlassFace[5]; - wm->fvec[6] = hgap(3) * (wm->thetas[5] - wm->thetas[6]) + wm->scon[3] * (wm->thetas[7] - wm->thetas[6]) - wm->A67 * thetas_6_7_4 + - wm->AbsRadGlassFace[6]; - wm->fvec[7] = wm->Rmir * wm->emis[7] - wm->emis[7] * Constant::StefanBoltzmann * pow_4(wm->thetas[7]) + - wm->scon[3] * (wm->thetas[6] - wm->thetas[7]) + wm->hcin * (wm->tin - wm->thetas[7]) + wm->AbsRadGlassFace[7]; - } break; - } // switch - } // WindowHeatBalanceEquations() -#endif // GET_OUT - //**************************************************************************** void GetHeatBalanceEqCoefMatrixSimple(EnergyPlusData &state, @@ -5452,13 +5295,9 @@ namespace Window { } // InterpolateBetweenFourValues() //************************************************************************** - - void W5LsqFit(Array1S const IndepVar, // Independent variables - Array1S const DepVar, // Dependent variables - int const N, // Order of polynomial - int const N1, // First and last data points used - int const N2, - Array1S CoeffsCurve // Polynomial coefficients from fit + void W5LsqFit(std::array const &ivars, // Independent variables + std::array const &dvars, // Dependent variables + std::array &coeffs // Polynomial coefficients from fit ) { @@ -5475,65 +5314,61 @@ namespace Window { // form C1*X + C2*X**2 + C3*X**3 + ... +CN*X**N, where N <= 6. // Adapted from BLAST subroutine LSQFIT. - Array2D A(6, 6); // Least squares derivative matrix - Array1D B(6); // Least squares derivative vector - Array2D D(6, 16); // Powers of independent variable - Real64 ACON; // Intermediate variables - Real64 SUM; - int LP1; - int NM1; + std::array, maxPolyCoef> A; // Least squares derivative matrix + std::array B; // Least squares derivative vector + std::array, maxPolyCoef> D; // Powers of independent variable // Set up least squares matrix - for (int M = N1; M <= N2; ++M) { - D(1, M) = IndepVar(M); + for (int M = 0; M < numPhis; ++M) { + D[0][M] = ivars[M]; } - for (int i = 2; i <= N; ++i) { - for (int M = N1; M <= N2; ++M) { - D(i, M) = D(i - 1, M) * IndepVar(M); + for (int i = 1; i < maxPolyCoef; ++i) { + for (int M = 0; M < numPhis; ++M) { + D[i][M] = D[i - 1][M] * ivars[M]; } } - for (int i = 1; i <= N; ++i) { - SUM = 0.0; - for (int M = N1; M <= N2; ++M) { - SUM += DepVar(M) * D(i, M); + for (int i = 0; i < maxPolyCoef; ++i) { + Real64 SUM = 0.0; + for (int M = 0; M < numPhis; ++M) { + SUM += dvars[M] * D[i][M]; } - B(i) = SUM; - for (int j = 1; j <= N; ++j) { - SUM = 0.0; - for (int M = N1; M <= N2; ++M) { - SUM += D(i, M) * D(j, M); + B[i] = SUM; + for (int j = 0; j < maxPolyCoef; ++j) { + Real64 SUM2 = 0.0; + for (int M = 0; M < numPhis; ++M) { + SUM2 += D[i][M] * D[j][M]; } - A(j, i) = SUM; - A(i, j) = SUM; + A[j][i] = SUM2; + A[i][j] = SUM2; } } // Solve the simultaneous equations using Gauss elimination - NM1 = N - 1; - for (int K = 1; K <= NM1; ++K) { + int order1 = maxPolyCoef - 1; + for (int K = 0; K < order1; ++K) { int KP1 = K + 1; - for (int i = KP1; i <= N; ++i) { - ACON = A(K, i) / A(K, K); - B(i) -= B(K) * ACON; - for (int j = K; j <= N; ++j) { - A(j, i) -= A(j, K) * ACON; + for (int i = KP1; i < maxPolyCoef; ++i) { + Real64 ACON = A[K][i] / A[K][K]; + B[i] -= B[K] * ACON; + for (int j = K; j < maxPolyCoef; ++j) { + A[j][i] -= A[j][K] * ACON; } } } // Perform back substitution - CoeffsCurve(N) = B(N) / A(N, N); - LP1 = N; - int L = N - 1; + coeffs[maxPolyCoef - 1] = B[maxPolyCoef - 1] / A[maxPolyCoef - 1][maxPolyCoef - 1]; + int LP1 = maxPolyCoef - 1; + int L = maxPolyCoef - 2; - while (L > 0) { - SUM = 0.0; - for (int j = LP1; j <= N; ++j) { - SUM += A(j, L) * CoeffsCurve(j); + while (L >= 0) { + Real64 SUM = 0.0; + for (int j = LP1; j < maxPolyCoef; ++j) { + SUM += A[j][L] * coeffs[j]; } - CoeffsCurve(L) = (B(L) - SUM) / A(L, L); + coeffs[L] = (B[L] - SUM) / A[L][L]; LP1 = L; --L; } @@ -5635,7 +5470,7 @@ namespace Window { //*********************************************************************** - Real64 DiffuseAverage(Array1S const PropertyValue) // Property value at angles of incidence + Real64 DiffuseAverage(std::array const &props) // Property value at angles of incidence { // FUNCTION INFORMATION: @@ -5654,23 +5489,18 @@ namespace Window { // 2*PropertyValue(phi)*cos(phi)*sin(phi)*dphi (which is same as // PropertyValue(phi)*sin(2*phi)*dphi) - // Return value - Real64 DiffuseAverage; - // Locals // SUBROUTINE ARGUMENT DEFINITIONS: // 0,10,20,...,80,90 degrees - Real64 const DPhiR(10.0 * Constant::DegToRadians); // Half of 10-deg incidence angle increment (radians) + constexpr Real64 dPhiR = dPhiDeg * Constant::DegToRad; // Half of 10-deg incidence angle increment (radians) - DiffuseAverage = 0.0; - for (int IPhi = 1; IPhi <= 9; ++IPhi) { - DiffuseAverage += - 0.5 * DPhiR * (PropertyValue(IPhi) * std::sin(2.0 * (IPhi - 1) * DPhiR) + PropertyValue(IPhi + 1) * std::sin(2.0 * IPhi * DPhiR)); + Real64 avg = 0.0; + for (int iPhi = 0; iPhi < numPhis - 1; ++iPhi) { + avg += 0.5 * dPhiR * (props[iPhi] * std::sin(2.0 * iPhi * dPhiR) + props[iPhi + 1] * std::sin(2.0 * (iPhi + 1) * dPhiR)); } - if (DiffuseAverage < 0.0) DiffuseAverage = 0.0; - return DiffuseAverage; + return (avg < 0.0) ? 0.0 : avg; } // DiffuseAverage() //************************************************************************************* @@ -6128,11 +5958,11 @@ namespace Window { return; } - TSolNorm = General::POLYF(1.0, state.dataConstruction->Construct(ConstrNum).TransSolBeamCoef); - TVisNorm = General::POLYF(1.0, state.dataConstruction->Construct(ConstrNum).TransVisBeamCoef); + TSolNorm = POLYF(1.0, state.dataConstruction->Construct(ConstrNum).TransSolBeamCoef); + TVisNorm = POLYF(1.0, state.dataConstruction->Construct(ConstrNum).TransVisBeamCoef); AbsBeamShadeNorm = 0.0; if (ShadeFlag == WinShadingType::IntShade || ShadeFlag == WinShadingType::ExtShade) { // Exterior or interior shade on - AbsBeamShadeNorm = General::POLYF(1.0, state.dataConstruction->Construct(ConstrNum).AbsBeamShadeCoef); + AbsBeamShadeNorm = POLYF(1.0, state.dataConstruction->Construct(ConstrNum).AbsBeamShadeCoef); // Exterior blind or screen or interior blind on } else if (ShadeFlag == WinShadingType::IntBlind || ShadeFlag == WinShadingType::ExtBlind || ShadeFlag == WinShadingType::ExtScreen) { // Find unshaded construction that goes with this construction w/blind or screen @@ -6163,8 +5993,8 @@ namespace Window { } auto const &constructBare = state.dataConstruction->Construct(ConstrNumBare); - TBmBm = General::POLYF(1.0, constructBare.TransSolBeamCoef); - TBmBmVis = General::POLYF(1.0, constructBare.TransVisBeamCoef); + TBmBm = POLYF(1.0, constructBare.TransSolBeamCoef); + TBmBmVis = POLYF(1.0, constructBare.TransVisBeamCoef); if (ShadeFlag == WinShadingType::ExtScreen) { // Don't need to call subroutine, use normal incident properties (SUBROUTINE CalcNominalWindowCond) @@ -6182,8 +6012,8 @@ namespace Window { RScBackVis = matScreen->ShadeRefVis; RScDifBack = matScreen->DfRef; RScDifBackVis = matScreen->DfRefVis; - RGlFront = General::POLYF(1.0, constructBare.ReflSolBeamFrontCoef); - RGlFrontVis = General::POLYF(1.0, constructBare.ReflSolBeamFrontCoef); + RGlFront = POLYF(1.0, constructBare.ReflSolBeamFrontCoef); + RGlFrontVis = POLYF(1.0, constructBare.ReflSolBeamFrontCoef); RGlDiffFront = constructBare.ReflectSolDiffFront; RGlDiffFrontVis = constructBare.ReflectVisDiffFront; TSolNorm = TScBmBm * (TBmBm + TDif * RGlFront * RScBack / (1 - RGlDiffFront * RScDifBack)) + @@ -6235,8 +6065,8 @@ namespace Window { (TBlBmBm + TBlBmDifVis + TBlDifDifVis * RhoBlFrontVis * RGlDiffBackVis / (1.0 - RhoBlDiffFrontVis * RGlDiffBackVis)); } else if (ShadeFlag == WinShadingType::ExtBlind) { - RGlFront = General::POLYF(1.0, constructBare.ReflSolBeamFrontCoef); - RGlFrontVis = General::POLYF(1.0, constructBare.ReflSolBeamFrontCoef); + RGlFront = POLYF(1.0, constructBare.ReflSolBeamFrontCoef); + RGlFrontVis = POLYF(1.0, constructBare.ReflSolBeamFrontCoef); AbsBlFront = blindTAR.Sol.Ft.Bm[profIdxLo].Abs; AbsBlBack = blindTAR.Sol.Bk.Bm[profIdxLo].Abs; AbsBlDiffBack = blindTAR.Sol.Bk.Df.Abs; @@ -6290,20 +6120,20 @@ namespace Window { wm->emis[2 * IGlass - 1] = matGlass->AbsorpThermalBack; wm->tir[2 * IGlass - 2] = matGlass->TransThermal; wm->tir[2 * IGlass - 1] = matGlass->TransThermal; - AbsBeamNorm(IGlass) = General::POLYF(1.0, state.dataConstruction->Construct(ConstrNum).AbsBeamCoef(IGlass)); + AbsBeamNorm(IGlass) = POLYF(1.0, state.dataConstruction->Construct(ConstrNum).AbsBeamCoef(IGlass)); if (ShadeFlag == WinShadingType::IntBlind) { // Interior blind on auto const &constructBare = state.dataConstruction->Construct(ConstrNumBare); - AbsBeamNorm(IGlass) = General::POLYF(1.0, constructBare.AbsBeamCoef(IGlass)); + AbsBeamNorm(IGlass) = POLYF(1.0, constructBare.AbsBeamCoef(IGlass)); AGlDiffBack = constructBare.AbsDiffBack(IGlass); AbsBeamNorm(IGlass) += TBmBm * AGlDiffBack * RhoBlFront / (1.0 - RhoBlFront * RGlDiffBack); } else if (ShadeFlag == WinShadingType::ExtBlind) { // Exterior blind on auto const &constructBare = state.dataConstruction->Construct(ConstrNumBare); - AbsBeamNorm(IGlass) = General::POLYF(1.0, constructBare.AbsBeamCoef(IGlass)); + AbsBeamNorm(IGlass) = POLYF(1.0, constructBare.AbsBeamCoef(IGlass)); AbsBeamNorm(IGlass) = TBlBmBm * AbsBeamNorm(IGlass) + (TBlBmBm * RGlFront * RhoBlBack + TBlBmDif) * constructBare.AbsDiff(IGlass) / (1.0 - RGlDiffFront * RhoBlDiffBack); } else if (ShadeFlag == WinShadingType::ExtScreen) { // Exterior screen on auto const &constructBare = state.dataConstruction->Construct(ConstrNumBare); - AbsBeamNorm(IGlass) = General::POLYF(1.0, constructBare.AbsBeamCoef(IGlass)); + AbsBeamNorm(IGlass) = POLYF(1.0, constructBare.AbsBeamCoef(IGlass)); AbsBeamNorm(IGlass) = TScBmBm * AbsBeamNorm(IGlass) + (TScBmBm * RGlFront * RScBack + TScBmDif) * constructBare.AbsDiff(IGlass) / (1.0 - RGlDiffFront * RScDifBack); } @@ -7673,8 +7503,7 @@ namespace Window { c.dim(15); p.dim(16); - Array1D fEdgeSource(10); // Slat edge correction factor vs source elevation - Array1D fEdgeA(2); // Average slat edge correction factor for upper and lower quadrants + Array1D fEdgeA(2); // Average slat edge correction factor for upper and lower quadrants // seen by window blind Array1D j(6); // Slat section radiosity vector Array1D G(6); // Slat section irradiance vector @@ -7766,7 +7595,6 @@ namespace Window { } // Irradiances - for (int k = 1; k <= 6; ++k) { G(k) = 0.0; for (int m = 1; m <= 6; ++m) { @@ -7776,13 +7604,18 @@ namespace Window { } // Slat edge correction factor - Real64 const phib = b_el; // Elevation of slat normal vector (radians) - Real64 constexpr delphis = Constant::PiOvr2 / 10.0; // Angle increment for integration over source distribution (radians) + std::array fEdgeSource; // Slat edge correction factor vs source elevation + + Real64 const phib = b_el; // Elevation of slat normal vector (radians) + Real64 constexpr delphis = + Constant::PiOvr2 / + 10.0; // Angle increment for integration over source distribution (radians) // This is a bug, the delta is 10.0, PiOvr2/10.0 is 9.0. + for (int IUpDown = 1; IUpDown <= 2; ++IUpDown) { - for (int Iphis = 1; Iphis <= 10; ++Iphis) { - Real64 phis = -(Iphis - 0.5) * delphis; // Source elevation (radians) - if (IUpDown == 2) phis = (Iphis - 0.5) * delphis; - fEdgeSource(Iphis) = 0.0; + for (int iPhi = 0; iPhi < numPhis; ++iPhi) { + Real64 phis = -((double)iPhi + 0.5) * delphis; // Source elevation (radians) + if (IUpDown == 2) phis = ((double)iPhi + 0.5) * delphis; + fEdgeSource[iPhi] = 0.0; Real64 fEdge1 = 0.0; Real64 gamma = phib - phis; if (std::abs(std::sin(gamma)) > 0.01) { @@ -7791,7 +7624,7 @@ namespace Window { fEdge1 = matBlind->SlatThickness * std::abs(std::sin(gamma)) / ((matBlind->SlatSeparation + matBlind->SlatThickness / std::abs(std::sin(phib))) * std::cos(phis)); } - fEdgeSource(Iphis) = min(1.0, std::abs(fEdge1)); + fEdgeSource[iPhi] = min(1.0, std::abs(fEdge1)); } } fEdgeA(IUpDown) = DiffuseAverage(fEdgeSource); diff --git a/src/EnergyPlus/WindowManager.hh b/src/EnergyPlus/WindowManager.hh index 730049a628d..99ed3d75cc9 100644 --- a/src/EnergyPlus/WindowManager.hh +++ b/src/EnergyPlus/WindowManager.hh @@ -52,12 +52,11 @@ #include #include #include -#include // EnergyPlus Headers #include #include -#include +#include #include #include #include @@ -75,9 +74,25 @@ namespace Window { int constexpr maxGlassLayers = 5; int constexpr maxGapLayers = 5; - int constexpr maxIncidentAngles = 20; int constexpr maxSpectralDataElements = 800; // Maximum number in Spectral Data arrays. + int constexpr numPhis = 10; + Real64 constexpr dPhiDeg = 10.0; + Real64 constexpr dPhiRad = dPhiDeg * Constant::DegToRad; + + constexpr std::array cosPhis = {1.0, + 0.98480775301220802, + 0.93969262078590842, + 0.86602540378443871, + 0.76604444311897812, + 0.64278760968653936, + 0.50000000000000011, + 0.34202014332566882, + 0.17364817766693041, + 0.0}; // 6.123233995736766E-17 + + constexpr int maxPolyCoef = 6; + class CWindowModel; class CWindowOpticalModel; class CWindowConstructionsSimplified; @@ -139,10 +154,6 @@ namespace Window { Real64 &SurfOutsideTemp // Outside surface temperature (C) ); -#ifdef GET_OUT - void WindowHeatBalanceEquations(EnergyPlusData &state, int SurfNum); // Surface number -#endif // GET_OUT - void GetHeatBalanceEqCoefMatrixSimple(EnergyPlusData &state, int nglasslayer, // Number of glass layers Array1D const &hr, // Radiative conductance (W/m2-K) @@ -229,6 +240,26 @@ namespace Window { Array1D &b // Matrix and vector in a.x = b; ); + constexpr Real64 POLYF(Real64 const X, // Cosine of angle of incidence + std::array const &A // Polynomial coefficients + ) + { + return (X < 0.0 || X > 1.0) ? 0.0 : (X * (A[0] + X * (A[1] + X * (A[2] + X * (A[3] + X * (A[4] + X * A[5])))))); + } + +#ifdef GET_OUT + constexpr Real64 POLYF(Real64 const X, // Cosine of angle of incidence + Array1D const &A // Polynomial coefficients + ) + { + if (X < 0.0 || X > 1.0) { + return 0.0; + } else { + return X * (A(1) + X * (A(2) + X * (A(3) + X * (A(4) + X * (A(5) + X * A(6)))))); + } + } +#endif // GET_OUT + void WindowGasConductance(EnergyPlusData &state, Real64 tleft, // Temperature of gap surface closest to outside (K) Real64 tright, // Temperature of gap surface closest to zone (K) @@ -277,27 +308,12 @@ namespace Window { Real64 InterpolateBetweenFourValues( Real64 X, Real64 Y, Real64 X1, Real64 X2, Real64 Y1, Real64 Y2, Real64 Fx1y1, Real64 Fx1y2, Real64 Fx2y1, Real64 Fx2y2); - void W5LsqFit(Array1S IndepVar, // Independent variables - Array1S DepVar, // Dependent variables - int N, // Order of polynomial - int N1, // First and last data points used - int N2, - Array1S CoeffsCurve // Polynomial coeffients from fit - ); - - void W5LsqFit2(Array1A IndepVar, // Independent variables - Array1A DepVar, // Dependent variables - int N, // Order of polynomial - int N1, // First and last data points used - int N2, - Array1A CoeffsCurve // Polynomial coeffients from fit + void W5LsqFit(std::array const &ivars, // Independent variables + std::array const &dvars, // Dependent variables + std::array &coeffs // Polynomial coeffients from fit ); - Real64 DiffuseAverage(Array1S PropertyValue); // Property value at angles of incidence - - Real64 DiffuseAverageProfAngGnd(Array1S Property); // Property value vs. profile angle - - Real64 DiffuseAverageProfAngSky(Array1S Property); // Property value vs. profile angle + Real64 DiffuseAverage(std::array const &props); // Property value at angles of incidence void CalcWinFrameAndDividerTemps(EnergyPlusData &state, int SurfNum, // Surface number @@ -480,9 +496,6 @@ struct WindowManagerData : BaseGlobalStruct 0.0}; // Solar radiation and IR radiation from internal gains absorbed by glass face std::array thetas = {0.0}; // Glass surface temperatures (K) std::array thetasPrev = {0.0}; // Previous-iteration glass surface temperatures (K) -#ifdef GET_OUT - std::array fvec = {0.0}; // Glass face heat balance function -#endif // GET_OUT std::array hrgap = {0.0}; // Radiative gap conductance @@ -553,9 +566,6 @@ struct WindowManagerData : BaseGlobalStruct this->AbsRadGlassFace = {0.0}; this->thetas = {0.0}; this->thetasPrev = {0.0}; -#ifdef GET_OUT - this->fvec = {0.0}; -#endif // GET_OUT this->hrgap = {0.0}; this->A23P = 0.0; this->A32P = 0.0; diff --git a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc index dbb84bbd90a..74ec7167d4e 100644 --- a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc @@ -4909,10 +4909,13 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_IncSolarMultiplier) int ConstrNum = 1; state->dataSurface->Surface(SurfNum).Construction = ConstrNum; + auto &constr = state->dataConstruction->Construct(ConstrNum); + state->dataSurface->SurfActiveConstruction(SurfNum) = state->dataSurface->Surface(SurfNum).Construction; state->dataConstruction->Construct(ConstrNum).TransDiff = 0.1; - state->dataConstruction->Construct(ConstrNum).TransSolBeamCoef = 0.1; - state->dataConstruction->Construct(ConstrNum).TransSolBeamCoef = 0.2; + // Why is this being written and immediately overwritten? + std::fill(constr.TransSolBeamCoef.begin(), constr.TransSolBeamCoef.end(), 0.1); + std::fill(constr.TransSolBeamCoef.begin(), constr.TransSolBeamCoef.end(), 0.2); state->dataSurface->SurfaceWindow.allocate(totSurf); state->dataSurface->SurfaceWindow(SurfNum).OutProjSLFracMult[state->dataGlobal->HourOfDay] = 999.0; diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 23d8830f682..26d993ae1e8 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -5223,7 +5223,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcBeamSolarOnWinRevealSurface) construct1.LayerPoint(1) = 1; construct1.Name = "Construction1"; construct1.TotGlassLayers = 1; - construct1.TransSolBeamCoef(1) = 0.9; + construct1.TransSolBeamCoef[0] = 0.9; auto &s_mat = state->dataMaterial; @@ -5250,7 +5250,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcBeamSolarOnWinRevealSurface) state->dataHeatBal->SurfSunlitFracWithoutReveal(state->dataGlobal->HourOfDay, state->dataGlobal->TimeStep, 2) = 1.0; Window::W5InitGlassParameters(*state); - construct1.TransSolBeamCoef(1) = 0.9; + construct1.TransSolBeamCoef[0] = 0.9; state->dataSurface->SurfWinTanProfileAngVert(1) = 10.0; state->dataSurface->SurfWinTanProfileAngVert(2) = 10.0; state->dataSurface->SurfWinTanProfileAngHor(1) = 10.0;