Module: OpenstudioStandards::Equipment

Defined in:
lib/openstudio-standards/equipment/create_transformer.rb,
lib/openstudio-standards/equipment/create_typical_equipment.rb

Overview

The Equipment module provides methods to create, modify, and get information about equipment

Create Transformer collapse

Create Typical Equipment collapse

Class Method Details

.create_transformer(model, name: 'Transformer_1', wired_lighting_frac: nil, transformer_size: nil, transformer_efficiency: nil, excluded_interiorequip_key: '', excluded_interiorequip_meter: nil) ⇒ OpenStudio::Model::ElectricLoadCenterTransformer

Add transformer to the model

Parameters:

  • model (OpenStudio::Model::Model)

    OpenStudio model object

  • name (String) (defaults to: 'Transformer_1')

    the name of the transformer

  • wired_lighting_frac (Double) (defaults to: nil)

    the wired lighting fraction, 0-1

  • transformer_size (Double) (defaults to: nil)

    the transformer size in VA

  • transformer_efficiency (Double) (defaults to: nil)

    the transformer efficiency, 0-1

  • excluded_interiorequip_key (String) (defaults to: '')

    key to exclude

  • excluded_interiorequip_meter (String) (defaults to: nil)

    meter to exclude

Returns:

  • (OpenStudio::Model::ElectricLoadCenterTransformer)

    the transformer object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/openstudio-standards/equipment/create_transformer.rb', line 17

def self.create_transformer(model,
                            name: 'Transformer_1',
                            wired_lighting_frac: nil,
                            transformer_size: nil,
                            transformer_efficiency: nil,
                            excluded_interiorequip_key: '',
                            excluded_interiorequip_meter: nil)
  # throw an error if transformer properties are missing
  if wired_lighting_frac.nil? || transformer_size.nil? || transformer_efficiency.nil?
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Equipment', "Either 'wired_lighting_frac', 'transformer_size', or 'transformer_efficiency' is unspecified.  Cannot add transformer.")
    return false
  end

  # throw an error if Decepticon
  if ['megatron', 'starscream', 'soundwave', 'shockwave', 'skywarp', 'thundercracker', 'reflector'].include? name.downcase
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Equipment', "Decepticons will corrupt the OpenStudio model. Will not add transformer.")
    return false
  end

  # @todo default values are for testing only
  # ems sensor for interior lighting
  facility_int_ltg = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'InteriorLights:Electricity')
  facility_int_ltg.setName('Facility_Int_LTG')

  # declaire ems variable for transformer wired lighting portion
  wired_ltg_var = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, 'Wired_LTG')

  # ems program for transformer load
  transformer_load_prog = OpenStudio::Model::EnergyManagementSystemProgram.new(model)
  transformer_load_prog.setName('Transformer_Load_Prog')
  transformer_load_prog_body = <<-EMS
  SET Wired_LTG = Facility_Int_LTG*#{wired_lighting_frac}
  EMS
  transformer_load_prog.setBody(transformer_load_prog_body)

  # ems program calling manager
  transformer_load_prog_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)
  transformer_load_prog_manager.setName('Transformer_Load_Prog_Manager')
  transformer_load_prog_manager.setCallingPoint('AfterPredictorAfterHVACManagers')
  transformer_load_prog_manager.addProgram(transformer_load_prog)

  # ems output variable
  wired_ltg_emsout = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, wired_ltg_var)
  wired_ltg_emsout.setName('Wired_LTG')
  wired_ltg_emsout.setTypeOfDataInVariable('Summed')
  wired_ltg_emsout.setUpdateFrequency('ZoneTimeStep')
  wired_ltg_emsout.setUnits('J')

  # meter for ems output
  wired_ltg_meter = OpenStudio::Model::MeterCustom.new(model)
  wired_ltg_meter.setName('Wired_LTG_Electricity')
  wired_ltg_meter.setFuelType('Electricity')
  wired_ltg_meter.addKeyVarGroup('', 'Wired_LTG')

  # meter for wired int equip
  unless excluded_interiorequip_meter.nil?
    wired_int_equip_meter = OpenStudio::Model::MeterCustomDecrement.new(model, 'InteriorEquipment:Electricity')
    wired_int_equip_meter.setName('Wired_Int_EQUIP')
    wired_int_equip_meter.setFuelType('Electricity')
    wired_int_equip_meter.addKeyVarGroup(excluded_interiorequip_key, excluded_interiorequip_meter)
  end

  # add transformer
  transformer = OpenStudio::Model::ElectricLoadCenterTransformer.new(model)
  transformer.setName(name)
  transformer.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)
  transformer.setTransformerUsage('PowerInFromGrid')
  transformer.setRatedCapacity(transformer_size)
  transformer.setPhase('3')
  transformer.setConductorMaterial('Aluminum')
  transformer.setFullLoadTemperatureRise(150)
  transformer.setFractionofEddyCurrentLosses(0.1)
  transformer.setPerformanceInputMethod('NominalEfficiency')
  transformer.setNameplateEfficiency(transformer_efficiency)
  transformer.setPerUnitLoadforNameplateEfficiency(0.35)
  transformer.setReferenceTemperatureforNameplateEfficiency(75)
  transformer.setConsiderTransformerLossforUtilityCost(true)
  transformer.addMeter('Wired_LTG_Electricity')
  if excluded_interiorequip_meter.nil?
    transformer.addMeter('InteriorEquipment:Electricity') # by default, add this as the second meter
  else
    transformer.addMeter('Wired_Int_EQUIP')
  end

  return transformer
