Class: RunOpenstudio
- Inherits:
-
Object
- Object
- RunOpenstudio
- Includes:
- OpenStudio::Workflow::ApplyMeasures
- Defined in:
- lib/openstudio/workflow/jobs/run_openstudio/run_openstudio.rb
Overview
TODO: I hear that measures can step on each other if not run in their own directory
Constant Summary
Constants included from OpenStudio::Workflow::ApplyMeasures
OpenStudio::Workflow::ApplyMeasures::MEASURE_TYPES
Instance Method Summary collapse
-
#initialize(directory, logger, time_logger, adapter, options = {}) ⇒ RunOpenstudio
constructor
Initialize param directory: base directory where the simulation files are prepared param logger: logger object in which to write log messages.
- #perform ⇒ Object
Methods included from OpenStudio::Workflow::ApplyMeasures
#apply_arguments, #apply_measure, #apply_measures, #apply_variables
Constructor Details
#initialize(directory, logger, time_logger, adapter, options = {}) ⇒ RunOpenstudio
Initialize param directory: base directory where the simulation files are prepared param logger: logger object in which to write log messages
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/openstudio/workflow/jobs/run_openstudio/run_openstudio.rb', line 28 def initialize(directory, logger, time_logger, adapter, = {}) defaults = { format: 'hash', use_monthly_reports: false, analysis_root_path: '.' } @options = defaults.merge() @directory = directory # TODO: there is a base number of arguments that each job will need including @run_directory. abstract it out. @run_directory = "#{@directory}/run" @adapter = adapter @results = {} @logger = logger @time_logger = time_logger @logger.info "#{self.class} passed the following options #{@options}" # initialize instance variables that are needed in the perform section @model = nil @model_idf = nil @initial_weather_file = nil @weather_file_path = nil @analysis_json = nil # TODO: rename datapoint_json to just datapoint @datapoint_json = nil @output_attributes = {} @report_measures = [] end |
Instance Method Details
#perform ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/openstudio/workflow/jobs/run_openstudio/run_openstudio.rb', line 52 def perform @logger.info "Calling #{__method__} in the #{self.class} class" @logger.info "Current directory is #{@directory}" @logger.info 'Retrieving datapoint and problem' @datapoint_json = @adapter.get_datapoint(@directory, @options) @analysis_json = @adapter.get_problem(@directory, @options) if @analysis_json && @analysis_json[:analysis] @model = load_seed_model load_weather_file apply_measures(:openstudio_measure) @time_logger.start('Translating to EnergyPlus') translate_to_energyplus @time_logger.stop('Translating to EnergyPlus') apply_measures(:energyplus_measure) # check if the weather file has changed. This is cheesy for now. Should have a default measure that # always sets the weather file so that it can be better controlled updated_weather_file = get_weather_file_from_model unless updated_weather_file == @initial_weather_file # reset the result hash so the future processes know which weather file to run @logger.info "Updating the weather file to be '#{updated_weather_file}'" if (Pathname.new updated_weather_file).absolute? && (Pathname.new updated_weather_file).exist? @results[:weather_filename] = updated_weather_file else @results[:weather_filename] = "#{@weather_file_path}/#{updated_weather_file}" end end @logger.info 'Saving measure output attributes JSON' File.open("#{@run_directory}/measure_attributes.json", 'w') do |f| f << JSON.pretty_generate(@output_attributes) end end @time_logger.start('Saving OSM and IDF') save_osm_and_idf @time_logger.stop('Saving OSM and IDF') @results end |