Skip to content

Commit

Permalink
Merge 922c2ca into c68fcf6
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec authored Aug 12, 2020
2 parents c68fcf6 + 922c2ca commit 7c236bf
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/energyplus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@ set(${target_name}_test_src
Test/ThermalZone_GTest.cpp
Test/ThermostatSetpointDualSetpoint_GTest.cpp
Test/WindowPropertyFrameAndDivider_GTest.cpp
Test/WaterHeaterMixed_GTest.cpp
Test/WaterHeaterStratified_GTest.cpp
Test/ZoneHVACLowTemperatureRadiantConstFlow_GTest.cpp
Test/ZoneHVACLowTempRadiantConstFlow_GTest.cpp
Test/ZoneHVACLowTempRadiantElectric_GTest.cpp
Expand Down
6 changes: 6 additions & 0 deletions src/energyplus/ForwardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,12 @@ std::vector<IddObjectType> ForwardTranslator::iddObjectsToTranslateInitializer()
result.push_back(IddObjectType::OS_Coil_Heating_Water);
result.push_back(IddObjectType::OS_Coil_Heating_WaterToAirHeatPump_EquationFit);
result.push_back(IddObjectType::OS_Coil_WaterHeating_Desuperheater);

// If using a plantLoop, this will be translated by the PlantLoop. But WaterHeaters can also be used stand-alone, so always translate them
// We'll check in their FT if the "Peak Use Flow Rate" is actually initialized as it's an indication that the WH was
result.push_back(IddObjectType::OS_WaterHeater_Mixed);
result.push_back(IddObjectType::OS_WaterHeater_Stratified);

result.push_back(IddObjectType::OS_Connection);
result.push_back(IddObjectType::OS_Connector_Mixer);
result.push_back(IddObjectType::OS_Connector_Splitter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@
#include "../../model/CurveCubic_Impl.hpp"
#include "../../model/ThermalZone.hpp"
#include "../../model/ThermalZone_Impl.hpp"
#include <utilities/idd/WaterHeater_Mixed_FieldEnums.hxx>
#include "../../model/PlantLoop.hpp"
#include "../../model/PlantLoop_Impl.hpp"

#include "../../utilities/idd/IddEnums.hpp"
#include "../../utilities/core/Optional.hpp"

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

Expand All @@ -58,6 +63,12 @@ boost::optional<IdfObject> ForwardTranslator::translateWaterHeaterMixed( WaterHe
boost::optional<double> value;
boost::optional<Schedule> schedule;

if (!(modelObject.plantLoop() || (modelObject.peakUseFlowRate() && modelObject.useFlowRateFractionSchedule()))) {
LOG(Warn, modelObject.briefDescription() << " will not be translated as it is not on a PlantLoop, and it does not have both a Peak Use Flow Rate "
"and a Use Flow Rate Fraction Schedule which is a required condition for stand-alone operation");
return boost::none;
}

IdfObject idfObject(IddObjectType::WaterHeater_Mixed);

m_idfObjects.push_back(idfObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@
#include "../../model/WaterHeaterStratified_Impl.hpp"
#include "../../model/ThermalZone.hpp"
#include "../../model/ThermalZone_Impl.hpp"
#include <utilities/idd/WaterHeater_Stratified_FieldEnums.hxx>
#include "../../model/PlantLoop.hpp"

#include "../../utilities/idd/IddEnums.hpp"
#include "../../utilities/core/Optional.hpp"

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

Expand All @@ -54,6 +58,12 @@ boost::optional<IdfObject> ForwardTranslator::translateWaterHeaterStratified( Wa
boost::optional<double> value;
boost::optional<Schedule> schedule;

if (!modelObject.plantLoop() && !(modelObject.peakUseFlowRate() && modelObject.useFlowRateFractionSchedule()) ) {
LOG(Warn, modelObject.briefDescription() << " will not be translated as it is not on a PlantLoop, and it does not have both a Peak Use Flow Rate "
"and a Use Flow Rate Fraction Schedule which is a required condition for stand-alone operation");
return boost::none;
}

// Name
IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::WaterHeater_Stratified, modelObject);

Expand Down
1 change: 1 addition & 0 deletions src/energyplus/Test/GeneratorMicroTurbine_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorGeneratorMicroTurbine_ELCD_Orphan)
// Add it on the same branch as the chpHR, right after it
Node mchpHROutletNode = mchpHR.outletModelObject()->cast<Node>();
ASSERT_TRUE(waterHeater.addToNode(mchpHROutletNode));
EXPECT_TRUE(waterHeater.plantLoop());

// Create a plantEquipmentOperationHeatingLoad
PlantEquipmentOperationHeatingLoad operation(model);
Expand Down
114 changes: 114 additions & 0 deletions src/energyplus/Test/WaterHeaterMixed_GTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/***********************************************************************************************************************
* 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/Model.hpp"
#include "../../model/WaterHeaterMixed.hpp"
// #include "../../model/WaterHeaterMixed_Impl.hpp"
#include "../../model/Schedule.hpp"

#include "../../model/PlantLoop.hpp"
#include "../../model/PlantLoop_Impl.hpp"

#include "../../utilities/idf/IdfFile.hpp"
#include "../../utilities/idf/Workspace.hpp"
#include "../../utilities/idf/IdfObject.hpp"
#include "../../utilities/idf/WorkspaceObject.hpp"
#include "../../utilities/idf/IdfExtensibleGroup.hpp"

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

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

// Test for #1675
TEST_F(EnergyPlusFixture,ForwardTranslatorWaterHeaterMixed_Condition)
{
ForwardTranslator ft;
Model m;

WaterHeaterMixed wh(m);
EXPECT_FALSE(wh.peakUseFlowRate());
EXPECT_FALSE(wh.useFlowRateFractionSchedule());

// Not on a PlantLoop, and no Peak use Flow rate => Not translated
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Mixed).size());
}

// Has a peak flow rate, but still missing the Flow Rate schedule
EXPECT_TRUE(wh.setPeakUseFlowRate(0.1));
EXPECT_TRUE(wh.peakUseFlowRate());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Mixed).size());
}

// Has both required conditions for standalone
auto alwaysOnContinuous = m.alwaysOnContinuousSchedule();
EXPECT_TRUE(wh.setUseFlowRateFractionSchedule(alwaysOnContinuous));
EXPECT_TRUE(wh.useFlowRateFractionSchedule());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::WaterHeater_Mixed).size());
}

// Now it has the schedule, but not the peak use flow rate
wh.resetPeakUseFlowRate();
EXPECT_FALSE(wh.peakUseFlowRate());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Mixed).size());
}

// Now it has neither
wh.resetUseFlowRateFractionSchedule();
EXPECT_FALSE(wh.useFlowRateFractionSchedule());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Mixed).size());
}

PlantLoop p(m);
// Add a supply branch for the wh
EXPECT_TRUE(p.addSupplyBranchForComponent(wh));
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::WaterHeater_Mixed).size());
}

}
114 changes: 114 additions & 0 deletions src/energyplus/Test/WaterHeaterStratified_GTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/***********************************************************************************************************************
* 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/Model.hpp"
#include "../../model/WaterHeaterStratified.hpp"
// #include "../../model/WaterHeaterStratified_Impl.hpp"
#include "../../model/Schedule.hpp"

#include "../../model/PlantLoop.hpp"
#include "../../model/PlantLoop_Impl.hpp"

#include "../../utilities/idf/IdfFile.hpp"
#include "../../utilities/idf/Workspace.hpp"
#include "../../utilities/idf/IdfObject.hpp"
#include "../../utilities/idf/WorkspaceObject.hpp"
#include "../../utilities/idf/IdfExtensibleGroup.hpp"

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

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

// Test for #1675
TEST_F(EnergyPlusFixture,ForwardTranslatorWaterHeaterStratified_Condition)
{
ForwardTranslator ft;
Model m;

WaterHeaterStratified wh(m);
EXPECT_FALSE(wh.peakUseFlowRate());
EXPECT_FALSE(wh.useFlowRateFractionSchedule());

// Not on a PlantLoop, and no Peak use Flow rate => Not translated
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Stratified).size());
}

// Has a peak flow rate, but still missing the Flow Rate schedule
EXPECT_TRUE(wh.setPeakUseFlowRate(0.1));
EXPECT_TRUE(wh.peakUseFlowRate());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Stratified).size());
}

// Has both required conditions for standalone
auto alwaysOnContinuous = m.alwaysOnContinuousSchedule();
EXPECT_TRUE(wh.setUseFlowRateFractionSchedule(alwaysOnContinuous));
EXPECT_TRUE(wh.useFlowRateFractionSchedule());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::WaterHeater_Stratified).size());
}

// Now it has the schedule, but not the peak use flow rate
wh.resetPeakUseFlowRate();
EXPECT_FALSE(wh.peakUseFlowRate());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Stratified).size());
}

// Now it has neither
wh.resetUseFlowRateFractionSchedule();
EXPECT_FALSE(wh.useFlowRateFractionSchedule());
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(0u, w.getObjectsByType(IddObjectType::WaterHeater_Stratified).size());
}

PlantLoop p(m);
// Add a supply branch for the wh
EXPECT_TRUE(p.addSupplyBranchForComponent(wh));
{
Workspace w = ft.translateModel(m);
EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::WaterHeater_Stratified).size());
}

}
14 changes: 14 additions & 0 deletions src/model/GeneratorMicroTurbine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ namespace detail {
return newCHP;
}

std::vector<IdfObject> GeneratorMicroTurbine_Impl::remove() {
std::vector<IdfObject> result;

if (boost::optional<GeneratorMicroTurbineHeatRecovery> mchpHR = generatorMicroTurbineHeatRecovery()) {
std::vector<IdfObject> objs = mchpHR->remove();
result.insert(result.end(), objs.begin(), objs.end());
}

std::vector<IdfObject> objs = Generator_Impl::remove();
result.insert(result.end(), objs.begin(), objs.end());

return result;
}

// Return allowable child types: Generator:MicroTurbine
std::vector<IddObjectType> GeneratorMicroTurbine_Impl::allowableChildTypes() const
{
Expand Down
16 changes: 11 additions & 5 deletions src/model/GeneratorMicroTurbine_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ namespace detail {

virtual boost::optional<double> ratedThermaltoElectricalPowerRatio() const override;

// Will clone also the mchpHR if any
virtual ModelObject clone(Model model) const override;

// Will also remove the mchpHR (and remove it from loop) if any
virtual std::vector<IdfObject> remove() override;

virtual std::vector<IddObjectType> allowableChildTypes() const override;

virtual std::vector<ModelObject> children() const override;


//@}
/** @name Getters */
//@{
Expand Down Expand Up @@ -258,11 +269,6 @@ namespace detail {
/** @name Other */
//@{

ModelObject clone(Model model) const override;

std::vector<IddObjectType> allowableChildTypes() const override;

std::vector<ModelObject> children() const override;

//@}
protected:
Expand Down

0 comments on commit 7c236bf

Please sign in to comment.