Class: SetExteriorWallsAndFloorsToAdiabatic

Inherits:
OpenStudio::Measure::ModelMeasure
  • Object
show all
Defined in:
lib/measures/set_exterior_walls_and_floors_to_adiabatic/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
29
30
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
# File 'lib/measures/set_exterior_walls_and_floors_to_adiabatic/measure.rb', line 24

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

  # make an argument for ext_roofs
  ext_roofs = OpenStudio::Measure::OSArgument.makeBoolArgument('ext_roofs', true)
  ext_roofs.setDisplayName('Make Exterior Roof Surfaces Adiabatic')
  ext_roofs.setDefaultValue(true)
  args << ext_roofs

  # make an argument for ext_floors
  ext_floors = OpenStudio::Measure::OSArgument.makeBoolArgument('ext_floors', true)
  ext_floors.setDisplayName('Make Exterior Exposed Floor Surfaces Adiabatic')
  ext_floors.setDefaultValue(true)
  args << ext_floors

  # make an argument for ground_floors
  ground_floors = OpenStudio::Measure::OSArgument.makeBoolArgument('ground_floors', true)
  ground_floors.setDisplayName('Make Ground Exposed Floor Surfaces Adiabatic')
  ground_floors.setDefaultValue(true)
  args << ground_floors

  # make an argument for north_walls
  north_walls = OpenStudio::Measure::OSArgument.makeBoolArgument('north_walls', true)
  north_walls.setDisplayName('Make North Facing Exterior Surfaces Adiabatic')
  north_walls.setDefaultValue(false)
  args << north_walls

  # make an argument for south_walls
  south_walls = OpenStudio::Measure::OSArgument.makeBoolArgument('south_walls', true)
  south_walls.setDisplayName('Make South Facing Exterior Surfaces Adiabatic')
  south_walls.setDefaultValue(false)
  args << south_walls

  # make an argument for east_walls
  east_walls = OpenStudio::Measure::OSArgument.makeBoolArgument('east_walls', true)
  east_walls.setDisplayName('Make East Facing Exterior Surfaces Adiabatic')
  east_walls.setDefaultValue(false)
  args << east_walls

  # make an argument for west_walls
  west_walls = OpenStudio::Measure::OSArgument.makeBoolArgument('west_walls', true)
  west_walls.setDisplayName('Make West Facing Exterior Surfaces Adiabatic')
  west_walls.setDefaultValue(false)
  args << west_walls

  # make an argument for inclusion_list
  inclusion_list = OpenStudio::Measure::OSArgument.makeStringArgument('inclusion_list', true)
  inclusion_list.setDisplayName('Adiabatic Inclusion List')
  inclusion_list.setDescription('Surfaces listed here will be changed to adiabatic boundary condition. This can contain one or more surface names. It is case sensitive and multiple names should be separated with a vertical pipe character like this. |')
  inclusion_list.setDefaultValue('make_me_adiabatic_01|make_me_adiabatic_02')
  args << inclusion_list

  # make an argument for exclusion_list
  exclusion_list = OpenStudio::Measure::OSArgument.makeStringArgument('exclusion_list', true)
  exclusion_list.setDisplayName('Adiabatic Exclusion List')
  exclusion_list.setDescription('Surfaces listed here will not be changed to adiabatic boundary condition. This can contain one or more surface names. It is case sensitive and multiple names should be separated with a vertical pipe character like this. |')
  exclusion_list.setDefaultValue('do_not_change_me_01|do_not_change_me_02')
  args << exclusion_list

  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/set_exterior_walls_and_floors_to_adiabatic/measure.rb', line 19

def name
  return 'Set Exterior Walls and Floors to Adiabatic'
end

#run(model, runner, user_arguments) ⇒ Object

