openstudio-calibration 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +29 -0
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile +20 -0
  5. data/Jenkinsfile +6 -0
  6. data/LICENSE.md +27 -0
  7. data/README.md +33 -0
  8. data/Rakefile +50 -0
  9. data/doc_templates/LICENSE.md +27 -0
  10. data/doc_templates/README.md.erb +42 -0
  11. data/doc_templates/copyright_erb.txt +36 -0
  12. data/doc_templates/copyright_js.txt +4 -0
  13. data/doc_templates/copyright_ruby.txt +34 -0
  14. data/lib/files/.gitkeep +0 -0
  15. data/lib/measures/AddMonthlyJSONUtilityData/LICENSE.md +27 -0
  16. data/lib/measures/AddMonthlyJSONUtilityData/README.md +96 -0
  17. data/lib/measures/AddMonthlyJSONUtilityData/README.md.erb +42 -0
  18. data/lib/measures/AddMonthlyJSONUtilityData/measure.rb +280 -0
  19. data/lib/measures/AddMonthlyJSONUtilityData/measure.xml +163 -0
  20. data/lib/measures/AddMonthlyUtilityData/LICENSE.md +27 -0
  21. data/lib/measures/AddMonthlyUtilityData/README.md +64 -0
  22. data/lib/measures/AddMonthlyUtilityData/README.md.erb +42 -0
  23. data/lib/measures/AddMonthlyUtilityData/measure.rb +312 -0
  24. data/lib/measures/AddMonthlyUtilityData/measure.xml +115 -0
  25. data/lib/measures/AddMonthlyUtilityData/tests/AddMonthlyUtilityData_Test.rb +88 -0
  26. data/lib/measures/AddMonthlyUtilityData/tests/electric_billed_usages.json +198 -0
  27. data/lib/measures/AddMonthlyUtilityData/tests/gas_billed_usages.json +198 -0
  28. data/lib/measures/CalibrationReports/LICENSE.md +27 -0
  29. data/lib/measures/CalibrationReports/README.md +26 -0
  30. data/lib/measures/CalibrationReports/README.md.erb +42 -0
  31. data/lib/measures/CalibrationReports/measure.rb +511 -0
  32. data/lib/measures/CalibrationReports/measure.xml +98 -0
  33. data/lib/measures/CalibrationReports/resources/report.html.in +379 -0
  34. data/lib/measures/CalibrationReports/tests/CalibrationReports_Test.rb +523 -0
  35. data/lib/measures/CalibrationReports/tests/ExampleModel.osm +10497 -0
  36. data/lib/measures/CalibrationReports/tests/ExampleModelNoDemandInput.osm +10560 -0
  37. data/lib/measures/CalibrationReports/tests/ExampleModelNoGasInput.osm +10456 -0
  38. data/lib/measures/CalibrationReports/tests/USA_CO_Golden-NREL.724666_TMY3.epw +8768 -0
  39. data/lib/measures/CalibrationReportsEnhanced/LICENSE.md +27 -0
  40. data/lib/measures/CalibrationReportsEnhanced/README.md +143 -0
  41. data/lib/measures/CalibrationReportsEnhanced/README.md.erb +42 -0
  42. data/lib/measures/CalibrationReportsEnhanced/measure.rb +798 -0
  43. data/lib/measures/CalibrationReportsEnhanced/measure.xml +372 -0
  44. data/lib/measures/CalibrationReportsEnhanced/resources/report.html.in +380 -0
  45. data/lib/measures/CalibrationReportsEnhanced/tests/CalibrationReportsEnhanced_Test.rb +734 -0
  46. data/lib/measures/CalibrationReportsEnhanced/tests/ExampleModel.osm +10497 -0
  47. data/lib/measures/CalibrationReportsEnhanced/tests/ExampleModel_FuelOil.osm +12740 -0
  48. data/lib/measures/CalibrationReportsEnhanced/tests/USA_CO_Golden-NREL.724666_TMY3.epw +8768 -0
  49. data/lib/measures/CalibrationReportsEnhanced21/LICENSE.md +27 -0
  50. data/lib/measures/CalibrationReportsEnhanced21/README.md +109 -0
  51. data/lib/measures/CalibrationReportsEnhanced21/README.md.erb +42 -0
  52. data/lib/measures/CalibrationReportsEnhanced21/measure.rb +690 -0
  53. data/lib/measures/CalibrationReportsEnhanced21/measure.xml +269 -0
  54. data/lib/measures/CalibrationReportsEnhanced21/resources/report.html.in +380 -0
  55. data/lib/measures/CoilCoolingDXSingleSpeedMultiplier/LICENSE.md +27 -0
  56. data/lib/measures/CoilCoolingDXSingleSpeedMultiplier/README.md +48 -0
  57. data/lib/measures/CoilCoolingDXSingleSpeedMultiplier/README.md.erb +42 -0
  58. data/lib/measures/CoilCoolingDXSingleSpeedMultiplier/measure.rb +237 -0
  59. data/lib/measures/CoilCoolingDXSingleSpeedMultiplier/measure.xml +93 -0
  60. data/lib/measures/CoilCoolingDXSingleSpeedPercentChange/LICENSE.md +27 -0
  61. data/lib/measures/CoilCoolingDXSingleSpeedPercentChange/README.md +48 -0
  62. data/lib/measures/CoilCoolingDXSingleSpeedPercentChange/README.md.erb +42 -0
  63. data/lib/measures/CoilCoolingDXSingleSpeedPercentChange/measure.rb +228 -0
  64. data/lib/measures/CoilCoolingDXSingleSpeedPercentChange/measure.xml +93 -0
  65. data/lib/measures/CoilCoolingDXTwoSpeedMultiplier/LICENSE.md +27 -0
  66. data/lib/measures/CoilCoolingDXTwoSpeedMultiplier/README.md +64 -0
  67. data/lib/measures/CoilCoolingDXTwoSpeedMultiplier/README.md.erb +42 -0
  68. data/lib/measures/CoilCoolingDXTwoSpeedMultiplier/measure.rb +280 -0
  69. data/lib/measures/CoilCoolingDXTwoSpeedMultiplier/measure.xml +111 -0
  70. data/lib/measures/CoilCoolingDXTwoSpeedPercentChange/LICENSE.md +27 -0
  71. data/lib/measures/CoilCoolingDXTwoSpeedPercentChange/README.md +64 -0
  72. data/lib/measures/CoilCoolingDXTwoSpeedPercentChange/README.md.erb +42 -0
  73. data/lib/measures/CoilCoolingDXTwoSpeedPercentChange/measure.rb +270 -0
  74. data/lib/measures/CoilCoolingDXTwoSpeedPercentChange/measure.xml +111 -0
  75. data/lib/measures/CoilCoolingWaterMultiplier/LICENSE.md +27 -0
  76. data/lib/measures/CoilCoolingWaterMultiplier/README.md +80 -0
  77. data/lib/measures/CoilCoolingWaterMultiplier/README.md.erb +42 -0
  78. data/lib/measures/CoilCoolingWaterMultiplier/measure.rb +324 -0
  79. data/lib/measures/CoilCoolingWaterMultiplier/measure.xml +129 -0
  80. data/lib/measures/CoilCoolingWaterPercentChange/LICENSE.md +27 -0
  81. data/lib/measures/CoilCoolingWaterPercentChange/README.md +80 -0
  82. data/lib/measures/CoilCoolingWaterPercentChange/README.md.erb +42 -0
  83. data/lib/measures/CoilCoolingWaterPercentChange/measure.rb +311 -0
  84. data/lib/measures/CoilCoolingWaterPercentChange/measure.xml +129 -0
  85. data/lib/measures/CoilHeatingElectricMultiplier/LICENSE.md +27 -0
  86. data/lib/measures/CoilHeatingElectricMultiplier/README.md +48 -0
  87. data/lib/measures/CoilHeatingElectricMultiplier/README.md.erb +42 -0
  88. data/lib/measures/CoilHeatingElectricMultiplier/measure.rb +240 -0
  89. data/lib/measures/CoilHeatingElectricMultiplier/measure.xml +93 -0
  90. data/lib/measures/CoilHeatingElectricPercentChange/LICENSE.md +27 -0
  91. data/lib/measures/CoilHeatingElectricPercentChange/README.md +48 -0
  92. data/lib/measures/CoilHeatingElectricPercentChange/README.md.erb +42 -0
  93. data/lib/measures/CoilHeatingElectricPercentChange/measure.rb +231 -0
  94. data/lib/measures/CoilHeatingElectricPercentChange/measure.xml +93 -0
  95. data/lib/measures/CoilHeatingGasMultiplier/LICENSE.md +27 -0
  96. data/lib/measures/CoilHeatingGasMultiplier/README.md +64 -0
  97. data/lib/measures/CoilHeatingGasMultiplier/README.md.erb +42 -0
  98. data/lib/measures/CoilHeatingGasMultiplier/measure.rb +282 -0
  99. data/lib/measures/CoilHeatingGasMultiplier/measure.xml +111 -0
  100. data/lib/measures/CoilHeatingGasPercentChange/LICENSE.md +27 -0
  101. data/lib/measures/CoilHeatingGasPercentChange/README.md +64 -0
  102. data/lib/measures/CoilHeatingGasPercentChange/README.md.erb +42 -0
  103. data/lib/measures/CoilHeatingGasPercentChange/measure.rb +271 -0
  104. data/lib/measures/CoilHeatingGasPercentChange/measure.xml +111 -0
  105. data/lib/measures/CoilHeatingWaterMultiplier/LICENSE.md +27 -0
  106. data/lib/measures/CoilHeatingWaterMultiplier/README.md +48 -0
  107. data/lib/measures/CoilHeatingWaterMultiplier/README.md.erb +42 -0
  108. data/lib/measures/CoilHeatingWaterMultiplier/measure.rb +235 -0
  109. data/lib/measures/CoilHeatingWaterMultiplier/measure.xml +93 -0
  110. data/lib/measures/CoilHeatingWaterPercentChange/LICENSE.md +27 -0
  111. data/lib/measures/CoilHeatingWaterPercentChange/README.md +48 -0
  112. data/lib/measures/CoilHeatingWaterPercentChange/README.md.erb +42 -0
  113. data/lib/measures/CoilHeatingWaterPercentChange/measure.rb +226 -0
  114. data/lib/measures/CoilHeatingWaterPercentChange/measure.xml +93 -0
  115. data/lib/measures/ConstructionLayerZeroMaterialProperties/LICENSE.md +27 -0
  116. data/lib/measures/ConstructionLayerZeroMaterialProperties/README.md +88 -0
  117. data/lib/measures/ConstructionLayerZeroMaterialProperties/README.md.erb +42 -0
  118. data/lib/measures/ConstructionLayerZeroMaterialProperties/measure.rb +221 -0
  119. data/lib/measures/ConstructionLayerZeroMaterialProperties/measure.xml +194 -0
  120. data/lib/measures/ElectricBaseboardEfficiencyAndCapacity/LICENSE.md +27 -0
  121. data/lib/measures/ElectricBaseboardEfficiencyAndCapacity/README.md +40 -0
  122. data/lib/measures/ElectricBaseboardEfficiencyAndCapacity/README.md.erb +42 -0
  123. data/lib/measures/ElectricBaseboardEfficiencyAndCapacity/measure.rb +102 -0
  124. data/lib/measures/ElectricBaseboardEfficiencyAndCapacity/measure.xml +78 -0
  125. data/lib/measures/ExteriorWallThermalPropertiesMultiplier/LICENSE.md +27 -0
  126. data/lib/measures/ExteriorWallThermalPropertiesMultiplier/README.md +48 -0
  127. data/lib/measures/ExteriorWallThermalPropertiesMultiplier/README.md.erb +42 -0
  128. data/lib/measures/ExteriorWallThermalPropertiesMultiplier/measure.rb +263 -0
  129. data/lib/measures/ExteriorWallThermalPropertiesMultiplier/measure.xml +97 -0
  130. data/lib/measures/ExteriorWallThermalPropertiesPercentChange/LICENSE.md +27 -0
  131. data/lib/measures/ExteriorWallThermalPropertiesPercentChange/README.md +48 -0
  132. data/lib/measures/ExteriorWallThermalPropertiesPercentChange/README.md.erb +42 -0
  133. data/lib/measures/ExteriorWallThermalPropertiesPercentChange/measure.rb +253 -0
  134. data/lib/measures/ExteriorWallThermalPropertiesPercentChange/measure.xml +97 -0
  135. data/lib/measures/FansMultiplier/LICENSE.md +27 -0
  136. data/lib/measures/FansMultiplier/README.md +64 -0
  137. data/lib/measures/FansMultiplier/README.md.erb +42 -0
  138. data/lib/measures/FansMultiplier/measure.rb +297 -0
  139. data/lib/measures/FansMultiplier/measure.xml +166 -0
  140. data/lib/measures/FansPercentChange/LICENSE.md +27 -0
  141. data/lib/measures/FansPercentChange/README.md +64 -0
  142. data/lib/measures/FansPercentChange/README.md.erb +42 -0
  143. data/lib/measures/FansPercentChange/measure.rb +286 -0
  144. data/lib/measures/FansPercentChange/measure.xml +166 -0
  145. data/lib/measures/GeneralCalibrationMeasureMultiplier/LICENSE.md +27 -0
  146. data/lib/measures/GeneralCalibrationMeasureMultiplier/README.md +112 -0
  147. data/lib/measures/GeneralCalibrationMeasureMultiplier/README.md.erb +42 -0
  148. data/lib/measures/GeneralCalibrationMeasureMultiplier/measure.rb +639 -0
  149. data/lib/measures/GeneralCalibrationMeasureMultiplier/measure.xml +229 -0
  150. data/lib/measures/GeneralCalibrationMeasurePercentChange/LICENSE.md +27 -0
  151. data/lib/measures/GeneralCalibrationMeasurePercentChange/README.md +112 -0
  152. data/lib/measures/GeneralCalibrationMeasurePercentChange/README.md.erb +42 -0
  153. data/lib/measures/GeneralCalibrationMeasurePercentChange/measure.rb +756 -0
  154. data/lib/measures/GeneralCalibrationMeasurePercentChange/measure.xml +229 -0
  155. data/lib/measures/HardSizeHvac/LICENSE.md +27 -0
  156. data/lib/measures/HardSizeHvac/README.md +26 -0
  157. data/lib/measures/HardSizeHvac/README.md.erb +42 -0
  158. data/lib/measures/HardSizeHvac/measure.rb +88 -0
  159. data/lib/measures/HardSizeHvac/measure.xml +81 -0
  160. data/lib/measures/MaalkaMonthlyJSONUtilityData/LICENSE.md +27 -0
  161. data/lib/measures/MaalkaMonthlyJSONUtilityData/README.md +104 -0
  162. data/lib/measures/MaalkaMonthlyJSONUtilityData/README.md.erb +42 -0
  163. data/lib/measures/MaalkaMonthlyJSONUtilityData/measure.rb +304 -0
  164. data/lib/measures/MaalkaMonthlyJSONUtilityData/measure.xml +216 -0
  165. data/lib/measures/RValueOfInsulationForConstructionMultiplier/LICENSE.md +27 -0
  166. data/lib/measures/RValueOfInsulationForConstructionMultiplier/README.md +40 -0
  167. data/lib/measures/RValueOfInsulationForConstructionMultiplier/README.md.erb +42 -0
  168. data/lib/measures/RValueOfInsulationForConstructionMultiplier/measure.rb +196 -0
  169. data/lib/measures/RValueOfInsulationForConstructionMultiplier/measure.xml +132 -0
  170. data/lib/measures/RValueOfInsulationForConstructionPercentageChange/LICENSE.md +27 -0
  171. data/lib/measures/RValueOfInsulationForConstructionPercentageChange/README.md +40 -0
  172. data/lib/measures/RValueOfInsulationForConstructionPercentageChange/README.md.erb +42 -0
  173. data/lib/measures/RValueOfInsulationForConstructionPercentageChange/measure.rb +189 -0
  174. data/lib/measures/RValueOfInsulationForConstructionPercentageChange/measure.xml +132 -0
  175. data/lib/measures/RoofThermalPropertiesMultiplier/LICENSE.md +27 -0
  176. data/lib/measures/RoofThermalPropertiesMultiplier/README.md +48 -0
  177. data/lib/measures/RoofThermalPropertiesMultiplier/README.md.erb +42 -0
  178. data/lib/measures/RoofThermalPropertiesMultiplier/measure.rb +263 -0
  179. data/lib/measures/RoofThermalPropertiesMultiplier/measure.xml +97 -0
  180. data/lib/measures/RoofThermalPropertiesPercentChange/LICENSE.md +27 -0
  181. data/lib/measures/RoofThermalPropertiesPercentChange/README.md +48 -0
  182. data/lib/measures/RoofThermalPropertiesPercentChange/README.md.erb +42 -0
  183. data/lib/measures/RoofThermalPropertiesPercentChange/measure.rb +253 -0
  184. data/lib/measures/RoofThermalPropertiesPercentChange/measure.xml +97 -0
  185. data/lib/measures/TimeseriesObjectiveFunction/LICENSE.md +27 -0
  186. data/lib/measures/TimeseriesObjectiveFunction/README.md +207 -0
  187. data/lib/measures/TimeseriesObjectiveFunction/README.md.erb +42 -0
  188. data/lib/measures/TimeseriesObjectiveFunction/measure.rb +748 -0
  189. data/lib/measures/TimeseriesObjectiveFunction/measure.xml +435 -0
  190. data/lib/measures/TimeseriesObjectiveFunction/resources/report.html.erb +288 -0
  191. data/lib/measures/TimeseriesPlot/LICENSE.md +27 -0
  192. data/lib/measures/TimeseriesPlot/README.md +56 -0
  193. data/lib/measures/TimeseriesPlot/README.md.erb +42 -0
  194. data/lib/measures/TimeseriesPlot/measure.rb +302 -0
  195. data/lib/measures/TimeseriesPlot/measure.xml +137 -0
  196. data/lib/measures/TimeseriesPlot/resources/report.html.erb +270 -0
  197. data/lib/measures/WaterHeaterMixedMultiplier/LICENSE.md +27 -0
  198. data/lib/measures/WaterHeaterMixedMultiplier/README.md +64 -0
  199. data/lib/measures/WaterHeaterMixedMultiplier/README.md.erb +42 -0
  200. data/lib/measures/WaterHeaterMixedMultiplier/measure.rb +255 -0
  201. data/lib/measures/WaterHeaterMixedMultiplier/measure.xml +180 -0
  202. data/lib/measures/WaterHeaterMixedPercentChange/LICENSE.md +27 -0
  203. data/lib/measures/WaterHeaterMixedPercentChange/README.md +64 -0
  204. data/lib/measures/WaterHeaterMixedPercentChange/README.md.erb +42 -0
  205. data/lib/measures/WaterHeaterMixedPercentChange/measure.rb +245 -0
  206. data/lib/measures/WaterHeaterMixedPercentChange/measure.xml +180 -0
  207. data/lib/measures/zone_report/LICENSE.md +27 -0
  208. data/lib/measures/zone_report/README.md +26 -0
  209. data/lib/measures/zone_report/README.md.erb +42 -0
  210. data/lib/measures/zone_report/measure.rb +706 -0
  211. data/lib/measures/zone_report/measure.xml +67 -0
  212. data/lib/measures/zone_report/resources/report.html.in +342 -0
  213. data/lib/openstudio-calibration-measures.rb +36 -0
  214. data/lib/openstudio/calibration_measures.rb +37 -0
  215. data/lib/openstudio/calibration_measures/extension.rb +49 -0
  216. data/lib/openstudio/calibration_measures/version.rb +40 -0
  217. data/openstudio-calibration.gemspec +30 -0
  218. metadata +331 -0
