Skip to content

Conversation

@rraustad
Copy link
Contributor

@rraustad rraustad commented Apr 11, 2025

Pull request overview

Description of the purpose of this PR

Incorrect curve name leads to a crash when curves are evaluated in function CheckSimpleWAHPRatedCurvesOutputs.

Pull Request Author

  • 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

  • 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

@rraustad rraustad added the Defect Includes code to repair a defect in EnergyPlus label Apr 11, 2025
@rraustad rraustad changed the title Protect WSHP from null curve pointers Protect WSHP from incorrect or missing curve names Apr 11, 2025
@rraustad
Copy link
Contributor Author

rraustad commented Apr 11, 2025

Defect file previously crashed and showed a blank err file. This file now exits gracefully and err file shows cause of crash:

** Severe  ** GetSimpleWatertoAirHPInput: Coil:Cooling:WaterToAirHeatPump:EquationFit = SYS 1 HEAT PUMP COOLING MODE
**   ~~~   ** Total Cooling Capacity Curve Name = TOTCOOLCAPCURV, item not found.
** Severe  ** GetSimpleWatertoAirHPInput: Coil:Cooling:WaterToAirHeatPump:EquationFit = SYS 1 HEAT PUMP COOLING MODE
**   ~~~   ** Sensible Cooling Capacity Curve Name = COOLSENSCAPCURV, item not found.
** Severe  ** GetSimpleWatertoAirHPInput: Coil:Cooling:WaterToAirHeatPump:EquationFit = SYS 1 HEAT PUMP COOLING MODE
**   ~~~   ** Cooling Power Consumption Curve Name = COOLPOWCURV, item not found.
**  Fatal  ** GetSimpleWatertoAirHPInput:  Errors found getting input. Program terminates.

EXPECT_NE(state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).RatedEntAirWetbulbTemp, DataSizing::AutoSize);
state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).HeatCapCurve = nullptr;
state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).HeatPowCurve = nullptr;
WaterToAirHeatPumpSimple::CheckSimpleWAHPRatedCurvesOutputs(*state, state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).Name);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check that function does not crash with null curve pointers.

Copy link
Member

Choose a reason for hiding this comment

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

Excellent.


} else if (wahp.WAHPType == WatertoAirHP::Heating) {
if (wahp.RatedEntAirDrybulbTemp != DataSizing::AutoSize) {
if (wahp.RatedEntAirDrybulbTemp != DataSizing::AutoSize && wahp.HeatCapCurve != nullptr && wahp.HeatPowCurve != nullptr) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue correction is here on these 3 lines above in function CheckSimpleWAHPRatedCurvesOutputs

Copy link
Member

Choose a reason for hiding this comment

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

Got it. The function will be fine skipping this part, because it doesn't need to check the curves that don't exist.

@rraustad rraustad added this to the EnergyPlus 25.2 milestone Apr 11, 2025
Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

This looks great to me, I'm happy to get this tested and merged.

// Jin, H. 2002. Parameter Estimation Based Models of Water Source Heat Pumps. Phd Thesis.
// Oklahoma State University.

using namespace DataLoopNode;
Copy link
Member

Choose a reason for hiding this comment

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

Getting rid of using...yes.

using BranchNodeConnections::TestCompSet;
using GlobalNames::VerifyUniqueCoilName;
using PlantUtilities::RegisterPlantCompDesignFlow;
using namespace OutputReportPredefined;
Copy link
Member

Choose a reason for hiding this comment

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

Getting rid of using...yes.

int PlantOutletNode;
Real64 rho; // local fluid density
Real64 Cp; // local fluid specific heat
bool errFlag;
Copy link
Member

Choose a reason for hiding this comment

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

Localized variables...yes.

RatedAirVolFlowRateDes);
} else {
if (simpleWatertoAirHP.RatedAirVolFlowRate > 0.0 && RatedAirVolFlowRateDes > 0.0 && !HardSizeNoDesRun) {
if (simpleWatertoAirHP.RatedAirVolFlowRate > 0.0 && RatedAirVolFlowRateDes > 0.0) {
Copy link
Member

Choose a reason for hiding this comment

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

I see, this is already inside the !HardSizeNoDesRun if condition, so no need to extra check it.


} else if (wahp.WAHPType == WatertoAirHP::Heating) {
if (wahp.RatedEntAirDrybulbTemp != DataSizing::AutoSize) {
if (wahp.RatedEntAirDrybulbTemp != DataSizing::AutoSize && wahp.HeatCapCurve != nullptr && wahp.HeatPowCurve != nullptr) {
Copy link
Member

Choose a reason for hiding this comment

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

Got it. The function will be fine skipping this part, because it doesn't need to check the curves that don't exist.

EXPECT_NE(state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).RatedEntAirWetbulbTemp, DataSizing::AutoSize);
state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).HeatCapCurve = nullptr;
state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).HeatPowCurve = nullptr;
WaterToAirHeatPumpSimple::CheckSimpleWAHPRatedCurvesOutputs(*state, state->dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).Name);
Copy link
Member

Choose a reason for hiding this comment

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

Excellent.

@Myoldmopar
Copy link
Member

This is good, thanks @rraustad, merging.

@Myoldmopar Myoldmopar merged commit 1d1af7d into develop Apr 15, 2025
9 checks passed
@Myoldmopar Myoldmopar deleted the 11025-Curve-Crash branch April 15, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hard crash in WAHP CurveValue lookup

5 participants