-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathhvac.rb
More file actions
5394 lines (4886 loc) · 274 KB
/
hvac.rb
File metadata and controls
5394 lines (4886 loc) · 274 KB
1
2
3
4
5
6
7
8
9
10
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
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
234
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# frozen_string_literal: true
# Collection of methods related to HVAC systems.
module HVAC
AirSourceHeatRatedODB = 47.0 # degF, Rated outdoor drybulb for air-source systems, heating
AirSourceHeatRatedIDB = 70.0 # degF, Rated indoor drybulb for air-source systems, heating
AirSourceCoolRatedODB = 95.0 # degF, Rated outdoor drybulb for air-source systems, cooling
AirSourceCoolRatedOWB = 75.0 # degF, Rated outdoor wetbulb for air-source systems, cooling
AirSourceCoolRatedIDB = 80.0 # degF, Rated indoor drybulb for air-source systems, cooling
AirSourceCoolRatedIWB = 67.0 # degF, Rated indoor wetbulb for air-source systems, cooling
RatedCFMPerTon = 400.0 # cfm/ton of rated capacity, RESNET HERS Addendum 82
CrankcaseHeaterTemp = 50.0 # degF, RESNET HERS Addendum 82
MinCapacity = 1.0 # Btuh
MinAirflow = 3.0 # cfm; E+ min airflow is 0.001 m3/s
GroundSourceHeatRatedWET = 70.0 # degF, Rated water entering temperature for ground-source systems, heating
GroundSourceHeatRatedIDB = 70.0 # degF, Rated indoor drybulb for ground-source systems, heating
GroundSourceCoolRatedWET = 85.0 # degF, Rated water entering temperature for ground-source systems, cooling
GroundSourceCoolRatedIDB = 80.0 # degF, Rated indoor drybulb for ground-source systems, cooling
GroundSourceCoolRatedIWB = 67.0 # degF, Rated indoor wetbulb for ground-source systems, cooling
# Adds any HVAC Systems to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @param hvac_season_days [Hash] Map of htg/clg => Array of 365 days with 1s during the heating/cooling season and 0s otherwise
# @return [Hash] Map of HPXML System ID -> AirLoopHVAC (or ZoneHVACFourPipeFanCoil)
def self.apply_hvac_systems(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, hvac_season_days)
# Init
hvac_remaining_load_fracs = { htg: 1.0, clg: 1.0 }
airloop_map = {}
if hpxml_bldg.hvac_controls.size == 0
return airloop_map
end
hvac_unavailable_periods = { htg: Schedule.get_unavailable_periods(runner, SchedulesFile::Columns[:SpaceHeating].name, hpxml_header.unavailable_periods),
clg: Schedule.get_unavailable_periods(runner, SchedulesFile::Columns[:SpaceCooling].name, hpxml_header.unavailable_periods) }
# Create heating availability sensor
if not hvac_unavailable_periods[:htg].empty?
htg_avail_sch = ScheduleConstant.new(model, 'heating availability schedule', 1.0, EPlus::ScheduleTypeLimitsFraction, unavailable_periods: hvac_unavailable_periods[:htg])
htg_avail_sensor = Model.add_ems_sensor(
model,
name: "#{htg_avail_sch.schedule.name} s",
output_var_or_meter_name: 'Schedule Value',
key_name: htg_avail_sch.schedule.name
)
htg_avail_sensor.additionalProperties.setFeature('ObjectType', Constants::ObjectTypeHeatingAvailabilitySensor)
end
# Create cooling availability sensor
if not hvac_unavailable_periods[:clg].empty?
clg_avail_sch = ScheduleConstant.new(model, 'cooling availability schedule', 1.0, EPlus::ScheduleTypeLimitsFraction, unavailable_periods: hvac_unavailable_periods[:clg])
clg_avail_sensor = Model.add_ems_sensor(
model,
name: "#{clg_avail_sch.schedule.name} s",
output_var_or_meter_name: 'Schedule Value',
key_name: clg_avail_sch.schedule.name
)
clg_avail_sensor.additionalProperties.setFeature('ObjectType', Constants::ObjectTypeCoolingAvailabilitySensor)
end
apply_unit_multiplier(hpxml_bldg, hpxml_header)
ensure_nonzero_sizing_values(hpxml_bldg)
apply_ideal_air_systems(model, weather, spaces, hpxml_bldg, hpxml_header, hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs)
apply_cooling_system(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, airloop_map, hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs)
hp_backup_obj = apply_heating_system(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, airloop_map, hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs)
apply_heat_pump(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, airloop_map, hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs, hp_backup_obj)
return airloop_map
end
# Adds any HPXML Cooling Systems to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @param airloop_map [Hash] Map of HPXML System ID => OpenStudio AirLoopHVAC (or ZoneHVACFourPipeFanCoil or ZoneHVACBaseboardConvectiveWater) objects
# @param hvac_season_days [Hash] Map of htg/clg => Array of 365 days with 1s during the heating/cooling season and 0s otherwise
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @param hvac_remaining_load_fracs [Hash] Map of htg/clg => Fraction of heating/cooling load that has not yet been met
# @return [nil]
def self.apply_cooling_system(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, airloop_map,
hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs)
conditioned_zone = spaces[HPXML::LocationConditionedSpace].thermalZone.get
get_hpxml_hvac_systems(hpxml_bldg).each do |hvac_system|
next if hvac_system[:cooling].nil?
next unless hvac_system[:cooling].is_a? HPXML::CoolingSystem
cooling_system = hvac_system[:cooling]
heating_system = hvac_system[:heating]
check_distribution_system(cooling_system, cooling_system.cooling_system_type)
hvac_sequential_load_fracs = {}
# Calculate cooling sequential load fractions
hvac_sequential_load_fracs[:clg] = calc_sequential_load_fractions(cooling_system.fraction_cool_load_served.to_f, hvac_remaining_load_fracs[:clg], hvac_season_days[:clg])
hvac_remaining_load_fracs[:clg] -= cooling_system.fraction_cool_load_served.to_f
# Calculate heating sequential load fractions
if not heating_system.nil?
hvac_sequential_load_fracs[:htg] = calc_sequential_load_fractions(heating_system.fraction_heat_load_served, hvac_remaining_load_fracs[:htg], hvac_season_days[:htg])
hvac_remaining_load_fracs[:htg] -= heating_system.fraction_heat_load_served
elsif cooling_system.has_integrated_heating
hvac_sequential_load_fracs[:htg] = calc_sequential_load_fractions(cooling_system.integrated_heating_system_fraction_heat_load_served, hvac_remaining_load_fracs[:htg], hvac_season_days[:htg])
hvac_remaining_load_fracs[:htg] -= cooling_system.integrated_heating_system_fraction_heat_load_served
else
hvac_sequential_load_fracs[:htg] = [0]
end
sys_id = cooling_system.id
case cooling_system.cooling_system_type
when HPXML::HVACTypeCentralAirConditioner, HPXML::HVACTypeRoomAirConditioner,
HPXML::HVACTypeMiniSplitAirConditioner, HPXML::HVACTypePTAC
airloop_map[sys_id] = apply_air_source_hvac_systems(runner, model, weather, hpxml_bldg, hpxml_header, cooling_system, heating_system,
hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods, schedules_file)
when HPXML::HVACTypeEvaporativeCooler
airloop_map[sys_id] = apply_evaporative_cooler(model, hpxml_bldg, cooling_system, hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods)
end
end
end
# Adds any HPXML Heating Systems to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @param airloop_map [Hash] Map of HPXML System ID => OpenStudio AirLoopHVAC (or ZoneHVACFourPipeFanCoil or ZoneHVACBaseboardConvectiveWater) objects
# @param hvac_season_days [Hash] Map of htg/clg => Array of 365 days with 1s during the heating/cooling season and 0s otherwise
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @param hvac_remaining_load_fracs [Hash] Map of htg/clg => Fraction of heating/cooling load that has not yet been met
# @return [OpenStudio::Model::ModelObject] Heat pump separate backup heating system equipment object
def self.apply_heating_system(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, airloop_map,
hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs)
conditioned_zone = spaces[HPXML::LocationConditionedSpace].thermalZone.get
hp_backup_obj = nil
get_hpxml_hvac_systems(hpxml_bldg).each do |hvac_system|
next if hvac_system[:heating].nil?
next unless hvac_system[:heating].is_a? HPXML::HeatingSystem
cooling_system = hvac_system[:cooling]
heating_system = hvac_system[:heating]
check_distribution_system(heating_system, heating_system.heating_system_type)
if (heating_system.heating_system_type == HPXML::HVACTypeFurnace) && (not cooling_system.nil?)
next # Already processed combined AC+furnace
end
hvac_sequential_load_fracs = {}
# Calculate heating sequential load fractions
if heating_system.is_heat_pump_backup_system
# Heating system will be last in the EquipmentList and should meet entirety of
# remaining load during the heating season.
hvac_sequential_load_fracs[:htg] = hvac_season_days[:htg].map(&:to_f)
if not heating_system.fraction_heat_load_served.nil?
fail 'Heat pump backup system cannot have a fraction heat load served specified.'
end
else
hvac_sequential_load_fracs[:htg] = calc_sequential_load_fractions(heating_system.fraction_heat_load_served, hvac_remaining_load_fracs[:htg], hvac_season_days[:htg])
hvac_remaining_load_fracs[:htg] -= heating_system.fraction_heat_load_served
end
sys_id = heating_system.id
case heating_system.heating_system_type
when HPXML::HVACTypeFurnace
airloop_map[sys_id] = apply_air_source_hvac_systems(runner, model, weather, hpxml_bldg, hpxml_header, nil, heating_system,
hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods, schedules_file)
when HPXML::HVACTypeBoiler
airloop_map[sys_id] = apply_boiler(runner, model, heating_system, hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods)
when HPXML::HVACTypeElectricResistance
apply_electric_baseboard(model, heating_system, hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods)
when HPXML::HVACTypeStove, HPXML::HVACTypeSpaceHeater, HPXML::HVACTypeWallFurnace,
HPXML::HVACTypeFloorFurnace, HPXML::HVACTypeFireplace
apply_unit_heater(model, heating_system, hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods)
end
next unless heating_system.is_heat_pump_backup_system
# Store OS object for later use
hp_backup_obj = model.getZoneHVACEquipmentLists.find { |el| el.thermalZone == conditioned_zone }.equipment[-1]
end
return hp_backup_obj
end
# Adds any HPXML Heat Pumps to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @param airloop_map [Hash] Map of HPXML System ID => OpenStudio AirLoopHVAC (or ZoneHVACFourPipeFanCoil or ZoneHVACBaseboardConvectiveWater) objects
# @param hvac_season_days [Hash] Map of htg/clg => Array of 365 days with 1s during the heating/cooling season and 0s otherwise
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @param hvac_remaining_load_fracs [Hash] Map of htg/clg => Fraction of heating/cooling load that has not yet been met
# @param hp_backup_obj [OpenStudio::Model::ModelObject] Heat pump separate backup heating system equipment object
# @return [nil]
def self.apply_heat_pump(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedules_file, airloop_map,
hvac_season_days, hvac_unavailable_periods, hvac_remaining_load_fracs, hp_backup_obj)
conditioned_zone = spaces[HPXML::LocationConditionedSpace].thermalZone.get
get_hpxml_hvac_systems(hpxml_bldg).each do |hvac_system|
next if hvac_system[:cooling].nil?
next unless hvac_system[:cooling].is_a? HPXML::HeatPump
heat_pump = hvac_system[:cooling]
check_distribution_system(heat_pump, heat_pump.heat_pump_type)
hvac_sequential_load_fracs = {}
# Calculate heating sequential load fractions
hvac_sequential_load_fracs[:htg] = calc_sequential_load_fractions(heat_pump.fraction_heat_load_served, hvac_remaining_load_fracs[:htg], hvac_season_days[:htg])
hvac_remaining_load_fracs[:htg] -= heat_pump.fraction_heat_load_served
# Calculate cooling sequential load fractions
hvac_sequential_load_fracs[:clg] = calc_sequential_load_fractions(heat_pump.fraction_cool_load_served, hvac_remaining_load_fracs[:clg], hvac_season_days[:clg])
hvac_remaining_load_fracs[:clg] -= heat_pump.fraction_cool_load_served
sys_id = heat_pump.id
case heat_pump.heat_pump_type
when HPXML::HVACTypeHeatPumpWaterLoopToAir
airloop_map[sys_id] = apply_water_loop_to_air_heat_pump(model, heat_pump, hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods)
when HPXML::HVACTypeHeatPumpAirToAir, HPXML::HVACTypeHeatPumpMiniSplit,
HPXML::HVACTypeHeatPumpPTHP, HPXML::HVACTypeHeatPumpRoom
airloop_map[sys_id] = apply_air_source_hvac_systems(runner, model, weather, hpxml_bldg, hpxml_header, heat_pump, heat_pump,
hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods, schedules_file)
when HPXML::HVACTypeHeatPumpGroundToAir
airloop_map[sys_id] = apply_ground_source_heat_pump(runner, model, weather, hpxml_bldg, hpxml_header, heat_pump,
hvac_sequential_load_fracs, conditioned_zone, hvac_unavailable_periods)
end
next if heat_pump.backup_system.nil?
equipment_list = model.getZoneHVACEquipmentLists.find { |el| el.thermalZone == conditioned_zone }
# Set priority to be last (i.e., after the heat pump that it is backup for)
equipment_list.setHeatingPriority(hp_backup_obj, 99)
equipment_list.setCoolingPriority(hp_backup_obj, 99)
end
end
# Adds the HPXML air-source hvac system (central/minisplit/room ACs or HPs, furnace, etc.) to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param cooling_system [HPXML::CoolingSystem or HPXML::HeatPump] The HPXML cooling system or heat pump of interest
# @param heating_system [HPXML::HeatingSystem or HPXML::HeatPump] The HPXML heating system or heat pump of interest
# @param hvac_sequential_load_fracs [Hash<Array<Double>>] Map of htg/clg => Array of daily fractions of remaining heating/cooling load to be met by the HVAC system
# @param control_zone [OpenStudio::Model::ThermalZone] Conditioned space thermal zone
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @return [OpenStudio::Model::AirLoopHVAC] The newly created air loop hvac object
def self.apply_air_source_hvac_systems(runner, model, weather, hpxml_bldg, hpxml_header, cooling_system, heating_system,
hvac_sequential_load_fracs, control_zone, hvac_unavailable_periods, schedules_file)
if not cooling_system.nil?
clg_ap = cooling_system.additional_properties
end
if not heating_system.nil?
htg_ap = heating_system.additional_properties
end
if (not cooling_system.nil?)
has_deadband_control = hpxml_header.hvac_onoff_thermostat_deadband.to_f > 0.0
# Error-checking
if has_deadband_control
if not [HPXML::HVACCompressorTypeSingleStage, HPXML::HVACCompressorTypeTwoStage].include? cooling_system.compressor_type
# Throw error and stop simulation, because the setpoint schedule is already shifted, user will get wrong results otherwise.
runner.registerError('On-off thermostat deadband currently is only supported for single speed or two speed air source systems.')
end
if hpxml_bldg.building_construction.number_of_units > 1
# Throw error and stop simulation
runner.registerError('NumberofUnits greater than 1 is not supported for on-off thermostat deadband.')
end
end
else
has_deadband_control = false
end
is_heatpump = false
if not cooling_system.nil?
if cooling_system.is_a? HPXML::HeatPump
is_heatpump = true
case cooling_system.heat_pump_type
when HPXML::HVACTypeHeatPumpAirToAir
obj_name = Constants::ObjectTypeAirSourceHeatPump
when HPXML::HVACTypeHeatPumpMiniSplit
obj_name = Constants::ObjectTypeMiniSplitHeatPump
when HPXML::HVACTypeHeatPumpPTHP
obj_name = Constants::ObjectTypePTHP
fan_watts_per_cfm = 0.0
when HPXML::HVACTypeHeatPumpRoom
obj_name = Constants::ObjectTypeRoomHP
fan_watts_per_cfm = 0.0
else
fail "Unexpected heat pump type: #{cooling_system.heat_pump_type}."
end
elsif cooling_system.is_a? HPXML::CoolingSystem
case cooling_system.cooling_system_type
when HPXML::HVACTypeCentralAirConditioner
if heating_system.nil?
obj_name = Constants::ObjectTypeCentralAirConditioner
else
obj_name = Constants::ObjectTypeCentralAirConditionerAndFurnace
# error checking for fan motor type
if (not cooling_system.fan_motor_type.nil?) && (not heating_system.fan_motor_type.nil?) && (cooling_system.fan_motor_type != heating_system.fan_motor_type)
fail "Fan motor types for heating system '#{heating_system.id}' (#{heating_system.fan_motor_type}) and cooling system '#{cooling_system.id}' (#{cooling_system.fan_motor_type}) are attached to a single distribution system and therefore must be the same."
end
# error checking for fan power
if (not cooling_system.fan_watts_per_cfm.nil?) && (not heating_system.fan_watts_per_cfm.nil?) && (cooling_system.fan_watts_per_cfm != heating_system.fan_watts_per_cfm)
fail "Fan powers for heating system '#{heating_system.id}' (#{heating_system.fan_watts_per_cfm} W/cfm) and cooling system '#{cooling_system.id}' (#{cooling_system.fan_watts_per_cfm} W/cfm) are attached to a single distribution system and therefore must be the same."
end
end
when HPXML::HVACTypeRoomAirConditioner, HPXML::HVACTypePTAC
fan_watts_per_cfm = 0.0
if cooling_system.cooling_system_type == HPXML::HVACTypeRoomAirConditioner
obj_name = Constants::ObjectTypeRoomAC
else
obj_name = Constants::ObjectTypePTAC
end
when HPXML::HVACTypeMiniSplitAirConditioner
obj_name = Constants::ObjectTypeMiniSplitAirConditioner
else
fail "Unexpected cooling system type: #{cooling_system.cooling_system_type}."
end
end
elsif (heating_system.is_a? HPXML::HeatingSystem) && (heating_system.heating_system_type == HPXML::HVACTypeFurnace)
obj_name = Constants::ObjectTypeFurnace
else
fail "Unexpected heating system type: #{heating_system.heating_system_type}, expect central air source hvac systems."
end
if fan_watts_per_cfm.nil?
if (not cooling_system.nil?) && (not cooling_system.fan_watts_per_cfm.nil?)
fan_watts_per_cfm = cooling_system.fan_watts_per_cfm
else
fan_watts_per_cfm = heating_system.fan_watts_per_cfm
end
end
# Calculate fan heating/cooling airflow rates at all speeds
fan_cfms = []
if not cooling_system.nil?
clg_cfm = clg_ap.cooling_actual_airflow_cfm
clg_ap.cool_capacity_ratios.each do |capacity_ratio|
fan_cfms << clg_cfm * capacity_ratio
end
if (cooling_system.is_a? HPXML::CoolingSystem) && cooling_system.has_integrated_heating
htg_cfm = cooling_system.integrated_heating_system_airflow_cfm
fan_cfms << htg_cfm
end
end
if not heating_system.nil?
if is_heatpump
htg_cfm = htg_ap.heating_actual_airflow_cfm
htg_ap.heat_capacity_ratios.each do |capacity_ratio|
fan_cfms << htg_cfm * capacity_ratio
end
else
htg_cfm = htg_ap.heating_actual_airflow_cfm
fan_cfms << htg_cfm
end
end
if not cooling_system.nil?
# Cooling Coil
clg_coil = create_dx_cooling_coil(model, obj_name, cooling_system, weather.data.AnnualMaxDrybulb, has_deadband_control)
if (cooling_system.is_a? HPXML::CoolingSystem) && cooling_system.has_integrated_heating
htg_coil = Model.add_coil_heating(
model,
name: "#{obj_name} htg coil",
efficiency: cooling_system.integrated_heating_system_efficiency_percent,
capacity: UnitConversions.convert(cooling_system.integrated_heating_system_capacity, 'Btu/hr', 'W'),
fuel_type: cooling_system.integrated_heating_system_fuel
)
htg_coil.additionalProperties.setFeature('HPXML_ID', cooling_system.id) # Used by reporting measure
end
end
if not heating_system.nil?
if is_heatpump
supp_max_temp = htg_ap.supp_max_temp
# Heating Coil
htg_coil = create_dx_heating_coil(model, obj_name, heating_system, weather.data.AnnualMinDrybulb, has_deadband_control)
# Supplemental Heating Coil
htg_supp_coil = create_heat_pump_supplemental_heating_coil(model, obj_name, heating_system, hpxml_header, runner, hpxml_bldg)
else
# Heating Coil
htg_coil = Model.add_coil_heating(
model,
name: "#{obj_name} htg coil",
efficiency: heating_system.heating_efficiency_afue,
capacity: UnitConversions.convert(heating_system.heating_capacity, 'Btu/hr', 'W'),
fuel_type: heating_system.heating_system_fuel,
off_cycle_gas_load: UnitConversions.convert(heating_system.pilot_light_btuh.to_f, 'Btu/hr', 'W')
)
htg_coil.additionalProperties.setFeature('HPXML_ID', heating_system.id) # Used by reporting measure
htg_coil.additionalProperties.setFeature('IsHeatPumpBackup', heating_system.is_heat_pump_backup_system) # Used by reporting measure
end
end
# Fan
hvac_system = cooling_system.nil? ? heating_system : cooling_system
fan = create_supply_fan(model, obj_name, fan_watts_per_cfm, fan_cfms, hvac_system)
if heating_system.is_a?(HPXML::HeatPump) && (not heating_system.backup_system.nil?) && (not htg_ap.hp_min_temp.nil?)
# Disable blower fan power below compressor lockout temperature if separate backup heating system
add_fan_power_ems_program(model, fan, htg_ap.hp_min_temp)
end
if (not cooling_system.nil?) && (not heating_system.nil?) && (cooling_system == heating_system)
add_fan_pump_disaggregation_ems_program(model, fan, htg_coil, clg_coil, htg_supp_coil, cooling_system)
else
if not cooling_system.nil?
if cooling_system.has_integrated_heating
add_fan_pump_disaggregation_ems_program(model, fan, htg_coil, clg_coil, nil, cooling_system)
else
add_fan_pump_disaggregation_ems_program(model, fan, nil, clg_coil, nil, cooling_system)
end
end
if not heating_system.nil?
if heating_system.is_heat_pump_backup_system
add_fan_pump_disaggregation_ems_program(model, fan, nil, nil, htg_coil, heating_system)
else
add_fan_pump_disaggregation_ems_program(model, fan, htg_coil, nil, htg_supp_coil, heating_system)
end
end
end
# Unitary System
air_loop_unitary = create_air_loop_unitary_system(model, obj_name, fan, htg_coil, clg_coil, htg_supp_coil, htg_cfm, clg_cfm, supp_max_temp)
# Unitary System Performance
if (not clg_ap.nil?) && (clg_ap.cool_capacity_ratios.size > 1)
perf = OpenStudio::Model::UnitarySystemPerformanceMultispeed.new(model)
perf.setSingleModeOperation(false)
for speed in 1..clg_ap.cool_capacity_ratios.size
if is_heatpump
f = OpenStudio::Model::SupplyAirflowRatioField.new(htg_ap.heat_capacity_ratios[speed - 1], clg_ap.cool_capacity_ratios[speed - 1])
else
f = OpenStudio::Model::SupplyAirflowRatioField.fromCoolingRatio(clg_ap.cool_capacity_ratios[speed - 1])
end
perf.addSupplyAirflowRatioField(f)
end
air_loop_unitary.setDesignSpecificationMultispeedObject(perf)
end
# Air Loop
air_loop = create_air_loop(model, obj_name, air_loop_unitary, control_zone, hvac_sequential_load_fracs, [htg_cfm.to_f, clg_cfm.to_f].max, heating_system, hvac_unavailable_periods)
add_backup_staging_ems_program(model, air_loop_unitary, htg_supp_coil, control_zone, htg_coil)
apply_installation_quality_ems_program(model, heating_system, cooling_system, air_loop_unitary, htg_coil, clg_coil, control_zone)
# supp coil control in staging EMS
add_two_speed_staging_ems_program(model, air_loop_unitary, htg_supp_coil, control_zone, has_deadband_control, cooling_system)
add_supplemental_coil_ems_program(model, htg_supp_coil, control_zone, htg_coil, has_deadband_control, cooling_system)
add_variable_speed_power_ems_program(runner, model, air_loop_unitary, control_zone, heating_system, cooling_system, htg_supp_coil, clg_coil, htg_coil, schedules_file)
if not cooling_system.nil?
if is_heatpump
ems_program = apply_defrost_ems_program(model, htg_coil, control_zone.spaces[0], cooling_system, hpxml_bldg.building_construction.number_of_units)
apply_pan_heater_ems_program(model, ems_program, htg_coil, control_zone.spaces[0], cooling_system, htg_ap.hp_min_temp)
end
apply_crankcase_heater_ems_program(model, htg_coil, clg_coil, control_zone.spaces[0], cooling_system)
end
return air_loop
end
# Adds the HPXML evaporative cooler system to the OpenStudio model.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param cooling_system [HPXML::CoolingSystem or HPXML::HeatPump] The HPXML cooling system or heat pump of interest
# @param hvac_sequential_load_fracs [Hash<Array<Double>>] Map of htg/clg => Array of daily fractions of remaining heating/cooling load to be met by the HVAC system
# @param control_zone [OpenStudio::Model::ThermalZone] Conditioned space thermal zone
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @return [OpenStudio::Model::AirLoopHVAC] The newly created air loop hvac object
def self.apply_evaporative_cooler(model, hpxml_bldg, cooling_system, hvac_sequential_load_fracs, control_zone, hvac_unavailable_periods)
obj_name = Constants::ObjectTypeEvaporativeCooler
clg_ap = cooling_system.additional_properties
clg_cfm = clg_ap.cooling_actual_airflow_cfm
unit_multiplier = hpxml_bldg.building_construction.number_of_units
# Evap Cooler
evap_cooler = OpenStudio::Model::EvaporativeCoolerDirectResearchSpecial.new(model, model.alwaysOnDiscreteSchedule)
evap_cooler.setName(obj_name)
evap_cooler.setCoolerEffectiveness(clg_ap.effectiveness)
evap_cooler.setEvaporativeOperationMinimumDrybulbTemperature(0) # relax limitation to open evap cooler for any potential cooling
evap_cooler.setEvaporativeOperationMaximumLimitWetbulbTemperature(50) # relax limitation to open evap cooler for any potential cooling
evap_cooler.setEvaporativeOperationMaximumLimitDrybulbTemperature(50) # relax limitation to open evap cooler for any potential cooling
evap_cooler.setPrimaryAirDesignFlowRate(UnitConversions.convert(clg_cfm, 'cfm', 'm^3/s'))
evap_cooler.additionalProperties.setFeature('HPXML_ID', cooling_system.id) # Used by reporting measure
# Air Loop
air_loop = create_air_loop(model, obj_name, evap_cooler, control_zone, hvac_sequential_load_fracs, clg_cfm, nil, hvac_unavailable_periods)
# Fan
fan_watts_per_cfm = [2.79 * (clg_cfm / unit_multiplier)**-0.29, 0.6].min # W/cfm; fit of efficacy to air flow from the CEC listed equipment
fan = create_supply_fan(model, obj_name, fan_watts_per_cfm, [clg_cfm], cooling_system)
fan.addToNode(air_loop.supplyInletNode)
add_fan_pump_disaggregation_ems_program(model, fan, nil, evap_cooler, nil, cooling_system)
# Outdoor air intake system
oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)
oa_intake_controller.setName("#{air_loop.name} OA Controller")
oa_intake_controller.setMinimumLimitType('FixedMinimum')
oa_intake_controller.resetEconomizerMinimumLimitDryBulbTemperature
oa_intake_controller.setMinimumFractionofOutdoorAirSchedule(model.alwaysOnDiscreteSchedule)
oa_intake_controller.setMaximumOutdoorAirFlowRate(UnitConversions.convert(clg_cfm, 'cfm', 'm^3/s'))
oa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)
oa_intake.setName("#{air_loop.name} OA System")
oa_intake.addToNode(air_loop.supplyInletNode)
# air handler controls
# setpoint follows OAT WetBulb
evap_stpt_manager = OpenStudio::Model::SetpointManagerFollowOutdoorAirTemperature.new(model)
evap_stpt_manager.setName('Follow OATwb')
evap_stpt_manager.setReferenceTemperatureType('OutdoorAirWetBulb')
evap_stpt_manager.setOffsetTemperatureDifference(0.0)
evap_stpt_manager.addToNode(air_loop.supplyOutletNode)
return air_loop
end
# Adds the HPXML ground-source heat pump system to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param heat_pump [HPXML::HeatPump] The HPXML heat pump of interest
# @param hvac_sequential_load_fracs [Hash<Array<Double>>] Map of htg/clg => Array of daily fractions of remaining heating/cooling load to be met by the HVAC system
# @param control_zone [OpenStudio::Model::ThermalZone] Conditioned space thermal zone
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @return [OpenStudio::Model::AirLoopHVAC] The newly created air loop hvac object
def self.apply_ground_source_heat_pump(runner, model, weather, hpxml_bldg, hpxml_header, heat_pump,
hvac_sequential_load_fracs, control_zone, hvac_unavailable_periods)
unit_multiplier = hpxml_bldg.building_construction.number_of_units
if unit_multiplier > 1
# FUTURE: Figure out how to allow this. If we allow it, update docs and hpxml_translator_test.rb too.
# https://github.com/NREL/OpenStudio-HPXML/issues/1499
fail 'NumberofUnits greater than 1 is not supported for ground-to-air heat pumps.'
end
obj_name = Constants::ObjectTypeGroundSourceHeatPump
geothermal_loop = heat_pump.geothermal_loop
hp_ap = heat_pump.additional_properties
htg_cfm = hp_ap.heating_actual_airflow_cfm
clg_cfm = hp_ap.cooling_actual_airflow_cfm
htg_air_flow_rated = calc_rated_airflow(heat_pump.heating_capacity, hp_ap.heat_rated_cfm_per_ton, 'm^3/s')
clg_air_flow_rated = calc_rated_airflow(heat_pump.cooling_capacity, hp_ap.cool_rated_cfm_per_ton, 'm^3/s')
if hp_ap.frac_glycol == 0
hp_ap.fluid_type = EPlus::FluidWater
runner.registerWarning("Specified #{hp_ap.fluid_type} fluid type and 0 fraction of glycol, so assuming #{EPlus::FluidWater} fluid type.")
end
# Apply unit multiplier
geothermal_loop.loop_flow *= unit_multiplier
geothermal_loop.num_bore_holes *= unit_multiplier
if [HPXML::GroundToAirHeatPumpModelTypeStandard].include? hpxml_header.ground_to_air_heat_pump_model_type
# Cooling Coil
clg_total_cap_curve = Model.add_curve_quad_linear(
model,
name: "#{obj_name} clg total cap curve",
coeff: hp_ap.cool_cap_curve_spec[0]
)
clg_sens_cap_curve = Model.add_curve_quint_linear(
model,
name: "#{obj_name} clg sens cap curve",
coeff: hp_ap.cool_sh_curve_spec[0]
)
clg_power_curve = Model.add_curve_quad_linear(
model,
name: "#{obj_name} clg power curve",
coeff: hp_ap.cool_power_curve_spec[0]
)
clg_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model, clg_total_cap_curve, clg_sens_cap_curve, clg_power_curve)
clg_coil.setName(obj_name + ' clg coil')
clg_coil.setRatedCoolingCoefficientofPerformance(hp_ap.cool_rated_cops[0])
clg_coil.setNominalTimeforCondensateRemovaltoBegin(1000)
clg_coil.setRatioofInitialMoistureEvaporationRateandSteadyStateLatentCapacity(1.5)
clg_coil.setRatedAirFlowRate(clg_air_flow_rated)
clg_coil.setRatedWaterFlowRate(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s'))
clg_coil.setRatedEnteringWaterTemperature(UnitConversions.convert(80, 'F', 'C'))
clg_coil.setRatedEnteringAirDryBulbTemperature(UnitConversions.convert(80, 'F', 'C'))
clg_coil.setRatedEnteringAirWetBulbTemperature(UnitConversions.convert(67, 'F', 'C'))
# TODO: Add net to gross conversion after RESNET PR: https://github.com/NREL/OpenStudio-HPXML/pull/1879
clg_coil.setRatedTotalCoolingCapacity(UnitConversions.convert(heat_pump.cooling_capacity, 'Btu/hr', 'W'))
clg_coil.setRatedSensibleCoolingCapacity(UnitConversions.convert(heat_pump.cooling_capacity * hp_ap.cool_rated_shr_gross, 'Btu/hr', 'W'))
# Heating Coil
htg_cap_curve = Model.add_curve_quad_linear(
model,
name: "#{obj_name} htg cap curve",
coeff: hp_ap.heat_cap_curve_spec[0]
)
htg_power_curve = Model.add_curve_quad_linear(
model,
name: "#{obj_name} htg power curve",
coeff: hp_ap.heat_power_curve_spec[0]
)
htg_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model, htg_cap_curve, htg_power_curve)
htg_coil.setName(obj_name + ' htg coil')
htg_coil.setRatedHeatingCoefficientofPerformance(hp_ap.heat_rated_cops[0])
htg_coil.setRatedAirFlowRate(htg_air_flow_rated)
htg_coil.setRatedWaterFlowRate(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s'))
htg_coil.setRatedEnteringWaterTemperature(UnitConversions.convert(60, 'F', 'C'))
htg_coil.setRatedEnteringAirDryBulbTemperature(UnitConversions.convert(70, 'F', 'C'))
# TODO: Add net to gross conversion after RESNET PR: https://github.com/NREL/OpenStudio-HPXML/pull/1879
htg_coil.setRatedHeatingCapacity(UnitConversions.convert(heat_pump.heating_capacity, 'Btu/hr', 'W'))
elsif [HPXML::GroundToAirHeatPumpModelTypeExperimental].include? hpxml_header.ground_to_air_heat_pump_model_type
num_speeds = hp_ap.cool_capacity_ratios.size
if heat_pump.compressor_type == HPXML::HVACCompressorTypeVariableSpeed
plf_fplr_curve = Model.add_curve_quadratic(
model,
name: 'Cool-PLF-fPLR',
coeff: [1.0, 0.0, 0.0],
min_x: 0, max_x: 1, min_y: 0.7, max_y: 1
)
else
# Derived from: https://www.e3s-conferences.org/articles/e3sconf/pdf/2018/19/e3sconf_eko-dok2018_00139.pdf
plf_fplr_curve = Model.add_curve_cubic(
model,
name: 'Cool-PLF-fPLR',
coeff: [0.4603, 1.6416, -1.8588, 0.7605],
min_x: 0, max_x: 1, min_y: 0.7, max_y: 1
)
end
clg_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit.new(model, plf_fplr_curve)
clg_coil.setName(obj_name + ' clg coil')
clg_coil.setNominalTimeforCondensatetoBeginLeavingtheCoil(1000)
clg_coil.setInitialMoistureEvaporationRateDividedbySteadyStateACLatentCapacity(1.5)
clg_coil.setNominalSpeedLevel(num_speeds)
clg_coil.setRatedAirFlowRateAtSelectedNominalSpeedLevel(clg_air_flow_rated)
clg_coil.setRatedWaterFlowRateAtSelectedNominalSpeedLevel(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s'))
# TODO: Add net to gross conversion after RESNET PR: https://github.com/NREL/OpenStudio-HPXML/pull/1879
clg_coil.setGrossRatedTotalCoolingCapacityAtSelectedNominalSpeedLevel(UnitConversions.convert(heat_pump.cooling_capacity, 'Btu/hr', 'W'))
for i in 0..(num_speeds - 1)
cap_ft_curve = Model.add_curve_biquadratic(
model,
name: "Cool-CAP-fT#{i + 1}",
coeff: hp_ap.cool_cap_ft_spec[i],
min_x: -100, max_x: 100, min_y: -100, max_y: 100
)
cap_faf_curve = Model.add_curve_quadratic(
model,
name: "Cool-CAP-fAF#{i + 1}",
coeff: hp_ap.cool_cap_fflow_spec[i],
min_x: 0, max_x: 2, min_y: 0, max_y: 2
)
cap_fwf_curve = Model.add_curve_quadratic(
model,
name: "Cool-CAP-fWF#{i + 1}",
coeff: hp_ap.cool_cap_fwf_spec[i],
min_x: 0.45, max_x: 2, min_y: 0, max_y: 2
)
eir_ft_curve = Model.add_curve_biquadratic(
model,
name: "Cool-EIR-fT#{i + 1}",
coeff: hp_ap.cool_eir_ft_spec[i],
min_x: -100, max_x: 100, min_y: -100, max_y: 100
)
eir_faf_curve = Model.add_curve_quadratic(
model,
name: "Cool-EIR-fAF#{i + 1}",
coeff: hp_ap.cool_eir_fflow_spec[i],
min_x: 0, max_x: 2, min_y: 0, max_y: 2
)
eir_fwf_curve = Model.add_curve_quadratic(
model,
name: "Cool-EIR-fWF#{i + 1}",
coeff: hp_ap.cool_eir_fwf_spec[i],
min_x: 0.45, max_x: 2, min_y: 0, max_y: 2
)
# Recoverable heat modifier as a function of indoor wet-bulb and water entering temperatures.
waste_heat_ft = Model.add_curve_biquadratic(
model,
name: "WasteHeat-FT#{i + 1}",
coeff: [1, 0, 0, 0, 0, 0]
)
speed = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFitSpeedData.new(model, cap_ft_curve, cap_faf_curve, cap_fwf_curve, eir_ft_curve, eir_faf_curve, eir_fwf_curve, waste_heat_ft)
# TODO: Add net to gross conversion after RESNET PR: https://github.com/NREL/OpenStudio-HPXML/pull/1879
speed.setReferenceUnitGrossRatedTotalCoolingCapacity(UnitConversions.convert(heat_pump.cooling_capacity, 'Btu/hr', 'W') * hp_ap.cool_capacity_ratios[i])
speed.setReferenceUnitGrossRatedSensibleHeatRatio(hp_ap.cool_rated_shr_gross)
speed.setReferenceUnitGrossRatedCoolingCOP(hp_ap.cool_rated_cops[i])
speed.setReferenceUnitRatedAirFlowRate(UnitConversions.convert(UnitConversions.convert(heat_pump.cooling_capacity, 'Btu/hr', 'ton') * hp_ap.cool_capacity_ratios[i] * hp_ap.cool_rated_cfm_per_ton, 'cfm', 'm^3/s'))
speed.setReferenceUnitRatedWaterFlowRate(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s') * hp_ap.cool_capacity_ratios[i])
speed.setReferenceUnitWasteHeatFractionofInputPowerAtRatedConditions(0.0)
clg_coil.addSpeed(speed)
end
if heat_pump.compressor_type == HPXML::HVACCompressorTypeVariableSpeed
plf_fplr_curve = Model.add_curve_quadratic(
model,
name: 'Heat-PLF-fPLR',
coeff: [1.0, 0.0, 0.0],
min_x: 0, max_x: 1, min_y: 0.7, max_y: 1
)
else
# Derived from: https://www.e3s-conferences.org/articles/e3sconf/pdf/2018/19/e3sconf_eko-dok2018_00139.pdf
plf_fplr_curve = Model.add_curve_cubic(
model,
name: 'Heat-PLF-fPLR',
coeff: [0.4603, 1.6416, -1.8588, 0.7605],
min_x: 0, max_x: 1, min_y: 0.7, max_y: 1
)
end
htg_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit.new(model, plf_fplr_curve)
htg_coil.setName(obj_name + ' htg coil')
htg_coil.setNominalSpeedLevel(num_speeds)
htg_coil.setRatedAirFlowRateAtSelectedNominalSpeedLevel(htg_air_flow_rated)
htg_coil.setRatedWaterFlowRateAtSelectedNominalSpeedLevel(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s'))
# TODO: Add net to gross conversion after RESNET PR: https://github.com/NREL/OpenStudio-HPXML/pull/1879
htg_coil.setRatedHeatingCapacityAtSelectedNominalSpeedLevel(UnitConversions.convert(heat_pump.heating_capacity, 'Btu/hr', 'W'))
for i in 0..(num_speeds - 1)
cap_ft_curve = Model.add_curve_biquadratic(
model,
name: "Heat-CAP-fT#{i + 1}",
coeff: hp_ap.heat_cap_ft_spec[i],
min_x: -100, max_x: 100, min_y: -100, max_y: 100
)
cap_faf_curve = Model.add_curve_quadratic(
model,
name: "Heat-CAP-fAF#{i + 1}",
coeff: hp_ap.heat_cap_fflow_spec[i],
min_x: 0, max_x: 2, min_y: 0, max_y: 2
)
cap_fwf_curve = Model.add_curve_quadratic(
model,
name: "Heat-CAP-fWF#{i + 1}",
coeff: hp_ap.heat_cap_fwf_spec[i],
min_x: 0.45, max_x: 2, min_y: 0, max_y: 2
)
eir_ft_curve = Model.add_curve_biquadratic(
model,
name: "Heat-EIR-fT#{i + 1}",
coeff: hp_ap.heat_eir_ft_spec[i],
min_x: -100, max_x: 100, min_y: -100, max_y: 100
)
eir_faf_curve = Model.add_curve_quadratic(
model,
name: "Heat-EIR-fAF#{i + 1}",
coeff: hp_ap.heat_eir_fflow_spec[i],
min_x: 0, max_x: 2, min_y: 0, max_y: 2
)
eir_fwf_curve = Model.add_curve_quadratic(
model,
name: "Heat-EIR-fWF#{i + 1}",
coeff: hp_ap.heat_eir_fwf_spec[i],
min_x: 0.45, max_x: 2, min_y: 0, max_y: 2
)
# Recoverable heat modifier as a function of indoor wet-bulb and water entering temperatures.
waste_heat_ft = Model.add_curve_biquadratic(
model,
name: "WasteHeat-FT#{i + 1}",
coeff: [1, 0, 0, 0, 0, 0]
)
speed = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFitSpeedData.new(model, cap_ft_curve, cap_faf_curve, cap_fwf_curve, eir_ft_curve, eir_faf_curve, eir_fwf_curve, waste_heat_ft)
# TODO: Add net to gross conversion after RESNET PR: https://github.com/NREL/OpenStudio-HPXML/pull/1879
speed.setReferenceUnitGrossRatedHeatingCapacity(UnitConversions.convert(heat_pump.heating_capacity, 'Btu/hr', 'W') * hp_ap.heat_capacity_ratios[i])
speed.setReferenceUnitGrossRatedHeatingCOP(hp_ap.heat_rated_cops[i])
speed.setReferenceUnitRatedAirFlow(UnitConversions.convert(UnitConversions.convert(heat_pump.heating_capacity, 'Btu/hr', 'ton') * hp_ap.heat_capacity_ratios[i] * hp_ap.heat_rated_cfm_per_ton, 'cfm', 'm^3/s'))
speed.setReferenceUnitRatedWaterFlowRate(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s') * hp_ap.heat_capacity_ratios[i])
speed.setReferenceUnitWasteHeatFractionofInputPowerAtRatedConditions(0.0)
htg_coil.addSpeed(speed)
end
end
clg_coil.additionalProperties.setFeature('HPXML_ID', heat_pump.id) # Used by reporting measure
htg_coil.additionalProperties.setFeature('HPXML_ID', heat_pump.id) # Used by reporting measure
# Supplemental Heating Coil
htg_supp_coil = create_heat_pump_supplemental_heating_coil(model, obj_name, heat_pump)
# Site Ground Temperature Undisturbed
xing = OpenStudio::Model::SiteGroundTemperatureUndisturbedXing.new(model)
xing.setSoilSurfaceTemperatureAmplitude1(UnitConversions.convert(weather.data.DeepGroundSurfTempAmp1, 'deltaf', 'deltac'))
xing.setSoilSurfaceTemperatureAmplitude2(UnitConversions.convert(weather.data.DeepGroundSurfTempAmp2, 'deltaf', 'deltac'))
xing.setPhaseShiftofTemperatureAmplitude1(weather.data.DeepGroundPhaseShiftTempAmp1)
xing.setPhaseShiftofTemperatureAmplitude2(weather.data.DeepGroundPhaseShiftTempAmp2)
# Ground Heat Exchanger
ground_heat_exch_vert = OpenStudio::Model::GroundHeatExchangerVertical.new(model, xing)
ground_heat_exch_vert.setName(obj_name + ' exchanger')
ground_heat_exch_vert.setBoreHoleRadius(UnitConversions.convert(geothermal_loop.bore_diameter / 2.0, 'in', 'm'))
ground_heat_exch_vert.setGroundThermalConductivity(UnitConversions.convert(hpxml_bldg.site.ground_conductivity, 'Btu/(hr*ft*R)', 'W/(m*K)'))
ground_heat_exch_vert.setGroundThermalHeatCapacity(UnitConversions.convert(hpxml_bldg.site.ground_conductivity / hpxml_bldg.site.ground_diffusivity, 'Btu/(ft^3*F)', 'J/(m^3*K)'))
ground_heat_exch_vert.setGroundTemperature(UnitConversions.convert(weather.data.DeepGroundAnnualTemp, 'F', 'C'))
ground_heat_exch_vert.setGroutThermalConductivity(UnitConversions.convert(geothermal_loop.grout_conductivity, 'Btu/(hr*ft*R)', 'W/(m*K)'))
ground_heat_exch_vert.setPipeThermalConductivity(UnitConversions.convert(geothermal_loop.pipe_conductivity, 'Btu/(hr*ft*R)', 'W/(m*K)'))
ground_heat_exch_vert.setPipeOutDiameter(UnitConversions.convert(hp_ap.pipe_od, 'in', 'm'))
ground_heat_exch_vert.setUTubeDistance(UnitConversions.convert(geothermal_loop.shank_spacing, 'in', 'm'))
ground_heat_exch_vert.setPipeThickness(UnitConversions.convert((hp_ap.pipe_od - hp_ap.pipe_id) / 2.0, 'in', 'm'))
ground_heat_exch_vert.setMaximumLengthofSimulation(1)
ground_heat_exch_vert.setDesignFlowRate(UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s'))
ground_heat_exch_vert.setNumberofBoreHoles(geothermal_loop.num_bore_holes)
ground_heat_exch_vert.setBoreHoleLength(UnitConversions.convert(geothermal_loop.bore_length, 'ft', 'm'))
ground_heat_exch_vert.setBoreHoleTopDepth(2) # Consistent with G-function library
ground_heat_exch_vert.setGFunctionReferenceRatio(ground_heat_exch_vert.boreHoleRadius.get / ground_heat_exch_vert.boreHoleLength.get) # ensure this ratio is consistent with rb/H so that g values will be taken as-is
ground_heat_exch_vert.removeAllGFunctions
for i in 0..(hp_ap.GSHP_G_Functions[0].size - 1)
ground_heat_exch_vert.addGFunction(hp_ap.GSHP_G_Functions[0][i], hp_ap.GSHP_G_Functions[1][i])
end
xing = ground_heat_exch_vert.undisturbedGroundTemperatureModel.to_SiteGroundTemperatureUndisturbedXing.get
xing.setSoilThermalConductivity(ground_heat_exch_vert.groundThermalConductivity.get)
xing.setSoilSpecificHeat(ground_heat_exch_vert.groundThermalHeatCapacity.get / xing.soilDensity)
xing.setAverageSoilSurfaceTemperature(ground_heat_exch_vert.groundTemperature.get)
# Plant Loop
plant_loop = Model.add_plant_loop(
model,
name: "#{obj_name} condenser loop",
fluid_type: hp_ap.fluid_type,
glycol_concentration: (hp_ap.frac_glycol * 100).to_i,
min_temp: UnitConversions.convert(hp_ap.design_hw, 'F', 'C'),
max_temp: 48.88889,
max_flow_rate: UnitConversions.convert(geothermal_loop.loop_flow, 'gal/min', 'm^3/s')
)
plant_loop.addSupplyBranchForComponent(ground_heat_exch_vert)
plant_loop.addDemandBranchForComponent(htg_coil)
plant_loop.addDemandBranchForComponent(clg_coil)
sizing_plant = plant_loop.sizingPlant
sizing_plant.setLoopType('Condenser')
sizing_plant.setDesignLoopExitTemperature(UnitConversions.convert(hp_ap.design_chw, 'F', 'C'))
sizing_plant.setLoopDesignTemperatureDifference(UnitConversions.convert(hp_ap.design_delta_t, 'deltaF', 'deltaC'))
setpoint_mgr_follow_ground_temp = OpenStudio::Model::SetpointManagerFollowGroundTemperature.new(model)
setpoint_mgr_follow_ground_temp.setName(obj_name + ' condenser loop temp')
setpoint_mgr_follow_ground_temp.setControlVariable('Temperature')
setpoint_mgr_follow_ground_temp.setMaximumSetpointTemperature(48.88889)
setpoint_mgr_follow_ground_temp.setMinimumSetpointTemperature(UnitConversions.convert(hp_ap.design_hw, 'F', 'C'))
setpoint_mgr_follow_ground_temp.setReferenceGroundTemperatureObjectType('Site:GroundTemperature:Deep')
setpoint_mgr_follow_ground_temp.addToNode(plant_loop.supplyOutletNode)
# Pump
pump_w = get_pump_power_watts(heat_pump)
if heat_pump.is_shared_system
pump_w += heat_pump.shared_loop_watts / heat_pump.number_of_units_served.to_f
end
pump_w = [pump_w, 1.0].max # prevent error if zero
pump = Model.add_pump_variable_speed(
model,
name: "#{obj_name} pump",
rated_power: pump_w
)
pump.addToNode(plant_loop.supplyInletNode)
add_fan_pump_disaggregation_ems_program(model, pump, htg_coil, clg_coil, htg_supp_coil, heat_pump)
# Pipes
chiller_bypass_pipe = Model.add_pipe_adiabatic(model)
plant_loop.addSupplyBranchForComponent(chiller_bypass_pipe)
coil_bypass_pipe = Model.add_pipe_adiabatic(model)
plant_loop.addDemandBranchForComponent(coil_bypass_pipe)
supply_outlet_pipe = Model.add_pipe_adiabatic(model)
supply_outlet_pipe.addToNode(plant_loop.supplyOutletNode)
demand_inlet_pipe = Model.add_pipe_adiabatic(model)
demand_inlet_pipe.addToNode(plant_loop.demandInletNode)
demand_outlet_pipe = Model.add_pipe_adiabatic(model)
demand_outlet_pipe.addToNode(plant_loop.demandOutletNode)
# Fan
fan_cfms = []
hp_ap.cool_capacity_ratios.each do |capacity_ratio|
fan_cfms << clg_cfm * capacity_ratio
end
hp_ap.heat_capacity_ratios.each do |capacity_ratio|
fan_cfms << htg_cfm * capacity_ratio
end
fan = create_supply_fan(model, obj_name, heat_pump.fan_watts_per_cfm, fan_cfms, heat_pump)
add_fan_pump_disaggregation_ems_program(model, fan, htg_coil, clg_coil, htg_supp_coil, heat_pump)
# Unitary System
air_loop_unitary = create_air_loop_unitary_system(model, obj_name, fan, htg_coil, clg_coil, htg_supp_coil, htg_cfm, clg_cfm, 40.0)
add_pump_power_ems_program(model, pump, air_loop_unitary, heat_pump)
if (heat_pump.compressor_type == HPXML::HVACCompressorTypeVariableSpeed) && (hpxml_header.ground_to_air_heat_pump_model_type == HPXML::GroundToAirHeatPumpModelTypeExperimental)
add_ghp_pump_mass_flow_rate_ems_program(model, pump, control_zone, htg_coil, clg_coil)
end
# Air Loop
air_loop = create_air_loop(model, obj_name, air_loop_unitary, control_zone, hvac_sequential_load_fracs, [htg_cfm, clg_cfm].max, heat_pump, hvac_unavailable_periods)
# HVAC Installation Quality
apply_installation_quality_ems_program(model, heat_pump, heat_pump, air_loop_unitary, htg_coil, clg_coil, control_zone)
return air_loop
end
# Adds the HPXML water-loop heat pump system to the OpenStudio model.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param heat_pump [HPXML::HeatPump] The HPXML heat pump of interest
# @param hvac_sequential_load_fracs [Hash<Array<Double>>] Map of htg/clg => Array of daily fractions of remaining heating/cooling load to be met by the HVAC system
# @param control_zone [OpenStudio::Model::ThermalZone] Conditioned space thermal zone
# @param hvac_unavailable_periods [Hash] Map of htg/clg => HPXML::UnavailablePeriods for heating/cooling
# @return [OpenStudio::Model::AirLoopHVAC] The newly created air loop hvac object
def self.apply_water_loop_to_air_heat_pump(model, heat_pump, hvac_sequential_load_fracs, control_zone, hvac_unavailable_periods)
if heat_pump.fraction_cool_load_served > 0
# WLHPs connected to chillers or cooling towers should have already been converted to
# central air conditioners
fail 'WLHP model should only be called for central boilers.'
end
obj_name = Constants::ObjectTypeWaterLoopHeatPump
hp_ap = heat_pump.additional_properties
htg_cfm = hp_ap.heating_actual_airflow_cfm
# Cooling Coil (none)
clg_coil = nil
# Heating Coil (model w/ constant efficiency)
constant_biquadratic = Model.add_curve_biquadratic(
model,
name: 'ConstantBiquadratic',
coeff: [1, 0, 0, 0, 0, 0]
)
constant_quadratic = Model.add_curve_quadratic(
model,
name: 'ConstantQuadratic',
coeff: [1, 0, 0]
)
htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new(model, model.alwaysOnDiscreteSchedule, constant_biquadratic, constant_quadratic, constant_biquadratic, constant_quadratic, constant_quadratic)
htg_coil.setName(obj_name + ' htg coil')
htg_coil.setRatedCOP(heat_pump.heating_efficiency_cop)
htg_coil.setDefrostTimePeriodFraction(0.00001) # Disable defrost; avoid E+ warning w/ value of zero
htg_coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(-40)
htg_coil.setRatedTotalHeatingCapacity(UnitConversions.convert(heat_pump.heating_capacity, 'Btu/hr', 'W'))
htg_coil.setRatedAirFlowRate(htg_cfm)
htg_coil.additionalProperties.setFeature('HPXML_ID', heat_pump.id) # Used by reporting measure
# Supplemental Heating Coil
htg_supp_coil = create_heat_pump_supplemental_heating_coil(model, obj_name, heat_pump)
# Fan
fan_power_installed = 0.0 # Use provided net COP
fan = create_supply_fan(model, obj_name, fan_power_installed, [htg_cfm], heat_pump)
add_fan_pump_disaggregation_ems_program(model, fan, htg_coil, clg_coil, htg_supp_coil, heat_pump)
# Unitary System
air_loop_unitary = create_air_loop_unitary_system(model, obj_name, fan, htg_coil, clg_coil, htg_supp_coil, htg_cfm, nil)
# Air Loop
air_loop = create_air_loop(model, obj_name, air_loop_unitary, control_zone, hvac_sequential_load_fracs, htg_cfm, heat_pump, hvac_unavailable_periods)
return air_loop
end
# Get the outdoor unit (compressor) power (W) using regression based on (output) capacity.
# The equation is a derived regression for the minimum circuit amp (MCA) of direct expansion compressor from 201 product datapoints (including central ACs, room ACs, and ASHPs) collected between 2023-2024.
#
# @param capacity [Double] Direct expansion coil rated (output) capacity [kBtu/hr].
# @param voltage [String] '120' or '240'
# @return [Double] Direct expansion coil rated (input) capacity (W)
def self.get_dx_coil_power_watts_from_capacity(capacity, voltage)
required_amperage = 0.631 * capacity + 1.615
power = required_amperage * Float(voltage)
return power
end
# Get the indoor unit (air handler) power (W).
#
# @param fan_watts_per_cfm [Double] Blower fan watts per cfm [W/cfm]
# @param airflow_cfm [Double] HVAC system airflow rate [cfm]
# @return [Double] Blower fan power [W]
def self.get_blower_fan_power_watts(fan_watts_per_cfm, airflow_cfm)
return 0.0 if fan_watts_per_cfm.nil? || airflow_cfm.nil?