Class: MakeShadingSurfacesBasedOnZoneMultipliers

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

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(model) ⇒ Object

define the arguments that the user will input



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
# File 'lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb', line 30

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

  # TODO: - make arguments for each group of common non 1 multipliers on the same story

  # TODO: - optionally could also list individual zones with non 1 multiliers as well

  # TODO: - argument for z offset distance per zone
  z_offset_dist = OpenStudio::Measure::OSArgument.makeDoubleArgument('z_offset_dist', true)
  z_offset_dist.setDisplayName('Z offset distance for selcected zones.')
  z_offset_dist.setDefaultValue(10.0)
  z_offset_dist.setUnits('ft')
  args << z_offset_dist

  # TODO: - argument for z start offset starting position (0 is equal above and below)
  z_num_pos = OpenStudio::Measure::OSArgument.makeIntegerArgument('z_num_pos', true)
  z_num_pos.setDisplayName('Number of copies in the positive direction.')
  z_num_pos.setDescription('Should be integer no more than the multiplier - 1')
  z_num_pos.setDefaultValue(1) # TODO: - replace with half of multiplier rounded up
  args << z_num_pos

  # TODO: - argument for x offset distance per zone

  # TODO: - argument for x start offset starting position (0 is equal above and below)

  # TODO: - argument for y offset distance per zone

  # TODO: - argument for y start offset starting position (0 is equal above and below)

  return args
end

#descriptionObject

human readable description



20
21
22
# File 'lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb', line 20

def description
  return 'Initially this will jsut focus on Z shifting of geometry, but in future could work on x,z or y,z multiplier grids like what is use don the large hotel'
end

#modeler_descriptionObject

human readable description of modeling approach



25
26
27
# File 'lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb', line 25

def modeler_description
  return 'Not sure how I will handle arguments. Maybe lump together all spaces on same sotry that have the same multilier value. This will have variable number of arguments basd on the model pased in. Alternative is to either only allo w one group to be chosen at at time, or allow a comlex string that describes everything. Also need to see how to define shirting. There is an offset but it may be above and below and may not be equal. In Some cases a mid floor is halfway betwen floors which makes just copying the base surfaces as shading multiple times probemeatic, since there is overlap. It coudl be nice to stretch one surface over many stories. If I check for vertial adn orthogonal surface that may work fine. '
end

#nameObject

human readable name



15
16
17
# File 'lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb', line 15

def name
  return 'Make Shading Surfaces Based on Zone Multipliers'
end

#run(model, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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
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
# File 'lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb', line 63

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

  # assign the user inputs to variables
  args = runner.getArgumentValues(arguments(model), user_arguments)
  args = Hash[args.collect{ |k, v| [k.to_s, v] }]
  if !args then return false end

  # report initial condition of model
  runner.registerInitialCondition("The building started with #{model.getShadingSurfaces.size} shading surfaces.")

  # find thermal zones with multiplier greater than 1
  zones_to_alter = {}
  model.getThermalZones.each do |zone|
    if zone.multiplier > 1
      puts "#{zone.name} has a multiplier of #{zone.multiplier}"
      zones_to_alter[zone.spaces] = zone.multiplier
    end
  end

  # gather inputs
  z_offset_si = OpenStudio.convert(args['z_offset_dist'], 'ft', 'm').get

  # gather surfaces to copy
  surfaces_to_copy = {}
  zones_to_alter.each do |spaces, multiplier|
    spaces.each do |space|
      # space_origin
      origin = [space.xOrigin, space.yOrigin, space.zOrigin]

      origin_pos_z = space.zOrigin
      args['z_num_pos'].times do
        origin_pos_z += z_offset_si

        # make shading surface group and set origin
        shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)
        shading_surface_group.setXOrigin(origin[0])
        shading_surface_group.setYOrigin(origin[1])
        shading_surface_group.setZOrigin(origin_pos_z)

        space.surfaces.each do |surface|
          next if surface.outsideBoundaryCondition != 'Outdoors'

          surfaces_to_copy[surface] = multiplier

          # store  vertices
          vertices = surface.vertices

          # make shading surface for new group
          shading_surface = OpenStudio::Model::ShadingSurface.new(vertices, model)
          shading_surface.setShadingSurfaceGroup(shading_surface_group)
          shading_surface.setName("mult - #{surface.name}")
        end
      end

      origin_neg_z = space.zOrigin
      num_nug = (multiplier - args['z_num_pos']) - 1 # one copy already exist, so only need multiplier - 1
      num_nug.times do
        origin_neg_z -= z_offset_si

        # make shading surface group and set origin
        shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)
        shading_surface_group.setXOrigin(origin[0])
        shading_surface_group.setYOrigin(origin[1])
        shading_surface_group.setZOrigin(origin_neg_z)

        space.surfaces.each do |surface|
          next if surface.outsideBoundaryCondition != 'Outdoors'

          surfaces_to_copy[surface] = multiplier

          # store  vertices
          vertices = surface.vertices

          # make shading surface for new group
          shading_surface = OpenStudio::Model::ShadingSurface.new(vertices, model)
          shading_surface.setShadingSurfaceGroup(shading_surface_group)
          shading_surface.setName("mult - #{surface.name}")
        end
      end
    end
  end

  # TODO: - stretching on non orthogonal won't work, take different approach in those cases.

  # report final condition of model
  runner.registerFinalCondition("The building finished with #{model.getShadingSurfaces.size} surfaces.")

  return true
end