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

Fix #2797 - Do not translate a ZoneHVACLowTempRadiant object if it doesn't have any surfaces with Internal Source #3986

Merged
merged 3 commits into from
Aug 10, 2020
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
1 change: 1 addition & 0 deletions src/energyplus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ set(${target_name}_test_src
Test/ThermostatSetpointDualSetpoint_GTest.cpp
Test/WindowPropertyFrameAndDivider_GTest.cpp
Test/ZoneHVACLowTemperatureRadiantConstFlow_GTest.cpp
Test/ZoneHVACLowTempRadiantConstFlow_GTest.cpp
Test/ZoneHVACLowTempRadiantElectric_GTest.cpp
Test/ZoneHVACLowTempRadiantVarFlow_GTest.cpp
Test/ZoneHVACTerminalUnitVariableRefrigerantFlow_GTest.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ boost::optional<IdfObject> ForwardTranslator::translateZoneHVACLowTempRadiantCon
boost::optional<double> value;
boost::optional<ModelObject> temp;

// If it doesn't have any surfaces, then don't bother translating it, E+ will crash
if (modelObject.surfaces().empty()) {
LOG(Info, modelObject.briefDescription() << " does not have any target surfaces with ConstructionWithInternalSource, it will not be translated");
return boost::none;
}

IdfObject idfObject(IddObjectType::ZoneHVAC_LowTemperatureRadiant_ConstantFlow);
m_idfObjects.push_back(idfObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ boost::optional<IdfObject> ForwardTranslator::translateZoneHVACLowTempRadiantVar
boost::optional<double> value;
boost::optional<ModelObject> temp;

// If it doesn't have any surfaces, then don't bother translating it, E+ will crash
if (modelObject.surfaces().empty()) {
LOG(Info, modelObject.briefDescription() << " does not have any target surfaces with ConstructionWithInternalSource, it will not be translated");
return boost::none;
}

IdfObject idfObject(IddObjectType::ZoneHVAC_LowTemperatureRadiant_VariableFlow);
m_idfObjects.push_back(idfObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ boost::optional<IdfObject> ForwardTranslator::translateZoneHVACLowTemperatureRad
boost::optional<double> value;
boost::optional<ModelObject> temp;

// If it doesn't have any surfaces, then don't bother translating it, E+ will crash
if (modelObject.surfaces().empty()) {
LOG(Info, modelObject.briefDescription() << " does not have any target surfaces with ConstructionWithInternalSource, it will not be translated");
return boost::none;
}

IdfObject idfObject(IddObjectType::ZoneHVAC_LowTemperatureRadiant_Electric);
m_idfObjects.push_back(idfObject);

Expand Down
124 changes: 124 additions & 0 deletions src/energyplus/Test/ZoneHVACLowTempRadiantConstFlow_GTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/

#include <gtest/gtest.h>
#include "EnergyPlusFixture.hpp"

#include "../ForwardTranslator.hpp"
#include "../ReverseTranslator.hpp"

#include "../../model/ZoneHVACLowTempRadiantConstFlow.hpp"
#include "../../model/ZoneHVACLowTempRadiantConstFlow_Impl.hpp"
#include "../../model/CoilCoolingLowTempRadiantConstFlow.hpp"
#include "../../model/CoilCoolingLowTempRadiantConstFlow_Impl.hpp"
#include "../../model/CoilHeatingLowTempRadiantConstFlow.hpp"
#include "../../model/CoilHeatingLowTempRadiantConstFlow_Impl.hpp"
#include "../../model/ConstructionWithInternalSource.hpp"
#include "../../model/ScheduleConstant.hpp"
#include "../../model/ThermalZone.hpp"
#include "../../model/Space.hpp"

#include <utilities/idd/ZoneHVAC_LowTemperatureRadiant_VariableFlow_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>

#include "../../utilities/idf/IdfExtensibleGroup.hpp"

#include <resources.hxx>

#include <sstream>

using namespace openstudio::energyplus;
using namespace openstudio::model;
using namespace openstudio;

TEST_F(EnergyPlusFixture, ZoneHVACLowTempRadiantConstFlow_Crash_no_constructions) {

ForwardTranslator ft;

Model m;

// make a space with some surfaces
Point3dVector points;
points.push_back(Point3d(0, 0, 0));
points.push_back(Point3d(0, 1, 0));
points.push_back(Point3d(1, 1, 0));
points.push_back(Point3d(1, 0, 0));

boost::optional<Space> _space1 = Space::fromFloorPrint(points, 3, m);
ASSERT_TRUE(_space1);

// make a zone, add the space
ThermalZone z(m);
_space1->setThermalZone(z);

// make some plant loops
PlantLoop clg_loop(m);
PlantLoop htg_loop(m);

ASSERT_NO_THROW(ft.translateModel(m));

// Make a radiant low temperature system
Schedule alwaysOn = m.alwaysOnDiscreteSchedule();



ScheduleConstant availabilitySched(m);
ScheduleConstant coolingHighWaterTempSched(m);
ScheduleConstant coolingLowWaterTempSched(m);
ScheduleConstant coolingHighControlTempSched(m);
ScheduleConstant coolingLowControlTempSched(m);
ScheduleConstant heatingHighWaterTempSched(m);
ScheduleConstant heatingLowWaterTempSched(m);
ScheduleConstant heatingHighControlTempSched(m);
ScheduleConstant heatingLowControlTempSched(m);

availabilitySched.setValue(1.0);
coolingHighWaterTempSched.setValue(15.0);
coolingLowWaterTempSched.setValue(10.0);
coolingHighControlTempSched.setValue(26.0);
coolingLowControlTempSched.setValue(22.0);
heatingHighWaterTempSched.setValue(50.0);
heatingLowWaterTempSched.setValue(30.0);
heatingHighControlTempSched.setValue(21.0);
heatingLowControlTempSched.setValue(15.0);

CoilCoolingLowTempRadiantConstFlow clg_coil(m,coolingHighWaterTempSched,coolingLowWaterTempSched,coolingHighControlTempSched,coolingLowControlTempSched);
CoilHeatingLowTempRadiantConstFlow htg_coil(m,heatingHighWaterTempSched,heatingLowWaterTempSched,heatingHighControlTempSched,heatingLowControlTempSched);

ZoneHVACLowTempRadiantConstFlow testRad(m, alwaysOn, htg_coil, clg_coil);
EXPECT_TRUE(testRad.addToThermalZone(z));

ASSERT_NO_THROW(ft.translateModel(m));

// Test for #2797 - When no surfaces, it shouldn't even be translated or E+ will crash
EXPECT_TRUE(testRad.surfaces().empty());
Workspace w = ft.translateModel(m);
WorkspaceObjectVector idf_rads(w.getObjectsByType(IddObjectType::ZoneHVAC_LowTemperatureRadiant_ConstantFlow));
EXPECT_EQ(0u, idf_rads.size());
}
45 changes: 44 additions & 1 deletion src/energyplus/Test/ZoneHVACLowTempRadiantElectric_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include "../../model/StandardOpaqueMaterial_Impl.hpp"
#include "../../model/ThermalZone.hpp"
#include "../../model/ThermalZone_Impl.hpp"
#include "../../model/Space.hpp"
#include <utilities/idd/IddEnums.hxx>

#include <utilities/idd/ZoneHVAC_LowTemperatureRadiant_Electric_FieldEnums.hxx>
#include "../../utilities/idf/IdfExtensibleGroup.hpp"
Expand Down Expand Up @@ -122,7 +124,48 @@ TEST_F(EnergyPlusFixture,ZoneHVACLowTempRadiantElectric_Set_Flow_Fractions)
}
}
}

}

