Skip to content
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

v24.1.0-IOFreeze: PeopleDefinition's EnclosureAveraged key #5100

Merged
merged 11 commits into from
Mar 8, 2024
3 changes: 2 additions & 1 deletion resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -3904,8 +3904,9 @@ OS:People:Definition,
A5, \field Mean Radiant Temperature Calculation Type
\note optional (only required for thermal comfort runs)
\type choice
\default ZoneAveraged
\default EnclosureAveraged
\key ZoneAveraged
\key EnclosureAveraged
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
\key SurfaceWeighted
\key AngleFactor
A6; \field Thermal Comfort Model Type
Expand Down
5 changes: 4 additions & 1 deletion src/energyplus/ForwardTranslator/ForwardTranslatePeople.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ namespace energyplus {
}

if (!definition.isMeanRadiantTemperatureCalculationTypeDefaulted()) {
idfObject.setString(PeopleFields::MeanRadiantTemperatureCalculationType, definition.meanRadiantTemperatureCalculationType());
std::string meanRadiantTemperatureCalculationType = definition.meanRadiantTemperatureCalculationType();
if (!(meanRadiantTemperatureCalculationType == "ZoneAveraged")) {
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
idfObject.setString(PeopleFields::MeanRadiantTemperatureCalculationType, meanRadiantTemperatureCalculationType);
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
}
}

// TODO: Surface Name/Angle Factor List Name
Expand Down
12 changes: 12 additions & 0 deletions src/model/test/People_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ TEST_F(ModelFixture, People_DefaultConstructor) {
EXPECT_EQ(0, definition.numberofPeople().get());
EXPECT_FALSE(definition.peopleperSpaceFloorArea());
EXPECT_FALSE(definition.spaceFloorAreaperPerson());

EXPECT_TRUE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
EXPECT_NE("ZoneAveraged", definition.meanRadiantTemperatureCalculationType());
EXPECT_EQ("EnclosureAveraged", definition.meanRadiantTemperatureCalculationType());
EXPECT_TRUE(definition.setMeanRadiantTemperatureCalculationType("ZoneAveraged"));
EXPECT_EQ("ZoneAveraged", definition.meanRadiantTemperatureCalculationType());
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_FALSE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
EXPECT_TRUE(definition.setMeanRadiantTemperatureCalculationType("EnclosureAveraged"));
EXPECT_EQ("EnclosureAveraged", definition.meanRadiantTemperatureCalculationType());
EXPECT_FALSE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
definition.resetMeanRadiantTemperatureCalculationType();
EXPECT_TRUE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
}

