Class: BTAP::Analysis

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/btap/qaqc/analysis.rb

Overview

BTAP Analysis

Class to instantiate post-analysis mechanisms like costing or carbon calculation. Can be done during a simulation or without one given an OSM file and its SQL file, along with a few other parameters.

Abstract class, only instantiate BTAP::NoSimAnalysis or BTAP::DatapointAnalysis.

Direct Known Subclasses

DatapointAnalysis, NoSimAnalysis

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_folder:) ⇒ Analysis

Returns a new instance of Analysis.

Parameters:



16
17
18
# File 'lib/openstudio-standards/btap/qaqc/analysis.rb', line 16

def initialize(output_folder:)
  @output_folder = output_folder
end

Instance Attribute Details

#attributes ⇒ Object

Returns the value of attribute attributes.



13
14
15
# File 'lib/openstudio-standards/btap/qaqc/analysis.rb', line 13

def attributes
  @attributes
end

Class Method Details

.get_tbd_attributes(model:) ⇒ (Boolean, Hash)

Parameters:

Returns:



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
# File 'lib/openstudio-standards/btap/qaqc/analysis.rb', line 65

def self.get_tbd_attributes(model:)

  # The "psi_quality" additional property is only initialized when TBD
  # is run, used as a marker here to determine the "tbd_enabled" attribute.
  tbd_enabled      = model.getBuilding.additionalProperties.hasFeature("psi_quality")
  tbd_edge_tallies = {}

  # Process the thermal bridging edge tallies out of the building's
  # additional properties and format them into a hash.
  if tbd_enabled
    BTAP::BridgingData.admissible_edges.map(&:to_s).each do |edge_type|
      (1..model.getDefaultConstructionSets.length).each do |id|
        edge_key     = "PSI#{edge_type}#{id}"
        keep_looking = false
        if model.getBuilding.additionalProperties.hasFeature(edge_key)
          keep_looking = true
          tbd_edge_tallies[edge_type] = {} unless tbd_edge_tallies.has_key?(edge_type)
          wall_reference, quantity =
            model.getBuilding.additionalProperties.getFeatureAsString(edge_key).get.split(/\s(?=\d)/)

          tbd_edge_tallies[edge_type][wall_reference] = quantity.to_f
        end
        break unless keep_looking
      end
    end
  end
  return tbd_enabled, tbd_edge_tallies
end

Instance Method Details

#run_carbon ⇒ Object

Run BTAP Carbon.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/openstudio-standards/btap/qaqc/analysis.rb', line 47

def run_carbon
  carbon = Carbon.new(attributes: @attributes, standards_data: @standard.standards_data)
  carbon_result = carbon.audit_embodied_carbon

  if not @qaqc.nil?
    @qaqc[:carbon_information] = carbon_result
  end

  File.open(File.join(@output_folder, 'carbon_results.json'), 'w') do |f|
    f.write(JSON.pretty_generate(carbon_result, allow_nan: true))
  end
  puts "Wrote File carbon_results.json in #{@output_folder} "

  return carbon_result
end

#run_costing(costs_csv: Paths.costs_path, factors_csv: Paths.costs_local_factors_path) ⇒ Object

Run BTAP Costing.

Parameters:

  • costs_csv (String) (defaults to: Paths.costs_path) —

    Path to a custom costing CSV file if custom costing is desired.

  • factors_csv (String) (defaults to: Paths.costs_local_factors_path) —

    Path to a custom costing localization factors CSV file if custom costing is desired.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/openstudio-standards/btap/qaqc/analysis.rb', line 26

def run_costing(costs_csv: Paths.costs_path, factors_csv: Paths.costs_local_factors_path)
  costing = Costing.new(costs_csv: costs_csv, factors_csv: factors_csv, attributes: @attributes)

  cost_result, _ = costing.cost_audit_all(
    model: @model,
    prototype_creator: @standard,
    template_type: @model.getBuilding.standardsTemplate.get)

  if not @qaqc.nil?
    @qaqc[:costing_information] = cost_result
  end

  File.open(File.join(@output_folder, 'cost_results.json'), 'w') do |f|
    f.write(JSON.pretty_generate(cost_result, allow_nan: true))
  end
  puts "Wrote File cost_results.json in #{@output_folder} "

  return cost_result
end