openstudio-analysis 1.0.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -3
- data/CHANGELOG.md +25 -0
- data/Gemfile +1 -5
- data/LICENSE.md +1 -1
- data/Rakefile +1 -1
- data/lib/openstudio-analysis.rb +2 -1
- data/lib/openstudio/analysis.rb +23 -27
- data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
- data/lib/openstudio/analysis/formulation.rb +1 -1
- data/lib/openstudio/analysis/server_api.rb +8 -14
- data/lib/openstudio/analysis/support_files.rb +1 -1
- data/lib/openstudio/analysis/translator/datapoints.rb +24 -38
- data/lib/openstudio/analysis/translator/excel.rb +2 -2
- data/lib/openstudio/analysis/translator/workflow.rb +10 -13
- data/lib/openstudio/analysis/version.rb +2 -2
- data/lib/openstudio/analysis/workflow.rb +9 -18
- data/lib/openstudio/analysis/workflow_step.rb +67 -78
- data/lib/openstudio/helpers/hash.rb +1 -1
- data/lib/openstudio/helpers/string.rb +1 -1
- data/{spec/openstudio/server_api_spec.rb → lib/openstudio/helpers/utils.rb} +26 -28
- data/lib/openstudio/weather/epw.rb +1 -1
- data/openstudio-analysis.gemspec +17 -14
- data/update_license.rb +3 -3
- metadata +57 -194
- data/spec/files/0_1_09_no_variables.xlsx +0 -0
- data/spec/files/0_1_09_outputvars.xlsx +0 -0
- data/spec/files/0_1_09_setup_version_2.xlsx +0 -0
- data/spec/files/0_1_09_small_list.xlsx +0 -0
- data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
- data/spec/files/0_1_09_small_list_repeat_vars.xlsx +0 -0
- data/spec/files/0_1_09_small_list_validation_errors.xlsx +0 -0
- data/spec/files/0_1_10_proxy.xlsx +0 -0
- data/spec/files/0_1_10_proxy_user.xlsx +0 -0
- data/spec/files/0_1_10_template_input.xlsx +0 -0
- data/spec/files/0_1_11_discrete_variables.xlsx +0 -0
- data/spec/files/0_1_12_discrete_dynamic_columns.xlsx +0 -0
- data/spec/files/0_2_0_template.xlsx +0 -0
- data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
- data/spec/files/0_3_0_dynamic_uuids.xlsx +0 -0
- data/spec/files/0_3_0_measure_existence.xlsx +0 -0
- data/spec/files/0_3_0_outputs.xlsx +0 -0
- data/spec/files/0_3_3_short_names.xlsx +0 -0
- data/spec/files/0_3_5_multiple_measure_paths.xlsx +0 -0
- data/spec/files/0_3_7_unique_measure_names.xlsx +0 -0
- data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
- data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
- data/spec/files/0_4_0_multiple_seeds.xlsx +0 -0
- data/spec/files/0_4_0_pivot_test.xlsx +0 -0
- data/spec/files/analysis/examples/discrete_lhs_example.json +0 -809
- data/spec/files/analysis/examples/medium_office_example.json +0 -1674
- data/spec/files/analysis/examples/medium_office_workflow.json +0 -1298
- data/spec/files/measures/ActualMeasureNoJson/measure.rb +0 -80
- data/spec/files/measures/ActualMeasureNoJson/measure.xml +0 -2
- data/spec/files/measures/ExampleMeasure/measure.json +0 -3
- data/spec/files/measures/ExampleMeasure/measure.rb +0 -5
- data/spec/files/measures/ExampleMeasure/measure.xml +0 -1
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +0 -36
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +0 -22
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +0 -5
- data/spec/files/measures/NoMeasureRbFile/.gitkeep +0 -0
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.json +0 -3
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.rb +0 -5
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.xml +0 -1
- data/spec/files/measures/SetThermostatSchedules/measure.json +0 -63
- data/spec/files/measures/SetThermostatSchedules/measure.rb +0 -254
- data/spec/files/measures/SetThermostatSchedules/measure.xml +0 -2
- data/spec/files/measures/example_measure_auto_directory_name/measure.json +0 -3
- data/spec/files/measures/example_measure_auto_directory_name/measure.rb +0 -5
- data/spec/files/measures/example_measure_auto_directory_name/measure.xml +0 -1
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.json +0 -3
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.xml +0 -1
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.xml +0 -1
- data/spec/files/measures/rotate_building/measure.rb +0 -5
- data/spec/files/measures/rotate_building/measure.xml +0 -1
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.rb +0 -5
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.xml +0 -1
- data/spec/files/measures_second_path/measure_in_another_dir/measure.json +0 -3
- data/spec/files/measures_second_path/measure_in_another_dir/measure.rb +0 -5
- data/spec/files/measures_second_path/measure_in_another_dir/measure.xml +0 -1
- data/spec/files/partial_weather.epw +0 -32
- data/spec/files/partial_weather_2.epw +0 -32
- data/spec/files/small_seed.osm +0 -4622
- data/spec/files/worker_init/first_file.rb +0 -15
- data/spec/files/worker_init/second_file.sh +0 -4
- data/spec/files/workflow/analysis.osa +0 -1334
- data/spec/files/workflow/datapoint_0.osd +0 -65
- data/spec/files/workflow/datapoint_1.osd +0 -65
- data/spec/files/workflow/datapoint_2.osd +0 -65
- data/spec/files/workflow/datapoint_wrong_osa_id.osd +0 -65
- data/spec/integration/server_api_spec.rb +0 -83
- data/spec/openstudio/excel_spec.rb +0 -606
- data/spec/openstudio/formulation_spec.rb +0 -200
- data/spec/openstudio/hash_spec.rb +0 -56
- data/spec/openstudio/osw_spec.rb +0 -129
- data/spec/openstudio/string_spec.rb +0 -34
- data/spec/openstudio/support_files_spec.rb +0 -89
- data/spec/openstudio/weather_spec.rb +0 -80
- data/spec/openstudio/workflow_spec.rb +0 -126
- data/spec/openstudio/workflow_step_spec.rb +0 -158
- data/spec/schema/osa.json +0 -613
- data/spec/schema/osa.png +0 -0
- data/spec/schema/osd.json +0 -110
- data/spec/schema/osd.png +0 -0
- data/spec/spec_helper.rb +0 -56
@@ -1,200 +0,0 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-2019, 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 HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
require 'spec_helper'
|
37
|
-
|
38
|
-
describe OpenStudio::Analysis::Formulation do
|
39
|
-
it 'should create an analysis' do
|
40
|
-
a = OpenStudio::Analysis.create('Name of an analysis')
|
41
|
-
expect(a).not_to be nil
|
42
|
-
expect(a.display_name).to eq 'Name of an analysis'
|
43
|
-
expect(a).to be_a OpenStudio::Analysis::Formulation
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should add measure paths' do
|
47
|
-
expect(OpenStudio::Analysis.measure_paths).to eq ['./measures']
|
48
|
-
OpenStudio::Analysis.measure_paths = ['a', 'b']
|
49
|
-
expect(OpenStudio::Analysis.measure_paths).to eq ['a', 'b']
|
50
|
-
|
51
|
-
# append a measure apth
|
52
|
-
OpenStudio::Analysis.measure_paths << 'c'
|
53
|
-
expect(OpenStudio::Analysis.measure_paths).to eq ['a', 'b', 'c']
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should have a workflow object' do
|
57
|
-
a = OpenStudio::Analysis.create('workflow')
|
58
|
-
expect(a.workflow).not_to be nil
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should load the workflow from a file' do
|
62
|
-
OpenStudio::Analysis.measure_paths << 'spec/files/measures'
|
63
|
-
a = OpenStudio::Analysis.create('workflow')
|
64
|
-
file = File.join('spec/files/analysis/examples/medium_office_workflow.json')
|
65
|
-
expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should save a hash (version 1)' do
|
69
|
-
OpenStudio::Analysis.measure_paths << 'spec/files/measures'
|
70
|
-
a = OpenStudio::Analysis.create('workflow 2')
|
71
|
-
file = File.join('spec/files/analysis/examples/medium_office_workflow.json')
|
72
|
-
expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
|
73
|
-
h = a.to_hash
|
74
|
-
# expect(h[:workflow].empty?).not_to eq true
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should read from windows fqp' do
|
78
|
-
OpenStudio::Analysis.measure_paths << 'spec/files/measures'
|
79
|
-
a = OpenStudio::Analysis.create('workflow 2')
|
80
|
-
file = File.expand_path(File.join('spec/files/analysis/examples/medium_office_workflow.json'))
|
81
|
-
file = file.tr('/', '\\') if Gem.win_platform?
|
82
|
-
expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should create a save an empty analysis' do
|
86
|
-
a = OpenStudio::Analysis.create('workflow')
|
87
|
-
run_dir = 'spec/files/export/workflow'
|
88
|
-
|
89
|
-
FileUtils.mkdir_p run_dir
|
90
|
-
|
91
|
-
h = a.to_hash
|
92
|
-
expect(h[:analysis][:problem][:analysis_type]).to eq nil
|
93
|
-
expect(a.save("#{run_dir}/analysis.json")).to eq true
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should increment objective functions' do
|
97
|
-
a = OpenStudio::Analysis.create('my analysis')
|
98
|
-
|
99
|
-
a.add_output(
|
100
|
-
display_name: 'Total Natural Gas',
|
101
|
-
name: 'standard_report_legacy.total_natural_gas',
|
102
|
-
units: 'MJ/m2',
|
103
|
-
objective_function: true
|
104
|
-
)
|
105
|
-
|
106
|
-
expect(a.to_hash[:analysis][:output_variables].first[:objective_function_index]).to eq 0
|
107
|
-
|
108
|
-
a.add_output(
|
109
|
-
display_name: 'Another Output',
|
110
|
-
name: 'standard_report_legacy.output_2',
|
111
|
-
units: 'MJ/m2',
|
112
|
-
objective_function: true
|
113
|
-
)
|
114
|
-
expect(a.to_hash[:analysis][:output_variables].last[:objective_function_index]).to eq 1
|
115
|
-
|
116
|
-
a.add_output(
|
117
|
-
display_name: 'Another Output Not Objective Function',
|
118
|
-
name: 'standard_report_legacy.output_3',
|
119
|
-
units: 'MJ/m2',
|
120
|
-
objective_function: false
|
121
|
-
)
|
122
|
-
|
123
|
-
a.add_output(
|
124
|
-
display_name: 'Another Output 4',
|
125
|
-
name: 'standard_report_legacy.output_4',
|
126
|
-
units: 'MJ/m2',
|
127
|
-
objective_function: true
|
128
|
-
)
|
129
|
-
expect(a.to_hash[:analysis][:output_variables].last[:objective_function_index]).to eq 2
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should not add the same output' do
|
133
|
-
a = OpenStudio::Analysis.create('my analysis')
|
134
|
-
|
135
|
-
a.add_output(
|
136
|
-
display_name: 'Total Natural Gas',
|
137
|
-
name: 'standard_report_legacy.total_natural_gas',
|
138
|
-
units: 'MJ/m2',
|
139
|
-
objective_function: true
|
140
|
-
)
|
141
|
-
|
142
|
-
a.add_output(
|
143
|
-
display_name: 'Total Natural Gas',
|
144
|
-
name: 'standard_report_legacy.total_natural_gas',
|
145
|
-
units: 'MJ/m2',
|
146
|
-
objective_function: false # this doesn't do anything
|
147
|
-
)
|
148
|
-
|
149
|
-
expect(a.to_hash[:analysis][:output_variables].size).to eq 1
|
150
|
-
expect(a.to_hash[:analysis][:output_variables].last[:objective_function]).to eq true
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'should create a new formulation' do
|
154
|
-
a = OpenStudio::Analysis.create('my analysis')
|
155
|
-
p = 'spec/files/measures/SetThermostatSchedules'
|
156
|
-
|
157
|
-
a.workflow.add_measure_from_path('thermostat', 'thermostat', p)
|
158
|
-
m = a.workflow.add_measure_from_path('thermostat_2', 'thermostat 2', p)
|
159
|
-
|
160
|
-
d = {
|
161
|
-
type: 'uniform',
|
162
|
-
minimum: 5,
|
163
|
-
maximum: 7,
|
164
|
-
mean: 6.2
|
165
|
-
}
|
166
|
-
m.make_variable('cooling_sch', 'Change the cooling schedule', d)
|
167
|
-
m.argument_value('heating_sch', 'some-string')
|
168
|
-
|
169
|
-
expect(a.workflow.measures.size).to eq 2
|
170
|
-
expect(a.workflow.measures[1].arguments[3][:value]).to eq 'some-string'
|
171
|
-
expect(a.workflow.measures[1].variables[0][:uuid]).to match /[\w]{8}(-[\w]{4}){3}-[\w]{12}/
|
172
|
-
|
173
|
-
a.analysis_type = 'single_run'
|
174
|
-
a.algorithm.set_attribute('sample_method', 'all_variables')
|
175
|
-
o = {
|
176
|
-
display_name: 'Total Natural Gas',
|
177
|
-
display_name_short: 'Total Natural Gas',
|
178
|
-
metadata_id: nil,
|
179
|
-
name: 'total_natural_gas',
|
180
|
-
units: 'MJ/m2',
|
181
|
-
objective_function: true,
|
182
|
-
objective_function_index: 0,
|
183
|
-
objective_function_target: 330.7,
|
184
|
-
scaling_factor: nil,
|
185
|
-
objective_function_group: nil
|
186
|
-
}
|
187
|
-
a.add_output(o)
|
188
|
-
|
189
|
-
a.seed_model = 'spec/files/small_seed.osm'
|
190
|
-
a.weather_file = 'spec/files/partial_weather.epw'
|
191
|
-
|
192
|
-
expect(a.seed_model.first).to eq 'spec/files/small_seed.osm'
|
193
|
-
|
194
|
-
expect(a.to_hash[:analysis][:problem][:algorithm][:objective_functions]).to match ['total_natural_gas']
|
195
|
-
expect(a.analysis_type).to eq 'single_run'
|
196
|
-
|
197
|
-
dp_hash = a.to_static_data_point_hash
|
198
|
-
expect(dp_hash[:data_point][:set_variable_values].values).to eq ['*No Change*']
|
199
|
-
end
|
200
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-2019, 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 HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
require 'spec_helper'
|
37
|
-
|
38
|
-
describe Hash do
|
39
|
-
context 'deep key' do
|
40
|
-
before :all do
|
41
|
-
@h = {
|
42
|
-
a: ['array_1', 'array_2'],
|
43
|
-
b: {
|
44
|
-
c: {
|
45
|
-
'string_key' => 'finally'
|
46
|
-
}
|
47
|
-
}
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should find the key' do
|
52
|
-
expect(@h.deep_find(:a)).to eq ['array_1', 'array_2']
|
53
|
-
expect(@h.deep_find('string_key')).to eq 'finally'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/spec/openstudio/osw_spec.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-2019, 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 HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
require 'spec_helper'
|
37
|
-
|
38
|
-
describe OpenStudio::Analysis::Translator::Workflow do
|
39
|
-
before :all do
|
40
|
-
clean_dir = File.expand_path 'spec/files/workflow/datapoints'
|
41
|
-
|
42
|
-
if Dir.exist? clean_dir
|
43
|
-
FileUtils.rm_rf clean_dir
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'read in the osa' do
|
48
|
-
let(:osa_path) { File.expand_path 'analysis.osa' }
|
49
|
-
|
50
|
-
before(:each) do
|
51
|
-
Dir.chdir 'spec/files/workflow'
|
52
|
-
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
53
|
-
end
|
54
|
-
|
55
|
-
after(:each) do
|
56
|
-
Dir.chdir '../../..'
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should find and load the osa' do
|
60
|
-
expect(@translator).not_to be_nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should load the analysis' do
|
64
|
-
expect(@translator.osa.class).to eq(Hash)
|
65
|
-
expect(@translator.osa).not_to eq({})
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should not have measure or file paths' do
|
69
|
-
expect(@translator.file_paths).to eq([])
|
70
|
-
expect(@translator.measure_paths).to eq([])
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should have steps' do
|
74
|
-
expect(@translator.steps.class).to eq(Array)
|
75
|
-
expect(@translator.steps).not_to eq([])
|
76
|
-
@translator.steps.each do |step|
|
77
|
-
expect(step.class).to eq(Hash)
|
78
|
-
expect(step).not_to eq({})
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'write individual osws' do
|
84
|
-
let(:osa_path) { 'analysis.osa' }
|
85
|
-
|
86
|
-
before(:each) do
|
87
|
-
FileUtils.mkdir_p 'spec/files/export/workflow' unless Dir.exist? 'spec/files/export/workflow'
|
88
|
-
|
89
|
-
Dir.chdir 'spec/files/workflow'
|
90
|
-
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
91
|
-
end
|
92
|
-
|
93
|
-
after(:each) do
|
94
|
-
Dir.chdir '../../..'
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should write a single osd' do
|
98
|
-
osd_path = 'datapoint_0.osd'
|
99
|
-
result = @translator.process_datapoint(osd_path)
|
100
|
-
expect(result).to be_a(Hash)
|
101
|
-
|
102
|
-
# Save the file to the export directory
|
103
|
-
File.open('../../../spec/files/export/workflow/0.osw', 'w') { |f| f << JSON.pretty_generate(result) }
|
104
|
-
|
105
|
-
expect(result.key?(:seed_model)).to eq false
|
106
|
-
expect(result[:seed_file]).to eq 'large_office_air_cooled_chiller.osm'
|
107
|
-
expect(result[:weather_file]).to eq 'USA_CO_Denver.Intl.AP.725650_TMY3.epw'
|
108
|
-
expect(result[:file_format_version]).to eq '0.0.1'
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should not write a osd with a different osa id' do
|
112
|
-
osd_path = 'datapoint_wrong_osa_id.osd'
|
113
|
-
expect { @translator.process_datapoint(osd_path).first }.to raise_error(RuntimeError)
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'should write several osds' do
|
117
|
-
osd_paths = ['datapoint_0.osd', 'datapoint_1.osd', 'datapoint_2.osd']
|
118
|
-
r = @translator.process_datapoints(osd_paths)
|
119
|
-
expect(r.size).to eq 3
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should not fail when one osd is bad' do
|
123
|
-
osd_paths = ['datapoint_0.osd', 'datapoint_1.osd', 'datapoint_wrong_osa_id.osd']
|
124
|
-
r = @translator.process_datapoints(osd_paths)
|
125
|
-
expect(r[0]).to be_a Hash
|
126
|
-
expect(r[2]).to eq nil
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-2019, 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 HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-2019, 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 HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
require_relative './../spec_helper'
|
37
|
-
|
38
|
-
describe OpenStudio::Analysis::SupportFiles do
|
39
|
-
before :all do
|
40
|
-
@s = OpenStudio::Analysis::SupportFiles.new
|
41
|
-
expect(@s).to be_a OpenStudio::Analysis::SupportFiles
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should add files' do
|
45
|
-
f = 'spec/files/worker_init/first_file.rb'
|
46
|
-
@s.add(f)
|
47
|
-
|
48
|
-
expect(@s.size).to eq 1
|
49
|
-
expect(@s.files.first[:file]).to eq f
|
50
|
-
|
51
|
-
# add some other items
|
52
|
-
@s.add('spec/files/worker_init/second_file.sh')
|
53
|
-
|
54
|
-
expect(@s.size).to eq 2
|
55
|
-
@s.each do |f|
|
56
|
-
expect(f).to_not be nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should remove existing items' do
|
61
|
-
f = 'spec/files/worker_init/second_file.sh'
|
62
|
-
@s.add(f)
|
63
|
-
|
64
|
-
@s.clear
|
65
|
-
expect(@s.size).to eq 0
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should only add existing files' do
|
69
|
-
f = 'spec/files/worker_init/second_file.sh'
|
70
|
-
@s.add(f)
|
71
|
-
@s.add(f)
|
72
|
-
|
73
|
-
expect(@s.size).to eq 1
|
74
|
-
|
75
|
-
f = 'non-existent.rb'
|
76
|
-
expect { @s.add(f) }.to raise_error /Path or file does not exist and cannot be added.*/
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should add metadata data' do
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should add a directory' do
|
83
|
-
@s.clear
|
84
|
-
@s.add_files('spec/files/measures/**/*.rb', d: 'new')
|
85
|
-
|
86
|
-
expect(@s.size).to eq 10
|
87
|
-
expect(@s[0][:metadata][:d]).to eq 'new'
|
88
|
-
end
|
89
|
-
end
|