Class: Honeybee::ServiceHotWaterAbridged

Inherits:
ModelObject show all
Defined in:
lib/honeybee/load/service_hot_water.rb,
lib/to_openstudio/load/service_hot_water.rb,
lib/from_openstudio/load/service_hot_water.rb

Constant Summary collapse

@@max_target_temp =
60
@@max_temp_schedule =
nil
@@shw_connections =
{}
@@shw_rates =
{}
@@hp_deadband =
4
@@sys_count =
1

Instance Attribute Summary

Attributes inherited from ModelObject

#errors, #openstudio_object, #warnings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ModelObject

#allowable_types, clean_identifier, clean_name, #initialize, #method_missing, read_from_disk, truncate

Constructor Details

This class inherits a constructor from Honeybee::ModelObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Honeybee::ModelObject

Class Method Details

.from_load(load, floor_area) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/from_openstudio/load/service_hot_water.rb', line 38

def self.from_load(load, floor_area)
    # create an empty hash
    hash = {}
    hash[:type] = 'ServiceHotWaterAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(load.nameString)
    load_def = load.waterUseEquipmentDefinition
    # units of peak flow rate are m3/s
    peak_flow = load_def.peakFlowRate
    # unit for flow per area is L/h-m2 (m3/s = 3600000 L/h)
    hash[:flow_per_area] = (peak_flow * 3600000) / floor_area
    unless load.flowRateFractionSchedule.empty? 
        schedule = load.flowRateFractionSchedule.get
        hash[:schedule] = schedule.nameString
    end

    hash
end

Instance Method Details

#add_hot_water_plants(openstudio_model, shw_hashes) ⇒ Object



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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/to_openstudio/load/service_hot_water.rb', line 55

