Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ include_directories("${PROJECT_BINARY_DIR}/src/")
if(MSVC)
# treat warnings as errors
add_definitions(/WX)
elseif()
else()
add_definitions(-Werror)
endif()

Expand Down
16 changes: 13 additions & 3 deletions resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -7021,12 +7021,22 @@ OS:People,
\note optional (only required for thermal comfort runs)
\type object-list
\object-list ScheduleNames
A9, \field Clothing Insulation Schedule Name
A9, \field Clothing Insulation Calculation Method
\type choice
\key ClothingInsulationSchedule
\key DynamicClothingModelASHRAE55
\key CalculationMethodSchedule
\required-field
A10, \field Clothing Insulation Calculation Method Schedule Name
\type object-list
\object-list ScheduleNames
\note a schedule value of 1 for the Scheduled method, and 2 for the DynamicClothingModelASHRAE55 method
A11, \field Clothing Insulation Schedule Name
\note use "Clo" from ASHRAE or Thermal Comfort guides
\note optional (only required for thermal comfort runs)
\type object-list
\object-list ScheduleNames
A10, \field Air Velocity Schedule Name
A12, \field Air Velocity Schedule Name
\note units in the schedule are m/s
\note optional (only required for thermal comfort runs)
\type object-list
Expand All @@ -7035,7 +7045,7 @@ OS:People,
\type real
\minimum 0.0
\default 1.0
A11, \field Ankle Level Air Velocity Schedule Name
A13, \field Ankle Level Air Velocity Schedule Name
\type object-list
\object-list ScheduleNames
\note units in the schedule are m/s
Expand Down
29 changes: 26 additions & 3 deletions src/energyplus/ForwardTranslator/ForwardTranslatePeople.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,32 @@ namespace energyplus {
}
}

