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

Revision history [back]

Matt, that is a good catch. The logic in the existing measures that change single and two speed dx COP's loops through air loops, and then supply components. You want to loop through zone equipment instead. The code below should do what you want. It is specifically looking for PTAC with single speed DX, but you could expand it to look for other types of objects.

# loop through zone equipment
model.getZoneHVACComponents.each do |component|

  # see if it is a PTAC
  if component.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized
    runner.registerInfo("#{component.name} is a PTAC")
    ptac = component.to_ZoneHVACPackagedTerminalAirConditioner.get

    # get the cooling coil
    coil_cooling = ptac.coolingCoil

    # see if it is single speed dx
    if coil_cooling.to_CoilCoolingDXSingleSpeed.is_initialized
      single_speed_dx = coil_cooling.to_CoilCoolingDXSingleSpeed.get
      runner.registerInfo("The intial COP is #{single_speed_dx.ratedCOP}")

      # set cop
      target_cop = 1.5 * single_speed_dx.ratedCOP.get # need the get because ratedCOP returns an optional, should check if it exists before doing a get
      optionalDoubleCOP = OpenStudio::OptionalDouble.new(target_cop) # not many objects need this step, this is an odd one
      single_speed_dx.setRatedCOP(optionalDoubleCOP)
      runner.registerInfo("The adjusted COP is #{single_speed_dx.ratedCOP}")

    else
      # could add in elsif to look for other types of cooling coils
    end

  else  
    # could add in elsif to look for other kinds of zone equipment
  end

end

Here is the documentation on ZoneHVACPackagedTerminalAirConditioner

And here is the documentation on CoilCoolingDXSingleSpeed