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
6 changes: 3 additions & 3 deletions resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -3904,8 +3904,8 @@ OS:People:Definition,
A5, \field Mean Radiant Temperature Calculation Type
\note optional (only required for thermal comfort runs)
\type choice
\default ZoneAveraged
\key ZoneAveraged
\default EnclosureAveraged
\key EnclosureAveraged
\key SurfaceWeighted
\key AngleFactor
A6; \field Thermal Comfort Model Type
Expand Down Expand Up @@ -12054,7 +12054,7 @@ OS:AirLoopHVAC:UnitarySystem,
\key Yes
\key No
\required-field
\note This field is not used when Design Specification Multispeed Object Type input is present
\note This field is not used when Design Specification Multispeed Object Type input is present
\note When Yes is selected the minimum air flow rate is used.
\note When No is selected the maximum air flow rate is used.
N17, \field Maximum Supply Air Temperature
Expand Down
5 changes: 4 additions & 1 deletion src/model/PeopleDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ namespace model {
}

bool PeopleDefinition_Impl::setMeanRadiantTemperatureCalculationType(const std::string& meanRadiantTemperatureCalculationType) {
bool result = setString(OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType, meanRadiantTemperatureCalculationType);
// Backward compat, starting at 3.8.0
const std::string mrtType =
istringEqual("ZoneAveraged", meanRadiantTemperatureCalculationType) ? "EnclosureAveraged" : meanRadiantTemperatureCalculationType;
bool result = setString(OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType, mrtType);
return result;
}

Expand Down
18 changes: 18 additions & 0 deletions src/model/test/People_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ 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("SurfaceWeighted"));
EXPECT_EQ("SurfaceWeighted", definition.meanRadiantTemperatureCalculationType());

// Backward compat
EXPECT_TRUE(definition.setMeanRadiantTemperatureCalculationType("ZoneAveraged"));
EXPECT_EQ("EnclosureAveraged", definition.meanRadiantTemperatureCalculationType());

EXPECT_FALSE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
EXPECT_TRUE(definition.setMeanRadiantTemperatureCalculationType("SurfaceWeighted"));
EXPECT_EQ("SurfaceWeighted", definition.meanRadiantTemperatureCalculationType());
EXPECT_FALSE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
definition.resetMeanRadiantTemperatureCalculationType();
EXPECT_TRUE(definition.isMeanRadiantTemperatureCalculationTypeDefaulted());
}

TEST_F(ModelFixture, People_DesignLevels) {
Expand Down
33 changes: 30 additions & 3 deletions src/osversion/VersionTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9084,8 +9084,8 @@ namespace osversion {

newObject.setString(10, "Yes");

m_refactored.push_back(RefactoredObjectData(object, newObject));
ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

} else if (iddname == "OS:ZoneHVAC:WaterToAirHeatPump") {

Expand All @@ -9107,8 +9107,8 @@ namespace osversion {

newObject.setString(9, "Yes");

m_refactored.push_back(RefactoredObjectData(object, newObject));
ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

} else if (iddname == "OS:AirLoopHVAC:UnitarySystem") {

Expand All @@ -9130,8 +9130,35 @@ namespace osversion {

newObject.setString(35, "Yes");

m_refactored.push_back(RefactoredObjectData(object, newObject));
ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

} else 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 (istringEqual(value.get(), "ZoneAveraged")) {
newObject.setString(10, "EnclosureAveraged");
} else {
newObject.setString(10, value.get());
}
} else {
newObject.setString(i, value.get());
}
}
}

ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

// No-op
} else {
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 @@ -4161,3 +4161,28 @@ TEST_F(OSVersionFixture, update_3_7_0_to_3_8_0_NoLoadSupplyAirFlowRateControlSet
EXPECT_EQ(80, unitary.getDouble(36).get()); // Maximum Supply Air Temperature {C}
EXPECT_EQ(0, unitary.getDouble(40).get()); // Ancilliary Off-Cycle Electric Power {W}
}

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
}