Skip to content

Commit

Permalink
Fix variable absorptance, thermochromic window, and PCM issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroth committed Aug 22, 2024
1 parent 3eba56a commit aa8256f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/EnergyPlus/DataHeatBalance.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,6 @@ struct HeatBalanceData : BaseGlobalStruct
bool AnyKiva = false; // Kiva used
bool AnyAirBoundary = false; // Construction:AirBoundary used (implies grouped solar and radiant is present)
bool AnyBSDF = false; // True if any WindowModelType == WindowModel:: BSDF
bool AnyVariableAbsorptance = false; // true if any MaterialProperty:VariableAbsorptance is present
int MaxNumberOfWarmupDays = 25; // Maximum number of warmup days allowed
int MinNumberOfWarmupDays = 1; // Minimum number of warmup days allowed
Real64 CondFDRelaxFactor = 1.0; // Relaxation factor, for looping across all the surfaces.
Expand Down
15 changes: 6 additions & 9 deletions src/EnergyPlus/DataSurfaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -730,16 +730,13 @@ Real64 AbsBackSide(EnergyPlusData &state, int SurfNum)

void GetVariableAbsorptanceSurfaceList(EnergyPlusData &state)
{
if (!state.dataHeatBal->AnyVariableAbsorptance) return;
if (!state.dataMaterial->AnyVariableAbsorptance) return;
for (int surfNum : state.dataSurface->AllHTSurfaceList) {
auto const &thisSurface = state.dataSurface->Surface(surfNum);
int ConstrNum = thisSurface.Construction;
auto const &thisConstruct = state.dataConstruction->Construct(ConstrNum);
int TotLayers = thisConstruct.TotLayers;
if (TotLayers == 0) continue;
int materNum = thisConstruct.LayerPoint(1);
if (materNum == 0) continue; // error finding material number
auto const *mat = state.dataMaterial->materials(materNum);
auto const &thisConstruct = state.dataConstruction->Construct(thisSurface.Construction);
if (thisConstruct.TotLayers == 0) continue;
if (thisConstruct.LayerPoint(1) == 0) continue; // error finding material number
auto const *mat = state.dataMaterial->materials(thisConstruct.LayerPoint(1));
if (mat->group != Material::Group::Regular) continue;

if (mat->absorpVarCtrlSignal != Material::VariableAbsCtrlSignal::Invalid) {
Expand Down Expand Up @@ -768,7 +765,7 @@ void GetVariableAbsorptanceSurfaceList(EnergyPlusData &state)
}
}
}
}
} // GetVariableAbsorptanceSurfaceList()

