-
Notifications
You must be signed in to change notification settings - Fork 196
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 #5313 - AirLoopHVACUnitaryHeatPump(Multispeed) fixes #5322
Changes from all commits
c5bfaca
33fd849
93c150f
1ede1bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ | |
#include "CoilHeatingElectric_Impl.hpp" | ||
#include "CoilHeatingGas.hpp" | ||
#include "CoilHeatingGas_Impl.hpp" | ||
#include "CoilHeatingWater.hpp" | ||
#include "CoilHeatingWater_Impl.hpp" | ||
#include "FanConstantVolume.hpp" | ||
#include "FanConstantVolume_Impl.hpp" | ||
#include "FanOnOff.hpp" | ||
|
@@ -114,10 +116,19 @@ namespace model { | |
std::vector<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::children() const { | ||
std::vector<ModelObject> result; | ||
|
||
result.push_back(supplyAirFan()); | ||
result.push_back(coolingCoil()); | ||
result.push_back(heatingCoil()); | ||
result.push_back(supplementalHeatingCoil()); | ||
// Avoid crashing when calling remove() in Ctor when failing to set one of the child component by calling the optional one | ||
if (boost::optional<HVACComponent> supplyFan = this->optionalSupplyAirFan()) { | ||
result.push_back(std::move(*supplyFan)); | ||
} | ||
if (boost::optional<HVACComponent> coolingCoil = this->optionalCoolingCoil()) { | ||
result.push_back(std::move(*coolingCoil)); | ||
} | ||
if (boost::optional<HVACComponent> heatingCoil = this->optionalHeatingCoil()) { | ||
result.push_back(std::move(*heatingCoil)); | ||
} | ||
if (boost::optional<HVACComponent> supplementalHeatingCoil = this->optionalSupplementalHeatingCoil()) { | ||
result.push_back(std::move(*supplementalHeatingCoil)); | ||
} | ||
Comment on lines
+119
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix for the crash is here |
||
|
||
return result; | ||
} | ||
|
@@ -206,44 +217,51 @@ namespace model { | |
} | ||
|
||
HVACComponent AirLoopHVACUnitaryHeatPumpAirToAir_Impl::supplyAirFan() const { | ||
boost::optional<HVACComponent> result; | ||
|
||
result = getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::SupplyAirFanName); | ||
|
||
OS_ASSERT(result); | ||
|
||
return result.get(); | ||
boost::optional<HVACComponent> value = optionalSupplyAirFan(); | ||
if (!value) { | ||
LOG_AND_THROW(briefDescription() << " does not have an Supply Air Fan attached."); | ||
} | ||
return value.get(); | ||
} | ||
|
||
HVACComponent AirLoopHVACUnitaryHeatPumpAirToAir_Impl::heatingCoil() const { | ||
boost::optional<HVACComponent> result; | ||
|
||
result = getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::HeatingCoilName); | ||
|
||
OS_ASSERT(result); | ||
|
||
return result.get(); | ||
boost::optional<HVACComponent> value = optionalHeatingCoil(); | ||
if (!value) { | ||
LOG_AND_THROW(briefDescription() << " does not have an Heating Coil attached."); | ||
} | ||
return value.get(); | ||
} | ||
|
||
HVACComponent AirLoopHVACUnitaryHeatPumpAirToAir_Impl::coolingCoil() const { | ||
boost::optional<HVACComponent> result; | ||
|
||
result = getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::CoolingCoilName); | ||
|
||
OS_ASSERT(result); | ||
|
||
return result.get(); | ||
boost::optional<HVACComponent> value = optionalCoolingCoil(); | ||
if (!value) { | ||
LOG_AND_THROW(briefDescription() << " does not have an Cooling Coil attached."); | ||
} | ||
return value.get(); | ||
} | ||
|
||
HVACComponent AirLoopHVACUnitaryHeatPumpAirToAir_Impl::supplementalHeatingCoil() const { | ||
boost::optional<HVACComponent> result; | ||
auto value = optionalSupplementalHeatingCoil(); | ||
if (!value) { | ||
LOG_AND_THROW(briefDescription() << " does not have a Supplemental Heating Coil attached."); | ||
} | ||
return value.get(); | ||
} | ||
|
||
boost::optional<HVACComponent> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::optionalSupplyAirFan() const { | ||
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::SupplyAirFanName); | ||
} | ||
|
||
result = | ||
getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::SupplementalHeatingCoilName); | ||
boost::optional<HVACComponent> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::optionalHeatingCoil() const { | ||
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::HeatingCoilName); | ||
} | ||
|
||
OS_ASSERT(result); | ||
boost::optional<HVACComponent> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::optionalCoolingCoil() const { | ||
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::CoolingCoilName); | ||
} | ||
|
||
return result.get(); | ||
boost::optional<HVACComponent> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::optionalSupplementalHeatingCoil() const { | ||
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAirFields::SupplementalHeatingCoilName); | ||
} | ||
|
||
boost::optional<double> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::maximumSupplyAirTemperaturefromSupplementalHeater() const { | ||
|
@@ -419,6 +437,8 @@ namespace model { | |
isTypeOK = true; | ||
} else if (hvacComponent.optionalCast<CoilHeatingElectric>()) { | ||
isTypeOK = true; | ||
} else if (hvacComponent.optionalCast<CoilHeatingWater>()) { | ||
isTypeOK = true; | ||
Comment on lines
+440
to
+441
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we check type on Multispeed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OS:AirLoopHVAC:UnitaryHeatPump:AirToAir,
[...]
A10, \field Supplemental Heating Coil Name
\note Needs to match in the supplemental heating coil object
\type object-list
\required-field
+ \object-list HeatingCoilsGasElec OS:AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed,
A12, \field Supplemental Heating Coil
\type object-list
+ \object-list HeatingCoilName Technically speaking, checking specifically on the The Multispeed accepts all coils. |
||
} | ||
|
||
if (isTypeOK) { | ||
|
@@ -488,130 +508,6 @@ namespace model { | |
OS_ASSERT(result); | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::availabilityScheduleAsModelObject() const { | ||
OptionalModelObject result = availabilitySchedule(); | ||
return result; | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::controllingZoneAsModelObject() const { | ||
OptionalModelObject result; | ||
OptionalThermalZone intermediate = controllingZone(); | ||
if (intermediate) { | ||
result = *intermediate; | ||
} | ||
return result; | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::supplyAirFanAsModelObject() const { | ||
OptionalModelObject result = supplyAirFan(); | ||
return result; | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::heatingCoilAsModelObject() const { | ||
OptionalModelObject result = heatingCoil(); | ||
return result; | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::coolingCoilAsModelObject() const { | ||
OptionalModelObject result = coolingCoil(); | ||
return result; | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::supplementalHeatingCoilAsModelObject() const { | ||
OptionalModelObject result = supplementalHeatingCoil(); | ||
return result; | ||
} | ||
|
||
boost::optional<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::supplyAirFanOperatingModeScheduleAsModelObject() const { | ||
OptionalModelObject result; | ||
OptionalSchedule intermediate = supplyAirFanOperatingModeSchedule(); | ||
if (intermediate) { | ||
result = *intermediate; | ||
} | ||
return result; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setAvailabilityScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalSchedule intermediate = modelObject->optionalCast<Schedule>(); | ||
if (intermediate) { | ||
Schedule schedule(*intermediate); | ||
return setAvailabilitySchedule(schedule); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setControllingZoneAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalThermalZone intermediate = modelObject->optionalCast<ThermalZone>(); | ||
if (intermediate) { | ||
setControllingZone(*intermediate); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setSupplyAirFanAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalHVACComponent intermediate = modelObject->optionalCast<HVACComponent>(); | ||
if (intermediate) { | ||
setSupplyAirFan(*intermediate); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setHeatingCoilAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalHVACComponent intermediate = modelObject->optionalCast<HVACComponent>(); | ||
if (intermediate) { | ||
setHeatingCoil(*intermediate); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setCoolingCoilAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalHVACComponent intermediate = modelObject->optionalCast<HVACComponent>(); | ||
if (intermediate) { | ||
setCoolingCoil(*intermediate); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setSupplementalHeatingCoilAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalHVACComponent intermediate = modelObject->optionalCast<HVACComponent>(); | ||
if (intermediate) { | ||
setSupplementalHeatingCoil(*intermediate); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAir_Impl::setSupplyAirFanOperatingModeScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) { | ||
if (modelObject) { | ||
OptionalSchedule intermediate = modelObject->optionalCast<Schedule>(); | ||
if (intermediate) { | ||
Schedule schedule(*intermediate); | ||
return setSupplyAirFanOperatingModeSchedule(schedule); | ||
} else { | ||
return false; | ||
} | ||
} else { | ||
resetSupplyAirFanOperatingModeSchedule(); | ||
} | ||
return true; | ||
} | ||
|
||
boost::optional<double> AirLoopHVACUnitaryHeatPumpAirToAir_Impl::autosizedSupplyAirFlowRateDuringCoolingOperation() const { | ||
return getAutosizedValue("Supply Air Flow Rate During Cooling Operation", "m3/s"); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,14 @@ | |
#include "Model_Impl.hpp" | ||
#include "AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.hpp" | ||
#include "AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl.hpp" | ||
#include "AirLoopHVAC.hpp" | ||
#include "Node.hpp" | ||
#include "Schedule.hpp" | ||
#include "Schedule_Impl.hpp" | ||
#include "ThermalZone.hpp" | ||
#include "ThermalZone_Impl.hpp" | ||
#include "ScheduleTypeLimits.hpp" | ||
#include "ScheduleTypeRegistry.hpp" | ||
#include "ThermalZone.hpp" | ||
#include "ThermalZone_Impl.hpp" | ||
|
||
#include "../utilities/core/Assert.hpp" | ||
#include "../utilities/data/DataEnums.hpp" | ||
|
@@ -121,8 +123,7 @@ namespace model { | |
} | ||
|
||
HVACComponent AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl::supplementalHeatingCoil() const { | ||
auto value = getObject<ModelObject>().getModelObjectTarget<HVACComponent>( | ||
OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeedFields::SupplementalHeatingCoil); | ||
auto value = optionalSupplementalHeatingCoil(); | ||
if (!value) { | ||
LOG_AND_THROW(briefDescription() << " does not have a Supplemental Heating Coil attached."); | ||
} | ||
|
@@ -583,6 +584,11 @@ namespace model { | |
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeedFields::CoolingCoil); | ||
} | ||
|
||
boost::optional<HVACComponent> AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl::optionalSupplementalHeatingCoil() const { | ||
return getObject<ModelObject>().getModelObjectTarget<HVACComponent>( | ||
OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeedFields::SupplementalHeatingCoil); | ||
} | ||
|
||
unsigned AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl::inletPort() const { | ||
return OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeedFields::AirInletNode; | ||
} | ||
|
@@ -591,8 +597,18 @@ namespace model { | |
return OS_AirLoopHVAC_UnitaryHeatPump_AirToAir_MultiSpeedFields::AirOutletNode; | ||
} | ||
|
||
bool AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl::addToNode(Node& node) { | ||
if (boost::optional<AirLoopHVAC> airLoop = node.airLoopHVAC()) { | ||
if (airLoop->supplyComponent(node.handle())) { | ||
return StraightComponent_Impl::addToNode(node); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
Comment on lines
+600
to
+608
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restrict addToNode. Note that ideally we should also allow demand side of a plant loop and connect the Heat Recovery Water Nodes there, but outside the scope and no one ever asked for it. |
||
|
||
ModelObject AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl::clone(Model model) const { | ||
auto modelObjectClone = ModelObject_Impl::clone(model).cast<AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed>(); | ||
auto modelObjectClone = StraightComponent_Impl::clone(model).cast<AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixup clone here |
||
|
||
if (boost::optional<HVACComponent> supplyFan = this->supplyAirFan()) { | ||
modelObjectClone.setSupplyAirFan(supplyFan->clone(model).cast<HVACComponent>()); | ||
|
@@ -613,17 +629,18 @@ namespace model { | |
std::vector<ModelObject> AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed_Impl::children() const { | ||
std::vector<ModelObject> result; | ||
|
||
if (boost::optional<HVACComponent> supplyFan = this->supplyAirFan()) { | ||
result.push_back(*supplyFan); | ||
// Avoid crashing when calling remove() in Ctor when failing to set one of the child component by calling the optional one | ||
if (boost::optional<HVACComponent> supplyFan = this->optionalSupplyAirFan()) { | ||
result.push_back(std::move(*supplyFan)); | ||
} | ||
if (boost::optional<HVACComponent> coolingCoil = this->coolingCoil()) { | ||
result.push_back(*coolingCoil); | ||
if (boost::optional<HVACComponent> coolingCoil = this->optionalCoolingCoil()) { | ||
result.push_back(std::move(*coolingCoil)); | ||
} | ||
if (boost::optional<HVACComponent> heatingCoil = this->heatingCoil()) { | ||
result.push_back(*heatingCoil); | ||
if (boost::optional<HVACComponent> heatingCoil = this->optionalHeatingCoil()) { | ||
result.push_back(std::move(*heatingCoil)); | ||
} | ||
if (boost::optional<HVACComponent> supplementalHeatingCoil = this->supplementalHeatingCoil()) { | ||
result.push_back(*supplementalHeatingCoil); | ||
if (boost::optional<HVACComponent> supplementalHeatingCoil = this->optionalSupplementalHeatingCoil()) { | ||
result.push_back(std::move(*supplementalHeatingCoil)); | ||
} | ||
|
||
return result; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specific for #5313 - Suppl HC should allow Coil:Heating:Water (Coil:Heating:Steam isn't wrapped in OS)