Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

boost::optional argument for WSHP in ruby

Hi, I am trying to set the value of outdoor air flow rate in my ZoneHVAC:WatertoAirHeatPump to zero, through a measure. For this object, the setOutdoorAirFlowRateDuringCoolingOperation() accepts a boost::optional argument, as per the OS Class Runner reference. I am looking for ways to initialise a boost::optional argument in ruby, and I think I maybe getting confused between an OptionalDouble and a boost::optional

https://unmethours.com/question/8806/openstudio-python-bindings-set-optionals/ addresses this question, and one of the answers says I need to use the following syntax:

                             value = OpenStudio.OptionalDouble.new(10000.0)
                             coil.setRatedHighSpeedTotalCoolingCapacity(value)

This doesn't seem to be working though, and Ruby says this method is not recognised. Is there something I should add before/after these lines to have 'value' be initialised as a boost::optional type? I tried initialising the object as an Optional double with a default value, but this still gives a run time error. My code block is as such: In the arguments section: def arguments(model) args = OpenStudio::Ruleset::OSArgumentVector.new zero = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('zero',false) zero.setDefaultValue(0.00) args << zero

In the runner: zone.equipment.each do |zone_equip| wshp = zone_equip.to_ZoneHVACWaterToAirHeatPump if wshp.is_initialized wshp = wshp.get if zero.is_initialized wshp.setOutdoorAirFlowRateDuringCoolingOperation(zero.get) wshp.setOutdoorAirFlowRateDuringHeatingOperation(zero.get) wshp.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(zero.get) #wshp.setSupplyAirFlowRateWhenNoCoolingorHeatingisNeeded(0) end end end

Am I missing something here?

boost::optional argument for WSHP in ruby

Hi, I am trying to set the value of outdoor air flow rate in my ZoneHVAC:WatertoAirHeatPump to zero, through a measure. For this object, the setOutdoorAirFlowRateDuringCoolingOperation() accepts a boost::optional argument, as per the OS Class Runner reference. I am looking for ways to initialise a boost::optional argument in ruby, and I think I maybe getting confused between an OptionalDouble and a boost::optional

https://unmethours.com/question/8806/openstudio-python-bindings-set-optionals/ addresses this question, and one of the answers says I need to use the following syntax:

                             value = OpenStudio.OptionalDouble.new(10000.0)
                             coil.setRatedHighSpeedTotalCoolingCapacity(value)

This doesn't seem to be working though, and Ruby says this method is not recognised. Is there something I should add before/after these lines to have 'value' be initialised as a boost::optional type? I tried initialising the object as an Optional double with a default value, but this still gives a run time error. My code block is as such: In the arguments section: def arguments(model) args = OpenStudio::Ruleset::OSArgumentVector.new zero = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('zero',false) zero.setDefaultValue(0.00) args << zero

In the runner: zone.equipment.each do |zone_equip| wshp = zone_equip.to_ZoneHVACWaterToAirHeatPump if wshp.is_initialized wshp = wshp.get if zero.is_initialized wshp.setOutdoorAirFlowRateDuringCoolingOperation(zero.get) wshp.setOutdoorAirFlowRateDuringHeatingOperation(zero.get) wshp.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(zero.get) #wshp.setSupplyAirFlowRateWhenNoCoolingorHeatingisNeeded(0) end end end

Am I missing something here?