TEST_F(ModelFixture, People_DesignLevels) {
Expand Down
51 changes: 50 additions & 1 deletion src/osversion/VersionTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ namespace osversion {
m_updateMethods[VersionString("3.5.1")] = &VersionTranslator::update_3_5_0_to_3_5_1;
m_updateMethods[VersionString("3.6.0")] = &VersionTranslator::update_3_5_1_to_3_6_0;
m_updateMethods[VersionString("3.7.0")] = &VersionTranslator::update_3_6_1_to_3_7_0;
m_updateMethods[VersionString("3.8.0")] = &VersionTranslator::defaultUpdate;
m_updateMethods[VersionString("3.8.0")] = &VersionTranslator::update_3_7_0_to_3_8_0;
// m_updateMethods[VersionString("3.8.0")] = &VersionTranslator::defaultUpdate;

// List of previous versions that may be updated to this one.
// - To increment the translator, add an entry for the version just released (branched for
Expand Down Expand Up @@ -8951,5 +8952,53 @@ namespace osversion {

} // end update_3_6_1_to_3_7_0

std::string VersionTranslator::update_3_7_0_to_3_8_0(const IdfFile& idf_3_7_0, const IddFileAndFactoryWrapper& idd_3_8_0) {
std::stringstream ss;
boost::optional<std::string> value;

ss << idf_3_7_0.header() << '\n' << '\n';
IdfFile targetIdf(idd_3_8_0.iddFile());
ss << targetIdf.versionObject().get();

for (const IdfObject& object : idf_3_7_0.objects()) {
auto iddname = object.iddObject().name();

if (iddname == "OS:People:Definition") {

// 1 Key has been changed from 3.7.0 to 3.8.0:
// ----------------------------------------------
// * Mean Radiant Temperature Calculation Type * 10
// * ZoneAveraged -> EnclosureAveraged

auto iddObject = idd_3_8_0.getObject(iddname);
IdfObject newObject(iddObject.get());

for (size_t i = 0; i < object.numFields(); ++i) {
if ((value = object.getString(i))) {
if (i == 10) {
if (value.get() == "ZoneAveraged") {
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
newObject.setString(10, "EnclosureAveraged");
} else {
newObject.setString(10, value.get());
}
} else {
newObject.setString(i, value.get());
}
}
}

m_refactored.push_back(RefactoredObjectData(object, newObject));
ss << newObject;
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved

// No-op
} else {
ss << object;
}
}

return ss.str();

} // end update_3_7_0_to_3_8_0

} // namespace osversion
} // namespace openstudio
1 change: 1 addition & 0 deletions src/osversion/VersionTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ namespace osversion {
std::string update_3_5_0_to_3_5_1(const IdfFile& idf_3_5_0, const IddFileAndFactoryWrapper& idd_3_5_1);
std::string update_3_5_1_to_3_6_0(const IdfFile& idf_3_5_1, const IddFileAndFactoryWrapper& idd_3_6_0);
std::string update_3_6_1_to_3_7_0(const IdfFile& idf_3_6_1, const IddFileAndFactoryWrapper& idd_3_7_0);
std::string update_3_7_0_to_3_8_0(const IdfFile& idf_3_7_0, const IddFileAndFactoryWrapper& idd_3_8_0);

IdfObject updateUrlField_0_7_1_to_0_7_2(const IdfObject& object, unsigned index);

Expand Down
18 changes: 18 additions & 0 deletions src/osversion/test/3_8_0/test_vt_PeopleDefinition.osm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

OS:Version,
{7541834d-c2da-4d8b-8eaa-5219048d5428}, !- Handle
3.7.0; !- Version Identifier

OS:People:Definition,
{ede10f40-c28d-4de2-b32b-570d4e205850}, !- Handle
People Definition 1, !- Name
People, !- Number of People Calculation Method
0, !- Number of People {people}
, !- People per Space Floor Area {person/m2}
, !- Space Floor Area per Person {m2/person}
0.3, !- Fraction Radiant
, !- Sensible Heat Fraction
, !- Carbon Dioxide Generation Rate {m3/s-W}
, !- Enable ASHRAE 55 Comfort Warnings
ZoneAveraged; !- Mean Radiant Temperature Calculation Type

10 changes: 10 additions & 0 deletions src/osversion/test/3_8_0/test_vt_PeopleDefinition.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#require '/usr/local/openstudio-3.6.1/Ruby/openstudio'

include OpenStudio::Model

m = Model.new

people_def = PeopleDefinition.new(m)
people_def.setMeanRadiantTemperatureCalculationType("ZoneAveraged")

m.save('test_vt_PeopleDefinition.osm', true)
25 changes: 25 additions & 0 deletions src/osversion/test/VersionTranslator_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4022,3 +4022,28 @@ TEST_F(OSVersionFixture, update_3_6_1_to_3_7_0_HeatPumpPlantLoopEIR) {
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // TimedEmpiricalDefrostHeatInputEnergyFractionCurveName
}
}

TEST_F(OSVersionFixture, update_3_7_0_to_3_8_0_PeopleDefinition) {
openstudio::path path = resourcesPath() / toPath("osversion/3_8_0/test_vt_PeopleDefinition.osm");
osversion::VersionTranslator vt;
boost::optional<model::Model> model = vt.loadModel(path);
ASSERT_TRUE(model) << "Failed to load " << path;

openstudio::path outPath = resourcesPath() / toPath("osversion/3_8_0/test_vt_PeopleDefinition_updated.osm");
model->save(outPath, true);

std::vector<WorkspaceObject> defs = model->getObjectsByType("OS:People:Definition");
ASSERT_EQ(1u, defs.size());
WorkspaceObject def = defs[0];

EXPECT_EQ("People Definition 1", def.getString(1).get()); // Name
EXPECT_EQ("People", def.getString(2).get()); // Number of People Calculation Method
EXPECT_EQ(0, def.getDouble(3).get()); // Number of People {people}
EXPECT_TRUE(def.isEmpty(4)); // People per Space Floor Area {person/m2}
EXPECT_TRUE(def.isEmpty(5)); // Space Floor Area per Person {m2/person}
EXPECT_EQ(0.3, def.getDouble(6).get()); // Fraction Radiant
EXPECT_TRUE(def.isEmpty(7)); // Sensible Heat Fraction
EXPECT_TRUE(def.isEmpty(8)); // Carbon Dioxide Generation Rate {m3/s-W}
EXPECT_TRUE(def.isEmpty(9)); // Enable ASHRAE 55 Comfort Warnings
EXPECT_EQ("EnclosureAveraged", def.getString(10).get()); // Mean Radiant Temperature Calculation Type
}