Class: RunTranslation
- Inherits:
-
OpenStudio::Workflow::Job
- Object
- OpenStudio::Workflow::Job
- RunTranslation
- Includes:
- OpenStudio::Workflow::Util::Model
- Defined in:
- lib/openstudio/workflow/jobs/run_translation.rb
Overview
Run the initialization job to validate the directory and initialize the adapters.
Instance Method Summary collapse
-
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunTranslation
constructor
A new instance of RunTranslation.
- #perform ⇒ Object
Methods included from OpenStudio::Workflow::Util::Model
#load_idf, #load_osm, #save_epjson, #save_idf, #save_osm, #translate_idf_to_epjson, #translate_to_energyplus
Constructor Details
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunTranslation
Returns a new instance of RunTranslation.
43 44 45 |
# File 'lib/openstudio/workflow/jobs/run_translation.rb', line 43 def initialize(input_adapter, output_adapter, registry, = {}) super end |
Instance Method Details
#perform ⇒ Object
47 48 49 50 51 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 |
# File 'lib/openstudio/workflow/jobs/run_translation.rb', line 47 def perform @logger.debug "Calling #{__method__} in the #{self.class} class" # skip if halted if @registry[:runner].halted @logger.info 'Workflow halted, skipping OSM to IDF translation' @registry.register(:model_idf) { OpenStudio::Workspace.new } # This allows model arguments to still be calculated return nil end # Ensure that the run directory is created FileUtils.mkdir_p(@registry[:run_dir]) # Copy in the weather file defined in the registry, or alternately in the options if @registry[:wf] @logger.info "Weather file for EnergyPlus simulation is #{@registry[:wf]}" FileUtils.copy(@registry[:wf], "#{@registry[:run_dir]}/in.epw") @registry.register(:wf) { "#{@registry[:run_dir]}/in.epw" } else @logger.warn "EPW file not found or not sent to #{self.class}" end # Translate the OSM to an IDF @logger.info 'Beginning the translation to IDF' @registry[:time_logger]&.start('Translating to EnergyPlus') model_idf = translate_to_energyplus @registry[:model], @logger @registry[:time_logger]&.stop('Translating to EnergyPlus') @registry.register(:model_idf) { model_idf } @logger.info 'Successfully translated to IDF' # Save the generated IDF file if the :debug option is true return nil unless [:debug] @registry[:time_logger]&.start('Saving IDF') idf_name = save_idf(@registry[:model_idf], @registry[:root_dir]) @registry[:time_logger]&.stop('Saving IDF') @logger.debug "Saved IDF as #{idf_name}" nil end |