Skip to content

Commit

Permalink
#3976 - Coil:Cooling:DX:VariableSpeed code changes
Browse files Browse the repository at this point in the history
* Added double getter, isDefaulted, setter and resetter
* Added to Model Test
* Added VersionTranslation for inserted field
* Added VersionTranslation test
* Added new field to the FT
* Added a FT test
* RT doesn't exist at all
  • Loading branch information
jmarrec committed May 15, 2020
1 parent c89be36 commit ff0070c
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/energyplus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ set(${target_name}_test_src
Test/CoilCoolingDXSingleSpeed_GTest.cpp
Test/CoilCoolingDXMultiSpeed_GTest.cpp
Test/CoilCoolingDXTwoStageWithHumidityControlMode_GTest.cpp
Test/CoilCoolingDXVariableSpeed_GTest.cpp
Test/Construction_GTest.cpp
Test/DaylightingControl_GTest.cpp
Test/DaylightingDeviceShelf_GTest.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXVariableSpee
idfObject.setDouble(Coil_Cooling_DX_VariableSpeedFields::MaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation,value.get());
}

// Minimum Outdoor Dry-Bulb Temperature for Compressor Operation
if( (value = modelObject.minimumOutdoorDryBulbTemperatureforCompressorOperation()) ) {
idfObject.setDouble(Coil_Cooling_DX_VariableSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation,value.get());
}

// SupplyWaterStorageTankName

