openstudio-analysis 1.0.0.rc19 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.gitlab-ci.yml +20 -0
- data/.rubocop.yml +2 -133
- data/.travis.yml +2 -2
- data/CHANGELOG.md +26 -32
- data/Gemfile +5 -6
- data/LICENSE.md +28 -0
- data/README.md +16 -8
- data/Rakefile +38 -3
- data/lib/openstudio-analysis.rb +35 -0
- data/lib/openstudio/analysis.rb +57 -26
- data/lib/openstudio/analysis/algorithm_attributes.rb +36 -1
- data/lib/openstudio/analysis/formulation.rb +41 -6
- data/lib/openstudio/analysis/server_api.rb +53 -36
- data/lib/openstudio/analysis/support_files.rb +40 -0
- data/lib/openstudio/analysis/translator/datapoints.rb +39 -4
- data/lib/openstudio/analysis/translator/excel.rb +43 -8
- data/lib/openstudio/analysis/translator/workflow.rb +54 -14
- data/lib/openstudio/analysis/version.rb +36 -1
- data/lib/openstudio/analysis/workflow.rb +37 -2
- data/lib/openstudio/analysis/workflow_step.rb +97 -70
- data/lib/openstudio/helpers/hash.rb +35 -0
- data/lib/openstudio/helpers/string.rb +36 -2
- data/lib/openstudio/weather/epw.rb +32 -17
- data/openstudio-analysis.gemspec +21 -18
- data/update_license.rb +120 -0
- metadata +62 -200
- data/LGPL-2.1.txt +0 -502
- data/LICENSE.txt +0 -65
- data/rubocop-todo.yml +0 -246
- 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 -1673
- 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.rb +0 -15
- 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 -48
- data/spec/openstudio/excel_spec.rb +0 -571
- data/spec/openstudio/formulation_spec.rb +0 -157
- data/spec/openstudio/hash_spec.rb +0 -21
- data/spec/openstudio/osw_spec.rb +0 -94
- data/spec/openstudio/server_api_spec.rb +0 -25
- data/spec/openstudio/string_spec.rb +0 -0
- data/spec/openstudio/support_files_spec.rb +0 -54
- data/spec/openstudio/weather_spec.rb +0 -45
- data/spec/openstudio/workflow_spec.rb +0 -91
- data/spec/openstudio/workflow_step_spec.rb +0 -118
- 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 -19
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenStudio::Analysis::Formulation do
|
4
|
-
it 'should create an analysis' do
|
5
|
-
a = OpenStudio::Analysis.create('Name of an analysis')
|
6
|
-
expect(a).not_to be nil
|
7
|
-
expect(a.display_name).to eq 'Name of an analysis'
|
8
|
-
expect(a).to be_a OpenStudio::Analysis::Formulation
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should add measure paths' do
|
12
|
-
expect(OpenStudio::Analysis.measure_paths).to eq ['./measures']
|
13
|
-
OpenStudio::Analysis.measure_paths = %w(a b)
|
14
|
-
expect(OpenStudio::Analysis.measure_paths).to eq %w(a b)
|
15
|
-
|
16
|
-
# append a measure apth
|
17
|
-
OpenStudio::Analysis.measure_paths << 'c'
|
18
|
-
expect(OpenStudio::Analysis.measure_paths).to eq %w(a b c)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should have a workflow object' do
|
22
|
-
a = OpenStudio::Analysis.create('workflow')
|
23
|
-
expect(a.workflow).not_to be nil
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should load the workflow from a file' do
|
27
|
-
OpenStudio::Analysis.measure_paths << 'spec/files/measures'
|
28
|
-
a = OpenStudio::Analysis.create('workflow')
|
29
|
-
file = File.join('spec/files/analysis/examples/medium_office_workflow.json')
|
30
|
-
expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should save a hash (version 1)' do
|
34
|
-
OpenStudio::Analysis.measure_paths << 'spec/files/measures'
|
35
|
-
a = OpenStudio::Analysis.create('workflow 2')
|
36
|
-
file = File.join('spec/files/analysis/examples/medium_office_workflow.json')
|
37
|
-
expect(a.workflow = OpenStudio::Analysis::Workflow.from_file(file)).not_to be nil
|
38
|
-
h = a.to_hash
|
39
|
-
# expect(h[:workflow].empty?).not_to eq true
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should create a save an empty analysis' do
|
43
|
-
a = OpenStudio::Analysis.create('workflow')
|
44
|
-
run_dir = 'spec/files/export/workflow'
|
45
|
-
|
46
|
-
FileUtils.mkdir_p run_dir
|
47
|
-
|
48
|
-
h = a.to_hash
|
49
|
-
expect(h[:analysis][:problem][:analysis_type]).to eq nil
|
50
|
-
expect(a.save("#{run_dir}/analysis.json")).to eq true
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should increment objective functions' do
|
54
|
-
a = OpenStudio::Analysis.create('my analysis')
|
55
|
-
|
56
|
-
a.add_output(
|
57
|
-
display_name: 'Total Natural Gas',
|
58
|
-
name: 'standard_report_legacy.total_natural_gas',
|
59
|
-
units: 'MJ/m2',
|
60
|
-
objective_function: true
|
61
|
-
)
|
62
|
-
|
63
|
-
expect(a.to_hash[:analysis][:output_variables].first[:objective_function_index]).to eq 0
|
64
|
-
|
65
|
-
a.add_output(
|
66
|
-
display_name: 'Another Output',
|
67
|
-
name: 'standard_report_legacy.output_2',
|
68
|
-
units: 'MJ/m2',
|
69
|
-
objective_function: true
|
70
|
-
)
|
71
|
-
expect(a.to_hash[:analysis][:output_variables].last[:objective_function_index]).to eq 1
|
72
|
-
|
73
|
-
a.add_output(
|
74
|
-
display_name: 'Another Output Not Objective Function',
|
75
|
-
name: 'standard_report_legacy.output_3',
|
76
|
-
units: 'MJ/m2',
|
77
|
-
objective_function: false
|
78
|
-
)
|
79
|
-
|
80
|
-
a.add_output(
|
81
|
-
display_name: 'Another Output 4',
|
82
|
-
name: 'standard_report_legacy.output_4',
|
83
|
-
units: 'MJ/m2',
|
84
|
-
objective_function: true
|
85
|
-
)
|
86
|
-
expect(a.to_hash[:analysis][:output_variables].last[:objective_function_index]).to eq 2
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should not add the same output' do
|
90
|
-
a = OpenStudio::Analysis.create('my analysis')
|
91
|
-
|
92
|
-
a.add_output(
|
93
|
-
display_name: 'Total Natural Gas',
|
94
|
-
name: 'standard_report_legacy.total_natural_gas',
|
95
|
-
units: 'MJ/m2',
|
96
|
-
objective_function: true
|
97
|
-
)
|
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: false # this doesn't do anything
|
104
|
-
)
|
105
|
-
|
106
|
-
expect(a.to_hash[:analysis][:output_variables].size).to eq 1
|
107
|
-
expect(a.to_hash[:analysis][:output_variables].last[:objective_function]).to eq true
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should create a new formulation' do
|
111
|
-
a = OpenStudio::Analysis.create('my analysis')
|
112
|
-
p = 'spec/files/measures/SetThermostatSchedules'
|
113
|
-
|
114
|
-
a.workflow.add_measure_from_path('thermostat', 'thermostat', p)
|
115
|
-
m = a.workflow.add_measure_from_path('thermostat_2', 'thermostat 2', p)
|
116
|
-
|
117
|
-
d = {
|
118
|
-
type: 'uniform',
|
119
|
-
minimum: 5,
|
120
|
-
maximum: 7,
|
121
|
-
mean: 6.2
|
122
|
-
}
|
123
|
-
m.make_variable('cooling_sch', 'Change the cooling schedule', d)
|
124
|
-
m.argument_value('heating_sch', 'some-string')
|
125
|
-
|
126
|
-
expect(a.workflow.measures.size).to eq 2
|
127
|
-
expect(a.workflow.measures[1].arguments[3][:value]).to eq 'some-string'
|
128
|
-
expect(a.workflow.measures[1].variables[0][:uuid]).to match /[\w]{8}(-[\w]{4}){3}-[\w]{12}/
|
129
|
-
|
130
|
-
a.analysis_type = 'single_run'
|
131
|
-
a.algorithm.set_attribute('sample_method', 'all_variables')
|
132
|
-
o = {
|
133
|
-
display_name: 'Total Natural Gas',
|
134
|
-
display_name_short: 'Total Natural Gas',
|
135
|
-
metadata_id: nil,
|
136
|
-
name: 'total_natural_gas',
|
137
|
-
units: 'MJ/m2',
|
138
|
-
objective_function: true,
|
139
|
-
objective_function_index: 0,
|
140
|
-
objective_function_target: 330.7,
|
141
|
-
scaling_factor: nil,
|
142
|
-
objective_function_group: nil
|
143
|
-
}
|
144
|
-
a.add_output(o)
|
145
|
-
|
146
|
-
a.seed_model = 'spec/files/small_seed.osm'
|
147
|
-
a.weather_file = 'spec/files/partial_weather.epw'
|
148
|
-
|
149
|
-
expect(a.seed_model.first).to eq 'spec/files/small_seed.osm'
|
150
|
-
|
151
|
-
expect(a.to_hash[:analysis][:problem][:algorithm][:objective_functions]).to match ['total_natural_gas']
|
152
|
-
expect(a.analysis_type).to eq 'single_run'
|
153
|
-
|
154
|
-
dp_hash = a.to_static_data_point_hash
|
155
|
-
expect(dp_hash[:data_point][:set_variable_values].values).to eq ['*No Change*']
|
156
|
-
end
|
157
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hash do
|
4
|
-
context 'deep key' do
|
5
|
-
before :all do
|
6
|
-
@h = {
|
7
|
-
a: %w(array_1 array_2),
|
8
|
-
b: {
|
9
|
-
c: {
|
10
|
-
'string_key' => 'finally'
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should find the key' do
|
17
|
-
expect(@h.deep_find(:a)).to eq %w(array_1 array_2)
|
18
|
-
expect(@h.deep_find('string_key')).to eq 'finally'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/spec/openstudio/osw_spec.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenStudio::Analysis::Translator::Workflow do
|
4
|
-
before :all do
|
5
|
-
clean_dir = File.expand_path 'spec/files/workflow/datapoints'
|
6
|
-
|
7
|
-
if Dir.exist? clean_dir
|
8
|
-
FileUtils.rm_rf clean_dir
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'read in the osa' do
|
13
|
-
let(:osa_path) { File.expand_path 'analysis.osa' }
|
14
|
-
|
15
|
-
before(:each) do
|
16
|
-
Dir.chdir 'spec/files/workflow'
|
17
|
-
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
18
|
-
end
|
19
|
-
|
20
|
-
after(:each) do
|
21
|
-
Dir.chdir '../../..'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should find and load the osa' do
|
25
|
-
expect(@translator).not_to be_nil
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should load the analysis' do
|
29
|
-
expect(@translator.osa.class).to eq(Hash)
|
30
|
-
expect(@translator.osa).not_to eq({})
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should not have measure or file paths' do
|
34
|
-
expect(@translator.file_paths).to eq([])
|
35
|
-
expect(@translator.measure_paths).to eq([])
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should have steps' do
|
39
|
-
expect(@translator.steps.class).to eq(Array)
|
40
|
-
expect(@translator.steps).not_to eq([])
|
41
|
-
@translator.steps.each do |step|
|
42
|
-
expect(step.class).to eq(Hash)
|
43
|
-
expect(step).not_to eq({})
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'write individual osws' do
|
49
|
-
let(:osa_path) { 'analysis.osa' }
|
50
|
-
|
51
|
-
before(:each) do
|
52
|
-
FileUtils.mkdir_p 'spec/files/export/workflow' unless Dir.exist? 'spec/files/export/workflow'
|
53
|
-
|
54
|
-
Dir.chdir 'spec/files/workflow'
|
55
|
-
@translator = OpenStudio::Analysis::Translator::Workflow.new(osa_path)
|
56
|
-
end
|
57
|
-
|
58
|
-
after(:each) do
|
59
|
-
Dir.chdir '../../..'
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should write a single osd' do
|
63
|
-
osd_path = 'datapoint_0.osd'
|
64
|
-
result = @translator.process_datapoint(osd_path)
|
65
|
-
expect(result).to be_a(Hash)
|
66
|
-
|
67
|
-
# Save the file to the export directory
|
68
|
-
File.open('../../../spec/files/export/workflow/0.osw', 'w') { |f| f << JSON.pretty_generate(result) }
|
69
|
-
|
70
|
-
expect(result.key?(:seed_model)).to eq false
|
71
|
-
expect(result[:seed_file]).to eq 'large_office_air_cooled_chiller.osm'
|
72
|
-
expect(result[:weather_file]).to eq 'USA_CO_Denver.Intl.AP.725650_TMY3.epw'
|
73
|
-
expect(result[:file_format_version]).to eq '0.0.1'
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should not write a osd with a different osa id' do
|
77
|
-
osd_path = 'datapoint_wrong_osa_id.osd'
|
78
|
-
expect { @translator.process_datapoint(osd_path).first }.to raise_error(RuntimeError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'should write several osds' do
|
82
|
-
osd_paths = %w(datapoint_0.osd datapoint_1.osd datapoint_2.osd)
|
83
|
-
r = @translator.process_datapoints(osd_paths)
|
84
|
-
expect(r.size).to eq 3
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should not fail when one osd is bad' do
|
88
|
-
osd_paths = %w(datapoint_0.osd datapoint_1.osd datapoint_wrong_osa_id.osd)
|
89
|
-
r = @translator.process_datapoints(osd_paths)
|
90
|
-
expect(r[0]).to be_a Hash
|
91
|
-
expect(r[2]).to eq nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenStudio::Analysis::ServerApi do
|
4
|
-
before :all do
|
5
|
-
@host = 'http://localhost:8080'
|
6
|
-
end
|
7
|
-
|
8
|
-
context 'create a new object instance' do
|
9
|
-
before(:all) do
|
10
|
-
@api = OpenStudio::Analysis::ServerApi.new
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should set the default host to localhost' do
|
14
|
-
expect(@api.hostname).to eq(@host)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'test not localhost' do
|
19
|
-
it 'should have a not localhost URL' do
|
20
|
-
options = { hostname: 'http://abc.def.ghi' }
|
21
|
-
api = OpenStudio::Analysis::ServerApi.new(options)
|
22
|
-
expect(api.hostname).to eq(options[:hostname])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
File without changes
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenStudio::Analysis::SupportFiles do
|
4
|
-
before :all do
|
5
|
-
@s = OpenStudio::Analysis::SupportFiles.new
|
6
|
-
expect(@s).to be_a OpenStudio::Analysis::SupportFiles
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should add files' do
|
10
|
-
f = 'spec/files/worker_init/first_file.rb'
|
11
|
-
@s.add(f)
|
12
|
-
|
13
|
-
expect(@s.size).to eq 1
|
14
|
-
expect(@s.files.first[:file]).to eq f
|
15
|
-
|
16
|
-
# add some other items
|
17
|
-
@s.add('spec/files/worker_init/second_file.rb')
|
18
|
-
|
19
|
-
expect(@s.size).to eq 2
|
20
|
-
@s.each do |f|
|
21
|
-
expect(f).to_not be nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should remove existing items' do
|
26
|
-
f = 'spec/files/worker_init/second_file.rb'
|
27
|
-
@s.add(f)
|
28
|
-
|
29
|
-
@s.clear
|
30
|
-
expect(@s.size).to eq 0
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should only add existing files' do
|
34
|
-
f = 'spec/files/worker_init/second_file.rb'
|
35
|
-
@s.add(f)
|
36
|
-
@s.add(f)
|
37
|
-
|
38
|
-
expect(@s.size).to eq 1
|
39
|
-
|
40
|
-
f = 'non-existent.rb'
|
41
|
-
expect { @s.add(f) }.to raise_error /Path or file does not exist and cannot be added.*/
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should add metadata data' do
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should add a directory' do
|
48
|
-
@s.clear
|
49
|
-
@s.add_files('spec/files/measures/**/*.rb', d: 'new')
|
50
|
-
|
51
|
-
expect(@s.size).to eq 10
|
52
|
-
expect(@s[0][:metadata][:d]).to eq 'new'
|
53
|
-
end
|
54
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenStudio::Weather::Epw do
|
4
|
-
before :all do
|
5
|
-
@s = OpenStudio::Analysis::SupportFiles.new
|
6
|
-
expect(@s).to be_a OpenStudio::Analysis::SupportFiles
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should process the header of a weather file' do
|
10
|
-
epw = OpenStudio::Weather::Epw.load('spec/files/partial_weather.epw')
|
11
|
-
expect(epw.valid?).to be true
|
12
|
-
expect(epw.city).to eq 'Denver Intl Ap'
|
13
|
-
expect(epw.state).to eq 'CO'
|
14
|
-
expect(epw.country).to eq 'USA'
|
15
|
-
expect(epw.data_type).to eq 'TMY3'
|
16
|
-
expect(epw.wmo).to eq 725650
|
17
|
-
expect(epw.lat).to eq 39.83
|
18
|
-
expect(epw.lon).to eq -104.65
|
19
|
-
expect(epw.gmt).to eq -7.0
|
20
|
-
expect(epw.elevation).to eq 1650.0
|
21
|
-
|
22
|
-
expect(epw.header_data.size).to eq 7
|
23
|
-
expect(epw.weather_data.size).to eq 24
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should read and write the weather file' do
|
27
|
-
o = 'spec/files/partial_weather.epw'
|
28
|
-
epw = OpenStudio::Weather::Epw.load(o)
|
29
|
-
f = 'spec/files/export/weather/weather_out.epw'
|
30
|
-
File.delete(f) if File.exist? f
|
31
|
-
expect(epw.save_as(f)).to eq true
|
32
|
-
expect(File.exist?(f)).to eq true
|
33
|
-
expect(File.size(o)).to eq File.size(f)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should append weather data' do
|
37
|
-
o = 'spec/files/partial_weather.epw'
|
38
|
-
epw = OpenStudio::Weather::Epw.load(o)
|
39
|
-
|
40
|
-
epw.append_weather_data(o)
|
41
|
-
|
42
|
-
f = 'spec/files/export/weather/weather_out_appended.epw'
|
43
|
-
epw.save_as(f)
|
44
|
-
end
|
45
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenStudio::Analysis::Workflow do
|
4
|
-
before :all do
|
5
|
-
@w = OpenStudio::Analysis::Workflow.new
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should create a workflow' do
|
9
|
-
expect(@w).not_to be nil
|
10
|
-
expect(@w).to be_a OpenStudio::Analysis::Workflow
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should add a measure' do
|
14
|
-
p = 'spec/files/measures/IncreaseInsulationRValueForRoofs'
|
15
|
-
expect(@w.add_measure_from_path('insulation', 'Increase Insulation', p)).to be_an OpenStudio::Analysis::WorkflowStep
|
16
|
-
|
17
|
-
p = 'spec/files/measures/ActualMeasureNoJson'
|
18
|
-
FileUtils.remove "#{p}/measure.json" if File.exist? "#{p}/measure.json"
|
19
|
-
m = @w.add_measure_from_path('a_measure', 'Actual Measure', p)
|
20
|
-
expect(m).to be_a OpenStudio::Analysis::WorkflowStep
|
21
|
-
expect(m.measure_definition_class_name).to eq 'RotateBuilding'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should fix the path of the measure' do
|
25
|
-
p = 'spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb'
|
26
|
-
m = @w.add_measure_from_path('insulation', 'Increase Insulation', p)
|
27
|
-
expect(m).to be_an OpenStudio::Analysis::WorkflowStep
|
28
|
-
expect(m.measure_definition_directory).to eq './measures/IncreaseInsulationRValueForRoofs'
|
29
|
-
expect(m.measure_definition_directory_local).to eq 'spec/files/measures/IncreaseInsulationRValueForRoofs'
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should clear out a workflow' do
|
33
|
-
p = 'spec/files/measures/SetThermostatSchedules'
|
34
|
-
@w.add_measure_from_path('thermostat', 'thermostat', p)
|
35
|
-
@w.add_measure_from_path('thermostat 2', 'thermostat 2', p)
|
36
|
-
|
37
|
-
expect(@w.items.size).to be > 1
|
38
|
-
@w.clear
|
39
|
-
expect(@w.items.size).to eq 0
|
40
|
-
|
41
|
-
@w.add_measure_from_path('thermostat', 'thermostat', p)
|
42
|
-
@w.add_measure_from_path('thermostat 2', 'thermostat 2', p)
|
43
|
-
expect(@w.items.size).to eq 2
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should find a workflow step' do
|
47
|
-
@w.clear
|
48
|
-
|
49
|
-
p = 'spec/files/measures/SetThermostatSchedules'
|
50
|
-
@w.add_measure_from_path('thermostat', 'thermostat', p)
|
51
|
-
@w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
|
52
|
-
|
53
|
-
m = @w.find_measure('thermostat_2')
|
54
|
-
expect(m).not_to be nil
|
55
|
-
expect(m).to be_a OpenStudio::Analysis::WorkflowStep
|
56
|
-
expect(m.name).to eq 'thermostat_2'
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should find a workflow step and make a variable' do
|
60
|
-
@w.clear
|
61
|
-
|
62
|
-
p = 'spec/files/measures/SetThermostatSchedules'
|
63
|
-
@w.add_measure_from_path('thermostat', 'thermostat', p)
|
64
|
-
@w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
|
65
|
-
|
66
|
-
m = @w.find_measure('thermostat_2')
|
67
|
-
expect(m.argument_names).to eq %w(__SKIP__ zones cooling_sch heating_sch material_cost)
|
68
|
-
|
69
|
-
d = {
|
70
|
-
type: 'uniform',
|
71
|
-
minimum: 5,
|
72
|
-
maximum: 7,
|
73
|
-
mean: 6.2
|
74
|
-
}
|
75
|
-
m.make_variable('cooling_sch', 'Change the cooling schedule', d)
|
76
|
-
|
77
|
-
d = {
|
78
|
-
type: 'uniform',
|
79
|
-
minimum: 5,
|
80
|
-
maximum: 7,
|
81
|
-
mean: 6.2
|
82
|
-
}
|
83
|
-
m.make_variable('heating_sch', 'Change the heating schedule', d)
|
84
|
-
|
85
|
-
expect(@w.measures.size).to eq 2
|
86
|
-
expect(@w.items.size).to eq 2
|
87
|
-
expect(@w.items.size).to eq 2
|
88
|
-
|
89
|
-
expect(@w.all_variables.size).to eq 2
|
90
|
-
end
|
91
|
-
end
|