Class: RunPreprocess

Overview

Prepares the directory for the EnergyPlus simulation

Constant Summary

Constants included from OpenStudio::Workflow::Util::EnergyPlus

OpenStudio::Workflow::Util::EnergyPlus::ENERGYPLUS_REGEX, OpenStudio::Workflow::Util::EnergyPlus::EXPAND_OBJECTS_REGEX

Instance Method Summary collapse

Methods included from OpenStudio::Workflow::Util::Measure

#add_result_measure_info, #apply_arguments, #apply_arguments_2, #apply_measure, #apply_measures, #validate_measures

Methods included from OpenStudio::Workflow::Util::Model

#load_idf, #load_osm, #save_idf, #save_osm, #translate_to_energyplus

Methods included from OpenStudio::Workflow::Util::EnergyPlus

add_energyplus_output_request, #call_energyplus, check_for_object, #clean_directory, #energyplus_preprocess, #find_energyplus, merge_output_table_summary_reports, monthly_report_idf_text, #prepare_energyplus_dir

Methods included from OpenStudio::Workflow::Util::IO

#is_windows?, #popen_command

Constructor Details

#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunPreprocess

Returns a new instance of RunPreprocess.



27
28
29
# File 'lib/openstudio/workflow/jobs/run_preprocess.rb', line 27

def initialize(input_adapter, output_adapter, registry, options = {})
  super
end

Instance Method Details

#performObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
# File 'lib/openstudio/workflow/jobs/run_preprocess.rb', line 31

def perform
  @logger.debug "Calling #{__method__} in the #{self.class} class"
  
  # halted workflow is handled in apply_measures

  # Ensure that the directory is created (but it should already be at this point)
  FileUtils.mkdir_p(@registry[:run_dir])

  # save the pre-preprocess file
  if !@options[:skip_energyplus_preprocess]
    File.open("#{@registry[:run_dir]}/pre-preprocess.idf", 'w') { |f| f << @registry[:model_idf].to_s }
  end

  # Add any EnergyPlus Output Requests from Reporting Measures
  @logger.info 'Beginning to collect output requests from Reporting measures.'
  energyplus_output_requests = true
  apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options, energyplus_output_requests)
  @logger.info('Finished collect output requests from Reporting measures.')

  # Skip the pre-processor if halted
  halted = @registry[:runner].halted
  @logger.info 'Workflow halted, skipping the EnergyPlus pre-processor' if halted
  return nil if halted

  # Perform pre-processing on in.idf to capture logic in RunManager
  if !@options[:skip_energyplus_preprocess]
    @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
    energyplus_preprocess(@registry[:model_idf], @logger)
    @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
    @logger.info 'Finished preprocess job for EnergyPlus simulation'
  end

  # Save the model objects in the registry to the run directory
  if File.exist?("#{@registry[:run_dir]}/in.idf")
    # DLM: why is this here?
    @logger.warn 'IDF (in.idf) already exists in the run directory. Will simulate using this file'
  else
    save_idf(@registry[:model_idf], @registry[:run_dir])
  end

  # Save the generated IDF file if the :debug option is true
  return nil unless @options[:debug]
  @registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
  idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
  @registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
  @logger.debug "Saved IDF as #{idf_name}"

  nil
end