src/model/CentralHeatPumpSystemModule.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "CentralHeatPumpSystemModule.hpp" | ||
| 7 | #include "CentralHeatPumpSystemModule_Impl.hpp" | ||
| 8 | |||
| 9 | #include "ChillerHeaterPerformanceElectricEIR.hpp" | ||
| 10 | #include "ChillerHeaterPerformanceElectricEIR_Impl.hpp" | ||
| 11 | #include "CentralHeatPumpSystem.hpp" | ||
| 12 | #include "CentralHeatPumpSystem_Impl.hpp" | ||
| 13 | |||
| 14 | #include "Schedule.hpp" | ||
| 15 | #include "Schedule_Impl.hpp" | ||
| 16 | #include "Model.hpp" | ||
| 17 | #include "ScheduleTypeLimits.hpp" | ||
| 18 | #include "ScheduleTypeRegistry.hpp" | ||
| 19 | |||
| 20 | #include <utilities/idd/IddEnums.hxx> | ||
| 21 | #include <utilities/idd/OS_CentralHeatPumpSystem_Module_FieldEnums.hxx> | ||
| 22 | |||
| 23 | #include "../utilities/core/Assert.hpp" | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | namespace model { | ||
| 27 | |||
| 28 | namespace detail { | ||
| 29 | |||
| 30 | 15 | CentralHeatPumpSystemModule_Impl::CentralHeatPumpSystemModule_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 31 | 15 | : ParentObject_Impl(idfObject, model, keepHandle) { | |
| 32 |
4/6✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 15 times.
✗ Branch 13 not taken.
|
15 | OS_ASSERT(idfObject.iddObject().type() == CentralHeatPumpSystemModule::iddObjectType()); |
| 33 | 15 | } | |
| 34 | |||
| 35 | 1 | CentralHeatPumpSystemModule_Impl::CentralHeatPumpSystemModule_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 36 | 1 | bool keepHandle) | |
| 37 | 1 | : ParentObject_Impl(other, model, keepHandle) { | |
| 38 |
4/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
|
1 | OS_ASSERT(other.iddObject().type() == CentralHeatPumpSystemModule::iddObjectType()); |
| 39 | 1 | } | |
| 40 | |||
| 41 | 7 | CentralHeatPumpSystemModule_Impl::CentralHeatPumpSystemModule_Impl(const CentralHeatPumpSystemModule_Impl& other, Model_Impl* model, | |
| 42 | 7 | bool keepHandle) | |
| 43 | 7 | : ParentObject_Impl(other, model, keepHandle) {} | |
| 44 | |||
| 45 | ✗ | const std::vector<std::string>& CentralHeatPumpSystemModule_Impl::outputVariableNames() const { | |
| 46 | ✗ | static const std::vector<std::string> result; | |
| 47 | ✗ | return result; | |
| 48 | } | ||
| 49 | |||
| 50 | ✗ | IddObjectType CentralHeatPumpSystemModule_Impl::iddObjectType() const { | |
| 51 | ✗ | return CentralHeatPumpSystemModule::iddObjectType(); | |
| 52 | } | ||
| 53 | |||
| 54 | ✗ | std::vector<ScheduleTypeKey> CentralHeatPumpSystemModule_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 55 | // TODO: Check schedule display names. | ||
| 56 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 57 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 58 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 59 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 60 | ✗ | if (std::find(b, e, OS_CentralHeatPumpSystem_ModuleFields::ChillerHeaterModulesControlScheduleName) != e) { | |
| 61 | ✗ | result.push_back(ScheduleTypeKey("CentralHeatPumpSystemModule", "Chiller Heater Modules Control")); | |
| 62 | } | ||
| 63 | ✗ | return result; | |
| 64 | ✗ | } | |
| 65 | |||
| 66 | /** This method clones the CentralHeatPumpSystemModyle but sets the chillerHeaterModulesPerformanceComponent to the same as the original | ||
| 67 | * By using the "children" method and listing the chillerHeaterModulesPerformanceComponent there ModelObject_Impl::clone will automatically do | ||
| 68 | * the right thing -> NO IT DOESN'T */ | ||
| 69 | 2 | ModelObject CentralHeatPumpSystemModule_Impl::clone(Model model) const { | |
| 70 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | auto newCentralHPMod = ModelObject_Impl::clone(model).cast<CentralHeatPumpSystemModule>(); |
| 71 | |||
| 72 | // If not using "children", then expliclity do it: | ||
| 73 | 2 | bool ok = true; | |
| 74 |
1/1✓ Branch 1 taken 2 times.
|
2 | Model t_model = this->model(); |
| 75 | |||
| 76 | // If it's the same model | ||
| 77 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | if (t_model == model) { |
| 78 | // We don't want to clone the perf object, set it to the same ChillHeaterPerformanceElectricEIR | ||
| 79 |
1/1✓ Branch 1 taken 1 time.
|
1 | ChillerHeaterPerformanceElectricEIR chillerHeaterPerf = this->chillerHeaterModulesPerformanceComponent(); |
| 80 |
1/1✓ Branch 1 taken 1 time.
|
1 | ok = newCentralHPMod.setChillerHeaterModulesPerformanceComponent(chillerHeaterPerf); |
| 81 | |||
| 82 | // If it's a different model | ||
| 83 | 1 | } else { | |
| 84 | // We clone the chillerHeaterPerformance into the target model | ||
| 85 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | auto chillerHeaterPerf = this->chillerHeaterModulesPerformanceComponent().clone(model).cast<ChillerHeaterPerformanceElectricEIR>(); |
| 86 |
1/1✓ Branch 1 taken 1 time.
|
1 | ok = newCentralHPMod.setChillerHeaterModulesPerformanceComponent(chillerHeaterPerf); |
| 87 | 1 | } | |
| 88 | |||
| 89 | // This better have worked | ||
| 90 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
|
2 | OS_ASSERT(ok); |
| 91 | |||
| 92 | 4 | return std::move(newCentralHPMod); | |
| 93 | 2 | } | |
| 94 | |||
| 95 | // Returns allowable child types: ChillerHeaterPerformanceElectricEIR | ||
| 96 | ✗ | std::vector<IddObjectType> CentralHeatPumpSystemModule_Impl::allowableChildTypes() const { | |
| 97 | ✗ | std::vector<IddObjectType> result; | |
| 98 | // result.push_back(IddObjectType::OS_ChillerHeaterPerformance_Electric_EIR); | ||
| 99 | ✗ | return result; | |
| 100 | } | ||
| 101 | |||
| 102 | // Returns the single child object: the ChillerHeaterPerformanceElectricEIR | ||
| 103 | ✗ | std::vector<ModelObject> CentralHeatPumpSystemModule_Impl::children() const { | |
| 104 | ✗ | std::vector<ModelObject> result; | |
| 105 | |||
| 106 | // ChillerHeaterPerformanceElectricEIR ch_heater = chillerHeaterModulesPerformanceComponent(); | ||
| 107 | // result.push_back(ch_heater); | ||
| 108 | |||
| 109 | // The chillerHeaterModulesControlSchedule, being a schedule, is already a resource so no need here | ||
| 110 | |||
| 111 | ✗ | return result; | |
| 112 | } | ||
| 113 | |||
| 114 | 26 | ChillerHeaterPerformanceElectricEIR CentralHeatPumpSystemModule_Impl::chillerHeaterModulesPerformanceComponent() const { | |
| 115 |
1/1✓ Branch 1 taken 26 times.
|
26 | boost::optional<ChillerHeaterPerformanceElectricEIR> value = optionalChillerHeaterModulesPerformanceComponent(); |
| 116 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
|
26 | if (!value) { |
| 117 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Chiller Heater Modules Performance Component attached."); | |
| 118 | } | ||
| 119 |
2/2✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
|
52 | return value.get(); |
| 120 | 26 | } | |
| 121 | |||
| 122 | 5 | Schedule CentralHeatPumpSystemModule_Impl::chillerHeaterModulesControlSchedule() const { | |
| 123 |
1/1✓ Branch 1 taken 5 times.
|
5 | boost::optional<Schedule> value = optionalChillerHeaterModulesControlSchedule(); |
| 124 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (!value) { |
| 125 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Chiller Heater Modules Control Schedule attached."); | |
| 126 | } | ||
| 127 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
10 | return value.get(); |
| 128 | 5 | } | |
| 129 | |||
| 130 | 7 | int CentralHeatPumpSystemModule_Impl::numberofChillerHeaterModules() const { | |
| 131 |
1/1✓ Branch 1 taken 7 times.
|
7 | boost::optional<int> value = getInt(OS_CentralHeatPumpSystem_ModuleFields::NumberofChillerHeaterModules, true); |
| 132 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
|
7 | OS_ASSERT(value); |
| 133 |
1/1✓ Branch 1 taken 7 times.
|
14 | return value.get(); |
| 134 | } | ||
| 135 | |||
| 136 | 19 | bool CentralHeatPumpSystemModule_Impl::setChillerHeaterModulesPerformanceComponent( | |
| 137 | const ChillerHeaterPerformanceElectricEIR& chillerHeaterPerformanceElectricEIR) { | ||
| 138 | bool result = | ||
| 139 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | setPointer(OS_CentralHeatPumpSystem_ModuleFields::ChillerHeaterModulesPerformanceComponentName, chillerHeaterPerformanceElectricEIR.handle()); |
| 140 | 19 | return result; | |
| 141 | } | ||
| 142 | |||
| 143 | 15 | bool CentralHeatPumpSystemModule_Impl::setChillerHeaterModulesControlSchedule(Schedule& schedule) { | |
| 144 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
60 | bool result = setSchedule(OS_CentralHeatPumpSystem_ModuleFields::ChillerHeaterModulesControlScheduleName, "CentralHeatPumpSystemModule", |
| 145 | "Chiller Heater Modules Control", schedule); | ||
| 146 | 15 | return result; | |
| 147 | } | ||
| 148 | |||
| 149 | 16 | bool CentralHeatPumpSystemModule_Impl::setNumberofChillerHeaterModules(int numberofChillerHeaterModules) { | |
| 150 | 16 | bool result = setInt(OS_CentralHeatPumpSystem_ModuleFields::NumberofChillerHeaterModules, numberofChillerHeaterModules); | |
| 151 | 16 | return result; | |
| 152 | } | ||
| 153 | |||
| 154 | 26 | boost::optional<ChillerHeaterPerformanceElectricEIR> CentralHeatPumpSystemModule_Impl::optionalChillerHeaterModulesPerformanceComponent() const { | |
| 155 |
1/1✓ Branch 1 taken 26 times.
|
52 | return getObject<ModelObject>().getModelObjectTarget<ChillerHeaterPerformanceElectricEIR>( |
| 156 |
1/1✓ Branch 1 taken 26 times.
|
52 | OS_CentralHeatPumpSystem_ModuleFields::ChillerHeaterModulesPerformanceComponentName); |
| 157 | } | ||
| 158 | |||
| 159 | 5 | boost::optional<Schedule> CentralHeatPumpSystemModule_Impl::optionalChillerHeaterModulesControlSchedule() const { | |
| 160 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_CentralHeatPumpSystem_ModuleFields::ChillerHeaterModulesControlScheduleName); |
| 161 | } | ||
| 162 | |||
| 163 | // Convenience function to return parent CentralHeatPumpSystem | ||
| 164 | 5 | boost::optional<CentralHeatPumpSystem> CentralHeatPumpSystemModule_Impl::centralHeatPumpSystem() const { | |
| 165 | |||
| 166 | // loop on all CentralHeatPumpSystems in the model | ||
| 167 |
4/4✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 12 taken 5 times.
✓ Branch 13 taken 1 time.
|
6 | for (const CentralHeatPumpSystem& central_hp : this->model().getConcreteModelObjects<CentralHeatPumpSystem>()) { |
| 168 | // Loop on each CentralHeatPumpSystemModules | ||
| 169 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 1 time.
|
5 | for (const CentralHeatPumpSystemModule& central_hp_module : central_hp.modules()) { |
| 170 |
4/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
|
4 | if (central_hp_module.handle() == this->handle()) { |
| 171 |
1/1✓ Branch 1 taken 4 times.
|
4 | return central_hp; |
| 172 | } | ||
| 173 | 5 | } | |
| 174 | 5 | } | |
| 175 | 1 | return boost::none; | |
| 176 | } | ||
| 177 | |||
| 178 | } // namespace detail | ||
| 179 | |||
| 180 | 14 | CentralHeatPumpSystemModule::CentralHeatPumpSystemModule(const Model& model) : ParentObject(CentralHeatPumpSystemModule::iddObjectType(), model) { | |
| 181 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 5 not taken.
|
14 | OS_ASSERT(getImpl<detail::CentralHeatPumpSystemModule_Impl>()); |
| 182 | |||
| 183 |
1/1✓ Branch 1 taken 14 times.
|
14 | auto alwaysOn = model.alwaysOnDiscreteSchedule(); |
| 184 |
1/1✓ Branch 1 taken 14 times.
|
14 | auto const module = ChillerHeaterPerformanceElectricEIR(model); |
| 185 | |||
| 186 | 14 | bool ok = true; | |
| 187 |
1/1✓ Branch 1 taken 14 times.
|
14 | ok = setChillerHeaterModulesPerformanceComponent(module); |
| 188 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
|
14 | OS_ASSERT(ok); |
| 189 |
1/1✓ Branch 1 taken 14 times.
|
14 | ok = setChillerHeaterModulesControlSchedule(alwaysOn); |
| 190 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
|
14 | OS_ASSERT(ok); |
| 191 |
1/1✓ Branch 1 taken 14 times.
|
14 | ok = setNumberofChillerHeaterModules(1); |
| 192 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
|
14 | OS_ASSERT(ok); |
| 193 | 14 | } | |
| 194 | |||
| 195 | 7642 | IddObjectType CentralHeatPumpSystemModule::iddObjectType() { | |
| 196 |
1/1✓ Branch 1 taken 7642 times.
|
7642 | return {IddObjectType::OS_CentralHeatPumpSystem_Module}; |
| 197 | } | ||
| 198 | |||
| 199 | 24 | ChillerHeaterPerformanceElectricEIR CentralHeatPumpSystemModule::chillerHeaterModulesPerformanceComponent() const { | |
| 200 |
1/1✓ Branch 3 taken 24 times.
|
24 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->chillerHeaterModulesPerformanceComponent(); |
| 201 | } | ||
| 202 | |||
| 203 | 5 | Schedule CentralHeatPumpSystemModule::chillerHeaterModulesControlSchedule() const { | |
| 204 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->chillerHeaterModulesControlSchedule(); |
| 205 | } | ||
| 206 | |||
| 207 | 7 | int CentralHeatPumpSystemModule::numberofChillerHeaterModules() const { | |
| 208 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->numberofChillerHeaterModules(); |
| 209 | } | ||
| 210 | |||
| 211 | 19 | bool CentralHeatPumpSystemModule::setChillerHeaterModulesPerformanceComponent( | |
| 212 | const ChillerHeaterPerformanceElectricEIR& chillerHeaterPerformanceElectricEIR) { | ||
| 213 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->setChillerHeaterModulesPerformanceComponent(chillerHeaterPerformanceElectricEIR); |
| 214 | } | ||
| 215 | |||
| 216 | 15 | bool CentralHeatPumpSystemModule::setChillerHeaterModulesControlSchedule(Schedule& schedule) { | |
| 217 |
1/1✓ Branch 3 taken 15 times.
|
15 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->setChillerHeaterModulesControlSchedule(schedule); |
| 218 | } | ||
| 219 | |||
| 220 | 16 | bool CentralHeatPumpSystemModule::setNumberofChillerHeaterModules(int numberofChillerHeaterModules) { | |
| 221 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->setNumberofChillerHeaterModules(numberofChillerHeaterModules); |
| 222 | } | ||
| 223 | |||
| 224 | 5 | boost::optional<CentralHeatPumpSystem> CentralHeatPumpSystemModule::centralHeatPumpSystem() const { | |
| 225 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::CentralHeatPumpSystemModule_Impl>()->centralHeatPumpSystem(); |
| 226 | } | ||
| 227 | |||
| 228 | /// @cond | ||
| 229 | 46 | CentralHeatPumpSystemModule::CentralHeatPumpSystemModule(std::shared_ptr<detail::CentralHeatPumpSystemModule_Impl> impl) | |
| 230 |
1/1✓ Branch 3 taken 46 times.
|
46 | : ParentObject(std::move(impl)) {} |
| 231 | /// @endcond | ||
| 232 | |||
| 233 | } // namespace model | ||
| 234 | } // namespace openstudio | ||
| 235 |