// CondensateCollectionWaterStorageTankName
Expand Down
69 changes: 69 additions & 0 deletions src/energyplus/Test/CoilCoolingDXVariableSpeed_GTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/***********************************************************************************************************************
* 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 "../../model/Model.hpp"
#include "../../model/CoilCoolingDXVariableSpeed.hpp"
#include "../../model/CoilCoolingDXVariableSpeed_Impl.hpp"
#include "../../model/AirLoopHVAC.hpp"
#include "../../model/Node.hpp"

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

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

TEST_F(EnergyPlusFixture, ForwardTranslator_CoilCoolingDXVariableSpeed_MinOATCompressor) {
Model m;

CoilCoolingDXVariableSpeed coil(m);
coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(-7.5);

// Need to be used to be translated
AirLoopHVAC airLoop(m);
Node supplyOutletNode = airLoop.supplyOutletNode();
coil.addToNode(supplyOutletNode);

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

WorkspaceObjectVector idf_coils(w.getObjectsByType(IddObjectType::Coil_Cooling_DX_VariableSpeed));
ASSERT_EQ(1u, idf_coils.size());
WorkspaceObject idf_coil(idf_coils[0]);

auto _d = idf_coil.getDouble(Coil_Cooling_DX_VariableSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation);
ASSERT_TRUE(_d);
EXPECT_DOUBLE_EQ(-7.5, _d.get());
}
37 changes: 37 additions & 0 deletions src/model/CoilCoolingDXVariableSpeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,27 @@ namespace detail {
OS_ASSERT(result);
}

double CoilCoolingDXVariableSpeed_Impl::minimumOutdoorDryBulbTemperatureforCompressorOperation() const {
boost::optional<double> value = getDouble(OS_Coil_Cooling_DX_VariableSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation,true);
OS_ASSERT(value);
return value.get();
}

bool CoilCoolingDXVariableSpeed_Impl::isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted() const {
return isEmpty(OS_Coil_Cooling_DX_VariableSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation);
}

bool CoilCoolingDXVariableSpeed_Impl::setMinimumOutdoorDryBulbTemperatureforCompressorOperation(double minimumOutdoorDryBulbTemperatureforCompressorOperation) {
bool result = setDouble(OS_Coil_Cooling_DX_VariableSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation,
minimumOutdoorDryBulbTemperatureforCompressorOperation);
return result;
}

void CoilCoolingDXVariableSpeed_Impl::resetMinimumOutdoorDryBulbTemperatureforCompressorOperation() {
bool result = setString(OS_Coil_Cooling_DX_VariableSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation, "");
OS_ASSERT(result);
}

boost::optional<Curve> CoilCoolingDXVariableSpeed_Impl::optionalEnergyPartLoadFractionCurve() const {
return getObject<ModelObject>().getModelObjectTarget<Curve>(OS_Coil_Cooling_DX_VariableSpeedFields::EnergyPartLoadFractionCurveName);
}
Expand Down Expand Up @@ -921,6 +942,22 @@ void CoilCoolingDXVariableSpeed::resetBasinHeaterOperatingSchedule() {
getImpl<detail::CoilCoolingDXVariableSpeed_Impl>()->resetBasinHeaterOperatingSchedule();
}

double CoilCoolingDXVariableSpeed::minimumOutdoorDryBulbTemperatureforCompressorOperation() const {
return getImpl<detail::CoilCoolingDXVariableSpeed_Impl>()->minimumOutdoorDryBulbTemperatureforCompressorOperation();
}

bool CoilCoolingDXVariableSpeed::isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted() const {
return getImpl<detail::CoilCoolingDXVariableSpeed_Impl>()->isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted();
}

bool CoilCoolingDXVariableSpeed::setMinimumOutdoorDryBulbTemperatureforCompressorOperation(double minimumOutdoorDryBulbTemperatureforCompressorOperation) {
return getImpl<detail::CoilCoolingDXVariableSpeed_Impl>()->setMinimumOutdoorDryBulbTemperatureforCompressorOperation(minimumOutdoorDryBulbTemperatureforCompressorOperation);
}

void CoilCoolingDXVariableSpeed::resetMinimumOutdoorDryBulbTemperatureforCompressorOperation() {
getImpl<detail::CoilCoolingDXVariableSpeed_Impl>()->resetMinimumOutdoorDryBulbTemperatureforCompressorOperation();
}

std::vector<CoilCoolingDXVariableSpeedSpeedData> CoilCoolingDXVariableSpeed::speeds() const {
return getImpl<detail::CoilCoolingDXVariableSpeed_Impl>()->speeds();
}
Expand Down
8 changes: 8 additions & 0 deletions src/model/CoilCoolingDXVariableSpeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ class MODEL_API CoilCoolingDXVariableSpeed : public StraightComponent {

boost::optional<Schedule> basinHeaterOperatingSchedule() const;

double minimumOutdoorDryBulbTemperatureforCompressorOperation() const;

bool isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted() const;

//@}
/** @name Setters */
//@{
Expand Down Expand Up @@ -157,6 +161,10 @@ class MODEL_API CoilCoolingDXVariableSpeed : public StraightComponent {

void resetBasinHeaterOperatingSchedule();

bool setMinimumOutdoorDryBulbTemperatureforCompressorOperation(double minimumOutdoorDryBulbTemperatureforCompressorOperation);

void resetMinimumOutdoorDryBulbTemperatureforCompressorOperation();

//@}
/** @name Other */
//@{
Expand Down
28 changes: 19 additions & 9 deletions src/model/CoilCoolingDXVariableSpeed_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ namespace detail {

virtual bool addToNode(Node & node) override;

virtual std::vector<IdfObject> remove() override;

virtual void autosize() override;

virtual void applySizingValues() override;

//@}
/** @name Getters */
//@{
Expand Down Expand Up @@ -130,15 +136,9 @@ namespace detail {

boost::optional<Schedule> basinHeaterOperatingSchedule() const;

boost::optional<double> autosizedGrossRatedTotalCoolingCapacityAtSelectedNominalSpeedLevel() const ;

boost::optional<double> autosizedRatedAirFlowRateAtSelectedNominalSpeedLevel() const ;

boost::optional<double> autosizedEvaporativeCondenserPumpRatedPowerConsumption() const ;

virtual void autosize() override;
double minimumOutdoorDryBulbTemperatureforCompressorOperation() const;

virtual void applySizingValues() override;
bool isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted() const;

//@}
/** @name Setters */
Expand Down Expand Up @@ -190,6 +190,10 @@ namespace detail {

void resetBasinHeaterOperatingSchedule();

bool setMinimumOutdoorDryBulbTemperatureforCompressorOperation(double minimumOutdoorDryBulbTemperatureforCompressorOperation);

void resetMinimumOutdoorDryBulbTemperatureforCompressorOperation();

//@}
/** @name Other */
//@{
Expand All @@ -208,7 +212,13 @@ namespace detail {

void removeAllSpeeds();

std::vector<IdfObject> remove() override;

// Autosize methods
boost::optional<double> autosizedGrossRatedTotalCoolingCapacityAtSelectedNominalSpeedLevel() const ;

boost::optional<double> autosizedRatedAirFlowRateAtSelectedNominalSpeedLevel() const ;

boost::optional<double> autosizedEvaporativeCondenserPumpRatedPowerConsumption() const ;

//@}
protected:
Expand Down
19 changes: 19 additions & 0 deletions src/model/test/CoilCoolingDXVariableSpeed_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ TEST_F(ModelFixture,CoilCoolingDXVariableSpeed_Remove)

EXPECT_EQ(count,m.modelObjects().size() - curves.size());
}

TEST_F(ModelFixture,CoilCoolingDXVariableSpeed_MinOATCompressor)
{
Model m;

CoilCoolingDXVariableSpeed coil(m);

// #3976 - Minimum Outdoor Dry-Bulb Temperature for Compressor Operation
EXPECT_TRUE(coil.isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted());
double defaultedMinOATTemp = coil.minimumOutdoorDryBulbTemperatureforCompressorOperation();
// There are no IDD limits, so everything should work
EXPECT_TRUE(coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(-5));
EXPECT_FALSE(coil.isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted());
EXPECT_EQ(-5, coil.minimumOutdoorDryBulbTemperatureforCompressorOperation());
// reset
coil.resetMinimumOutdoorDryBulbTemperatureforCompressorOperation();
EXPECT_TRUE(coil.isMinimumOutdoorDryBulbTemperatureforCompressorOperationDefaulted());
EXPECT_EQ(defaultedMinOATTemp, coil.minimumOutdoorDryBulbTemperatureforCompressorOperation());
}
20 changes: 20 additions & 0 deletions src/osversion/VersionTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5307,6 +5307,26 @@ std::string VersionTranslator::update_3_0_0_to_3_0_1(const IdfFile& idf_3_0_0, c
m_refactored.push_back(RefactoredObjectData(object, newObject));
ss << newObject;

} else if (iddname == "OS:Coil:Cooling:DX:VariableSpeed") {
// Inserted field 'Minimum Outdoor Dry-Bulb Temperature for Compressor Operation' at position 15 (0-indexed)
auto iddObject = idd_3_0_1.getObject(iddname);
IdfObject newObject(iddObject.get());

for (size_t i = 0; i < object.numFields(); ++i) {
if ((value = object.getString(i))) {
if (i < 15) {
// Handle
newObject.setString(i, value.get());
} else {
// Every other is shifted by one field
newObject.setString(i + 1, value.get());
}
}
}

m_refactored.push_back(RefactoredObjectData(object, newObject));
ss << newObject;

// No-op
} else {
ss << object;
Expand Down
41 changes: 41 additions & 0 deletions src/osversion/test/3_0_1/test_vt_CoilCoolingDXVariableSpeed.osm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

OS:Version,
{af733672-23c2-4eea-93d6-1017dc341614}, !- Handle
3.0.0; !- Version Identifier

OS:Coil:Cooling:DX:VariableSpeed,
{e2e4bac6-5849-4c06-a35b-5b512e89e84f}, !- Handle
Coil Cooling DX Variable Speed 1, !- Name
, !- Indoor Air Inlet Node Name
, !- Indoor Air Outlet Node Name
1, !- Nominal Speed Level {dimensionless}
autosize, !- Gross Rated Total Cooling Capacity At Selected Nominal Speed Level {W}
autosize, !- Rated Air Flow Rate At Selected Nominal Speed Level {m3/s}
0, !- Nominal Time for Condensate to Begin Leaving the Coil {s}
0, !- Initial Moisture Evaporation Rate Divided by Steady-State AC Latent Capacity {dimensionless}
{dd042707-2520-4672-9cf2-194e21086783}, !- Energy Part Load Fraction Curve Name
, !- Condenser Air Inlet Node Name
AirCooled, !- Condenser Type
0, !- Evaporative Condenser Pump Rated Power Consumption {W}
0, !- Crankcase Heater Capacity {W}
11, !- Maximum Outdoor Dry-Bulb Temperature for Crankcase Heater Operation {C}
, !- Supply Water Storage Tank Name
, !- Condensate Collection Water Storage Tank Name
0, !- Basin Heater Capacity {W/K}
2, !- Basin Heater Setpoint Temperature {C}
, !- Basin Heater Operating Schedule Name
{a59a5a80-3bed-4c6b-99fe-4ef7a4dc758e}; !- Speed Data List

OS:Curve:Quadratic,
{dd042707-2520-4672-9cf2-194e21086783}, !- Handle
Curve Quadratic 1, !- Name
0.85, !- Coefficient1 Constant
0.15, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Minimum Value of x
1; !- Maximum Value of x

OS:ModelObjectList,
{a59a5a80-3bed-4c6b-99fe-4ef7a4dc758e}, !- Handle
Coil Cooling DX Variable Speed 1 Speed Data List; !- Name

27 changes: 27 additions & 0 deletions src/osversion/test/VersionTranslator_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,4 +817,31 @@ TEST_F(OSVersionFixture, update_3_0_0_to_3_0_1_CoilCoolingDXMultiSpeed_minOATCom
// Last field
ASSERT_TRUE(c.getString(17, false, true));
EXPECT_EQ("Electricity", c.getString(17, false, true).get());
}

TEST_F(OSVersionFixture, update_3_0_0_to_3_0_1_CoilCoolingDXVariableSpeed_minOATCompressor) {

openstudio::path path = resourcesPath() / toPath("osversion/3_0_1/test_vt_CoilCoolingDXVariableSpeed.osm");
osversion::VersionTranslator vt;
boost::optional<model::Model> model = vt.loadModel(path);
ASSERT_TRUE(model) << "Failed to load " << path;;
openstudio::path outPath = resourcesPath() / toPath("osversion/3_0_1/test_vt_CoilCoolingDXVariableSpeed_updated.osm");
model->save(outPath, true);

ASSERT_EQ(1u, model->getObjectsByType("OS:Coil:Cooling:DX:VariableSpeed").size());
WorkspaceObject c = model->getObjectsByType("OS:Coil:Cooling:DX:VariableSpeed")[0];

// Field before insertion point
ASSERT_TRUE(c.getDouble(14));
EXPECT_EQ(11.0, c.getDouble(14).get());

// Insertion point is at index 15, and is defaulted
EXPECT_FALSE(c.getString(15, false, true));

// After is unused (storage tank)
EXPECT_FALSE(c.getString(16, false, true));

// Last field is the SpeedDataList
ASSERT_TRUE(c.getTarget(21));
EXPECT_EQ("Coil Cooling DX Variable Speed 1 Speed Data List", c.getTarget(21)->nameString());
}

0 comments on commit ff0070c

Please sign in to comment.