Skip to content

Commit

Permalink
Try changing heatingDryBulb99 to boost::optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson authored and jmarrec committed Oct 30, 2024
1 parent df1f9fc commit 8853cd9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/utilities/filetypes/EpwFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2668,8 +2668,8 @@ double EpwDesignCondition::heatingDryBulb99pt6() const {
return m_heatingDryBulb99pt6;
}

double EpwDesignCondition::heatingDryBulb99() const {
return m_heatingDryBulb99;
boost::optional<double> EpwDesignCondition::heatingDryBulb99() const {
return boost::optional<double>(m_heatingDryBulb99);
}

double EpwDesignCondition::heatingHumidificationDewPoint99pt6() const {
Expand Down Expand Up @@ -2941,7 +2941,11 @@ void EpwDesignCondition::setHeatingDryBulb99pt6(double heatingDryBulb99pt6) {
bool EpwDesignCondition::setHeatingDryBulb99(const std::string& heatingDryBulb99) {
bool ok;
double value = stringToDouble(heatingDryBulb99, &ok);
setHeatingDryBulb99(value);
if (!ok) {
m_heatingDryBulb99 = boost::none;
} else {
setHeatingDryBulb99(value);
}
return ok;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utilities/filetypes/EpwFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class UTILITIES_API EpwDesignCondition
/** Returns the heating dry bulb temperature 99.6% in degrees C*/
double heatingDryBulb99pt6() const;
/** Returns the heating dry bulb temperature 99% in degrees C*/
double heatingDryBulb99() const;
boost::optional<double> heatingDryBulb99() const;
/** Returns the heating humidification dew point temperature 99.6% in degrees C*/
double heatingHumidificationDewPoint99pt6() const;
/** Returns the heating humidification humidity ratio 99.6% in g of moisture per kg of dry air */
Expand Down Expand Up @@ -780,7 +780,7 @@ class UTILITIES_API EpwDesignCondition
std::string m_titleOfDesignCondition;
int m_heatingColdestMonth;
double m_heatingDryBulb99pt6;
double m_heatingDryBulb99;
boost::optional<double> m_heatingDryBulb99;
double m_heatingHumidificationDewPoint99pt6;
double m_heatingHumidificationHumidityRatio99pt6;
double m_heatingHumidificationMeanCoincidentDryBulb99pt6;
Expand Down
16 changes: 10 additions & 6 deletions src/utilities/filetypes/test/EpwFile_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ TEST(Filetypes, EpwFile_Design) {
EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get());
EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get());
EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%")));
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99());
ASSERT_TRUE(designs[0].heatingDryBulb99());
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get());
EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6());
EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6());
EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6());
Expand Down Expand Up @@ -288,7 +289,8 @@ TEST(Filetypes, EpwFile_Design_DoubleRead) {
EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get());
EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get());
EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%")));
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99());
ASSERT_TRUE(designs[0].heatingDryBulb99());
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get());
EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6());
EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6());
EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6());
Expand Down Expand Up @@ -387,7 +389,8 @@ TEST(Filetypes, EpwFile_Data_DoubleRead) {
EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get());
EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get());
EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%")));
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99());
ASSERT_TRUE(designs[0].heatingDryBulb99());
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get());
EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6());
EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6());
EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6());
Expand Down Expand Up @@ -497,7 +500,7 @@ TEST(Filetypes, EpwFile_IncompleteDesign) {
path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3_IncompleteDesign.epw");
EpwFile epwFile(p);
EXPECT_EQ(p, epwFile.path());
EXPECT_EQ("BDF687C1", epwFile.checksum());
EXPECT_EQ("ECC55BA2", epwFile.checksum());
EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum());
EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city());
EXPECT_EQ("CO", epwFile.stateProvinceRegion());
Expand All @@ -515,14 +518,15 @@ TEST(Filetypes, EpwFile_IncompleteDesign) {
// Up to here, everything should be the same as the first test. Now ask for the design conditions
std::vector<EpwDesignCondition> designs = epwFile.designConditions();
EXPECT_EQ(1, designs.size());
EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition());
EXPECT_EQ("Climate Design Data 2013 ASHRAE Handbook", designs[0].titleOfDesignCondition());
EXPECT_EQ(12, designs[0].heatingColdestMonth());
EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6());
EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get());
EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get());
EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get());
EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%")));
EXPECT_EQ(-15.5, designs[0].heatingDryBulb99());
ASSERT_FALSE(designs[0].heatingDryBulb99());
//EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get());
EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6());
EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6());
EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6());
Expand Down

0 comments on commit 8853cd9

Please sign in to comment.