define what happens when the measure is run



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/measures/set_exterior_walls_and_floors_to_adiabatic/measure.rb', line 87

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

  # assign the user inputs to variables
  ext_roofs = runner.getBoolArgumentValue('ext_roofs', user_arguments)
  ext_floors = runner.getBoolArgumentValue('ext_floors', user_arguments)
  ground_floors = runner.getBoolArgumentValue('ground_floors', user_arguments)
  north_walls = runner.getBoolArgumentValue('north_walls', user_arguments)
  south_walls = runner.getBoolArgumentValue('south_walls', user_arguments)
  east_walls = runner.getBoolArgumentValue('east_walls', user_arguments)
  west_walls = runner.getBoolArgumentValue('west_walls', user_arguments)

  # split list arguments inoto an array
  inclusion_list = runner.getStringArgumentValue('inclusion_list', user_arguments).split('|')
  exclusion_list = runner.getStringArgumentValue('exclusion_list', user_arguments).split('|')

  # add warning if same item on inclusion_list and exclusion_list
  common_items = inclusion_list & exclusion_list
  if !common_items.empty?
    runner.registerWarning("One or more items (#{common_items.join(',')}) were on both the inclusion and exclusion list. The exclusion list will take precedence.")
  end

  # counter for number of constructions use for interior walls in initial construction
  orig_adiabatic = 0

  # make an array of walls that started as matched surfaces.
  # I need to do this first, because when one of pair changes to Adiabatic, the other will change to Outdoors
  surfaces_to_change = []
  surfaces = model.getSurfaces
  surfaces.each do |surface|
    if surface.outsideBoundaryCondition == 'Adiabatic'
      orig_adiabatic += 1
    end

    # stop here if in exclusion list
    next if exclusion_list.include?(surface.name.to_s)

    if inclusion_list.include?(surface.name.to_s)
      # if on list gets added without having to check orientation
      surfaces_to_change << surface
    elsif ext_roofs && (surface.surfaceType == 'RoofCeiling') && (surface.outsideBoundaryCondition == 'Outdoors')
      surfaces_to_change << surface
    elsif ext_floors && (surface.surfaceType == 'Floor') && (surface.outsideBoundaryCondition == 'Outdoors')
      surfaces_to_change << surface
    elsif ground_floors && (surface.surfaceType == 'Floor') && (surface.outsideBoundaryCondition == 'Ground')
      surfaces_to_change << surface
    elsif (surface.surfaceType == 'Wall') && (surface.outsideBoundaryCondition == 'Outdoors') && (north_walls || south_walls || east_walls || west_walls)

      # get absolute azimuth and cardinal direction
      absoluteAzimuth = OpenStudio.convert(surface.azimuth, 'rad', 'deg').get + surface.space.get.directionofRelativeNorth + model.getBuilding.northAxis
      absoluteAzimuth -= 360.0 until absoluteAzimuth < 360.0
      if north_walls && ((absoluteAzimuth >= 315.0) || (absoluteAzimuth < 45.0))
        surfaces_to_change << surface
      elsif east_walls && ((absoluteAzimuth >= 45.0) && (absoluteAzimuth < 135.0))
        surfaces_to_change << surface
      elsif south_walls && ((absoluteAzimuth >= 135.0) && (absoluteAzimuth < 225.0))
        surfaces_to_change << surface
      elsif west_walls && ((absoluteAzimuth >= 225.0) && (absoluteAzimuth < 315.0))
        surfaces_to_change << surface
      end
    end
  end

  # change boundary condition and assign constructions
  surfaces_to_change.each do |surface|
    if surface.construction.is_initialized
      surface.setConstruction(surface.construction.get)
    end
    # this will remove any existing sub-surfaces for the surface.
    surface.setOutsideBoundaryCondition('Adiabatic')
  end

  # reporting initial condition of model
  runner.registerInitialCondition("The initial model has #{orig_adiabatic} adiabatic surfaces.")

  # reporting final condition of model
  runner.registerFinalCondition("The final model has #{orig_adiabatic + surfaces_to_change.size} adiabatic surfaces.")

  return true
end