Skip to content

Commit

Permalink
Merge pull request #4013 from NREL/issue-2867
Browse files Browse the repository at this point in the history
Addresses #2867, sum of fraction radiant, fraction lost, etc can be > 1
  • Loading branch information
kbenne authored Jul 10, 2020
2 parents 0607f87 + 0b67f4a commit 46d9979
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/model/ElectricEquipmentDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ namespace detail {
}

bool ElectricEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) {

double fractionRadiantAndLost = fractionRadiant() + fractionLost();
if ( (fractionLatent + fractionRadiantAndLost) > 1.0) {
LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost
<< " and you supplied a Latent Fraction of " << fractionLatent
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_ElectricEquipment_DefinitionFields::FractionLatent, fractionLatent);
return result;
}
Expand All @@ -217,6 +225,14 @@ namespace detail {
}

bool ElectricEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) {

double fractionLatentAndLost = fractionLatent() + fractionLost();
if ( (fractionRadiant + fractionLatentAndLost) > 1.0) {
LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost
<< " and you supplied a Radiant Fraction of " << fractionRadiant
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_ElectricEquipment_DefinitionFields::FractionRadiant, fractionRadiant);
return result;
}
Expand All @@ -227,6 +243,14 @@ namespace detail {
}

bool ElectricEquipmentDefinition_Impl::setFractionLost(double fractionLost) {

double fractionLatentAndRadiant = fractionLatent() + fractionRadiant();
if ( (fractionLost + fractionLatentAndRadiant) > 1.0) {
LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant
<< " and you supplied a Lost Fraction of " << fractionLost
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_ElectricEquipment_DefinitionFields::FractionLost, fractionLost);
return result;
}
Expand Down
24 changes: 24 additions & 0 deletions src/model/GasEquipmentDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ namespace detail {
}

bool GasEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) {

double fractionRadiantAndLost = fractionRadiant() + fractionLost();
if ( (fractionLatent + fractionRadiantAndLost) > 1.0) {
LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost
<< " and you supplied a Latent Fraction of " << fractionLatent
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_GasEquipment_DefinitionFields::FractionLatent, fractionLatent);
return result;
}
Expand All @@ -227,6 +235,14 @@ namespace detail {
}

bool GasEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) {

double fractionLatentAndLost = fractionLatent() + fractionLost();
if ( (fractionRadiant + fractionLatentAndLost) > 1.0) {
LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost
<< " and you supplied a Radiant Fraction of " << fractionRadiant
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_GasEquipment_DefinitionFields::FractionRadiant, fractionRadiant);
return result;
}
Expand All @@ -237,6 +253,14 @@ namespace detail {
}

bool GasEquipmentDefinition_Impl::setFractionLost(double fractionLost) {

double fractionLatentAndRadiant = fractionLatent() + fractionRadiant();
if ( (fractionLost + fractionLatentAndRadiant) > 1.0) {
LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant
<< " and you supplied a Lost Fraction of " << fractionLost
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_GasEquipment_DefinitionFields::FractionLost, fractionLost);
return result;
}
Expand Down
24 changes: 24 additions & 0 deletions src/model/HotWaterEquipmentDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ namespace detail {
}

bool HotWaterEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) {

double fractionRadiantAndLost = fractionRadiant() + fractionLost();
if ( (fractionLatent + fractionRadiantAndLost) > 1.0) {
LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost
<< " and you supplied a Latent Fraction of " << fractionLatent
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_HotWaterEquipment_DefinitionFields::FractionLatent, fractionLatent);
return result;
}
Expand All @@ -219,6 +227,14 @@ namespace detail {
}

bool HotWaterEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) {

double fractionLatentAndLost = fractionLatent() + fractionLost();
if ( (fractionRadiant + fractionLatentAndLost) > 1.0) {
LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost
<< " and you supplied a Radiant Fraction of " << fractionRadiant
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_HotWaterEquipment_DefinitionFields::FractionRadiant, fractionRadiant);
return result;
}
Expand All @@ -229,6 +245,14 @@ namespace detail {
}

bool HotWaterEquipmentDefinition_Impl::setFractionLost(double fractionLost) {

double fractionLatentAndRadiant = fractionLatent() + fractionRadiant();
if ( (fractionLost + fractionLatentAndRadiant) > 1.0) {
LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant
<< " and you supplied a Lost Fraction of " << fractionLost
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_HotWaterEquipment_DefinitionFields::FractionLost, fractionLost);
return result;
}
Expand Down
24 changes: 24 additions & 0 deletions src/model/OtherEquipmentDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ namespace detail {
}

bool OtherEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) {

double fractionRadiantAndLost = fractionRadiant() + fractionLost();
if ( (fractionLatent + fractionRadiantAndLost) > 1.0) {
LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost
<< " and you supplied a Latent Fraction of " << fractionLatent
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_OtherEquipment_DefinitionFields::FractionLatent, fractionLatent);
return result;
}
Expand All @@ -185,6 +193,14 @@ namespace detail {
}

bool OtherEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) {

double fractionLatentAndLost = fractionLatent() + fractionLost();
if ( (fractionRadiant + fractionLatentAndLost) > 1.0) {
LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost
<< " and you supplied a Radiant Fraction of " << fractionRadiant
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_OtherEquipment_DefinitionFields::FractionRadiant, fractionRadiant);
return result;
}
Expand All @@ -195,6 +211,14 @@ namespace detail {
}

bool OtherEquipmentDefinition_Impl::setFractionLost(double fractionLost) {

double fractionLatentAndRadiant = fractionLatent() + fractionRadiant();
if ( (fractionLost + fractionLatentAndRadiant) > 1.0) {
LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant
<< " and you supplied a Lost Fraction of " << fractionLost
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_OtherEquipment_DefinitionFields::FractionLost, fractionLost);
return result;
}
Expand Down
24 changes: 24 additions & 0 deletions src/model/SteamEquipmentDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ namespace detail {
}

