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

Heat Pump Plant Loop EIR refactoring #10404

Merged
merged 31 commits into from
Mar 15, 2024

Conversation

Nigusse
Copy link
Contributor

@Nigusse Nigusse commented Feb 20, 2024

Pull request overview

NOTE: ENHANCEMENTS MUST FOLLOW A SUBMISSION PROCESS INCLUDING A FEATURE PROPOSAL AND DESIGN DOCUMENT PRIOR TO SUBMITTING CODE

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@Nigusse Nigusse added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Feb 20, 2024
@Nigusse
Copy link
Contributor Author

Nigusse commented Feb 20, 2024

This is a refactoring effort; hence, diffs are not expected. However, a diff was found in one example file (PlantLoopHeatPump_Fuel-Fired.idf) because the refactoring process addressed a defect described here.

@Myoldmopar Myoldmopar self-assigned this Feb 20, 2024
@Nigusse
Copy link
Contributor Author

Nigusse commented Feb 20, 2024

An existing unit test failed due to the new report() function. This function should have been declared as virtual. I will push the branch with a fix along with the clang formatting change shortly.

Copy link
Contributor Author

@Nigusse Nigusse left a comment

Choose a reason for hiding this comment

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

Code refactoring walkthrough for EIRPlantLoopHeatPump

}
state.dataLoopNodes->Node(this->sourceSideNodes.outlet).Temp = this->sourceSideOutletTemp;
// update report variables and nodes
this->report(state);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the node update to newly created function report().

@@ -198,6 +194,7 @@ void EIRPlantLoopHeatPump::resetReportingVariables()
this->fractionalDefrostTime = 0.0;
this->partLoadRatio = 0.0;
this->cyclingRatio = 0.0;
this->defrostPowerMultiplier = 1.0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since defrost calculation is refactored to a new function I added a new member variable defrostPowerMultiplier for use else where.

Real64 constexpr RH60 = 60.0;
Real64 constexpr rangeRH = 30.0;
Real64 const reportingInterval = state.dataHVACGlobal->TimeStepSysSec;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to a new function heatingCapacityModifierASHP.

this->doPhysicsWSHP(state, currentLoad);
} else if (this->airSource) {
this->doPhysicsASHP(state, currentLoad);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we have two separate functions doPhysicsWSHP() and doPhysicsASHP() that are wrapped in existing doPhysics(). The doPhysics() is a virtual function used for EIRFuelFiredHeatPump module as well.


// evaluate the source side heat transfer rate
this->calcSourceSideHeatTransferWSHP(state);
}
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 WSHP do physics new function doPhysicsWSHP(), which is a wrapper for all water source calculations. No defrost calculation call here.

// energy balance on heat pump
// this->sourceSideHeatTransfer = this->calcQsource(this->loadSideHeatTransfer, this->powerUsage);
this->sourceSideHeatTransfer = this->calcQsource(this->loadSideHeatTransfer, this->fuelRate + this->powerUsage - this->standbyElecPower);
this->sourceSideEnergy = this->sourceSideHeatTransfer * reportingInterval;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Report variables update has moved to the new member report() function.

state.dataLoopNodes->Node(this->loadSideNodes.outlet).Temp = this->loadSideOutletTemp;
state.dataLoopNodes->Node(this->sourceSideNodes.outlet).Temp = this->sourceSideOutletTemp;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add similar new member report() function for EIRFuelFiredHeatPump module as well.

void calcSourceSideHeatTransferASHP(EnergyPlusData &state);

virtual void report(EnergyPlusData &state);

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 various refactored member functions.

void capModFTCurveCheck(EnergyPlusData &state, const Real64 loadSideOutletSPTemp, Real64 &capModFTemp);

void eirModCurveCheck(EnergyPlusData &state, Real64 &eirModFTemp, Real64 &eirModFPLR);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

@@ -3499,6 +3499,7 @@ TEST_F(EnergyPlusFixture, Test_Curve_Negative_Energy)
thisCoolingPLHP->loadSideInletTemp = 20;
thisCoolingPLHP->sourceSideInletTemp = 20;
thisCoolingPLHP->doPhysics(*state, curLoad);
thisCoolingPLHP->report(*state);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

called the new report() function here to update the report variables for testing.

@Nigusse
Copy link
Contributor Author

Nigusse commented Feb 21, 2024

This branch is ready for review, and it includes the fix for issue #10403. Because of this fix, diff is expected in PlantLoopHeatPump_Fuel-Fired.idf example file.

@mjwitte mjwitte added this to the EnergyPlus 24.1 milestone Feb 29, 2024
@Myoldmopar
Copy link
Member

@Nigusse this is now conflicted, looks like maybe you made a similar-but-not-quite-the-same change in your heat pump fix branch? I'm going to hold off on this for now, but feel free to merge up develop and resolve that small conflict.

@Nigusse
Copy link
Contributor Author

Nigusse commented Mar 15, 2024

I am going to work on it now.

@Nigusse
Copy link
Contributor Author

Nigusse commented Mar 15, 2024

@Myoldmopar Merged in develop and resolved conflict. Run regression tests on five example files (with EIR Heat Pump) and found no diffs. Diffs were not expected for this branch.

@Myoldmopar
Copy link
Member

Thanks @Nigusse, I'll let CI run, but this will merge if CI is green.

@Myoldmopar
Copy link
Member

All green, thanks @Nigusse, merging.

@Myoldmopar Myoldmopar merged commit 7d0ec8a into develop Mar 15, 2024
15 checks passed
@Myoldmopar Myoldmopar deleted the air_to_water_hp_heat_recovery_refactor branch March 15, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

EIRFuelFiredHeatPump object electric energy consumption output variable reports zero value
8 participants