Skip to content

Commit

Permalink
Merge pull request #5321 from NREL/5314_HPWH_TankElementControlLogic
Browse files Browse the repository at this point in the history
Fix #5314 - Add Tank Element Control Logic field to WaterHeaterHeatPump
  • Loading branch information
jmarrec authored Dec 23, 2024
2 parents 73e12b9 + 2e37401 commit 6f293ed
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 6 deletions.
11 changes: 10 additions & 1 deletion resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -31701,7 +31701,16 @@ OS:WaterHeater:HeatPump,
\note A schedule value of 1 denotes inlet air is drawn only from outdoors.
\note Schedule values between 0 and 1 denote a mixture of zone and outdoor air
\note proportional to the schedule value.
A19; \field Control Sensor Location In Stratified Tank
A19, \field Tank Element Control Logic
\type choice
\key MutuallyExclusive
\key Simultaneous
\required-field
\note MutuallyExclusive means that once the tank heating element is active the
\note heat pump is shut down until setpoint is reached.
\note Simultaneous (default) means that both the tank heating element and
\note heat pump are used at the same time recover the tank temperature.
A20; \field Control Sensor Location In Stratified Tank
\note Used to indicate height of control sensor if Tank Object Type is WaterHeater:Stratified
\type choice
\key Heater1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ namespace energyplus {
idfObject.setString(WaterHeater_HeatPump_PumpedCondenserFields::ParasiticHeatRejectionLocation, value);
}

{
auto value = modelObject.tankElementControlLogic();
idfObject.setString(WaterHeater_HeatPump_PumpedCondenserFields::TankElementControlLogic, value);
}