if (boost::optional<Schedule> schedule_ = modelObject.clothingInsulationSchedule()) {
if (auto idf_schedule_ = translateAndMapModelObject(schedule_.get())) {
idfObject.setString(PeopleFields::ClothingInsulationScheduleName, idf_schedule_->nameString());
// Clothing Insulation
// ---
// ClothingInsulationSchedule: Only Clothing Insulation Schedule Name should be filled.
// DynamicClothingModelASHRAE55: Neither should be filled.
// CalculationMethodSchedule: Both Clothing Insulation Calculation Method Schedule Name and Clothing Insulation Schedule Name should be filled.

// Clothing Insulation Calculation Method
const std::string clothingInsulationCalculationMethod = modelObject.clothingInsulationCalculationMethod();
idfObject.setString(PeopleFields::ClothingInsulationCalculationMethod, clothingInsulationCalculationMethod);

// Clothing Insulation Calculation Method Schedule Name
if (istringEqual(clothingInsulationCalculationMethod, "CalculationMethodSchedule")) {
if (boost::optional<Schedule> schedule_ = modelObject.clothingInsulationCalculationMethodSchedule()) {
if (auto idf_schedule_ = translateAndMapModelObject(schedule_.get())) {
idfObject.setString(PeopleFields::ClothingInsulationCalculationMethodScheduleName, idf_schedule_->nameString());
}
}
}

// Clothing Insulation Schedule Name
if (istringEqual(clothingInsulationCalculationMethod, "ClothingInsulationSchedule")
|| istringEqual(clothingInsulationCalculationMethod, "CalculationMethodSchedule")) {
if (boost::optional<Schedule> schedule_ = modelObject.clothingInsulationSchedule()) {
if (auto idf_schedule_ = translateAndMapModelObject(schedule_.get())) {
idfObject.setString(PeopleFields::ClothingInsulationScheduleName, idf_schedule_->nameString());
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/energyplus/ReverseTranslator/ReverseTranslatePeople.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ namespace energyplus {
}
}

s = workspaceObject.getString(openstudio::PeopleFields::ClothingInsulationCalculationMethod);
if (s) {
people.setClothingInsulationCalculationMethod(*s);
}

target = workspaceObject.getTarget(openstudio::PeopleFields::ClothingInsulationCalculationMethodScheduleName);
if (target) {
OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
if (modelObject) {
if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
Schedule schedule(*intermediate);
bool ok = people.setClothingInsulationCalculationMethodSchedule(schedule);
if (!ok) {
LOG(Warn, "Unable to set " << people.briefDescription() << "'s Clothing Insulation Calculation Method schedule to "
<< schedule.briefDescription() << ", likely because of a ScheduleTypeLimits conflict.");
}
}
}
}

target = workspaceObject.getTarget(openstudio::PeopleFields::ClothingInsulationScheduleName);
if (target) {
OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
Expand Down
14 changes: 10 additions & 4 deletions src/energyplus/Test/People_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_People) {
cloSch.setName("ClothingInsulationSchedule");
cloSch.setValue(1.0);
EXPECT_TRUE(p.setClothingInsulationSchedule(cloSch));

ScheduleConstant cloSch2(m);
cloSch2.setName("CalculationMethodSchedule");
cloSch2.setValue(1.0);
EXPECT_TRUE(p.setClothingInsulationCalculationMethodSchedule(cloSch2));
}

{
Expand Down Expand Up @@ -117,11 +122,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_People) {
EXPECT_TRUE(peopleObject.isEmpty(PeopleFields::SurfaceName_AngleFactorListName));
EXPECT_EQ("WorkEfficiencySchedule", peopleObject.getString(PeopleFields::WorkEfficiencyScheduleName).get());

EXPECT_TRUE(peopleObject.isEmpty(PeopleFields::ClothingInsulationCalculationMethod));
EXPECT_EQ("ClothingInsulationSchedule", peopleObject.getString(PeopleFields::ClothingInsulationCalculationMethod, true).get());
EXPECT_EQ("ClothingInsulationSchedule", peopleObject.getString(PeopleFields::ClothingInsulationCalculationMethod).get());
EXPECT_TRUE(peopleObject.isEmpty(PeopleFields::ClothingInsulationCalculationMethodScheduleName));

EXPECT_EQ("ClothingInsulationSchedule", peopleObject.getString(PeopleFields::ClothingInsulationScheduleName).get());

EXPECT_EQ("AirVelocitySchedule", peopleObject.getString(PeopleFields::AirVelocityScheduleName).get());
EXPECT_EQ("Fanger", peopleObject.getString(PeopleFields::ThermalComfortModel1Type).get());
EXPECT_EQ("Pierce", peopleObject.getString(PeopleFields::ThermalComfortModel2Type).get());
Expand Down Expand Up @@ -168,7 +172,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_People) {
EXPECT_TRUE(_i_people->setString(PeopleFields::MeanRadiantTemperatureCalculationType, "SurfaceWeighted"));
EXPECT_TRUE(_i_people->setString(PeopleFields::SurfaceName_AngleFactorListName, ""));
assignSchedule(PeopleFields::WorkEfficiencyScheduleName, "WorkEfficiencySchedule");
EXPECT_TRUE(_i_people->setString(PeopleFields::ClothingInsulationCalculationMethod, ""));
EXPECT_TRUE(_i_people->setString(PeopleFields::ClothingInsulationCalculationMethod, "ClothingInsulationSchedule"));
EXPECT_TRUE(_i_people->setString(PeopleFields::ClothingInsulationCalculationMethodScheduleName, ""));
assignSchedule(PeopleFields::ClothingInsulationScheduleName, "ClothingInsulationSchedule");
assignSchedule(PeopleFields::AirVelocityScheduleName, "AirVelocitySchedule");
Expand Down Expand Up @@ -198,6 +202,8 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_People) {
EXPECT_EQ("ActivitySchedule", p.activityLevelSchedule()->nameString());
ASSERT_TRUE(p.workEfficiencySchedule());
EXPECT_EQ("WorkEfficiencySchedule", p.workEfficiencySchedule()->nameString());
EXPECT_EQ("ClothingInsulationSchedule", p.clothingInsulationCalculationMethod());
EXPECT_FALSE(p.clothingInsulationCalculationMethodSchedule());
ASSERT_TRUE(p.clothingInsulationSchedule());
EXPECT_EQ("ClothingInsulationSchedule", p.clothingInsulationSchedule()->nameString());
ASSERT_TRUE(p.airVelocitySchedule());
Expand Down
55 changes: 55 additions & 0 deletions src/model/People.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <utilities/idd/OS_People_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>
#include <utilities/idd/IddFactory.hxx>

#include "../utilities/core/Assert.hpp"

Expand Down Expand Up @@ -103,6 +104,9 @@ namespace model {
if (std::find(b, e, OS_PeopleFields::WorkEfficiencyScheduleName) != e) {
result.emplace_back("People", "Work Efficiency");
}
if (std::find(b, e, OS_PeopleFields::ClothingInsulationCalculationMethodScheduleName) != e) {
result.emplace_back("People", "Clothing Insulation Calculation Method");
}
if (std::find(b, e, OS_PeopleFields::ClothingInsulationScheduleName) != e) {
result.emplace_back("People", "Clothing Insulation");
}
Expand Down Expand Up @@ -317,10 +321,35 @@ namespace model {
OS_ASSERT(result);
}

std::string People_Impl::clothingInsulationCalculationMethod() const {
boost::optional<std::string> value = getString(OS_PeopleFields::ClothingInsulationCalculationMethod, true);
OS_ASSERT(value);
return value.get();
}

boost::optional<Schedule> People_Impl::clothingInsulationCalculationMethodSchedule() const {
return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_PeopleFields::ClothingInsulationCalculationMethodScheduleName);
}

boost::optional<Schedule> People_Impl::clothingInsulationSchedule() const {
return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_PeopleFields::ClothingInsulationScheduleName);
}

bool People_Impl::setClothingInsulationCalculationMethod(const std::string& clothingInsulationCalculationMethod) {
const bool result = setString(OS_PeopleFields::ClothingInsulationCalculationMethod, clothingInsulationCalculationMethod);
return result;
}

bool People_Impl::setClothingInsulationCalculationMethodSchedule(Schedule& schedule) {
return setSchedule(OS_PeopleFields::ClothingInsulationCalculationMethodScheduleName, "People", "Clothing Insulation Calculation Method",
schedule);
}

void People_Impl::resetClothingInsulationCalculationMethodSchedule() {
bool result = setString(OS_PeopleFields::ClothingInsulationCalculationMethodScheduleName, "");
OS_ASSERT(result);
}

bool People_Impl::setClothingInsulationSchedule(Schedule& schedule) {
return setSchedule(OS_PeopleFields::ClothingInsulationScheduleName, "People", "Clothing Insulation", schedule);
}
Expand Down Expand Up @@ -611,13 +640,19 @@ namespace model {

bool test = this->setMultiplier(1.0);
OS_ASSERT(test);
test = setClothingInsulationCalculationMethod("ClothingInsulationSchedule");
OS_ASSERT(test);
}

IddObjectType People::iddObjectType() {
IddObjectType result(IddObjectType::OS_People);
return result;
}

std::vector<std::string> People::clothingInsulationCalculationMethodValues() {
return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_PeopleFields::ClothingInsulationCalculationMethod);
}

bool People::setMultiplier(double multiplier) {
return getImpl<detail::People_Impl>()->setMultiplier(multiplier);
}
Expand Down Expand Up @@ -678,10 +713,30 @@ namespace model {
getImpl<detail::People_Impl>()->resetWorkEfficiencySchedule();
}

std::string People::clothingInsulationCalculationMethod() const {
return getImpl<detail::People_Impl>()->clothingInsulationCalculationMethod();
}

boost::optional<Schedule> People::clothingInsulationCalculationMethodSchedule() const {
return getImpl<detail::People_Impl>()->clothingInsulationCalculationMethodSchedule();
}

boost::optional<Schedule> People::clothingInsulationSchedule() const {
return getImpl<detail::People_Impl>()->clothingInsulationSchedule();
}

bool People::setClothingInsulationCalculationMethod(const std::string& clothingInsulationCalculationMethod) {
return getImpl<detail::People_Impl>()->setClothingInsulationCalculationMethod(clothingInsulationCalculationMethod);
}

bool People::setClothingInsulationCalculationMethodSchedule(Schedule& schedule) {
return getImpl<detail::People_Impl>()->setClothingInsulationCalculationMethodSchedule(schedule);
}

void People::resetClothingInsulationCalculationMethodSchedule() {
getImpl<detail::People_Impl>()->resetClothingInsulationCalculationMethodSchedule();
}

bool People::setClothingInsulationSchedule(Schedule& schedule) {
return getImpl<detail::People_Impl>()->setClothingInsulationSchedule(schedule);
}
Expand Down
17 changes: 17 additions & 0 deletions src/model/People.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ namespace model {

static IddObjectType iddObjectType();

static std::vector<std::string> clothingInsulationCalculationMethodValues();

/** @name Getters */
//@{

Expand All @@ -66,6 +68,12 @@ namespace model {
/** Returns the work efficiency schedule. */
boost::optional<Schedule> workEfficiencySchedule() const;

/** Returns the clothing insulation calculation method. */
std::string clothingInsulationCalculationMethod() const;

/** Returns the clothing insulation calculation method schedule. */
boost::optional<Schedule> clothingInsulationCalculationMethodSchedule() const;

/** Returns the clothing insulation schedule. */
boost::optional<Schedule> clothingInsulationSchedule() const;

Expand Down Expand Up @@ -112,6 +120,15 @@ namespace model {
/** Resets the work efficiency Schedule. */
void resetWorkEfficiencySchedule();

/** Sets the clothing insulation calculation method. */
bool setClothingInsulationCalculationMethod(const std::string& clothingInsulationCalculationMethod);

/** Sets the clothing insulation calculation method schedule. */
bool setClothingInsulationCalculationMethodSchedule(Schedule& schedule);

/** Resets the clothing insulation calculationg method schedule. */
void resetClothingInsulationCalculationMethodSchedule();

/** Sets the clothing insulation Schedule. Returns false if schedule has a ScheduleTypeLimits
* that is incompatible with this use. Sets the ScheduleTypeLimits of schedule if there is
* none. */
Expand Down
15 changes: 15 additions & 0 deletions src/model/People_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ namespace model {
/** Returns the work efficiency schedule. */
boost::optional<Schedule> workEfficiencySchedule() const;

/** Returns the clothing insulation calculation method. */
std::string clothingInsulationCalculationMethod() const;

/** Returns the clothing insulation calculation method schedule. */
boost::optional<Schedule> clothingInsulationCalculationMethodSchedule() const;

/** Returns the clothing insulation schedule. */
boost::optional<Schedule> clothingInsulationSchedule() const;

Expand Down Expand Up @@ -123,6 +129,15 @@ namespace model {
/** Resets the work efficiency Schedule. */
void resetWorkEfficiencySchedule();

/** Sets the clothing insulation calculation method. */
bool setClothingInsulationCalculationMethod(const std::string& clothingInsulationCalculationMethod);

/** Sets the clothing insulation calculation method schedule. */
bool setClothingInsulationCalculationMethodSchedule(Schedule& schedule);

/** Resets the clothing insulation calculationg method schedule. */
void resetClothingInsulationCalculationMethodSchedule();

/** Sets the clothing insulation Schedule. */
bool setClothingInsulationSchedule(Schedule& schedule);

Expand Down
1 change: 1 addition & 0 deletions src/model/ScheduleTypeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ namespace model {
{"People", "Number of People", "numberofPeopleSchedule", true, "", 0.0, 1.0},
{"People", "Activity Level", "activityLevelSchedule", true, "ActivityLevel", 0.0, OptionalDouble()},
{"People", "Work Efficiency", "workEfficiencySchedule", true, "", 0.0, 1.0},
{"People", "Clothing Insulation Calculation Method", "clothingInsulationCalculationMethodSchedule", false, "", 1.0, 2.0},
{"People", "Clothing Insulation", "clothingInsulationSchedule", true, "ClothingInsulation", 0.0, OptionalDouble()},
{"People", "Air Velocity", "airVelocitySchedule", true, "Velocity", 0.0, OptionalDouble()},
{"People", "Ankle Level Air Velocity", "ankleLevelAirVelocitySchedule", true, "Velocity", 0.0, OptionalDouble()},
Expand Down
49 changes: 49 additions & 0 deletions src/model/test/People_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "../ScheduleRuleset.hpp"
#include "../ScheduleDay.hpp"
#include "../ScheduleTypeRegistry.hpp"
#include "../ScheduleConstant.hpp"

#include <utilities/idd/IddEnums.hxx>

Expand All @@ -34,6 +35,8 @@ TEST_F(ModelFixture, People_DefaultConstructor) {
EXPECT_EQ(definition.handle(), person.peopleDefinition().handle());
ASSERT_EQ(1u, definition.instances().size());
EXPECT_EQ(person.handle(), definition.instances()[0].handle());
EXPECT_EQ(1.0, person.multiplier());
EXPECT_EQ("ClothingInsulationSchedule", person.clothingInsulationCalculationMethod());

EXPECT_EQ("People", definition.numberofPeopleCalculationMethod());
ASSERT_TRUE(definition.numberofPeople());
Expand Down Expand Up @@ -110,6 +113,52 @@ TEST_F(ModelFixture, People_DesignLevels) {
EXPECT_EQ(1.0, definition.getFloorAreaPerPerson(100.0));
}

TEST_F(ModelFixture, People_ClothingInsulation) {
Model model;

// make a new People object
PeopleDefinition definition(model);
People person(definition);

EXPECT_EQ("ClothingInsulationSchedule", person.clothingInsulationCalculationMethod());
EXPECT_FALSE(person.clothingInsulationCalculationMethodSchedule());
EXPECT_FALSE(person.clothingInsulationSchedule());

ScheduleConstant cloSch1(model);
EXPECT_TRUE(person.setClothingInsulationCalculationMethodSchedule(cloSch1));
ScheduleConstant cloSch2(model);
EXPECT_TRUE(person.setClothingInsulationSchedule(cloSch2));

// set clothing insulation schedule
EXPECT_TRUE(person.setClothingInsulationCalculationMethod("ClothingInsulationSchedule"));
EXPECT_EQ("ClothingInsulationSchedule", person.clothingInsulationCalculationMethod());
ASSERT_TRUE(person.clothingInsulationCalculationMethodSchedule());
EXPECT_EQ(cloSch1, person.clothingInsulationCalculationMethodSchedule().get());
ASSERT_TRUE(person.clothingInsulationSchedule());
EXPECT_EQ(cloSch2, person.clothingInsulationSchedule().get());

// set dynamic clothing model ashrae 55
EXPECT_TRUE(person.setClothingInsulationCalculationMethod("DynamicClothingModelASHRAE55"));
EXPECT_EQ("DynamicClothingModelASHRAE55", person.clothingInsulationCalculationMethod());
ASSERT_TRUE(person.clothingInsulationCalculationMethodSchedule());
EXPECT_EQ(cloSch1, person.clothingInsulationCalculationMethodSchedule().get());
ASSERT_TRUE(person.clothingInsulationSchedule());
EXPECT_EQ(cloSch2, person.clothingInsulationSchedule().get());

// set calculation method schedule
EXPECT_TRUE(person.setClothingInsulationCalculationMethod("CalculationMethodSchedule"));
EXPECT_EQ("CalculationMethodSchedule", person.clothingInsulationCalculationMethod());
ASSERT_TRUE(person.clothingInsulationCalculationMethodSchedule());
EXPECT_EQ(cloSch1, person.clothingInsulationCalculationMethodSchedule().get());
ASSERT_TRUE(person.clothingInsulationSchedule());
EXPECT_EQ(cloSch2, person.clothingInsulationSchedule().get());

person.resetClothingInsulationSchedule();
person.resetClothingInsulationCalculationMethodSchedule();
EXPECT_FALSE(person.clothingInsulationSchedule());
EXPECT_FALSE(person.clothingInsulationCalculationMethodSchedule());
}

TEST_F(ModelFixture, People_Remove) {
Model model;

Expand Down
Loading
Loading