end

.create_typical_equipment(model) ⇒ Boolean

Create typical equipment in a model

Parameters:

Returns:

  • (Boolean)

    returns true if successful, false if not



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
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
107
108
109
110
111
112
113
114
115
# File 'lib/openstudio-standards/equipment/create_typical_equipment.rb', line 11

def self.create_typical_equipment(model)
  # load equipment data
  electric_equipment_space_type_data = JSON.parse(File.read("#{File.dirname(__FILE__)}/data/electric_equipment_space_types.json"), symbolize_names: true)
  gas_equipment_space_type_data = JSON.parse(File.read("#{File.dirname(__FILE__)}/data/gas_equipment_space_types.json"), symbolize_names: true)

  if electric_equipment_space_type_data.nil? || gas_equipment_space_type_data.nil?
    OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Equipment', 'Unable to load equipment space types data. No equipment will be added to model.')
    return false
  end

  # loop over space types and apply equipment
  model.getSpaceTypes.each do |space_type|
    # remove existing equipment objects
    space_type.electricEquipment.sort.each(&:remove)
    space_type.gasEquipment.sort.each(&:remove)

    # remove existing equipment objects from spaces
    space_type.spaces.each do |space|
      space.electricEquipment.sort.each(&:remove)
      space.gasEquipment.sort.each(&:remove)
    end

    # get building type
    standards_building_type = nil
    if space_type.standardsBuildingType.is_initialized
      standards_building_type = space_type.standardsBuildingType.get
    end

    # get equipment space type from the object
    has_electric_equipment_space_type = space_type.additionalProperties.hasFeature('electric_equipment_space_type')
    has_gas_equipment_space_type = space_type.additionalProperties.hasFeature('natural_gas_equipment_space_type')
    unless has_electric_equipment_space_type || has_gas_equipment_space_type
      OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Equipment', "Space type '#{space_type.name}' does not have a electric_equipment_space_type or natural_gas_equipment_space_type property assigned. Ignoring space type.")
      next
    end
    if has_electric_equipment_space_type
      electric_equipment_space_type = space_type.additionalProperties.getFeatureAsString('electric_equipment_space_type').to_s
    else
      electric_equipment_space_type = nil
    end
    if has_gas_equipment_space_type
      gas_equipment_space_type = space_type.additionalProperties.getFeatureAsString('natural_gas_equipment_space_type').to_s
    else
      gas_equipment_space_type = nil
    end

    if has_electric_equipment_space_type && !electric_equipment_space_type.nil? && (electric_equipment_space_type != 'na')
      # get equipment properties for the electric equipment space type
      electric_equipment_space_type_properties = electric_equipment_space_type_data.select { |r| (r[:electric_equipment_space_type_name] == electric_equipment_space_type) && (r[:standards_building_type] == standards_building_type) }
      if electric_equipment_space_type_properties.empty?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Equipment', "Unable to find electric equipment space type data for '#{electric_equipment_space_type}' with standards_building_type #{standards_building_type}.")
      else
        electric_equipment_space_type_properties = electric_equipment_space_type_properties[0]
        elec_equip_per_area = electric_equipment_space_type_properties[:electric_equipment_per_area].to_f
        elec_equip_frac_latent = electric_equipment_space_type_properties[:electric_equipment_fraction_latent]
        elec_equip_frac_radiant = electric_equipment_space_type_properties[:electric_equipment_fraction_radiant]
        elec_equip_frac_lost = electric_equipment_space_type_properties[:electric_equipment_fraction_lost]
        if elec_equip_per_area > 0
          definition = OpenStudio::Model::ElectricEquipmentDefinition.new(space_type.model)
          definition.setName("#{space_type.name} Elec Equip Definition")
          definition.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area.to_f, 'W/ft^2', 'W/m^2').get)
          definition.resetFractionLatent unless definition.isFractionLatentDefaulted
          definition.resetFractionRadiant unless definition.isFractionRadiantDefaulted
          definition.resetFractionLost unless definition.isFractionLostDefaulted
          definition.setFractionLatent(elec_equip_frac_latent.to_f) if elec_equip_frac_latent
          definition.setFractionRadiant(elec_equip_frac_radiant.to_f) if elec_equip_frac_radiant
          definition.setFractionLost(elec_equip_frac_lost.to_f) if elec_equip_frac_lost
          instance = OpenStudio::Model::ElectricEquipment.new(definition)
          instance.setName("#{space_type.name} Elec Equip")
          instance.setSpaceType(space_type)
        end
      end
    end

    if has_gas_equipment_space_type && !gas_equipment_space_type.nil? && (gas_equipment_space_type != 'na')
      # get equipment properties for the gas equipment space type
      gas_equipment_space_type_properties = gas_equipment_space_type_data.select { |r| (r[:natural_gas_equipment_space_type_name] == gas_equipment_space_type) && (r[:standards_building_type] == standards_building_type) }
      if gas_equipment_space_type_properties.empty?
        OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Equipment', "Unable to find gas equipment space type data for '#{gas_equipment_space_type}' with standards_building_type #{standards_building_type}.")
      else
        gas_equipment_space_type_properties = gas_equipment_space_type_properties[0]
        gas_equip_per_area = gas_equipment_space_type_properties[:gas_equipment_per_area].to_f
        gas_equip_frac_latent = gas_equipment_space_type_properties[:gas_equipment_fraction_latent]
        gas_equip_frac_radiant = gas_equipment_space_type_properties[:gas_equipment_fraction_radiant]
        gas_equip_frac_lost = gas_equipment_space_type_properties[:gas_equipment_fraction_lost]
        if gas_equip_per_area > 0
          definition = OpenStudio::Model::GasEquipmentDefinition.new(space_type.model)
          definition.setName("#{space_type.name} Gas Equip Definition")
          definition.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area.to_f, 'Btu/hr*ft^2', 'W/m^2').get)
          definition.resetFractionLatent unless definition.isFractionLatentDefaulted
          definition.resetFractionRadiant unless definition.isFractionRadiantDefaulted
          definition.resetFractionLost unless definition.isFractionLostDefaulted
          definition.setFractionLatent(gas_equip_frac_latent.to_f) if gas_equip_frac_latent
          definition.setFractionRadiant(gas_equip_frac_radiant.to_f) if gas_equip_frac_radiant
          definition.setFractionLost(gas_equip_frac_lost.to_f) if gas_equip_frac_lost
          instance = OpenStudio::Model::GasEquipment.new(definition)
          instance.setName("#{space_type.name} Gas Equip")
          instance.setSpaceType(space_type)
        end
      end
    end
  end

  return true
end