Skip to content

Commit

Permalink
Update based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rraustad committed Oct 21, 2024
1 parent f53ddb4 commit 9b32f9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
24 changes: 8 additions & 16 deletions src/EnergyPlus/PlantUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,6 @@ void PullCompInterconnectTrigger(EnergyPlusData &state,
// SUBROUTINE INFORMATION:
// AUTHOR Edwin Lee
// DATE WRITTEN September 2010
// MODIFIED na
// RE-ENGINEERED na

// PURPOSE OF THIS SUBROUTINE:
// Provides a generic means for components to trigger interconnected loop sides sim flags
Expand All @@ -881,13 +879,6 @@ void PullCompInterconnectTrigger(EnergyPlusData &state,
// associated component. Therefore whenever we come in with a non-zero index, we will just
// verify that the stored loop/side/branch/comp matches

// Using/Aliasing
using DataPlant::CriteriaDelta_HeatTransferRate;
using DataPlant::CriteriaDelta_MassFlowRate;
using DataPlant::CriteriaDelta_Temperature;

CriteriaData CurCriteria; // for convenience

if (UniqueCriteriaCheckIndex <= 0) { // If we don't yet have an index, we need to initialize

// We need to start by allocating, or REallocating the array
Expand All @@ -897,9 +888,10 @@ void PullCompInterconnectTrigger(EnergyPlusData &state,
// Store the unique name and location
state.dataPlantUtilities->CriteriaChecks(CurrentNumChecksStored).CallingCompLoopNum = plantLoc.loopNum;
state.dataPlantUtilities->CriteriaChecks(CurrentNumChecksStored).CallingCompLoopSideNum = plantLoc.loopSideNum;
state.dataPlantUtilities->CriteriaChecks(CurrentNumChecksStored).CallingCompBranchNum = plantLoc.branchNum;
state.dataPlantUtilities->CriteriaChecks(CurrentNumChecksStored).CallingCompCompNum = plantLoc.compNum;

if (plantLoc.loopNum == 0 || plantLoc.loopSideNum == DataPlant::LoopSideLocation::Invalid) {
assert(false); // check that component has been set up correctly
}
// Since this was the first pass, it is safe to assume something has changed!
// Therefore we'll set the sim flag to true
state.dataPlnt->PlantLoop(ConnectedPlantLoc.loopNum).LoopSide(ConnectedPlantLoc.loopSideNum).SimLoopSideNeeded = true;
Expand All @@ -913,27 +905,27 @@ void PullCompInterconnectTrigger(EnergyPlusData &state,
// sim flag status based on the criteria type

// First store the current check in a single variable instead of array for readability
CurCriteria = state.dataPlantUtilities->CriteriaChecks(UniqueCriteriaCheckIndex);
CriteriaData CurCriteria = state.dataPlantUtilities->CriteriaChecks(UniqueCriteriaCheckIndex);

// Initialize, then check if we are out of range
switch (CriteriaType) {
case DataPlant::CriteriaType::MassFlowRate: {
if (std::abs(CurCriteria.ThisCriteriaCheckValue - CriteriaValue) > CriteriaDelta_MassFlowRate) {
if (std::abs(CurCriteria.ThisCriteriaCheckValue - CriteriaValue) > DataPlant::CriteriaDelta_MassFlowRate) {
state.dataPlnt->PlantLoop(ConnectedPlantLoc.loopNum).LoopSide(ConnectedPlantLoc.loopSideNum).SimLoopSideNeeded = true;
}
} break;
case DataPlant::CriteriaType::Temperature: {
if (std::abs(CurCriteria.ThisCriteriaCheckValue - CriteriaValue) > CriteriaDelta_Temperature) {
if (std::abs(CurCriteria.ThisCriteriaCheckValue - CriteriaValue) > DataPlant::CriteriaDelta_Temperature) {
state.dataPlnt->PlantLoop(ConnectedPlantLoc.loopNum).LoopSide(ConnectedPlantLoc.loopSideNum).SimLoopSideNeeded = true;
}
} break;
case DataPlant::CriteriaType::HeatTransferRate: {
if (std::abs(CurCriteria.ThisCriteriaCheckValue - CriteriaValue) > CriteriaDelta_HeatTransferRate) {
if (std::abs(CurCriteria.ThisCriteriaCheckValue - CriteriaValue) > DataPlant::CriteriaDelta_HeatTransferRate) {
state.dataPlnt->PlantLoop(ConnectedPlantLoc.loopNum).LoopSide(ConnectedPlantLoc.loopSideNum).SimLoopSideNeeded = true;
}
} break;
default:
// Diagnostic fatal: improper criteria type
assert(false);
break;
}

Expand Down
15 changes: 3 additions & 12 deletions src/EnergyPlus/PlantUtilities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,9 @@ namespace PlantUtilities {
struct CriteriaData
{
// Members
int CallingCompLoopNum; // for debug error handling
DataPlant::LoopSideLocation CallingCompLoopSideNum; // for debug error handling
int CallingCompBranchNum; // for debug error handling
int CallingCompCompNum; // for debug error handling
Real64 ThisCriteriaCheckValue; // the previous value, to check the current against

// Default Constructor
CriteriaData()
: CallingCompLoopNum(0), CallingCompLoopSideNum(DataPlant::LoopSideLocation::Invalid), CallingCompBranchNum(0), CallingCompCompNum(0),
ThisCriteriaCheckValue(0.0)
{
}
int CallingCompLoopNum = 0; // for debug error handling
DataPlant::LoopSideLocation CallingCompLoopSideNum = DataPlant::LoopSideLocation::Invalid; // for debug error handling
Real64 ThisCriteriaCheckValue = 0.0; // the previous value, to check the current against
};

} // namespace PlantUtilities
Expand Down

4 comments on commit 9b32f9e

@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.

Remove-dead-code (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: Tests Failed (0 of 0 tests passed, 0 test warnings)

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.

Remove-dead-code (rraustad) - Win64-Windows-10-VisualStudio-16: OK (2894 of 2894 tests passed, 0 test warnings)

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.

Remove-dead-code (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-RelWithDebInfo: OK (2098 of 2098 tests passed, 0 test warnings)

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.

Remove-dead-code (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-RelWithDebInfo: OK (801 of 801 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.