Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code #10794

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 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,33 +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);

// Check to make sure we didn't reuse the index in multiple components
if (CurCriteria.CallingCompLoopNum != plantLoc.loopNum || CurCriteria.CallingCompLoopSideNum != plantLoc.loopSideNum ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful to change this into an assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure,. I think this is the type of thing that should only be done once in the simulation, just not sure where to do that. Maybe move this code up into the if (UniqueCriteriaCheckIndex <= 0) block? I would think those 4 Nums would always be non-zero but this code would be better served there than here (and with the assert).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other thing that could be improved is that BranchNum and CompNum are not used. Those could be removed.

CurCriteria.CallingCompBranchNum != plantLoc.branchNum || CurCriteria.CallingCompCompNum != plantLoc.compNum) {
// Diagnostic fatal: component does not properly utilize unique indexing
}
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
Loading