Skip to content

Commit

Permalink
update idf in unit tests, add curveindex check in main code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yujie Xu authored and Yujie Xu committed Nov 7, 2023
1 parent c2c4123 commit 1dbfec3
Show file tree
Hide file tree
Showing 6 changed files with 636 additions and 86 deletions.
70 changes: 56 additions & 14 deletions src/EnergyPlus/HeatRecovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2072,12 +2072,24 @@ namespace HeatRecovery {

if (this->SupInTemp < this->SecInTemp) {
// Use heating effectiveness values
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
this->SensEffectiveness = this->HeatEffectSensible100;
if (this->HeatEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->HeatEffectLatent100;
if (this->HeatEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio);
}
} else {
// Use cooling effectiveness values
this->SensEffectiveness = Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->CoolEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio) * this->CoolEffectLatent100 ;
this->SensEffectiveness = this->CoolEffectSensible100;
if (this->CoolEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->CoolEffectLatent100;
if (this->CoolEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio);
}
}

// Keep effectiveness between 0 and 1.0 ??
Expand Down Expand Up @@ -2186,12 +2198,24 @@ namespace HeatRecovery {
CMin = min(CSup, CSec);
if (TempSupIn < TempSecIn) {
// Use heating effectiveness values
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
this->SensEffectiveness = this->HeatEffectSensible100;
if (this->HeatEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->HeatEffectLatent100;
if (this->HeatEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio);
}
} else {
// Use cooling effectiveness values
this->SensEffectiveness = Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->CoolEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio) * this->CoolEffectLatent100 ;
this->SensEffectiveness = this->CoolEffectSensible100;
if (this->CoolEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->CoolEffectLatent100;
if (this->CoolEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio);
}
}

if (this->SensEffectiveness < 0.0) {
Expand Down Expand Up @@ -2758,8 +2782,14 @@ namespace HeatRecovery {
HXSecAirVolFlowRate = this->SecOutMassFlow / RhoSec;
HXAvgAirVolFlowRate = (HXSecAirVolFlowRate + HXSupAirVolFlowRate) / 2.0;
HXAirVolFlowRatio = HXAvgAirVolFlowRate / this->NomSupAirVolFlow;
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
this->SensEffectiveness = this->HeatEffectSensible100;
if (this->HeatEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->HeatEffectLatent100;
if (this->HeatEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio);
}
this->SupOutTemp = this->SupInTemp + this->SensEffectiveness * CMin / CSup * (this->SecInTemp - this->SupInTemp);
this->SupOutHumRat = this->SupInHumRat + this->LatEffectiveness * CMin / CSup * (this->SecInHumRat - this->SupInHumRat);
this->SupOutEnth = Psychrometrics::PsyHFnTdbW(this->SupOutTemp, this->SupOutHumRat);
Expand Down Expand Up @@ -2812,12 +2842,24 @@ namespace HeatRecovery {
CMin = min(CSup, CSec);
if (TempSupIn < TempSecIn) {
// Use heating effectiveness values
this->SensEffectiveness = Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->HeatEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio) * this->HeatEffectLatent100 ;
this->SensEffectiveness = this->HeatEffectSensible100;
if (this->HeatEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->HeatEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->HeatEffectLatent100;
if (this->HeatEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->HeatEffectLatentCurveIndex, HXAirVolFlowRatio);
}
} else {
// Use cooling effectiveness values
this->SensEffectiveness = Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio) * this->CoolEffectSensible100;
this->LatEffectiveness = Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio) * this->CoolEffectLatent100 ;
this->SensEffectiveness = this->CoolEffectSensible100;
if (this->CoolEffectSensibleCurveIndex > 0) {
this->SensEffectiveness *= Curve::CurveValue(state, this->CoolEffectSensibleCurveIndex, HXAirVolFlowRatio);
}
this->LatEffectiveness = this->CoolEffectLatent100;
if (this->CoolEffectLatentCurveIndex > 0) {
this->LatEffectiveness *= Curve::CurveValue(state, this->CoolEffectLatentCurveIndex, HXAirVolFlowRatio);
}
}
// calculation of local variable Csup can be 0, gaurd against divide by 0.
TempSupOut = TempSupIn + this->SensEffectiveness * SafeDiv(CMin, CSup) * (TempSecIn - TempSupIn);
Expand Down
112 changes: 102 additions & 10 deletions tst/EnergyPlus/unit/AirLoopHVACDOAS.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3960,12 +3960,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest)
" 1.5, !- Nominal Supply Air Flow Rate {m3/s}",
" 0.7, !- Sensible Effectiveness at 100% Heating Air Flow {dimensionless}",
" 0.65, !- Latent Effectiveness at 100% Heating Air Flow {dimensionless}",
" 0.750000, !- Sensible Effectiveness at 75% Heating Air Flow {dimensionless}",
" 0.700000, !- Latent Effectiveness at 75% Heating Air Flow {dimensionless}",
" 0.7, !- Sensible Effectiveness at 100% Cooling Air Flow {dimensionless}",
" 0.65, !- Latent Effectiveness at 100% Cooling Air Flow {dimensionless}",
" 0.750000, !- Sensible Effectiveness at 75% Cooling Air Flow {dimensionless}",
" 0.700000, !- Latent Effectiveness at 75% Cooling Air Flow {dimensionless}",
" Outside Air Inlet Node 1, !- Supply Air Inlet Node Name",
" DOAS Heat Recovery Supply Outlet, !- Supply Air Outlet Node Name",
" AirLoopDOASMixerOutlet, !- Exhaust Air Inlet Node Name",
Expand All @@ -3977,7 +3973,57 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOASTest)
" 1.7, !- Threshold Temperature {C}",
" 0.083, !- Initial Defrost Time Fraction {dimensionless}",
" 0.012, !- Rate of Defrost Time Fraction Increase {1/K}",
" Yes; !- Economizer Lockout",
" Yes, !- Economizer Lockout",
" SenEffectivenessTable, !- Sensible Effectiveness of Heating Air Flow Curve Name",
" LatEffectivenessTable, !- Latent Effectiveness of Heating Air Flow Curve Name",
" SenEffectivenessTable, !- Sensible Effectiveness of Cooling Air Flow Curve Name",
" LatEffectivenessTable; !- Latent Effectiveness of Cooling Air Flow Curve Name",

