openstudio-workflow 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -72
  3. data/README.md +93 -48
  4. data/Rakefile +36 -36
  5. data/lib/openstudio-workflow.rb +49 -49
  6. data/lib/openstudio/workflow/adapters/input/local.rb +244 -240
  7. data/lib/openstudio/workflow/adapters/output/local.rb +95 -95
  8. data/lib/openstudio/workflow/adapters/output/socket.rb +91 -91
  9. data/lib/openstudio/workflow/adapters/output/web.rb +66 -66
  10. data/lib/openstudio/workflow/adapters/output_adapter.rb +147 -147
  11. data/lib/openstudio/workflow/job.rb +22 -22
  12. data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
  13. data/lib/openstudio/workflow/jobs/run_energyplus.rb +49 -49
  14. data/lib/openstudio/workflow/jobs/run_ep_measures.rb +55 -55
  15. data/lib/openstudio/workflow/jobs/run_initialization.rb +169 -167
  16. data/lib/openstudio/workflow/jobs/run_os_measures.rb +69 -69
  17. data/lib/openstudio/workflow/jobs/run_postprocess.rb +53 -53
  18. data/lib/openstudio/workflow/jobs/run_preprocess.rb +69 -69
  19. data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +98 -98
  20. data/lib/openstudio/workflow/jobs/run_translation.rb +61 -61
  21. data/lib/openstudio/workflow/multi_delegator.rb +46 -46
  22. data/lib/openstudio/workflow/registry.rb +137 -137
  23. data/lib/openstudio/workflow/run.rb +299 -299
  24. data/lib/openstudio/workflow/time_logger.rb +53 -53
  25. data/lib/openstudio/workflow/util.rb +14 -14
  26. data/lib/openstudio/workflow/util/energyplus.rb +566 -564
  27. data/lib/openstudio/workflow/util/io.rb +33 -33
  28. data/lib/openstudio/workflow/util/measure.rb +588 -588
  29. data/lib/openstudio/workflow/util/model.rb +100 -100
  30. data/lib/openstudio/workflow/util/post_process.rb +187 -187
  31. data/lib/openstudio/workflow/util/weather_file.rb +108 -108
  32. data/lib/openstudio/workflow/version.rb +24 -24
  33. data/lib/openstudio/workflow_json.rb +426 -426
  34. data/lib/openstudio/workflow_runner.rb +233 -215
  35. metadata +3 -3
