src/model/ZoneHVACComponent.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 "ZoneHVACComponent.hpp" | ||
| 7 | #include "ZoneHVACComponent_Impl.hpp" | ||
| 8 | #include "HVACComponent.hpp" | ||
| 9 | #include "HVACComponent_Impl.hpp" | ||
| 10 | #include "AirTerminalSingleDuctInletSideMixer.hpp" | ||
| 11 | #include "AirTerminalSingleDuctInletSideMixer_Impl.hpp" | ||
| 12 | #include "AirLoopHVACReturnPlenum.hpp" | ||
| 13 | #include "AirLoopHVACReturnPlenum_Impl.hpp" | ||
| 14 | #include "Model.hpp" | ||
| 15 | #include "Model_Impl.hpp" | ||
| 16 | #include "Node.hpp" | ||
| 17 | #include "Node_Impl.hpp" | ||
| 18 | #include "ThermalZone.hpp" | ||
| 19 | #include "ThermalZone_Impl.hpp" | ||
| 20 | #include "AirLoopHVAC.hpp" | ||
| 21 | #include "AirLoopHVAC_Impl.hpp" | ||
| 22 | #include "PortList.hpp" | ||
| 23 | #include "PortList_Impl.hpp" | ||
| 24 | #include "Connection.hpp" | ||
| 25 | #include "Connection_Impl.hpp" | ||
| 26 | |||
| 27 | #include "../utilities/core/Assert.hpp" | ||
| 28 | |||
| 29 | namespace openstudio { | ||
| 30 | namespace model { | ||
| 31 | |||
| 32 | namespace detail { | ||
| 33 | |||
| 34 | ✗ | ZoneHVACComponent_Impl::ZoneHVACComponent_Impl(IddObjectType type, Model_Impl* model) : HVACComponent_Impl(type, model) {} | |
| 35 | |||
| 36 | 431 | ZoneHVACComponent_Impl::ZoneHVACComponent_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 37 | 431 | : HVACComponent_Impl(idfObject, model, keepHandle) {} | |
| 38 | |||
| 39 | 50 | ZoneHVACComponent_Impl::ZoneHVACComponent_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 40 | 50 | : HVACComponent_Impl(other, model, keepHandle) {} | |
| 41 | |||
| 42 | 267 | ZoneHVACComponent_Impl::ZoneHVACComponent_Impl(const ZoneHVACComponent_Impl& other, Model_Impl* model, bool keepHandles) | |
| 43 | 267 | : HVACComponent_Impl(other, model, keepHandles) {} | |
| 44 | |||
| 45 | 29 | std::vector<ModelObject> ZoneHVACComponent_Impl::children() const { | |
| 46 | 29 | return {}; | |
| 47 | } | ||
| 48 | |||
| 49 | 30 | boost::optional<ParentObject> ZoneHVACComponent_Impl::parent() const { | |
| 50 | 30 | return {}; | |
| 51 | } | ||
| 52 | |||
| 53 | ✗ | const std::vector<std::string>& ZoneHVACComponent_Impl::outputVariableNames() const { | |
| 54 | ✗ | static const std::vector<std::string> result; | |
| 55 | ✗ | return result; | |
| 56 | } | ||
| 57 | |||
| 58 | 22 | ModelObject ZoneHVACComponent_Impl::clone(Model model) const { | |
| 59 |
3/3✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
|
22 | auto clone = ModelObject_Impl::clone(model).cast<ZoneHVACComponent>(); |
| 60 |
3/3✓ Branch 1 taken 22 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 8 times.
|
22 | if (clone.inletPort() != 0u) { |
| 61 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
28 | clone.setString(clone.inletPort(), ""); |
| 62 | } | ||
| 63 |
3/3✓ Branch 1 taken 22 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 8 times.
|
22 | if (clone.outletPort() != 0u) { |
| 64 |
3/3✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
|
28 | clone.setString(clone.outletPort(), ""); |
| 65 | } | ||
| 66 | |||
| 67 | 44 | return std::move(clone); | |
| 68 | 22 | } | |
| 69 | |||
| 70 | 144 | boost::optional<ThermalZone> ZoneHVACComponent_Impl::thermalZone() const { | |
| 71 |
1/1✓ Branch 1 taken 144 times.
|
144 | auto thisObject = this->getObject<ModelObject>(); |
| 72 |
4/4✓ Branch 1 taken 144 times.
✓ Branch 4 taken 144 times.
✓ Branch 12 taken 131 times.
✓ Branch 13 taken 97 times.
|
228 | for (const auto& thermalZone : model().getConcreteModelObjects<ThermalZone>()) { |
| 73 |
1/1✓ Branch 1 taken 131 times.
|
131 | std::vector<ModelObject> equipment = thermalZone.equipment(); |
| 74 | |||
| 75 |
3/3✓ Branch 4 taken 131 times.
✓ Branch 7 taken 47 times.
✓ Branch 8 taken 84 times.
|
131 | if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) { |
| 76 |
1/1✓ Branch 1 taken 47 times.
|
47 | return thermalZone; |
| 77 | } | ||
| 78 | 275 | } | |
| 79 | 97 | return boost::none; | |
| 80 | 144 | } | |
| 81 | |||
| 82 | //boost::optional<Connection> ZoneHVACComponent_Impl::returnPlenumOutletNodeConnection() const { | ||
| 83 | // auto m = model(); | ||
| 84 | // auto h = handle(); | ||
| 85 | |||
| 86 | // auto connections = subsetCastVector<Connection>(m.getConcreteModelObjects<Connection>()); | ||
| 87 | // auto plenums = subsetCastVector<AirLoopHVACReturnPlenum>(m.getConcreteModelObjects<AirLoopHVACReturnPlenum>()); | ||
| 88 | // for ( auto & c : connections ) { | ||
| 89 | // auto target = c.targetObject(); | ||
| 90 | // if ( target && ( target->handle() == h ) ) { | ||
| 91 | // auto source = c.sourceObject(); | ||
| 92 | // if ( source ) { | ||
| 93 | // auto sourceHandle = source->handle(); | ||
| 94 | // for ( auto & p : plenums ) { | ||
| 95 | // auto outlet = p.outletModelObject(); | ||
| 96 | // if ( outlet && ( outlet->handle() == sourceHandle ) ) { | ||
| 97 | // return c; | ||
| 98 | // } | ||
| 99 | // } | ||
| 100 | // } | ||
| 101 | // } | ||
| 102 | // } | ||
| 103 | |||
| 104 | // return boost::none; | ||
| 105 | //} | ||
| 106 | |||
| 107 | 75 | boost::optional<AirLoopHVACReturnPlenum> ZoneHVACComponent_Impl::returnPlenum() const { | |
| 108 | 75 | boost::optional<AirLoopHVACReturnPlenum> plenum; | |
| 109 | |||
| 110 |
1/1✓ Branch 1 taken 75 times.
|
75 | auto node = inletNode(); |
| 111 |
2/2✓ Branch 0 taken 50 times.
✓ Branch 1 taken 25 times.
|
75 | if (node) { |
| 112 |
2/2✓ Branch 1 taken 50 times.
✓ Branch 4 taken 50 times.
|
50 | auto mo = node->inletModelObject(); |
| 113 |
1/2✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
|
50 | if (mo) { |
| 114 |
2/2✓ Branch 1 taken 50 times.
✓ Branch 4 taken 50 times.
|
50 | auto pl = mo->optionalCast<PortList>(); |
| 115 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 2 times.
|
50 | if (pl) { |
| 116 |
2/2✓ Branch 1 taken 48 times.
✓ Branch 6 taken 48 times.
|
48 | auto mo2 = pl->getImpl<detail::PortList_Impl>()->hvacComponent(); |
| 117 |
1/1✓ Branch 1 taken 48 times.
|
48 | plenum = mo2.optionalCast<AirLoopHVACReturnPlenum>(); |
| 118 | 48 | } | |
| 119 | 50 | } | |
| 120 | 50 | } | |
| 121 | |||
| 122 | 150 | return plenum; | |
| 123 | 75 | } | |
| 124 | |||
| 125 | 1 | void ZoneHVACComponent_Impl::removeReturnPlenum() { | |
| 126 |
1/1✓ Branch 1 taken 1 time.
|
1 | Model m = model(); |
| 127 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto plenum = returnPlenum(); |
| 128 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto thisObject = getObject<ZoneHVACComponent>(); |
| 129 | |||
| 130 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (plenum) { |
| 131 | ✗ | auto zone = thermalZone(); | |
| 132 | ✗ | OS_ASSERT(zone); | |
| 133 | ✗ | auto h = zone->handle(); | |
| 134 | |||
| 135 | ✗ | auto inlet = inletNode(); | |
| 136 | ✗ | boost::optional<Node> plenumInletNode; | |
| 137 | |||
| 138 | ✗ | auto plenumInlets = plenum->inletModelObjects(); | |
| 139 | ✗ | for (auto& plenumInlet : plenumInlets) { | |
| 140 | ✗ | auto node = plenumInlet.optionalCast<Node>(); | |
| 141 | ✗ | if (node) { | |
| 142 | ✗ | auto pl = node->inletModelObject(); | |
| 143 | ✗ | if (pl && pl->optionalCast<PortList>()) { | |
| 144 | ✗ | auto mo = pl->cast<PortList>().getImpl<model::detail::PortList_Impl>()->hvacComponent(); | |
| 145 | ✗ | if (mo.handle() == h) { | |
| 146 | ✗ | plenumInletNode = node; | |
| 147 | ✗ | break; | |
| 148 | } | ||
| 149 | ✗ | } | |
| 150 | ✗ | } | |
| 151 | ✗ | } | |
| 152 | |||
| 153 | ✗ | if (inlet && plenumInletNode) { | |
| 154 | ✗ | inlet->remove(); | |
| 155 | ✗ | auto branch = plenum->branchIndexForInletModelObject(plenumInletNode.get()); | |
| 156 | ✗ | plenum->removePortForBranch(branch); | |
| 157 | ✗ | m.connect(plenumInletNode.get(), plenumInletNode->outletPort(), thisObject, thisObject.inletPort()); | |
| 158 | ✗ | plenumInlets = plenum->inletModelObjects(); | |
| 159 | ✗ | if (plenumInlets.empty()) { | |
| 160 | ✗ | plenum->remove(); | |
| 161 | } | ||
| 162 | } | ||
| 163 | ✗ | } | |
| 164 | 1 | } | |
| 165 | |||
| 166 | 1 | bool ZoneHVACComponent_Impl::setReturnPlenum(const ThermalZone& plenumZone) { | |
| 167 | |||
| 168 | 1 | bool result = true; | |
| 169 | |||
| 170 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
1 | if (!plenumZone.canBePlenum()) { |
| 171 | ✗ | result = false; | |
| 172 | } | ||
| 173 | |||
| 174 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto node = inletNode(); |
| 175 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!node) { |
| 176 | ✗ | result = false; | |
| 177 | } | ||
| 178 | |||
| 179 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto m = model(); |
| 180 | |||
| 181 | 1 | boost::optional<AirLoopHVACReturnPlenum> plenum; | |
| 182 | |||
| 183 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (result) { |
| 184 |
1/1✓ Branch 3 taken 1 time.
|
1 | plenum = plenumZone.getImpl<ThermalZone_Impl>()->airLoopHVACReturnPlenum(); |
| 185 | |||
| 186 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (!plenum) { |
| 187 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | plenum = AirLoopHVACReturnPlenum(m); |
| 188 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | plenum->setThermalZone(plenumZone); |
| 189 | } | ||
| 190 | |||
| 191 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(plenum); |
| 192 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(node); |
| 193 | } | ||
| 194 | |||
| 195 | // don't let a plenum connect to ZoneHVAC and AirLoopHVAC at the same time | ||
| 196 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
|
2 | if (plenum->airLoopHVAC()) { |
| 197 | ✗ | result = false; | |
| 198 | } | ||
| 199 | |||
| 200 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (result) { |
| 201 |
1/1✓ Branch 1 taken 1 time.
|
1 | removeReturnPlenum(); |
| 202 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | result = plenum->addToNode(node.get()); |
| 203 | } | ||
| 204 | |||
| 205 | 1 | return result; | |
| 206 | 1 | } | |
| 207 | |||
| 208 | 61 | bool ZoneHVACComponent_Impl::addToThermalZone(ThermalZone& thermalZone) { | |
| 209 |
1/1✓ Branch 1 taken 61 times.
|
61 | Model m = this->model(); |
| 210 | |||
| 211 |
3/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
|
61 | if (thermalZone.model() != m) { |
| 212 | ✗ | return false; | |
| 213 | } | ||
| 214 | |||
| 215 |
2/3✓ Branch 1 taken 61 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
|
61 | if (thermalZone.isPlenum()) { |
| 216 | ✗ | return false; | |
| 217 | } | ||
| 218 | |||
| 219 |
1/1✓ Branch 1 taken 61 times.
|
61 | removeFromThermalZone(); |
| 220 | |||
| 221 |
1/1✓ Branch 1 taken 61 times.
|
61 | thermalZone.setUseIdealAirLoads(false); |
| 222 | |||
| 223 | // Connect nodes if this is an air based zone hvac component | ||
| 224 |
5/8✓ Branch 1 taken 61 times.
✓ Branch 3 taken 61 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 61 times.
✓ Branch 8 taken 61 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 61 times.
✗ Branch 11 not taken.
|
61 | if (inletPort() != 0u && outletPort() != 0u) { |
| 225 | // Exhaust Node | ||
| 226 |
1/1✓ Branch 1 taken 61 times.
|
61 | Node exhaustNode(m); |
| 227 |
1/1✓ Branch 1 taken 61 times.
|
61 | PortList exhaustPortList = thermalZone.exhaustPortList(); |
| 228 |
1/1✓ Branch 1 taken 61 times.
|
61 | unsigned nextPort = exhaustPortList.nextPort(); |
| 229 |
4/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
|
61 | m.connect(exhaustPortList, nextPort, exhaustNode, exhaustNode.inletPort()); |
| 230 |
1/1✓ Branch 1 taken 61 times.
|
61 | auto mo = this->getObject<ModelObject>(); |
| 231 |
5/5✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✓ Branch 13 taken 61 times.
|
61 | m.connect(exhaustNode, exhaustNode.outletPort(), mo, this->inletPort()); |
| 232 | |||
| 233 | // Air Inlet Node | ||
| 234 |
1/1✓ Branch 1 taken 61 times.
|
61 | Node airInletNode(m); |
| 235 |
1/1✓ Branch 1 taken 61 times.
|
61 | PortList inletPortList = thermalZone.inletPortList(); |
| 236 |
1/1✓ Branch 1 taken 61 times.
|
61 | unsigned nextInletPort = inletPortList.nextPort(); |
| 237 |
4/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
|
61 | m.connect(airInletNode, airInletNode.outletPort(), inletPortList, nextInletPort); |
| 238 |
5/5✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✓ Branch 13 taken 61 times.
|
61 | m.connect(mo, this->outletPort(), airInletNode, airInletNode.inletPort()); |
| 239 | 61 | } | |
| 240 | |||
| 241 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | thermalZone.addEquipment(this->getObject<ZoneHVACComponent>()); |
| 242 | |||
| 243 | 61 | return true; | |
| 244 | 61 | } | |
| 245 | |||
| 246 | 97 | void ZoneHVACComponent_Impl::removeFromThermalZone() { | |
| 247 |
1/1✓ Branch 1 taken 97 times.
|
97 | boost::optional<ThermalZone> thermalZone = this->thermalZone(); |
| 248 |
1/1✓ Branch 1 taken 97 times.
|
97 | boost::optional<AirLoopHVAC> airLoopHVAC = this->airLoopHVAC(); |
| 249 |
1/1✓ Branch 1 taken 97 times.
|
97 | Model m = this->model(); |
| 250 |
1/1✓ Branch 1 taken 97 times.
|
97 | auto mo = getObject<ZoneHVACComponent>(); |
| 251 | |||
| 252 | 97 | bool inletSideMixer = false; | |
| 253 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 94 times.
|
97 | if (airLoopHVAC) { |
| 254 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 1 time.
|
6 | if (airLoopHVAC->demandComponent(mo.handle())) { |
| 255 | 2 | inletSideMixer = true; | |
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 259 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 95 times.
|
97 | if (inletSideMixer) { |
| 260 |
1/1✓ Branch 1 taken 2 times.
|
2 | removeFromInletSideMixer(); |
| 261 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 84 times.
|
95 | } else if (thermalZone) { |
| 262 | |||
| 263 |
2/3✓ Branch 1 taken 11 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
|
22 | if (auto t_inletNode = inletNode()) { |
| 264 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | t_inletNode->disconnect(); |
| 265 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | t_inletNode->remove(); |
| 266 | 11 | } | |
| 267 | |||
| 268 |
2/3✓ Branch 1 taken 11 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
|
22 | if (auto t_outletNode = outletNode()) { |
| 269 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | t_outletNode->disconnect(); |
| 270 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | t_outletNode->remove(); |
| 271 | 11 | } | |
| 272 | } | ||
| 273 | |||
| 274 |
1/1✓ Branch 1 taken 97 times.
|
97 | auto thisObject = this->getObject<ModelObject>(); |
| 275 |
3/3✓ Branch 1 taken 97 times.
✓ Branch 8 taken 89 times.
✓ Branch 9 taken 84 times.
|
173 | for (auto& thermalZone : m.getConcreteModelObjects<ThermalZone>()) { |
| 276 |
1/1✓ Branch 1 taken 89 times.
|
89 | std::vector<ModelObject> equipment = thermalZone.equipment(); |
| 277 | |||
| 278 |
3/3✓ Branch 4 taken 89 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 76 times.
|
89 | if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) { |
| 279 |
1/1✓ Branch 1 taken 13 times.
|
13 | thermalZone.removeEquipment(thisObject); |
| 280 | 13 | break; | |
| 281 | } | ||
| 282 | 186 | } | |
| 283 | 97 | } | |
| 284 | |||
| 285 | 839 | boost::optional<Node> ZoneHVACComponent_Impl::inletNode() const { | |
| 286 |
2/2✓ Branch 1 taken 839 times.
✓ Branch 4 taken 839 times.
|
839 | boost::optional<ModelObject> mo = connectedObject(inletPort()); |
| 287 | 839 | boost::optional<Node> result; | |
| 288 | |||
| 289 |
2/2✓ Branch 0 taken 497 times.
✓ Branch 1 taken 342 times.
|
839 | if (mo) { |
| 290 |
3/4✓ Branch 1 taken 497 times.
✓ Branch 4 taken 497 times.
✓ Branch 6 taken 497 times.
✗ Branch 7 not taken.
|
994 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 291 |
1/1✓ Branch 1 taken 497 times.
|
497 | result = node; |
| 292 | 497 | } | |
| 293 | } | ||
| 294 | |||
| 295 | 1678 | return result; | |
| 296 | 839 | } | |
| 297 | |||
| 298 | 796 | boost::optional<Node> ZoneHVACComponent_Impl::outletNode() const { | |
| 299 |
2/2✓ Branch 1 taken 796 times.
✓ Branch 4 taken 796 times.
|
796 | boost::optional<ModelObject> mo = connectedObject(outletPort()); |
| 300 | 796 | boost::optional<Node> result; | |
| 301 | |||
| 302 |
2/2✓ Branch 0 taken 777 times.
✓ Branch 1 taken 19 times.
|
796 | if (mo) { |
| 303 |
3/4✓ Branch 1 taken 777 times.
✓ Branch 4 taken 777 times.
✓ Branch 6 taken 777 times.
✗ Branch 7 not taken.
|
1554 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 304 |
1/1✓ Branch 1 taken 777 times.
|
777 | result = node; |
| 305 | 777 | } | |
| 306 | } | ||
| 307 | |||
| 308 | 1592 | return result; | |
| 309 | 796 | } | |
| 310 | |||
| 311 | 35 | std::vector<openstudio::IdfObject> ZoneHVACComponent_Impl::remove() { | |
| 312 | 35 | removeFromThermalZone(); | |
| 313 | |||
| 314 | 35 | bool result = removeFromAirLoopHVAC(); | |
| 315 |
7/12✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 34 times.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 35 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 34 times.
✓ Branch 14 taken 1 time.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
35 | OS_ASSERT(result || !airLoopHVAC()); |
| 316 | |||
| 317 | 35 | return HVACComponent_Impl::remove(); | |
| 318 | } | ||
| 319 | |||
| 320 | 99 | bool ZoneHVACComponent_Impl::addToNode(Node& node) { | |
| 321 | 99 | bool result = false; | |
| 322 | |||
| 323 | 99 | boost::optional<ThermalZone> thermalZone; | |
| 324 | 99 | boost::optional<AirTerminalSingleDuctInletSideMixer> terminal; | |
| 325 | |||
| 326 |
3/3✓ Branch 1 taken 99 times.
✓ Branch 3 taken 97 times.
✓ Branch 4 taken 2 times.
|
198 | if (boost::optional<ModelObject> outlet = node.outletModelObject()) { |
| 327 |
4/4✓ Branch 1 taken 97 times.
✓ Branch 4 taken 97 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 93 times.
|
194 | if (boost::optional<PortList> pl = outlet->optionalCast<PortList>()) { |
| 328 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | thermalZone = pl->thermalZone(); |
| 329 | 97 | } | |
| 330 | 99 | } | |
| 331 | |||
| 332 |
3/3✓ Branch 1 taken 99 times.
✓ Branch 3 taken 97 times.
✓ Branch 4 taken 2 times.
|
198 | if (boost::optional<ModelObject> inlet = node.inletModelObject()) { |
| 333 |
2/2✓ Branch 1 taken 97 times.
✓ Branch 4 taken 97 times.
|
97 | terminal = inlet->optionalCast<AirTerminalSingleDuctInletSideMixer>(); |
| 334 | 99 | } | |
| 335 | |||
| 336 |
5/6✓ Branch 0 taken 4 times.
✓ Branch 1 taken 95 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 95 times.
|
103 | if (thermalZone && terminal) { |
| 337 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
|
8 | if (this->thermalZone()) { |
| 338 | ✗ | removeFromThermalZone(); | |
| 339 | } | ||
| 340 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | thermalZone->setUseIdealAirLoads(false); |
| 341 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto thisObject = getObject<ZoneHVACComponent>(); |
| 342 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | thermalZone->addEquipment(thisObject); |
| 343 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | thermalZone->setCoolingPriority(thisObject, 1); |
| 344 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | thermalZone->setHeatingPriority(thisObject, 1); |
| 345 |
1/1✓ Branch 1 taken 4 times.
|
4 | Model t_model = model(); |
| 346 |
1/1✓ Branch 1 taken 4 times.
|
4 | ModelObject thisModelObject = getObject<model::ZoneHVACComponent>(); |
| 347 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | unsigned targetPort = node.connectedObjectPort(node.outletPort()).get(); |
| 348 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | ModelObject targetModelObject = node.connectedObject(node.outletPort()).get(); |
| 349 |
1/1✓ Branch 1 taken 4 times.
|
4 | Node newNode(t_model); |
| 350 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | t_model.connect(node, node.outletPort(), thisModelObject, inletPort()); |
| 351 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | t_model.connect(thisModelObject, outletPort(), newNode, newNode.inletPort()); |
| 352 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | t_model.connect(newNode, newNode.outletPort(), targetModelObject, targetPort); |
| 353 | |||
| 354 |
1/1✓ Branch 1 taken 4 times.
|
4 | Node exhaustNode(t_model); |
| 355 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | PortList exhaustPortList = thermalZone->exhaustPortList(); |
| 356 |
1/1✓ Branch 1 taken 4 times.
|
4 | unsigned nextPort = exhaustPortList.nextPort(); |
| 357 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | t_model.connect(exhaustPortList, nextPort, exhaustNode, exhaustNode.inletPort()); |
| 358 |
7/7✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
|
4 | t_model.connect(exhaustNode, exhaustNode.outletPort(), terminal.get(), terminal->secondaryAirInletPort()); |
| 359 | |||
| 360 | 4 | result = true; | |
| 361 | 4 | } | |
| 362 | |||
| 363 | 99 | return result; | |
| 364 | 99 | } | |
| 365 | |||
| 366 | 2 | void ZoneHVACComponent_Impl::removeFromInletSideMixer() { | |
| 367 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<AirLoopHVAC> t_airLoopHVAC = airLoopHVAC()) { |
| 368 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<Node> t_inletNode = inletNode(); |
| 369 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(t_inletNode); |
| 370 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<Node> t_outletNode = outletNode(); |
| 371 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(t_outletNode); |
| 372 | |||
| 373 |
5/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
4 | if (t_airLoopHVAC->demandComponent(t_inletNode->handle())) { |
| 374 |
5/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
|
2 | unsigned targetPort = t_outletNode->connectedObjectPort(t_outletNode->outletPort()).get(); |
| 375 |
6/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
|
2 | ModelObject targetModelObject = t_outletNode->connectedObject(t_outletNode->outletPort()).get(); |
| 376 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | t_outletNode->disconnect(); |
| 377 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | t_outletNode->remove(); |
| 378 | |||
| 379 |
1/1✓ Branch 1 taken 2 times.
|
2 | Model t_model = model(); |
| 380 |
6/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
|
2 | t_model.connect(t_inletNode.get(), t_inletNode->outletPort(), targetModelObject, targetPort); |
| 381 | |||
| 382 | std::vector<AirTerminalSingleDuctInletSideMixer> terminalMixers = subsetCastVector<AirTerminalSingleDuctInletSideMixer>( | ||
| 383 |
8/8✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
|
4 | t_airLoopHVAC->demandComponents(t_airLoopHVAC->demandInletNode(), t_inletNode.get())); |
| 384 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (!terminalMixers.empty()) { |
| 385 |
2/3✓ Branch 2 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | if (boost::optional<Node> secondaryNode = terminalMixers.front().secondaryAirInletNode()) { |
| 386 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | secondaryNode->disconnect(); |
| 387 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | secondaryNode->remove(); |
| 388 | 2 | } | |
| 389 | } | ||
| 390 | 2 | } | |
| 391 | 4 | } | |
| 392 | 2 | } | |
| 393 | |||
| 394 | 439 | boost::optional<AirLoopHVAC> ZoneHVACComponent_Impl::airLoopHVAC() const { | |
| 395 |
3/3✓ Branch 1 taken 439 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 300 times.
|
878 | if (boost::optional<Node> node = inletNode()) { |
| 396 |
2/2✓ Branch 1 taken 139 times.
✓ Branch 4 taken 139 times.
|
139 | return node->airLoopHVAC(); |
| 397 | 439 | } | |
| 398 | |||
| 399 | 300 | return boost::none; | |
| 400 | } | ||
| 401 | |||
| 402 | 488 | std::vector<HVACComponent> ZoneHVACComponent_Impl::edges(const boost::optional<HVACComponent>& /*prev*/) { | |
| 403 | 488 | std::vector<HVACComponent> edges; | |
| 404 |
3/3✓ Branch 1 taken 488 times.
✓ Branch 3 taken 486 times.
✓ Branch 4 taken 2 times.
|
976 | if (boost::optional<Node> t_node = this->outletNode()) { |
| 405 |
3/3✓ Branch 1 taken 486 times.
✓ Branch 4 taken 486 times.
✓ Branch 7 taken 486 times.
|
486 | edges.push_back(t_node->cast<HVACComponent>()); |
| 406 | 488 | } | |
| 407 | 488 | return edges; | |
| 408 | ✗ | } | |
| 409 | |||
| 410 | 113 | bool ZoneHVACComponent_Impl::removeFromAirLoopHVAC() { | |
| 411 | // Note JM 2018-09-22: | ||
| 412 | // This calls HVACComponent::airLoopHVACOutdoorAirSystem | ||
| 413 | // It returns an AirLoopHVACOutdoorAirSystem that this component is ON | ||
| 414 | // Not to be confused with this->airLoopHVAC()->airLoopHVACOutdoorAirSystem() which returns an | ||
| 415 | // eventual AirLoopHVACOutdoorAirSystem whether this component is on it or not! | ||
| 416 |
2/3✓ Branch 1 taken 113 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
|
226 | if (auto t_oaSystem = airLoopHVACOutdoorAirSystem()) { |
| 417 | ✗ | if (t_oaSystem->oaComponent(handle())) { | |
| 418 | ✗ | return HVACComponent_Impl::removeFromLoop(t_oaSystem->outboardOANode().get(), t_oaSystem.get(), inletPort(), outletPort()); | |
| 419 | ✗ | } else if (t_oaSystem->reliefComponent(handle())) { | |
| 420 | ✗ | return HVACComponent_Impl::removeFromLoop(t_oaSystem.get(), t_oaSystem->outboardReliefNode().get(), inletPort(), outletPort()); | |
| 421 | } | ||
| 422 |
3/3✓ Branch 1 taken 113 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 112 times.
|
226 | } else if (auto t_loop = loop()) { |
| 423 |
4/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
2 | if (t_loop->supplyComponent(handle())) { |
| 424 |
7/7✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
|
1 | return HVACComponent_Impl::removeFromLoop(t_loop->supplyInletNode(), t_loop->supplyOutletNode(), inletPort(), outletPort()); |
| 425 | } | ||
| 426 | /* | ||
| 427 | *else if( t_loop->demandComponent(handle()) ) { | ||
| 428 | * return HVACComponent_Impl::removeFromLoop(t_loop->demandInletNode(), | ||
| 429 | * t_loop->demandOutletNode(), | ||
| 430 | * inletPort(), | ||
| 431 | * outletPort()); | ||
| 432 | *} | ||
| 433 | */ | ||
| 434 | 226 | } | |
| 435 | 112 | return false; | |
| 436 | } | ||
| 437 | |||
| 438 | 8 | boost::optional<ModelObject> ZoneHVACComponent_Impl::airInletModelObject() const { | |
| 439 |
1/1✓ Branch 1 taken 8 times.
|
8 | auto node = inletNode(); |
| 440 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (node) { |
| 441 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
|
8 | return node->cast<ModelObject>(); |
| 442 | } | ||
| 443 | ✗ | return boost::none; | |
| 444 | 8 | } | |
| 445 | |||
| 446 | 35 | boost::optional<ModelObject> ZoneHVACComponent_Impl::airOutletModelObject() const { | |
| 447 |
1/1✓ Branch 1 taken 35 times.
|
35 | auto node = outletNode(); |
| 448 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | if (node) { |
| 449 |
3/3✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
|
35 | return node->cast<ModelObject>(); |
| 450 | } | ||
| 451 | ✗ | return boost::none; | |
| 452 | 35 | } | |
| 453 | |||
| 454 | } // namespace detail | ||
| 455 | |||
| 456 |
1/1✓ Branch 3 taken 1262 times.
|
1262 | ZoneHVACComponent::ZoneHVACComponent(std::shared_ptr<detail::ZoneHVACComponent_Impl> p) : HVACComponent(std::move(p)) {} |
| 457 | |||
| 458 | 381 | ZoneHVACComponent::ZoneHVACComponent(IddObjectType type, const Model& model) : HVACComponent(type, model) { | |
| 459 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 381 times.
✗ Branch 5 not taken.
|
381 | OS_ASSERT(getImpl<detail::ZoneHVACComponent_Impl>()); |
| 460 | 381 | } | |
| 461 | |||
| 462 | 50 | unsigned ZoneHVACComponent::inletPort() const { | |
| 463 |
1/1✓ Branch 3 taken 50 times.
|
50 | return getImpl<detail::ZoneHVACComponent_Impl>()->inletPort(); |
| 464 | } | ||
| 465 | |||
| 466 | 49 | unsigned ZoneHVACComponent::outletPort() const { | |
| 467 |
1/1✓ Branch 3 taken 49 times.
|
49 | return getImpl<detail::ZoneHVACComponent_Impl>()->outletPort(); |
| 468 | } | ||
| 469 | |||
| 470 | 54 | boost::optional<ThermalZone> ZoneHVACComponent::thermalZone() const { | |
| 471 |
1/1✓ Branch 3 taken 54 times.
|
54 | return getImpl<detail::ZoneHVACComponent_Impl>()->thermalZone(); |
| 472 | } | ||
| 473 | |||
| 474 | 71 | bool ZoneHVACComponent::addToThermalZone(ThermalZone& thermalZone) { | |
| 475 |
1/1✓ Branch 3 taken 71 times.
|
71 | return getImpl<detail::ZoneHVACComponent_Impl>()->addToThermalZone(thermalZone); |
| 476 | } | ||
| 477 | |||
| 478 | 11 | void ZoneHVACComponent::removeFromThermalZone() { | |
| 479 |
1/1✓ Branch 3 taken 11 times.
|
11 | return getImpl<detail::ZoneHVACComponent_Impl>()->removeFromThermalZone(); |
| 480 | } | ||
| 481 | |||
| 482 | 301 | boost::optional<Node> ZoneHVACComponent::inletNode() const { | |
| 483 |
1/1✓ Branch 3 taken 301 times.
|
301 | return getImpl<detail::ZoneHVACComponent_Impl>()->inletNode(); |
| 484 | } | ||
| 485 | |||
| 486 | 258 | boost::optional<Node> ZoneHVACComponent::outletNode() const { | |
| 487 |
1/1✓ Branch 3 taken 258 times.
|
258 | return getImpl<detail::ZoneHVACComponent_Impl>()->outletNode(); |
| 488 | } | ||
| 489 | |||
| 490 | 94 | bool ZoneHVACComponent::addToNode(Node& node) { | |
| 491 |
1/1✓ Branch 3 taken 94 times.
|
94 | return getImpl<detail::ZoneHVACComponent_Impl>()->addToNode(node); |
| 492 | } | ||
| 493 | |||
| 494 | 146 | boost::optional<AirLoopHVAC> ZoneHVACComponent::airLoopHVAC() const { | |
| 495 |
1/1✓ Branch 3 taken 146 times.
|
146 | return getImpl<detail::ZoneHVACComponent_Impl>()->airLoopHVAC(); |
| 496 | } | ||
| 497 | |||
| 498 | ✗ | void ZoneHVACComponent::removeReturnPlenum() { | |
| 499 | ✗ | return getImpl<detail::ZoneHVACComponent_Impl>()->removeReturnPlenum(); | |
| 500 | } | ||
| 501 | |||
| 502 | ✗ | bool ZoneHVACComponent::removeFromAirLoopHVAC() { | |
| 503 | ✗ | return getImpl<detail::ZoneHVACComponent_Impl>()->removeFromAirLoopHVAC(); | |
| 504 | } | ||
| 505 | |||
| 506 | 8 | boost::optional<ModelObject> ZoneHVACComponent::airInletModelObject() const { | |
| 507 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::ZoneHVACComponent_Impl>()->airInletModelObject(); |
| 508 | } | ||
| 509 | |||
| 510 | 35 | boost::optional<ModelObject> ZoneHVACComponent::airOutletModelObject() const { | |
| 511 |
1/1✓ Branch 3 taken 35 times.
|
35 | return getImpl<detail::ZoneHVACComponent_Impl>()->airOutletModelObject(); |
| 512 | } | ||
| 513 | |||
| 514 | 74 | boost::optional<AirLoopHVACReturnPlenum> ZoneHVACComponent::returnPlenum() const { | |
| 515 |
1/1✓ Branch 3 taken 74 times.
|
74 | return getImpl<detail::ZoneHVACComponent_Impl>()->returnPlenum(); |
| 516 | } | ||
| 517 | |||
| 518 | 1 | bool ZoneHVACComponent::setReturnPlenum(const ThermalZone& plenumZone) { | |
| 519 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::ZoneHVACComponent_Impl>()->setReturnPlenum(plenumZone); |
| 520 | } | ||
| 521 | |||
| 522 | } // namespace model | ||
| 523 | |||
| 524 | } // namespace openstudio | ||
| 525 |