@@ -0,0 +1,734 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2020, 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 'openstudio'
37
+
38
+ require 'openstudio/ruleset/ShowRunnerOutput'
39
+
40
+ require "#{File.dirname(__FILE__)}/../measure.rb"
41
+
42
+ require 'fileutils'
43
+
44
+ require 'minitest/autorun'
45
+
46
+ class CalibrationReportsEnhanced_Test < Minitest::Test
47
+ def is_openstudio_2?
48
+ begin
49
+ workflow = OpenStudio::WorkflowJSON.new
50
+ rescue StandardError
51
+ return false
52
+ end
53
+ true
54
+ end
55
+
56
+ def model_in_path_default
57
+ "#{File.dirname(__FILE__)}/ExampleModel.osm"
58
+ end
59
+
60
+ def epw_path_default
61
+ # make sure we have a weather data location
62
+ epw = nil
63
+ epw = OpenStudio::Path.new("#{File.dirname(__FILE__)}/USA_CO_Golden-NREL.724666_TMY3.epw")
64
+ assert(File.exist?(epw.to_s))
65
+ epw.to_s
66
+ end
67
+
68
+ def run_dir(test_name)
69
+ # always generate test output in specially named 'output' directory so result files are not made part of the measure
70
+ "#{File.dirname(__FILE__)}/output/#{test_name}"
71
+ end
72
+
73
+ def model_out_path(test_name)
74
+ "#{run_dir(test_name)}/TestOutput.osm"
75
+ end
76
+
77
+ def workspace_path(test_name)
78
+ if is_openstudio_2?
79
+ "#{run_dir(test_name)}/run/in.idf"
80
+ else
81
+ "#{run_dir(test_name)}/ModelToIdf/in.idf"
82
+ end
83
+ end
84
+
85
+ def sql_path(test_name)
86
+ if is_openstudio_2?
87
+ "#{run_dir(test_name)}/run/eplusout.sql"
88
+ else
89
+ "#{run_dir(test_name)}/ModelToIdf/EnergyPlusPreProcess-0/EnergyPlus-0/eplusout.sql"
90
+ end
91
+ end
92
+
93
+ def report_path(test_name)
94
+ "#{run_dir(test_name)}/report.html"
95
+ end
96
+
97
+ # method for running the test simulation using OpenStudio 1.x API
98
+ def setup_test_1(test_name, epw_path)
99
+ co = OpenStudio::Runmanager::ConfigOptions.new(true)
100
+ co.findTools(false, true, false, true)
101
+
102
+ unless File.exist?(sql_path(test_name))
103
+ puts 'Running EnergyPlus'
104
+
105
+ wf = OpenStudio::Runmanager::Workflow.new('modeltoidf->energypluspreprocess->energyplus')
106
+ wf.add(co.getTools)
107
+ job = wf.create(OpenStudio::Path.new(run_dir(test_name)), OpenStudio::Path.new(model_out_path(test_name)), OpenStudio::Path.new(epw_path))
108
+
109
+ rm = OpenStudio::Runmanager::RunManager.new
110
+ rm.enqueue(job, true)
111
+ rm.waitForFinished
112
+ end
113
+ end
114
+
115
+ # method for running the test simulation using OpenStudio 2.x API
116
+ def setup_test_2(test_name, epw_path)
117
+ osw_path = File.join(run_dir(test_name), 'in.osw')
118
+ osw_path = File.absolute_path(osw_path)
119
+
120
+ workflow = OpenStudio::WorkflowJSON.new
121
+ workflow.setSeedFile(File.absolute_path(model_out_path(test_name)))
122
+ workflow.setWeatherFile(File.absolute_path(epw_path))
123
+ workflow.saveAs(osw_path)
124
+
125
+ cli_path = OpenStudio.getOpenStudioCLI
126
+ cmd = "\"#{cli_path}\" run -w \"#{osw_path}\""
127
+ puts cmd
128
+ system(cmd)
129
+ end
130
+
131
+ # create test files if they do not exist when the test first runs
132
+ def setup_test(test_name, idf_output_requests, model_in_path = model_in_path_default, epw_path = epw_path_default)
133
+ FileUtils.mkdir_p(run_dir(test_name)) unless File.exist?(run_dir(test_name))
134
+ assert(File.exist?(run_dir(test_name)))
135
+
136
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
137
+
138
+ assert(File.exist?(model_in_path))
139
+
140
+ if File.exist?(model_out_path(test_name))
141
+ FileUtils.rm(model_out_path(test_name))
142
+ end
143
+
144
+ # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf
145
+ workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)
146
+ workspace.addObjects(idf_output_requests)
147
+ rt = OpenStudio::EnergyPlus::ReverseTranslator.new
148
+ request_model = rt.translateWorkspace(workspace)
149
+
150
+ translator = OpenStudio::OSVersion::VersionTranslator.new
151
+ model = translator.loadModel(model_in_path)
152
+ assert(!model.empty?)
153
+ model = model.get
154
+ model.addObjects(request_model.objects)
155
+ model.save(model_out_path(test_name), true)
156
+
157
+ if is_openstudio_2?
158
+ setup_test_2(test_name, epw_path)
159
+ else
160
+ setup_test_1(test_name, epw_path)
161
+ end
162
+ end
163
+
164
+ # calibration_reports
165
+ def test_CalibrationReportsEnhanced
166
+ test_name = 'calibration_reports'
167
+
168
+ # create an instance of the measure
169
+ measure = CalibrationReportsEnhanced.new
170
+
171
+ # create an instance of a runner
172
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
173
+
174
+ # get arguments
175
+ arguments = measure.arguments
176
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
177
+
178
+ # create hash of argument values
179
+ args_hash = {}
180
+
181
+ # populate argument with specified hash value if specified
182
+ arguments.each do |arg|
183
+ temp_arg_var = arg.clone
184
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
185
+ argument_map[arg.name] = temp_arg_var
186
+ end
187
+
188
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
189
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
190
+ assert_equal(0, idf_output_requests.size)
191
+
192
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
193
+ epw_path = epw_path_default
194
+ setup_test(test_name, idf_output_requests)
195
+
196
+ assert(File.exist?(model_out_path(test_name)))
197
+ assert(File.exist?(sql_path(test_name)))
198
+ assert(File.exist?(epw_path))
199
+
200
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
201
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
202
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
203
+ runner.setLastEpwFilePath(epw_path)
204
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
205
+
206
+ # delete the output if it exists
207
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
208
+ assert(!File.exist?(report_path(test_name)))
209
+
210
+ # temporarily change directory to the run directory and run the measure
211
+ start_dir = Dir.pwd
212
+ begin
213
+ Dir.chdir(run_dir(test_name))
214
+
215
+ # run the measure
216
+ measure.run(runner, argument_map)
217
+ result = runner.result
218
+ show_output(result)
219
+ assert_equal('Success', result.value.valueName)
220
+ assert(result.warnings.empty?)
221
+ ensure
222
+ Dir.chdir(start_dir)
223
+ end
224
+
225
+ model = runner.lastOpenStudioModel
226
+ assert(!model.empty?)
227
+ model = model.get
228
+
229
+ sqlFile = runner.lastEnergyPlusSqlFile
230
+ assert(!sqlFile.empty?)
231
+ sqlFile = sqlFile.get
232
+
233
+ model.setSqlFile(sqlFile)
234
+
235
+ # must have a runPeriod
236
+ runPeriod = model.runPeriod
237
+ assert(!runPeriod.empty?)
238
+
239
+ # must have a calendarYear
240
+ yearDescription = model.yearDescription
241
+ assert(!yearDescription.empty?)
242
+ calendarYear = yearDescription.get.calendarYear
243
+ assert(!calendarYear.empty?)
244
+
245
+ # check for varying demand
246
+ model.getUtilityBills.each do |utilityBill|
247
+ next if utilityBill.peakDemandUnitConversionFactor.empty?
248
+ hasVaryingDemand = false
249
+ modelPeakDemand = 0.0
250
+ count = 0
251
+ utilityBill.billingPeriods.each do |billingPeriod|
252
+ peakDemand = billingPeriod.modelPeakDemand
253
+ next if peakDemand.empty?
254
+ temp = peakDemand.get
255
+ if count == 0
256
+ modelPeakDemand = temp
257
+ else
258
+ if modelPeakDemand != temp
259
+ hasVaryingDemand = true
260
+ break
261
+ end
262
+ end
263
+ count += 1
264
+ end
265
+ assert(hasVaryingDemand) if count > 1
266
+ end
267
+
268
+ # make sure the report file exists
269
+ assert(File.exist?(report_path(test_name)))
270
+ end
271
+
272
+ # calibration_reports_no_gas
273
+ def test_CalibrationReportsEnhanced_NoGas
274
+ test_name = 'calibration_reports_no_gas'
275
+
276
+ # load model, remove gas bills, save to new file
277
+ raw_model_path = "#{File.dirname(__FILE__)}/ExampleModel.osm"
278
+ vt = OpenStudio::OSVersion::VersionTranslator.new
279
+ model = vt.loadModel(raw_model_path)
280
+ assert(!model.empty?)
281
+ model = model.get
282
+ utilityBills = model.getUtilityBills
283
+ assert_equal(2, utilityBills.size)
284
+ utilityBills.each do |utilityBill|
285
+ utilityBill.remove if utilityBill.fuelType == 'Gas'.to_FuelType
286
+ end
287
+ utilityBills = model.getUtilityBills
288
+ assert_equal(1, utilityBills.size)
289
+ altered_model_path = OpenStudio::Path.new("#{run_dir(test_name)}/ExampleModelNoGasInput.osm")
290
+ FileUtils.mkdir_p run_dir(test_name)
291
+ model.save(altered_model_path, true)
292
+
293
+ # set model_in_path to new altered copy of model
294
+ model_in_path = altered_model_path
295
+
296
+ # create an instance of the measure
297
+ measure = CalibrationReportsEnhanced.new
298
+
299
+ # create an instance of a runner
300
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
301
+
302
+ # get arguments
303
+ arguments = measure.arguments
304
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
305
+
306
+ # create hash of argument values
307
+ args_hash = {}
308
+
309
+ # populate argument with specified hash value if specified
310
+ arguments.each do |arg|
311
+ temp_arg_var = arg.clone
312
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
313
+ argument_map[arg.name] = temp_arg_var
314
+ end
315
+
316
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
317
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
318
+ assert_equal(0, idf_output_requests.size)
319
+
320
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
321
+ epw_path = epw_path_default
322
+ setup_test(test_name, idf_output_requests, model_in_path.to_s)
323
+
324
+ assert(File.exist?(model_out_path(test_name)))
325
+ assert(File.exist?(sql_path(test_name)))
326
+ assert(File.exist?(epw_path))
327
+
328
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
329
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
330
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
331
+ runner.setLastEpwFilePath(epw_path)
332
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
333
+
334
+ # delete the output if it exists
335
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
336
+ assert(!File.exist?(report_path(test_name)))
337
+
338
+ # temporarily change directory to the run directory and run the measure
339
+ start_dir = Dir.pwd
340
+ begin
341
+ Dir.chdir(run_dir(test_name))
342
+
343
+ # run the measure
344
+ measure.run(runner, argument_map)
345
+ result = runner.result
346
+ show_output(result)
347
+ assert_equal('Success', result.value.valueName)
348
+ assert(result.warnings.empty?)
349
+ ensure
350
+ Dir.chdir(start_dir)
351
+ end
352
+
353
+ model = runner.lastOpenStudioModel
354
+ assert(!model.empty?)
355
+ model = model.get
356
+
357
+ sqlFile = runner.lastEnergyPlusSqlFile
358
+ assert(!sqlFile.empty?)
359
+ sqlFile = sqlFile.get
360
+
361
+ model.setSqlFile(sqlFile)
362
+
363
+ # must have a runPeriod
364
+ runPeriod = model.runPeriod
365
+ assert(!runPeriod.empty?)
366
+
367
+ # must have a calendarYear
368
+ yearDescription = model.yearDescription
369
+ assert(!yearDescription.empty?)
370
+ calendarYear = yearDescription.get.calendarYear
371
+ assert(!calendarYear.empty?)
372
+
373
+ # check for varying demand
374
+ model.getUtilityBills.each do |utilityBill|
375
+ next if utilityBill.peakDemandUnitConversionFactor.empty?
376
+ hasVaryingDemand = false
377
+ modelPeakDemand = 0.0
378
+ count = 0
379
+ utilityBill.billingPeriods.each do |billingPeriod|
380
+ peakDemand = billingPeriod.modelPeakDemand
381
+ next if peakDemand.empty?
382
+ temp = peakDemand.get
383
+ if count == 0
384
+ modelPeakDemand = temp
385
+ else
386
+ if modelPeakDemand != temp
387
+ hasVaryingDemand = true
388
+ break
389
+ end
390
+ end
391
+ count += 1
392
+ end
393
+ assert(hasVaryingDemand) if count > 1
394
+ end
395
+
396
+ # make sure the report file exists
397
+ assert(File.exist?(report_path(test_name)))
398
+ end
399
+
400
+ # calibration_reports_no_demand
401
+ def test_CalibrationReportsEnhanced_NoDemand
402
+ test_name = 'calibration_reports_no_demand'
403
+
404
+ # load model, remove gas bills, save to new file
405
+ raw_model_path = "#{File.dirname(__FILE__)}/ExampleModel.osm"
406
+ vt = OpenStudio::OSVersion::VersionTranslator.new
407
+ model = vt.loadModel(raw_model_path)
408
+ assert(!model.empty?)
409
+ model = model.get
410
+ utilityBills = model.getUtilityBills
411
+ assert_equal(2, utilityBills.size)
412
+ utilityBills.each do |utilityBill|
413
+ next unless utilityBill.fuelType == 'Electricity'.to_FuelType
414
+ utilityBill.billingPeriods.each(&:resetPeakDemand)
415
+ end
416
+ utilityBills = model.getUtilityBills
417
+ assert_equal(2, utilityBills.size)
418
+ altered_model_path = OpenStudio::Path.new("#{run_dir(test_name)}/ExampleModelNoDemandInput.osm")
419
+ FileUtils.mkdir_p run_dir(test_name)
420
+ model.save(altered_model_path, true)
421
+
422
+ # set model_in_path to new altered copy of model
423
+ model_in_path = altered_model_path
424
+
425
+ # create an instance of the measure
426
+ measure = CalibrationReportsEnhanced.new
427
+
428
+ # create an instance of a runner
429
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
430
+
431
+ # get arguments
432
+ arguments = measure.arguments
433
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
434
+
435
+ # create hash of argument values
436
+ args_hash = {}
437
+
438
+ # populate argument with specified hash value if specified
439
+ arguments.each do |arg|
440
+ temp_arg_var = arg.clone
441
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
442
+ argument_map[arg.name] = temp_arg_var
443
+ end
444
+
445
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
446
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
447
+ assert_equal(0, idf_output_requests.size)
448
+
449
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
450
+ epw_path = epw_path_default
451
+ setup_test(test_name, idf_output_requests, model_in_path.to_s)
452
+
453
+ assert(File.exist?(model_out_path(test_name)))
454
+ assert(File.exist?(sql_path(test_name)))
455
+ assert(File.exist?(epw_path))
456
+
457
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
458
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
459
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
460
+ runner.setLastEpwFilePath(epw_path)
461
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
462
+
463
+ # delete the output if it exists
464
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
465
+ assert(!File.exist?(report_path(test_name)))
466
+
467
+ # temporarily change directory to the run directory and run the measure
468
+ start_dir = Dir.pwd
469
+ begin
470
+ Dir.chdir(run_dir(test_name))
471
+
472
+ # run the measure
473
+ measure.run(runner, argument_map)
474
+ result = runner.result
475
+ show_output(result)
476
+ assert_equal('Success', result.value.valueName)
477
+ assert(result.warnings.empty?)
478
+ ensure
479
+ Dir.chdir(start_dir)
480
+ end
481
+
482
+ model = runner.lastOpenStudioModel
483
+ assert(!model.empty?)
484
+ model = model.get
485
+
486
+ sqlFile = runner.lastEnergyPlusSqlFile
487
+ assert(!sqlFile.empty?)
488
+ sqlFile = sqlFile.get
489
+
490
+ model.setSqlFile(sqlFile)
491
+
492
+ # must have a runPeriod
493
+ runPeriod = model.runPeriod
494
+ assert(!runPeriod.empty?)
495
+
496
+ # must have a calendarYear
497
+ yearDescription = model.yearDescription
498
+ assert(!yearDescription.empty?)
499
+ calendarYear = yearDescription.get.calendarYear
500
+ assert(!calendarYear.empty?)
501
+
502
+ # check for no demand
503
+ model.getUtilityBills.each do |utilityBill|
504
+ utilityBill.billingPeriods.each do |billingPeriod|
505
+ assert(billingPeriod.peakDemand.empty?)
506
+ end
507
+ end
508
+
509
+ # make sure the report file exists
510
+ assert(File.exist?(report_path(test_name)))
511
+ end
512
+
513
+ # calibration_reports_with_two_gas_bills
514
+ def test_CalibrationReportsEnhanced_TwoGas
515
+ test_name = 'calibration_reports_two_gas'
516
+
517
+ # load model, remove gas bills, save to new file
518
+ raw_model_path = "#{File.dirname(__FILE__)}/ExampleModel.osm"
519
+ vt = OpenStudio::OSVersion::VersionTranslator.new
520
+ model = vt.loadModel(raw_model_path)
521
+ assert(!model.empty?)
522
+ model = model.get
523
+ utilityBills = model.getUtilityBills
524
+ assert_equal(2, utilityBills.size)
525
+ utilityBills.each do |utilityBill|
526
+ utilityBill.clone(model) if utilityBill.fuelType == 'Gas'.to_FuelType
527
+ end
528
+ utilityBills = model.getUtilityBills
529
+ assert_equal(3, utilityBills.size)
530
+ altered_model_path = OpenStudio::Path.new("#{run_dir(test_name)}/ExampleModelTwoGasInput.osm")
531
+ FileUtils.mkdir_p run_dir(test_name)
532
+ model.save(altered_model_path, true)
533
+
534
+ # set model_in_path to new altered copy of model
535
+ model_in_path = altered_model_path
536
+
537
+ # create an instance of the measure
538
+ measure = CalibrationReportsEnhanced.new
539
+
540
+ # create an instance of a runner
541
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
542
+
543
+ # get arguments
544
+ arguments = measure.arguments
545
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
546
+
547
+ # create hash of argument values
548
+ args_hash = {}
549
+
550
+ # populate argument with specified hash value if specified
551
+ arguments.each do |arg|
552
+ temp_arg_var = arg.clone
553
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
554
+ argument_map[arg.name] = temp_arg_var
555
+ end
556
+
557
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
558
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
559
+ assert_equal(0, idf_output_requests.size)
560
+
561
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
562
+ epw_path = epw_path_default
563
+ setup_test(test_name, idf_output_requests, model_in_path.to_s)
564
+
565
+ assert(File.exist?(model_out_path(test_name)))
566
+ assert(File.exist?(sql_path(test_name)))
567
+ assert(File.exist?(epw_path))
568
+
569
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
570
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
571
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
572
+ runner.setLastEpwFilePath(epw_path)
573
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
574
+
575
+ # delete the output if it exists
576
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
577
+ assert(!File.exist?(report_path(test_name)))
578
+
579
+ # temporarily change directory to the run directory and run the measure
580
+ start_dir = Dir.pwd
581
+ begin
582
+ Dir.chdir(run_dir(test_name))
583
+
584
+ # run the measure
585
+ measure.run(runner, argument_map)
586
+ result = runner.result
587
+ show_output(result)
588
+ assert_equal('Success', result.value.valueName)
589
+ assert(result.warnings.size == 1)
590
+ ensure
591
+ Dir.chdir(start_dir)
592
+ end
593
+
594
+ model = runner.lastOpenStudioModel
595
+ assert(!model.empty?)
596
+ model = model.get
597
+
598
+ sqlFile = runner.lastEnergyPlusSqlFile
599
+ assert(!sqlFile.empty?)
600
+ sqlFile = sqlFile.get
601
+
602
+ model.setSqlFile(sqlFile)
603
+
604
+ # must have a runPeriod
605
+ runPeriod = model.runPeriod
606
+ assert(!runPeriod.empty?)
607
+
608
+ # must have a calendarYear
609
+ yearDescription = model.yearDescription
610
+ assert(!yearDescription.empty?)
611
+ calendarYear = yearDescription.get.calendarYear
612
+ assert(!calendarYear.empty?)
613
+
614
+ # make sure the report file exists
615
+ assert(File.exist?(report_path(test_name)))
616
+ end
617
+
618
+ # calibration_reports
619
+ def test_CalibrationFuelOil2
620
+ skip 'Remove once CI is using 2.7.0 or later'
621
+
622
+ test_name = 'calibration_fuel_oil2'
623
+ model_in_path = "#{File.dirname(__FILE__)}/ExampleModel_FuelOil.osm"
624
+
625
+ # create an instance of the measure
626
+ measure = CalibrationReportsEnhanced.new
627
+
628
+ # create an instance of a runner
629
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
630
+
631
+ # get arguments
632
+ arguments = measure.arguments
633
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
634
+
635
+ # create hash of argument values
636
+ args_hash = {}
637
+
638
+ # populate argument with specified hash value if specified
639
+ arguments.each do |arg|
640
+ temp_arg_var = arg.clone
641
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
642
+ argument_map[arg.name] = temp_arg_var
643
+ end
644
+
645
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
646
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
647
+ assert_equal(0, idf_output_requests.size)
648
+
649
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
650
+ epw_path = epw_path_default
651
+ setup_test(test_name, idf_output_requests, model_in_path)
652
+
653
+ assert(File.exist?(model_out_path(test_name)))
654
+ assert(File.exist?(sql_path(test_name)))
655
+ assert(File.exist?(epw_path))
656
+
657
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
658
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
659
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
660
+ runner.setLastEpwFilePath(epw_path)
661
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
662
+
663
+ # delete the output if it exists
664
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
665
+ assert(!File.exist?(report_path(test_name)))
666
+
667
+ # temporarily change directory to the run directory and run the measure
668
+ start_dir = Dir.pwd
669
+ begin
670
+ Dir.chdir(run_dir(test_name))
671
+
672
+ # run the measure
673
+ measure.run(runner, argument_map)
674
+ result = runner.result
675
+ show_output(result)
676
+ assert_equal('Success', result.value.valueName)
677
+ # assert(result.warnings.size == 0)
678
+ ensure
679
+ Dir.chdir(start_dir)
680
+ end
681
+
682
+ model = runner.lastOpenStudioModel
683
+ assert(!model.empty?)
684
+ model = model.get
685
+
686
+ sqlFile = runner.lastEnergyPlusSqlFile
687
+ assert(!sqlFile.empty?)
688
+ sqlFile = sqlFile.get
689
+
690
+ model.setSqlFile(sqlFile)
691
+
692
+ # must have a runPeriod
693
+ runPeriod = model.runPeriod
694
+ assert(!runPeriod.empty?)
695
+
696
+ # must have a calendarYear
697
+ yearDescription = model.yearDescription
698
+ assert(!yearDescription.empty?)
699
+ calendarYear = yearDescription.get.calendarYear
700
+ assert(!calendarYear.empty?)
701
+
702
+ # check for varying demand
703
+ assert_equal(3, model.getUtilityBills.size)
704
+ model.getUtilityBills.each do |utilityBill|
705
+ assert(!utilityBill.billingPeriods.empty?)
706
+ utilityBill.billingPeriods.each do |billingPeriod|
707
+ assert(!billingPeriod.modelConsumption.empty?)
708
+ end
709
+
710
+ next if utilityBill.peakDemandUnitConversionFactor.empty?
711
+ hasVaryingDemand = false
712
+ modelPeakDemand = 0.0
713
+ count = 0
714
+ utilityBill.billingPeriods.each do |billingPeriod|
715
+ peakDemand = billingPeriod.modelPeakDemand
716
+ next if peakDemand.empty?
717
+ temp = peakDemand.get
718
+ if count == 0
719
+ modelPeakDemand = temp
720
+ else
721
+ if modelPeakDemand != temp
722
+ hasVaryingDemand = true
723
+ break
724
+ end
725
+ end
726
+ count += 1
727
+ end
728
+ assert(hasVaryingDemand) if count > 1
729
+ end
730
+
731
+ # make sure the report file exists
732
+ assert(File.exist?(report_path(test_name)))
733
+ end
734
+ end