Skip to content

Commit

Permalink
Fix #4074 - Implement Setpoint2 and support all Shading Control Type …
Browse files Browse the repository at this point in the history
…& improve model logic
  • Loading branch information
jmarrec committed Sep 15, 2020
1 parent 7ee6d21 commit d6041d8
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 60 deletions.
50 changes: 35 additions & 15 deletions src/energyplus/ForwardTranslator/ForwardTranslateShadingControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ boost::optional<IdfObject> ForwardTranslator::translateShadingControl(model::Sha
return boost::none;
}

// Read this now, since we'll use it to test if a Warn is needed
std::string shadingControlType = modelObject.shadingControlType();

if (modelObject.isControlTypeValueNeedingSetpoint1() && !modelObject.setpoint()) {
LOG(Error, modelObject.briefDescription() << " is using Shading Control Type '" << shadingControlType
<< "' which requires a Setpoint which is missing, it will not be translated");
return boost::none;
}

if (modelObject.isControlTypeValueNeedingSetpoint2() && !modelObject.setpoint2()) {
LOG(Error, modelObject.briefDescription() << " is using Shading Control Type '" << shadingControlType
<< "' which requires a Setpoint2 which is missing, it will not be translated");
return boost::none;
}

if (modelObject.isControlTypeValueRequiringSchedule() && !modelObject.schedule()) {
LOG(Error, modelObject.briefDescription() << " is using Shading Control Type '" << shadingControlType
<< "' which requires a Schedule which is missing, it will not be translated");
return boost::none;
}

IdfObject idfObject(openstudio::IddObjectType::WindowShadingControl);

m_idfObjects.push_back(idfObject);
Expand Down Expand Up @@ -94,8 +115,6 @@ boost::optional<IdfObject> ForwardTranslator::translateShadingControl(model::Sha
}
idfObject.setString(WindowShadingControlFields::ZoneName, zoneName);

// Read this now, since we'll use it to test if a Warn is needed
std::string shadingControlType = modelObject.shadingControlType();
idfObject.setString(WindowShadingControlFields::ShadingControlType, shadingControlType);

