openstudio-model-articulation 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/LICENSE.md +7 -21
  4. data/README.md +5 -3
  5. data/Rakefile +2 -32
  6. data/doc_templates/LICENSE.md +7 -21
  7. data/doc_templates/copyright_erb.txt +2 -32
  8. data/doc_templates/copyright_js.txt +2 -2
  9. data/doc_templates/copyright_ruby.txt +3 -33
  10. data/lib/measures/AssignConstructionSetToBuilding/LICENSE.md +7 -21
  11. data/lib/measures/AssignConstructionSetToBuilding/measure.rb +2 -32
  12. data/lib/measures/AssignConstructionSetToBuilding/measure.xml +7 -7
  13. data/lib/measures/AssignSpaceTypeBySpaceName/LICENSE.md +7 -21
  14. data/lib/measures/AssignSpaceTypeBySpaceName/measure.rb +2 -32
  15. data/lib/measures/AssignSpaceTypeBySpaceName/measure.xml +25 -25
  16. data/lib/measures/AssignSpaceTypeToBuilding/LICENSE.md +7 -21
  17. data/lib/measures/AssignSpaceTypeToBuilding/measure.rb +2 -32
  18. data/lib/measures/AssignSpaceTypeToBuilding/measure.xml +7 -7
  19. data/lib/measures/AssignSpacesToStories/LICENSE.md +7 -21
  20. data/lib/measures/AssignSpacesToStories/measure.rb +2 -32
  21. data/lib/measures/AssignSpacesToStories/measure.xml +5 -5
  22. data/lib/measures/BarAspectRatioStudy/LICENSE.md +7 -21
  23. data/lib/measures/BarAspectRatioStudy/measure.rb +2 -32
  24. data/lib/measures/BarAspectRatioStudy/measure.xml +5 -5
  25. data/lib/measures/CleanupSpaceOrigins/LICENSE.md +7 -21
  26. data/lib/measures/CleanupSpaceOrigins/measure.rb +2 -32
  27. data/lib/measures/CleanupSpaceOrigins/measure.xml +5 -5
  28. data/lib/measures/FindAndReplaceObjectNames/LICENSE.md +7 -21
  29. data/lib/measures/FindAndReplaceObjectNames/measure.rb +2 -32
  30. data/lib/measures/FindAndReplaceObjectNames/measure.xml +5 -5
  31. data/lib/measures/InjectOsmGeometryIntoAnExternalIdf/LICENSE.md +7 -21
  32. data/lib/measures/InjectOsmGeometryIntoAnExternalIdf/measure.rb +2 -32
  33. data/lib/measures/InjectOsmGeometryIntoAnExternalIdf/measure.xml +23 -23
  34. data/lib/measures/RemoveHardAssignedConstructions/LICENSE.md +7 -21
  35. data/lib/measures/RemoveHardAssignedConstructions/measure.rb +2 -32
  36. data/lib/measures/RemoveHardAssignedConstructions/measure.xml +5 -5
  37. data/lib/measures/RenameSpaceSurfacesBasedonParentSpaceandOrientation/LICENSE.md +7 -21
  38. data/lib/measures/RenameSpaceSurfacesBasedonParentSpaceandOrientation/measure.rb +2 -32
  39. data/lib/measures/RenameSpaceSurfacesBasedonParentSpaceandOrientation/measure.xml +25 -25
  40. data/lib/measures/RotateBuilding/LICENSE.md +7 -21
  41. data/lib/measures/RotateBuilding/measure.rb +2 -32
  42. data/lib/measures/RotateBuilding/measure.xml +5 -5
  43. data/lib/measures/SetExtWallToGroundBoundaryConditionByStory/LICENSE.md +7 -21
  44. data/lib/measures/SetExtWallToGroundBoundaryConditionByStory/measure.rb +2 -32
  45. data/lib/measures/SetExtWallToGroundBoundaryConditionByStory/measure.xml +11 -11
  46. data/lib/measures/SetInteriorWallsAndFloorsToAdiabatic/LICENSE.md +7 -21
  47. data/lib/measures/SetInteriorWallsAndFloorsToAdiabatic/measure.rb +2 -32
  48. data/lib/measures/SetInteriorWallsAndFloorsToAdiabatic/measure.xml +5 -5
  49. data/lib/measures/SetInteriorWallsToSelectedConstruction/LICENSE.md +7 -21
  50. data/lib/measures/SetInteriorWallsToSelectedConstruction/measure.rb +2 -32
  51. data/lib/measures/SetInteriorWallsToSelectedConstruction/measure.xml +5 -5
  52. data/lib/measures/SetWindowToWallRatioByFacade/LICENSE.md +7 -21
  53. data/lib/measures/SetWindowToWallRatioByFacade/measure.rb +2 -32
  54. data/lib/measures/SetWindowToWallRatioByFacade/measure.xml +11 -11
  55. data/lib/measures/SetWindowToWallRatioByFacade/resources/functions.rb +2 -32
  56. data/lib/measures/SimplifyGeometryToSlicedBar/LICENSE.md +7 -21
  57. data/lib/measures/SimplifyGeometryToSlicedBar/measure.rb +2 -32
  58. data/lib/measures/SimplifyGeometryToSlicedBar/measure.xml +26 -26
  59. data/lib/measures/SimplifyGeometryToSlicedBar/resources/os_lib_cofee.rb +2 -32
  60. data/lib/measures/SimplifyGeometryToSlicedBar/resources/os_lib_geometry.rb +2 -32
  61. data/lib/measures/SimplifyGeometryToSlicedBar/resources/os_lib_helper_methods.rb +2 -32
  62. data/lib/measures/SpaceTypeAndConstructionSetWizard/LICENSE.md +7 -21
  63. data/lib/measures/SpaceTypeAndConstructionSetWizard/measure.rb +2 -32
  64. data/lib/measures/SpaceTypeAndConstructionSetWizard/measure.xml +21 -5
  65. data/lib/measures/SurfaceMatching/LICENSE.md +7 -21
  66. data/lib/measures/SurfaceMatching/measure.rb +2 -32
  67. data/lib/measures/SurfaceMatching/measure.xml +5 -5
  68. data/lib/measures/add_empd_material_properties/LICENSE.md +7 -21
  69. data/lib/measures/add_empd_material_properties/measure.rb +2 -32
  70. data/lib/measures/add_empd_material_properties/measure.xml +10 -10
  71. data/lib/measures/blended_space_type_from_floor_area_ratios/LICENSE.md +7 -21
  72. data/lib/measures/blended_space_type_from_floor_area_ratios/measure.rb +2 -32
  73. data/lib/measures/blended_space_type_from_floor_area_ratios/measure.xml +5 -5
  74. data/lib/measures/blended_space_type_from_model/LICENSE.md +7 -21
  75. data/lib/measures/blended_space_type_from_model/measure.rb +2 -32
  76. data/lib/measures/blended_space_type_from_model/measure.xml +10 -10
  77. data/lib/measures/clone_building_from_external_model/LICENSE.md +7 -21
  78. data/lib/measures/clone_building_from_external_model/measure.rb +2 -32
  79. data/lib/measures/clone_building_from_external_model/measure.xml +5 -5
  80. data/lib/measures/create_DOE_prototype_building/LICENSE.md +7 -21
  81. data/lib/measures/create_DOE_prototype_building/measure.rb +2 -32
  82. data/lib/measures/create_DOE_prototype_building/measure.xml +603 -235
  83. data/lib/measures/create_and_assign_thermal_zones_for_unassigned_spaces/LICENSE.md +7 -21
  84. data/lib/measures/create_and_assign_thermal_zones_for_unassigned_spaces/measure.rb +2 -32
  85. data/lib/measures/create_and_assign_thermal_zones_for_unassigned_spaces/measure.xml +5 -5
  86. data/lib/measures/create_bar_from_building_type_ratios/LICENSE.md +7 -21
  87. data/lib/measures/create_bar_from_building_type_ratios/README.md +5 -5
  88. data/lib/measures/create_bar_from_building_type_ratios/measure.rb +2 -32
  89. data/lib/measures/create_bar_from_building_type_ratios/measure.xml +53 -13
  90. data/lib/measures/create_bar_from_deer_building_type_ratios/LICENSE.md +7 -21
  91. data/lib/measures/create_bar_from_deer_building_type_ratios/measure.rb +2 -32
  92. data/lib/measures/create_bar_from_deer_building_type_ratios/measure.xml +10 -10
  93. data/lib/measures/create_bar_from_doe_building_type_ratios/LICENSE.md +7 -21
  94. data/lib/measures/create_bar_from_doe_building_type_ratios/README.md +13 -5
  95. data/lib/measures/create_bar_from_doe_building_type_ratios/measure.rb +2 -32
  96. data/lib/measures/create_bar_from_doe_building_type_ratios/measure.xml +53 -13
  97. data/lib/measures/create_bar_from_model/LICENSE.md +7 -21
  98. data/lib/measures/create_bar_from_model/measure.rb +2 -32
  99. data/lib/measures/create_bar_from_model/measure.xml +5 -5
  100. data/lib/measures/create_bar_from_space_type_ratios/LICENSE.md +7 -21
  101. data/lib/measures/create_bar_from_space_type_ratios/README.md +1 -1
  102. data/lib/measures/create_bar_from_space_type_ratios/measure.rb +2 -32
  103. data/lib/measures/create_bar_from_space_type_ratios/measure.xml +21 -13
  104. data/lib/measures/create_baseline_building/LICENSE.md +7 -21
  105. data/lib/measures/create_baseline_building/measure.rb +2 -32
  106. data/lib/measures/create_baseline_building/measure.xml +5 -5
  107. data/lib/measures/create_deer_prototype_building/LICENSE.md +7 -21
  108. data/lib/measures/create_deer_prototype_building/measure.rb +2 -32
  109. data/lib/measures/create_deer_prototype_building/measure.xml +6 -6
  110. data/lib/measures/create_deer_prototype_building/resources/deer_building_types.rb +2 -32
  111. data/lib/measures/create_parametric_schedules/LICENSE.md +7 -21
  112. data/lib/measures/create_parametric_schedules/measure.rb +2 -32
  113. data/lib/measures/create_parametric_schedules/measure.xml +5 -5
  114. data/lib/measures/create_typical_building_from_model/LICENSE.md +7 -21
  115. data/lib/measures/create_typical_building_from_model/README.md +1 -1
  116. data/lib/measures/create_typical_building_from_model/measure.rb +2 -32
  117. data/lib/measures/create_typical_building_from_model/measure.xml +27 -19
  118. data/lib/measures/create_typical_building_from_model/resources/Model.hvac.rb +2 -32
  119. data/lib/measures/create_typical_deer_building_from_model/LICENSE.md +7 -21
  120. data/lib/measures/create_typical_deer_building_from_model/measure.rb +2 -32
  121. data/lib/measures/create_typical_deer_building_from_model/measure.xml +17 -17
  122. data/lib/measures/create_typical_deer_building_from_model/resources/Model.hvac.rb +2 -32
  123. data/lib/measures/create_typical_doe_building_from_model/LICENSE.md +7 -21
  124. data/lib/measures/create_typical_doe_building_from_model/README.md +5 -1
  125. data/lib/measures/create_typical_doe_building_from_model/measure.rb +2 -32
  126. data/lib/measures/create_typical_doe_building_from_model/measure.xml +27 -19
  127. data/lib/measures/create_typical_doe_building_from_model/resources/Model.hvac.rb +2 -32
  128. data/lib/measures/deer_space_type_and_construction_set_wizard/LICENSE.md +7 -21
  129. data/lib/measures/deer_space_type_and_construction_set_wizard/measure.rb +2 -32
  130. data/lib/measures/deer_space_type_and_construction_set_wizard/measure.xml +5 -5
  131. data/lib/measures/find_and_replace_in_all_thermal_zone_names/LICENSE.md +7 -21
  132. data/lib/measures/find_and_replace_in_all_thermal_zone_names/measure.rb +2 -32
  133. data/lib/measures/find_and_replace_in_all_thermal_zone_names/measure.xml +5 -5
  134. data/lib/measures/make_shading_surfaces_based_on_zone_multipliers/LICENSE.md +7 -21
  135. data/lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.rb +2 -32
  136. data/lib/measures/make_shading_surfaces_based_on_zone_multipliers/measure.xml +5 -5
  137. data/lib/measures/merge_floorspace_js_with_model/LICENSE.md +7 -21
  138. data/lib/measures/merge_floorspace_js_with_model/measure.rb +2 -32
  139. data/lib/measures/merge_floorspace_js_with_model/measure.xml +11 -5
  140. data/lib/measures/merge_spaces_from_external_file/LICENSE.md +7 -21
  141. data/lib/measures/merge_spaces_from_external_file/measure.rb +2 -32
  142. data/lib/measures/merge_spaces_from_external_file/measure.xml +6 -6
  143. data/lib/measures/merge_spaces_from_external_file/resources/ScheduleTranslator.rb +2 -32
  144. data/lib/measures/radiance_measure/LICENSE.md +7 -21
  145. data/lib/measures/radiance_measure/measure.rb +2 -32
  146. data/lib/measures/radiance_measure/measure.xml +5 -5
  147. data/lib/measures/radiant_slab_with_doas/LICENSE.md +7 -21
  148. data/lib/measures/radiant_slab_with_doas/README.md +0 -8
  149. data/lib/measures/radiant_slab_with_doas/measure.rb +2 -41
  150. data/lib/measures/radiant_slab_with_doas/measure.xml +31 -40
  151. data/lib/measures/replace_geometry_by_story/LICENSE.md +7 -21
  152. data/lib/measures/replace_geometry_by_story/measure.rb +2 -32
  153. data/lib/measures/replace_geometry_by_story/measure.xml +5 -5
  154. data/lib/measures/scale_geometry/LICENSE.md +7 -21
  155. data/lib/measures/scale_geometry/measure.rb +2 -32
  156. data/lib/measures/scale_geometry/measure.xml +5 -5
  157. data/lib/measures/set_nist_infiltration_correlations/LICENSE.md +27 -0
  158. data/lib/measures/set_nist_infiltration_correlations/README.md +94 -0
  159. data/lib/measures/set_nist_infiltration_correlations/README.md.erb +45 -0
  160. data/lib/measures/set_nist_infiltration_correlations/docs/Data-NISTInfiltrationCorrelations.xlsx +0 -0
  161. data/lib/measures/set_nist_infiltration_correlations/docs/NIST.TN.2221.pdf +0 -0
  162. data/lib/measures/set_nist_infiltration_correlations/measure.rb +652 -0
  163. data/lib/measures/set_nist_infiltration_correlations/measure.xml +373 -0
  164. data/lib/measures/set_nist_infiltration_correlations/resources/Data-NISTInfiltrationCorrelations.csv +353 -0
  165. data/lib/openstudio/model_articulation/extension.rb +2 -32
  166. data/lib/openstudio/model_articulation/version.rb +3 -33
  167. data/lib/openstudio/model_articulation.rb +2 -32
  168. data/lib/openstudio-model-articulation.rb +2 -32
  169. data/openstudio-model-articulation.gemspec +2 -2
  170. metadata +15 -7
