Skip to content
Open
20 changes: 20 additions & 0 deletions src/EnergyPlus/AirflowNetwork/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12705,6 +12705,7 @@ namespace AirflowNetwork {
DuctSizingSBFlag = true;
}
while (NodeNum1 != NodeSplitter) {
bool foundNextDuct = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added this boolean as part of a trapdoor to prevent an infinite loop failure. This came up in one of the failing unit tests, it then failed more normally, but the approach itself is risky.

for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) {
if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0]) {
continue;
Expand All @@ -12724,10 +12725,14 @@ namespace AirflowNetwork {
DynamicLoss += disSysCompDuct.TurDynCoef;
NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1];
DuctSizingSTFlag = true;
foundNextDuct = true;
break;
}
}
}
if (!foundNextDuct) {
break;
}
}
}
if (DuctSizingSTFlag) {
Expand Down Expand Up @@ -12828,6 +12833,7 @@ namespace AirflowNetwork {
DuctSizingSBFlag = true;
}
while (NodeNum1 != NodeSplitter) {
bool foundNextDuct = false;
for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) {
if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1]) {
continue;
Expand All @@ -12847,10 +12853,14 @@ namespace AirflowNetwork {
DynamicLoss += disSysCompDuct.TurDynCoef;
NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0];
DuctSizingSBFlag = true;
foundNextDuct = true;
break;
}
}
}
if (!foundNextDuct) {
break;
}
}
}
if (DuctSizingSBFlag) {
Expand Down Expand Up @@ -12955,6 +12965,7 @@ namespace AirflowNetwork {
DuctSizingRTFlag = true;
}
while (NodeNum1 != NodeMixer) {
bool foundNextDuct = false;
for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) {
if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1]) {
continue;
Expand All @@ -12974,10 +12985,14 @@ namespace AirflowNetwork {
DynamicLoss += disSysCompDuct.TurDynCoef;
NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0];
DuctSizingRTFlag = true;
foundNextDuct = true;
break;
}
}
}
if (!foundNextDuct) {
break;
}
}
}
if (DuctSizingRTFlag) {
Expand Down Expand Up @@ -13080,6 +13095,7 @@ namespace AirflowNetwork {
DuctSizingRBFlag = true;
}
while (NodeNum1 != NodeMixer) {
bool foundNextDuct = false;
for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) {
if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0]) {
continue;
Expand All @@ -13099,10 +13115,14 @@ namespace AirflowNetwork {
DynamicLoss += disSysCompDuct.TurDynCoef;
NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1];
DuctSizingRBFlag = true;
foundNextDuct = true;
break;
}
}
}
if (!foundNextDuct) {
break;
}
}
}
if (DuctSizingRBFlag) {
Expand Down
7 changes: 4 additions & 3 deletions src/EnergyPlus/Coils/CoilCoolingDX.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ std::shared_ptr<CoilCoolingDXPerformanceBase> CoilCoolingDX::makePerformanceSubc

int CoilCoolingDX::factory(EnergyPlus::EnergyPlusData &state, std::string const &coilName)
{
if (state.dataCoilCoolingDX->coilCoolingDXGetInputFlag) {
if (state.dataCoilCoolingDX->GetInputFlag) {
CoilCoolingDX::getInput(state);
state.dataCoilCoolingDX->coilCoolingDXGetInputFlag = false;
state.dataCoilCoolingDX->GetInputFlag = false;
}
int handle = -1;
std::string coilNameUpper = Util::makeUPPER(coilName);
Expand All @@ -115,10 +115,11 @@ int CoilCoolingDX::factory(EnergyPlus::EnergyPlusData &state, std::string const

void CoilCoolingDX::getInput(EnergyPlusData &state)
{

auto *inputProcessor = state.dataInputProcessing->inputProcessor.get();
auto const coilInstances = inputProcessor->epJSON.find(state.dataCoilCoolingDX->coilCoolingDXObjectName);
if (coilInstances == inputProcessor->epJSON.end() || coilInstances->empty()) {
ShowFatalError(state, R"(No "Coil:Cooling:DX" objects in input file)");
return; // Was fatal error
}
auto const &coilSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataCoilCoolingDX->coilCoolingDXObjectName);

Expand Down
10 changes: 7 additions & 3 deletions src/EnergyPlus/Coils/CoilCoolingDX.hh
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,28 @@ private:
struct CoilCoolingDXData : BaseGlobalStruct
{
std::vector<CoilCoolingDX> coilCoolingDXs;
bool coilCoolingDXGetInputFlag = true;
std::string const coilCoolingDXObjectName = "Coil:Cooling:DX";
HVAC::CoilType coilType = HVAC::CoilType::CoolingDX;
bool stillNeedToReportStandardRatings = true; // standard ratings flag for all coils to report at the same time

bool GetInputFlag = true;

void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
{
}

void init_state([[maybe_unused]] EnergyPlusData &state) override
{
if (this->GetInputFlag) {
CoilCoolingDX::getInput(state);
this->GetInputFlag = false;
}
}

void clear_state() override
{
coilCoolingDXs.clear();
coilCoolingDXGetInputFlag = true;
stillNeedToReportStandardRatings = true;
GetInputFlag = true;
}
};

Expand Down
Loading
Loading