In OpenStudio HVACComponent objects are connected to each other through ports. The port is an identifier or address assigned to the points where HVACComponent instances can be connected together. Currently OpenStudio defines ports as simply unsigned integers, but that could change to something more sophisticated in the future.
A connection is made between two HVACComponent instances using the Model::connect method. The method takes four arguments, the source object, source port, target object, and target port. To connect a fan's outlet port to a water coil's air inlet port you would call Model::connect
like this:
model.connect(fan,fan.outletPort(),waterCoil,waterCoil.airInletPort())
Behind the scenes the connect method is generating a new Connection object that is saved to the osm file. The connection object stores these four important pieces of information, the source object, source port, target object, and target port. The port again being the location on those source and target objects where the connection is made. A splitter for example could have many outlet ports so you need an identifier (Port) to indicate which one you are connecting.
But the example is a little misleading. You will never find a fan connected directly to a coil because for the sake of EnergyPlus there is always a Node between the fan and coil. The above example is more correct like this:
model.connect(fan,fan.outletPort(),node,node.inletPort())
model.connect(node,node.outletPort,coil,coil.airInletPort())
This is a little confusing coming from an EnergyPlus view of the world, but in OpenStudio nodes are just another type of HVACComponent that are connected into the HVAC system network. Nodes are not themselves a means of connecting things together, but they need to be there because they are an important point of information and control. For example you need to see the nodes in OpenStudio to apply setpoint managers and request many important report variables. Connections in OpenStudio serve a similar purpose as Node in EnergyPlus but Connection is more general and we will likely use it to connect other HVAC networks together in the future beyond just the fluid flow topology like we do now. The most likely future application is the control domain, where you might want to be able to arbitrarily connect control signals from one component to another in a similar way as Simulink or Modelica style interface.
Everything I have just explained is a layer below where we normally want to be working in OpenStudio. We don't want to worry about ports and making connections directly. For one it is tedious and for two EnergyPlus imposes many restrictions on how HVAC networks are assembled. To account for this HVACComponent has the addToNode method which is the primary way of connecting things together. Given a particular HVACComponent and Node, addToNode
will figure out given the context of the node, if the component is allowed, and if it is make the necessary connections for you. In many cases addToNode
will insert new ... (more)