Class: EnableIdealAirLoadsForAllZones

Inherits:
OpenStudio::Measure::ModelMeasure
  • Object
show all
Defined in:
lib/measures/EnableIdealAirLoadsForAllZones/measure.rb

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(model) ⇒ Object

define the arguments that the user will input



24
25
26
27
28
# File 'lib/measures/EnableIdealAirLoadsForAllZones/measure.rb', line 24

def arguments(model)
  args = OpenStudio::Measure::OSArgumentVector.new

  return args
end

#nameObject

define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml



19
20
21
# File 'lib/measures/EnableIdealAirLoadsForAllZones/measure.rb', line 19

def name
  return 'EnableIdealAirLoadsForAllZones'
end

#run(model, runner, user_arguments) ⇒ Object

define what happens when the measure is run



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/measures/EnableIdealAirLoadsForAllZones/measure.rb', line 31

def run(model, runner, user_arguments)
  super(model, runner, user_arguments)

  # use the built-in error checking
  if !runner.validateUserArguments(arguments(model), user_arguments)
    return false
  end

  # array of zones initially using ideal air loads
  startingIdealAir = []

  # remove zone equipment except for exhaust and natural ventilation
  zone_hvac_ideal_found = false
  model.getZoneHVACComponents.each do |component|
    next if component.to_FanZoneExhaust.is_initialized
    component.remove
  end

  thermalZones = model.getThermalZones
  thermalZones.each do |zone|
    # TODO: - need to also look for ZoneHVACIdealLoadsAirSystem
    if zone.useIdealAirLoads
      startingIdealAir << zone
    else

      if zone_hvac_ideal_found == true
        startingIdealAir << zone
      else

        next if !zone.thermostatSetpointDualSetpoint.is_initialized
        ideal_loads = OpenStudio::Model::ZoneHVACIdealLoadsAirSystem.new(model)
        ideal_loads.addToThermalZone(zone)
        # Set the ideal loads properties
        # ideal_loads.setMinimumCoolingTemperature(0.0)
      end

    end
  end

  # remove air and plant loops not used for SWH
  model.getAirLoopHVACs.each(&:remove)

  # see if plant loop is swh or not and take proper action (booter loop doesn't have water use equipment)
  model.getPlantLoops.each do |plant_loop|
    is_swh_loop = false
    plant_loop.supplyComponents.each do |component|
      if component.to_WaterHeaterMixed.is_initialized
        is_swh_loop = true
        next
      end
    end
    if is_swh_loop == false
      plant_loop.remove
    end
  end

  # reporting initial condition of model
  runner.registerInitialCondition("In the initial model #{startingIdealAir.size} zones use ideal air loads.")

  # reporting final condition of model
  finalIdealAir = []
  thermalZones.each do |zone|
    if zone.useIdealAirLoads
      finalIdealAir << zone
    end
  end
  runner.registerFinalCondition("In the final model #{finalIdealAir.size} zones use ideal air loads.")

  return true
end