Module: BTAP::Reports

Defined in:
lib/openstudio-standards/btap/btap.rb

Class Method Summary collapse

Class Method Details

.all_output_variables(model, frequency) ⇒ OpenStudio::Model::Model

This turns all output on. Warning: Long runtimes will result.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • frequency (Fixnum)

Returns:

Author:

  • Phylroy A. Lopez



225
226
227
228
# File 'lib/openstudio-standards/btap/btap.rb', line 225

def self.all_output_variables(model,frequency)
  BTAP::Reports::set_output_variables(model, frequency, BTAP::Reports::get_possible_output_variables(model))
  return model
end

.clear_output_variables(model) ⇒ OpenStudio::Model::Model

This method clears all the output variables to make simulations run faster or to start fresh.

Parameters:

Returns:

Author:

  • Phylroy A. Lopez



212
213
214
215
216
217
218
# File 'lib/openstudio-standards/btap/btap.rb', line 212

def self.clear_output_variables(model)
  #remove existing outputs
  model.getOutputVariables.sort.each do |object|
    object.remove
  end
  return model
end

.get_possible_output_variables(model) ⇒ Array<String>

This method returns a vector of the results that are available in the current model.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

Returns:

  • (Array<String>)

    a list of all the possible output variables.

Author:

  • Phylroy A. Lopez



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/openstudio-standards/btap/btap.rb', line 235

def self.get_possible_output_variables( model )
  #Run simulation
  copy = BTAP::FileIO::deep_copy(model)
  copy.building.get.setName("rdd_run")
  BTAP::SimulationSettings::set_run_period(copy, 1, 1, 1, 1)
  BTAP::SimManager::run_simulation(copy,"C:\\temp\\rdd_maker")
  rdd_file_path = ""
  Find.find("C:\\temp\\rdd_maker") do |path|
    rdd_file_path = path if path =~ /.*\.rdd$/
  end
  contents = File.read(rdd_file_path)
  output_variables = Array.new()
  contents.each do |line|
    match = line.match /^\s*Output:Variable,\*,(.*),(.*);(.*)/
    if match
      output_variables.push(match[1])
    end
  end
  return output_variables
end

.set_output_variables(model, frequency, output_variable_array) ⇒ OpenStudio::Model::Model

This method sets up some predetermined output variables. May take a while to run with these settings.

Parameters:

  • model (OpenStudio::model::Model)

    A model object

  • frequency (Fixnum)
  • output_variable_array (Array<String>)

    a list of output variables that you wish to report from the simulation.

Returns:

Author:

  • Phylroy A. Lopez



262
263
264
265
266
267
268
269
270
# File 'lib/openstudio-standards/btap/btap.rb', line 262

def self.set_output_variables(model,frequency, output_variable_array)
  raise("Frequency is not valid. Must by \"Hourly\" or \"Timestep\" but got #{frequency}.") unless ["Hourly","Timestep"].include?(frequency)
  output_variable_array.each do |variable|
    output = OpenStudio::Model::OutputVariable.new(variable,model)
    output.setKeyValue("*")
    output.setReportingFrequency(frequency)
  end
  return model
end