" Table:IndependentVariable,",
" airFlowRatio, !- Name",
" Linear, !- Interpolation Method",
" Linear, !- Extrapolation Method",
" 0.0, !- Minimum Value",
" 1.0, !- Maximum Value",
" , !- Normalization Reference Value",
" Dimensionless, !- Unit Type",
" , !- External File Name",
" , !- External File Column Number",
" , !- External File Starting Row Number",
" 0.75, !- Value 1",
" 1.0; !- Value 2",

" Table:IndependentVariableList,",
" effectiveness_IndependentVariableList, !- Name",
" airFlowRatio; !- Independent Variable 1 Name",

" Table:Lookup,",
" SenEffectivenessTable, !- Name",
" effectiveness_IndependentVariableList, !- Independent Variable List Name",
" DivisorOnly, !- Normalization Method",
" 0.7, !- Normalization Divisor",
" 0.0, !- Minimum Output",
" 1.0, !- Maximum Output",
" Dimensionless, !- Output Unit Type",
" , !- External File Name",
" , !- External File Column Number",
" , !- External File Starting Row Number",
" 0.75, !- Output Value 1",
" 0.70; !- Output Value 2",

" Table:Lookup,",
" LatEffectivenessTable, !- Name",
" effectiveness_IndependentVariableList, !- Independent Variable List Name",
" DivisorOnly, !- Normalization Method",
" 0.65, !- Normalization Divisor",
" 0.0, !- Minimum Output",
" 1.0, !- Maximum Output",
" Dimensionless, !- Output Unit Type",
" , !- External File Name",
" , !- External File Column Number",
" , !- External File Starting Row Number",
" 0.70, !- Output Value 1",
" 0.65; !- Output Value 2",

