src/model/Node.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 "Node.hpp" | ||
| 7 | #include "Node_Impl.hpp" | ||
| 8 | #include "SetpointManager.hpp" | ||
| 9 | #include "SetpointManager_Impl.hpp" | ||
| 10 | #include "SetpointManagerMixedAir.hpp" | ||
| 11 | #include "SetpointManagerMixedAir_Impl.hpp" | ||
| 12 | #include "SetpointManagerOutdoorAirReset.hpp" | ||
| 13 | #include "SetpointManagerOutdoorAirReset_Impl.hpp" | ||
| 14 | #include "SetpointManagerSingleZoneReheat.hpp" | ||
| 15 | #include "SetpointManagerSingleZoneReheat_Impl.hpp" | ||
| 16 | #include "SetpointManagerScheduled.hpp" | ||
| 17 | #include "SetpointManagerScheduled_Impl.hpp" | ||
| 18 | #include "SetpointManagerFollowOutdoorAirTemperature.hpp" | ||
| 19 | #include "SetpointManagerFollowOutdoorAirTemperature_Impl.hpp" | ||
| 20 | #include "SetpointManagerWarmest.hpp" | ||
| 21 | #include "SetpointManagerWarmest_Impl.hpp" | ||
| 22 | #include "AirflowNetworkDistributionNode.hpp" | ||
| 23 | #include "AirflowNetworkDistributionNode_Impl.hpp" | ||
| 24 | #include "ThermalZone.hpp" | ||
| 25 | #include "PortList.hpp" | ||
| 26 | #include "PortList_Impl.hpp" | ||
| 27 | #include "Model.hpp" | ||
| 28 | |||
| 29 | #include "../utilities/core/Assert.hpp" | ||
| 30 | #include "../utilities/data/DataEnums.hpp" | ||
| 31 | |||
| 32 | #include <utilities/idd/OS_Node_FieldEnums.hxx> | ||
| 33 | #include <utilities/idd/IddEnums.hxx> | ||
| 34 | |||
| 35 | namespace openstudio { | ||
| 36 | |||
| 37 | namespace model { | ||
| 38 | |||
| 39 | namespace detail { | ||
| 40 | |||
| 41 | 15408 | Node_Impl::Node_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : StraightComponent_Impl(idfObject, model, keepHandle) { | |
| 42 |
4/6✓ Branch 1 taken 15408 times.
✓ Branch 4 taken 15408 times.
✓ Branch 7 taken 15408 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 15408 times.
✗ Branch 13 not taken.
|
15408 | OS_ASSERT(idfObject.iddObject().type() == Node::iddObjectType()); |
| 43 | 15408 | } | |
| 44 | |||
| 45 | 2003 | Node_Impl::Node_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 46 | 2003 | : StraightComponent_Impl(other, model, keepHandle) { | |
| 47 |
4/6✓ Branch 1 taken 2003 times.
✓ Branch 4 taken 2003 times.
✓ Branch 7 taken 2003 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2003 times.
✗ Branch 13 not taken.
|
2003 | OS_ASSERT(other.iddObject().type() == Node::iddObjectType()); |
| 48 | 2003 | } | |
| 49 | |||
| 50 | 4980 | Node_Impl::Node_Impl(const Node_Impl& other, Model_Impl* model, bool keepHandle) : StraightComponent_Impl(other, model, keepHandle) {} | |
| 51 | |||
| 52 | // virtual destructor | ||
| 53 | |||
| 54 | // Get all output variable names that could be associated with this object. | ||
| 55 | 14 | const std::vector<std::string>& Node_Impl::outputVariableNames() const { | |
| 56 | static const std::vector<std::string> result{ | ||
| 57 | // Common Variables | ||
| 58 | "System Node Temperature", "System Node Last Timestep Temperature", "System Node Mass Flow Rate", "System Node Humidity Ratio", | ||
| 59 | "System Node Setpoint Temperature", "System Node Setpoint High Temperature", "System Node Setpoint Low Temperature", | ||
| 60 | "System Node Setpoint Humidity Ratio", "System Node Setpoint Minimum Humidity Ratio", "System Node Setpoint Maximum Humidity Ratio", | ||
| 61 | "System Node Relative Humidity", "System Node Pressure", "System Node Standard Density Volume Flow Rate", "System Node Enthalpy", | ||
| 62 | "System Node Last Timestep Enthalpy", "System Node Wetbulb Temperature", "System Node Dewpoint Temperature", "System Node Quality", | ||
| 63 | "System Node Height", "System Node Specific Heat", | ||
| 64 | |||
| 65 | // The following node variable is also available for system nodes that are for “air”: | ||
| 66 | // TODO: implement check? If no, make result non static and remove the result.empty() check | ||
| 67 | "System Node Current Density Volume Flow Rate", "System Node Current Density" | ||
| 68 | |||
| 69 | // The following node variables are “advanced” and normally used for debugging unusual cases: | ||
| 70 | //"System Node Minimum Temperature", | ||
| 71 | //"System Node Maximum Temperature", | ||
| 72 | //"System Node Minimum Limit Mass Flow Rate", | ||
| 73 | //"System Node Maximum Limit Mass Flow Rate", | ||
| 74 | //"System Node Minimum Available Mass Flow Rate", | ||
| 75 | //"System Node Maximum Available Mass Flow Rate", | ||
| 76 | //"System Node Requested Mass Flow Rate", | ||
| 77 | //"System Node Setpoint Mass Flow Rate", | ||
| 78 | |||
| 79 | // The following node variable reports node carbon dioxide concentration when carbon dioxide is simulated (ref. ZoneAirContaminantBalance): | ||
| 80 | // "System Node CO2 Concentration", | ||
| 81 | |||
| 82 | // The following node variable reports node generic contaminant concentration when generic contaminant is simulated (ref. ZoneAirContaminantBalance): | ||
| 83 | // "System Node Generic Air Contaminant Concentration" | ||
| 84 | |||
| 85 |
6/11✓ Branch 0 taken 1 time.
✓ Branch 1 taken 13 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 time.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
38 | }; |
| 86 | |||
| 87 | 14 | return result; | |
| 88 | 4 | } | |
| 89 | |||
| 90 | 23172 | IddObjectType Node_Impl::iddObjectType() const { | |
| 91 | 23172 | return Node::iddObjectType(); | |
| 92 | } | ||
| 93 | |||
| 94 | 25940 | unsigned Node_Impl::inletPort() const { | |
| 95 | 25940 | return OS_NodeFields::InletPort; | |
| 96 | } | ||
| 97 | |||
| 98 | 128820 | unsigned Node_Impl::outletPort() const { | |
| 99 | 128820 | return OS_NodeFields::OutletPort; | |
| 100 | } | ||
| 101 | |||
| 102 | 105307 | std::vector<HVACComponent> Node_Impl::edges(const boost::optional<HVACComponent>& /*prev*/) { | |
| 103 | 105307 | std::vector<HVACComponent> edges; | |
| 104 |
3/3✓ Branch 1 taken 105307 times.
✓ Branch 3 taken 105224 times.
✓ Branch 4 taken 83 times.
|
210614 | if (boost::optional<ModelObject> edgeModelObject = this->outletModelObject()) { |
| 105 |
4/4✓ Branch 1 taken 105224 times.
✓ Branch 4 taken 105224 times.
✓ Branch 6 taken 6081 times.
✓ Branch 7 taken 99143 times.
|
210448 | if (boost::optional<PortList> portList = edgeModelObject->optionalCast<PortList>()) { |
| 106 |
4/5✓ Branch 1 taken 6081 times.
✓ Branch 4 taken 6081 times.
✓ Branch 7 taken 6081 times.
✓ Branch 11 taken 6081 times.
✗ Branch 12 not taken.
|
12162 | if (boost::optional<ThermalZone> thermalZone = portList->thermalZone()) { |
| 107 |
2/2✓ Branch 1 taken 6081 times.
✓ Branch 4 taken 6081 times.
|
6081 | edges.push_back(*thermalZone); |
| 108 | 6081 | } | |
| 109 |
4/4✓ Branch 1 taken 99143 times.
✓ Branch 4 taken 99143 times.
✓ Branch 6 taken 97782 times.
✓ Branch 7 taken 1361 times.
|
198286 | } else if (boost::optional<HVACComponent> edgeObject = edgeModelObject->optionalCast<HVACComponent>()) { |
| 110 |
2/2✓ Branch 1 taken 97782 times.
✓ Branch 4 taken 97782 times.
|
97782 | edges.push_back(*edgeObject); |
| 111 | 204367 | } | |
| 112 | 105307 | } | |
| 113 | 105307 | return edges; | |
| 114 | ✗ | } | |
| 115 | |||
| 116 | 619 | std::vector<IdfObject> Node_Impl::remove() { | |
| 117 |
2/2✓ Branch 1 taken 612 times.
✓ Branch 2 taken 7 times.
|
619 | if (isRemovable()) { |
| 118 | 612 | this->removeSetpointManagers(); | |
| 119 | 612 | return ModelObject_Impl::remove(); | |
| 120 | } else { | ||
| 121 | 7 | return {}; | |
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | 6819 | std::vector<ModelObject> Node_Impl::children() const { | |
| 126 |
2/2✓ Branch 1 taken 6819 times.
✓ Branch 4 taken 6819 times.
|
6819 | std::vector<ModelObject> result = castVector<ModelObject>(this->setpointManagers()); |
| 127 | std::vector<AirflowNetworkDistributionNode> myAFNItems = | ||
| 128 |
3/3✓ Branch 1 taken 6819 times.
✓ Branch 4 taken 6819 times.
✓ Branch 7 taken 6819 times.
|
6819 | getObject<ModelObject>().getModelObjectSources<AirflowNetworkDistributionNode>(AirflowNetworkDistributionNode::iddObjectType()); |
| 129 |
1/1✓ Branch 5 taken 6819 times.
|
6819 | result.insert(result.end(), myAFNItems.begin(), myAFNItems.end()); |
| 130 | 13638 | return result; | |
| 131 | 6819 | } | |
| 132 | |||
| 133 | ✗ | bool Node_Impl::addToNode(Node& /*node*/) { | |
| 134 | ✗ | return false; | |
| 135 | } | ||
| 136 | |||
| 137 | ✗ | ModelObject Node_Impl::clone(Model model) const { | |
| 138 | ✗ | return StraightComponent_Impl::clone(model); | |
| 139 | } | ||
| 140 | |||
| 141 | 620 | bool Node_Impl::isRemovable() const { | |
| 142 |
3/3✓ Branch 1 taken 620 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 613 times.
|
1240 | if (this->loop()) { |
| 143 | 7 | return false; | |
| 144 | } else { | ||
| 145 | 613 | return true; | |
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | 19811 | std::vector<SetpointManager> Node_Impl::setpointManagers() const { | |
| 150 | 19811 | std::vector<SetpointManager> _setpointManagers; | |
| 151 |
2/2✓ Branch 1 taken 19811 times.
✓ Branch 4 taken 19811 times.
|
19811 | std::vector<SetpointManager> _modelObjects = getObject<Node>().getModelObjectSources<SetpointManager>(); |
| 152 |
2/2✓ Branch 4 taken 3244 times.
✓ Branch 5 taken 19811 times.
|
23055 | for (auto it = _modelObjects.begin(); it != _modelObjects.end(); ++it) { |
| 153 |
2/3✓ Branch 2 taken 3244 times.
✓ Branch 4 taken 3244 times.
✗ Branch 5 not taken.
|
6488 | if (boost::optional<Node> setpointNode = it->setpointNode()) { |
| 154 |
6/6✓ Branch 1 taken 3244 times.
✓ Branch 4 taken 3244 times.
✓ Branch 7 taken 3244 times.
✓ Branch 10 taken 3244 times.
✓ Branch 12 taken 1667 times.
✓ Branch 13 taken 1577 times.
|
3244 | if (setpointNode->handle() == this->handle()) { |
| 155 |
1/1✓ Branch 2 taken 1667 times.
|
1667 | _setpointManagers.push_back(*it); |
| 156 | } | ||
| 157 | 3244 | } | |
| 158 | } | ||
| 159 | 39622 | return _setpointManagers; | |
| 160 | 19811 | } | |
| 161 | |||
| 162 | 613 | void Node_Impl::removeSetpointManagers() { | |
| 163 |
1/1✓ Branch 1 taken 613 times.
|
613 | std::vector<SetpointManager> _setpointManagers = this->setpointManagers(); |
| 164 |
2/2✓ Branch 3 taken 54 times.
✓ Branch 4 taken 613 times.
|
667 | for (auto it = _setpointManagers.begin(); it != _setpointManagers.end(); ++it) { |
| 165 |
1/1✓ Branch 2 taken 54 times.
|
54 | it->remove(); |
| 166 | } | ||
| 167 | 613 | } | |
| 168 | |||
| 169 | 1670 | bool Node_Impl::isConnected(const ModelObject& modelObject) { | |
| 170 |
3/3✓ Branch 1 taken 1670 times.
✓ Branch 3 taken 1642 times.
✓ Branch 4 taken 28 times.
|
3340 | if (auto mo = outletModelObject()) { |
| 171 |
6/6✓ Branch 1 taken 1642 times.
✓ Branch 4 taken 1642 times.
✓ Branch 7 taken 1642 times.
✓ Branch 10 taken 1642 times.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 1641 times.
|
1642 | if (modelObject.handle() == mo->handle()) { |
| 172 | 1 | return true; | |
| 173 | } | ||
| 174 | 1670 | } | |
| 175 |
3/3✓ Branch 1 taken 1669 times.
✓ Branch 3 taken 1447 times.
✓ Branch 4 taken 222 times.
|
3338 | if (auto mo = inletModelObject()) { |
| 176 |
6/6✓ Branch 1 taken 1447 times.
✓ Branch 4 taken 1447 times.
✓ Branch 7 taken 1447 times.
✓ Branch 10 taken 1447 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 1444 times.
|
1447 | if (modelObject.handle() == mo->handle()) { |
| 177 | 3 | return true; | |
| 178 | } | ||
| 179 | 1669 | } | |
| 180 | |||
| 181 | 1666 | return false; | |
| 182 | } | ||
| 183 | |||
| 184 | ✗ | std::vector<EMSActuatorNames> Node_Impl::emsActuatorNames() const { | |
| 185 | std::vector<EMSActuatorNames> actuators{{"System Node Setpoint", "Temperature Setpoint"}, | ||
| 186 | {"System Node Setpoint", "Temperature Minimum Setpoint"}, | ||
| 187 | {"System Node Setpoint", "Temperature Maximum Setpoint"}, | ||
| 188 | {"System Node Setpoint", "Humidity Ratio Setpoint"}, | ||
| 189 | {"System Node Setpoint", "Humidity Ratio Maximum Setpoint"}, | ||
| 190 | {"System Node Setpoint", "Humidity Ratio Minimum Setpoint"}, | ||
| 191 | {"System Node Setpoint", "Mass Flow Rate Setpoint"}, | ||
| 192 | {"System Node Setpoint", "Mass Flow Rate Maximum Available Setpoint"}, | ||
| 193 | {"System Node Setpoint", "Mass Flow Rate Minimum Available Setpoint"}, | ||
| 194 | {"Outdoor Air System Node", "Drybulb Temperature"}, | ||
| 195 | {"Outdoor Air System Node", "Wetbulb Temperature"}, | ||
| 196 | {"Outdoor Air System Node", "Wind Speed"}, | ||
| 197 | ✗ | {"Outdoor Air System Node", "Wind Direction"}}; | |
| 198 | ✗ | return actuators; | |
| 199 | ✗ | } | |
| 200 | |||
| 201 | ✗ | std::vector<std::string> Node_Impl::emsInternalVariableNames() const { | |
| 202 | ✗ | std::vector<std::string> types; | |
| 203 | ✗ | return types; | |
| 204 | } | ||
| 205 | |||
| 206 | 6 | AirflowNetworkDistributionNode Node_Impl::getAirflowNetworkDistributionNode() { | |
| 207 |
1/1✓ Branch 1 taken 6 times.
|
6 | boost::optional<AirflowNetworkDistributionNode> opt = airflowNetworkDistributionNode(); |
| 208 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (opt) { |
| 209 | ✗ | return opt.get(); | |
| 210 | } | ||
| 211 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | return AirflowNetworkDistributionNode(model(), handle()); |
| 212 | 6 | } | |
| 213 | |||
| 214 | 6 | boost::optional<AirflowNetworkDistributionNode> Node_Impl::airflowNetworkDistributionNode() const { | |
| 215 | std::vector<AirflowNetworkDistributionNode> myAFNItems = | ||
| 216 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | getObject<ModelObject>().getModelObjectSources<AirflowNetworkDistributionNode>(AirflowNetworkDistributionNode::iddObjectType()); |
| 217 | 6 | auto count = myAFNItems.size(); | |
| 218 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (count == 1) { |
| 219 | ✗ | return myAFNItems[0]; | |
| 220 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | } else if (count > 1) { |
| 221 | ✗ | LOG(Warn, briefDescription() << " has more than one AirflowNetwork DistributionNode attached, returning first."); | |
| 222 | ✗ | return myAFNItems[0]; | |
| 223 | } | ||
| 224 | 6 | return boost::none; | |
| 225 | 6 | } | |
| 226 | |||
| 227 | 2672 | ComponentType Node_Impl::componentType() const { | |
| 228 |
1/1✓ Branch 1 taken 2672 times.
|
2672 | return ComponentType::None; |
| 229 | } | ||
| 230 | |||
| 231 | 114 | std::vector<FuelType> Node_Impl::coolingFuelTypes() const { | |
| 232 | 114 | return {}; | |
| 233 | } | ||
| 234 | |||
| 235 | 179 | std::vector<FuelType> Node_Impl::heatingFuelTypes() const { | |
| 236 | 179 | return {}; | |
| 237 | } | ||
| 238 | |||
| 239 | 172 | std::vector<AppGFuelType> Node_Impl::appGHeatingFuelTypes() const { | |
| 240 | 172 | return {}; | |
| 241 | } | ||
| 242 | |||
| 243 | } // namespace detail | ||
| 244 | |||
| 245 | // create a new Node object in the model's workspace | ||
| 246 | 13391 | Node::Node(const Model& model) : StraightComponent(Node::iddObjectType(), model) { | |
| 247 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 13391 times.
✗ Branch 5 not taken.
|
13391 | OS_ASSERT(getImpl<detail::Node_Impl>()); |
| 248 | 13391 | } | |
| 249 | |||
| 250 |
1/1✓ Branch 3 taken 131854 times.
|
131854 | Node::Node(std::shared_ptr<detail::Node_Impl> impl) : StraightComponent(std::move(impl)) {} |
| 251 | |||
| 252 | 12379 | std::vector<SetpointManager> Node::setpointManagers() const { | |
| 253 |
1/1✓ Branch 3 taken 12379 times.
|
12379 | return getImpl<detail::Node_Impl>()->setpointManagers(); |
| 254 | } | ||
| 255 | |||
| 256 | 63257 | IddObjectType Node::iddObjectType() { | |
| 257 |
1/1✓ Branch 1 taken 63257 times.
|
63257 | IddObjectType result(IddObjectType::OS_Node); |
| 258 | 63257 | return result; | |
| 259 | } | ||
| 260 | |||
| 261 | 6 | AirflowNetworkDistributionNode Node::getAirflowNetworkDistributionNode() { | |
| 262 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::Node_Impl>()->getAirflowNetworkDistributionNode(); |
| 263 | } | ||
| 264 | |||
| 265 | ✗ | boost::optional<AirflowNetworkDistributionNode> Node::airflowNetworkDistributionNode() const { | |
| 266 | ✗ | return getImpl<detail::Node_Impl>()->airflowNetworkDistributionNode(); | |
| 267 | } | ||
| 268 | |||
| 269 | } // namespace model | ||
| 270 | } // namespace openstudio | ||
| 271 |