@@ -0,0 +1,652 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ #
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
24
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
27
+ # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
28
+ # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30
+ # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
+ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
35
+
36
+ require 'csv'
37
+
38
+ # start the measure
39
+ class SetNISTInfiltrationCorrelations < OpenStudio::Measure::ModelMeasure
40
+ # human readable name
41
+ def name
42
+ # Measure name should be the title case of the class name.
43
+ return 'SetNISTInfiltrationCorrelations'
44
+ end
45
+
46
+ # human readable description
47
+ def description
48
+ return "This measure incorporates infiltration that varies with weather and HVAC operation, and takes into account building geometry (height, above-ground exterior surface area, and volume). It is based on work published by Ng et al. (2018) <a href='https://doi.org/10.1016/j.buildenv.2017.10.029'>'Weather correlations to calculate infiltration rates for U.S. commercial building energy models'</a> and Ng et al. (2021) <a href='https://doi.org/10.1016/j.buildenv.2021.107783'>'Evaluating potential benefits of air barriers in commercial buildings using NIST infiltration correlations in EnergyPlus'</a>. This method of calculating infiltration was developed using eleven of the DOE commercial prototype building models (<a href='https://www.energycodes.gov/development/commercial/prototype_models'>Goel et al. 2014</a>) and TMY3 weather files for eight climate zones (CZ). Guidance on implementing the infiltration correlations are explained in the NIST technical report <a href='https://doi.org/10.6028/NIST.TN.2221'>'Implementing NIST Infiltration Correlations'</a>. Ng et al. (2018) shows that when analyzing the benefits of building envelope airtightening, greater HVAC energy savings were predicted using the infiltration inputs included in this Measure compared with using the default inputs that are included in the prototype building models. Brian Polidoro (NIST) first developed this Measure in 2015 and updated it in 2018 and 2019. Matthew Dahlhausen (NREL) updated the 2019 Measure and published this current version in 2023. To provide feedback on the NIST infiltration correlations, please email infiltration@list.nist.gov or lisa.ng@nist.gov. For measure implementation questions or issues, contact matthew.dahlhausen@nrel.gov."
49
+ end
50
+
51
+ # human readable description of modeling approach
52
+ def modeler_description
53
+ return "This measure will remove any existing infiltration objects (OS:SpaceInfiltration:DesignFlowRate and OS:SpaceInfiltration:EffectiveLeakageArea). Every zone will then get two OS:SpaceInfiltration:DesignFlowRate objects that add infiltration using the 'Flow per Exterior Surface Area' input option, one infiltration object when the HVAC system is on and one object when the HVAC system is off. The method assumes that HVAC operation is set by a schedule, though it may not reflect actual simulation/operation when fan operation may depend on internal loads and temperature setpoints. By default, interior zones will receive no infiltration. The user may enter a design building envelope airtightness at a specific design pressure, and whether the design value represents a 4-sided, 5-sided, or 6-sided normalization. By default, the measure assumes an airtightness design value of 13.8 (m^3/h-m^2) at 75 Pa. The measure assumes that infiltration is evenly distributed across the entire building envelope, including the roof. The user may select the HVAC system operating schedule in the model, or infer it based on the availability schedule of the air loop that serves the largest amount of floor area. The measure will make a copy of the HVAC operating schedule, 'Infiltration HVAC On Schedule', which is used with the HVAC on infiltration correlations. The measure will also make an 'Infiltration HVAC Off Schedule' with inverse operation, used with the HVAC off infiltration correlations. OS:SpaceInfiltration:DesignFlowRate object coefficients (A, B, C, and D) come from Ng et al. (2018). The user may select the Building Type and Climate Zone, or the measure will infer them from the model."
54
+ end
55
+
56
+ # DOE prototype buildings for which there are NIST infiltration coefficients
57
+ def nist_building_types
58
+ building_types = OpenStudio::StringVector.new
59
+ building_types << 'SecondarySchool'
60
+ building_types << 'PrimarySchool'
61
+ building_types << 'SmallOffice'
62
+ building_types << 'MediumOffice'
63
+ building_types << 'SmallHotel'
64
+ building_types << 'LargeHotel'
65
+ building_types << 'RetailStandalone'
66
+ building_types << 'RetailStripmall'
67
+ building_types << 'Hospital'
68
+ building_types << 'MidriseApartment'
69
+ building_types << 'HighriseApartment'
70
+
71
+ return building_types
72
+ end
73
+
74
+ def infer_nist_building_type(model)
75
+ if model.getBuilding.standardsBuildingType.is_initialized
76
+ model_building_type = model.getBuilding.standardsBuildingType.get
77
+ else
78
+ model_building_type = ''
79
+ end
80
+
81
+ case model_building_type
82
+ when 'Office'
83
+ # map office building type to small medium or large
84
+ floor_area = model.getBuilding.floorArea
85
+ if floor_area < 2750.0
86
+ nist_building_type = 'SmallOffice'
87
+ else
88
+ nist_building_type = 'MediumOffice'
89
+ end
90
+ when 'LargeOffice'
91
+ nist_building_type = 'MediumOffice'
92
+ when 'Retail'
93
+ # map retal building type to RetailStripmall or RetailStandalone based on building name
94
+ building_name = model.getBuilding.name.get
95
+ if building_name.include? 'RetailStandalone'
96
+ nist_building_type = 'RetailStandalone'
97
+ else
98
+ nist_building_type = 'RetailStripmall'
99
+ end
100
+ when 'StripMall'
101
+ nist_building_type = 'RetailStripmall'
102
+ when 'Warehouse'
103
+ nist_building_type = 'RetailStripmall'
104
+ when 'QuickServiceRestaurant'
105
+ nist_building_type = 'RetailStripmall'
106
+ when 'FullServiceRestaurant'
107
+ nist_building_type = 'RetailStripmall'
108
+ when 'Outpatient'
109
+ nist_building_type = 'MediumOffice'
110
+ when 'SuperMarket'
111
+ nist_building_type = 'RetailStandalone'
112
+ when 'EPr'
113
+ nist_building_type = 'PrimarySchool'
114
+ when 'ESe'
115
+ nist_building_type = 'SecondarySchool'
116
+ when 'RtL'
117
+ nist_building_type = 'RetailStandalone'
118
+ when 'RtS'
119
+ nist_building_type = 'RetailStripmall'
120
+ when 'RSD'
121
+ nist_building_type = 'RetailStripmall'
122
+ when 'RFF'
123
+ nist_building_type = 'RetailStripmall'
124
+ when 'Mtl'
125
+ nist_building_type = 'SmallHotel'
126
+ when 'Htl'
127
+ nist_building_type = 'LargeHotel'
128
+ when 'Hsp'
129
+ nist_building_type = 'Hospital'
130
+ when 'OfS'
131
+ nist_building_type = 'SmallOffice'
132
+ when 'OfL'
133
+ nist_building_type = 'MediumOffice'
134
+ when 'SCn'
135
+ nist_building_type = 'RetailStripmall'
136
+ else
137
+ nist_building_type = model_building_type
138
+ end
139
+
140
+ results = {}
141
+ results['model_building_type'] = model_building_type
142
+ results['nist_building_type'] = nist_building_type
143
+
144
+ return results
145
+ end
146
+
147
+ # method to invert a schedule day
148
+ def invert_schedule_day(old_schedule_day, new_schedule_day, new_schedule_name)
149
+ new_schedule_day.setName("#{new_schedule_name}")
150
+ for index in 0..old_schedule_day.times.size-1
151
+ old_value = old_schedule_day.values[index]
152
+ if old_value == 0
153
+ new_value = 1
154
+ else
155
+ new_value = 0
156
+ end
157
+ new_schedule_day.addValue(old_schedule_day.times[index], new_value)
158
+ end
159
+
160
+ return new_schedule_day
161
+ end
162
+
163
+ # method to invert a schedule ruleset
164
+ def invert_schedule_ruleset(schedule_ruleset, new_schedule_name)
165
+ model = schedule_ruleset.model
166
+ new_schedule = OpenStudio::Model::ScheduleRuleset.new(model, 0.0)
167
+ new_schedule.setName(new_schedule_name)
168
+
169
+ # change summer design day
170
+ summer_design_day_schedule = schedule_ruleset.summerDesignDaySchedule
171
+ new_summer_design_day_schedule = OpenStudio::Model::ScheduleDay.new(model)
172
+ invert_schedule_day(summer_design_day_schedule, new_summer_design_day_schedule, "#{new_schedule_name} Summer Design Day Schedule")
173
+ new_schedule.setSummerDesignDaySchedule(new_summer_design_day_schedule)
174
+
175
+ # change winter design day
176
+ winter_design_day_schedule = schedule_ruleset.winterDesignDaySchedule
177
+ new_winter_design_day_schedule = OpenStudio::Model::ScheduleDay.new(model)
178
+ invert_schedule_day(winter_design_day_schedule, new_winter_design_day_schedule, "#{new_schedule_name} Winter Design Day Schedule")
179
+ new_schedule.setWinterDesignDaySchedule(new_winter_design_day_schedule)
180
+
181
+ # change the default day values
182
+ default_day_schedule = schedule_ruleset.defaultDaySchedule
183
+ new_default_day_schedule = new_schedule.defaultDaySchedule
184
+ invert_schedule_day(default_day_schedule, new_default_day_schedule, "#{new_schedule_name} Default Day Schedule")
185
+
186
+ # change for schedule rules
187
+ schedule_ruleset.scheduleRules.each_with_index do |rule, i|
188
+ old_schedule_day = rule.daySchedule
189
+ new_schedule_day = OpenStudio::Model::ScheduleDay.new(model)
190
+ invert_schedule_day(old_schedule_day, new_schedule_day, "#{new_schedule_name} Schedule Day #{i}")
191
+
192
+ new_rule = OpenStudio::Model::ScheduleRule.new(new_schedule, new_schedule_day)
193
+ new_rule.setName("#{new_schedule_day.name} Rule")
194
+ new_rule.setApplySunday(rule.applySunday)
195
+ new_rule.setApplyMonday(rule.applyMonday)
196
+ new_rule.setApplyTuesday(rule.applyTuesday)
197
+ new_rule.setApplyWednesday(rule.applyWednesday)
198
+ new_rule.setApplyThursday(rule.applyThursday)
199
+ new_rule.setApplyFriday(rule.applyFriday)
200
+ new_rule.setApplySaturday(rule.applySaturday)
201
+ end
202
+ return new_schedule
203
+ end
204
+
205
+ # define the arguments that the user will input
206
+ def arguments(model)
207
+ args = OpenStudio::Measure::OSArgumentVector.new
208
+
209
+ # airtightness value
210
+ airtightness_value = OpenStudio::Measure::OSArgument::makeDoubleArgument('airtightness_value', false)
211
+ airtightness_value.setDefaultValue(13.8)
212
+ airtightness_value.setDisplayName('Airtightness design value (m^3/h-m^2)')
213
+ airtightness_value.setDescription('The airtightness design value from a building pressurization test. Use 5.0 (m^3/h-m^2) as a default for buildings with air barriers. Convert (cfm/ft^2) to (m^3/h-m^2) by multiplying by 18.288 (m-min/ft-hr). (0.3048 m/ft)*(60 min/hr) = 18.288 (m-min/ft-hr).')
214
+ args << airtightness_value
215
+
216
+ # airtightness pressure
217
+ airtightness_pressure = OpenStudio::Measure::OSArgument::makeDoubleArgument('airtightness_pressure', false)
218
+ airtightness_pressure.setDefaultValue(75.0)
219
+ airtightness_pressure.setDisplayName('Airtightness design pressure (Pa)')
220
+ airtightness_pressure.setDescription('The corresponding pressure for the airtightness design value, typically 75 Pa for commercial buildings and 50 Pa for residential buildings.')
221
+ args << airtightness_pressure
222
+
223
+ # choices for air-tightness scope
224
+ airtightness_choices = OpenStudio::StringVector.new
225
+ airtightness_choices << '4-sided'
226
+ airtightness_choices << '5-sided'
227
+ airtightness_choices << '6-sided'
228
+
229
+ # airtightness area
230
+ airtightness_area = OpenStudio::Measure::OSArgument.makeChoiceArgument('airtightness_area', airtightness_choices, false)
231
+ airtightness_area.setDefaultValue('5-sided')
232
+ airtightness_area.setDisplayName('Airtightness exterior surface area scope')
233
+ airtightness_area.setDescription('Airtightness measurements are weighted by exterior surface area. 4-sided values divide infiltration by exterior wall area. 5-sided values additionally include roof area. 6-sided values additionally include floor and ground area.')
234
+ args << airtightness_area
235
+
236
+ # air barrier
237
+ air_barrier = OpenStudio::Measure::OSArgument::makeBoolArgument('air_barrier', false)
238
+ air_barrier.setDefaultValue(false)
239
+ air_barrier.setDisplayName('Does the building have an air barrier?')
240
+ air_barrier.setDescription('Buildings with air barriers use a different set of coefficients.')
241
+ args << air_barrier
242
+
243
+ # populate choice argument for schedules in the model
244
+ sch_handles = OpenStudio::StringVector.new
245
+ sch_display_names = OpenStudio::StringVector.new
246
+
247
+ # populate choice argument for schedules that are applied to surfaces in the model
248
+ schedule_handles = OpenStudio::StringVector.new
249
+ schedule_display_names = OpenStudio::StringVector.new
250
+
251
+ # putting space types and names into hash
252
+ schedule_names = []
253
+ schedule_names << 'Lookup From Model'
254
+ model.getScheduleRulesets.each { |sch| schedule_names << sch.name.to_s }
255
+ model.getScheduleConstants.each { |sch| schedule_names << sch.name.to_s }
256
+
257
+ # hvac operation schedule
258
+ hvac_schedule = OpenStudio::Measure::OSArgument::makeChoiceArgument('hvac_schedule', schedule_names, false, true)
259
+ hvac_schedule.setDefaultValue('Lookup From Model')
260
+ hvac_schedule.setDisplayName('HVAC Operating Schedule')
261
+ hvac_schedule.setDescription('Choose the HVAC Operating Schedule for the building. The schedule must be a Schedule Constant or Schedule Ruleset object. Lookup From Model will use the operating schedule from the largest airloop by floor area served. If the largest airloop serves less than 5% of the building, the measure will attempt to use the Building Hours of Operation schedule instead.')
262
+ args << hvac_schedule
263
+
264
+ # climate zone options
265
+ cz_choices = OpenStudio::StringVector.new
266
+ cz_choices << '1A'
267
+ cz_choices << '1B'
268
+ cz_choices << '2A'
269
+ cz_choices << '2B'
270
+ cz_choices << '3A'
271
+ cz_choices << '3B'
272
+ cz_choices << '3C'
273
+ cz_choices << '4A'
274
+ cz_choices << '4B'
275
+ cz_choices << '4C'
276
+ cz_choices << '5A'
277
+ cz_choices << '5B'
278
+ cz_choices << '5C'
279
+ cz_choices << '6A'
280
+ cz_choices << '6B'
281
+ cz_choices << '7A'
282
+ cz_choices << '8A'
283
+ cz_choices << 'Lookup From Model'
284
+
285
+ # climate zone
286
+ climate_zone = OpenStudio::Measure::OSArgument.makeChoiceArgument('climate_zone', cz_choices, false)
287
+ climate_zone.setDefaultValue('Lookup From Model')
288
+ climate_zone.setDisplayName('Climate Zone')
289
+ climate_zone.setDescription('Specify the ASHRAE climate zone. CEC climate zones are not supported.')
290
+ args << climate_zone
291
+
292
+ # building type options
293
+ building_types = nist_building_types
294
+ building_types << 'Lookup From Model'
295
+
296
+ # building type
297
+ building_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('building_type', building_types, false)
298
+ building_type.setDefaultValue('Lookup From Model')
299
+ building_type.setDisplayName('Building Type')
300
+ building_type.setDescription('If the building type is not available, pick the one with the most similar geometry and exhaust fan flow rates.')
301
+ args << building_type
302
+
303
+ return args
304
+ end
305
+
306
+ # define what happens when the measure is run
307
+ def run(model, runner, user_arguments)
308
+ super(model, runner, user_arguments)
309
+
310
+ # use the built-in error checking
311
+ if !runner.validateUserArguments(arguments(model), user_arguments)
312
+ return false
313
+ end
314
+
315
+ # assign the user inputs to variables
316
+ airtightness_value = runner.getDoubleArgumentValue('airtightness_value', user_arguments)
317
+ airtightness_pressure = runner.getDoubleArgumentValue('airtightness_pressure', user_arguments)
318
+ airtightness_area = runner.getStringArgumentValue('airtightness_area', user_arguments)
319
+ air_barrier = runner.getBoolArgumentValue('air_barrier', user_arguments)
320
+ hvac_schedule = runner.getStringArgumentValue('hvac_schedule', user_arguments)
321
+ climate_zone = runner.getStringArgumentValue('climate_zone', user_arguments)
322
+ building_type = runner.getStringArgumentValue('building_type', user_arguments)
323
+
324
+ # validate airtightness value and pressure
325
+ if airtightness_value < 0.0
326
+ runner.registerError('Airtightness value must be postive.')
327
+ return false
328
+ end
329
+
330
+ if airtightness_pressure < 0.0
331
+ runner.registerError('Airtightness pressure must be postive.')
332
+ return false
333
+ end
334
+
335
+ # calculate infiltration design value at 4 Pa
336
+ airtightness_value_4pa_per_hr = airtightness_value * ((4.0 / airtightness_pressure)**0.65)
337
+ runner.registerInfo("User-inputed airtightness design value #{airtightness_value} (m^3/h-m^2) at #{airtightness_pressure} Pa converts to #{airtightness_value_4pa_per_hr.round(7)} (m^3/h-m^2) at 4 Pa")
338
+
339
+ # convert to m^3/s-m^2
340
+ airtightness_value_4pa_per_s = airtightness_value_4pa_per_hr / 3600.0
341
+
342
+ # get 4-sided, 5-sided, and 6-sided areas
343
+ exterior_wall_area = 0.0
344
+ exterior_roof_area = 0.0
345
+ exterior_floor_area = 0.0
346
+ ground_wall_area = 0.0
347
+ ground_roof_area = 0.0
348
+ ground_floor_area = 0.0
349
+ model.getSurfaces.each do |surface|
350
+ bc = surface.outsideBoundaryCondition
351
+ type = surface.surfaceType
352
+ area = surface.grossArea
353
+ exterior_wall_area += area if bc == 'Outdoors' && type == 'Wall'
354
+ exterior_roof_area += area if bc == 'Outdoors' && type == 'RoofCeiling'
355
+ exterior_floor_area += area if bc == 'Outdoors' && type == 'Floor'
356
+ ground_wall_area += area if bc == 'Ground' && type == 'Wall'
357
+ ground_roof_area += area if bc == 'Ground' && type == 'RoofCeiling'
358
+ ground_floor_area += area if bc == 'Ground' && type == 'Floor'
359
+ end
360
+ four_sided_area = exterior_wall_area + ground_wall_area
361
+ five_sided_area = exterior_wall_area + ground_wall_area + exterior_roof_area + ground_roof_area
362
+ six_sided_area = exterior_wall_area + ground_wall_area + exterior_roof_area + ground_roof_area + exterior_floor_area + ground_floor_area
363
+ energy_plus_area = exterior_wall_area + exterior_roof_area
364
+ runner.registerInfo("4-sided area = #{four_sided_area.round(2)} m^2, 5-sided area = #{five_sided_area.round(2)} m^2, 6-sided area = #{six_sided_area.round(2)} m^2.")
365
+
366
+ # The SpaceInfiltrationDesignFlowRate object FlowperExteriorSurfaceArea method only counts surfaces with the 'Outdoors' boundary conditions towards exterior surface area, not surfaces with the 'Ground' boundary conditions. That means all values need to be normalized to exterior wall and roof area.
367
+ case airtightness_area
368
+ when '4-sided'
369
+ design_infiltration_4pa = airtightness_value_4pa_per_s * (four_sided_area / energy_plus_area)
370
+ runner.registerInfo("#{airtightness_area} infiltration design value #{airtightness_value_4pa_per_s.round(7)} (m^3/s-m^2) converted to #{design_infiltration_4pa.round(7)} (m^3/s-m^2) based on 4-sided area #{four_sided_area.round(2)} m^2 and 5-sided area #{energy_plus_area.round(2)} m^2 excluding ground boundary surfaces for energyplus.")
371
+ when '5-sided'
372
+ design_infiltration_4pa = airtightness_value_4pa_per_s * (five_sided_area / energy_plus_area)
373
+ runner.registerInfo("#{airtightness_area} infiltration design value #{airtightness_value_4pa_per_s.round(7)} (m^3/s-m^2) converted to #{design_infiltration_4pa.round(7)} (m^3/s-m^2) based on 5-sided area #{five_sided_area.round(2)} m^2 and 5-sided area #{energy_plus_area.round(2)} m^2 excluding ground boundary surfaces for energyplus.")
374
+ when '6-sided'
375
+ design_infiltration_4pa = airtightness_value_4pa_per_s * (six_sided_area / energy_plus_area)
376
+ runner.registerInfo("#{airtightness_area} infiltration design value #{airtightness_value_4pa_per_s.round(7)} (m^3/s-m^2) converted to #{design_infiltration_4pa.round(7)} (m^3/s-m^2) based on 6-sided area #{six_sided_area.round(2)} m^2 and 5-sided area #{energy_plus_area.round(2)} m^2 excluding ground boundary surfaces for energyplus.")
377
+ end
378
+ runner.registerValue('design_infiltration_4pa', design_infiltration_4pa, 'm/s')
379
+
380
+ # validate hvac schedule
381
+ if hvac_schedule == 'Lookup From Model'
382
+ # lookup from model, using largest air loop
383
+ # check multiple kinds of systems, including unitary systems
384
+ hvac_schedule = nil
385
+ largest_area = 0.0
386
+
387
+ model.getAirLoopHVACs.each do |air_loop|
388
+ air_loop_area = 0.0
389
+ air_loop.thermalZones.each { |tz| air_loop_area += tz.floorArea }
390
+ if air_loop_area > largest_area
391
+ hvac_schedule = air_loop.availabilitySchedule
392
+ largest_area = air_loop_area
393
+ end
394
+ end
395
+
396
+ model.getAirLoopHVACUnitarySystems.each do |unitary|
397
+ next unless unitary.thermalZone.is_initialized
398
+ air_loop_area = unitary.thermalZone.get.floorArea
399
+ if air_loop_area > largest_area
400
+ if unitary.availabilitySchedule.is_initialized
401
+ hvac_schedule = unitary.availabilitySchedule.get
402
+ else
403
+ hvac_schedule = model.alwaysOnDiscreteSchedule
404
+ end
405
+ largest_area = air_loop_area
406
+ end
407
+ end
408
+
409
+ model.getAirLoopHVACUnitaryHeatPumpAirToAirs.each do |unitary|
410
+ next unless unitary.controllingZone.is_initialized
411
+ air_loop_area = unitary.controllingZone.get.floorArea
412
+ if air_loop_area > largest_area
413
+ hvac_schedule = unitary.availabilitySchedule.get
414
+ largest_area = air_loop_area
415
+ end
416
+ end
417
+
418
+ model.getAirLoopHVACUnitaryHeatPumpAirToAirMultiSpeeds.each do |unitary|
419
+ next unless unitary.controllingZoneorThermostatLocation.is_initialized
420
+ air_loop_area = unitary.controllingZoneorThermostatLocation.get.floorArea
421
+ if air_loop_area > largest_area
422
+ if unitary.availabilitySchedule.is_initialized
423
+ hvac_schedule = unitary.availabilitySchedule.get
424
+ else
425
+ hvac_schedule = model.alwaysOnDiscreteSchedule
426
+ end
427
+ largest_area = air_loop_area
428
+ end
429
+ end
430
+
431
+ model.getFanZoneExhausts.each do |fan|
432
+ next unless fan.thermalZone.is_initialized
433
+ air_loop_area = fan.thermalZone.get.floorArea
434
+ if air_loop_area > largest_area
435
+ if fan.availabilitySchedule.is_initialized
436
+ hvac_schedule = fan.availabilitySchedule.get
437
+ else
438
+ hvac_schedule = model.alwaysOnDiscreteSchedule
439
+ end
440
+ largest_area = air_loop_area
441
+ end
442
+ end
443
+
444
+ building_area = model.getBuilding.floorArea
445
+ if largest_area < 0.05*building_area
446
+ runner.registerWarning("The largest airloop or HVAC system serves #{largest_area.round(1)} m^2, which is less than 5% of the building area #{building_area.round(1)} m^2. Attempting to use building hours of operation schedule instead.")
447
+ default_schedule_set = model.getBuilding.defaultScheduleSet
448
+ if default_schedule_set.is_initialized
449
+ default_schedule_set = default_schedule_set.get
450
+ hoo = default_schedule_set.hoursofOperationSchedule
451
+ if hoo.is_initialized
452
+ hvac_schedule = hoo.get
453
+ largest_area = building_area
454
+ else
455
+ runner.registerWarning("Unable to determine building hours of operation schedule. Treating the building as if there is no HVAC system schedule.")
456
+ hvac_schedule = nil
457
+ end
458
+ else
459
+ runner.registerWarning("Unable to determine building hours of operation schedule. Treating the building as if there is no HVAC system schedule.")
460
+ hvac_schedule = nil
461
+ end
462
+ end
463
+
464
+ unless hvac_schedule.nil?
465
+ area_fraction = 100.0 * largest_area / building_area
466
+ runner.registerInfo("Using schedule #{hvac_schedule.name} serving area #{largest_area.round(1)} m^2, #{area_fraction.round(0)}% of building area #{building_area.round(1)} m^2 to determine infiltration on/off schedule.")
467
+ end
468
+ else
469
+ hvac_schedule = model.getScheduleByName(hvac_schedule)
470
+ unless schedule_object.is_initialized
471
+ runner.registerError("HVAC schedule argument #{hvac_schedule} not found in the model. IT may have been removed by another measure.")
472
+ return false
473
+ end
474
+ hvac_schedule = hvac_schedule.get
475
+ if hvac_schedule.get.to_ScheduleRuleset.is_initialized
476
+ hvac_schedule = hvac_schedule.get.to_ScheduleRuleset.get
477
+ elsif hvac_schedule.get.to_ScheduleConstant.is_initialized
478
+ hvac_schedule = hvac_schedule.get.to_ScheduleConstant.get
479
+ else
480
+ runner.registerError("HVAC schedule argument #{hvac_schedule} is not a Schedule Constant or Schedule Ruleset object.")
481
+ return false
482
+ end
483
+
484
+ runner.registerInfo("Using HVAC schedule #{hvac_schedule.name} from user arguments to determine infiltration on/off schedule.")
485
+ end
486
+
487
+ # creating infiltration schedules based on hvac schedule
488
+ if hvac_schedule.nil?
489
+ runner.registerWarning('Unable to determine the HVAC schedule. Treating the building as if there is no HVAC system with outdoor air. If this is not the case, input a schedule argument, or assign one to an air loop in the model.')
490
+ on_schedule = OpenStudio::Model::ScheduleConstant.new(model)
491
+ on_schedule.setName("Infiltration HVAC On Schedule")
492
+ on_schedule.setValue(0.0)
493
+ off_schedule = OpenStudio::Model::ScheduleConstant.new(model)
494
+ off_schedule.setName("Infiltration HVAC Off Schedule")
495
+ off_schedule.setValue(1.0)
496
+ elsif hvac_schedule.to_ScheduleConstant.is_initialized
497
+ hvac_schedule = hvac_schedule.to_ScheduleConstant.get
498
+ on_schedule = OpenStudio::Model::ScheduleConstant.new(model)
499
+ on_schedule.setName("Infiltration HVAC On Schedule")
500
+ on_schedule.setValue(hvac_schedule.value)
501
+ off_schedule = OpenStudio::Model::ScheduleConstant.new(model)
502
+ off_schedule.setName("Infiltration HVAC Off Schedule")
503
+ if hvac_schedule.value > 0
504
+ off_schedule.setValue(0.0)
505
+ else
506
+ off_schedule.setValue(1.0)
507
+ end
508
+ elsif hvac_schedule.to_ScheduleRuleset.is_initialized
509
+ hvac_schedule = hvac_schedule.to_ScheduleRuleset.get
510
+ on_schedule = hvac_schedule.clone.to_ScheduleRuleset.get
511
+ on_schedule.setName("Infiltration HVAC On Schedule")
512
+ off_schedule = invert_schedule_ruleset(hvac_schedule, 'Infiltration HVAC Off Schedule')
513
+ end
514
+
515
+ # validate climate zone
516
+ if climate_zone == 'Lookup From Model'
517
+ climate_zone = ''
518
+ model.getClimateZones.climateZones.each do |cz|
519
+ next if cz.value == ''
520
+ cz_institution = cz.institution
521
+ if cz_institution == 'ASHRAE'
522
+ climate_zone = cz.value
523
+ climate_zone = climate_zone.gsub('ASHRAE 169-2006-','')
524
+ climate_zone = climate_zone.gsub('ASHRAE 169-2013-','')
525
+ climate_zone = climate_zone.gsub('ASHRAE 169-2020-','')
526
+ climate_zone = climate_zone.gsub('ASHRAE 169-2021-','')
527
+ elsif cz_institution == 'CEC'
528
+ california_cz = cz.value.gsub('CEC','')
529
+ case california_cz
530
+ when '1'
531
+ climate_zone = '4B'
532
+ when '2','3','4','5','6'
533
+ climate_zone = '3C'
534
+ when '7','8','9','10','11','12','13','14'
535
+ climate_zone = '3B'
536
+ when '15'
537
+ climate_zone = '2B'
538
+ when '16'
539
+ climate_zone = '5B'
540
+ end
541
+ runner.registerWarning("Using ASHRAE climate zone #{climate_zone} for California climate zone #{california_cz}.")
542
+ end
543
+ end
544
+
545
+ if climate_zone == ''
546
+ runner.registerError('Unable to determine an ASHRAE climate zone for the model. An ASHRAE climate zone value is necessary to lookup the coefficients.')
547
+ return false
548
+ end
549
+
550
+ runner.registerInfo("Using climate zone #{climate_zone} from model.")
551
+ else
552
+ runner.registerInfo("Using climate zone #{climate_zone} from user arguments.")
553
+ end
554
+
555
+ # get climate zone number
556
+ climate_zone_number = climate_zone.delete('^0-9').to_i
557
+
558
+ # validate building type
559
+ if building_type == 'Lookup From Model'
560
+
561
+ # get building type from the model
562
+ building_type_data = infer_nist_building_type(model)
563
+ model_building_type = building_type_data['model_building_type']
564
+ nist_building_type = building_type_data['nist_building_type']
565
+ building_type = nist_building_type
566
+
567
+ # check that model building type is supported
568
+ unless nist_building_types.include? nist_building_type
569
+ runner.registerError("NIST coefficients are not available for model building type #{nist_building_type}.")
570
+ return false
571
+ end
572
+
573
+ # warn the user if the model building type is different from support nist building types
574
+ unless model_building_type == nist_building_type
575
+ runner.registerWarning("Using building type #{building_type} for model building type #{model_building_type}.")
576
+ else
577
+ runner.registerInfo("Using building type #{building_type} from model.")
578
+ end
579
+ else
580
+ runner.registerInfo("Using building type #{building_type} from user arguments.")
581
+ end
582
+
583
+ # remove existing infiltration objects
584
+ runner.registerInitialCondition("The modeled started with #{model.getSpaceInfiltrationDesignFlowRates.size} infiltration objects and #{model.getSpaceInfiltrationEffectiveLeakageAreas.size} effective leakage area objects.")
585
+ model.getSpaceInfiltrationDesignFlowRates.each(&:remove)
586
+ model.getSpaceInfiltrationEffectiveLeakageAreas.each(&:remove)
587
+
588
+ # load NIST infiltration correlations file and convert to hash table
589
+ nist_infiltration_correlations_csv = "#{File.dirname(__FILE__)}/resources/Data-NISTInfiltrationCorrelations.csv"
590
+ if not File.file?(nist_infiltration_correlations_csv)
591
+ runner.registerError("Unable to find file: #{nist_infiltration_correlations_csv}")
592
+ return nil
593
+ end
594
+ coefficients_tbl = CSV.table(nist_infiltration_correlations_csv)
595
+ coefficients_hsh = coefficients_tbl.map { |row| row.to_hash }
596
+
597
+ # select down to building type and climate zone
598
+ coefficients = coefficients_hsh.select { |r| (r[:building_type] == building_type) && (r[:climate_zone] == climate_zone_number) }
599
+
600
+ # filter by air barrier
601
+ if air_barrier
602
+ coefficients = coefficients.select { |r| r[:air_barrier] == 'yes'}
603
+ else
604
+ coefficients = coefficients.select { |r| r[:air_barrier] == 'no'}
605
+ end
606
+
607
+ # determine coefficients
608
+ # if no off coefficients are defined, use 0 for a and the on coefficients for b and d
609
+ on_coefficients = coefficients.select { |r| r[:hvac_status] == 'on'}
610
+ off_coefficients = coefficients.select { |r| r[:hvac_status] == 'off'}
611
+ a_on = on_coefficients[0][:a]
612
+ b_on = on_coefficients[0][:b]
613
+ d_on = on_coefficients[0][:d]
614
+ a_off = off_coefficients[0][:a].nil? ? on_coefficients[0][:a] : off_coefficients[0][:a]
615
+ b_off = off_coefficients[0][:b].nil? ? on_coefficients[0][:b] : off_coefficients[0][:b]
616
+ d_off = off_coefficients[0][:d].nil? ? on_coefficients[0][:d] : off_coefficients[0][:d]
617
+
618
+ # add new infiltration objects
619
+ # define infiltration as flow per exterior area
620
+ model.getSpaces.each do |space|
621
+ next unless space.exteriorArea > 0.0
622
+
623
+ hvac_on_infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(model)
624
+ hvac_on_infiltration.setName("#{space.name.get} HVAC On Infiltration")
625
+ hvac_on_infiltration.setFlowperExteriorSurfaceArea(design_infiltration_4pa)
626
+ hvac_on_infiltration.setConstantTermCoefficient(a_on)
627
+ hvac_on_infiltration.setTemperatureTermCoefficient(b_on)
628
+ hvac_on_infiltration.setVelocityTermCoefficient(0.0)
629
+ hvac_on_infiltration.setVelocitySquaredTermCoefficient(d_on)
630
+ hvac_on_infiltration.setSpace(space)
631
+ hvac_on_infiltration.setSchedule(on_schedule)
632
+
633
+ hvac_off_infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(model)
634
+ hvac_off_infiltration.setName("#{space.name.get} HVAC Off Infiltration")
635
+ hvac_off_infiltration.setFlowperExteriorSurfaceArea(design_infiltration_4pa)
636
+ hvac_off_infiltration.setConstantTermCoefficient(a_off)
637
+ hvac_off_infiltration.setTemperatureTermCoefficient(b_off)
638
+ hvac_off_infiltration.setVelocityTermCoefficient(0.0)
639
+ hvac_off_infiltration.setVelocitySquaredTermCoefficient(d_off)
640
+ hvac_off_infiltration.setSpace(space)
641
+ hvac_off_infiltration.setSchedule(off_schedule)
642
+
643
+ end
644
+
645
+ runner.registerFinalCondition("The modeled finished with #{model.getSpaceInfiltrationDesignFlowRates.size} infiltration objects.")
646
+
647
+ return true
648
+ end
649
+ end
650
+
651
+ # register the measure to be used by the application
652
+ SetNISTInfiltrationCorrelations.new.registerWithApplication