-
Notifications
You must be signed in to change notification settings - Fork 12
/
hpxml_defaults.rb
3840 lines (3563 loc) · 184 KB
/
hpxml_defaults.rb
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
# Note: Each HPXML object (e.g., HPXML::Wall) has an additional_properties
# child object where custom information can be attached to the object without
# being written to the HPXML file. This will allow the custom information to
# be used by subsequent calculations/logic.
class HPXMLDefaults
# TODO
#
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
# @param hpxml [HPXML] HPXML object
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param eri_version [String] Version of the ANSI/RESNET/ICC 301 Standard to use for equations/assumptions
# @param weather [WeatherProcess] Weather object
# @param epw_file [OpenStudio::EpwFile] TODO
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @param convert_shared_systems [TODO] TODO
# @param design_load_details_output_file_path [TODO] TODO
# @param output_format [TODO] TODO
# @return [TODO] TODO
def self.apply(runner, hpxml, hpxml_bldg, eri_version, weather, epw_file: nil, schedules_file: nil, convert_shared_systems: true,
design_load_details_output_file_path: nil, output_format: 'csv')
cfa = hpxml_bldg.building_construction.conditioned_floor_area
nbeds = hpxml_bldg.building_construction.number_of_bedrooms
ncfl = hpxml_bldg.building_construction.number_of_conditioned_floors
ncfl_ag = hpxml_bldg.building_construction.number_of_conditioned_floors_above_grade
has_uncond_bsmnt = hpxml_bldg.has_location(HPXML::LocationBasementUnconditioned)
has_cond_bsmnt = hpxml_bldg.has_location(HPXML::LocationBasementConditioned)
# Check for presence of fuels once
has_fuel = hpxml_bldg.has_fuels(Constants.FossilFuels, hpxml.to_doc)
add_zones_spaces_if_needed(hpxml, hpxml_bldg, cfa)
apply_header(hpxml.header, epw_file, hpxml_bldg)
apply_building(hpxml_bldg, epw_file)
apply_emissions_scenarios(hpxml.header, has_fuel)
apply_utility_bill_scenarios(runner, hpxml.header, hpxml_bldg, has_fuel)
apply_building_header(hpxml.header, hpxml_bldg, weather)
apply_building_header_sizing(runner, hpxml_bldg, weather, nbeds)
apply_site(hpxml_bldg)
apply_neighbor_buildings(hpxml_bldg)
apply_building_occupancy(hpxml_bldg, schedules_file)
apply_building_construction(hpxml_bldg, cfa, nbeds)
apply_zone_spaces(hpxml_bldg)
apply_climate_and_risk_zones(hpxml_bldg, epw_file)
apply_attics(hpxml_bldg)
apply_foundations(hpxml_bldg)
apply_infiltration(hpxml_bldg)
apply_roofs(hpxml_bldg)
apply_rim_joists(hpxml_bldg)
apply_walls(hpxml_bldg)
apply_foundation_walls(hpxml_bldg)
apply_floors(runner, hpxml_bldg)
apply_slabs(hpxml_bldg)
apply_windows(hpxml_bldg, eri_version)
apply_skylights(hpxml_bldg)
apply_doors(hpxml_bldg)
apply_partition_wall_mass(hpxml_bldg)
apply_furniture_mass(hpxml_bldg)
apply_hvac(runner, hpxml, hpxml_bldg, weather, convert_shared_systems)
apply_hvac_control(hpxml_bldg, schedules_file, eri_version)
apply_hvac_distribution(hpxml_bldg, ncfl, ncfl_ag)
apply_hvac_location(hpxml_bldg)
apply_ventilation_fans(hpxml_bldg, weather, cfa, nbeds, eri_version)
apply_water_heaters(hpxml_bldg, nbeds, eri_version, schedules_file)
apply_flue_or_chimney(hpxml_bldg)
apply_hot_water_distribution(hpxml_bldg, cfa, ncfl, has_uncond_bsmnt, has_cond_bsmnt, schedules_file)
apply_water_fixtures(hpxml_bldg, schedules_file)
apply_solar_thermal_systems(hpxml_bldg)
apply_appliances(hpxml_bldg, nbeds, eri_version, schedules_file)
apply_lighting(hpxml_bldg, schedules_file)
apply_ceiling_fans(hpxml_bldg, nbeds, weather, schedules_file)
apply_pools_and_permanent_spas(hpxml_bldg, cfa, schedules_file)
apply_plug_loads(hpxml_bldg, cfa, schedules_file)
apply_fuel_loads(hpxml_bldg, cfa, schedules_file)
apply_pv_systems(hpxml_bldg)
apply_generators(hpxml_bldg)
apply_batteries(hpxml_bldg)
# Do HVAC sizing after all other defaults have been applied
apply_hvac_sizing(runner, hpxml_bldg, weather, output_format, design_load_details_output_file_path)
# Default detailed performance has to be after sizing to have autosized capacity information
apply_detailed_performance_data_for_var_speed_systems(hpxml_bldg)
cleanup_zones_spaces(hpxml_bldg)
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.get_default_azimuths(hpxml_bldg)
# TODO
#
# @param azimuth [TODO] TODO
# @return [TODO] TODO
def self.sanitize_azimuth(azimuth)
# Ensure 0 <= orientation < 360
while azimuth < 0
azimuth += 360
end
while azimuth >= 360
azimuth -= 360
end
return azimuth
end
# Returns a list of four azimuths (facing each direction). Determined based
# on the primary azimuth, as defined by the azimuth with the largest surface
# area, plus azimuths that are offset by 90/180/270 degrees. Used for
# surfaces that may not have an azimuth defined (e.g., walls).
azimuth_areas = {}
(hpxml_bldg.surfaces + hpxml_bldg.subsurfaces).each do |surface|
next unless surface.respond_to?(:azimuth)
az = surface.azimuth
next if az.nil?
azimuth_areas[az] = 0 if azimuth_areas[az].nil?
azimuth_areas[az] += surface.area
end
if azimuth_areas.empty?
primary_azimuth = 0
else
primary_azimuth = azimuth_areas.max_by { |_k, v| v }[0]
end
return [primary_azimuth,
sanitize_azimuth(primary_azimuth + 90),
sanitize_azimuth(primary_azimuth + 180),
sanitize_azimuth(primary_azimuth + 270)].sort
end
# FIXME: The following class methods are meant to be private.
# TODO
#
# @param hpxml [HPXML] HPXML object
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param cfa [Double] Conditioned floor area in the dwelling unit (ft^2)
# @return [TODO] TODO
def self.add_zones_spaces_if_needed(hpxml, hpxml_bldg, cfa)
# Automatically add conditioned zone/space if not provided to simplify the HVAC sizing code
bldg_idx = hpxml.buildings.index(hpxml_bldg)
if hpxml_bldg.conditioned_zones.empty?
hpxml_bldg.zones.add(id: "#{Constants.AutomaticallyAdded}Zone#{bldg_idx + 1}",
zone_type: HPXML::ZoneTypeConditioned)
hpxml_bldg.hvac_systems.each do |hvac_system|
hvac_system.attached_to_zone_idref = hpxml_bldg.zones[-1].id
end
hpxml_bldg.zones[-1].spaces.add(id: "#{Constants.AutomaticallyAdded}Space#{bldg_idx + 1}",
floor_area: cfa)
hpxml_bldg.surfaces.each do |surface|
next unless HPXML::conditioned_locations_this_unit.include? surface.interior_adjacent_to
next if surface.exterior_adjacent_to == HPXML::LocationOtherHousingUnit
surface.attached_to_space_idref = hpxml_bldg.zones[-1].spaces[-1].id
end
end
end
# TODO
#
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param epw_file [OpenStudio::EpwFile] TODO
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_header(hpxml_header, epw_file, hpxml_bldg)
if hpxml_header.timestep.nil?
hpxml_header.timestep = 60
hpxml_header.timestep_isdefaulted = true
end
if hpxml_header.sim_begin_month.nil?
hpxml_header.sim_begin_month = 1
hpxml_header.sim_begin_month_isdefaulted = true
end
if hpxml_header.sim_begin_day.nil?
hpxml_header.sim_begin_day = 1
hpxml_header.sim_begin_day_isdefaulted = true
end
if hpxml_header.sim_end_month.nil?
hpxml_header.sim_end_month = 12
hpxml_header.sim_end_month_isdefaulted = true
end
if hpxml_header.sim_end_day.nil?
hpxml_header.sim_end_day = 31
hpxml_header.sim_end_day_isdefaulted = true
end
sim_calendar_year = Location.get_sim_calendar_year(hpxml_header.sim_calendar_year, epw_file)
if not hpxml_header.sim_calendar_year.nil?
if hpxml_header.sim_calendar_year != sim_calendar_year
hpxml_header.sim_calendar_year = sim_calendar_year
hpxml_header.sim_calendar_year_isdefaulted = true
end
else
hpxml_header.sim_calendar_year = sim_calendar_year
hpxml_header.sim_calendar_year_isdefaulted = true
end
if hpxml_header.temperature_capacitance_multiplier.nil?
hpxml_header.temperature_capacitance_multiplier = 7.0
hpxml_header.temperature_capacitance_multiplier_isdefaulted = true
end
if hpxml_header.defrost_model_type.nil? && (hpxml_bldg.heat_pumps.any? { |hp| [HPXML::HVACTypeHeatPumpAirToAir, HPXML::HVACTypeHeatPumpMiniSplit, HPXML::HVACTypeHeatPumpRoom, HPXML::HVACTypeHeatPumpPTHP].include? hp.heat_pump_type })
hpxml_header.defrost_model_type = HPXML::AdvancedResearchDefrostModelTypeStandard
hpxml_header.defrost_model_type_isdefaulted = true
end
hpxml_header.unavailable_periods.each do |unavailable_period|
if unavailable_period.begin_hour.nil?
unavailable_period.begin_hour = 0
unavailable_period.begin_hour_isdefaulted = true
end
if unavailable_period.end_hour.nil?
unavailable_period.end_hour = 24
unavailable_period.end_hour_isdefaulted = true
end
if unavailable_period.natvent_availability.nil?
unavailable_period.natvent_availability = HPXML::ScheduleRegular
unavailable_period.natvent_availability_isdefaulted = true
end
end
end
# TODO
#
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param weather [WeatherProcess] Weather object
# @param nbeds [Integer] Number of bedrooms in the dwelling unit
# @return [TODO] TODO
def self.apply_building_header_sizing(runner, hpxml_bldg, weather, nbeds)
if hpxml_bldg.header.manualj_heating_design_temp.nil?
hpxml_bldg.header.manualj_heating_design_temp = weather.design.HeatingDrybulb.round(2)
hpxml_bldg.header.manualj_heating_design_temp_isdefaulted = true
end
if hpxml_bldg.header.manualj_cooling_design_temp.nil?
hpxml_bldg.header.manualj_cooling_design_temp = weather.design.CoolingDrybulb.round(2)
hpxml_bldg.header.manualj_cooling_design_temp_isdefaulted = true
end
if hpxml_bldg.header.manualj_daily_temp_range.nil?
hpxml_bldg.header.manualj_daily_temp_range = HVACSizing.determine_daily_temperature_range_class(weather.design.DailyTemperatureRange)
hpxml_bldg.header.manualj_daily_temp_range_isdefaulted = true
end
if hpxml_bldg.header.manualj_heating_setpoint.nil?
hpxml_bldg.header.manualj_heating_setpoint = 70.0 # deg-F, per Manual J
hpxml_bldg.header.manualj_heating_setpoint_isdefaulted = true
end
if hpxml_bldg.header.manualj_cooling_setpoint.nil?
hpxml_bldg.header.manualj_cooling_setpoint = 75.0 # deg-F, per Manual J
hpxml_bldg.header.manualj_cooling_setpoint_isdefaulted = true
end
if hpxml_bldg.header.manualj_humidity_setpoint.nil?
hpxml_bldg.header.manualj_humidity_setpoint = 0.5 # 50%
p_atm = UnitConversions.convert(Psychrometrics.Pstd_fZ(hpxml_bldg.elevation), 'psi', 'atm')
hr_indoor_cooling = HVACSizing.calculate_indoor_hr(hpxml_bldg.header.manualj_humidity_setpoint, hpxml_bldg.header.manualj_cooling_setpoint, p_atm)
if HVACSizing.calculate_design_grains(weather.design.CoolingHumidityRatio, hr_indoor_cooling) < 0
# Dry summer climate per Manual J 18-1 Design Grains
hpxml_bldg.header.manualj_humidity_setpoint = 0.45 # 45%
end
hpxml_bldg.header.manualj_humidity_setpoint_isdefaulted = true
end
if hpxml_bldg.header.manualj_humidity_difference.nil?
p_atm = UnitConversions.convert(Psychrometrics.Pstd_fZ(hpxml_bldg.elevation), 'psi', 'atm')
hr_indoor_cooling = HVACSizing.calculate_indoor_hr(hpxml_bldg.header.manualj_humidity_setpoint, hpxml_bldg.header.manualj_cooling_setpoint, p_atm)
hpxml_bldg.header.manualj_humidity_difference = HVACSizing.calculate_design_grains(weather.design.CoolingHumidityRatio, hr_indoor_cooling).round(1)
hpxml_bldg.header.manualj_humidity_difference_isdefaulted = true
end
sum_space_manualj_internal_loads_sensible = Float(hpxml_bldg.conditioned_spaces.map { |space| space.manualj_internal_loads_sensible.to_f }.sum.round)
if hpxml_bldg.header.manualj_internal_loads_sensible.nil?
if sum_space_manualj_internal_loads_sensible > 0
hpxml_bldg.header.manualj_internal_loads_sensible = sum_space_manualj_internal_loads_sensible
elsif hpxml_bldg.refrigerators.size + hpxml_bldg.freezers.size <= 1
hpxml_bldg.header.manualj_internal_loads_sensible = 2400.0 # Btuh, per Manual J
else
hpxml_bldg.header.manualj_internal_loads_sensible = 3600.0 # Btuh, per Manual J
end
hpxml_bldg.header.manualj_internal_loads_sensible_isdefaulted = true
end
if sum_space_manualj_internal_loads_sensible == 0
# Area weighted assignment
total_floor_area = hpxml_bldg.conditioned_spaces.map { |space| space.floor_area }.sum
hpxml_bldg.conditioned_spaces.each do |space|
space.manualj_internal_loads_sensible = (hpxml_bldg.header.manualj_internal_loads_sensible * space.floor_area / total_floor_area).round
space.manualj_internal_loads_sensible_isdefaulted = true
end
elsif (hpxml_bldg.header.manualj_internal_loads_sensible - sum_space_manualj_internal_loads_sensible).abs > 50 # Tolerance for rounding
runner.registerWarning("ManualJInputs/InternalLoadsSensible (#{hpxml_bldg.header.manualj_internal_loads_sensible}) does not match sum of conditioned spaces (#{sum_space_manualj_internal_loads_sensible}).")
end
sum_space_manualj_internal_loads_latent = Float(hpxml_bldg.conditioned_spaces.map { |space| space.manualj_internal_loads_latent.to_f }.sum.round)
if hpxml_bldg.header.manualj_internal_loads_latent.nil?
hpxml_bldg.header.manualj_internal_loads_latent = sum_space_manualj_internal_loads_latent # Btuh
hpxml_bldg.header.manualj_internal_loads_latent_isdefaulted = true
end
if sum_space_manualj_internal_loads_latent == 0
# Area weighted assignment
total_floor_area = hpxml_bldg.conditioned_spaces.map { |space| space.floor_area }.sum
hpxml_bldg.conditioned_spaces.each do |space|
space.manualj_internal_loads_latent = (hpxml_bldg.header.manualj_internal_loads_latent * space.floor_area / total_floor_area).round
space.manualj_internal_loads_latent_isdefaulted = true
end
elsif (hpxml_bldg.header.manualj_internal_loads_latent - sum_space_manualj_internal_loads_latent).abs > 50 # Tolerance for rounding
runner.registerWarning("ManualJInputs/InternalLoadsLatent (#{hpxml_bldg.header.manualj_internal_loads_latent}) does not match sum of conditioned spaces (#{sum_space_manualj_internal_loads_latent}).")
end
sum_space_manualj_num_occupants = hpxml_bldg.conditioned_spaces.map { |space| space.manualj_num_occupants.to_f }.sum.round
if hpxml_bldg.header.manualj_num_occupants.nil?
if sum_space_manualj_num_occupants > 0
hpxml_bldg.header.manualj_num_occupants = sum_space_manualj_num_occupants
else
hpxml_bldg.header.manualj_num_occupants = nbeds + 1 # Per Manual J
end
hpxml_bldg.header.manualj_num_occupants_isdefaulted = true
end
if sum_space_manualj_num_occupants == 0
# Area weighted assignment
total_floor_area = hpxml_bldg.conditioned_spaces.map { |space| space.floor_area }.sum
hpxml_bldg.conditioned_spaces.each do |space|
space.manualj_num_occupants = (hpxml_bldg.header.manualj_num_occupants * space.floor_area / total_floor_area).round(2)
space.manualj_num_occupants_isdefaulted = true
end
elsif (hpxml_bldg.header.manualj_num_occupants - sum_space_manualj_num_occupants).abs >= 1 # Tolerance for rounding
runner.registerWarning("ManualJInputs/NumberofOccupants (#{hpxml_bldg.header.manualj_num_occupants}) does not match sum of conditioned spaces (#{sum_space_manualj_num_occupants}).")
end
end
# TODO
#
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param weather [WeatherProcess] Weather object
# @return [TODO] TODO
def self.apply_building_header(hpxml_header, hpxml_bldg, weather)
if hpxml_bldg.header.natvent_days_per_week.nil?
hpxml_bldg.header.natvent_days_per_week = 3
hpxml_bldg.header.natvent_days_per_week_isdefaulted = true
end
if hpxml_bldg.header.heat_pump_sizing_methodology.nil? && (hpxml_bldg.heat_pumps.size > 0)
hpxml_bldg.header.heat_pump_sizing_methodology = HPXML::HeatPumpSizingHERS
hpxml_bldg.header.heat_pump_sizing_methodology_isdefaulted = true
end
if hpxml_bldg.header.heat_pump_backup_sizing_methodology.nil? && (hpxml_bldg.heat_pumps.size > 0)
hpxml_bldg.header.heat_pump_backup_sizing_methodology = HPXML::HeatPumpBackupSizingEmergency
hpxml_bldg.header.heat_pump_backup_sizing_methodology_isdefaulted = true
end
if hpxml_bldg.header.allow_increased_fixed_capacities.nil?
hpxml_bldg.header.allow_increased_fixed_capacities = false
hpxml_bldg.header.allow_increased_fixed_capacities_isdefaulted = true
end
if hpxml_bldg.header.shading_summer_begin_month.nil? || hpxml_bldg.header.shading_summer_begin_day.nil? || hpxml_bldg.header.shading_summer_end_month.nil? || hpxml_bldg.header.shading_summer_end_day.nil?
if not weather.nil?
# Default based on Building America seasons
_, default_cooling_months = HVAC.get_default_heating_and_cooling_seasons(weather, hpxml_bldg.latitude)
begin_month, begin_day, end_month, end_day = Schedule.get_begin_and_end_dates_from_monthly_array(default_cooling_months, hpxml_header.sim_calendar_year)
if not begin_month.nil? # Check if no summer
hpxml_bldg.header.shading_summer_begin_month = begin_month
hpxml_bldg.header.shading_summer_begin_day = begin_day
hpxml_bldg.header.shading_summer_end_month = end_month
hpxml_bldg.header.shading_summer_end_day = end_day
hpxml_bldg.header.shading_summer_begin_month_isdefaulted = true
hpxml_bldg.header.shading_summer_begin_day_isdefaulted = true
hpxml_bldg.header.shading_summer_end_month_isdefaulted = true
hpxml_bldg.header.shading_summer_end_day_isdefaulted = true
end
end
end
end
# TODO
#
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param has_fuel [TODO] TODO
# @return [TODO] TODO
def self.apply_emissions_scenarios(hpxml_header, has_fuel)
hpxml_header.emissions_scenarios.each do |scenario|
# Electricity
if not scenario.elec_schedule_filepath.nil?
if scenario.elec_schedule_number_of_header_rows.nil?
scenario.elec_schedule_number_of_header_rows = 0
scenario.elec_schedule_number_of_header_rows_isdefaulted = true
end
if scenario.elec_schedule_column_number.nil?
scenario.elec_schedule_column_number = 1
scenario.elec_schedule_column_number_isdefaulted = true
end
end
# Fossil fuels
default_units = HPXML::EmissionsScenario::UnitsLbPerMBtu
if scenario.emissions_type.downcase == 'co2e'
natural_gas, propane, fuel_oil, coal, wood, wood_pellets = 147.3, 177.8, 195.9, nil, nil, nil
elsif scenario.emissions_type.downcase == 'nox'
natural_gas, propane, fuel_oil, coal, wood, wood_pellets = 0.0922, 0.1421, 0.1300, nil, nil, nil
elsif scenario.emissions_type.downcase == 'so2'
natural_gas, propane, fuel_oil, coal, wood, wood_pellets = 0.0006, 0.0002, 0.0015, nil, nil, nil
else
natural_gas, propane, fuel_oil, coal, wood, wood_pellets = nil, nil, nil, nil, nil, nil
end
if has_fuel[HPXML::FuelTypeNaturalGas]
if (scenario.natural_gas_units.nil? || scenario.natural_gas_value.nil?) && (not natural_gas.nil?)
scenario.natural_gas_units = default_units
scenario.natural_gas_units_isdefaulted = true
scenario.natural_gas_value = natural_gas
scenario.natural_gas_value_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypePropane]
if (scenario.propane_units.nil? || scenario.propane_value.nil?) && (not propane.nil?)
scenario.propane_units = default_units
scenario.propane_units_isdefaulted = true
scenario.propane_value = propane
scenario.propane_value_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeOil]
if (scenario.fuel_oil_units.nil? || scenario.fuel_oil_value.nil?) && (not fuel_oil.nil?)
scenario.fuel_oil_units = default_units
scenario.fuel_oil_units_isdefaulted = true
scenario.fuel_oil_value = fuel_oil
scenario.fuel_oil_value_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeCoal]
if (scenario.coal_units.nil? || scenario.coal_value.nil?) && (not coal.nil?)
scenario.coal_units = default_units
scenario.coal_units_isdefaulted = true
scenario.coal_value = coal
scenario.coal_value_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeWoodCord]
if (scenario.wood_units.nil? || scenario.wood_value.nil?) && (not wood.nil?)
scenario.wood_units = default_units
scenario.wood_units_isdefaulted = true
scenario.wood_value = wood
scenario.wood_value_isdefaulted = true
end
end
next unless has_fuel[HPXML::FuelTypeWoodPellets]
next unless (scenario.wood_pellets_units.nil? || scenario.wood_pellets_value.nil?) && (not wood_pellets.nil?)
scenario.wood_pellets_units = default_units
scenario.wood_pellets_units_isdefaulted = true
scenario.wood_pellets_value = wood_pellets
scenario.wood_pellets_value_isdefaulted = true
end
end
# TODO
#
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param has_fuel [TODO] TODO
# @return [TODO] TODO
def self.apply_utility_bill_scenarios(runner, hpxml_header, hpxml_bldg, has_fuel)
hpxml_header.utility_bill_scenarios.each do |scenario|
if scenario.elec_tariff_filepath.nil?
if scenario.elec_fixed_charge.nil?
scenario.elec_fixed_charge = 12.0 # https://www.nrdc.org/experts/samantha-williams/there-war-attrition-electricity-fixed-charges says $11.19/month in 2018
scenario.elec_fixed_charge_isdefaulted = true
end
if scenario.elec_marginal_rate.nil?
scenario.elec_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypeElectricity, scenario.elec_fixed_charge)
scenario.elec_marginal_rate_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeNaturalGas]
if scenario.natural_gas_fixed_charge.nil?
scenario.natural_gas_fixed_charge = 12.0 # https://www.aga.org/sites/default/files/aga_energy_analysis_-_natural_gas_utility_rate_structure.pdf says $11.25/month in 2015
scenario.natural_gas_fixed_charge_isdefaulted = true
end
if scenario.natural_gas_marginal_rate.nil?
scenario.natural_gas_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypeNaturalGas, scenario.natural_gas_fixed_charge)
scenario.natural_gas_marginal_rate_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypePropane]
if scenario.propane_fixed_charge.nil?
scenario.propane_fixed_charge = 0.0
scenario.propane_fixed_charge_isdefaulted = true
end
if scenario.propane_marginal_rate.nil?
scenario.propane_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypePropane, nil)
scenario.propane_marginal_rate_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeOil]
if scenario.fuel_oil_fixed_charge.nil?
scenario.fuel_oil_fixed_charge = 0.0
scenario.fuel_oil_fixed_charge_isdefaulted = true
end
if scenario.fuel_oil_marginal_rate.nil?
scenario.fuel_oil_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypeOil, nil)
scenario.fuel_oil_marginal_rate_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeCoal]
if scenario.coal_fixed_charge.nil?
scenario.coal_fixed_charge = 0.0
scenario.coal_fixed_charge_isdefaulted = true
end
if scenario.coal_marginal_rate.nil?
scenario.coal_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypeCoal, nil)
scenario.coal_marginal_rate_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeWoodCord]
if scenario.wood_fixed_charge.nil?
scenario.wood_fixed_charge = 0.0
scenario.wood_fixed_charge_isdefaulted = true
end
if scenario.wood_marginal_rate.nil?
scenario.wood_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypeWoodCord, nil)
scenario.wood_marginal_rate_isdefaulted = true
end
end
if has_fuel[HPXML::FuelTypeWoodPellets]
if scenario.wood_pellets_fixed_charge.nil?
scenario.wood_pellets_fixed_charge = 0.0
scenario.wood_pellets_fixed_charge_isdefaulted = true
end
if scenario.wood_pellets_marginal_rate.nil?
scenario.wood_pellets_marginal_rate, _ = UtilityBills.get_rates_from_eia_data(runner, hpxml_bldg.state_code, HPXML::FuelTypeWoodPellets, nil)
scenario.wood_pellets_marginal_rate_isdefaulted = true
end
end
next unless hpxml_bldg.pv_systems.size > 0
if scenario.pv_compensation_type.nil?
scenario.pv_compensation_type = HPXML::PVCompensationTypeNetMetering
scenario.pv_compensation_type_isdefaulted = true
end
if scenario.pv_compensation_type == HPXML::PVCompensationTypeNetMetering
if scenario.pv_net_metering_annual_excess_sellback_rate_type.nil?
scenario.pv_net_metering_annual_excess_sellback_rate_type = HPXML::PVAnnualExcessSellbackRateTypeUserSpecified
scenario.pv_net_metering_annual_excess_sellback_rate_type_isdefaulted = true
end
if scenario.pv_net_metering_annual_excess_sellback_rate_type == HPXML::PVAnnualExcessSellbackRateTypeUserSpecified
if scenario.pv_net_metering_annual_excess_sellback_rate.nil?
scenario.pv_net_metering_annual_excess_sellback_rate = 0.03
scenario.pv_net_metering_annual_excess_sellback_rate_isdefaulted = true
end
end
elsif scenario.pv_compensation_type == HPXML::PVCompensationTypeFeedInTariff
if scenario.pv_feed_in_tariff_rate.nil?
scenario.pv_feed_in_tariff_rate = 0.12
scenario.pv_feed_in_tariff_rate_isdefaulted = true
end
end
if scenario.pv_monthly_grid_connection_fee_dollars_per_kw.nil? && scenario.pv_monthly_grid_connection_fee_dollars.nil?
scenario.pv_monthly_grid_connection_fee_dollars = 0.0
scenario.pv_monthly_grid_connection_fee_dollars_isdefaulted = true
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param epw_file [OpenStudio::EpwFile] TODO
# @return [TODO] TODO
def self.apply_building(hpxml_bldg, epw_file)
if hpxml_bldg.site.soil_type.nil? && hpxml_bldg.site.ground_conductivity.nil? && hpxml_bldg.site.ground_diffusivity.nil?
hpxml_bldg.site.soil_type = HPXML::SiteSoilTypeUnknown
hpxml_bldg.site.soil_type_isdefaulted = true
end
if hpxml_bldg.site.moisture_type.nil? && hpxml_bldg.site.ground_conductivity.nil? && hpxml_bldg.site.ground_diffusivity.nil?
hpxml_bldg.site.moisture_type = HPXML::SiteSoilMoistureTypeMixed
hpxml_bldg.site.moisture_type_isdefaulted = true
end
# Conductivity/diffusivity values come from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4813881 (with the exception of "unknown")
if hpxml_bldg.site.ground_conductivity.nil? && hpxml_bldg.site.ground_diffusivity.nil?
if hpxml_bldg.site.soil_type == HPXML::SiteSoilTypeSand
if hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeDry
hpxml_bldg.site.ground_conductivity = 0.2311 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0097 # ft^2/hr
elsif hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeWet
hpxml_bldg.site.ground_conductivity = 1.3865 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0322 # ft^2/hr
elsif hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeMixed
hpxml_bldg.site.ground_conductivity = ((0.2311 + 1.3865) / 2.0).round(4) # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = ((0.0097 + 0.0322) / 2.0).round(4) # ft^2/hr
end
hpxml_bldg.site.ground_conductivity_isdefaulted = true
hpxml_bldg.site.ground_diffusivity_isdefaulted = true
elsif hpxml_bldg.site.soil_type == HPXML::SiteSoilTypeSilt || hpxml_bldg.site.soil_type == HPXML::SiteSoilTypeClay
if hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeDry
hpxml_bldg.site.ground_conductivity = 0.2889 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0120 # ft^2/hr
elsif hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeWet
hpxml_bldg.site.ground_conductivity = 0.9821 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0194 # ft^2/hr
elsif hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeMixed
hpxml_bldg.site.ground_conductivity = ((0.2889 + 0.9821) / 2.0).round(4) # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = ((0.0120 + 0.0194) / 2.0).round(4) # ft^2/hr
end
hpxml_bldg.site.ground_conductivity_isdefaulted = true
hpxml_bldg.site.ground_diffusivity_isdefaulted = true
elsif hpxml_bldg.site.soil_type == HPXML::SiteSoilTypeLoam
hpxml_bldg.site.ground_conductivity = 1.2132 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0353 # ft^2/hr
hpxml_bldg.site.ground_conductivity_isdefaulted = true
hpxml_bldg.site.ground_diffusivity_isdefaulted = true
elsif hpxml_bldg.site.soil_type == HPXML::SiteSoilTypeGravel
if hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeDry
hpxml_bldg.site.ground_conductivity = 0.2311 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0097 # ft^2/hr
elsif hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeWet
hpxml_bldg.site.ground_conductivity = 1.0399 # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = 0.0291 # ft^2/hr
elsif hpxml_bldg.site.moisture_type == HPXML::SiteSoilMoistureTypeMixed
hpxml_bldg.site.ground_conductivity = ((0.2311 + 1.0399) / 2.0).round(4) # Btu/hr-ft-F
hpxml_bldg.site.ground_diffusivity = ((0.0097 + 0.0291) / 2.0).round(4) # ft^2/hr
end
hpxml_bldg.site.ground_conductivity_isdefaulted = true
hpxml_bldg.site.ground_diffusivity_isdefaulted = true
elsif hpxml_bldg.site.soil_type == HPXML::SiteSoilTypeUnknown
hpxml_bldg.site.ground_conductivity = 1.0
hpxml_bldg.site.ground_diffusivity = 0.0208
hpxml_bldg.site.ground_conductivity_isdefaulted = true
hpxml_bldg.site.ground_diffusivity_isdefaulted = true
end
end
if hpxml_bldg.site.ground_conductivity.nil? && !hpxml_bldg.site.ground_diffusivity.nil?
# Divide diffusivity by 0.0208 to maintain 1/0.0208 relationship
hpxml_bldg.site.ground_conductivity = hpxml_bldg.site.ground_diffusivity / 0.0208 # Btu/hr-ft-F
hpxml_bldg.site.ground_conductivity_isdefaulted = true
elsif !hpxml_bldg.site.ground_conductivity.nil? && hpxml_bldg.site.ground_diffusivity.nil?
# Multiply conductivity by 0.0208 to maintain 1/0.0208 relationship
hpxml_bldg.site.ground_diffusivity = hpxml_bldg.site.ground_conductivity * 0.0208 # ft^2/hr
hpxml_bldg.site.ground_diffusivity_isdefaulted = true
end
if hpxml_bldg.dst_enabled.nil?
hpxml_bldg.dst_enabled = true # Assume DST since it occurs in most US locations
hpxml_bldg.dst_enabled_isdefaulted = true
end
if not epw_file.nil?
if hpxml_bldg.state_code.nil?
hpxml_bldg.state_code = get_default_state_code(hpxml_bldg.state_code, epw_file)
hpxml_bldg.state_code_isdefaulted = true
end
if hpxml_bldg.city.nil?
hpxml_bldg.city = epw_file.city
hpxml_bldg.city_isdefaulted = true
end
if hpxml_bldg.time_zone_utc_offset.nil?
hpxml_bldg.time_zone_utc_offset = get_default_time_zone(hpxml_bldg.time_zone_utc_offset, epw_file)
hpxml_bldg.time_zone_utc_offset_isdefaulted = true
end
if hpxml_bldg.dst_enabled
if hpxml_bldg.dst_begin_month.nil? || hpxml_bldg.dst_begin_day.nil? || hpxml_bldg.dst_end_month.nil? || hpxml_bldg.dst_end_day.nil?
if epw_file.daylightSavingStartDate.is_initialized && epw_file.daylightSavingEndDate.is_initialized
# Use weather file DST dates if available
dst_start_date = epw_file.daylightSavingStartDate.get
dst_end_date = epw_file.daylightSavingEndDate.get
hpxml_bldg.dst_begin_month = dst_start_date.monthOfYear.value
hpxml_bldg.dst_begin_day = dst_start_date.dayOfMonth
hpxml_bldg.dst_end_month = dst_end_date.monthOfYear.value
hpxml_bldg.dst_end_day = dst_end_date.dayOfMonth
else
# Roughly average US dates according to https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
hpxml_bldg.dst_begin_month = 3
hpxml_bldg.dst_begin_day = 12
hpxml_bldg.dst_end_month = 11
hpxml_bldg.dst_end_day = 5
end
hpxml_bldg.dst_begin_month_isdefaulted = true
hpxml_bldg.dst_begin_day_isdefaulted = true
hpxml_bldg.dst_end_month_isdefaulted = true
hpxml_bldg.dst_end_day_isdefaulted = true
end
end
if hpxml_bldg.elevation.nil?
hpxml_bldg.elevation = UnitConversions.convert([epw_file.elevation, 0.0].max, 'm', 'ft').round(1)
hpxml_bldg.elevation_isdefaulted = true
end
if hpxml_bldg.latitude.nil?
hpxml_bldg.latitude = get_default_latitude(hpxml_bldg.latitude, epw_file)
hpxml_bldg.latitude_isdefaulted = true
end
if hpxml_bldg.longitude.nil?
hpxml_bldg.longitude = get_default_longitude(hpxml_bldg.longitude, epw_file)
hpxml_bldg.longitude_isdefaulted = true
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_site(hpxml_bldg)
if hpxml_bldg.site.site_type.nil?
hpxml_bldg.site.site_type = HPXML::SiteTypeSuburban
hpxml_bldg.site.site_type_isdefaulted = true
end
if hpxml_bldg.site.shielding_of_home.nil?
if [HPXML::ResidentialTypeApartment, HPXML::ResidentialTypeSFA].include?(hpxml_bldg.building_construction.residential_facility_type)
# Shielding Class 5 is ACCA MJ8 default for Table 5B/5E for townhouses and condos
hpxml_bldg.site.shielding_of_home = HPXML::ShieldingWellShielded
else
# Shielding Class 4 is ACCA MJ8 default for Table 5A/5D and ANSI/RESNET 301 default
hpxml_bldg.site.shielding_of_home = HPXML::ShieldingNormal
end
hpxml_bldg.site.shielding_of_home_isdefaulted = true
end
if hpxml_bldg.site.ground_conductivity.nil?
hpxml_bldg.site.ground_conductivity = 1.0 # Btu/hr-ft-F
hpxml_bldg.site.ground_conductivity_isdefaulted = true
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_neighbor_buildings(hpxml_bldg)
hpxml_bldg.neighbor_buildings.each do |neighbor_building|
if neighbor_building.azimuth.nil?
neighbor_building.azimuth = get_azimuth_from_orientation(neighbor_building.orientation)
neighbor_building.azimuth_isdefaulted = true
end
if neighbor_building.orientation.nil?
neighbor_building.orientation = get_orientation_from_azimuth(neighbor_building.azimuth)
neighbor_building.orientation_isdefaulted = true
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @return [TODO] TODO
def self.apply_building_occupancy(hpxml_bldg, schedules_file)
if hpxml_bldg.building_occupancy.number_of_residents.nil?
hpxml_bldg.building_construction.additional_properties.adjusted_number_of_bedrooms = hpxml_bldg.building_construction.number_of_bedrooms
else
# Set adjusted number of bedrooms for operational calculation; this is an adjustment on
# ANSI 301 or Building America equations, which are based on number of bedrooms.
hpxml_bldg.building_construction.additional_properties.adjusted_number_of_bedrooms = get_nbeds_adjusted_for_operational_calculation(hpxml_bldg)
end
schedules_file_includes_occupants = (schedules_file.nil? ? false : schedules_file.includes_col_name(SchedulesFile::Columns[:Occupants].name))
if hpxml_bldg.building_occupancy.weekday_fractions.nil? && !schedules_file_includes_occupants
hpxml_bldg.building_occupancy.weekday_fractions = Schedule.OccupantsWeekdayFractions
hpxml_bldg.building_occupancy.weekday_fractions_isdefaulted = true
end
if hpxml_bldg.building_occupancy.weekend_fractions.nil? && !schedules_file_includes_occupants
hpxml_bldg.building_occupancy.weekend_fractions = Schedule.OccupantsWeekendFractions
hpxml_bldg.building_occupancy.weekend_fractions_isdefaulted = true
end
if hpxml_bldg.building_occupancy.monthly_multipliers.nil? && !schedules_file_includes_occupants
hpxml_bldg.building_occupancy.monthly_multipliers = Schedule.OccupantsMonthlyMultipliers
hpxml_bldg.building_occupancy.monthly_multipliers_isdefaulted = true
end
if hpxml_bldg.building_occupancy.general_water_use_usage_multiplier.nil?
hpxml_bldg.building_occupancy.general_water_use_usage_multiplier = 1.0
hpxml_bldg.building_occupancy.general_water_use_usage_multiplier_isdefaulted = true
end
schedules_file_includes_water = (schedules_file.nil? ? false : schedules_file.includes_col_name(SchedulesFile::Columns[:GeneralWaterUse].name))
if hpxml_bldg.building_occupancy.general_water_use_weekday_fractions.nil? && !schedules_file_includes_water
hpxml_bldg.building_occupancy.general_water_use_weekday_fractions = Schedule.GeneralWaterUseWeekdayFractions
hpxml_bldg.building_occupancy.general_water_use_weekday_fractions_isdefaulted = true
end
if hpxml_bldg.building_occupancy.general_water_use_weekend_fractions.nil? && !schedules_file_includes_water
hpxml_bldg.building_occupancy.general_water_use_weekend_fractions = Schedule.GeneralWaterUseWeekendFractions
hpxml_bldg.building_occupancy.general_water_use_weekend_fractions_isdefaulted = true
end
if hpxml_bldg.building_occupancy.general_water_use_monthly_multipliers.nil? && !schedules_file_includes_water
hpxml_bldg.building_occupancy.general_water_use_monthly_multipliers = Schedule.GeneralWaterUseMonthlyMultipliers
hpxml_bldg.building_occupancy.general_water_use_monthly_multipliers_isdefaulted = true
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param cfa [Double] Conditioned floor area in the dwelling unit (ft^2)
# @param nbeds [Integer] Number of bedrooms in the dwelling unit
# @return [TODO] TODO
def self.apply_building_construction(hpxml_bldg, cfa, nbeds)
cond_crawl_volume = hpxml_bldg.inferred_conditioned_crawlspace_volume()
if hpxml_bldg.building_construction.average_ceiling_height.nil?
# ASHRAE 62.2 default for average floor to ceiling height
hpxml_bldg.building_construction.average_ceiling_height = 8.2
hpxml_bldg.building_construction.average_ceiling_height_isdefaulted = true
end
if hpxml_bldg.building_construction.conditioned_building_volume.nil?
hpxml_bldg.building_construction.conditioned_building_volume = (cfa * hpxml_bldg.building_construction.average_ceiling_height + cond_crawl_volume).round
hpxml_bldg.building_construction.conditioned_building_volume_isdefaulted = true
end
if hpxml_bldg.building_construction.number_of_bathrooms.nil?
hpxml_bldg.building_construction.number_of_bathrooms = Float(Waterheater.get_default_num_bathrooms(nbeds)).to_i
hpxml_bldg.building_construction.number_of_bathrooms_isdefaulted = true
end
if hpxml_bldg.building_construction.number_of_units.nil?
hpxml_bldg.building_construction.number_of_units = 1
hpxml_bldg.building_construction.number_of_units_isdefaulted = true
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_zone_spaces(hpxml_bldg)
hpxml_bldg.conditioned_spaces.each do |space|
if space.fenestration_load_procedure.nil?
space.fenestration_load_procedure = HPXML::SpaceFenestrationLoadProcedureStandard
space.fenestration_load_procedure_isdefaulted = true
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param epw_file [OpenStudio::EpwFile] TODO
# @return [TODO] TODO
def self.apply_climate_and_risk_zones(hpxml_bldg, epw_file)
if (not epw_file.nil?) && hpxml_bldg.climate_and_risk_zones.climate_zone_ieccs.empty?
zone = Location.get_climate_zone_iecc(epw_file.wmoNumber)
if not zone.nil?
hpxml_bldg.climate_and_risk_zones.climate_zone_ieccs.add(zone: zone,
year: 2006,
zone_isdefaulted: true,
year_isdefaulted: true)
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_attics(hpxml_bldg)
if hpxml_bldg.has_location(HPXML::LocationAtticUnvented)
unvented_attics = hpxml_bldg.attics.select { |a| a.attic_type == HPXML::AtticTypeUnvented }
if unvented_attics.empty?
hpxml_bldg.attics.add(id: 'UnventedAttic',
attic_type: HPXML::AtticTypeUnvented)
unvented_attics << hpxml_bldg.attics[-1]
end
unvented_attics.each do |unvented_attic|
next unless unvented_attic.within_infiltration_volume.nil?
unvented_attic.within_infiltration_volume = false
unvented_attic.within_infiltration_volume_isdefaulted = true
end
if unvented_attics.map { |a| a.within_infiltration_volume }.uniq.size != 1
fail 'All unvented attics must have the same WithinInfiltrationVolume.'
end
end
if hpxml_bldg.has_location(HPXML::LocationAtticVented)
vented_attics = hpxml_bldg.attics.select { |a| a.attic_type == HPXML::AtticTypeVented }
if vented_attics.empty?
hpxml_bldg.attics.add(id: 'VentedAttic',
attic_type: HPXML::AtticTypeVented)
vented_attics << hpxml_bldg.attics[-1]
end
vented_attics.each do |vented_attic|
next unless (vented_attic.vented_attic_sla.nil? && vented_attic.vented_attic_ach.nil?)
vented_attic.vented_attic_sla = Airflow.get_default_vented_attic_sla()
vented_attic.vented_attic_sla_isdefaulted = true
end
if vented_attics.map { |a| a.vented_attic_sla }.uniq.size != 1
fail 'All vented attics must have the same VentilationRate.'
end
if vented_attics.map { |a| a.vented_attic_ach }.uniq.size != 1
fail 'All vented attics must have the same VentilationRate.'
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_foundations(hpxml_bldg)
if hpxml_bldg.has_location(HPXML::LocationCrawlspaceUnvented)
unvented_crawls = hpxml_bldg.foundations.select { |f| f.foundation_type == HPXML::FoundationTypeCrawlspaceUnvented }
if unvented_crawls.empty?
hpxml_bldg.foundations.add(id: 'UnventedCrawlspace',
foundation_type: HPXML::FoundationTypeCrawlspaceUnvented)
unvented_crawls << hpxml_bldg.foundations[-1]
end
unvented_crawls.each do |unvented_crawl|
next unless unvented_crawl.within_infiltration_volume.nil?
unvented_crawl.within_infiltration_volume = false
unvented_crawl.within_infiltration_volume_isdefaulted = true
end
if unvented_crawls.map { |f| f.within_infiltration_volume }.uniq.size != 1
fail 'All unvented crawlspaces must have the same WithinInfiltrationVolume.'
end
end
if hpxml_bldg.has_location(HPXML::LocationBasementUnconditioned)
uncond_bsmts = hpxml_bldg.foundations.select { |f| f.foundation_type == HPXML::FoundationTypeBasementUnconditioned }
if uncond_bsmts.empty?
hpxml_bldg.foundations.add(id: 'UnconditionedBasement',
foundation_type: HPXML::FoundationTypeBasementUnconditioned)
uncond_bsmts << hpxml_bldg.foundations[-1]
end
uncond_bsmts.each do |uncond_bsmt|
next unless uncond_bsmt.within_infiltration_volume.nil?
uncond_bsmt.within_infiltration_volume = false
uncond_bsmt.within_infiltration_volume_isdefaulted = true
end
if uncond_bsmts.map { |f| f.within_infiltration_volume }.uniq.size != 1
fail 'All unconditioned basements must have the same WithinInfiltrationVolume.'
end
end
if hpxml_bldg.has_location(HPXML::LocationCrawlspaceVented)
vented_crawls = hpxml_bldg.foundations.select { |f| f.foundation_type == HPXML::FoundationTypeCrawlspaceVented }
if vented_crawls.empty?
hpxml_bldg.foundations.add(id: 'VentedCrawlspace',
foundation_type: HPXML::FoundationTypeCrawlspaceVented)
vented_crawls << hpxml_bldg.foundations[-1]
end
vented_crawls.each do |vented_crawl|
next unless vented_crawl.vented_crawlspace_sla.nil?
vented_crawl.vented_crawlspace_sla = Airflow.get_default_vented_crawl_sla()
vented_crawl.vented_crawlspace_sla_isdefaulted = true
end
if vented_crawls.map { |f| f.vented_crawlspace_sla }.uniq.size != 1
fail 'All vented crawlspaces must have the same VentilationRate.'
end
end
if hpxml_bldg.has_location(HPXML::LocationManufacturedHomeUnderBelly)
belly_and_wing_foundations = hpxml_bldg.foundations.select { |f| f.foundation_type == HPXML::FoundationTypeBellyAndWing }
if belly_and_wing_foundations.empty?
hpxml_bldg.foundations.add(id: 'BellyAndWing',
foundation_type: HPXML::FoundationTypeBellyAndWing)
belly_and_wing_foundations << hpxml_bldg.foundations[-1]
end
belly_and_wing_foundations.each do |foundation|
next unless foundation.belly_wing_skirt_present.nil?
foundation.belly_wing_skirt_present = true
foundation.belly_wing_skirt_present_isdefaulted = true
end
if belly_and_wing_foundations.map { |f| f.belly_wing_skirt_present }.uniq.size != 1
fail 'All belly-and-wing foundations must have the same SkirtPresent.'
end
end
end
# TODO
#
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [TODO] TODO
def self.apply_infiltration(hpxml_bldg)