TEST_F(EnergyPlusFixture, ZoneHVACLowTempRadiantElectric_Crash_no_constructions) {

ForwardTranslator ft;

Model m;

// make a space with some surfaces
Point3dVector points;
points.push_back(Point3d(0, 0, 0));
points.push_back(Point3d(0, 1, 0));
points.push_back(Point3d(1, 1, 0));
points.push_back(Point3d(1, 0, 0));

boost::optional<Space> _space1 = Space::fromFloorPrint(points, 3, m);
ASSERT_TRUE(_space1);

// make a zone, add the space
ThermalZone z(m);
_space1->setThermalZone(z);

// make some plant loops
PlantLoop clg_loop(m);
PlantLoop htg_loop(m);

ASSERT_NO_THROW(ft.translateModel(m));

// Make a radiant low temperature system
Schedule alwaysOn = m.alwaysOnDiscreteSchedule();

ScheduleConstant heatingControlTemperatureSchedule(m);
heatingControlTemperatureSchedule.setValue(10.0);

ZoneHVACLowTemperatureRadiantElectric testRad(m,alwaysOn,heatingControlTemperatureSchedule);
EXPECT_TRUE(testRad.addToThermalZone(z));

ASSERT_NO_THROW(ft.translateModel(m));

// Test for #2797 - When no surfaces, it shouldn't even be translated or E+ will crash
EXPECT_TRUE(testRad.surfaces().empty());
Workspace w = ft.translateModel(m);
WorkspaceObjectVector idf_rads(w.getObjectsByType(IddObjectType::ZoneHVAC_LowTemperatureRadiant_Electric));
EXPECT_EQ(0u, idf_rads.size());
}
8 changes: 8 additions & 0 deletions src/energyplus/Test/ZoneHVACLowTempRadiantVarFlow_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include "../../model/Space.hpp"

#include <utilities/idd/ZoneHVAC_LowTemperatureRadiant_VariableFlow_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>

#include "../../utilities/idf/IdfExtensibleGroup.hpp"

#include <resources.hxx>
Expand Down Expand Up @@ -184,4 +186,10 @@ TEST_F(EnergyPlusFixture, ZoneHVACLowTempRadiantVarFlow_Crash_no_constructions)
EXPECT_TRUE(testRad.addToThermalZone(z));

ASSERT_NO_THROW(ft.translateModel(m));

// Test for #2797 - When no surfaces, it shouldn't even be translated or E+ will crash
EXPECT_TRUE(testRad.surfaces().empty());
Workspace w = ft.translateModel(m);
WorkspaceObjectVector idf_rads(w.getObjectsByType(IddObjectType::ZoneHVAC_LowTemperatureRadiant_VariableFlow));
EXPECT_EQ(0u, idf_rads.size());
}