openstudio-load-flexibility-measures 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE.md +7 -21
- data/README.md +4 -3
- data/Rakefile +5 -0
- data/doc_templates/LICENSE.md +7 -21
- data/doc_templates/copyright_erb.txt +2 -32
- data/doc_templates/copyright_js.txt +2 -2
- data/doc_templates/copyright_ruby.txt +3 -33
- data/lib/measures/ShiftScheduleByType/LICENSE.md +7 -21
- data/lib/measures/ShiftScheduleByType/measure.rb +2 -32
- data/lib/measures/ShiftScheduleByType/measure.xml +5 -5
- data/lib/measures/ShiftScheduleByType/tests/ShiftScheduleByType_Test.rb +2 -32
- data/lib/measures/add_central_ice_storage/LICENSE.md +7 -21
- data/lib/measures/add_central_ice_storage/measure.rb +2 -32
- data/lib/measures/add_central_ice_storage/measure.xml +6 -6
- data/lib/measures/add_central_ice_storage/resources/OsLib_Schedules.rb +2 -32
- data/lib/measures/add_central_ice_storage/tests/add_central_ice_storage_test.rb +2 -32
- data/lib/measures/add_hpwh/LICENSE.md +7 -21
- data/lib/measures/add_hpwh/measure.rb +2 -32
- data/lib/measures/add_hpwh/measure.xml +5 -5
- data/lib/measures/add_hpwh/tests/add_hpwh_test.rb +2 -32
- data/lib/measures/add_packaged_ice_storage/LICENSE.md +7 -21
- data/lib/measures/add_packaged_ice_storage/measure.rb +9 -37
- data/lib/measures/add_packaged_ice_storage/measure.xml +23 -11
- data/lib/measures/add_packaged_ice_storage/tests/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw +8768 -0
- data/lib/measures/add_packaged_ice_storage/tests/add_packaged_ice_storage_test.rb +160 -35
- data/lib/measures/add_packaged_ice_storage/tests/single_speed_dx_350.osm +4316 -0
- data/lib/openstudio/load_flexibility_measures/version.rb +3 -33
- data/lib/openstudio/load_flexibility_measures.rb +2 -32
- data/openstudio-load-flexibility-measures.gemspec +2 -2
- metadata +8 -6
@@ -1,36 +1,6 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c)
|
3
|
-
#
|
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.
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
34
4
|
# *******************************************************************************
|
35
5
|
|
36
6
|
require 'openstudio'
|
@@ -46,6 +16,107 @@ class AddPackagedIceStorageTest < MiniTest::Test
|
|
46
16
|
# def teardown
|
47
17
|
# end
|
48
18
|
|
19
|
+
# Runs an annual simulation of IDF
|
20
|
+
#
|
21
|
+
# code based on model_run_simulation_and_log_errors from OpenStudio Standards
|
22
|
+
# Maybe update method above to optionally take IDF instead of OSM or add another method
|
23
|
+
#
|
24
|
+
# @param IDF OpenStudio workspace IDF object
|
25
|
+
# @param run_dir [String] file path location for the annual run, defaults to 'Run' in the current directory
|
26
|
+
# @return [Bool] returns true if successful, false if not
|
27
|
+
def model_run_simulation_and_log_errors(workspace, run_dir = "#{Dir.pwd}/Run")
|
28
|
+
# Make the directory if it doesn't exist
|
29
|
+
unless Dir.exist?(run_dir)
|
30
|
+
FileUtils.mkdir_p(run_dir)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Save workspace IDF
|
34
|
+
idf_name = 'in.idf'
|
35
|
+
OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.Model', "Starting simulation here: #{run_dir}.")
|
36
|
+
OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', "Running simulation #{run_dir}.")
|
37
|
+
idf_path = OpenStudio::Path.new("#{run_dir}/#{idf_name}")
|
38
|
+
workspace.save(idf_path, true)
|
39
|
+
|
40
|
+
# Set up the simulation
|
41
|
+
# Find the weather file
|
42
|
+
epw_path = OpenStudio::Path.new("#{File.dirname(__FILE__)}/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw")
|
43
|
+
|
44
|
+
sql_path = nil
|
45
|
+
|
46
|
+
OpenStudio.logFree(OpenStudio::Debug, 'openstudio.model.Model', 'Running with RunManager.')
|
47
|
+
|
48
|
+
# Find EnergyPlus
|
49
|
+
ep_path = OpenStudio.getEnergyPlusExecutable
|
50
|
+
|
51
|
+
puts "EnergyPlus is: #{ep_path}"
|
52
|
+
job = "energyplus -w #{epw_path.to_s} -d #{run_dir} #{idf_path.to_s}"
|
53
|
+
puts job
|
54
|
+
system(job)
|
55
|
+
|
56
|
+
sql_path = OpenStudio::Path.new("#{run_dir}/eplusout.sql")
|
57
|
+
|
58
|
+
OpenStudio.logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished run.')
|
59
|
+
|
60
|
+
# @todo Delete the eplustbl.htm and other files created by the run for cleanliness.
|
61
|
+
|
62
|
+
if OpenStudio.exists(sql_path)
|
63
|
+
sql = OpenStudio::SqlFile.new(sql_path)
|
64
|
+
# Check to make sure the sql file is readable,
|
65
|
+
# which won't be true if EnergyPlus crashed during simulation.
|
66
|
+
unless sql.connectionOpen
|
67
|
+
OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "The run failed, cannot create model. Look at the eplusout.err file in #{File.dirname(sql_path.to_s)} to see the cause.")
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
else
|
71
|
+
# If the sql file does not exist, it is likely that EnergyPlus crashed,
|
72
|
+
# in which case the useful errors are inside the eplusout.err file.
|
73
|
+
err_file_path_string = "#{run_dir}/run/eplusout.err"
|
74
|
+
err_file_path = OpenStudio::Path.new(err_file_path_string)
|
75
|
+
if OpenStudio.exists(err_file_path)
|
76
|
+
if __dir__[0] == ':' # Running from OpenStudio CLI
|
77
|
+
errs = EmbeddedScripting.getFileAsString(err_file_path_string)
|
78
|
+
else
|
79
|
+
errs = File.read(err_file_path_string)
|
80
|
+
end
|
81
|
+
OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "The run did not finish because of the following errors: #{errs}")
|
82
|
+
return false
|
83
|
+
else
|
84
|
+
OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "Results for the run couldn't be found here: #{sql_path}.")
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# todo - figure out how to get code below to work so method returns false when simulation fails
|
90
|
+
|
91
|
+
# # Report severe or fatal errors in the run
|
92
|
+
# error_query = "SELECT ErrorMessage
|
93
|
+
# FROM Errors
|
94
|
+
# WHERE ErrorType in(1,2)"
|
95
|
+
# errs = model.sqlFile.get.execAndReturnVectorOfString(error_query)
|
96
|
+
# if errs.is_initialized
|
97
|
+
# errs = errs.get
|
98
|
+
# end
|
99
|
+
|
100
|
+
# # Check that the run completed successfully
|
101
|
+
# end_file_stringpath = "#{run_dir}/run/eplusout.end"
|
102
|
+
# end_file_path = OpenStudio::Path.new(end_file_stringpath)
|
103
|
+
# if OpenStudio.exists(end_file_path)
|
104
|
+
# endstring = File.read(end_file_stringpath)
|
105
|
+
# end
|
106
|
+
|
107
|
+
# if !endstring.include?('EnergyPlus Completed Successfully')
|
108
|
+
# OpenStudio.logFree(OpenStudio::Error, 'openstudio.model.Model', "The run did not finish and had following errors: #{errs.join('\n')}")
|
109
|
+
# return false
|
110
|
+
# end
|
111
|
+
|
112
|
+
# # Log any severe errors that did not cause simulation to fail
|
113
|
+
# unless errs.empty?
|
114
|
+
# OpenStudio.logFree(OpenStudio::Warn, 'openstudio.model.Model', "The run completed but had the following severe errors: #{errs.join('\n')}")
|
115
|
+
# end
|
116
|
+
|
117
|
+
return true
|
118
|
+
end
|
119
|
+
|
49
120
|
def test_good_argument_values
|
50
121
|
# create an instance of the measure
|
51
122
|
measure = AddPackagedIceStorage.new
|
@@ -82,14 +153,68 @@ class AddPackagedIceStorageTest < MiniTest::Test
|
|
82
153
|
|
83
154
|
# run the measure
|
84
155
|
measure.run(workspace, runner, argument_map)
|
156
|
+
|
157
|
+
# run the annual simulation
|
158
|
+
output_file_path = "#{File.dirname(__FILE__)}/output/test_good_argument_values/Run"
|
159
|
+
#sim_results = self.model_run_simulation_and_log_errors(workspace, output_file_path)
|
160
|
+
#assert(sim_results)
|
161
|
+
# todo - need to add code so test fails if simulation fails
|
162
|
+
|
85
163
|
result = runner.result
|
86
164
|
assert_equal('Success', result.value.valueName)
|
87
165
|
|
88
166
|
show_output(result)
|
89
167
|
|
90
|
-
|
91
|
-
|
92
|
-
|
168
|
+
true
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_single_speed_dx
|
172
|
+
# create an instance of the measure
|
173
|
+
measure = AddPackagedIceStorage.new
|
174
|
+
|
175
|
+
# create runner with empty OSW
|
176
|
+
osw = OpenStudio::WorkflowJSON.new
|
177
|
+
runner = OpenStudio::Measure::OSRunner.new(osw)
|
178
|
+
|
179
|
+
# load the test model
|
180
|
+
translator = OpenStudio::OSVersion::VersionTranslator.new
|
181
|
+
path = OpenStudio::Path.new("#{File.dirname(__FILE__)}/single_speed_dx_350.osm")
|
182
|
+
model = translator.loadModel(path)
|
183
|
+
assert(!model.empty?)
|
184
|
+
model = model.get
|
185
|
+
|
186
|
+
# forward translate OSM file to IDF file
|
187
|
+
ft = OpenStudio::EnergyPlus::ForwardTranslator.new
|
188
|
+
workspace = ft.translateModel(model)
|
189
|
+
|
190
|
+
# get arguments
|
191
|
+
arguments = measure.arguments(workspace)
|
192
|
+
argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
|
193
|
+
|
194
|
+
# create hash of argument values
|
195
|
+
args_hash = {}
|
196
|
+
#args_hash['ice_cap'] = '40,50'
|
197
|
+
|
198
|
+
# populate argument with specified has value if set
|
199
|
+
arguments.each do |arg|
|
200
|
+
temp_arg_var = arg.clone
|
201
|
+
assert(temp_arg_var.setValue(args_hash[arg.name])) if args_hash[arg.name]
|
202
|
+
argument_map[arg.name] = temp_arg_var
|
203
|
+
end
|
204
|
+
|
205
|
+
# run the measure
|
206
|
+
measure.run(workspace, runner, argument_map)
|
207
|
+
|
208
|
+
# run the annual simulation
|
209
|
+
output_file_path = "#{File.dirname(__FILE__)}/output/single_speed_dx/Run"
|
210
|
+
#sim_results = self.model_run_simulation_and_log_errors(workspace, output_file_path)
|
211
|
+
#assert(sim_results)
|
212
|
+
# todo - need to add code so test fails if simulation fails
|
213
|
+
|
214
|
+
result = runner.result
|
215
|
+
assert_equal('Success', result.value.valueName)
|
216
|
+
|
217
|
+
show_output(result)
|
93
218
|
|
94
219
|
true
|
95
220
|
end
|