Skip to content

Commit

Permalink
Fix for Defect #10508
Browse files Browse the repository at this point in the history
Fixes the defect with a solution suggested in GitHub which includes the following:
1. Calculates average multiplier regardless of system operation (now simply calculates it every time)
2. Uses the limit of 30 as a warning threshold but does not eliminate the value (previously set to 1 so that it wouldn't affect the average)
These items have been accomplished through the creation of a new subroutine that controls the calculation limits and calculates the sum, count, and average.
  • Loading branch information
RKStrand committed Jun 21, 2024
1 parent 3c8844f commit 9ef7d61
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 20 deletions.
60 changes: 40 additions & 20 deletions src/EnergyPlus/ZoneTempPredictorCorrector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5149,7 +5149,6 @@ void InverseModelTemperature(EnergyPlusData &state,

// HM calculation only HM calculation period start
if (state.dataEnvrn->DayOfYear >= hybridModelZone.HybridStartDayOfYear && state.dataEnvrn->DayOfYear <= hybridModelZone.HybridEndDayOfYear) {
Real64 HMMultiplierAverage(1.0);
Real64 MultpHM(1.0);

thisZoneHB.ZT = zone.ZoneMeasuredTemperature; // Array1D<Real64> ZT -- Zone
Expand Down Expand Up @@ -5248,31 +5247,15 @@ void InverseModelTemperature(EnergyPlusData &state,
thisZoneHB.airHumRat) *
Psychrometrics::PsyCpAirFnW(thisZoneHB.airHumRat)) *
(state.dataGlobal->TimeStepZone * Constant::SecInHour); // Inverse equation
if ((MultpHM < 1.0) || (MultpHM > 30.0)) { // Temperature capacity multiplier greater than
// 1 and less than 30
MultpHM = 1.0; // Default value 1.0
}
} else {
MultpHM = 1.0; // Default value 1.0
}

zone.ZoneVolCapMultpSensHM = MultpHM; // For timestep output
processInverseModelMultpHM(
state, MultpHM, zone.ZoneVolCapMultpSensHMSum, zone.ZoneVolCapMultpSensHMCountSum, zone.ZoneVolCapMultpSensHMAverage, ZoneNum);

// Calculate the average multiplier of the zone for the whole running period
{
// count for hybrid model calculations
if (MultpHM > 1.0) {
zone.ZoneVolCapMultpSensHMSum += MultpHM;
zone.ZoneVolCapMultpSensHMCountSum++;
}
zone.ZoneVolCapMultpSensHM = MultpHM; // For timestep output

// Calculate and store the multiplier average at the end of HM
// simulations
if (state.dataEnvrn->DayOfYear == hybridModelZone.HybridEndDayOfYear && state.dataGlobal->EndDayFlag) {
HMMultiplierAverage = zone.ZoneVolCapMultpSensHMSum / zone.ZoneVolCapMultpSensHMCountSum;
zone.ZoneVolCapMultpSensHMAverage = HMMultiplierAverage;
}
}
} // Hybrid model internal thermal mass calcualtion end

// Hybrid model people count calculation
Expand Down Expand Up @@ -5346,6 +5329,43 @@ void InverseModelTemperature(EnergyPlusData &state,
state.dataHeatBalFanSys->PreviousMeasuredZT1(ZoneNum) = thisZoneHB.ZT;
}

void processInverseModelMultpHM(EnergyPlusData &state,
Real64 &multiplierHM, // Hybrid model thermal mass multiplier
Real64 &multSumHM, // Sum of Hybrid model thermal mass multipliers
Real64 &countSumHM, // Count of number of points in sum
Real64 &multAvgHM, // Average of hybrid model mass multipier
int zoneNum // Zone number for the hybrid model
)
{
Real64 constexpr minHMMultValue = 1.0;
Real64 constexpr maxHMMultValue = 30.0;

auto &zone = state.dataHeatBal->Zone(zoneNum);
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum);

