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,523 @@
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
+ require 'openstudio/measure/ShowRunnerOutput'
38
+ require 'fileutils'
39
+
40
+ require_relative '../measure.rb'
41
+ require 'minitest/autorun'
42
+
43
+ class CalibrationReports_Test < Minitest::Test
44
+ def is_openstudio_2?
45
+ begin
46
+ workflow = OpenStudio::WorkflowJSON.new
47
+ rescue StandardError
48
+ return false
49
+ end
50
+ true
51
+ end
52
+
53
+ def model_in_path_default
54
+ "#{File.dirname(__FILE__)}/ExampleModel.osm"
55
+ end
56
+
57
+ def epw_path_default
58
+ # make sure we have a weather data location
59
+ epw = nil
60
+ epw = OpenStudio::Path.new("#{File.dirname(__FILE__)}/USA_CO_Golden-NREL.724666_TMY3.epw")
61
+ assert(File.exist?(epw.to_s))
62
+ epw.to_s
63
+ end
64
+
65
+ def run_dir(test_name)
66
+ # always generate test output in specially named 'output' directory so result files are not made part of the measure
67
+ "#{File.dirname(__FILE__)}/output/#{test_name}"
68
+ end
69
+
70
+ def model_out_path(test_name)
71
+ "#{run_dir(test_name)}/TestOutput.osm"
72
+ end
73
+
74
+ def workspace_path(test_name)
75
+ if is_openstudio_2?
76
+ "#{run_dir(test_name)}/run/in.idf"
77
+ else
78
+ "#{run_dir(test_name)}/ModelToIdf/in.idf"
79
+ end
80
+ end
81
+
82
+ def sql_path(test_name)
83
+ if is_openstudio_2?
84
+ "#{run_dir(test_name)}/run/eplusout.sql"
85
+ else
86
+ "#{run_dir(test_name)}/ModelToIdf/EnergyPlusPreProcess-0/EnergyPlus-0/eplusout.sql"
87
+ end
88
+ end
89
+
90
+ def report_path(test_name)
91
+ "#{run_dir(test_name)}/report.html"
92
+ end
93
+
94
+ # method for running the test simulation using OpenStudio 1.x API
95
+ def setup_test_1(test_name, epw_path)
96
+ co = OpenStudio::Runmanager::ConfigOptions.new(true)
97
+ co.findTools(false, true, false, true)
98
+
99
+ unless File.exist?(sql_path(test_name))
100
+ puts 'Running EnergyPlus'
101
+
102
+ wf = OpenStudio::Runmanager::Workflow.new('modeltoidf->energypluspreprocess->energyplus')
103
+ wf.add(co.getTools)
104
+ job = wf.create(OpenStudio::Path.new(run_dir(test_name)), OpenStudio::Path.new(model_out_path(test_name)), OpenStudio::Path.new(epw_path))
105
+
106
+ rm = OpenStudio::Runmanager::RunManager.new
107
+ rm.enqueue(job, true)
108
+ rm.waitForFinished
109
+ end
110
+ end
111
+
112
+ # method for running the test simulation using OpenStudio 2.x API
113
+ def setup_test_2(test_name, epw_path)
114
+ osw_path = File.join(run_dir(test_name), 'in.osw')
115
+ osw_path = File.absolute_path(osw_path)
116
+
117
+ workflow = OpenStudio::WorkflowJSON.new
118
+ workflow.setSeedFile(File.absolute_path(model_out_path(test_name)))
119
+ workflow.setWeatherFile(File.absolute_path(epw_path))
120
+ workflow.saveAs(osw_path)
121
+
122
+ cli_path = OpenStudio.getOpenStudioCLI
123
+ cmd = "\"#{cli_path}\" run -w \"#{osw_path}\""
124
+ puts cmd
125
+ system(cmd)
126
+ end
127
+
128
+ # create test files if they do not exist when the test first runs
129
+ def setup_test(test_name, idf_output_requests, model_in_path = model_in_path_default, epw_path = epw_path_default)
130
+ FileUtils.mkdir_p(run_dir(test_name)) unless File.exist?(run_dir(test_name))
131
+ assert(File.exist?(run_dir(test_name)))
132
+
133
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
134
+
135
+ assert(File.exist?(model_in_path))
136
+
137
+ if File.exist?(model_out_path(test_name))
138
+ FileUtils.rm(model_out_path(test_name))
139
+ end
140
+
141
+ # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf
142
+ workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)
143
+ workspace.addObjects(idf_output_requests)
144
+ rt = OpenStudio::EnergyPlus::ReverseTranslator.new
145
+ request_model = rt.translateWorkspace(workspace)
146
+
147
+ translator = OpenStudio::OSVersion::VersionTranslator.new
148
+ model = translator.loadModel(model_in_path)
149
+ assert(!model.empty?)
150
+ model = model.get
151
+ model.addObjects(request_model.objects)
152
+ model.save(model_out_path(test_name), true)
153
+
154
+ if ENV['OPENSTUDIO_TEST_NO_CACHE_SQLFILE']
155
+ FileUtils.rm_f(sql_path(test_name)) if File.exist?(sql_path(test_name))
156
+ end
157
+
158
+ if is_openstudio_2?
159
+ setup_test_2(test_name, epw_path)
160
+ else
161
+ setup_test_1(test_name, epw_path)
162
+ end
163
+ end
164
+
165
+ # calibration_reports
166
+ def test_CalibrationReports
167
+ test_name = 'calibration_reports'
168
+ model_in_path = "#{File.dirname(__FILE__)}/ExampleModel.osm"
169
+
170
+ # create an instance of the measure
171
+ measure = CalibrationReports.new
172
+
173
+ # create an instance of a runner
174
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
175
+
176
+ # get arguments
177
+ arguments = measure.arguments
178
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
179
+
180
+ # create hash of argument values
181
+ args_hash = {}
182
+
183
+ # populate argument with specified hash value if specified
184
+ arguments.each do |arg|
185
+ temp_arg_var = arg.clone
186
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
187
+ argument_map[arg.name] = temp_arg_var
188
+ end
189
+
190
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
191
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
192
+ assert_equal(0, idf_output_requests.size)
193
+
194
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
195
+ epw_path = epw_path_default
196
+ setup_test(test_name, idf_output_requests)
197
+
198
+ assert(File.exist?(model_out_path(test_name)))
199
+ assert(File.exist?(sql_path(test_name)))
200
+ assert(File.exist?(epw_path))
201
+
202
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
203
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
204
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
205
+ runner.setLastEpwFilePath(epw_path)
206
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
207
+
208
+ # delete the output if it exists
209
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
210
+ assert(!File.exist?(report_path(test_name)))
211
+
212
+ # temporarily change directory to the run directory and run the measure
213
+ start_dir = Dir.pwd
214
+ begin
215
+ Dir.chdir(run_dir(test_name))
216
+
217
+ # run the measure
218
+ measure.run(runner, argument_map)
219
+ result = runner.result
220
+ show_output(result)
221
+ assert_equal('Success', result.value.valueName)
222
+ assert(result.warnings.empty?)
223
+ ensure
224
+ Dir.chdir(start_dir)
225
+ end
226
+
227
+ model = runner.lastOpenStudioModel
228
+ assert(!model.empty?)
229
+ model = model.get
230
+
231
+ sqlFile = runner.lastEnergyPlusSqlFile
232
+ assert(!sqlFile.empty?)
233
+ sqlFile = sqlFile.get
234
+
235
+ model.setSqlFile(sqlFile)
236
+
237
+ # must have a runPeriod
238
+ runPeriod = model.runPeriod
239
+ assert(!runPeriod.empty?)
240
+
241
+ # must have a calendarYear
242
+ yearDescription = model.yearDescription
243
+ assert(!yearDescription.empty?)
244
+ calendarYear = yearDescription.get.calendarYear
245
+ assert(!calendarYear.empty?)
246
+
247
+ # check for varying demand
248
+ model.getUtilityBills.each do |utilityBill|
249
+ next if utilityBill.peakDemandUnitConversionFactor.empty?
250
+ hasVaryingDemand = false
251
+ modelPeakDemand = 0.0
252
+ count = 0
253
+ utilityBill.billingPeriods.each do |billingPeriod|
254
+ peakDemand = billingPeriod.modelPeakDemand
255
+ next if peakDemand.empty?
256
+ temp = peakDemand.get
257
+ if count == 0
258
+ modelPeakDemand = temp
259
+ else
260
+ if modelPeakDemand != temp
261
+ hasVaryingDemand = true
262
+ break
263
+ end
264
+ end
265
+ count += 1
266
+ end
267
+ assert(hasVaryingDemand) if count > 1
268
+ end
269
+
270
+ # make sure the report file exists
271
+ assert(File.exist?(report_path(test_name)))
272
+ end
273
+
274
+ # calibration_reports_no_gas
275
+ def test_CalibrationReports_NoGas
276
+ test_name = 'calibration_reports_no_gas'
277
+
278
+ # # load model, remove gas bills, save to new file
279
+ # raw_model_path = "#{File.dirname(__FILE__)}/ExampleModel.osm"
280
+ # vt = OpenStudio::OSVersion::VersionTranslator.new
281
+ # model = vt.loadModel(raw_model_path)
282
+ # assert(!model.empty?)
283
+ # model = model.get
284
+ # utilityBills = model.getUtilityBills
285
+ # assert_equal(2, utilityBills.size)
286
+ # utilityBills.each do |utilityBill|
287
+ # if utilityBill.fuelType == 'Gas'.to_FuelType
288
+ # utilityBill.remove
289
+ # end
290
+ # end
291
+ # utilityBills = model.getUtilityBills
292
+ # assert_equal(1, utilityBills.size)
293
+ # altered_model_path = OpenStudio::Path.new("#{run_dir(test_name)}/ExampleModelNoGasInput.osm")
294
+ # model.save(altered_model_path, true)
295
+ #
296
+ # # set model_in_path to new altered copy of model
297
+ # model_in_path = altered_model_path
298
+
299
+ # dynamically generated test model creating issues on CI, so using pre-made test model for now.
300
+ model_in_path = "#{File.dirname(__FILE__)}/ExampleModelNoGasInput.osm"
301
+
302
+ # create an instance of the measure
303
+ measure = CalibrationReports.new
304
+
305
+ # create an instance of a runner
306
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
307
+
308
+ # get arguments
309
+ arguments = measure.arguments
310
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
311
+
312
+ # create hash of argument values
313
+ args_hash = {}
314
+
315
+ # populate argument with specified hash value if specified
316
+ arguments.each do |arg|
317
+ temp_arg_var = arg.clone
318
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
319
+ argument_map[arg.name] = temp_arg_var
320
+ end
321
+
322
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
323
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
324
+ assert_equal(0, idf_output_requests.size)
325
+
326
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
327
+ epw_path = epw_path_default
328
+ sleep = 4 # try adding sleep for stability when test model is being created within test fails inconsistently
329
+ setup_test(test_name, idf_output_requests, model_in_path.to_s)
330
+
331
+ assert(File.exist?(model_out_path(test_name)))
332
+ assert(File.exist?(sql_path(test_name)))
333
+ assert(File.exist?(epw_path))
334
+
335
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
336
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
337
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
338
+ runner.setLastEpwFilePath(epw_path)
339
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
340
+
341
+ # delete the output if it exists
342
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
343
+ assert(!File.exist?(report_path(test_name)))
344
+
345
+ # temporarily change directory to the run directory and run the measure
346
+ start_dir = Dir.pwd
347
+ begin
348
+ Dir.chdir(run_dir(test_name))
349
+
350
+ # run the measure
351
+ measure.run(runner, argument_map)
352
+ result = runner.result
353
+ show_output(result)
354
+ assert_equal('Success', result.value.valueName)
355
+ assert(result.warnings.empty?)
356
+ ensure
357
+ Dir.chdir(start_dir)
358
+ end
359
+
360
+ model = runner.lastOpenStudioModel
361
+ assert(!model.empty?)
362
+ model = model.get
363
+
364
+ sqlFile = runner.lastEnergyPlusSqlFile
365
+ assert(!sqlFile.empty?)
366
+ sqlFile = sqlFile.get
367
+
368
+ model.setSqlFile(sqlFile)
369
+
370
+ # must have a runPeriod
371
+ runPeriod = model.runPeriod
372
+ assert(!runPeriod.empty?)
373
+
374
+ # must have a calendarYear
375
+ yearDescription = model.yearDescription
376
+ assert(!yearDescription.empty?)
377
+ calendarYear = yearDescription.get.calendarYear
378
+ assert(!calendarYear.empty?)
379
+
380
+ # check for varying demand
381
+ model.getUtilityBills.each do |utilityBill|
382
+ next if utilityBill.peakDemandUnitConversionFactor.empty?
383
+ hasVaryingDemand = false
384
+ modelPeakDemand = 0.0
385
+ count = 0
386
+ utilityBill.billingPeriods.each do |billingPeriod|
387
+ peakDemand = billingPeriod.modelPeakDemand
388
+ next if peakDemand.empty?
389
+ temp = peakDemand.get
390
+ if count == 0
391
+ modelPeakDemand = temp
392
+ else
393
+ if modelPeakDemand != temp
394
+ hasVaryingDemand = true
395
+ break
396
+ end
397
+ end
398
+ count += 1
399
+ end
400
+ assert(hasVaryingDemand) if count > 1
401
+ end
402
+
403
+ # make sure the report file exists
404
+ assert(File.exist?(report_path(test_name)))
405
+ end
406
+
407
+ # calibration_reports_no_gas
408
+ def test_CalibrationReports_NoDemand
409
+ test_name = 'calibration_reports_no_demand'
410
+
411
+ # # load model, remove gas bills, save to new file
412
+ # raw_model_path = "#{File.dirname(__FILE__)}/ExampleModel.osm"
413
+ # vt = OpenStudio::OSVersion::VersionTranslator.new
414
+ # model = vt.loadModel(raw_model_path)
415
+ # assert(!model.empty?)
416
+ # model = model.get
417
+ # utilityBills = model.getUtilityBills
418
+ # assert_equal(2, utilityBills.size)
419
+ # utilityBills.each do |utilityBill|
420
+ # if utilityBill.fuelType == 'Electricity'.to_FuelType
421
+ # utilityBill.billingPeriods.each(&:resetPeakDemand)
422
+ # end
423
+ # end
424
+ # utilityBills = model.getUtilityBills
425
+ # assert_equal(2, utilityBills.size)
426
+ # altered_model_path = OpenStudio::Path.new("#{run_dir(test_name)}/ExampleModelNoDemandInput.osm")
427
+ # model.save(altered_model_path, true)
428
+ #
429
+ # # set model_in_path to new altered copy of model
430
+ # model_in_path = altered_model_path
431
+
432
+ # dynamically generated test model creating issues on CI, so using pre-made test model for now.
433
+ model_in_path = "#{File.dirname(__FILE__)}/ExampleModelNoDemandInput.osm"
434
+
435
+ # create an instance of the measure
436
+ measure = CalibrationReports.new
437
+
438
+ # create an instance of a runner
439
+ runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
440
+
441
+ # get arguments
442
+ arguments = measure.arguments
443
+ argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
444
+
445
+ # create hash of argument values
446
+ args_hash = {}
447
+
448
+ # populate argument with specified hash value if specified
449
+ arguments.each do |arg|
450
+ temp_arg_var = arg.clone
451
+ assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
452
+ argument_map[arg.name] = temp_arg_var
453
+ end
454
+
455
+ # get the energyplus output requests, this will be done automatically by OS App and PAT
456
+ idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
457
+ assert_equal(0, idf_output_requests.size)
458
+
459
+ # mimic the process of running this measure in OS App or PAT. Optionally set custom model_in_path and custom epw_path.
460
+ epw_path = epw_path_default
461
+ sleep = 4 # try adding sleep for stability when test model is being created within test fails inconsistently
462
+ setup_test(test_name, idf_output_requests, model_in_path.to_s)
463
+
464
+ assert(File.exist?(model_out_path(test_name)))
465
+ assert(File.exist?(sql_path(test_name)))
466
+ assert(File.exist?(epw_path))
467
+
468
+ # set up runner, this will happen automatically when measure is run in PAT or OpenStudio
469
+ runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_out_path(test_name)))
470
+ runner.setLastEnergyPlusWorkspacePath(OpenStudio::Path.new(workspace_path(test_name)))
471
+ runner.setLastEpwFilePath(epw_path)
472
+ runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))
473
+
474
+ # delete the output if it exists
475
+ FileUtils.rm(report_path(test_name)) if File.exist?(report_path(test_name))
476
+ assert(!File.exist?(report_path(test_name)))
477
+
478
+ # temporarily change directory to the run directory and run the measure
479
+ start_dir = Dir.pwd
480
+ begin
481
+ Dir.chdir(run_dir(test_name))
482
+
483
+ # run the measure
484
+ measure.run(runner, argument_map)
485
+ result = runner.result
486
+ show_output(result)
487
+ assert_equal('Success', result.value.valueName)
488
+ assert(result.warnings.empty?)
489
+ ensure
490
+ Dir.chdir(start_dir)
491
+ end
492
+
493
+ model = runner.lastOpenStudioModel
494
+ assert(!model.empty?)
495
+ model = model.get
496
+
497
+ sqlFile = runner.lastEnergyPlusSqlFile
498
+ assert(!sqlFile.empty?)
499
+ sqlFile = sqlFile.get
500
+
501
+ model.setSqlFile(sqlFile)
502
+
503
+ # must have a runPeriod
504
+ runPeriod = model.runPeriod
505
+ assert(!runPeriod.empty?)
506
+
507
+ # must have a calendarYear
508
+ yearDescription = model.yearDescription
509
+ assert(!yearDescription.empty?)
510
+ calendarYear = yearDescription.get.calendarYear
511
+ assert(!calendarYear.empty?)
512
+
513
+ # check for no demand
514
+ model.getUtilityBills.each do |utilityBill|
515
+ utilityBill.billingPeriods.each do |billingPeriod|
516
+ assert(billingPeriod.peakDemand.empty?)
517
+ end
518
+ end
519
+
520
+ # make sure the report file exists
521
+ assert(File.exist?(report_path(test_name)))
522
+ end
523
+ end