" OutdoorAir:NodeList,",
" OutsideAirInletNodes; !- Node or NodeList Name 1",
Expand Down Expand Up @@ -8313,12 +8359,8 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_ReportVariableResetTest)
" 1.5, !- Nominal Supply Air Flow Rate {m3/s}",
" 0.7, !- Sensible Effectiveness at 100% Heating Air Flow {dimensionless}",
" 0.65, !- Latent Effectiveness at 100% Heating Air Flow {dimensionless}",
" 0.750000, !- Sensible Effectiveness at 75% Heating Air Flow {dimensionless}",
" 0.700000, !- Latent Effectiveness at 75% Heating Air Flow {dimensionless}",
" 0.7, !- Sensible Effectiveness at 100% Cooling Air Flow {dimensionless}",
" 0.65, !- Latent Effectiveness at 100% Cooling Air Flow {dimensionless}",
" 0.750000, !- Sensible Effectiveness at 75% Cooling Air Flow {dimensionless}",
" 0.700000, !- Latent Effectiveness at 75% Cooling Air Flow {dimensionless}",
" Outside Air Inlet Node 1, !- Supply Air Inlet Node Name",
" DOAS Heat Recovery Supply Outlet, !- Supply Air Outlet Node Name",
" AirLoopDOASMixerOutlet, !- Exhaust Air Inlet Node Name",
Expand All @@ -8330,7 +8372,57 @@ TEST_F(EnergyPlusFixture, AirLoopHVACDOAS_ReportVariableResetTest)
" 1.7, !- Threshold Temperature {C}",
" 0.083, !- Initial Defrost Time Fraction {dimensionless}",
" 0.012, !- Rate of Defrost Time Fraction Increase {1/K}",
" Yes; !- Economizer Lockout",
" Yes, !- Economizer Lockout",
" SenEffectivenessTable, !- Sensible Effectiveness of Heating Air Flow Curve Name",
" LatEffectivenessTable, !- Latent Effectiveness of Heating Air Flow Curve Name",
" SenEffectivenessTable, !- Sensible Effectiveness of Cooling Air Flow Curve Name",
" LatEffectivenessTable; !- Latent Effectiveness of Cooling Air Flow Curve Name",

" Table:IndependentVariable,",
" airFlowRatio, !- Name",
" Linear, !- Interpolation Method",
" Linear, !- Extrapolation Method",
" 0.0, !- Minimum Value",
" 1.0, !- Maximum Value",
" , !- Normalization Reference Value",
" Dimensionless, !- Unit Type",
" , !- External File Name",
" , !- External File Column Number",
" , !- External File Starting Row Number",
" 0.75, !- Value 1",
" 1.0; !- Value 2",

" Table:IndependentVariableList,",
" effectiveness_IndependentVariableList, !- Name",
" airFlowRatio; !- Independent Variable 1 Name",

" Table:Lookup,",
" SenEffectivenessTable, !- Name",
" effectiveness_IndependentVariableList, !- Independent Variable List Name",
" DivisorOnly, !- Normalization Method",
" 0.7, !- Normalization Divisor",
" 0.0, !- Minimum Output",
" 1.0, !- Maximum Output",
" Dimensionless, !- Output Unit Type",
" , !- External File Name",
" , !- External File Column Number",
" , !- External File Starting Row Number",
" 0.75, !- Output Value 1",
" 0.70; !- Output Value 2",

" Table:Lookup,",
" LatEffectivenessTable, !- Name",
" effectiveness_IndependentVariableList, !- Independent Variable List Name",
" DivisorOnly, !- Normalization Method",
" 0.65, !- Normalization Divisor",
" 0.0, !- Minimum Output",
" 1.0, !- Maximum Output",
" Dimensionless, !- Output Unit Type",
" , !- External File Name",
" , !- External File Column Number",
" , !- External File Starting Row Number",
" 0.70, !- Output Value 1",
" 0.65; !- Output Value 2",

" OutdoorAir:NodeList,",
" OutsideAirInletNodes; !- Node or NodeList Name 1",
Expand Down
Loading

3 comments on commit 1dbfec3

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

labHeatExchangerNFP (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3537 of 3576 tests passed, 3 test warnings)

Messages:\n

  • 4 tests had: AUD diffs.
  • 1 test had: EIO diffs.
  • 1 test had: ERR diffs.
  • 1 test had: ESO big diffs.
  • 2 tests had: Table big diffs.
  • 3 tests had: MDD diffs.
  • 3 tests had: MTD diffs.

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1471
  • Failed: 6
  • SEGFAULT: 1

integration Test Summary

  • Passed: 761
  • Failed: 30

regression Test Summary

  • Passed: 803
  • Failed: 2

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

labHeatExchangerNFP (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1956 of 1963 tests passed, 0 test warnings)

Failures:\n

EnergyPlusFixture Test Summary

  • Passed: 1471
  • Failed: 7

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

labHeatExchangerNFP (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (759 of 789 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 759
  • Failed: 30

Build Badge Test Badge Coverage Badge

Please sign in to comment.