From ff88de1bd78b6460357ef3dc9aa9079de8837b99 Mon Sep 17 00:00:00 2001 From: amirroth Date: Wed, 24 Jul 2024 21:53:19 -0400 Subject: [PATCH] Fix a few more things (blinds with movable slats still broken) --- src/EnergyPlus/DataHeatBalance.cc | 83 +++++++++---------- src/EnergyPlus/WindowManager.cc | 2 +- .../WindowManagerExteriorOptical.cc | 83 +++++++------------ 3 files changed, 71 insertions(+), 97 deletions(-) diff --git a/src/EnergyPlus/DataHeatBalance.cc b/src/EnergyPlus/DataHeatBalance.cc index 8328cc8598d..cb2eaadc738 100644 --- a/src/EnergyPlus/DataHeatBalance.cc +++ b/src/EnergyPlus/DataHeatBalance.cc @@ -348,7 +348,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, // This routine checks some properties of entered constructions; sets some properties; and sets // an error flag for certain error conditions. - auto &dmat = state.dataMaterial; + auto &s_mat = state.dataMaterial; auto &thisConstruct = state.dataConstruction->Construct(ConstrNum); int TotLayers = thisConstruct.TotLayers; // Number of layers in a construction @@ -361,7 +361,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, thisConstruct.DayltPropPtr = 0; int InsideMaterNum = thisConstruct.LayerPoint(InsideLayer); // Material "number" of the Inside layer if (InsideMaterNum != 0) { - auto const *mat = dmat->materials(InsideMaterNum); + auto const *mat = s_mat->materials(InsideMaterNum); thisConstruct.InsideAbsorpVis = mat->AbsorpVisible; thisConstruct.InsideAbsorpSolar = mat->AbsorpSolar; @@ -371,7 +371,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, int OutsideMaterNum = thisConstruct.LayerPoint(1); // Material "number" of the Outside layer if (OutsideMaterNum != 0) { - auto const *mat = dmat->materials(OutsideMaterNum); + auto const *mat = s_mat->materials(OutsideMaterNum); thisConstruct.OutsideAbsorpVis = mat->AbsorpVisible; thisConstruct.OutsideAbsorpSolar = mat->AbsorpSolar; } @@ -387,7 +387,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, for (int Layer = 1; Layer <= TotLayers; ++Layer) { int const MaterNum = thisConstruct.LayerPoint(Layer); if (MaterNum == 0) continue; // error -- has been caught will stop program later - auto const *mat = dmat->materials(MaterNum); + auto const *mat = s_mat->materials(MaterNum); thisConstruct.TypeIsWindow = (mat->group == Material::Group::WindowGlass || mat->group == Material::Group::WindowGas || mat->group == Material::Group::WindowGasMixture || mat->group == Material::Group::Shade || @@ -404,9 +404,9 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, } if (InsideMaterNum == 0) return; - auto const *matInside = dmat->materials(InsideMaterNum); + auto const *matInside = s_mat->materials(InsideMaterNum); if (OutsideMaterNum == 0) return; - auto const *matOutside = dmat->materials(OutsideMaterNum); + auto const *matOutside = s_mat->materials(OutsideMaterNum); if (thisConstruct.TypeIsWindow) { @@ -416,7 +416,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, for (int Layer = 1; Layer <= TotLayers; ++Layer) { int const MaterNum = thisConstruct.LayerPoint(Layer); if (MaterNum == 0) continue; // error -- has been caught will stop program later - auto const *mat = dmat->materials(MaterNum); + auto const *mat = s_mat->materials(MaterNum); WrongMaterialsMix = !((mat->group == Material::Group::WindowGlass) || (mat->group == Material::Group::WindowGas) || (mat->group == Material::Group::WindowGasMixture) || (mat->group == Material::Group::Shade) || @@ -444,7 +444,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, ErrorsFound = true; } else if (TotLayers == 1) { - auto const *mat = dmat->materials(thisConstruct.LayerPoint(1)); + auto const *mat = s_mat->materials(thisConstruct.LayerPoint(1)); Material::Group matGroup = mat->group; if ((matGroup == Material::Group::Shade) || (matGroup == Material::Group::WindowGas) || (matGroup == Material::Group::WindowGasMixture) || (matGroup == Material::Group::WindowBlind) || @@ -467,7 +467,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, for (int Layer = 1; Layer <= TotLayers; ++Layer) { int const MaterNum = thisConstruct.LayerPoint(Layer); if (MaterNum == 0) continue; // error -- has been caught will stop program later - auto const *mat = dmat->materials(MaterNum); + auto const *mat = s_mat->materials(MaterNum); if (mat->group == Material::Group::WindowGlass) ++TotGlassLayers; if (mat->group == Material::Group::WindowSimpleGlazing) ++TotGlassLayers; if (mat->group == Material::Group::Shade || mat->group == Material::Group::WindowBlind || @@ -480,7 +480,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, int const MaterNumNext = thisConstruct.LayerPoint(Layer + 1); // Adjacent layers of same type not allowed if (MaterNumNext == 0) continue; - if (mat->group == dmat->materials(MaterNumNext)->group) WrongWindowLayering = true; + if (mat->group == s_mat->materials(MaterNumNext)->group) WrongWindowLayering = true; } } @@ -509,7 +509,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, for (int Layer = 1; Layer <= TotLayers; ++Layer) { int const MatNum = thisConstruct.LayerPoint(Layer); if (MatNum == 0) continue; // error -- has been caught will stop program later - auto const *mat = dmat->materials(MatNum); + auto const *mat = s_mat->materials(MatNum); if (mat->group != Material::Group::WindowGlass && mat->group != Material::Group::WindowSimpleGlazing && mat->group != Material::Group::GlassEquivalentLayer) continue; @@ -530,7 +530,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, for (int Layer = 1; Layer <= TotLayers; ++Layer) { int const MatNum = thisConstruct.LayerPoint(Layer); if (MatNum == 0) continue; // error -- has been caught will stop program later - auto const *mat = dmat->materials(MatNum); + auto const *mat = s_mat->materials(MatNum); if (mat->group != Material::Group::WindowGlass) continue; auto const *matGlass = dynamic_cast(mat); @@ -568,14 +568,14 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, WrongWindowLayering = true; } else { if (matOutside->group == Material::Group::WindowGlass && - (dmat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGas || - dmat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGasMixture) && - ((dmat->materials(thisConstruct.LayerPoint(3))->group == Material::Group::Shade || - dmat->materials(thisConstruct.LayerPoint(3))->group == Material::Group::WindowBlind) && - dmat->materials(thisConstruct.LayerPoint(3))->group != Material::Group::Screen) && - (dmat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGas || - dmat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGasMixture) && - dmat->materials(thisConstruct.LayerPoint(5))->group == Material::Group::WindowGlass) + (s_mat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGas || + s_mat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGasMixture) && + ((s_mat->materials(thisConstruct.LayerPoint(3))->group == Material::Group::Shade || + s_mat->materials(thisConstruct.LayerPoint(3))->group == Material::Group::WindowBlind) && + s_mat->materials(thisConstruct.LayerPoint(3))->group != Material::Group::Screen) && + (s_mat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGas || + s_mat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGasMixture) && + s_mat->materials(thisConstruct.LayerPoint(5))->group == Material::Group::WindowGlass) ValidBGShadeBlindConst = true; } } else { // TotGlassLayers = 3 @@ -583,17 +583,17 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, WrongWindowLayering = true; } else { if (matOutside->group == Material::Group::WindowGlass && - (dmat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGas || - dmat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGasMixture) && - dmat->materials(thisConstruct.LayerPoint(3))->group == Material::Group::WindowGlass && - (dmat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGas || - dmat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGasMixture) && - ((dmat->materials(thisConstruct.LayerPoint(5))->group == Material::Group::Shade || - dmat->materials(thisConstruct.LayerPoint(5))->group == Material::Group::WindowBlind) && - dmat->materials(thisConstruct.LayerPoint(5))->group != Material::Group::Screen) && - (dmat->materials(thisConstruct.LayerPoint(6))->group == Material::Group::WindowGas || - dmat->materials(thisConstruct.LayerPoint(6))->group == Material::Group::WindowGasMixture) && - dmat->materials(thisConstruct.LayerPoint(7))->group == Material::Group::WindowGlass) + (s_mat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGas || + s_mat->materials(thisConstruct.LayerPoint(2))->group == Material::Group::WindowGasMixture) && + s_mat->materials(thisConstruct.LayerPoint(3))->group == Material::Group::WindowGlass && + (s_mat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGas || + s_mat->materials(thisConstruct.LayerPoint(4))->group == Material::Group::WindowGasMixture) && + ((s_mat->materials(thisConstruct.LayerPoint(5))->group == Material::Group::Shade || + s_mat->materials(thisConstruct.LayerPoint(5))->group == Material::Group::WindowBlind) && + s_mat->materials(thisConstruct.LayerPoint(5))->group != Material::Group::Screen) && + (s_mat->materials(thisConstruct.LayerPoint(6))->group == Material::Group::WindowGas || + s_mat->materials(thisConstruct.LayerPoint(6))->group == Material::Group::WindowGasMixture) && + s_mat->materials(thisConstruct.LayerPoint(7))->group == Material::Group::WindowGlass) ValidBGShadeBlindConst = true; } } // End of check if TotGlassLayers = 2 or 3 @@ -601,8 +601,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, if (!WrongWindowLayering) { int const LayNumSh = 2 * TotGlassLayers - 1; int const MatSh = thisConstruct.LayerPoint(LayNumSh); - auto const *matSh = dynamic_cast(dmat->materials(MatSh)); - assert(matSh != nullptr); + auto const *matSh = s_mat->materials(MatSh); // For double pane, shade/blind must be layer #3. // For triple pane, it must be layer #5 (i.e., between two inner panes). if (matSh->group != Material::Group::Shade && matSh->group != Material::Group::WindowBlind) @@ -612,8 +611,8 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, // Gas on either side of a between-glass shade/blind must be the same int const MatGapL = thisConstruct.LayerPoint(LayNumSh - 1); int const MatGapR = thisConstruct.LayerPoint(LayNumSh + 1); - auto const *matGapL = dynamic_cast(dmat->materials(MatGapL)); - auto const *matGapR = dynamic_cast(dmat->materials(MatGapR)); + auto const *matGapL = dynamic_cast(s_mat->materials(MatGapL)); + auto const *matGapR = dynamic_cast(s_mat->materials(MatGapR)); for (int IGas = 0; IGas < Material::maxMixGases; ++IGas) { if ((matGapL->gases[IGas].type != matGapR->gases[IGas].type) || (matGapL->gasFracts[IGas] != matGapR->gasFracts[IGas])) @@ -637,13 +636,13 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, } // End of check if construction has between-glass shade/blind // Check Simple Windows, - if (dmat->materials(thisConstruct.LayerPoint(1))->group == Material::Group::WindowSimpleGlazing) { + if (s_mat->materials(thisConstruct.LayerPoint(1))->group == Material::Group::WindowSimpleGlazing) { if (TotLayers > 1) { // check that none of the other layers are glazing or gas for (int Layer = 1; Layer <= TotLayers; ++Layer) { int const MaterNum = thisConstruct.LayerPoint(Layer); if (MaterNum == 0) continue; // error -- has been caught will stop program later - auto const *mat = dmat->materials(MaterNum); + auto const *mat = s_mat->materials(MaterNum); if (mat->group == Material::Group::WindowGlass) { ErrorsFound = true; ShowSevereError(state, format("CheckAndSetConstructionProperties: Error in window construction {}--", thisConstruct.Name)); @@ -693,7 +692,7 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, thisConstruct.InsideAbsorpThermal = matInside->AbsorpThermalBack; } if (InsideMaterNum != 0) { - auto const *thisInsideMaterial = dynamic_cast(dmat->materials(InsideMaterNum)); + auto const *thisInsideMaterial = dynamic_cast(s_mat->materials(InsideMaterNum)); thisConstruct.InsideAbsorpVis = thisInsideMaterial->AbsorpVisible; thisConstruct.InsideAbsorpSolar = thisInsideMaterial->AbsorpSolar; } @@ -729,10 +728,10 @@ void CheckAndSetConstructionProperties(EnergyPlusData &state, thisConstruct.TypeIsEcoRoof = true; // need to check EcoRoof is not non-outside layer for (int Layer = 2; Layer <= TotLayers; ++Layer) { - if (dmat->materials(thisConstruct.LayerPoint(Layer))->group == Material::Group::EcoRoof) { + if (s_mat->materials(thisConstruct.LayerPoint(Layer))->group == Material::Group::EcoRoof) { ShowSevereError(state, format("CheckAndSetConstructionProperties: Interior Layer is EcoRoof for construction {}", thisConstruct.Name)); - ShowContinueError(state, format(" Error in material {}", dmat->materials(thisConstruct.LayerPoint(Layer))->Name)); + ShowContinueError(state, format(" Error in material {}", s_mat->materials(thisConstruct.LayerPoint(Layer))->Name)); ErrorsFound = true; } } @@ -1042,7 +1041,7 @@ void SetFlagForWindowConstructionWithShadeOrBlindLayer(EnergyPlusData &state) int Layer(0); // construction material layer index int MaterNum(0); // construction material index - auto &dmat = state.dataMaterial; + auto &s_mat = state.dataMaterial; for (loopSurfNum = 1; loopSurfNum <= state.dataSurface->TotSurfaces; ++loopSurfNum) { @@ -1058,7 +1057,7 @@ void SetFlagForWindowConstructionWithShadeOrBlindLayer(EnergyPlusData &state) for (Layer = 1; Layer <= NumLayers; ++Layer) { MaterNum = thisConstruct.LayerPoint(Layer); if (MaterNum == 0) continue; - auto const *mat = dmat->materials(MaterNum); + auto const *mat = s_mat->materials(MaterNum); if (mat->group == Material::Group::Shade || mat->group == Material::Group::WindowBlind) state.dataSurface->SurfWinHasShadeOrBlindLayer(loopSurfNum) = true; } diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index 71bce2307d4..a90bad1d760 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -2373,7 +2373,7 @@ namespace Window { wm->thick[TotGlassLay] = matBlind->SlatThickness; wm->scon[TotGlassLay] = matBlind->SlatConductivity / matBlind->SlatThickness; - if (surfWin.blind.matNum) { + if (surfWin.blind.movableSlats) { int slatIdxLo = surfWin.blind.slatAngIndex; int slatIdxHi = std::min(Material::MaxSlatAngs, slatIdxLo + 1); diff --git a/src/EnergyPlus/WindowManagerExteriorOptical.cc b/src/EnergyPlus/WindowManagerExteriorOptical.cc index 5dff87edd35..be2d6fcabb1 100644 --- a/src/EnergyPlus/WindowManagerExteriorOptical.cc +++ b/src/EnergyPlus/WindowManagerExteriorOptical.cc @@ -189,22 +189,20 @@ namespace Window { auto &construction = state.dataConstruction->Construct(ConstrNum); if (construction.isGlazingConstruction(state)) { for (int LayNum = 1; LayNum <= construction.TotLayers; ++LayNum) { - auto *materialBase = s_mat->materials(construction.LayerPoint(LayNum)); - auto *material = dynamic_cast(materialBase); - assert(material != nullptr); - if (material->group != Material::Group::WindowGas && material->group != Material::Group::WindowGasMixture && - material->group != Material::Group::ComplexWindowGap && material->group != Material::Group::ComplexWindowShade) { + auto const *mat = s_mat->materials(construction.LayerPoint(LayNum)); + if (mat->group != Material::Group::WindowGas && mat->group != Material::Group::WindowGasMixture && + mat->group != Material::Group::ComplexWindowGap && mat->group != Material::Group::ComplexWindowShade) { // This is necessary because rest of EnergyPlus code relies on TransDiff property // of construction. It will basically trigger Window optical calculations if this // property is >0. construction.TransDiff = 0.1; WavelengthRange aRange = WavelengthRange::Solar; - auto aSolarLayer = getScatteringLayer(state, material, aRange); // (AUTO_OK_OBJ) + auto aSolarLayer = getScatteringLayer(state, mat, aRange); // (AUTO_OK_OBJ) aWinConstSimp.pushLayer(aRange, ConstrNum, aSolarLayer); aRange = WavelengthRange::Visible; - auto aVisibleLayer = getScatteringLayer(state, material, aRange); // (AUTO_OK_OBJ) + auto aVisibleLayer = getScatteringLayer(state, mat, aRange); // (AUTO_OK_OBJ) aWinConstSimp.pushLayer(aRange, ConstrNum, aVisibleLayer); } } @@ -226,53 +224,31 @@ namespace Window { int ConstrNumSh = surf.activeShadedConstruction; if (ConstrNumSh == 0) continue; int TotLay = state.dataConstruction->Construct(ConstrNumSh).TotLayers; - bool IntShade = false; - bool IntBlind = false; - int ShadeLayPtr = 0; - int BlNum = 0; - auto const *thisMaterial = dynamic_cast( - s_mat->materials(state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay))); - assert(thisMaterial != nullptr); - if (thisMaterial->group == Material::Group::Shade) { - IntShade = true; - ShadeLayPtr = state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay); - } - if (thisMaterial->group == Material::Group::WindowBlind) { - IntBlind = true; - BlNum = state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay); - } - - if (IntShade || IntBlind) { + auto const *mat = s_mat->materials(state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay)); + + if (mat->group == Material::Group::Shade) { + Real64 EpsGlIR = s_mat->materials(state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay - 1))->AbsorpThermalBack; + Real64 RhoGlIR = 1 - EpsGlIR; + Real64 TauShIR = mat->TransThermal; + Real64 EpsShIR = mat->AbsorpThermal; + Real64 RhoShIR = max(0.0, 1.0 - TauShIR - EpsShIR); + surfWin.EffShBlindEmiss[1] = EpsShIR * (1.0 + RhoGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR)); + surfWin.EffGlassEmiss[1] = EpsGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR); + + } else if (mat->group == Material::Group::WindowBlind) { + Real64 EpsGlIR = s_mat->materials(state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay - 1))->AbsorpThermalBack; + Real64 RhoGlIR = 1 - EpsGlIR; + + auto const *matBlind = dynamic_cast(mat); for (int ISlatAng = 1; ISlatAng <= Material::MaxSlatAngs; ++ISlatAng) { - Real64 EpsGlIR = 0.0; - Real64 RhoGlIR = 0.0; - if (IntShade || IntBlind) { - EpsGlIR = s_mat->materials(state.dataConstruction->Construct(ConstrNumSh).LayerPoint(TotLay - 1))->AbsorpThermalBack; - RhoGlIR = 1 - EpsGlIR; - } - if (IntShade) { - auto const *thisMaterialShade = dynamic_cast(s_mat->materials(ShadeLayPtr)); - Real64 TauShIR = thisMaterialShade->TransThermal; - Real64 EpsShIR = thisMaterialShade->AbsorpThermal; - Real64 RhoShIR = max(0.0, 1.0 - TauShIR - EpsShIR); - surfWin.EffShBlindEmiss[1] = EpsShIR * (1.0 + RhoGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR)); - surfWin.EffGlassEmiss[1] = EpsGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR); - } - if (IntBlind) { - auto const *matBlind = dynamic_cast(s_mat->materials(BlNum)); - Real64 TauShIR = matBlind->IRFrontTrans(ISlatAng); - Real64 EpsShIR = matBlind->IRBackEmiss(ISlatAng); - Real64 RhoShIR = max(0.0, 1.0 - TauShIR - EpsShIR); - surfWin.EffShBlindEmiss[ISlatAng] = EpsShIR * (1.0 + RhoGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR)); - surfWin.EffGlassEmiss[ISlatAng] = EpsGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR); - } - // Loop over remaining slat angles only if blind with movable slats - if (IntShade) break; // Loop over remaining slat angles only if blind - if (IntBlind) { - auto const *matBlind = dynamic_cast(s_mat->materials(BlNum)); - if (matBlind->SlatAngleType == DataWindowEquivalentLayer::AngleType::Fixed) break; - } - } // End of slat angle loop + Real64 TauShIR = matBlind->IRFrontTrans(ISlatAng); + Real64 EpsShIR = matBlind->IRBackEmiss(ISlatAng); + Real64 RhoShIR = max(0.0, 1.0 - TauShIR - EpsShIR); + surfWin.EffShBlindEmiss[ISlatAng] = EpsShIR * (1.0 + RhoGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR)); + surfWin.EffGlassEmiss[ISlatAng] = EpsGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR); + + if (matBlind->SlatAngleType == DataWindowEquivalentLayer::AngleType::Fixed) break; + } } // End of check if interior shade or interior blind } // End of surface loop } @@ -392,7 +368,6 @@ namespace Window { std::shared_ptr CWCEVenetianBlindMaterialsFactory::createVisibleRangeMaterial(EnergyPlusData &state) { - auto &s_mat = state.dataMaterial; auto const *matBlind = dynamic_cast(m_MaterialProperties); assert(matBlind != nullptr);