bool SteamEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) {

double fractionRadiantAndLost = fractionRadiant() + fractionLost();
if ( (fractionLatent + fractionRadiantAndLost) > 1.0) {
LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost
<< " and you supplied a Latent Fraction of " << fractionLatent
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_SteamEquipment_DefinitionFields::FractionLatent, fractionLatent);
return result;
}
Expand All @@ -187,6 +195,14 @@ namespace detail {
}

bool SteamEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) {

double fractionLatentAndLost = fractionLatent() + fractionLost();
if ( (fractionRadiant + fractionLatentAndLost) > 1.0) {
LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost
<< " and you supplied a Radiant Fraction of " << fractionRadiant
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_SteamEquipment_DefinitionFields::FractionRadiant, fractionRadiant);
return result;
}
Expand All @@ -197,6 +213,14 @@ namespace detail {
}

bool SteamEquipmentDefinition_Impl::setFractionLost(double fractionLost) {

double fractionLatentAndRadiant = fractionLatent() + fractionRadiant();
if ( (fractionLost + fractionLatentAndRadiant) > 1.0) {
LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant
<< " and you supplied a Lost Fraction of " << fractionLost
<< " which would result in a sum greater than 1.0");
return false;
}
bool result = setDouble(OS_SteamEquipment_DefinitionFields::FractionLost, fractionLost);
return result;
}
Expand Down
12 changes: 12 additions & 0 deletions src/model/test/ElectricEquipment_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,15 @@ TEST_F(ModelFixture, ElectricEquipment_Cost) {

EXPECT_DOUBLE_EQ(300.0, cost->totalCost());
}

/* Tests that you cannot set Fractions that sum to greater than 1 */
TEST_F(ModelFixture, ElectricEquipment_FractionsLatentRadiantLost) {
Model m;
ElectricEquipmentDefinition definition(m);

ASSERT_TRUE(definition.setFractionLatent(0.5));
ASSERT_TRUE(definition.setFractionRadiant(0.5));
ASSERT_FALSE(definition.setFractionLost(0.75));
ASSERT_FALSE(definition.setFractionLatent(0.75));
ASSERT_FALSE(definition.setFractionRadiant(0.75));
}
12 changes: 12 additions & 0 deletions src/model/test/GasEquipment_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,15 @@ TEST_F(ModelFixture, GasEquipment_Cost)

EXPECT_DOUBLE_EQ(80.0, cost->totalCost());
}

/* Tests that you cannot set Fractions that sum to greater than 1 */
TEST_F(ModelFixture, GasEquipment_FractionsLatentRadiantLost) {
Model m;
GasEquipmentDefinition definition(m);

ASSERT_TRUE(definition.setFractionLatent(0.5));
ASSERT_TRUE(definition.setFractionRadiant(0.5));
ASSERT_FALSE(definition.setFractionLost(0.75));
ASSERT_FALSE(definition.setFractionLatent(0.75));
ASSERT_FALSE(definition.setFractionRadiant(0.75));
}
12 changes: 12 additions & 0 deletions src/model/test/HotWaterEquipment_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,15 @@ TEST_F(ModelFixture, HotWaterEquipment)
HotWaterEquipment hotWaterEquipment(definition);
EXPECT_EQ(2u, model.numObjects());
}

/* Tests that you cannot set Fractions that sum to greater than 1 */
TEST_F(ModelFixture, HotWaterEquipment_FractionsLatentRadiantLost) {
Model m;
HotWaterEquipmentDefinition definition(m);

ASSERT_TRUE(definition.setFractionLatent(0.5));
ASSERT_TRUE(definition.setFractionRadiant(0.5));
ASSERT_FALSE(definition.setFractionLost(0.75));
ASSERT_FALSE(definition.setFractionLatent(0.75));
ASSERT_FALSE(definition.setFractionRadiant(0.75));
}
12 changes: 12 additions & 0 deletions src/model/test/OtherEquipment_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,15 @@ TEST_F(ModelFixture, OtherEquipment_EndUseSubcategory)
EXPECT_TRUE(equipment.isEndUseSubcategoryDefaulted());

}

/* Tests that you cannot set Fractions that sum to greater than 1 */
TEST_F(ModelFixture, OtherEquipment_FractionsLatentRadiantLost) {
Model m;
OtherEquipmentDefinition definition(m);

ASSERT_TRUE(definition.setFractionLatent(0.5));
ASSERT_TRUE(definition.setFractionRadiant(0.5));
ASSERT_FALSE(definition.setFractionLost(0.75));
ASSERT_FALSE(definition.setFractionLatent(0.75));
ASSERT_FALSE(definition.setFractionRadiant(0.75));
}
12 changes: 12 additions & 0 deletions src/model/test/SteamEquipment_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ TEST_F(ModelFixture, SteamEquipment_Instance)
SteamEquipment instance(definition);
EXPECT_TRUE(instance.definition().optionalCast<SteamEquipmentDefinition>());
}

/* Tests that you cannot set Fractions that sum to greater than 1 */
TEST_F(ModelFixture, SteamEquipment_FractionsLatentRadiantLost) {
Model m;
SteamEquipmentDefinition definition(m);

ASSERT_TRUE(definition.setFractionLatent(0.5));
ASSERT_TRUE(definition.setFractionRadiant(0.5));
ASSERT_FALSE(definition.setFractionLost(0.75));
ASSERT_FALSE(definition.setFractionLatent(0.75));
ASSERT_FALSE(definition.setFractionRadiant(0.75));
}

0 comments on commit 46d9979

Please sign in to comment.