Revision history  [back]

OpenStudio Optional Objects

I stumbled upon a so-called OptionalCoilCoolingDXVariableRefrigerantFlow object when working on a measure. I found a reference in the SDK but there were no details.

The steps to reproduce are as follow:

model = OpenStudio::Model::Model.new
indoor_unit = OpenStudio::Model::ZoneHVACTerminalUnitVariableRefrigerantFlow.new(model)
coil = OpenStudio::Model::CoilCoolingDXVariableRefrigerantFlow.new(model)
indoor_unit.coolingCoil(coil)
new_unit = indoor_unit.clone
new_unit = new_unit.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get
new_unit.coolingCoil

The terminal will return

=> #<OpenStudio::Model::OptionalCoilCoolingDXVariableRefrigerantFlow:0x00000006292e48 @__swigtype__="_p_boost__optionalT_openstudio__model__CoilCoolingDXVariableRefrigerantFlow_t">

I understand that every piece of ZoneHVAC needs different coils and fans. However, why does it return an Optional version of the ModelObject, instead of just the object itself? It adds the extra step to call .get, but I am more interested in the reason behind this implementation.

OpenStudio Optional Objects

I stumbled upon a so-called OptionalCoilCoolingDXVariableRefrigerantFlow object when working on a measure. I found a reference in the SDK but there were no details.

The steps to reproduce are as follow:

model = OpenStudio::Model::Model.new
indoor_unit = OpenStudio::Model::ZoneHVACTerminalUnitVariableRefrigerantFlow.new(model)
coil = OpenStudio::Model::CoilCoolingDXVariableRefrigerantFlow.new(model)
indoor_unit.coolingCoil(coil)
new_unit = indoor_unit.clone
new_unit = new_unit.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get
new_unit.coolingCoil

The terminal will return

=> #<OpenStudio::Model::OptionalCoilCoolingDXVariableRefrigerantFlow:0x00000006292e48 @__swigtype__="_p_boost__optionalT_openstudio__model__CoilCoolingDXVariableRefrigerantFlow_t">

I understand that every piece of ZoneHVAC needs different coils and fans. However, why does it return an Optional version of the ModelObject, instead of just the object itself? It adds the extra step to call .get, but I am more interested in the reason behind this implementation.implementation, I did not find an