-
Notifications
You must be signed in to change notification settings - Fork 209
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
#5145 - HeatExchangerAirToAirSensibleAndLatent normalization divisor error #5193
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
|
||
#include <algorithm> | ||
#include <iomanip> | ||
#include <limits> | ||
|
||
namespace openstudio { | ||
namespace model { | ||
|
@@ -165,8 +166,13 @@ namespace model { | |
return result; | ||
} | ||
|
||
bool TableLookup_Impl::setNormalizationDivisor(double normalizationDivisior) { | ||
bool result = setDouble(OS_Table_LookupFields::NormalizationDivisor, normalizationDivisior); | ||
bool TableLookup_Impl::setNormalizationDivisor(double normalizationDivisor) { | ||
if (std::abs(normalizationDivisor) < std::numeric_limits<double>::min()) { | ||
LOG(Warn, "Unable to set " << briefDescription() << "'s Normalization divisor to zero."); | ||
return false; | ||
} | ||
|
||
bool result = setDouble(OS_Table_LookupFields::NormalizationDivisor, normalizationDivisor); | ||
Comment on lines
+169
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TableLookup will reject 0.0 now, and return false + a warn |
||
return result; | ||
} | ||
|
||
|
@@ -374,8 +380,8 @@ namespace model { | |
return getImpl<detail::TableLookup_Impl>()->setNormalizationMethod(normalizationMethod); | ||
} | ||
|
||
bool TableLookup::setNormalizationDivisor(double normalizationDivisior) { | ||
return getImpl<detail::TableLookup_Impl>()->setNormalizationDivisor(normalizationDivisior); | ||
bool TableLookup::setNormalizationDivisor(double normalizationDivisor) { | ||
return getImpl<detail::TableLookup_Impl>()->setNormalizationDivisor(normalizationDivisor); | ||
} | ||
|
||
bool TableLookup::setMinimumOutput(double minimumOutput) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,26 @@ TEST_F(ModelFixture, HeatExchangerAirToAirSensibleAndLatent_Deprecated75Effectiv | |
EXPECT_TRUE(hx.setLatentEffectivenessat75CoolingAirFlow(val2)); | ||
EXPECT_DOUBLE_EQ(val2, hx.latentEffectivenessat75CoolingAirFlow()); | ||
} | ||
|
||
// Ensure we protect users against dumb issues that lead to a normalization divisor of zero | ||
{ | ||
// Ensure no curves assigned for now | ||
hx.resetSensibleEffectivenessofHeatingAirFlowCurve(); | ||
hx.resetLatentEffectivenessofHeatingAirFlowCurve(); | ||
hx.resetSensibleEffectivenessofCoolingAirFlowCurve(); | ||
hx.resetLatentEffectivenessofCoolingAirFlowCurve(); | ||
|
||
// IMHO this doesn't make sense (IDD should be `\minimum> 0.0`), but the E+ IDD and OS IDD have always allowed it, so leaving it untouched | ||
EXPECT_TRUE(hx.setSensibleEffectivenessat100HeatingAirFlow(0.0)); | ||
EXPECT_TRUE(hx.setLatentEffectivenessat100HeatingAirFlow(0.0)); | ||
EXPECT_TRUE(hx.setSensibleEffectivenessat100CoolingAirFlow(0.0)); | ||
EXPECT_TRUE(hx.setLatentEffectivenessat100CoolingAirFlow(0.0)); | ||
|
||
EXPECT_ANY_THROW(hx.setSensibleEffectivenessat75HeatingAirFlow(0.5)); | ||
EXPECT_ANY_THROW(hx.setLatentEffectivenessat75HeatingAirFlow(0.5)); | ||
EXPECT_ANY_THROW(hx.setSensibleEffectivenessat75CoolingAirFlow(0.5)); | ||
EXPECT_ANY_THROW(hx.setLatentEffectivenessat75CoolingAirFlow(0.5)); | ||
} | ||
Comment on lines
+405
to
+423
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test that it throws with HX |
||
} | ||
|
||
TEST_F(ModelFixture, HeatExchangerAirToAirSensibleAndLatent_assignHistoricalEffectivenessCurves) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,10 @@ TEST_F(ModelFixture, TableLookup_GettersSetters) { | |
EXPECT_TRUE(tableLookup.setNormalizationDivisor(0.5)); | ||
EXPECT_EQ(0.5, tableLookup.normalizationDivisor()); | ||
|
||
// #5145 - We reject 0 as a normalization divisor | ||
EXPECT_FALSE(tableLookup.setNormalizationDivisor(0.0)); | ||
EXPECT_EQ(0.5, tableLookup.normalizationDivisor()); | ||
Comment on lines
+54
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test that TableLookup just returns false and leaves it untouched |
||
|
||
// Minimum Output: Optional Double | ||
EXPECT_TRUE(tableLookup.setMinimumOutput(0.6)); | ||
ASSERT_TRUE(tableLookup.minimumOutput()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HX: we actually throw if we get to such a condition.