if (zone) {
Expand Down Expand Up @@ -137,21 +156,24 @@ boost::optional<IdfObject> ForwardTranslator::translateShadingControl(model::Sha
idfObject.setString(WindowShadingControlFields::ShadingDeviceMaterialName, shadingMaterial->name().get());
}

boost::optional<Schedule> schedule = modelObject.schedule();
if (schedule) {
idfObject.setString(WindowShadingControlFields::ScheduleName, schedule->name().get());
idfObject.setString(WindowShadingControlFields::ShadingControlIsScheduled, "Yes");
if (modelObject.isControlTypeValueAllowingSchedule()) {
boost::optional<Schedule> schedule = modelObject.schedule();
if (schedule) {
idfObject.setString(WindowShadingControlFields::ScheduleName, schedule->name().get());
idfObject.setString(WindowShadingControlFields::ShadingControlIsScheduled, "Yes");
} else {
idfObject.setString(WindowShadingControlFields::ShadingControlIsScheduled, "No");
}
} else {
idfObject.setString(WindowShadingControlFields::ShadingControlIsScheduled, "No");
}

boost::optional<double> setpoint = modelObject.setpoint();
if (istringEqual("OnIfHighSolarOnWindow", shadingControlType)) {
if (!setpoint) {
setpoint = 100; // W/m2
}
OS_ASSERT(setpoint);
idfObject.setDouble(WindowShadingControlFields::Setpoint, *setpoint);
if (modelObject.isControlTypeValueNeedingSetpoint1()) {
idfObject.setDouble(WindowShadingControlFields::Setpoint, modelObject.setpoint().get());
}

if (modelObject.isControlTypeValueNeedingSetpoint2()) {
idfObject.setDouble(WindowShadingControlFields::Setpoint2, modelObject.setpoint2().get());
}

idfObject.setString(WindowShadingControlFields::GlareControlIsActive, "No");
Expand All @@ -160,8 +182,6 @@ boost::optional<IdfObject> ForwardTranslator::translateShadingControl(model::Sha

//idfObject.setString(WindowShadingControlFields::SlatAngleScheduleName, "");

//idfObject.setDouble(WindowShadingControlFields::Setpoint2, 0.0);

idfObject.setString(WindowShadingControlFields::MultipleSurfaceControlType, modelObject.multipleSurfaceControlType());

idfObject.clearExtensibleGroups();
Expand Down
12 changes: 7 additions & 5 deletions src/energyplus/Test/ShadingControl_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ShadingControls)
ShadingControl shadingControl1(blind1);
EXPECT_TRUE(shadingControl1.setShadingType("ExteriorBlind"));

EXPECT_TRUE(shadingControl1.setShadingControlType("OnNightIfLowOutdoorTempAndOffDay"));
EXPECT_TRUE(shadingControl1.setShadingControlType("OnIfHighZoneAirTempAndHighSolarOnWindow"));
EXPECT_TRUE(shadingControl1.isControlTypeValueAllowingSchedule());
EXPECT_TRUE(shadingControl1.isControlTypeValueNeedingSetpoint1());
EXPECT_TRUE(shadingControl1.isControlTypeValueNeedingSetpoint2());

ScheduleConstant shadingControl1Schedule(model);
EXPECT_TRUE(shadingControl1.setSchedule(shadingControl1Schedule));
EXPECT_TRUE(shadingControl1.setSetpoint(3.0));
EXPECT_TRUE(shadingControl1.setSetpoint(25.0));
EXPECT_TRUE(shadingControl1.setSetpoint2(500.0));
EXPECT_TRUE(shadingControl1.setMultipleSurfaceControlType("Sequential"));
EXPECT_TRUE(shadingControl1.addSubSurface(subSurfaceA));
// Convenience method that calls ShadingControl::addSubSurface()
Expand Down Expand Up @@ -176,16 +178,16 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ShadingControls)
EXPECT_EQ(1, _wo->getInt(WindowShadingControlFields::ShadingControlSequenceNumber, false).get());
EXPECT_EQ("ExteriorBlind", _wo->getString(WindowShadingControlFields::ShadingType, false, true).get());
EXPECT_FALSE(_wo->getString(WindowShadingControlFields::ConstructionwithShadingName, false, true));
EXPECT_EQ("OnNightIfLowOutdoorTempAndOffDay", _wo->getString(WindowShadingControlFields::ShadingControlType, false, true).get());
EXPECT_EQ(3.0, _wo->getDouble(WindowShadingControlFields::Setpoint, false).get());
EXPECT_EQ("OnIfHighZoneAirTempAndHighSolarOnWindow", _wo->getString(WindowShadingControlFields::ShadingControlType, false, true).get());
EXPECT_EQ(25.0, _wo->getDouble(WindowShadingControlFields::Setpoint, false).get());
EXPECT_EQ(500.0, _wo->getDouble(WindowShadingControlFields::Setpoint2, false).get());

EXPECT_EQ(shadingControl1Schedule.nameString(), _wo->getString(WindowShadingControlFields::ScheduleName, false, true).get());
EXPECT_EQ("Yes", _wo->getString(WindowShadingControlFields::ShadingControlIsScheduled, false, true).get());

EXPECT_EQ("No", _wo->getString(WindowShadingControlFields::GlareControlIsActive, false, true).get());
EXPECT_EQ(blind1.nameString(), _wo->getString(WindowShadingControlFields::ShadingDeviceMaterialName, false, true).get());
EXPECT_FALSE(_wo->getString(WindowShadingControlFields::SlatAngleScheduleName, false, true));
EXPECT_FALSE(_wo->getString(WindowShadingControlFields::Setpoint2, false, true));
EXPECT_FALSE(_wo->getString(WindowShadingControlFields::DaylightingControlObjectName, false, true));
EXPECT_EQ("Sequential", _wo->getString(WindowShadingControlFields::MultipleSurfaceControlType, false).get());
ASSERT_EQ(2u, _wo->extensibleGroups().size());
Expand Down
Loading

0 comments on commit d6041d8

Please sign in to comment.