// Apply limits and generate warnings as needed
if (multiplierHM < minHMMultValue) { // don't allow this to be less than minimum (potential for instability)
multiplierHM = minHMMultValue;
} else if (multiplierHM > maxHMMultValue) { // as per suggestions in Defect #10508, only warn if greater than the max
if (thisZoneHB.hmThermalMassMultErrIndex == 0) {
ShowWarningMessage(state, format("Hybrid model thermal mass multiplier higher than the limit for {}", zone.Name));
ShowContinueError(state, "This means that the ratio of the zone air heat capacity for the current time step to the");
ShowContinueError(state, format("zone air heat storage is higher than the maximum limit of {:.1R},", maxHMMultValue));
}
ShowRecurringWarningErrorAtEnd(
state, "Hybrid model thermal mass multiplier limit exceeded in zone " + zone.Name, thisZoneHB.hmThermalMassMultErrIndex);
}

// Update running totals (but only when there is a valid multiplier, i.e. multiplier is greater than min but not higher than the max)
if (multiplierHM > minHMMultValue) {
multSumHM += multiplierHM;
countSumHM++;
}

// Calculate average (always so that it does get calculated)
if (countSumHM >= 1) multAvgHM = multSumHM / countSumHM;
}

void InverseModelHumidity(EnergyPlusData &state,
int const ZoneNum, // Zone number
Real64 const LatentGain, // Zone sum of latent gain
Expand Down
9 changes: 9 additions & 0 deletions src/EnergyPlus/ZoneTempPredictorCorrector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ namespace ZoneTempPredictorCorrector {
Real64 tempDepLoad = 0.0;
Real64 airRelHum = 0.0; // Zone relative humidity in percent
Real64 AirPowerCap = 0.0; // "air power capacity" Vol*VolMult*rho*Cp/timestep [W/degK]
int hmThermalMassMultErrIndex = 0;

virtual ~ZoneSpaceHeatBalanceData() = default;

Expand Down Expand Up @@ -338,6 +339,14 @@ namespace ZoneTempPredictorCorrector {
Real64 AirCap // Formerly CoefAirrat, coef in zone temp eqn with dim of "air power capacity"rd
);

void processInverseModelMultpHM(EnergyPlusData &state,
Real64 &multiplierHM, // Hybrid model thermal mass multiplier
Real64 &multSumHM, // Sum of Hybrid model thermal mass multipliers
Real64 &countSumHM, // Count of number of points in sum
Real64 &multAvgHM, // Average of hybrid model mass multipier
int zoneNum // Zone number for the hybrid model
);

void InverseModelHumidity(EnergyPlusData &state,
int ZoneNum, // Zone number
Real64 LatentGain, // Zone sum of latent gain
Expand Down

5 comments on commit 9ef7d61

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

10508HybridModelThermalMassCalculationIssue (RKStrand) - Win64-Windows-10-VisualStudio-16: OK (2808 of 2808 tests passed, 0 test warnings)

Build Badge Test 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.

10508HybridModelThermalMassCalculationIssue (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3637 of 3638 tests passed, 744 test warnings)

Messages:\n

  • 745 tests had: RDD diffs.
  • 1 test had: AUD diffs.
  • 1 test had: ERR diffs.
  • 1 test had: Table big diffs.

Failures:\n

regression Test Summary

  • Passed: 807
  • Failed: 1

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

10508HybridModelThermalMassCalculationIssue (RKStrand) - x86_64-MacOS-10.18-clang-15.0.0: OK (3596 of 3597 tests passed, 740 test warnings)

Messages:\n

  • 741 tests had: RDD diffs.
  • 1 test had: AUD diffs.
  • 1 test had: ERR diffs.
  • 1 test had: Table big diffs.

Failures:\n

regression Test Summary

  • Passed: 787
  • Failed: 1

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.

10508HybridModelThermalMassCalculationIssue (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (792 of 792 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

10508HybridModelThermalMassCalculationIssue (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2019 of 2019 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.