lib/measures/add_hpwh/measure.rb in openstudio-load-flexibility-measures-0.4.0 vs lib/measures/add_hpwh/measure.rb in openstudio-load-flexibility-measures-0.5.0
- old
+ new
@@ -92,10 +92,11 @@
remove_wh.setDefaultValue(true)
args << remove_wh
# find available water heaters and get default volume
default_vol = 80.0 # gallons
+ wheaters = []
wh_names = ['All Water Heaters (Simplified Only)']
if !model.getWaterHeaterMixeds.empty?
wheaters = model.getWaterHeaterMixeds
wheaters.each do |w|
if w.tankVolume.to_f > OpenStudio.convert(39, 'gal', 'm^3').to_f
@@ -281,10 +282,22 @@
max_temp = runner.getDoubleArgumentValue('max_temp', user_arguments)
min_temp = runner.getDoubleArgumentValue('min_temp', user_arguments)
db_temp = runner.getDoubleArgumentValue('db_temp', user_arguments)
sched = runner.getStringArgumentValue('sched', user_arguments)
+ # get zone of one was selected
+ if zone.to_s != 'N/A - Simplified'
+ if model.getThermalZoneByName(zone).is_initialized
+ zone = model.getThermalZoneByName(zone).get
+ else
+ runner.registerError("Could not find zone named #{zone} in the moodel")
+ return false
+ end
+ else
+ zone = 'N/A - Simplified'
+ end
+
4.times do |n|
flex << runner.getStringArgumentValue("flex#{n}", user_arguments)
flex_hrs << runner.getStringArgumentValue("flex_hrs#{n}", user_arguments)
end
@@ -529,16 +542,15 @@
# Add heat pump water heater and attach to selected loop
# Reference: https://github.com/NREL/openstudio-standards/blob/master/lib/
# => openstudio-standards/prototypes/common/objects/Prototype.ServiceWaterHeating.rb
if type != 'Simplified'
# convert zone name from STRING into OS model OBJECT
- zone = model.getThermalZoneByName(zone).get
hpwh = std.model_add_heatpump_water_heater(model, # model
type: type, # type
water_heater_capacity: (cap * 1000 / cop), # water_heater_capacity
electric_backup_capacity: (bu_cap * 1000), # electric_backup_capacity
- water_heater_volume: v, # water_heater_volume
+ water_heater_volume: v.to_f, # water_heater_volume
service_water_temperature: OpenStudio.convert(140.0, 'F', 'C').get, # service_water_temperature
parasitic_fuel_consumption_rate: 3.0, # parasitic_fuel_consumption_rate
swh_temp_sch: sched, # swh_temp_sch
cop: cop, # cop
shr: 0.88, # shr
@@ -546,10 +558,9 @@
set_peak_use_flowrate: false, # set_peak_use_flowrate
peak_flowrate: 0.0, # peak_flowrate
flowrate_schedule: nil, # flowrate_schedule
water_heater_thermal_zone: zone) # water_heater_thermal_zone
else
- # zone = whtr.ambientTemperatureThermalZone.get
hpwh = std.model_add_water_heater(model, # model
(cap * 1000), # water_heater_capacity
v.to_f, # water_heater_volume
'HeatPump', # water_heater_fuel
OpenStudio.convert(140.0, 'F', 'C').to_f, # service_water_temperature