Compass4 AzimuthToCompass4(Real64 azimuth)
{
Expand Down
17 changes: 15 additions & 2 deletions src/EnergyPlus/HeatBalFiniteDiffManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ namespace HeatBalFiniteDiffManager {
thisSurface.PhaseChangeState = Material::Phase::Transition;
thisSurface.PhaseChangeStateOld = Material::Phase::Transition;
thisSurface.PhaseChangeStateOldOld = Material::Phase::Transition;
thisSurface.PhaseChangeStateRep = Material::phaseInts[(int)Material::Phase::Transition];
thisSurface.PhaseChangeStateOldRep = Material::phaseInts[(int)Material::Phase::Transition];
thisSurface.PhaseChangeStateOldOldRep = Material::phaseInts[(int)Material::Phase::Transition];
thisSurface.PhaseChangeTemperatureReverse = 50;

state.dataMstBal->TempOutsideAirFD(SurfNum) = 0.0;
Expand Down Expand Up @@ -831,6 +834,9 @@ namespace HeatBalFiniteDiffManager {
SurfaceFD(Surf).PhaseChangeState.allocate(TotNodes + 1);
SurfaceFD(Surf).PhaseChangeStateOld.allocate(TotNodes + 1);
SurfaceFD(Surf).PhaseChangeStateOldOld.allocate(TotNodes + 1);
SurfaceFD(Surf).PhaseChangeStateRep.allocate(TotNodes + 1);
SurfaceFD(Surf).PhaseChangeStateOldRep.allocate(TotNodes + 1);
SurfaceFD(Surf).PhaseChangeStateOldOldRep.allocate(TotNodes + 1);
SurfaceFD(Surf).PhaseChangeTemperatureReverse.allocate(TotNodes + 1);
SurfaceFD(Surf).condMaterialActuators.allocate(TotLayers);
SurfaceFD(Surf).specHeatMaterialActuators.allocate(TotLayers);
Expand Down Expand Up @@ -866,6 +872,9 @@ namespace HeatBalFiniteDiffManager {
SurfaceFD(Surf).PhaseChangeState = Material::Phase::Transition;
SurfaceFD(Surf).PhaseChangeStateOld = Material::Phase::Transition;
SurfaceFD(Surf).PhaseChangeStateOldOld = Material::Phase::Transition;
SurfaceFD(Surf).PhaseChangeStateRep = Material::phaseInts[(int)Material::Phase::Transition];
SurfaceFD(Surf).PhaseChangeStateOldRep = Material::phaseInts[(int)Material::Phase::Transition];
SurfaceFD(Surf).PhaseChangeStateOldOldRep = Material::phaseInts[(int)Material::Phase::Transition];
SurfaceFD(Surf).PhaseChangeTemperatureReverse = 50;
SurfaceFD(Surf).condNodeReport = 0.0;
SurfaceFD(Surf).specHeatNodeReport = 0.0;
Expand Down Expand Up @@ -993,14 +1002,14 @@ namespace HeatBalFiniteDiffManager {
SetupOutputVariable(state,
format("CondFD Phase Change State {}", node),
Constant::Units::None,
(int&)SurfaceFD(SurfNum).PhaseChangeState(node),
(int&)SurfaceFD(SurfNum).PhaseChangeStateRep(node),
OutputProcessor::TimeStepType::Zone,
OutputProcessor::StoreType::Average,
state.dataSurface->Surface(SurfNum).Name);
SetupOutputVariable(state,
format("CondFD Phase Change Previous State {}", node),
Constant::Units::None,
(int&)SurfaceFD(SurfNum).PhaseChangeStateOld(node),
(int&)SurfaceFD(SurfNum).PhaseChangeStateOldRep(node),
OutputProcessor::TimeStepType::Zone,
OutputProcessor::StoreType::Average,
state.dataSurface->Surface(SurfNum).Name);
Expand Down Expand Up @@ -1267,6 +1276,8 @@ namespace HeatBalFiniteDiffManager {
surfaceFD.PhaseChangeStateOldOld = surfaceFD.PhaseChangeStateOld;
surfaceFD.PhaseChangeStateOld = surfaceFD.PhaseChangeState;

surfaceFD.PhaseChangeStateOldOldRep = surfaceFD.PhaseChangeStateOldRep;
surfaceFD.PhaseChangeStateOldRep = surfaceFD.PhaseChangeStateRep;
} // Time Loop //PT solving time steps

TempSurfOutTmp = surfaceFD.TDT(1);
Expand Down Expand Up @@ -2681,6 +2692,8 @@ namespace HeatBalFiniteDiffManager {
surfFD.PhaseChangeTemperatureReverse(finiteDifferenceLayerIndex),
surfFD.PhaseChangeStateOld(finiteDifferenceLayerIndex),
surfFD.PhaseChangeState(finiteDifferenceLayerIndex));

surfFD.PhaseChangeStateRep(finiteDifferenceLayerIndex) = Material::phaseInts[(int)surfFD.PhaseChangeState(finiteDifferenceLayerIndex)];
updatedDensity = mat->getDensity(temperaturePrevious);
updatedThermalConductivity = mat->getConductivity(temperatureUpdated);
}
Expand Down
3 changes: 3 additions & 0 deletions src/EnergyPlus/HeatBalFiniteDiffManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ namespace HeatBalFiniteDiffManager {
Array1D<Material::Phase> PhaseChangeState;
Array1D<Material::Phase> PhaseChangeStateOld;
Array1D<Material::Phase> PhaseChangeStateOldOld;
Array1D<int> PhaseChangeStateRep;
Array1D<int> PhaseChangeStateOldRep;
Array1D<int> PhaseChangeStateOldOldRep;
Array1D<Real64> PhaseChangeTemperatureReverse;
Array1D<MaterialActuatorData> condMaterialActuators;
Array1D<MaterialActuatorData> specHeatMaterialActuators;
Expand Down
15 changes: 11 additions & 4 deletions src/EnergyPlus/HeatBalanceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,7 @@ namespace HeatBalanceManager {
ErrorsFound = true;
continue;
} else if (mat->group == Material::Group::GlassTCParent) {
++GlassLayer;
// reset layer pointer to the first glazing in the TC GlazingGroup
auto const *matGlassTC = dynamic_cast<Material::MaterialGlassTC const *>(mat);
assert(matGlassTC != nullptr);
Expand Down Expand Up @@ -5207,20 +5208,26 @@ namespace HeatBalanceManager {
constr.numTCChildConstrs = matGlassTC->numMatRefs;
constr.TCChildConstrs.allocate(constr.numTCChildConstrs);

// The master thermochromic construction uses the first (i.e., lowest temp) glazing
constr.LayerPoint(constr.TCLayerNum) = matGlassTC->matRefs(1).matNum;
constr.specTemp = matGlassTC->matRefs(1).specTemp;

for (int iTC = 1; iTC <= constr.numTCChildConstrs; ++iTC) {
++NumNewConst;
auto &constrNew = state.dataConstruction->Construct(NumNewConst);

constrNew = constr; // This should be a deep copy
constrNew.Name = format("{}_TC_{:.0R}", constr.Name, matGlassTC->matRefs(iTC).specTemp);
constrNew.LayerPoint(constrNew.TCLayerNum) = matGlassTC->matRefs(iTC).matNum;

constr.TCChildConstrs(iTC).specTemp = matGlassTC->matRefs(iTC).specTemp;
constr.TCChildConstrs(iTC).constrNum = NumNewConst;

constrNew.specTemp = matGlassTC->matRefs(iTC).specTemp;

constrNew.isTCWindow = true;
constrNew.isTCMaster = false;
constrNew.TCMasterConstrNum = Loop;

constr.TCChildConstrs(iTC).specTemp = matGlassTC->matRefs(iTC).specTemp;
constr.TCChildConstrs(iTC).constrNum = NumNewConst;

}
}
state.dataHeatBal->TotConstructs = NumNewConst;
Expand Down
5 changes: 3 additions & 2 deletions src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ namespace Material {
}

if (mat->hasEMPD) {
ShowSevereCustomMessage(state, eoh, format("Material {} already has EMPD properties defined.", mat->Name, s_ipsc->cCurrentModuleObject));
ShowSevereCustomMessage(state, eoh, format("Material {} already has EMPD properties defined.", mat->Name));
ErrorsFound = true;
continue;
}

if (mat->hasHAMT) {
ShowSevereCustomMessage(state, eoh, format("Material {} already has HAMT properties defined.", mat->Name, s_ipsc->cCurrentModuleObject));
ShowSevereCustomMessage(state, eoh, format("Material {} already has HAMT properties defined.", mat->Name));
ErrorsFound = true;
continue;
}
Expand Down Expand Up @@ -399,6 +399,7 @@ namespace Material {
matPC->deltaTempFreezingLow = s_ipsc->rNumericArgs(13);
matPC->specHeatTransition = (matPC->specificHeatSolid + matPC->specificHeatLiquid) / 2.0;
matPC->CpOld = matPC->specificHeatSolid;
matPC->hasPCM = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/PhaseChangeModeling/HysteresisModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Material {
Num
};

static constexpr std::array<int, (int)Phase::Num> stateInts = {-2, -1, 0, 1, 2};
static constexpr std::array<int, (int)Phase::Num> phaseInts = {-2, -1, 0, 1, 2};

struct MaterialPhaseChange : public MaterialBase
{
Expand Down

4 comments on commit aa8256f

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blind (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3484 of 3706 tests passed, 12 test warnings)

Messages:\n

  • 171 tests had: EIO diffs.
  • 22 tests had: EDD diffs.
  • 215 tests had: Table string diffs.
  • 13 tests had: ESO big diffs.
  • 3 tests had: Table small diffs.
  • 5 tests had: ERR diffs.
  • 10 tests had: Table big diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: SSZ small diffs.
  • 1 test had: ZSZ small diffs.

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1583
  • SEGFAULT: 1

regression Test Summary

  • Passed: 592
  • Failed: 221

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blind (amirroth) - Win64-Windows-10-VisualStudio-16: OK (2870 of 2871 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1581
  • Failed: 1

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blind (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2076 of 2077 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1583
  • Subprocess aborted: 1

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blind (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (796 of 797 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 796
  • Failed: 1

Build Badge Test Badge Coverage Badge

Please sign in to comment.