Skip to content

Propagate Plant Location Shortcuts (phase 3)#11454

Open
amirroth wants to merge 8 commits intodevelopfrom
PlantShortcut3
Open

Propagate Plant Location Shortcuts (phase 3)#11454
amirroth wants to merge 8 commits intodevelopfrom
PlantShortcut3

Conversation

@amirroth
Copy link
Collaborator

@amirroth amirroth commented Mar 9, 2026

Propagates the PlantLocation shortcut idiom introduced earlier to (most of) the rest of the code.

Copy link
Collaborator Author

@amirroth amirroth left a comment

Choose a reason for hiding this comment

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

Simple walk-through, not much to see here.

foundLoc.loopSideNum = DataPlant::LoopSideLocation::Demand;
foundLoc.branchNum = BranchNum;
foundLoc.compNum = CompNum;
foundLoc.loop = &state.dataPlnt->PlantLoop(foundLoc.loopNum);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Set shortcuts.

.Branch(this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.branchNum)
.Comp(this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.compNum)
.CurOpSchemeType = this->Type;
this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.comp->OpScheme.allocate(1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use shortcuts. Using shortcuts to locate components saves a lot of code. And a little bit of time.

Real64 const CpCW =
state.dataPlnt->PlantLoop(this->DedicatedHR_HeatingPLHP.sourceSidePlantLoc.loopNum)
.glycol->getSpecificHeat(state, state.dataLoopNodes->Node(inletChWReturnNodeNum).Temp, "EvaluateChillerHeaterChangeoverOpScheme");
this->DedicatedHR_HeatingPLHP.sourceSidePlantLoc.loop->
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the most common usage of shortcuts.

for (int CompCounter = StartingComponent; CompCounter <= EndingComponent; ++CompCounter) {
PlantLocation this_plantLoc = {this->plantLoc.loopNum, this->plantLoc.loopSideNum, BranchCounter, CompCounter};

this_plantLoc.loop = &state.dataPlnt->PlantLoop(this_plantLoc.loopNum);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Set shortcuts here.

int EquipBranchNum = this_op_scheme.EquipList(ListNum).Comp(CompIndex).BranchNumPtr;
int EquipCompNum = this_op_scheme.EquipList(ListNum).Comp(CompIndex).CompNumPtr;
loop_side.Branch(EquipBranchNum).Comp(EquipCompNum).MyLoad = 0.0;
plantLoc.side->Branch(EquipBranchNum).Comp(EquipCompNum).MyLoad = 0.0;
Copy link
Collaborator Author

@amirroth amirroth Mar 9, 2026

Choose a reason for hiding this comment

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

Don't need special shortcuts anymore. They're already all in plantLoc.

@amirroth amirroth added Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring NotIDDChange Code does not impact IDD (can be merged after IO freeze) labels Mar 9, 2026
@amirroth amirroth added this to the EnergyPlus 26.1 milestone Mar 9, 2026
useOutlet.Temp = useOutletTemp;
} else if (mPlantReq > 0.0) {
plantOutlet.Temp = std::min(plantOutletTemp, state.dataPlnt->PlantLoop[this->sourcePlantLoc.loopNum].MaxTemp);
plantOutlet.Temp = std::min(plantOutletTemp, state.dataPlnt->PlantLoop[this->sourcePlantLoc.loopNum].MaxTemp); // Why is this in brackets?
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does look like a bug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll change this to parentheses.

Real64 HighestRange;

// Object Data
// Object Dataō
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting character.


for (int i = 1; i <= this->numTowers; i++) {
auto &towerComp = towerLoopSide.Branch(this->towerPlocs(i).branchNum).Comp(this->towerPlocs(i).compNum);
auto &towerComp = towerPlocs(1).side->Branch(this->towerPlocs(i).branchNum).Comp(this->towerPlocs(i).compNum);
Copy link
Collaborator

@rraustad rraustad Mar 9, 2026

Choose a reason for hiding this comment

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

towerPlocs(1) -> towerPlocs(i) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Either one, they are all on the same loop/side.

Copy link
Collaborator Author

@amirroth amirroth left a comment

Choose a reason for hiding this comment

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

Not much to see here.

Copy link
Collaborator

@mitchute mitchute left a comment

Choose a reason for hiding this comment

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

LGTM

case DataPlant::OpScheme::FreeRejection: //~ other control types
EncounteredNonLBObjDuringPass2 = true;
goto components2_end; // don't do anymore components on this branch
goto components2_end; // don't do anymore components on this branch // This is not good
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose we should start excising the remaining 123 uses of goto 🙃

Comment on lines +1251 to +1259
this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.comp->Available = false;
this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.comp->ON = false;
this->DedicatedHR_CoolingPLHP.sourceSidePlantLoc.comp->Available = false;
this->DedicatedHR_CoolingPLHP.sourceSidePlantLoc.comp->ON = false;

this->DedicatedHR_HeatingPLHP.loadSidePlantLoc.comp->Available = false;
this->DedicatedHR_HeatingPLHP.loadSidePlantLoc.comp->ON = false;
this->DedicatedHR_HeatingPLHP.sourceSidePlantLoc.comp->Available = false;
this->DedicatedHR_HeatingPLHP.sourceSidePlantLoc.comp->ON = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NotIDDChange Code does not impact IDD (can be merged after IO freeze) Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants