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

Avoid wshp array bounds error #10735

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft

Avoid wshp array bounds error #10735

wants to merge 6 commits into from

Conversation

mjwitte
Copy link
Contributor

@mjwitte mjwitte commented Sep 13, 2024

Pull request overview

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

@mjwitte mjwitte added the Defect Includes code to repair a defect in EnergyPlus label Sep 13, 2024
@@ -2580,86 +2580,92 @@ namespace WaterToAirHeatPumpSimple {

// determine adjusted cooling and heating coil capacity
simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe what the code below is trying to do is to size a HP, so the coils would need to be the same size. In this case that's not necessary but an actual HP would need to be tested to make sure it works. I guess it does work since all WSHPs apparently size correctly, or do they?

state.dataSize->DataConstantUsedForSizing = WaterToAirHeatPumpSimple::GetCoilCapacity(
state, HVAC::cAllCoilTypes(this->m_CoolingCoilType_Num), this->m_CoolingCoilName, ErrFound);
EqSizing.DesCoolingLoad = state.dataSize->DataConstantUsedForSizing;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I just wrapped all this in 1 IF block. Still not sure if the code at the end of this block is needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

The next step is to remove this IF block. There is no reason to call the cooling coil to report the UnitarySystem heating capacity. That's a cover up.

@rraustad
Copy link
Contributor

Regarding if this fix is correct, there is the same check for the cooling coil where the companionCoil index is checked before looking for the companion heating coil. So this does look like the fix moved in the right direction. It's just that there are some oddities that could also be looked at here or in a separate issue. See issue discussion.

@rraustad
Copy link
Contributor

rraustad commented Sep 19, 2024

Also some interesting table reports.

image

9849-Solution2-Separate UnitarySystems-in-v24.2-CompanionCoilCrash.txt

@@ -2734,7 +2740,7 @@ namespace WaterToAirHeatPumpSimple {

// user provided inputs are assumed to be at rated conditions
simpleWatertoAirHP.RatedPowerHeat = simpleWatertoAirHP.RatedCapHeat / simpleWatertoAirHP.RatedCOPHeatAtRatedCdts;
simpleWatertoAirHP.RatedCapHeatAtRatedCdts = 0;
simpleWatertoAirHP.RatedCapHeatAtRatedCdts = simpleWatertoAirHP.RatedCapHeat;
Copy link
Contributor

@rraustad rraustad Sep 19, 2024

Choose a reason for hiding this comment

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

Why would the rated capacity sizing variable be set to 0 if not autosized? And what about rated power below? and check the cooling coil code.

Real64 RatedCapHeatAtRatedCdts = 0.0;        // Rated Heating Capacity at Rated Conditions [W]

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I could have changed the water flow rate sizing to use RatedCapHeat instead.

if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    RatedWaterVolFlowRateDes =
        simpleWatertoAirHP.RatedCapHeatAtRatedCdts / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho);

Copy link
Contributor

@rraustad rraustad Sep 19, 2024

Choose a reason for hiding this comment

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

There is likely a difference between RatedCapHeat and RatedCapHeatAtRatedCdts given the CapFT term applied. This is above at line 2743.

            simpleWatertoAirHP.RatedCapHeat = RatedCapHeatDes;
            simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac;

Copy link
Contributor

@rraustad rraustad Sep 19, 2024

Choose a reason for hiding this comment

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

I think these equations need to be moved up into the IF blocks in order to use the correct variable. If RatedCapHeat is the coil load and RatedCapHeatatRatedCdts is the coil size, when autosized, then declaring these variables AFTER the coil size is determined seems wrong (i.e., after the if/else). If autosized, RatedCapHeatatRatedCdts should be used as the capacity, if not autosized, RatedCapHeat should be used as the capacity.

Copy link
Contributor

@rraustad rraustad Sep 20, 2024

Choose a reason for hiding this comment

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

I actually want to revert this change and change the RatedWaterVolFlowRateDes sizing equation to use RatedCapHeat because that's what the sizing routine is setting as the final coil capacity. And the calc routine uses RatedCapHeat as the coil capacity. So RatedCapHeat should be the final coil size whether the coil is autosized or hard-sized.

HeatCapAtPeak = rhoair * VolFlowRate * Psychrometrics::PsyCpAirFnW(DataPrecisionGlobals::constant_zero) *
                (HeatSupTemp - HeatMixTemp); // heating coil load

RatedCapHeatDes = (PeakHeatCapTempModFac > 0.0) ? HeatCapAtPeak / PeakHeatCapTempModFac : HeatCapAtPeak;

// heating capacity final determination
simpleWatertoAirHP.RatedCapHeat = RatedCapHeatDes;
simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac;

void CalcHPHeatingSimple(EnergyPlusData &state,
    HeatCapRated = simpleWatertoAirHP.RatedCapHeat;

So it follows that the water flow rate should use RatedHeatCap because that's the coil size. You can't see an issue in model performance when the water flow rate is sized with either of these variables because only exit water temp changes, not performance. You would have to really critique the exiting water temp to see an issue and even then it would be hard to see.

if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    RatedWaterVolFlowRateDes = 
        simpleWatertoAirHP.RatedCapHeatAtRatedCdts / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho);

And then I look at this line and it looks like RatedCapHeatAtRatedCdts is the correct variable to use to size the water flow rate. So I will leave this branch in this state for now even though I think it's wrong.

RatedHeatCapTempModFac =
    Curve::CurveValue(state, simpleWatertoAirHP.HeatCapCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);

Copy link
Contributor

Choose a reason for hiding this comment

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

RatedCapHeatDes is the CapFT modified coil capacity, as is RatedCapHeat. The next line modifies this value by the rated CapFT, which should be 1 by definition (but I expect it's not 1). So now I'm back to using RatedCapHeat to size the water flow rate. This is so very confusing but I think I am more comfortable with this now. @mjwitte ?

simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac;

@rraustad
Copy link
Contributor

@mjwitte I think it's time to review changes in unmet hours. This is for 9849-OffSml-MultiHVACSys DOAS_EP9_4 to24.2.

image

} else {
SystemCapacity = companionHeatingCoil.RatedCapHeat;
}
} else {
SystemCapacity = simpleWatertoAirHP.RatedCapCoolAtRatedCdts;
SystemCapacity = simpleWatertoAirHP.RatedCapCoolAtRatedCdts; // RatedCapCoolTotal ? * (1 + 1/COP) ?
Copy link
Contributor

Choose a reason for hiding this comment

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

These should also include the sizing ratio when basing condenser water flow sizing on cooling capacity.

AirLoopHVAC:UnitarySystem,
  N1 , \field DX Heating Coil Sizing Ratio

Copy link

⚠️ Regressions detected on macos-14 for commit f047836

Regression Summary
  • EIO: 14
  • MTR Small Diffs: 6
  • Table Big Diffs: 5
  • ESO Small Diffs: 14
  • Table Small Diffs: 9
  • Table String Diffs: 2

@nrel-bot
Copy link

@mjwitte @Myoldmopar it has been 28 days since this pull request was last updated.

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.

WaterToAirHeatPump:EquationFit sizing companion coil array bounds error
6 participants