def add_hot_water_plants(openstudio_model, shw_hashes)
  # add district hot water loops to supply all of the shw_connections
  shw_hashes.each do |shw_hash|
    unless @@shw_rates[shw_hash[:identifier]].nil?
      # create the plant loop
      hot_water_plant = OpenStudio::Model::PlantLoop.new(openstudio_model)
      hot_water_plant.setName('SHW Loop ' + shw_hash[:identifier])
      hot_water_plant.setMaximumLoopTemperature(@@max_target_temp)
      hot_water_plant.setMinimumLoopTemperature(10)  # default value in C from OpenStudio Application

      # edit the sizing information to be for a hot water loop
      loop_sizing = hot_water_plant.sizingPlant()
      loop_sizing.setLoopType('Heating')
      loop_sizing.setDesignLoopExitTemperature(@@max_target_temp)  
      loop_sizing.setLoopDesignTemperatureDifference(5)  # default value in C from OpenStudio Application

      # add a setpoint manager for the loop
      hot_sch = @@max_temp_schedule
      if @@max_temp_schedule.nil?
        hot_sch_name = @@max_target_temp.to_s + 'C Hot Water'
        hot_sch = create_constant_schedule(openstudio_model, hot_sch_name, @@max_target_temp)
      end
      sp_manager = OpenStudio::Model::SetpointManagerScheduled.new(openstudio_model, hot_sch)
      sp_manager.addToNode(hot_water_plant.supplyOutletNode())

      # add a constant speed pump for the loop
      hot_water_pump = OpenStudio::Model::PumpConstantSpeed.new(openstudio_model)
      hot_water_pump.setName('SHW Pump' + @@sys_count.to_s)
      hot_water_pump.setRatedPumpHead(29891)  # default value in Pa from OpenStudio Application
      hot_water_pump.setMotorEfficiency(0.9)  # default value from OpenStudio Application
      hot_water_pump.addToNode(hot_water_plant.supplyInletNode())

      eq_type = shw_hash[:equipment_type]
      if eq_type == 'Default_District_SHW'
        # add a district heating system to supply the heat for the loop
        district_hw = OpenStudio::Model::WaterHeaterMixed.new(openstudio_model)
        district_hw.setName('Ideal Service Hot Water Heater')
        district_hw.setHeaterFuelType('DistrictHeating')
        district_hw.setOffCycleParasiticFuelType('DistrictHeating')
        district_hw.setOnCycleParasiticFuelType('DistrictHeating')
        district_hw.setHeaterThermalEfficiency(1.0)
        district_hw.setHeaterMaximumCapacity(1000000)
        district_hw.setTankVolume(0)
        district_hw.setHeaterControlType('Modulate')
        target_sch_name = '22C Ambient Condition'
        target_sch = create_constant_schedule(openstudio_model, target_sch_name, 22)
        district_hw.setAmbientTemperatureSchedule(target_sch)
        district_hw.setOffCycleLossCoefficienttoAmbientTemperature(0)
        district_hw.setOnCycleLossCoefficienttoAmbientTemperature(0)
        hot_water_plant.addSupplyBranchForComponent(district_hw)
        # try to minimize the impact of the pump as much as possible
        hot_water_pump.setEndUseSubcategory('Water Systems')
        hot_water_pump.setMotorEfficiency(0.9)
      else
        # add a water heater to supply the heat for the loop
        heater = OpenStudio::Model::WaterHeaterMixed.new(openstudio_model)
        if eq_type == 'Electric_WaterHeater' || eq_type == 'HeatPump_WaterHeater' || eq_type == 'Electric_TanklessHeater'
          heater.setHeaterFuelType('Electricity')
          heater.setOffCycleParasiticFuelType('Electricity')
          heater.setOnCycleParasiticFuelType('Electricity')
        end

        # set the water heater efficiency
        if eq_type == 'HeatPump_WaterHeater'
          heater.setHeaterThermalEfficiency(1.0)
        elsif shw_hash[:heater_efficiency].nil?
          if eq_type == 'Electric_WaterHeater' || eq_type == 'Electric_TanklessHeater'
            heater.setHeaterThermalEfficiency(1.0)
          else
            heater.setHeaterThermalEfficiency(0.8)
          end
        else
          heater.setHeaterThermalEfficiency(shw_hash[:heater_efficiency])
        end

        # set the ambient condition of the water tank
        to_thermal_zone = false
        unless shw_hash[:ambient_condition].nil?
          if shw_hash[:ambient_condition].is_a? Numeric
            target_sch_name = shw_hash[:ambient_condition].to_s + 'C Ambient Condition'
            target_sch = create_constant_schedule(
              openstudio_model, target_sch_name, shw_hash[:ambient_condition])
            heater.setAmbientTemperatureSchedule(target_sch)
          else
            source_zone_ref = openstudio_model.getThermalZoneByName(shw_hash[:ambient_condition])
            unless source_zone_ref.empty?
              source_zone = source_zone_ref.get
              heater.setAmbientTemperatureThermalZone(source_zone)
            end
            heater.setAmbientTemperatureIndicator('ThermalZone')
            to_thermal_zone = true
          end
        else
          target_sch_name = '22C Ambient Condition'
          target_sch = create_constant_schedule(openstudio_model, target_sch_name, 22)
          heater.setAmbientTemperatureSchedule(target_sch)
        end

        # set the ambient loss coefficient
        if to_thermal_zone
          unless shw_hash[:ambient_loss_coefficient].nil?
            heater.setOffCycleLossFractiontoThermalZone(
              shw_hash[:ambient_loss_coefficient])
            heater.setOnCycleLossFractiontoThermalZone(
              shw_hash[:ambient_loss_coefficient])
          else
            heater.setOffCycleLossFractiontoThermalZone(6)
            heater.setOnCycleLossFractiontoThermalZone(6)
          end
        else
          unless shw_hash[:ambient_loss_coefficient].nil?
            heater.setOffCycleLossCoefficienttoAmbientTemperature(
              shw_hash[:ambient_loss_coefficient])
            heater.setOnCycleLossCoefficienttoAmbientTemperature(
              shw_hash[:ambient_loss_coefficient])
          else
            heater.setOffCycleLossCoefficienttoAmbientTemperature(6)
            heater.setOnCycleLossCoefficienttoAmbientTemperature(6)
          end
        end

        # set the capactiy and and controls of the water heater
        heater.setHeaterMaximumCapacity(1000000)
        if eq_type == 'Gas_TanklessHeater' || eq_type == 'Electric_TanklessHeater'
          heater.setName('SHW Tankless WaterHeater' + @@sys_count.to_s)
          heater.setTankVolume(0)
          heater.setHeaterControlType('Modulate')
          heater.setOffCycleLossCoefficienttoAmbientTemperature(0)
          heater.setOnCycleLossCoefficienttoAmbientTemperature(0)
        else
          heater.setName('SHW WaterHeater' + @@sys_count.to_s)
          heater.setTankVolume(@@shw_rates[shw_hash[:identifier]])
        end

        # add it to the loop
        hot_water_plant.addSupplyBranchForComponent(heater)
        
        # if it's a heat pump system, then add the pump
        if eq_type == 'HeatPump_WaterHeater'
          # create a coil for the heat pump
          heat_pump = OpenStudio::Model::CoilWaterHeatingAirToWaterHeatPump.new(openstudio_model)
          heat_pump.setName('SHW HPWH DX Coil' + @@sys_count.to_s)
          if shw_hash[:heater_efficiency].nil?
            heat_pump.setRatedCOP(3.5)
          else
            heat_pump.setRatedCOP(shw_hash[:heater_efficiency])
          end

          # add a fan for the heat pump system
          fan = OpenStudio::Model::FanOnOff.new(openstudio_model)
          fan.setName('HPWH Fan' + @@sys_count.to_s)
          fan.setEndUseSubcategory('Water Systems')
          setpt_sch = create_constant_schedule(
            openstudio_model, 'HPWH Setpoint' + @@sys_count.to_s, @@max_target_temp + (@@hp_deadband * 2))
          inlet_sch = create_constant_schedule(
            openstudio_model, 'Inlet Air Mixer Fraction' + @@sys_count.to_s, 0.2)

          # add a water heater to supply the heat for the loop
          heat_sys = OpenStudio::Model::WaterHeaterHeatPump.new(
            openstudio_model, heat_pump, heater, fan, setpt_sch, inlet_sch)
          heat_sys.setDeadBandTemperatureDifference(@@hp_deadband)
          
          source_zone_ref = openstudio_model.getThermalZoneByName(shw_hash[:ambient_condition])
          unless source_zone_ref.empty?
            source_zone = source_zone_ref.get
            heat_sys.addToThermalZone(source_zone)
          end
          heat_sys.setName('SHW WaterHeater HeatPump' + @@sys_count.to_s)
        end
      end

      # add all of the water use connections to the loop and total the capacity
      @@shw_connections[shw_hash[:identifier]].each do |shw_conn|
        hot_water_plant.addDemandBranchForComponent(shw_conn)
      end
      @@sys_count = @@sys_count + 1
    end
  end
