Skip to content

Commit

Permalink
Merge pull request #3858 from NREL/issue-3216
Browse files Browse the repository at this point in the history
Addresses #3216, wrong OS:Daylighting:Control rotation angle translated
  • Loading branch information
joseph-robertson authored Feb 14, 2020
2 parents 3260c3c + 937487e commit 05923c3
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ boost::optional<IdfObject> ForwardTranslator::translateThermalZone( ThermalZone
LOG(Warn, "Rotation of " << primaryDaylightingControl->psiRotationAroundXAxis() << " degrees about X axis not mapped for OS:Daylighting:Control " << primaryDaylightingControl->name().get());
}

if (primaryDaylightingControl->phiRotationAroundZAxis() != 0.0){
LOG(Warn, "Rotation of " << primaryDaylightingControl->phiRotationAroundZAxis() << " degrees about Z axis not mapped for OS:Daylighting:Control " << primaryDaylightingControl->name().get());
if (primaryDaylightingControl->thetaRotationAroundYAxis() != 0.0){
LOG(Warn, "Rotation of " << primaryDaylightingControl->thetaRotationAroundYAxis() << " degrees about Y axis not mapped for OS:Daylighting:Control " << primaryDaylightingControl->name().get());
}

// glare
double glareAngle = -openstudio::radToDeg(primaryDaylightingControl->thetaRotationAroundYAxis());
double glareAngle = primaryDaylightingControl->phiRotationAroundZAxis();
daylightingControlObject.setDouble(
Daylighting_ControlsFields::GlareCalculationAzimuthAngleofViewDirectionClockwisefromZoneyAxis,
glareAngle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ OptionalModelObject ReverseTranslator::translateDaylightingControls( const Works

d = workspaceObject.getDouble(Daylighting_ControlsFields::GlareCalculationAzimuthAngleofViewDirectionClockwisefromZoneyAxis);
if (d){
daylightingControl.setThetaRotationAroundYAxis(-degToRad(*d));
daylightingControl.setPhiRotationAroundZAxis(*d);
}

d = workspaceObject.getDouble(Daylighting_ControlsFields::MaximumAllowableDiscomfortGlareIndex);
Expand Down
24 changes: 24 additions & 0 deletions src/energyplus/Test/DaylightingControl_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,27 @@ TEST_F(EnergyPlusFixture,ForwardTranslator_DaylightingControl_TwoControl)

EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Daylighting_Controls).size());
}

TEST_F(EnergyPlusFixture,ForwardTranslator_DaylightingControl_3216)
{
Model model;

ThermalZone thermalZone(model);
Space space(model);
space.setThermalZone(thermalZone);

DaylightingControl daylightingControl(model);
daylightingControl.setThetaRotationAroundYAxis(90.0);
daylightingControl.setPhiRotationAroundZAxis(180.0);

EXPECT_TRUE(thermalZone.setPrimaryDaylightingControl(daylightingControl));

ForwardTranslator ft;
Workspace w = ft.translateModel(model);

WorkspaceObjectVector idfObjs = w.getObjectsByType(IddObjectType::Daylighting_Controls);
ASSERT_EQ(1u, idfObjs.size());
WorkspaceObject idf_d(idfObjs[0]);

EXPECT_EQ(daylightingControl.phiRotationAroundZAxis(), idf_d.getDouble(Daylighting_ControlsFields::GlareCalculationAzimuthAngleofViewDirectionClockwisefromZoneyAxis).get());
}
42 changes: 42 additions & 0 deletions src/energyplus/Test/ReverseTranslator_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
#include "../../model/StandardGlazing_Impl.hpp"
#include "../../model/MaterialPropertyGlazingSpectralData.hpp"
#include "../../model/MaterialPropertyGlazingSpectralData_Impl.hpp"
#include "../../model/DaylightingControl.hpp"
#include "../../model/DaylightingControl_Impl.hpp"

#include "../../utilities/core/Optional.hpp"
#include "../../utilities/core/Checksum.hpp"
Expand All @@ -104,6 +106,8 @@
#include <utilities/idd/ZoneList_FieldEnums.hxx>
#include <utilities/idd/GlobalGeometryRules_FieldEnums.hxx>
#include <utilities/idd/WindowMaterial_Glazing_FieldEnums.hxx>
#include <utilities/idd/Daylighting_Controls_FieldEnums.hxx>
#include <utilities/idd/Daylighting_ReferencePoint_FieldEnums.hxx>

#include "../../utilities/time/Time.hpp"

Expand Down Expand Up @@ -1042,3 +1046,41 @@ TEST_F(EnergyPlusFixture, ReverseTranslator_WindowMaterialGlazing_2) {
EXPECT_TRUE(standardGlazing.windowGlassSpectralDataSetName());
EXPECT_EQ(standardGlazing.windowGlassSpectralDataSet().get().name().get(), spectralData.name().get());
}

TEST_F(EnergyPlusFixture, ReverseTranslator_DaylightingControl_3216) {
openstudio::Workspace workspace(openstudio::StrictnessLevel::None, openstudio::IddFileType::EnergyPlus);

openstudio::IdfObject idfObject3(openstudio::IddObjectType::Daylighting_ReferencePoint);
idfObject3.setName("Reference Point 1");
idfObject3.setDouble(Daylighting_ReferencePointFields::XCoordinateofReferencePoint, 15);
idfObject3.setDouble(Daylighting_ReferencePointFields::YCoordinateofReferencePoint, 16.05);
idfObject3.setDouble(Daylighting_ReferencePointFields::ZCoordinateofReferencePoint, 0);

openstudio::WorkspaceObject epDaylightingReferencePoint1 = workspace.addObject(idfObject3).get();

openstudio::IdfObject idfObject1(openstudio::IddObjectType::Daylighting_Controls);
idfObject1.setDouble(Daylighting_ControlsFields::GlareCalculationAzimuthAngleofViewDirectionClockwisefromZoneyAxis, 180.0);
IdfExtensibleGroup group1 = idfObject1.pushExtensibleGroup();
group1.setString(0, "Reference Point 1");
group1.setDouble(1, 1);
group1.setDouble(2, 500);

openstudio::WorkspaceObject epDaylightingControls = workspace.addObject(idfObject1).get();

openstudio::IdfObject idfObject2(openstudio::IddObjectType::Zone);

openstudio::WorkspaceObject epZone = workspace.addObject(idfObject2).get();

EXPECT_TRUE(epDaylightingControls.setPointer(Daylighting_ControlsFields::ZoneName, epZone.handle()));
EXPECT_TRUE(epDaylightingReferencePoint1.setPointer(Daylighting_ReferencePointFields::ZoneName, epZone.handle()));

ReverseTranslator trans;
ASSERT_NO_THROW(trans.translateWorkspace(workspace));
Model model = trans.translateWorkspace(workspace);

std::vector<DaylightingControl> daylightingControls = model.getModelObjects<DaylightingControl>();
ASSERT_EQ(1u, daylightingControls.size());
DaylightingControl daylightingControl = daylightingControls[0];
EXPECT_EQ(daylightingControl.name().get(), "Reference Point 1");
EXPECT_EQ(daylightingControl.phiRotationAroundZAxis(), 180.0);
}
1 change: 0 additions & 1 deletion src/energyplus/Test/ThermalZone_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,6 @@ TEST_F(EnergyPlusFixture,ForwardTranslator_ThermalZone_Daylighting)
Space space1(m);
space1.setThermalZone(z);


Point3dVector points;
points.push_back(Point3d(0, 0, 0));
points.push_back(Point3d(0, 1, 0));
Expand Down

0 comments on commit 05923c3

Please # to comment.