Propagate Plant Location Shortcuts (phase 3)#11454
Conversation
amirroth
left a comment
There was a problem hiding this comment.
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); |
| .Branch(this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.branchNum) | ||
| .Comp(this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.compNum) | ||
| .CurOpSchemeType = this->Type; | ||
| this->DedicatedHR_CoolingPLHP.loadSidePlantLoc.comp->OpScheme.allocate(1); |
There was a problem hiding this comment.
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-> |
There was a problem hiding this comment.
This is the most common usage of shortcuts.
src/EnergyPlus/Plant/LoopSide.cc
Outdated
| 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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Don't need special shortcuts anymore. They're already all in plantLoc.
src/EnergyPlus/PCMThermalStorage.cc
Outdated
| 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? |
There was a problem hiding this comment.
This does look like a bug.
There was a problem hiding this comment.
I'll change this to parentheses.
| Real64 HighestRange; | ||
|
|
||
| // Object Data | ||
| // Object Dataō |
src/EnergyPlus/SetPointManager.cc
Outdated
|
|
||
| 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); |
There was a problem hiding this comment.
towerPlocs(1) -> towerPlocs(i) ?
There was a problem hiding this comment.
Either one, they are all on the same loop/side.
amirroth
left a comment
There was a problem hiding this comment.
Not much to see here.
| 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 |
There was a problem hiding this comment.
I suppose we should start excising the remaining 123 uses of goto 🙃
| 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; |
Propagates the
PlantLocationshortcut idiom introduced earlier to (most of) the rest of the code.