From 63a5723cc08000f3b142516b319e1de5f5f2a140 Mon Sep 17 00:00:00 2001 From: amirroth Date: Mon, 19 Aug 2024 18:43:29 -0400 Subject: [PATCH] Fix some integration/regression issues --- src/EnergyPlus/Construction.hh | 1 + src/EnergyPlus/HeatBalFiniteDiffManager.cc | 2 +- src/EnergyPlus/HeatBalanceManager.cc | 16 ++++++---------- src/EnergyPlus/Material.cc | 15 +++++++++++++-- src/EnergyPlus/Material.hh | 6 ++---- src/EnergyPlus/MoistureBalanceEMPDManager.cc | 2 +- src/EnergyPlus/SQLiteProcedures.cc | 2 +- src/EnergyPlus/WindowManager.cc | 2 +- src/EnergyPlus/WindowManagerExteriorOptical.cc | 7 ++++--- tst/EnergyPlus/unit/Construction.unit.cc | 1 - .../unit/ConvectionCoefficients.unit.cc | 1 - tst/EnergyPlus/unit/HeatBalanceManager.unit.cc | 5 +---- .../unit/HeatBalanceSurfaceManager.unit.cc | 2 -- tst/EnergyPlus/unit/SolarShading.unit.cc | 1 - 14 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/EnergyPlus/Construction.hh b/src/EnergyPlus/Construction.hh index b70affd0583..0331ea94370 100644 --- a/src/EnergyPlus/Construction.hh +++ b/src/EnergyPlus/Construction.hh @@ -251,6 +251,7 @@ namespace Construction { bool isTCWindow = false; bool isTCMaster = false; int TCMasterConstrNum = 0; // The master TC construction referenced by its slave constructions + int TCMasterMatNum = 0; // The master TC material int TCLayerNum = 0; // Which material layer is the TC glazing, counting all material layers. int TCGlassNum = 0; // Which glass layer is the TC glazing, counting from glass layers only. int numTCChildConstrs; diff --git a/src/EnergyPlus/HeatBalFiniteDiffManager.cc b/src/EnergyPlus/HeatBalFiniteDiffManager.cc index 4e174801041..7466454736f 100644 --- a/src/EnergyPlus/HeatBalFiniteDiffManager.cc +++ b/src/EnergyPlus/HeatBalFiniteDiffManager.cc @@ -208,7 +208,7 @@ namespace HeatBalFiniteDiffManager { int numProps = setSizeMaxProperties(state); MaterialProps.allocate(numProps); - s_hbfd->MaterialFD.allocate(state.dataMaterial->TotMaterials); + s_hbfd->MaterialFD.allocate(s_mat->materials.size()); // Load the additional CondFD Material properties s_ipsc->cCurrentModuleObject = "MaterialProperty:PhaseChange"; // Phase Change Information First diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index f9ddd232769..3ae3ebc8dea 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -1497,6 +1497,7 @@ namespace HeatBalanceManager { thisConstruct.isTCWindow = true; thisConstruct.isTCMaster = true; thisConstruct.TCMasterConstrNum = ConstrNum; + thisConstruct.TCMasterMatNum = matGlassTC->Num; thisConstruct.TCGlassNum = GlassLayer; // the TC glass layer ID thisConstruct.TCLayerNum = Layer; thisConstruct.TypeIsWindow = true; @@ -3615,7 +3616,6 @@ namespace HeatBalanceManager { Array2D_int NumGases(4, 2); // Number of gases in each gap of a glazing system Array2D_int MaterNumSysGlass(5, 2); // Material numbers for glazing system / glass combinations Array2D_int MaterNumSysGap(4, 2); // Material numbers for glazing system / gap combinations - int TotMaterialsPrev; // Number of materials before adding ones from W5DataFile int TotFrameDividerPrev; // Number of FrameAndDivider objects before adding ones from W5DataFile Array1D_int NGaps(2); // Number of gaps in window construction int NGlSys; // Number of glazing systems (normally 1, but 2 for mullioned window @@ -4009,14 +4009,10 @@ namespace HeatBalanceManager { "of above errors", DesiredConstructionName)); - TotMaterialsPrev = s_mat->TotMaterials; for (IGlSys = 1; IGlSys <= NGlSys; ++IGlSys) { NGaps(IGlSys) = NGlass(IGlSys) - 1; - s_mat->TotMaterials += NGlass(IGlSys) + NGaps(IGlSys); } - - // Create Material objects - + // Glass objects NextLine = W5DataFile.readLine(); if (NextLine.eof) goto Label1000; @@ -4227,8 +4223,8 @@ namespace HeatBalanceManager { } thisConstruct.OutsideRoughness = Material::SurfaceRoughness::VerySmooth; - thisConstruct.InsideAbsorpThermal = s_mat->materials(TotMaterialsPrev + NGlass(IGlSys))->AbsorpThermalBack; - thisConstruct.OutsideAbsorpThermal = s_mat->materials(TotMaterialsPrev + 1)->AbsorpThermalFront; + thisConstruct.InsideAbsorpThermal = s_mat->materials(thisConstruct.LayerPoint(thisConstruct.TotLayers))->AbsorpThermalBack; + thisConstruct.OutsideAbsorpThermal = s_mat->materials(thisConstruct.LayerPoint(1))->AbsorpThermalFront; thisConstruct.TypeIsWindow = true; thisConstruct.FromWindow5DataFile = true; thisConstruct.W5FileGlazingSysHeight = WinHeight(IGlSys); @@ -5188,7 +5184,7 @@ namespace HeatBalanceManager { if (!constr.isTCMaster) continue; - auto const *matGlassTC = dynamic_cast(s_mat->materials(constr.LayerPoint(constr.TCLayerNum))); + auto const *matGlassTC = dynamic_cast(s_mat->materials(constr.TCMasterMatNum)); assert(matGlassTC != nullptr); NumNewConst += matGlassTC->numMatRefs; } @@ -5207,7 +5203,7 @@ namespace HeatBalanceManager { auto &constr = state.dataConstruction->Construct(Loop); if (!constr.isTCMaster) continue; - auto const *matGlassTC = dynamic_cast(s_mat->materials(constr.LayerPoint(constr.TCLayerNum))); + auto const *matGlassTC = dynamic_cast(s_mat->materials(constr.TCMasterMatNum)); assert(matGlassTC != nullptr); constr.numTCChildConstrs = matGlassTC->numMatRefs; diff --git a/src/EnergyPlus/Material.cc b/src/EnergyPlus/Material.cc index 31aebec8af1..a3db5d1c7a3 100644 --- a/src/EnergyPlus/Material.cc +++ b/src/EnergyPlus/Material.cc @@ -2466,7 +2466,12 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } auto const &instances = itInstances.value(); - auto const itObj = instances.find(s_ipsc->cAlphaArgs(3)); + auto itObj = instances.begin(); + // Can't use find here because epJSON keys are not upper-cased + for (; itObj != instances.end(); ++itObj) { + if (Util::makeUPPER(itObj.key()) == s_ipsc->cAlphaArgs(3)) break; + } + if (itObj == instances.end()) { ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); ErrorsFound = true; @@ -2488,7 +2493,13 @@ void GetMaterialData(EnergyPlusData &state, bool &ErrorsFound) // set to true if } auto const &instances = itInstances.value(); - auto const itObj = instances.find(s_ipsc->cAlphaArgs(4)); + + auto itObj = instances.begin(); + // Can't use find here because epJSON keys are not upper-cased + for (; itObj != instances.end(); ++itObj) { + if (Util::makeUPPER(itObj.key()) == s_ipsc->cAlphaArgs(4)) break; + } + if (itObj == instances.end()) { ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); ErrorsFound = true; diff --git a/src/EnergyPlus/Material.hh b/src/EnergyPlus/Material.hh index 6cc00d43a00..cfc8f462022 100644 --- a/src/EnergyPlus/Material.hh +++ b/src/EnergyPlus/Material.hh @@ -842,8 +842,6 @@ struct MaterialData : BaseGlobalStruct Array1D materials; std::map materialMap; - int TotMaterials = 0; // Total number of unique materials (layers) in this simulation - int NumRegulars = 0; int NumNoMasses = 0; int NumIRTs = 0; @@ -881,8 +879,8 @@ struct MaterialData : BaseGlobalStruct void clear_state() override { - for (int i = 0; i < TotMaterials; ++i) { - delete materials[i]; // + for (int i = 0; i < materials.isize(); ++i) { + delete materials[i]; } materials.clear(); materialMap.clear(); diff --git a/src/EnergyPlus/MoistureBalanceEMPDManager.cc b/src/EnergyPlus/MoistureBalanceEMPDManager.cc index 8d76a23e398..583837f1353 100644 --- a/src/EnergyPlus/MoistureBalanceEMPDManager.cc +++ b/src/EnergyPlus/MoistureBalanceEMPDManager.cc @@ -762,7 +762,7 @@ void ReportMoistureBalanceEMPD(EnergyPlusData &state) assert(matEMPD != nullptr); static constexpr std::string_view Format_700( - " Construction EMPD, {}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}\n"); + " Construction EMPD, {}, {}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}, {:8.4F}\n"); print(state.files.eio, Format_700, constr.Name, diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 988d4d9f0cd..5400885192b 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -196,7 +196,7 @@ void CreateSQLiteZoneExtendedOutput(EnergyPlusData &state) auto const &surface = state.dataSurface->Surface(surfaceNumber); state.dataSQLiteProcedures->sqlite->addSurfaceData(surfaceNumber, surface, DataSurfaces::cSurfaceClass(surface.Class)); } - for (int materialNum = 1; materialNum <= state.dataMaterial->TotMaterials; ++materialNum) { + for (int materialNum = 1; materialNum <= state.dataMaterial->materials.size(); ++materialNum) { state.dataSQLiteProcedures->sqlite->addMaterialData(materialNum, state.dataMaterial->materials(materialNum)); } for (int constructNum = 1; constructNum <= state.dataHeatBal->TotConstructs; ++constructNum) { diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index d5974080faf..c9796d4bf2c 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -460,7 +460,7 @@ namespace Window { if (IntShade || ExtShade || ExtScreen) { ShadeLayPtr = thisConstruct.LayerPoint(ShadeLayNum); - auto const *matShade = dynamic_cast(s_mat->materials(ShadeLayPtr)); + auto const *matShade = dynamic_cast(s_mat->materials(ShadeLayPtr)); assert(matShade != nullptr); if (ExtScreen) { auto const *matScreen = dynamic_cast(matShade); diff --git a/src/EnergyPlus/WindowManagerExteriorOptical.cc b/src/EnergyPlus/WindowManagerExteriorOptical.cc index 034e25700d2..374692a7cc1 100644 --- a/src/EnergyPlus/WindowManagerExteriorOptical.cc +++ b/src/EnergyPlus/WindowManagerExteriorOptical.cc @@ -224,13 +224,14 @@ namespace Window { if (surf.activeShadedConstruction == 0) continue; auto &constrSh = state.dataConstruction->Construct(surf.activeShadedConstruction); int TotLay = constrSh.TotLayers; - auto const *mat = dynamic_cast(s_mat->materials(constrSh.LayerPoint(TotLay))); + auto const *mat = s_mat->materials(constrSh.LayerPoint(TotLay)); if (mat->group == Material::Group::Shade) { + auto const *matShade = dynamic_cast(mat); Real64 EpsGlIR = s_mat->materials(constrSh.LayerPoint(TotLay - 1))->AbsorpThermalBack; Real64 RhoGlIR = 1 - EpsGlIR; - Real64 TauShIR = mat->TransThermal; - Real64 EpsShIR = mat->AbsorpThermal; + Real64 TauShIR = matShade->TransThermal; + Real64 EpsShIR = matShade->AbsorpThermal; Real64 RhoShIR = max(0.0, 1.0 - TauShIR - EpsShIR); surfShade.effShadeEmi = EpsShIR * (1.0 + RhoGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR)); surfShade.effGlassEmi = EpsGlIR * TauShIR / (1.0 - RhoGlIR * RhoShIR); diff --git a/tst/EnergyPlus/unit/Construction.unit.cc b/tst/EnergyPlus/unit/Construction.unit.cc index 345c7409bfe..93ffc51b4db 100644 --- a/tst/EnergyPlus/unit/Construction.unit.cc +++ b/tst/EnergyPlus/unit/Construction.unit.cc @@ -70,7 +70,6 @@ TEST_F(EnergyPlusFixture, Construction_reportLayers) SetPredefinedTables(*state); - m->TotMaterials = 8; auto *mata = new Material::MaterialBase; mata->Name = "mat a"; m->materials.push_back(mata); auto *matb = new Material::MaterialBase; matb->Name = "mat b"; m->materials.push_back(matb); auto *matc = new Material::MaterialBase; matc->Name = "mat c"; m->materials.push_back(matc); diff --git a/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc b/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc index 1d7ddc55895..8af223662d3 100644 --- a/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc +++ b/tst/EnergyPlus/unit/ConvectionCoefficients.unit.cc @@ -3756,7 +3756,6 @@ TEST_F(ConvectionCoefficientsFixture, RoofExtConvectionCoefficient) state->dataConstruction->Construct(1).LayerPoint(1) = 1; // define material - s_mat->TotMaterials = 1; auto *mat1 = new Material::MaterialBase; s_mat->materials.push_back(mat1); mat1->AbsorpThermalFront = 0.1; diff --git a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc index b22a0ddc486..623b3f8f178 100644 --- a/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceManager.unit.cc @@ -343,9 +343,6 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetWindowConstructData) bool ErrorsFound(false); // If errors detected in input - s_mat->TotMaterials = 2; - - auto *mat1 = new Material::MaterialGlass; mat1->group = Material::Group::Glass; mat1->Name = "GLASS"; @@ -1860,7 +1857,7 @@ TEST_F(EnergyPlusFixture, HeatBalanceManager_GetAirBoundaryConstructData2) // skip call to get material data since this doesn't use IRT ErrorsFound = false; - EXPECT_EQ(state->dataMaterial->TotMaterials, 0); + EXPECT_EQ(state->dataMaterial->materials.size(), 0); // get constructions ErrorsFound = false; diff --git a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc index 4e05fa578d0..21947075eb1 100644 --- a/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc +++ b/tst/EnergyPlus/unit/HeatBalanceSurfaceManager.unit.cc @@ -289,7 +289,6 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_ComputeIntThermalAbsorpFacto state->dataSurface->TotSurfaces = 1; state->dataGlobal->NumOfZones = 1; - state->dataMaterial->TotMaterials = 1; state->dataHeatBal->TotConstructs = 1; state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); state->dataHeatBal->space.allocate(1); @@ -3132,7 +3131,6 @@ TEST_F(EnergyPlusFixture, HeatBalanceSurfaceManager_TestInterzoneRadFactorCalc) state->dataSurface->TotSurfaces = 2; state->dataGlobal->NumOfZones = 2; - state->dataMaterial->TotMaterials = 1; state->dataHeatBal->TotConstructs = 1; state->dataViewFactor->NumOfSolarEnclosures = 3; diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 5938812377b..a89c7d029ea 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -5227,7 +5227,6 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcBeamSolarOnWinRevealSurface) auto &s_mat = state->dataMaterial; - s_mat->TotMaterials = 1; auto *mat1 = new Material::MaterialGlass; mat1->Name = "GLASS"; mat1->group = Material::Group::Glass;