Module: BTAP::SimManager
- Defined in:
- lib/openstudio-standards/btap/simmanager.rb
Defined Under Namespace
Classes: ProcessManager
Class Method Summary collapse
-
.run_simulation(model, folder_name, epw_path = "") ⇒ OpenStudio::Model::Model
This method will run the simulation.
-
.simulate_all_files_in_folder(folder) ⇒ Object
This method will simulate all files in a folder.
- .simulate_files(folder, osm_files) ⇒ Object
Class Method Details
.run_simulation(model, folder_name, epw_path = "") ⇒ OpenStudio::Model::Model
This method will run the simulation. You must provide a folder where you wish to run the simulation, and if not previously defined, the weather file. This will delete and recreate the folder provided to ensure that it is clean.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/openstudio-standards/btap/simmanager.rb', line 77 def self.run_simulation( model, folder_name,epw_path = "" ) if not File.exists?(epw_path) and not File.exists?(model.getWeatherFile.path.get.to_s) raise ("Error: Weather file not set. Cannot run. Please set weather file using the OpenStudio::Model::WeatherFile::setWeatherFile(model,filepath) command ") else if epw_path != "" BTAP::Site::set_weather_file(model,epw_path) end #Create RunManager Dir::mkdir(folder_name) unless File.exists?( folder_name ) process_manager = BTAP::SimManager::ProcessManager.new( folder_name ) process_manager.addModel(model) process_manager.start_sims end return model end |
.simulate_all_files_in_folder(folder) ⇒ Object
This method will simulate all files in a folder.
29 30 31 32 |
# File 'lib/openstudio-standards/btap/simmanager.rb', line 29 def self.simulate_all_files_in_folder(folder) osm_files = BTAP::FileIO::get_find_files_from_folder_by_extension(folder, ".osm") self.simulate_files(folder,osm_files) end |
.simulate_files(folder, osm_files) ⇒ Object
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 |
# File 'lib/openstudio-standards/btap/simmanager.rb', line 37 def self.simulate_files(folder,osm_files) co = OpenStudio::Runmanager::ConfigOptions.new() co.fastFindEnergyPlus() rm = OpenStudio::Runmanager::RunManager.new("SecureRandom.hex.db", true) rm.setPaused(false) counter = 0 osm_files.each do |model_path| counter = counter + 1 work_items = OpenStudio::Runmanager::WorkItemVector.new work_items << OpenStudio::Runmanager::WorkItem.new("ModelToIdf".to_JobType) work_items << OpenStudio::Runmanager::WorkItem.new("ExpandObjects".to_JobType) # ruby_job = OpenStudio::Runmanager::RubyJobBuilder.new(cost_injection) # ruby_job.setIncludeDir(OpenStudio::Path.new("#{$OpenStudio_Dir}")) # work_items << ruby_job.toWorkItem work_items << OpenStudio::Runmanager::WorkItem.new("EnergyPlus".to_JobType) #work_items << OpenStudio::Runmanager::WorkItem.new("ReadVars".to_JobType) work_items << OpenStudio::Runmanager::WorkItem.new("OpenStudioPostProcess".to_JobType) workflow = OpenStudio::Runmanager::Workflow.new(work_items) params = OpenStudio::Runmanager::JobParams.new; params.append("cleanoutfiles", "standard"); workflow.add(params) workflow.add(co.getTools()) rm.enqueue( workflow.create( OpenStudio::Path.new("#{folder}/#{File.basename(model_path, ".osm")}"), OpenStudio::Path.new(model_path)),false) # puts "#{model_path} enqueued. #{counter} of #{osm_files.size}" end #rm.showStatusDialog() rm.waitForFinished() end |