@@ -1,49 +1,49 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # This class runs the EnergyPlus simulation
21
- class RunEnergyPlus < OpenStudio::Workflow::Job
22
- require 'openstudio/workflow/util/energyplus'
23
- include OpenStudio::Workflow::Util::EnergyPlus
24
-
25
- def initialize(input_adapter, output_adapter, registry, options = {})
26
- super
27
- end
28
-
29
- def perform
30
- @logger.debug "Calling #{__method__} in the #{self.class} class"
31
-
32
- # Checks and configuration
33
- raise 'No run_dir specified in the registry' unless @registry[:run_dir]
34
- ep_path = @options[:energyplus_path] ? @options[:energyplus_path] : nil
35
- @logger.warn "Using EnergyPlus path specified in options #{ep_path}" if ep_path
36
-
37
- @logger.info 'Starting the EnergyPlus simulation'
38
- @registry[:time_logger].start('Running EnergyPlus') if @registry[:time_logger]
39
- call_energyplus(@registry[:run_dir], ep_path, @output_adapter, @logger, @registry[:workflow_json])
40
- @registry[:time_logger].stop('Running EnergyPlus') if @registry[:time_logger]
41
- @logger.info 'Completed the EnergyPlus simulation'
42
-
43
- sql_path = File.join(@registry[:run_dir], 'eplusout.sql')
44
- @registry.register(:sql) { sql_path } if File.exist? sql_path
45
- @logger.warn "Unable to find sql file at #{sql_path}" unless @registry[:sql]
46
-
47
- nil
48
- end
49
- end
1
+ ######################################################################
2
+ # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
+ # All rights reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ ######################################################################
19
+
20
+ # This class runs the EnergyPlus simulation
21
+ class RunEnergyPlus < OpenStudio::Workflow::Job
22
+ require 'openstudio/workflow/util/energyplus'
23
+ include OpenStudio::Workflow::Util::EnergyPlus
24
+
25
+ def initialize(input_adapter, output_adapter, registry, options = {})
26
+ super
27
+ end
28
+
29
+ def perform
30
+ @logger.debug "Calling #{__method__} in the #{self.class} class"
31
+
32
+ # Checks and configuration
33
+ raise 'No run_dir specified in the registry' unless @registry[:run_dir]
34
+ ep_path = @options[:energyplus_path] ? @options[:energyplus_path] : nil
35
+ @logger.warn "Using EnergyPlus path specified in options #{ep_path}" if ep_path
36
+
37
+ @logger.info 'Starting the EnergyPlus simulation'
38
+ @registry[:time_logger].start('Running EnergyPlus') if @registry[:time_logger]
39
+ call_energyplus(@registry[:run_dir], ep_path, @output_adapter, @logger, @registry[:workflow_json])
40
+ @registry[:time_logger].stop('Running EnergyPlus') if @registry[:time_logger]
41
+ @logger.info 'Completed the EnergyPlus simulation'
42
+
43
+ sql_path = File.join(@registry[:run_dir], 'eplusout.sql')
44
+ @registry.register(:sql) { sql_path } if File.exist? sql_path
45
+ @logger.warn "Unable to find sql file at #{sql_path}" unless @registry[:sql]
46
+
47
+ nil
48
+ end
49
+ end
@@ -1,55 +1,55 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # This class runs all EnergyPlus measures defined in the OSW
21
- class RunEnergyPlusMeasures < OpenStudio::Workflow::Job
22
- require 'openstudio/workflow/util'
23
- include OpenStudio::Workflow::Util::Measure
24
- include OpenStudio::Workflow::Util::Model
25
-
26
- def initialize(input_adapter, output_adapter, registry, options = {})
27
- super
28
- end
29
-
30
- def perform
31
- @logger.debug "Calling #{__method__} in the #{self.class} class"
32
-
33
- # Ensure output_attributes is initialized in the registry
34
- @registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
35
-
36
- # Apply the EnergyPlus measures
37
- @options[:output_adapter] = @output_adapter
38
- @logger.info 'Beginning to execute EnergyPlus measures.'
39
- apply_measures('EnergyPlusMeasure'.to_MeasureType, @registry, @options)
40
- @logger.info('Finished applying EnergyPlus measures.')
41
-
42
- # Send the measure output attributes to the output adapter
43
- @logger.debug 'Communicating measure output attributes to the output adapter'
44
- @output_adapter.communicate_measure_attributes @registry[:output_attributes]
45
-
46
- # Save both the OSM and IDF if the :debug option is true
47
- return nil unless @options[:debug]
48
- @registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
49
- idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
50
- @registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
51
- @logger.debug "Saved IDF as #{idf_name}"
52
-
53
- nil
54
- end
55
- end
1
+ ######################################################################
2
+ # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
+ # All rights reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ ######################################################################
19
+
20
+ # This class runs all EnergyPlus measures defined in the OSW
21
+ class RunEnergyPlusMeasures < OpenStudio::Workflow::Job
22
+ require 'openstudio/workflow/util'
23
+ include OpenStudio::Workflow::Util::Measure
24
+ include OpenStudio::Workflow::Util::Model
25
+
26
+ def initialize(input_adapter, output_adapter, registry, options = {})
27
+ super
28
+ end
29
+
30
+ def perform
31
+ @logger.debug "Calling #{__method__} in the #{self.class} class"
32
+
33
+ # Ensure output_attributes is initialized in the registry
34
+ @registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
35
+
36
+ # Apply the EnergyPlus measures
37
+ @options[:output_adapter] = @output_adapter
38
+ @logger.info 'Beginning to execute EnergyPlus measures.'
39
+ apply_measures('EnergyPlusMeasure'.to_MeasureType, @registry, @options)
40
+ @logger.info('Finished applying EnergyPlus measures.')
41
+
42
+ # Send the measure output attributes to the output adapter
43
+ @logger.debug 'Communicating measure output attributes to the output adapter'
44
+ @output_adapter.communicate_measure_attributes @registry[:output_attributes]
45
+
46
+ # Save both the OSM and IDF if the :debug option is true
47
+ return nil unless @options[:debug]
48
+ @registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
49
+ idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
50
+ @registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
51
+ @logger.debug "Saved IDF as #{idf_name}"
52
+
53
+ nil
54
+ end
55
+ end
@@ -1,167 +1,169 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # Run the initialization job to run validations and initializations
21
- class RunInitialization < OpenStudio::Workflow::Job
22
- require 'openstudio/workflow/util'
23
- include OpenStudio::Workflow::Util::WeatherFile
24
- include OpenStudio::Workflow::Util::Model
25
- include OpenStudio::Workflow::Util::Measure
26
-
27
- def initialize(input_adapter, output_adapter, registry, options = {})
28
- defaults = {
29
- verify_osw: true
30
- }
31
- options = defaults.merge(options)
32
- super
33
- end
34
-
35
- def perform
36
- # DLM: why are there multiple loggers running around? there is one in the registry can we just use that?
37
- @logger.info "Calling #{__method__} in the #{self.class} class"
38
-
39
- # Communicate that the workflow has been started
40
- @logger.debug 'Registering that the workflow has started with the adapter'
41
- @output_adapter.communicate_started
42
-
43
- # Load various files and set basic directories for the registry
44
- # DLM: this key is the raw JSON object, it is deprecated and should not be used, use :workflow_json instead
45
- @registry.register(:workflow) { @input_adapter.workflow }
46
- raise 'Specified workflow was nil' unless @registry[:workflow]
47
- @logger.debug 'Retrieved the workflow from the adapter'
48
-
49
- @registry.register(:osw_dir) { @input_adapter.osw_dir }
50
- @logger.debug "osw_dir is #{@registry[:osw_dir]}"
51
-
52
- @registry.register(:datapoint) { @input_adapter.datapoint }
53
- @logger.debug 'Found associated OSD file' if @registry[:datapoint]
54
-
55
- @registry.register(:analysis) { @input_adapter.analysis }
56
- @logger.debug 'Found associated OSA file' if @registry[:analysis]
57
-
58
- # create the real WorkflowJSON here, we will be able to edit this during the run
59
- if @registry[:openstudio_2]
60
- workflow_json = OpenStudio::WorkflowJSON.new(JSON.fast_generate(@registry[:workflow]))
61
- workflow_json.setOswDir(@registry[:osw_dir])
62
- else
63
- workflow_json = WorkflowJSON_Shim.new(@registry[:workflow], @registry[:osw_dir])
64
- end
65
- @registry.register(:workflow_json) { workflow_json }
66
-
67
- @registry.register(:root_dir) { workflow_json.absoluteRootDir }
68
- @logger.debug "The root_dir for the datapoint is #{@registry[:root_dir]}"
69
-
70
- reports_dir = "#{@registry[:root_dir]}/reports"
71
- if File.exist?(reports_dir)
72
- @logger.debug "Removing existing reports directory: #{reports_dir}"
73
- FileUtils.rm_rf(reports_dir)
74
- end
75
-
76
- # create the runner with our WorkflowJSON
77
- @registry.register(:runner) { WorkflowRunner.new(@registry[:logger], @registry[:workflow_json], @registry[:openstudio_2]) }
78
- @logger.debug 'Initialized runner'
79
-
80
- # Validate the OSW measures if the flag is set to true, (the default state)
81
- if @options[:verify_osw]
82
- @logger.info 'Attempting to validate the measure workflow'
83
- validate_measures(@registry, @logger)
84
- @logger.info 'Validated the measure workflow'
85
- end
86
-
87
- # Load or create the seed OSM object
88
- @logger.debug 'Finding and loading the seed file'
89
- model_path = workflow_json.seedFile
90
- if !model_path.empty?
91
-
92
- model_full_path = workflow_json.findFile(model_path.get)
93
- if model_full_path.empty?
94
- raise "Seed model #{model_path.get} specified in OSW cannot be found"
95
- end
96
- model_full_path = model_full_path.get
97
-
98
- if File.extname(model_full_path.to_s) == '.idf'
99
- @registry.register(:model_idf) { load_idf(model_full_path, @logger) }
100
- @registry.register(:model) { nil }
101
- else
102
- @registry.register(:model) { load_osm(model_full_path, @logger) }
103
- end
104
- else
105
- @registry.register(:model) { OpenStudio::Model::Model.new }
106
-
107
- # add default objects to the model
108
- begin
109
- OpenStudio::Model::initializeModelObjects(@registry[:model])
110
- rescue NameError
111
- @registry[:model].getBuilding
112
- @registry[:model].getFacility
113
- @registry[:model].getSimulationControl
114
- @registry[:model].getSizingParameters
115
- @registry[:model].getTimestep
116
- @registry[:model].getShadowCalculation
117
- @registry[:model].getHeatBalanceAlgorithm
118
- @registry[:model].getRunPeriod
119
- @registry[:model].getLifeCycleCostParameters
120
- end
121
- end
122
-
123
- if @registry[:openstudio_2]
124
- if @registry[:model]
125
- @registry[:model].setWorkflowJSON(workflow_json.clone)
126
- end
127
- end
128
-
129
- # DLM: TODO, load weather_file from options so it can be overriden by user_options
130
-
131
- # Find the weather file, should it exist and be findable
132
- @logger.debug 'Getting the initial weather file'
133
- weather_path = workflow_json.weatherFile
134
- if weather_path.empty?
135
- @logger.debug 'No weather file specified in OSW, looking in model'
136
- if @registry[:model]
137
- model = @registry[:model]
138
- unless model.weatherFile.empty?
139
- weather_path = model.weatherFile.get.path
140
- end
141
- end
142
- end
143
-
144
- unless weather_path.empty?
145
- weather_path = weather_path.get
146
- @logger.debug 'Searching for weather file #{weather_path}'
147
-
148
- weather_full_path = workflow_json.findFile(weather_path)
149
- if weather_full_path.empty?
150
- weather_full_path = workflow_json.findFile(File.basename(weather_path.to_s))
151
- end
152
-
153
- if weather_full_path.empty?
154
- raise "Weather file '#{weather_path}' specified but cannot be found"
155
- end
156
- weather_full_path = weather_full_path.get
157
-
158
- @registry.register(:wf) { weather_full_path.to_s }
159
-
160
- end
161
- @logger.warn 'No valid weather file defined in either the osm or osw.' unless @registry[:wf]
162
-
163
- workflow_json.start
164
-
165
- nil
166
- end
167
- end
1
+ ######################################################################
2
+ # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
+ # All rights reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ ######################################################################
19
+
20
+ # Run the initialization job to run validations and initializations
21
+ class RunInitialization < OpenStudio::Workflow::Job
22
+ require 'openstudio/workflow/util'
23
+ include OpenStudio::Workflow::Util::WeatherFile
24
+ include OpenStudio::Workflow::Util::Model
25
+ include OpenStudio::Workflow::Util::Measure
26
+
27
+ def initialize(input_adapter, output_adapter, registry, options = {})
28
+ defaults = {
29
+ verify_osw: true
30
+ }
31
+ options = defaults.merge(options)
32
+ super
33
+ end
34
+
35
+ def perform
36
+ # DLM: why are there multiple loggers running around? there is one in the registry can we just use that?
37
+ @logger.info "Calling #{__method__} in the #{self.class} class"
38
+
39
+ # Communicate that the workflow has been started
40
+ @logger.debug 'Registering that the workflow has started with the adapter'
41
+ @output_adapter.communicate_started
42
+
43
+ # Load various files and set basic directories for the registry
44
+ # DLM: this key is the raw JSON object, it is deprecated and should not be used, use :workflow_json instead
45
+ @registry.register(:workflow) { @input_adapter.workflow }
46
+ raise 'Specified workflow was nil' unless @registry[:workflow]
47
+ @logger.debug 'Retrieved the workflow from the adapter'
48
+
49
+ @registry.register(:osw_dir) { @input_adapter.osw_dir }
50
+ @logger.debug "osw_dir is #{@registry[:osw_dir]}"
51
+
52
+ @registry.register(:datapoint) { @input_adapter.datapoint }
53
+ @logger.debug 'Found associated OSD file' if @registry[:datapoint]
54
+
55
+ @registry.register(:analysis) { @input_adapter.analysis }
56
+ @logger.debug 'Found associated OSA file' if @registry[:analysis]
57
+
58
+ # create the real WorkflowJSON here, we will be able to edit this during the run
59
+ if @registry[:openstudio_2]
60
+ workflow_json = OpenStudio::WorkflowJSON.new(JSON.fast_generate(@registry[:workflow]))
61
+ workflow_json.setOswDir(@registry[:osw_dir])
62
+ else
63
+ workflow_json = WorkflowJSON_Shim.new(@registry[:workflow], @registry[:osw_dir])
64
+ end
65
+ @registry.register(:workflow_json) { workflow_json }
66
+
67
+ @registry.register(:root_dir) { workflow_json.absoluteRootDir }
68
+ @logger.debug "The root_dir for the datapoint is #{@registry[:root_dir]}"
69
+
70
+ reports_dir = "#{@registry[:root_dir]}/reports"
71
+ if File.exist?(reports_dir)
72
+ @logger.debug "Removing existing reports directory: #{reports_dir}"
73
+ FileUtils.rm_rf(reports_dir)
74
+ end
75
+
76
+ # create the runner with our WorkflowJSON
77
+ @registry.register(:runner) { WorkflowRunner.new(@registry[:logger], @registry[:workflow_json], @registry[:openstudio_2]) }
78
+ @registry[:runner].setDatapoint(@registry[:datapoint])
79
+ @registry[:runner].setAnalysis(@registry[:analysis])
80
+ @logger.debug 'Initialized runner'
81
+
82
+ # Validate the OSW measures if the flag is set to true, (the default state)
83
+ if @options[:verify_osw]
84
+ @logger.info 'Attempting to validate the measure workflow'
85
+ validate_measures(@registry, @logger)
86
+ @logger.info 'Validated the measure workflow'
87
+ end
88
+
89
+ # Load or create the seed OSM object
90
+ @logger.debug 'Finding and loading the seed file'
91
+ model_path = workflow_json.seedFile
92
+ if !model_path.empty?
93
+
94
+ model_full_path = workflow_json.findFile(model_path.get)
95
+ if model_full_path.empty?
96
+ raise "Seed model #{model_path.get} specified in OSW cannot be found"
97
+ end
98
+ model_full_path = model_full_path.get
99
+
100
+ if File.extname(model_full_path.to_s) == '.idf'
101
+ @registry.register(:model_idf) { load_idf(model_full_path, @logger) }
102
+ @registry.register(:model) { nil }
103
+ else
104
+ @registry.register(:model) { load_osm(model_full_path, @logger) }
105
+ end
106
+ else
107
+ @registry.register(:model) { OpenStudio::Model::Model.new }
108
+
109
+ # add default objects to the model
110
+ begin
111
+ OpenStudio::Model::initializeModelObjects(@registry[:model])
112
+ rescue NameError
113
+ @registry[:model].getBuilding
114
+ @registry[:model].getFacility
115
+ @registry[:model].getSimulationControl
116
+ @registry[:model].getSizingParameters
117
+ @registry[:model].getTimestep
118
+ @registry[:model].getShadowCalculation
119
+ @registry[:model].getHeatBalanceAlgorithm
120
+ @registry[:model].getRunPeriod
121
+ @registry[:model].getLifeCycleCostParameters
122
+ end
123
+ end
124
+
125
+ if @registry[:openstudio_2]
126
+ if @registry[:model]
127
+ @registry[:model].setWorkflowJSON(workflow_json.clone)
128
+ end
129
+ end
130
+
131
+ # DLM: TODO, load weather_file from options so it can be overriden by user_options
132
+
133
+ # Find the weather file, should it exist and be findable
134
+ @logger.debug 'Getting the initial weather file'
135
+ weather_path = workflow_json.weatherFile
136
+ if weather_path.empty?
137
+ @logger.debug 'No weather file specified in OSW, looking in model'
138
+ if @registry[:model]
139
+ model = @registry[:model]
140
+ unless model.weatherFile.empty?
141
+ weather_path = model.weatherFile.get.path
142
+ end
143
+ end
144
+ end
145
+
146
+ unless weather_path.empty?
147
+ weather_path = weather_path.get
148
+ @logger.debug 'Searching for weather file #{weather_path}'
149
+
150
+ weather_full_path = workflow_json.findFile(weather_path)
151
+ if weather_full_path.empty?
152
+ weather_full_path = workflow_json.findFile(File.basename(weather_path.to_s))
153
+ end
154
+
155
+ if weather_full_path.empty?
156
+ raise "Weather file '#{weather_path}' specified but cannot be found"
157
+ end
158
+ weather_full_path = weather_full_path.get
159
+
160
+ @registry.register(:wf) { weather_full_path.to_s }
161
+
162
+ end
163
+ @logger.warn 'No valid weather file defined in either the osm or osw.' unless @registry[:wf]
164
+
165
+ workflow_json.start
166
+
167
+ nil
168
+ end
169
+ end