{
auto tank = modelObject.tank();
if (auto stratifiedTank = tank.optionalCast<model::WaterHeaterStratified>()) {
Expand Down
25 changes: 25 additions & 0 deletions src/model/WaterHeaterHeatPump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ namespace model {
return value.get();
}

std::string WaterHeaterHeatPump_Impl::tankElementControlLogic() const {
boost::optional<std::string> value = getString(OS_WaterHeater_HeatPumpFields::TankElementControlLogic, true);
OS_ASSERT(value);
return value.get();
}

std::string WaterHeaterHeatPump_Impl::controlSensorLocationInStratifiedTank() const {
boost::optional<std::string> value = getString(OS_WaterHeater_HeatPumpFields::ControlSensorLocationInStratifiedTank, true);
OS_ASSERT(value);
Expand Down Expand Up @@ -393,6 +399,11 @@ namespace model {
return result;
}

bool WaterHeaterHeatPump_Impl::setTankElementControlLogic(const std::string& tankElementControlLogic) {
bool result = setString(OS_WaterHeater_HeatPumpFields::TankElementControlLogic, tankElementControlLogic);
return result;
}

bool WaterHeaterHeatPump_Impl::setControlSensorLocationInStratifiedTank(const std::string& controlSensorLocationInStratifiedTank) {
bool result = setString(OS_WaterHeater_HeatPumpFields::ControlSensorLocationInStratifiedTank, controlSensorLocationInStratifiedTank);
return result;
Expand Down Expand Up @@ -565,6 +576,7 @@ namespace model {
setOnCycleParasiticElectricLoad(0.0);
setOffCycleParasiticElectricLoad(0.0);
setParasiticHeatRejectionLocation("Outdoors");
setTankElementControlLogic("Simultaneous");
setControlSensorLocationInStratifiedTank("Heater1");
}

Expand Down Expand Up @@ -621,6 +633,7 @@ namespace model {
setOnCycleParasiticElectricLoad(0.0);
setOffCycleParasiticElectricLoad(0.0);
setParasiticHeatRejectionLocation("Outdoors");
setTankElementControlLogic("Simultaneous");
setControlSensorLocationInStratifiedTank("Heater1");
}

Expand Down Expand Up @@ -649,6 +662,10 @@ namespace model {
OS_WaterHeater_HeatPumpFields::ControlSensorLocationInStratifiedTank);
}

std::vector<std::string> WaterHeaterHeatPump::tankElementControlLogicValues() {
return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_WaterHeater_HeatPumpFields::TankElementControlLogic);
}

boost::optional<Schedule> WaterHeaterHeatPump::availabilitySchedule() const {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->availabilitySchedule();
}
Expand Down Expand Up @@ -737,6 +754,10 @@ namespace model {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->inletAirMixerSchedule();
}

std::string WaterHeaterHeatPump::tankElementControlLogic() const {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->tankElementControlLogic();
}

std::string WaterHeaterHeatPump::controlSensorLocationInStratifiedTank() const {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->controlSensorLocationInStratifiedTank();
}
Expand Down Expand Up @@ -855,6 +876,10 @@ namespace model {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->setInletAirMixerSchedule(schedule);
}

bool WaterHeaterHeatPump::setTankElementControlLogic(const std::string& tankElementControlLogic) {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->setTankElementControlLogic(tankElementControlLogic);
}

bool WaterHeaterHeatPump::setControlSensorLocationInStratifiedTank(const std::string& controlSensorLocationInStratifiedTank) {
return getImpl<detail::WaterHeaterHeatPump_Impl>()->setControlSensorLocationInStratifiedTank(controlSensorLocationInStratifiedTank);
}
Expand Down
6 changes: 6 additions & 0 deletions src/model/WaterHeaterHeatPump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace model {

static std::vector<std::string> parasiticHeatRejectionLocationValues();

static std::vector<std::string> tankElementControlLogicValues();

static std::vector<std::string> controlSensorLocationInStratifiedTankValues();

/** @name Getters */
Expand Down Expand Up @@ -104,6 +106,8 @@ namespace model {

Schedule inletAirMixerSchedule() const;

std::string tankElementControlLogic() const;

std::string controlSensorLocationInStratifiedTank() const;

//@}
Expand Down Expand Up @@ -166,6 +170,8 @@ namespace model {

bool setInletAirMixerSchedule(Schedule& schedule);

bool setTankElementControlLogic(const std::string& tankElementControlLogic);

bool setControlSensorLocationInStratifiedTank(const std::string& controlSensorLocationInStratifiedTank);

//@}
Expand Down
4 changes: 2 additions & 2 deletions src/model/WaterHeaterHeatPumpWrappedCondenser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ namespace model {
setOnCycleParasiticElectricLoad(0.0);
setOffCycleParasiticElectricLoad(0.0);
setParasiticHeatRejectionLocation("Outdoors");
setTankElementControlLogic("MutuallyExclusive");
setTankElementControlLogic("MutuallyExclusive"); // TODO: The E+ default is Simultaneous!
setControlSensor1HeightInStratifiedTank(1.262);
setControlSensor1Weight(0.75);
setControlSensor2HeightInStratifiedTank(0.464);
Expand Down Expand Up @@ -640,7 +640,7 @@ namespace model {
setOnCycleParasiticElectricLoad(0.0);
setOffCycleParasiticElectricLoad(0.0);
setParasiticHeatRejectionLocation("Outdoors");
setTankElementControlLogic("MutuallyExclusive");
setTankElementControlLogic("MutuallyExclusive"); // TODO: The E+ default is Simultaneous!
setControlSensor1HeightInStratifiedTank(1.262);
setControlSensor1Weight(0.75);
setControlSensor2HeightInStratifiedTank(0.464);
Expand Down
4 changes: 4 additions & 0 deletions src/model/WaterHeaterHeatPump_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ namespace model {

Schedule inletAirMixerSchedule() const;

std::string tankElementControlLogic() const;

std::string controlSensorLocationInStratifiedTank() const;

boost::optional<double> autosizedCondenserWaterFlowRate() const;
Expand Down Expand Up @@ -165,6 +167,8 @@ namespace model {

bool setInletAirMixerSchedule(Schedule& schedule);

bool setTankElementControlLogic(const std::string& tankElementControlLogic);

bool setControlSensorLocationInStratifiedTank(const std::string& controlSensorLocationInStratifiedTank);

//@}
Expand Down
8 changes: 8 additions & 0 deletions src/model/test/WaterHeaterHeatPump_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ TEST_F(ModelFixture, WaterHeaterHeatPump_GettersSetters) {
EXPECT_EQ(obj, hpwh.inletAirMixerSchedule());
}

// Tank Element Control Logic: Required String
EXPECT_EQ("Simultaneous", hpwh.tankElementControlLogic());
EXPECT_TRUE(hpwh.setTankElementControlLogic("MutuallyExclusive"));
EXPECT_EQ("MutuallyExclusive", hpwh.tankElementControlLogic());
// Bad Value
EXPECT_FALSE(hpwh.setTankElementControlLogic("BADENUM"));
EXPECT_EQ("MutuallyExclusive", hpwh.tankElementControlLogic());

// Control Sensor Location In Stratified Tank: Required String
EXPECT_TRUE(hpwh.setControlSensorLocationInStratifiedTank("Heater1"));
EXPECT_EQ("Heater1", hpwh.controlSensorLocationInStratifiedTank());
Expand Down
46 changes: 45 additions & 1 deletion src/osversion/VersionTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace osversion {
m_updateMethods[VersionString("3.7.0")] = &VersionTranslator::update_3_6_1_to_3_7_0;
m_updateMethods[VersionString("3.8.0")] = &VersionTranslator::update_3_7_0_to_3_8_0;
m_updateMethods[VersionString("3.9.0")] = &VersionTranslator::update_3_8_0_to_3_9_0;
m_updateMethods[VersionString("3.9.1")] = &VersionTranslator::defaultUpdate;
m_updateMethods[VersionString("3.9.1")] = &VersionTranslator::update_3_9_0_to_3_9_1;
// m_updateMethods[VersionString("3.10.0")] = &VersionTranslator::defaultUpdate;

// List of previous versions that may be updated to this one.
Expand Down Expand Up @@ -9636,5 +9636,49 @@ namespace osversion {

} // end update_3_8_0_to_3_9_0

std::string VersionTranslator::update_3_9_0_to_3_9_1(const IdfFile& idf_3_9_0, const IddFileAndFactoryWrapper& idd_3_9_1) {
std::stringstream ss;
boost::optional<std::string> value;

ss << idf_3_9_0.header() << '\n' << '\n';
IdfFile targetIdf(idd_3_9_1.iddFile());
ss << targetIdf.versionObject().get();

for (const IdfObject& object : idf_3_9_0.objects()) {
auto iddname = object.iddObject().name();

if (iddname == "OS:WaterHeater:HeatPump") {

// 1 Field has been inserted from 3.9.0 to 3.9.1:
// ----------------------------------------------
// * Tank Element Control Logic * 25
auto iddObject = idd_3_9_1.getObject(iddname);
IdfObject newObject(iddObject.get());

for (size_t i = 0; i < object.numFields(); ++i) {
if ((value = object.getString(i))) {
if (i < 25) {
newObject.setString(i, value.get());
} else {
newObject.setString(i + 1, value.get());
}
}
}

newObject.setString(25, "Simultaneous");

ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

// No-op
} else {
ss << object;
}
}

return ss.str();

} // end update_3_9_0_to_3_9_1

} // namespace osversion
} // namespace openstudio
1 change: 1 addition & 0 deletions src/osversion/VersionTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ namespace osversion {
std::string update_3_6_1_to_3_7_0(const IdfFile& idf_3_6_1, const IddFileAndFactoryWrapper& idd_3_7_0);
std::string update_3_7_0_to_3_8_0(const IdfFile& idf_3_7_0, const IddFileAndFactoryWrapper& idd_3_8_0);
std::string update_3_8_0_to_3_9_0(const IdfFile& idf_3_8_0, const IddFileAndFactoryWrapper& idd_3_9_0);
std::string update_3_9_0_to_3_9_1(const IdfFile& idf_3_9_0, const IddFileAndFactoryWrapper& idd_3_9_1);

IdfObject updateUrlField_0_7_1_to_0_7_2(const IdfObject& object, unsigned index);

Expand Down
Loading

0 comments on commit 6f293ed

Please sign in to comment.