Class: BlendedSpaceTypeFromFloorAreaRatios
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- BlendedSpaceTypeFromFloorAreaRatios
- Defined in:
- lib/measures/blended_space_type_from_floor_area_ratios/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
human readable description.
-
#getSpaceTypeStandardsInformation(spaceTypeArray) ⇒ Object
gather standards info for space type array.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
human readable name.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
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 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 |
# File 'lib/measures/blended_space_type_from_floor_area_ratios/measure.rb', line 57 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # get building type, floor area, and name if model.getBuilding.standardsBuildingType.is_initialized building_type = model.getBuilding.standardsBuildingType.get else building_type = 'Unknown' end building_area = model.getBuilding.floorArea building_name = model.getBuilding.name # map office to small medium or large. if building_type == 'Office' if building_name.get.include?('SmallOffice') building_type = 'SmallOffice' elsif building_name.get.include?('LargeOffice') building_type = 'LargeOffice' elsif building_name.get.include?('MediumOffice') building_type = 'MediumOffice' else # TODO: - use building area as backup to building name building_type = 'MediumOffice' end end # map Apartment to MidriseApartment or HighriseApartment if building_type == 'Apartment' if building_name.get.include?('MidriseApartment') building_type = 'MidriseApartment' elsif building_name.get.include?('HighriseApartment') building_type = 'HighriseApartment' else # TODO: - use building area as backup to building name building_type = 'MidriseApartment' end end # map Retail if building_type == 'Retail' building_type = 'RetailStandalone' end if building_type == 'StripMall' building_type = 'RetailStandalone' end # infer template if building_name.get.include?('DOE Ref Pre-1980') template = 'DOE Ref Pre-1980' elsif building_name.get.include?('DOE Ref 1980-2004') template = 'DOE Ref 1980-2004' elsif building_name.get.include?('90.1-2004') template = '90.1-2004' elsif building_name.get.include?('90.1-2007') template = '90.1-2007' elsif building_name.get.include?('90.1-2010') template = '90.1-2010' elsif building_name.get.include?('90.1-2013') template = '90.1-2013' else # assume 2013 if can't infer from name template = '90.1-2013' end # get standards info for existing space types space_type_standards_info_hash = getSpaceTypeStandardsInformation(model.getSpaceTypes) # lookup ratios space_type_hash = OpenstudioStandards::CreateTypical.get_space_types_from_building_type(building_type) #just 1 instead of 4 args if space_type_hash == false default_string = 'Attempt to automatically generate space type ratio string failed, enter manually.' else default_string_array = [] space_type_hash.each do |space_type_standards_name, hash| # find name of first spcce type with this standards info and add to string space_type_standards_info_hash.each do |space_type, standards_info| # TODO: - also confirm building type (can't use adjusted building type) if standards_info[1] == space_type_standards_name default_string_array << "\'#{space_type.name.get}\' => #{hash[:ratio]}" end end end default_string = default_string_array.join(',') end # create space type ratio string input with default value based on building type and infered template space_type_ratio_string = OpenStudio::Measure::OSArgument.makeStringArgument('space_type_ratio_string', true) space_type_ratio_string.setDisplayName('Space Type Ratio String.') space_type_ratio_string.setDescription("\'Space Type A\' => ratio,\'Space Type B,ratio\', etc.") space_type_ratio_string.setDefaultValue(default_string) args << space_type_ratio_string # bool argument to set building default space type set_default_space_type = OpenStudio::Measure::OSArgument.makeBoolArgument('set_default_space_type', true) set_default_space_type.setDisplayName('Set Default Space Type using Blended Space Type.') set_default_space_type.setDefaultValue(true) args << set_default_space_type return args end |
#description ⇒ Object
human readable description
20 21 22 |
# File 'lib/measures/blended_space_type_from_floor_area_ratios/measure.rb', line 20 def description return 'This measure will take a string argument describing the space type ratios, for space types already in the model. There is also an argument to set the new blended space type as the default space type for the building. The space types refererenced by this argument should already exist in the model.' end |
#getSpaceTypeStandardsInformation(spaceTypeArray) ⇒ Object
gather standards info for space type array
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 |
# File 'lib/measures/blended_space_type_from_floor_area_ratios/measure.rb', line 30 def getSpaceTypeStandardsInformation(spaceTypeArray) # hash of space types spaceTypeStandardsInfoHash = {} spaceTypeArray.each do |spaceType| # get standards building if !spaceType.standardsBuildingType.empty? standardsBuilding = spaceType.standardsBuildingType.get else standardsBuilding = nil end # get standards space type if !spaceType.standardsSpaceType.empty? standardsSpaceType = spaceType.standardsSpaceType.get else standardsSpaceType = nil end # populate hash spaceTypeStandardsInfoHash[spaceType] = [standardsBuilding, standardsSpaceType] end return spaceTypeStandardsInfoHash end |
#modeler_description ⇒ Object
human readable description of modeling approach
25 26 27 |
# File 'lib/measures/blended_space_type_from_floor_area_ratios/measure.rb', line 25 def modeler_description return 'To determine default ratio look at the building type, and try to infer template (from building name) and set default ratios saved in the resources folder.' end |
#name ⇒ Object
human readable name
15 16 17 |
# File 'lib/measures/blended_space_type_from_floor_area_ratios/measure.rb', line 15 def name return 'Blended Space Type from Floor Area Ratios' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/measures/blended_space_type_from_floor_area_ratios/measure.rb', line 160 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 # get arguments space_type_ratio_string = runner.getStringArgumentValue('space_type_ratio_string', user_arguments) set_default_space_type = runner.getBoolArgumentValue('set_default_space_type', user_arguments) # report initial condition of model runner.registerInitialCondition("The initial building used #{model.getSpaceTypes.size} space types.") # make hash of out string arguemnt in eval. Rescue if can't be made into hash begin space_type_ratio_hash = eval("{#{space_type_ratio_string}}") rescue SyntaxError => e runner.registerError("{#{space_type_ratio_string}} could not be converted to a hash.") return false end # loop through space types and add to blend space_types_to_blend_hash = {} model.getSpaceTypes.each do |space_type| if space_type_ratio_hash.key?(space_type.name.get) # create hash with space type object as key and ratio as has floor_area_ratio = space_type_ratio_hash[space_type.name.get] space_types_to_blend_hash[space_type] = { floor_area_ratio: floor_area_ratio } end end # run method to create blended space type blended_space_type = OpenstudioStandards::CreateTypical.blend_space_types_from_floor_area_ratio(model, space_types_to_blend_hash) if blended_space_type.nil? return false end # set default if requested if set_default_space_type model.getBuilding.setSpaceType(blended_space_type) runner.registerInfo("Setting default space type for building to #{blended_space_type.name.get}") # remove all space type assignments, except for spaces not included in building area. model.getSpaces.each do |space| next if !space.partofTotalFloorArea space.resetSpaceType end end # report final condition of model runner.registerFinalCondition("The final building uses #{model.getSpaceTypes.size} spaces types.") return true end |