end

#defaultsObject



37
38
39
# File 'lib/honeybee/load/service_hot_water.rb', line 37

def defaults
  @@schema[:components][:schemas][:ServiceHotWaterAbridged][:properties]
end

#find_existing_openstudio_object(openstudio_model) ⇒ Object



49
50
51
52
53
# File 'lib/to_openstudio/load/service_hot_water.rb', line 49

def find_existing_openstudio_object(openstudio_model)
  model_shw = openstudio_model.getWaterUseEquipmentByName(@hash[:identifier])
  return model_shw.get unless model_shw.empty?
  nil
end

#shw_connectionsObject



45
46
47
# File 'lib/to_openstudio/load/service_hot_water.rb', line 45

def shw_connections
  @@shw_connections
end

#to_openstudio(openstudio_model, os_space, shw_name) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/to_openstudio/load/service_hot_water.rb', line 235

def to_openstudio(openstudio_model, os_space, shw_name)
  # create water use equipment + connection and set identifier
  os_shw_def = OpenStudio::Model::WaterUseEquipmentDefinition.new(openstudio_model)
  os_shw = OpenStudio::Model::WaterUseEquipment.new(os_shw_def)
  unique_id = @hash[:identifier] + '..' + os_space.nameString[0...-6]
  os_shw_def.setName(unique_id)
  os_shw.setName(unique_id)

  # assign the flow of water
  total_flow = (@hash[:flow_per_area].to_f * os_space.floorArea) / 3600000
  os_shw_def.setPeakFlowRate(total_flow)
  os_shw_def.setEndUseSubcategory('General')
  if @@shw_rates[shw_name].nil?
    @@shw_rates[shw_name] = 0
  end
  @@shw_rates[shw_name] = @@shw_rates[shw_name] + (total_flow * 3600)

  # assign schedule
  shw_schedule = openstudio_model.getScheduleByName(@hash[:schedule])
  unless shw_schedule.empty?
    shw_schedule_object = shw_schedule.get
    os_shw.setFlowRateFractionSchedule(shw_schedule_object)
  end

  # assign the hot water temperature
  target_temp = defaults[:target_temperature][:default]
  if @hash[:target_temperature]
    target_temp = @hash[:target_temperature]
  end
  target_sch_name = target_temp.to_s + 'C Hot Water'
  target_water_sch = create_constant_schedule(openstudio_model, target_sch_name, target_temp)
  os_shw_def.setTargetTemperatureSchedule(target_water_sch)

  # create the hot water connection with same temperature as target temperature
  os_shw_conn = OpenStudio::Model::WaterUseConnections.new(openstudio_model)
  os_shw_conn.addWaterUseEquipment(os_shw)
  os_shw_conn.setHotWaterSupplyTemperatureSchedule(target_water_sch)
  if target_temp > @@max_target_temp
    @@max_target_temp = target_temp
    @@max_temp_schedule = target_water_sch
  end
  if shw_name.nil?
    shw_name = 'default_district_shw'
  end
  if @@shw_connections[shw_name].nil?
    @@shw_connections[shw_name] = []
  end
  @@shw_connections[shw_name] << os_shw_conn

  # assign sensible fraction if it exists
  sens_fract = defaults[:sensible_fraction][:default]
  if @hash[:sensible_fraction]
    sens_fract = @hash[:sensible_fraction]
  end
  sens_sch_name = sens_fract.to_s + ' Hot Water Sensible Fraction'
  sens_fract_sch = create_constant_schedule(openstudio_model, sens_sch_name, sens_fract)
  os_shw_def.setSensibleFractionSchedule(sens_fract_sch)

  # assign latent fraction if it exists
  lat_fract = defaults[:latent_fraction][:default]
  if @hash[:latent_fraction]
    lat_fract = @hash[:latent_fraction]
  end
  lat_sch_name = lat_fract.to_s + ' Hot Water Latent Fraction'
  lat_fract_sch = create_constant_schedule(openstudio_model, lat_sch_name, lat_fract)
  os_shw_def.setLatentFractionSchedule(lat_fract_sch)

  # assign the service hot water to the space
  os_shw.setSpace(os_space)

  os_shw
end