Class: RunPreprocess
- Inherits:
-
OpenStudio::Workflow::Job
- Object
- OpenStudio::Workflow::Job
- RunPreprocess
- Includes:
- OpenStudio::Workflow::Util::EnergyPlus, OpenStudio::Workflow::Util::Measure, OpenStudio::Workflow::Util::Model
- Defined in:
- lib/openstudio/workflow/jobs/run_preprocess.rb
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
-
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunPreprocess
constructor
A new instance of RunPreprocess.
- #perform ⇒ Object
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_epjson, #save_idf, #save_osm, #translate_idf_to_epjson, #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
Constructor Details
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunPreprocess
Returns a new instance of RunPreprocess.
45 46 47 |
# File 'lib/openstudio/workflow/jobs/run_preprocess.rb', line 45 def initialize(input_adapter, output_adapter, registry, = {}) super end |
Instance Method Details
#perform ⇒ Object
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/openstudio/workflow/jobs/run_preprocess.rb', line 49 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 ![:skip_energyplus_preprocess] File.open("#{@registry[:run_dir]}/pre-preprocess.idf", 'w') do |f| f << @registry[:model_idf].to_s # make sure data is written to the disk one way or the other begin f.fsync rescue StandardError f.flush end end 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, , 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 ![:skip_energyplus_preprocess] @registry[:time_logger]&.start('Running EnergyPlus Preprocess') energyplus_preprocess(@registry[:model_idf], @logger) @registry[:time_logger]&.start('Running EnergyPlus Preprocess') @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 [: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 |