Skip to content

Commit 03ef91d

Browse files
authored
Merge pull request #2054 from NREL/equipment_module
Equipment module
2 parents f89833d + 679be7f commit 03ef91d

13 files changed

Lines changed: 2100 additions & 27 deletions

.yardopts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
lib/openstudio-standards/constructions/**/*.rb
1313
lib/openstudio-standards/create_typical/**/*.rb
1414
lib/openstudio-standards/daylighting/**/*.rb
15+
lib/openstudio-standards/equipment/**/*.rb
1516
lib/openstudio-standards/exterior_lighting/**/*.rb
1617
lib/openstudio-standards/geometry/**/*.rb
1718
lib/openstudio-standards/hvac/**/*.rb

lib/openstudio-standards.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ module OpenstudioStandards
2222
require_relative 'openstudio-standards/constructions/materials/information'
2323
require_relative 'openstudio-standards/constructions/materials/modify'
2424

25+
# Equipment Module
26+
require_relative 'openstudio-standards/equipment/create_typical_equipment'
27+
2528
# Infiltration Module
2629
require_relative 'openstudio-standards/infiltration/infiltration'
2730
require_relative 'openstudio-standards/infiltration/nist_infiltration'
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
module OpenstudioStandards
2+
# The Equipment module provides methods to create, modify, and get information about equipment
3+
module Equipment
4+
# @!group Create Typical Equipment
5+
# Methods to create typical equipment
6+
7+
# Create typical equipment in a model
8+
#
9+
# @param model [OpenStudio::Model::Model] OpenStudio model object
10+
# @return [Boolean] returns true if successful, false if not
11+
def self.create_typical_equipment(model)
12+
# load equipment data
13+
electric_equipment_space_type_data = JSON.parse(File.read("#{File.dirname(__FILE__)}/data/electric_equipment_space_types.json"), symbolize_names: true)
14+
gas_equipment_space_type_data = JSON.parse(File.read("#{File.dirname(__FILE__)}/data/gas_equipment_space_types.json"), symbolize_names: true)
15+
16+
if electric_equipment_space_type_data.nil? || gas_equipment_space_type_data.nil?
17+
OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Equipment', 'Unable to load equipment space types data. No equipment will be added to model.')
18+
return false
19+
end
20+
21+
# loop over space types and apply equipment
22+
model.getSpaceTypes.each do |space_type|
23+
# remove existing equipment objects
24+
space_type.electricEquipment.sort.each(&:remove)
25+
space_type.gasEquipment.sort.each(&:remove)
26+
27+
# remove existing equipment objects from spaces
28+
space_type.spaces.each do |space|
29+
space.electricEquipment.sort.each(&:remove)
30+
space.gasEquipment.sort.each(&:remove)
31+
end
32+
33+
# get building type
34+
standards_building_type = nil
35+
if space_type.standardsBuildingType.is_initialized
36+
standards_building_type = space_type.standardsBuildingType.get
37+
end
38+
39+
# get equipment space type from the object
40+
has_electric_equipment_space_type = space_type.additionalProperties.hasFeature('electric_equipment_space_type')
41+
has_gas_equipment_space_type = space_type.additionalProperties.hasFeature('natural_gas_equipment_space_type')
42+
unless has_electric_equipment_space_type || has_gas_equipment_space_type
43+
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.")
44+
next
45+
end
46+
if has_electric_equipment_space_type
47+
electric_equipment_space_type = space_type.additionalProperties.getFeatureAsString('electric_equipment_space_type').to_s
48+
else
49+
electric_equipment_space_type = nil
50+
end
51+
if has_gas_equipment_space_type
52+
gas_equipment_space_type = space_type.additionalProperties.getFeatureAsString('natural_gas_equipment_space_type').to_s
53+
else
54+
gas_equipment_space_type = nil
55+
end
56+
57+
if has_electric_equipment_space_type && !electric_equipment_space_type.nil? && (electric_equipment_space_type != 'na')
58+
# get equipment properties for the electric equipment space type
59+
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) }
60+
if electric_equipment_space_type_properties.empty?
61+
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}.")
62+
else
63+
electric_equipment_space_type_properties = electric_equipment_space_type_properties[0]
64+
elec_equip_per_area = electric_equipment_space_type_properties[:electric_equipment_per_area].to_f
65+
elec_equip_frac_latent = electric_equipment_space_type_properties[:electric_equipment_fraction_latent]
66+
elec_equip_frac_radiant = electric_equipment_space_type_properties[:electric_equipment_fraction_radiant]
67+
elec_equip_frac_lost = electric_equipment_space_type_properties[:electric_equipment_fraction_lost]
68+
if elec_equip_per_area > 0
69+
definition = OpenStudio::Model::ElectricEquipmentDefinition.new(space_type.model)
70+
definition.setName("#{space_type.name} Elec Equip Definition")
71+
definition.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area.to_f, 'W/ft^2', 'W/m^2').get)
72+
definition.resetFractionLatent unless definition.isFractionLatentDefaulted
73+
definition.resetFractionRadiant unless definition.isFractionRadiantDefaulted
74+
definition.resetFractionLost unless definition.isFractionLostDefaulted
75+
definition.setFractionLatent(elec_equip_frac_latent.to_f) if elec_equip_frac_latent
76+
definition.setFractionRadiant(elec_equip_frac_radiant.to_f) if elec_equip_frac_radiant
77+
definition.setFractionLost(elec_equip_frac_lost.to_f) if elec_equip_frac_lost
78+
instance = OpenStudio::Model::ElectricEquipment.new(definition)
79+
instance.setName("#{space_type.name} Elec Equip")
80+
instance.setSpaceType(space_type)
81+
end
82+
end
83+
end
84+
85+
if has_gas_equipment_space_type && !gas_equipment_space_type.nil? && (gas_equipment_space_type != 'na')
86+
# get equipment properties for the gas equipment space type
87+
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) }
88+
if gas_equipment_space_type_properties.empty?
89+
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}.")
90+
else
91+
gas_equipment_space_type_properties = gas_equipment_space_type_properties[0]
92+
gas_equip_per_area = gas_equipment_space_type_properties[:gas_equipment_per_area].to_f
93+
gas_equip_frac_latent = gas_equipment_space_type_properties[:gas_equipment_fraction_latent]
94+
gas_equip_frac_radiant = gas_equipment_space_type_properties[:gas_equipment_fraction_radiant]
95+
gas_equip_frac_lost = gas_equipment_space_type_properties[:gas_equipment_fraction_lost]
96+
if gas_equip_per_area > 0
97+
definition = OpenStudio::Model::GasEquipmentDefinition.new(space_type.model)
98+
definition.setName("#{space_type.name} Gas Equip Definition")
99+
definition.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area.to_f, 'Btu/hr*ft^2', 'W/m^2').get)
100+
definition.resetFractionLatent unless definition.isFractionLatentDefaulted
101+
definition.resetFractionRadiant unless definition.isFractionRadiantDefaulted
102+
definition.resetFractionLost unless definition.isFractionLostDefaulted
103+
definition.setFractionLatent(gas_equip_frac_latent.to_f) if gas_equip_frac_latent
104+
definition.setFractionRadiant(gas_equip_frac_radiant.to_f) if gas_equip_frac_radiant
105+
definition.setFractionLost(gas_equip_frac_lost.to_f) if gas_equip_frac_lost
106+
instance = OpenStudio::Model::GasEquipment.new(definition)
107+
instance.setName("#{space_type.name} Gas Equip")
108+
instance.setSpaceType(space_type)
109+
end
110+
end
111+
end
112+
end
113+
114+
return true
115+
end
116+
end
117+
end

0 commit comments

Comments
 (0)