openstudio-workflow 1.3.4 → 1.3.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -77
- data/README.md +67 -93
- data/Rakefile +36 -36
- data/lib/openstudio-workflow.rb +65 -65
- data/lib/openstudio/workflow/adapters/input/local.rb +311 -324
- data/lib/openstudio/workflow/adapters/output/local.rb +158 -161
- data/lib/openstudio/workflow/adapters/output/socket.rb +106 -107
- data/lib/openstudio/workflow/adapters/output/web.rb +82 -82
- data/lib/openstudio/workflow/adapters/output_adapter.rb +163 -163
- data/lib/openstudio/workflow/job.rb +57 -57
- data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
- data/lib/openstudio/workflow/jobs/run_energyplus.rb +70 -70
- data/lib/openstudio/workflow/jobs/run_ep_measures.rb +73 -73
- data/lib/openstudio/workflow/jobs/run_initialization.rb +203 -203
- data/lib/openstudio/workflow/jobs/run_os_measures.rb +89 -89
- data/lib/openstudio/workflow/jobs/run_postprocess.rb +73 -73
- data/lib/openstudio/workflow/jobs/run_preprocess.rb +104 -104
- data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +118 -118
- data/lib/openstudio/workflow/jobs/run_translation.rb +84 -84
- data/lib/openstudio/workflow/multi_delegator.rb +62 -62
- data/lib/openstudio/workflow/registry.rb +172 -172
- data/lib/openstudio/workflow/run.rb +342 -328
- data/lib/openstudio/workflow/time_logger.rb +96 -96
- data/lib/openstudio/workflow/util.rb +49 -49
- data/lib/openstudio/workflow/util/energyplus.rb +575 -605
- data/lib/openstudio/workflow/util/io.rb +68 -68
- data/lib/openstudio/workflow/util/measure.rb +658 -650
- data/lib/openstudio/workflow/util/model.rb +151 -151
- data/lib/openstudio/workflow/util/post_process.rb +235 -238
- data/lib/openstudio/workflow/util/weather_file.rb +143 -143
- data/lib/openstudio/workflow/version.rb +40 -40
- data/lib/openstudio/workflow_json.rb +475 -476
- data/lib/openstudio/workflow_runner.rb +263 -268
- metadata +24 -24
@@ -1,89 +1,89 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
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
|
-
# Run any OpenStudio measures contained in the OSW
|
37
|
-
class RunOpenStudioMeasures < OpenStudio::Workflow::Job
|
38
|
-
# Mixin the required util modules
|
39
|
-
require 'openstudio/workflow/util'
|
40
|
-
include OpenStudio::Workflow::Util::Measure
|
41
|
-
include OpenStudio::Workflow::Util::Model
|
42
|
-
|
43
|
-
def initialize(input_adapter, output_adapter, registry, options = {})
|
44
|
-
super
|
45
|
-
end
|
46
|
-
|
47
|
-
def perform
|
48
|
-
@logger.debug "Calling #{__method__} in the #{self.class} class"
|
49
|
-
|
50
|
-
# halted workflow is handled in apply_measures
|
51
|
-
|
52
|
-
# set weather file
|
53
|
-
if @registry[:wf] && @registry[:model]
|
54
|
-
epwFile = OpenStudio::EpwFile.load(@registry[:wf])
|
55
|
-
if !epwFile.empty?
|
56
|
-
OpenStudio::Model::WeatherFile.setWeatherFile(@registry[:model], epwFile.get)
|
57
|
-
else
|
58
|
-
@logger.warn "Could not load weather file from '#{@registry[:wf]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Ensure output_attributes is initialized in the registry
|
63
|
-
@registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
|
64
|
-
|
65
|
-
# Execute the OpenStudio measures
|
66
|
-
@options[:output_adapter] = @output_adapter
|
67
|
-
@logger.info 'Beginning to execute OpenStudio measures.'
|
68
|
-
apply_measures('ModelMeasure'.to_MeasureType, @registry, @options)
|
69
|
-
@logger.info('Finished applying OpenStudio measures.')
|
70
|
-
|
71
|
-
# Send the measure output attributes to the output adapter
|
72
|
-
@logger.debug 'Communicating measure output attributes to the output adapter'
|
73
|
-
@output_adapter.communicate_measure_attributes @registry[:output_attributes]
|
74
|
-
|
75
|
-
# save the final OSM
|
76
|
-
if !@options[:fast]
|
77
|
-
save_osm(@registry[:model], @registry[:run_dir])
|
78
|
-
end
|
79
|
-
|
80
|
-
# Save the OSM if the :debug option is true
|
81
|
-
return nil unless @options[:debug]
|
82
|
-
@registry[:time_logger].start('Saving OSM') if @registry[:time_logger]
|
83
|
-
osm_name = save_osm(@registry[:model], @registry[:root_dir])
|
84
|
-
@registry[:time_logger].stop('Saving OSM') if @registry[:time_logger]
|
85
|
-
@logger.debug "Saved model as #{osm_name}"
|
86
|
-
|
87
|
-
nil
|
88
|
-
end
|
89
|
-
end
|
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 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
|
+
# Run any OpenStudio measures contained in the OSW
|
37
|
+
class RunOpenStudioMeasures < OpenStudio::Workflow::Job
|
38
|
+
# Mixin the required util modules
|
39
|
+
require 'openstudio/workflow/util'
|
40
|
+
include OpenStudio::Workflow::Util::Measure
|
41
|
+
include OpenStudio::Workflow::Util::Model
|
42
|
+
|
43
|
+
def initialize(input_adapter, output_adapter, registry, options = {})
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def perform
|
48
|
+
@logger.debug "Calling #{__method__} in the #{self.class} class"
|
49
|
+
|
50
|
+
# halted workflow is handled in apply_measures
|
51
|
+
|
52
|
+
# set weather file
|
53
|
+
if @registry[:wf] && @registry[:model]
|
54
|
+
epwFile = OpenStudio::EpwFile.load(@registry[:wf])
|
55
|
+
if !epwFile.empty?
|
56
|
+
OpenStudio::Model::WeatherFile.setWeatherFile(@registry[:model], epwFile.get)
|
57
|
+
else
|
58
|
+
@logger.warn "Could not load weather file from '#{@registry[:wf]}'"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Ensure output_attributes is initialized in the registry
|
63
|
+
@registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
|
64
|
+
|
65
|
+
# Execute the OpenStudio measures
|
66
|
+
@options[:output_adapter] = @output_adapter
|
67
|
+
@logger.info 'Beginning to execute OpenStudio measures.'
|
68
|
+
apply_measures('ModelMeasure'.to_MeasureType, @registry, @options)
|
69
|
+
@logger.info('Finished applying OpenStudio measures.')
|
70
|
+
|
71
|
+
# Send the measure output attributes to the output adapter
|
72
|
+
@logger.debug 'Communicating measure output attributes to the output adapter'
|
73
|
+
@output_adapter.communicate_measure_attributes @registry[:output_attributes]
|
74
|
+
|
75
|
+
# save the final OSM
|
76
|
+
if !@options[:fast]
|
77
|
+
save_osm(@registry[:model], @registry[:run_dir])
|
78
|
+
end
|
79
|
+
|
80
|
+
# Save the OSM if the :debug option is true
|
81
|
+
return nil unless @options[:debug]
|
82
|
+
@registry[:time_logger].start('Saving OSM') if @registry[:time_logger]
|
83
|
+
osm_name = save_osm(@registry[:model], @registry[:root_dir])
|
84
|
+
@registry[:time_logger].stop('Saving OSM') if @registry[:time_logger]
|
85
|
+
@logger.debug "Saved model as #{osm_name}"
|
86
|
+
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
end
|
@@ -1,73 +1,73 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
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
|
-
# Clean up the run directory. Currently this class does nothing else, although eventually cleanup should become driven
|
37
|
-
# and responsive to options
|
38
|
-
class RunPostprocess < OpenStudio::Workflow::Job
|
39
|
-
require 'openstudio/workflow/util/post_process'
|
40
|
-
include OpenStudio::Workflow::Util::PostProcess
|
41
|
-
|
42
|
-
def initialize(input_adapter, output_adapter, registry, options = {})
|
43
|
-
defaults = {
|
44
|
-
cleanup: true
|
45
|
-
}
|
46
|
-
options = defaults.merge(options)
|
47
|
-
super
|
48
|
-
end
|
49
|
-
|
50
|
-
def perform
|
51
|
-
@logger.debug "Calling #{__method__} in the #{self.class} class"
|
52
|
-
|
53
|
-
# do not skip post_process if halted
|
54
|
-
|
55
|
-
if !@options[:fast]
|
56
|
-
@logger.info 'Gathering reports'
|
57
|
-
gather_reports(@registry[:run_dir], @registry[:root_dir], @registry[:workflow_json], @logger)
|
58
|
-
@logger.info 'Finished gathering reports'
|
59
|
-
end
|
60
|
-
|
61
|
-
if @options[:cleanup]
|
62
|
-
@logger.info 'Beginning cleanup of the run directory'
|
63
|
-
cleanup(@registry[:run_dir], @registry[:root_dir], @logger)
|
64
|
-
@logger.info 'Finished cleanup of the run directory'
|
65
|
-
else
|
66
|
-
@logger.info 'Flag for cleanup in options set to false. Moving to next step.'
|
67
|
-
end
|
68
|
-
|
69
|
-
@logger.info 'Finished postprocess'
|
70
|
-
|
71
|
-
nil
|
72
|
-
end
|
73
|
-
end
|
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 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
|
+
# Clean up the run directory. Currently this class does nothing else, although eventually cleanup should become driven
|
37
|
+
# and responsive to options
|
38
|
+
class RunPostprocess < OpenStudio::Workflow::Job
|
39
|
+
require 'openstudio/workflow/util/post_process'
|
40
|
+
include OpenStudio::Workflow::Util::PostProcess
|
41
|
+
|
42
|
+
def initialize(input_adapter, output_adapter, registry, options = {})
|
43
|
+
defaults = {
|
44
|
+
cleanup: true
|
45
|
+
}
|
46
|
+
options = defaults.merge(options)
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
def perform
|
51
|
+
@logger.debug "Calling #{__method__} in the #{self.class} class"
|
52
|
+
|
53
|
+
# do not skip post_process if halted
|
54
|
+
|
55
|
+
if !@options[:fast]
|
56
|
+
@logger.info 'Gathering reports'
|
57
|
+
gather_reports(@registry[:run_dir], @registry[:root_dir], @registry[:workflow_json], @logger)
|
58
|
+
@logger.info 'Finished gathering reports'
|
59
|
+
end
|
60
|
+
|
61
|
+
if @options[:cleanup]
|
62
|
+
@logger.info 'Beginning cleanup of the run directory'
|
63
|
+
cleanup(@registry[:run_dir], @registry[:root_dir], @logger)
|
64
|
+
@logger.info 'Finished cleanup of the run directory'
|
65
|
+
else
|
66
|
+
@logger.info 'Flag for cleanup in options set to false. Moving to next step.'
|
67
|
+
end
|
68
|
+
|
69
|
+
@logger.info 'Finished postprocess'
|
70
|
+
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
end
|
@@ -1,104 +1,104 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
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
|
-
# Prepares the directory for the EnergyPlus simulation
|
37
|
-
class RunPreprocess < OpenStudio::Workflow::Job
|
38
|
-
require 'openstudio/workflow/util'
|
39
|
-
include OpenStudio::Workflow::Util::EnergyPlus
|
40
|
-
include OpenStudio::Workflow::Util::Model
|
41
|
-
include OpenStudio::Workflow::Util::Measure
|
42
|
-
|
43
|
-
def initialize(input_adapter, output_adapter, registry, options = {})
|
44
|
-
super
|
45
|
-
end
|
46
|
-
|
47
|
-
def perform
|
48
|
-
@logger.debug "Calling #{__method__} in the #{self.class} class"
|
49
|
-
|
50
|
-
# halted workflow is handled in apply_measures
|
51
|
-
|
52
|
-
# Ensure that the directory is created (but it should already be at this point)
|
53
|
-
FileUtils.mkdir_p(@registry[:run_dir])
|
54
|
-
|
55
|
-
# save the pre-preprocess file
|
56
|
-
if !@options[:skip_energyplus_preprocess]
|
57
|
-
File.open("#{@registry[:run_dir]}/pre-preprocess.idf", 'w') do |f|
|
58
|
-
f << @registry[:model_idf].to_s
|
59
|
-
# make sure data is written to the disk one way or the other
|
60
|
-
begin
|
61
|
-
f.fsync
|
62
|
-
rescue
|
63
|
-
f.flush
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Add any EnergyPlus Output Requests from Reporting Measures
|
69
|
-
@logger.info 'Beginning to collect output requests from Reporting measures.'
|
70
|
-
energyplus_output_requests = true
|
71
|
-
apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options, energyplus_output_requests)
|
72
|
-
@logger.info('Finished collect output requests from Reporting measures.')
|
73
|
-
|
74
|
-
# Skip the pre-processor if halted
|
75
|
-
halted = @registry[:runner].halted
|
76
|
-
@logger.info 'Workflow halted, skipping the EnergyPlus pre-processor' if halted
|
77
|
-
return nil if halted
|
78
|
-
|
79
|
-
# Perform pre-processing on in.idf to capture logic in RunManager
|
80
|
-
if !@options[:skip_energyplus_preprocess]
|
81
|
-
@registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
|
82
|
-
energyplus_preprocess(@registry[:model_idf], @logger)
|
83
|
-
@registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
|
84
|
-
@logger.info 'Finished preprocess job for EnergyPlus simulation'
|
85
|
-
end
|
86
|
-
|
87
|
-
# Save the model objects in the registry to the run directory
|
88
|
-
if File.exist?("#{@registry[:run_dir]}/in.idf")
|
89
|
-
# DLM: why is this here?
|
90
|
-
@logger.warn 'IDF (in.idf) already exists in the run directory. Will simulate using this file'
|
91
|
-
else
|
92
|
-
save_idf(@registry[:model_idf], @registry[:run_dir])
|
93
|
-
end
|
94
|
-
|
95
|
-
# Save the generated IDF file if the :debug option is true
|
96
|
-
return nil unless @options[:debug]
|
97
|
-
@registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
|
98
|
-
idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
|
99
|
-
@registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
|
100
|
-
@logger.debug "Saved IDF as #{idf_name}"
|
101
|
-
|
102
|
-
nil
|
103
|
-
end
|
104
|
-
end
|
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 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
|
+
# Prepares the directory for the EnergyPlus simulation
|
37
|
+
class RunPreprocess < OpenStudio::Workflow::Job
|
38
|
+
require 'openstudio/workflow/util'
|
39
|
+
include OpenStudio::Workflow::Util::EnergyPlus
|
40
|
+
include OpenStudio::Workflow::Util::Model
|
41
|
+
include OpenStudio::Workflow::Util::Measure
|
42
|
+
|
43
|
+
def initialize(input_adapter, output_adapter, registry, options = {})
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def perform
|
48
|
+
@logger.debug "Calling #{__method__} in the #{self.class} class"
|
49
|
+
|
50
|
+
# halted workflow is handled in apply_measures
|
51
|
+
|
52
|
+
# Ensure that the directory is created (but it should already be at this point)
|
53
|
+
FileUtils.mkdir_p(@registry[:run_dir])
|
54
|
+
|
55
|
+
# save the pre-preprocess file
|
56
|
+
if !@options[:skip_energyplus_preprocess]
|
57
|
+
File.open("#{@registry[:run_dir]}/pre-preprocess.idf", 'w') do |f|
|
58
|
+
f << @registry[:model_idf].to_s
|
59
|
+
# make sure data is written to the disk one way or the other
|
60
|
+
begin
|
61
|
+
f.fsync
|
62
|
+
rescue StandardError
|
63
|
+
f.flush
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Add any EnergyPlus Output Requests from Reporting Measures
|
69
|
+
@logger.info 'Beginning to collect output requests from Reporting measures.'
|
70
|
+
energyplus_output_requests = true
|
71
|
+
apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options, energyplus_output_requests)
|
72
|
+
@logger.info('Finished collect output requests from Reporting measures.')
|
73
|
+
|
74
|
+
# Skip the pre-processor if halted
|
75
|
+
halted = @registry[:runner].halted
|
76
|
+
@logger.info 'Workflow halted, skipping the EnergyPlus pre-processor' if halted
|
77
|
+
return nil if halted
|
78
|
+
|
79
|
+
# Perform pre-processing on in.idf to capture logic in RunManager
|
80
|
+
if !@options[:skip_energyplus_preprocess]
|
81
|
+
@registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
|
82
|
+
energyplus_preprocess(@registry[:model_idf], @logger)
|
83
|
+
@registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
|
84
|
+
@logger.info 'Finished preprocess job for EnergyPlus simulation'
|
85
|
+
end
|
86
|
+
|
87
|
+
# Save the model objects in the registry to the run directory
|
88
|
+
if File.exist?("#{@registry[:run_dir]}/in.idf")
|
89
|
+
# DLM: why is this here?
|
90
|
+
@logger.warn 'IDF (in.idf) already exists in the run directory. Will simulate using this file'
|
91
|
+
else
|
92
|
+
save_idf(@registry[:model_idf], @registry[:run_dir])
|
93
|
+
end
|
94
|
+
|
95
|
+
# Save the generated IDF file if the :debug option is true
|
96
|
+
return nil unless @options[:debug]
|
97
|
+
@registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
|
98
|
+
idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
|
99
|
+
@registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
|
100
|
+
@logger.debug "Saved IDF as #{idf_name}"
|
101
|
+
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
end
|