-
Notifications
You must be signed in to change notification settings - Fork 2
/
custom_var_set_mapping.rb
179 lines (158 loc) · 7.74 KB
/
custom_var_set_mapping.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# this is called by osw_2_osa.rb script. Generally this is the file that should be customized to define variable sets and template osw and osa files.
# list of valid_var_sets
def valid_var_sets
return ['generic','pv_fraction','pv_bool','bar_study_1','bar_study_2'] # 'blend_skip_true','blend_typical'
end
# logic to select var set
def select_var_set
if ARGV[2].nil?
# default to location sweep only
var_set = "generic"
else
var_set = ARGV[2]
end
return var_set
end
# todo - blend_typical will not work as osa until I fix argument for geojson_file path to be relative or using runner.workflow.findFile
# logic to select OSW
def select_osw(var_set)
if ARGV[3].nil?
# add logic to use different default based on analysis chosen
if ['bar_study_1','bar_study_2','generic'].include?(var_set)
osw_path = OpenStudio::Path.new("run/workflows/bar_typical/in.osw")
elsif ['blend_skip_true','blend_typical'].include?(var_set)
osw_path = OpenStudio::Path.new("run/workflows/blend_typical/in.osw")
else
osw_path = OpenStudio::Path.new("run/workflows/floorspace_typical/in.osw")
end
else
osw_path = OpenStudio::Path.new("run/workflows/#{ARGV[3]}/in.osw")
end
return osw_path
end
# logic to select OSA
def select_osa(var_set)
# not currently using var_set to pick OSA but you can.
if ARGV[4].nil?
osa_template_path = OpenStudio::Path.new("template_osa_files/osa_template_doe.json")
else
osa_template_path = OpenStudio::Path.new("template_osa_files/#{ARGV[4]}.json")
end
return osa_template_path
end
# logic define variables
def var_mapping(var_set,osw_path)
desc_vars = {}
# weather_file
var_epw = []
if ['generic','bar_study_1'].include?(var_set)
# var_epw << 'VNM_Hanoi.488200_IWEC.epw' #0A
# var_epw << 'ARE_Abu.Dhabi.412170_IWEC.epw' #0B
# var_epw << 'USA_HI_Honolulu.Intl.AP.911820_TMY3.epw' #1A
# var_epw << 'IND_New.Delhi.421820_ISHRAE.epw' #1B
# var_epw << 'USA_FL_MacDill.AFB.747880_TMY3.epw' #2A
var_epw << 'USA_AZ_Davis-Monthan.AFB.722745_TMY3.epw' #2B
var_epw << 'USA_GA_Atlanta-Hartsfield-Jackson.Intl.AP.722190_TMY3.epw' #3A
# var_epw << 'USA_TX_El.Paso.Intl.AP.722700_TMY3.epw' #3B
var_epw << 'USA_CA_Chula.Vista-Brown.Field.Muni.AP.722904_TMY3.epw' #3C
# var_epw << 'USA_NY_New.York-J.F.Kennedy.Intl.AP.744860_TMY3.epw' #4A
# var_epw << 'USA_NM_Albuquerque.Intl.AP.723650_TMY3.epw' #4B
# var_epw << 'USA_WA_Seattle-Tacoma.Intl.AP.727930_TMY3.epw' #4c
var_epw << 'USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.epw' #5A
# var_epw << 'USA_CO_Aurora-Buckley.Field.ANGB.724695_TMY3.epw' #5B
# var_epw << 'USA_WA_Port.Angeles-William.R.Fairchild.Intl.AP.727885_TMY3.epw' #5C
# var_epw << 'USA_MN_Rochester.Intl.AP.726440_TMY3.epw' #6A
# var_epw << 'USA_MT_Great.Falls.Intl.AP.727750_TMY3.epw' #6B
var_epw << 'USA_MN_International.Falls.Intl.AP.727470_TMY3.epw' #7
# var_epw << 'USA_AK_Fairbanks.Intl.AP.702610_TMY3.epw' #8
else
var_epw << 'USA_AZ_Davis-Monthan.AFB.722745_TMY3.epw' #2B
var_epw << 'USA_GA_Atlanta-Hartsfield-Jackson.Intl.AP.722190_TMY3.epw' #3A
# chicago used in OSW but not in OSA
#var_epw << 'USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw'
end
# variable for ChangeBuildingLocation
if var_epw.size > 0
desc_vars['ChangeBuildingLocation'] = {}
desc_vars['ChangeBuildingLocation']['weather_file_name'] = var_epw
end
# setup multiple variables for create_bar_from_doe_building_type_ratios
desc_vars['create_bar_from_doe_building_type_ratios'] = {}
desc_vars['create_typical_building_from_model'] = {} # used on worfkflow that doesn't have create_bar
# template (note that depending on the workflow, a different measure is chosen to set template for)
if ["bar_study_1","bar_study_2"].include?(var_set)
var_template = []
var_template << 'DOE Ref Pre-1980'
var_template << 'DOE Ref 1980-2004'
var_template << '90.1-2004'
var_template << '90.1-2007'
var_template << '90.1-2010'
var_template << '90.1-2013'
if osw_path.to_s.include?("floorspace_typical")
desc_vars['create_typical_building_from_model']['template'] = var_template
else
desc_vars['create_bar_from_doe_building_type_ratios']['template'] = var_template
end
elsif ['generic','blend_skip_true','blend_typical'].include?(var_set)
var_template = []
var_template << '90.1-2004'
var_template << '90.1-2013'
if osw_path.to_s.include?("floorspace_typical")
desc_vars['create_typical_building_from_model']['template'] = var_template
else
desc_vars['create_bar_from_doe_building_type_ratios']['template'] = var_template
end
end
# num_stories_above_grade
if ["bar_study_2"].include?(var_set)
var_num_stories = [1.0,1.5,2.0,2.5,3.0] # when arg is integer instead of double store as string
desc_vars['create_bar_from_doe_building_type_ratios']['num_stories_above_grade'] = var_num_stories
elsif ["generic"].include?(var_set)
var_num_stories = [1.0,2.0]
desc_vars['create_bar_from_doe_building_type_ratios']['num_stories_above_grade'] = var_num_stories
end
# fraction_of_surface or skip measure var
if var_set == "pv_fraction"
var_fraction_pv = [0.25,0.375,0.5,0.625,0.75,0.875]
desc_vars['add_rooftop_pv'] = {}
desc_vars['add_rooftop_pv']['fraction_of_surface'] = var_fraction_pv
elsif var_set == "generic"
var_fraction_pv = [0.5,0.75]
desc_vars['add_rooftop_pv'] = {}
desc_vars['add_rooftop_pv']['fraction_of_surface'] = var_fraction_pv
elsif ['pv_bool','generic'].include?(var_set)
# you can use the __SKIP__ argument in any measure as a variable (this is not something that can be done in PAT)
# I could have set fraction to 0 to mimic skipping, but just did it this way to demonstrate the functionality
desc_vars['add_rooftop_pv'] = {}
desc_vars['add_rooftop_pv']['__SKIP__'] = [true,false]
end
# todo - add in example showing how to handle variables on measures with multiple instances in a workflow
# if wanted to use second instance of measure key would be SetWindowToWallRatioByFacade_2.
# I don't require or make use of the name field on the OSW, only the measure directory.
return desc_vars
end
# this is used to update static values for measure arguments for a specific variable set
# this demonstrates that you don't need to make unique OSW if you just want to enable/disable an extra measure or if you want to change a static value. Having less OSW's variable set specific logic here is easier to maintain then having a unique OSW for every variable set or analysis.
def update_static_arg_val(var_set)
desc_args = {}
# if var_set is blend_skip_true then turn off the blend and urban geometry measures
if var_set == 'blend_skip_true'
desc_args['blended_space_type_from_model'] = {}
desc_args['blended_space_type_from_model']['__SKIP__'] = true
desc_args['urban_geometry_creation'] = {}
desc_args['urban_geometry_creation']['__SKIP__'] = true
# todo - even when skip is true need valid geojson that can be found remove this once using workflow.runner.findFile
desc_args['urban_geometry_creation']['urban_geometry_creation'] = "../files/prototype_mesa_footprints.geojson"
elsif var_set == 'blend_typical'
desc_args['urban_geometry_creation'] = {}
# todo - remove this once using workflow.runner.findFile
desc_args['urban_geometry_creation']['urban_geometry_creation'] = "../files/prototype_mesa_footprints.geojson"
end
# manual switch to enable or disable zone conditions in OpenStudio results. It is off by default to avoid the hour zone time series temperature and humidity values that are needed
zone_conditions = false # this coudl be set by a var_set
if zone_conditions
desc_args['openstudio_results'] = {}
desc_args['openstudio_results']['zone_condition_section'] = true
end
return desc_args
end