-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtasks.rb
2794 lines (2663 loc) · 165 KB
/
tasks.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
OpenStudio::Logger.instance.standardOutLogger.setLogLevel(OpenStudio::Fatal)
Dir["#{File.dirname(__FILE__)}/HPXMLtoOpenStudio/resources/*.rb"].each do |resource_file|
next if resource_file.include? 'minitest_helper.rb'
require resource_file
end
def create_hpxmls
this_dir = File.dirname(__FILE__)
workflow_dir = File.join(this_dir, 'workflow')
hpxml_inputs_tsv_path = File.join(workflow_dir, 'hpxml_inputs.json')
require 'json'
json_inputs = JSON.parse(File.read(hpxml_inputs_tsv_path))
abs_hpxml_files = []
dirs = json_inputs.keys.map { |file_path| File.dirname(file_path) }.uniq
schema_path = File.join(File.dirname(__FILE__), 'HPXMLtoOpenStudio', 'resources', 'hpxml_schema', 'HPXML.xsd')
schema_validator = XMLValidator.get_xml_validator(schema_path)
# Delete all stochastic schedule files (they will be regenerated below)
stochastic_sched_basename = 'occupancy-stochastic'
stochastic_csvs = File.join(File.dirname(__FILE__), 'HPXMLtoOpenStudio', 'resources', 'schedule_files', "#{stochastic_sched_basename}*.csv")
Dir.glob(stochastic_csvs).each { |file| File.delete(file) }
# Specify list of sample files that should not regenerate schedule CSVs. These files test simulation timesteps
# that differ from the stochastic schedule timestep. If we were to call the BuildResidentialScheduleFile
# measure, it will generate a stochastic schedule that matches the simulation timestep; so we skip it and just
# use the stochastic schedule generated from another HPXML file.
schedule_skip_list = [
'base-schedules-detailed-occupancy-stochastic-10-mins.xml',
'base-simcontrol-timestep-10-mins-occupancy-stochastic-60-mins.xml'
]
puts "Generating #{json_inputs.size} HPXML files..."
json_inputs.keys.each_with_index do |hpxml_filename, hpxml_i|
puts "[#{hpxml_i + 1}/#{json_inputs.size}] Generating #{hpxml_filename}..."
hpxml_path = File.join(workflow_dir, hpxml_filename)
abs_hpxml_files << File.absolute_path(hpxml_path)
# Build up json_input from parent_hpxml(s)
parent_hpxml_filenames = []
parent_hpxml_filename = json_inputs[hpxml_filename]['parent_hpxml']
while not parent_hpxml_filename.nil?
if not json_inputs.keys.include? parent_hpxml_filename
fail "Could not find parent_hpxml: #{parent_hpxml_filename}."
end
parent_hpxml_filenames << parent_hpxml_filename
parent_hpxml_filename = json_inputs[parent_hpxml_filename]['parent_hpxml']
end
json_input = { 'hpxml_path' => hpxml_path }
for parent_hpxml_filename in parent_hpxml_filenames.reverse
json_input.merge!(json_inputs[parent_hpxml_filename])
end
json_input.merge!(json_inputs[hpxml_filename])
json_input.delete('parent_hpxml')
measures = {}
measures['BuildResidentialHPXML'] = [json_input]
measures_dir = File.dirname(__FILE__)
model = OpenStudio::Model::Model.new
runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
num_apply_measures = 1
if hpxml_path.include?('base-bldgtype-mf-whole-building.xml')
num_apply_measures = 6
end
for i in 1..num_apply_measures
build_residential_hpxml = measures['BuildResidentialHPXML'][0]
build_residential_hpxml['existing_hpxml_path'] = hpxml_path if i > 1
if hpxml_path.include?('base-bldgtype-mf-whole-building.xml')
suffix = "_#{i}" if i > 1
build_residential_hpxml['schedules_filepaths'] = "../../HPXMLtoOpenStudio/resources/schedule_files/occupancy-stochastic#{suffix}.csv"
build_residential_hpxml['geometry_foundation_type'] = (i <= 2 ? 'UnconditionedBasement' : 'AboveApartment')
build_residential_hpxml['geometry_attic_type'] = (i >= 5 ? 'VentedAttic' : 'BelowApartment')
build_residential_hpxml['geometry_unit_height_above_grade'] = { 1 => 0.0, 2 => 0.0, 3 => 10.0, 4 => 10.0, 5 => 20.0, 6 => 20.0 }[i]
end
# Re-generate stochastic schedule CSV?
prev_csv_path = nil
csv_path = json_input['schedules_filepaths'].to_s.split(',').map(&:strip).find { |fp| fp.include? stochastic_sched_basename }
if (not csv_path.nil?) && !schedule_skip_list.include?(File.basename(hpxml_path))
sch_args = { 'hpxml_path' => hpxml_path,
'output_csv_path' => csv_path,
'hpxml_output_path' => hpxml_path,
'building_id' => "MyBuilding#{suffix}" }
measures['BuildResidentialScheduleFile'] = [sch_args]
# Rename existing file (if found) for later comparison
csv_path = File.expand_path(File.join(File.dirname(hpxml_path), csv_path))
if File.exist? csv_path
prev_csv_path = csv_path + '.prev'
File.rename(csv_path, prev_csv_path)
end
end
# Apply measure
success = apply_measures(measures_dir, measures, runner, model)
# Report errors
runner.result.stepErrors.each do |s|
puts "Error: #{s}"
end
if not success
puts "\nError: Did not successfully generate #{hpxml_filename}."
exit!
end
# Make sure newly generated schedule CSV matches previously generated schedule CSV
next if prev_csv_path.nil?
csv_data = File.read(csv_path)
prev_csv_data = File.read(prev_csv_path)
if csv_data != prev_csv_data
puts "Error: Two different schedule CSVs (see #{File.basename(csv_path)} vs #{File.basename(prev_csv_path)}) were generated for the same filename."
exit!
end
File.delete(prev_csv_path)
end
hpxml = HPXML.new(hpxml_path: hpxml_path)
if hpxml_path.include?('ASHRAE_Standard_140') || hpxml_path.include?('HERS_HVAC') || hpxml_path.include?('HERS_DSE')
apply_hpxml_modification_ashrae_140(hpxml)
if hpxml_path.include?('HERS_HVAC') || hpxml_path.include?('HERS_DSE')
apply_hpxml_modification_hers_hvac_dse(hpxml_path, hpxml)
end
elsif hpxml_path.include?('HERS_Hot_Water')
apply_hpxml_modification_hers_hot_water(hpxml)
else
apply_hpxml_modification_sample_files(hpxml_path, hpxml)
end
hpxml_doc = hpxml.to_doc()
XMLHelper.write_file(hpxml_doc, hpxml_path)
errors, _warnings = XMLValidator.validate_against_schema(hpxml_path, schema_validator)
next unless errors.size > 0
errors.each do |s|
puts "Error: #{s}"
end
puts "\nError: Did not successfully validate #{hpxml_filename}."
exit!
end
puts "\n"
# Print warnings about extra files
dirs.each do |dir|
Dir["#{workflow_dir}/#{dir}/*.xml"].each do |hpxml|
next if abs_hpxml_files.include? File.absolute_path(hpxml)
puts "Warning: Extra HPXML file found at #{File.absolute_path(hpxml)}"
end
end
end
def apply_hpxml_modification_ashrae_140(hpxml)
# Set detailed HPXML values for ASHRAE 140 test files
hpxml_bldg = hpxml.buildings[0]
# ------------ #
# HPXML Header #
# ------------ #
hpxml.header.xml_generated_by = 'tasks.rb'
hpxml.header.created_date_and_time = Time.new(2000, 1, 1, 0, 0, 0, '-07:00').strftime('%Y-%m-%dT%H:%M:%S%:z') # Hard-code to prevent diffs
hpxml.header.apply_ashrae140_assumptions = true
# --------------------- #
# HPXML BuildingSummary #
# --------------------- #
hpxml_bldg.site.azimuth_of_front_of_home = nil
# --------------- #
# HPXML Enclosure #
# --------------- #
hpxml_bldg.attics[0].vented_attic_ach = 2.4
hpxml_bldg.foundations.reverse_each do |foundation|
foundation.delete
end
hpxml_bldg.roofs.each do |roof|
if roof.roof_color == HPXML::ColorReflective
roof.solar_absorptance = 0.2
else
roof.solar_absorptance = 0.6
end
roof.emittance = 0.9
roof.roof_color = nil
end
(hpxml_bldg.walls + hpxml_bldg.rim_joists).each do |wall|
if wall.color == HPXML::ColorReflective
wall.solar_absorptance = 0.2
else
wall.solar_absorptance = 0.6
end
wall.emittance = 0.9
wall.color = nil
if wall.is_a?(HPXML::Wall)
if wall.attic_wall_type == HPXML::AtticWallTypeGable
wall.insulation_assembly_r_value = 2.15
else
wall.interior_finish_type = HPXML::InteriorFinishGypsumBoard
wall.interior_finish_thickness = 0.5
end
end
end
hpxml_bldg.floors.each do |floor|
next unless floor.is_ceiling
floor.interior_finish_type = HPXML::InteriorFinishGypsumBoard
floor.interior_finish_thickness = 0.5
end
hpxml_bldg.foundation_walls.each do |fwall|
if fwall.insulation_interior_r_value == 0
fwall.interior_finish_type = HPXML::InteriorFinishNone
else
fwall.interior_finish_type = HPXML::InteriorFinishGypsumBoard
fwall.interior_finish_thickness = 0.5
end
end
if hpxml_bldg.doors.size == 1
hpxml_bldg.doors[0].area /= 2.0
hpxml_bldg.doors << hpxml_bldg.doors[0].dup
hpxml_bldg.doors[1].azimuth = 0
hpxml_bldg.doors[1].id = 'Door2'
end
hpxml_bldg.windows.each do |window|
next if window.overhangs_depth.nil?
window.overhangs_distance_to_bottom_of_window = 6.0
end
# ---------- #
# HPXML HVAC #
# ---------- #
if hpxml_bldg.hvac_controls.empty?
hpxml_bldg.hvac_controls.add(id: "HVACControl#{hpxml_bldg.hvac_controls.size + 1}",
heating_setpoint_temp: 68.0,
cooling_setpoint_temp: 78.0)
end
# --------------- #
# HPXML MiscLoads #
# --------------- #
return unless hpxml_bldg.plug_loads[0].kwh_per_year > 0
hpxml_bldg.plug_loads[0].weekday_fractions = '0.0203, 0.0203, 0.0203, 0.0203, 0.0203, 0.0339, 0.0426, 0.0852, 0.0497, 0.0304, 0.0304, 0.0406, 0.0304, 0.0254, 0.0264, 0.0264, 0.0386, 0.0416, 0.0447, 0.0700, 0.0700, 0.0731, 0.0731, 0.0660'
hpxml_bldg.plug_loads[0].weekend_fractions = '0.0203, 0.0203, 0.0203, 0.0203, 0.0203, 0.0339, 0.0426, 0.0852, 0.0497, 0.0304, 0.0304, 0.0406, 0.0304, 0.0254, 0.0264, 0.0264, 0.0386, 0.0416, 0.0447, 0.0700, 0.0700, 0.0731, 0.0731, 0.0660'
hpxml_bldg.plug_loads[0].monthly_multipliers = '1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0'
end
def apply_hpxml_modification_hers_hvac_dse(hpxml_path, hpxml)
# Set detailed HPXML values for HERS HVAC/DSE test files
hpxml_bldg = hpxml.buildings[0]
if hpxml_path.include? 'HERS_HVAC'
hpxml_bldg.hvac_distributions.clear
hpxml_bldg.hvac_distributions.add(id: 'HVACDistribution1',
distribution_system_type: HPXML::HVACDistributionTypeDSE,
annual_heating_dse: 1.0,
annual_cooling_dse: 1.0)
end
if hpxml_path.include? 'HERS_DSE'
# For DSE tests, use effective R-values instead of nominal R-values to match the test specs.
hpxml_bldg.hvac_distributions[0].ducts.each do |duct|
next if duct.duct_insulation_r_value.nil?
if duct.duct_insulation_r_value == 0
duct.duct_insulation_r_value = nil
duct.duct_effective_r_value = 1.5
elsif duct.duct_insulation_r_value == 6
duct.duct_insulation_r_value = nil
duct.duct_effective_r_value = 7
else
fail 'Unexpected error.'
end
end
end
end
def apply_hpxml_modification_hers_hot_water(hpxml)
# Set detailed HPXML values for HERS Hot Water test files
hpxml_bldg = hpxml.buildings[0]
hpxml.header.xml_generated_by = 'tasks.rb'
hpxml.header.created_date_and_time = Time.new(2000, 1, 1, 0, 0, 0, '-07:00').strftime('%Y-%m-%dT%H:%M:%S%:z') # Hard-code to prevent diffs
(hpxml_bldg.roofs + hpxml_bldg.walls + hpxml_bldg.rim_joists).each do |surface|
surface.solar_absorptance = 0.75
surface.emittance = 0.9
if surface.is_a? HPXML::Roof
surface.roof_color = nil
else
surface.color = nil
end
end
hpxml_bldg.hvac_distributions.clear
hpxml_bldg.hvac_distributions.add(id: 'HVACDistribution1',
distribution_system_type: HPXML::HVACDistributionTypeDSE,
annual_heating_dse: 1.0,
annual_cooling_dse: 1.0)
end
def apply_hpxml_modification_sample_files(hpxml_path, hpxml)
default_schedules_csv_data = Defaults.get_schedules_csv_data()
# Set detailed HPXML values for sample files
hpxml_file = File.basename(hpxml_path)
hpxml_bldg = hpxml.buildings[0]
# ------------ #
# HPXML Header #
# ------------ #
hpxml.header.xml_generated_by = 'tasks.rb'
hpxml.header.created_date_and_time = Time.new(2000, 1, 1, 0, 0, 0, '-07:00').strftime('%Y-%m-%dT%H:%M:%S%:z') # Hard-code to prevent diffs
if ['base-hvac-undersized-allow-increased-fixed-capacities.xml'].include? hpxml_file
hpxml_bldg.header.allow_increased_fixed_capacities = true
elsif ['base-misc-emissions.xml'].include? hpxml_file
hpxml_bldg.egrid_region = 'Western'
hpxml_bldg.egrid_subregion = 'RMPA'
hpxml_bldg.cambium_region_gea = 'RMPAc'
end
if ['base-hvac-autosize-sizing-controls.xml'].include? hpxml_file
hpxml_bldg.header.manualj_heating_design_temp = 0
hpxml_bldg.header.manualj_cooling_design_temp = 100
hpxml_bldg.header.manualj_heating_setpoint = 60
hpxml_bldg.header.manualj_cooling_setpoint = 80
hpxml_bldg.header.manualj_humidity_setpoint = 0.55
hpxml_bldg.header.manualj_internal_loads_sensible = 4000
hpxml_bldg.header.manualj_internal_loads_latent = 200
hpxml_bldg.header.manualj_num_occupants = 5
hpxml_bldg.header.manualj_daily_temp_range = HPXML::ManualJDailyTempRangeLow
hpxml_bldg.header.manualj_humidity_difference = 30
end
hpxml.buildings.each do |hpxml_bldg|
if ['base-misc-emissions.xml'].include? hpxml_file
hpxml_bldg.egrid_region = 'Western'
hpxml_bldg.egrid_subregion = 'RMPA'
hpxml_bldg.cambium_region_gea = 'RMPAc'
end
# --------------------- #
# HPXML BuildingSummary #
# --------------------- #
hpxml_bldg.site.available_fuels = [HPXML::FuelTypeElectricity, HPXML::FuelTypeNaturalGas]
if ['base-schedules-simple.xml',
'base-schedules-simple-vacancy.xml',
'base-schedules-simple-power-outage.xml',
'base-misc-loads-large-uncommon.xml',
'base-misc-loads-large-uncommon2.xml'].include? hpxml_file
hpxml_bldg.building_occupancy.weekday_fractions = '0.061, 0.061, 0.061, 0.061, 0.061, 0.061, 0.061, 0.053, 0.025, 0.015, 0.015, 0.015, 0.015, 0.015, 0.015, 0.015, 0.018, 0.033, 0.054, 0.054, 0.054, 0.061, 0.061, 0.061'
hpxml_bldg.building_occupancy.weekend_fractions = '0.061, 0.061, 0.061, 0.061, 0.061, 0.061, 0.061, 0.053, 0.025, 0.015, 0.015, 0.015, 0.015, 0.015, 0.015, 0.015, 0.018, 0.033, 0.054, 0.054, 0.054, 0.061, 0.061, 0.061'
hpxml_bldg.building_occupancy.monthly_multipliers = '1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0'
hpxml_bldg.building_occupancy.general_water_use_weekday_fractions = '0.023, 0.021, 0.021, 0.025, 0.027, 0.038, 0.044, 0.039, 0.037, 0.037, 0.034, 0.035, 0.035, 0.035, 0.039, 0.043, 0.051, 0.064, 0.065, 0.072, 0.073, 0.063, 0.045, 0.034'
hpxml_bldg.building_occupancy.general_water_use_weekend_fractions = '0.023, 0.021, 0.021, 0.025, 0.027, 0.038, 0.044, 0.039, 0.037, 0.037, 0.034, 0.035, 0.035, 0.035, 0.039, 0.043, 0.051, 0.064, 0.065, 0.072, 0.073, 0.063, 0.045, 0.034'
hpxml_bldg.building_occupancy.general_water_use_monthly_multipliers = '1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0'
elsif ['base-misc-defaults.xml'].include? hpxml_file
hpxml_bldg.building_construction.average_ceiling_height = nil
hpxml_bldg.building_construction.conditioned_building_volume = nil
elsif ['base-atticroof-cathedral.xml'].include? hpxml_file
hpxml_bldg.building_construction.number_of_conditioned_floors = 2
hpxml_bldg.building_construction.number_of_conditioned_floors_above_grade = 1
hpxml_bldg.building_construction.conditioned_floor_area = 2700
hpxml_bldg.attics[0].attic_type = HPXML::AtticTypeCathedral
elsif ['base-atticroof-conditioned.xml'].include? hpxml_file
hpxml_bldg.building_construction.conditioned_building_volume = 23850
hpxml_bldg.air_infiltration_measurements[0].infiltration_volume = hpxml_bldg.building_construction.conditioned_building_volume
hpxml_bldg.air_infiltration_measurements[0].infiltration_height = 15.0
elsif ['base-enclosure-split-level.xml'].include? hpxml_file
hpxml_bldg.building_construction.number_of_conditioned_floors = 1.5
hpxml_bldg.building_construction.number_of_conditioned_floors_above_grade = 1.5
elsif ['base-foundation-walkout-basement.xml'].include? hpxml_file
hpxml_bldg.building_construction.number_of_conditioned_floors_above_grade = 2
elsif ['base-foundation-basement-garage.xml'].include? hpxml_file
hpxml_bldg.building_construction.conditioned_floor_area -= 400 * 2
hpxml_bldg.building_construction.conditioned_building_volume -= 400 * 2 * 8
hpxml_bldg.air_infiltration_measurements[0].infiltration_volume = hpxml_bldg.building_construction.conditioned_building_volume
elsif ['base-bldgtype-mf-unit-infil-compartmentalization-test.xml'].include? hpxml_file
hpxml_bldg.air_infiltration_measurements[0].a_ext = 0.2
end
# ------------------ #
# HPXML Zones/Spaces #
# ------------------ #
if ['base-zones-spaces.xml',
'base-zones-spaces-multiple.xml'].include? hpxml_file
# Add zones
if hpxml_file == 'base-zones-spaces.xml'
hpxml_bldg.zones.add(id: 'ConditionedZone',
zone_type: HPXML::ZoneTypeConditioned)
ag_cond_zone = hpxml_bldg.zones[-1]
bg_cond_zone = hpxml_bldg.zones[-1]
elsif hpxml_file == 'base-zones-spaces-multiple.xml'
hpxml_bldg.zones.add(id: 'AGConditionedZone',
zone_type: HPXML::ZoneTypeConditioned)
ag_cond_zone = hpxml_bldg.zones[-1]
hpxml_bldg.zones.add(id: 'BGConditionedZone',
zone_type: HPXML::ZoneTypeConditioned)
bg_cond_zone = hpxml_bldg.zones[-1]
end
hpxml_bldg.zones.add(id: 'GarageZone',
zone_type: HPXML::ZoneTypeUnconditioned)
grg_zone = hpxml_bldg.zones[-1]
# Attach HVAC
hpxml_bldg.heating_systems[0].attached_to_zone_idref = hpxml_bldg.zones[0].id
hpxml_bldg.cooling_systems[0].attached_to_zone_idref = hpxml_bldg.zones[0].id
if hpxml_file == 'base-zones-spaces-multiple.xml'
hpxml_bldg.heating_systems << hpxml_bldg.heating_systems[0].dup
hpxml_bldg.heating_systems[-1].id = 'HeatingSystem2'
hpxml_bldg.heating_systems[-1].attached_to_zone_idref = hpxml_bldg.zones[1].id
hpxml_bldg.heating_systems[-1].primary_system = false
hpxml_bldg.cooling_systems << hpxml_bldg.cooling_systems[0].dup
hpxml_bldg.cooling_systems[-1].id = 'CoolingSystem2'
hpxml_bldg.cooling_systems[-1].attached_to_zone_idref = hpxml_bldg.zones[1].id
hpxml_bldg.cooling_systems[-1].primary_system = false
hpxml_bldg.hvac_distributions.add(id: "HVACDistribution#{hpxml_bldg.hvac_distributions.size + 1}",
distribution_system_type: HPXML::HVACDistributionTypeAir,
air_type: HPXML::AirTypeRegularVelocity)
hpxml_bldg.hvac_distributions[-1].duct_leakage_measurements << hpxml_bldg.hvac_distributions[0].duct_leakage_measurements[0].dup
hpxml_bldg.hvac_distributions[-1].duct_leakage_measurements << hpxml_bldg.hvac_distributions[0].duct_leakage_measurements[1].dup
hpxml_bldg.hvac_distributions[-1].ducts << hpxml_bldg.hvac_distributions[0].ducts[0].dup
hpxml_bldg.hvac_distributions[-1].ducts << hpxml_bldg.hvac_distributions[0].ducts[1].dup
hpxml_bldg.hvac_distributions[-1].ducts[0].id = 'Ducts3'
hpxml_bldg.hvac_distributions[-1].ducts[1].id = 'Ducts4'
hpxml_bldg.heating_systems[-1].distribution_system_idref = hpxml_bldg.hvac_distributions[-1].id
hpxml_bldg.cooling_systems[-1].distribution_system_idref = hpxml_bldg.hvac_distributions[-1].id
end
# Add spaces
ag_cond_zone.spaces.add(id: 'Space1',
floor_area: 850,
manualj_num_occupants: 2,
manualj_internal_loads_sensible: 1000,
manualj_internal_loads_latent: 100)
ag_cond_zone.spaces.add(id: 'Space2',
floor_area: 500,
manualj_num_occupants: 0,
manualj_internal_loads_sensible: 0,
manualj_internal_loads_latent: 0)
bg_cond_zone.spaces.add(id: 'Space3',
floor_area: 1000,
manualj_num_occupants: 1,
manualj_internal_loads_sensible: 1400,
manualj_internal_loads_latent: 200)
bg_cond_zone.spaces.add(id: 'Space4',
floor_area: 350,
manualj_num_occupants: 1,
manualj_internal_loads_sensible: 600,
manualj_internal_loads_latent: 0)
grg_zone.spaces.add(id: 'GarageSpace',
floor_area: 600)
# Attach surfaces
ag_surfaces = hpxml_bldg.surfaces.select { |w| w.interior_adjacent_to == HPXML::LocationConditionedSpace }
ag_spaces = hpxml_bldg.conditioned_spaces[0..1]
ag_cfa = ag_spaces.map { |space| space.floor_area }.sum
ag_surfaces.reverse_each do |ag_surface|
ag_spaces.each do |ag_space|
if ag_surface.is_a? HPXML::Wall
hpxml_bldg.walls << ag_surface.dup
new_ag_surface = hpxml_bldg.walls[-1]
elsif ag_surface.is_a? HPXML::Floor
hpxml_bldg.floors << ag_surface.dup
new_ag_surface = hpxml_bldg.floors[-1]
else
fail "Unexpected surface type: #{ag_surface.class}"
end
new_ag_surface.id = "#{ag_surface.id}#{ag_space.id}"
new_ag_surface.insulation_id = "#{ag_surface.insulation_id}#{ag_space.id}"
new_ag_surface.area = (new_ag_surface.area * ag_space.floor_area / ag_cfa).round(1)
new_ag_surface.attached_to_space_idref = ag_space.id
if ag_surface.is_a? HPXML::Floor
hpxml_bldg.attics[0].attached_to_floor_idrefs << new_ag_surface.id
end
next unless ag_surface.is_a? HPXML::Wall
ag_surface.windows.each do |window|
hpxml_bldg.windows << window.dup
hpxml_bldg.windows[-1].id = "#{hpxml_bldg.windows[-1].id}#{ag_space.id}"
hpxml_bldg.windows[-1].area = (hpxml_bldg.windows[-1].area * ag_space.floor_area / ag_cfa).round(1)
hpxml_bldg.windows[-1].interior_shading_id = "#{hpxml_bldg.windows[-1].interior_shading_id}#{ag_space.id}"
hpxml_bldg.windows[-1].attached_to_wall_idref = new_ag_surface.id
end
ag_surface.doors.each do |door|
hpxml_bldg.doors << door.dup
hpxml_bldg.doors[-1].id = "#{hpxml_bldg.doors[-1].id}#{ag_space.id}"
hpxml_bldg.doors[-1].area = (hpxml_bldg.doors[-1].area / ag_surface.doors.size).round(1)
hpxml_bldg.doors[-1].attached_to_wall_idref = new_ag_surface.id
end
end
ag_surface.delete
end
bg_surfaces = hpxml_bldg.surfaces.select { |w| w.interior_adjacent_to == HPXML::LocationBasementConditioned }
bg_spaces = hpxml_bldg.conditioned_spaces[2..3]
bg_cfa = bg_spaces.map { |space| space.floor_area }.sum
bg_surfaces.reverse_each do |bg_surface|
hpxml_bldg.conditioned_spaces[2..3].each do |bg_space|
if bg_surface.is_a? HPXML::FoundationWall
hpxml_bldg.foundation_walls << bg_surface.dup
new_bg_surface = hpxml_bldg.foundation_walls[-1]
elsif bg_surface.is_a? HPXML::RimJoist
hpxml_bldg.rim_joists << bg_surface.dup
new_bg_surface = hpxml_bldg.rim_joists[-1]
elsif bg_surface.is_a? HPXML::Slab
hpxml_bldg.slabs << bg_surface.dup
new_bg_surface = hpxml_bldg.slabs[-1]
else
fail "Unexpected surface type: #{bg_surface.class}"
end
new_bg_surface.id = "#{bg_surface.id}#{bg_space.id}"
if bg_surface.is_a? HPXML::Slab
new_bg_surface.perimeter_insulation_id = "#{bg_surface.perimeter_insulation_id}#{bg_space.id}"
new_bg_surface.under_slab_insulation_id = "#{bg_surface.under_slab_insulation_id}#{bg_space.id}"
if not new_bg_surface.exterior_horizontal_insulation_id.nil?
new_bg_surface.exterior_horizontal_insulation_id = "#{bg_surface.exterior_horizontal_insulation_id}#{bg_space.id}"
end
else
new_bg_surface.insulation_id = "#{bg_space.id}#{bg_surface.insulation_id}"
end
new_bg_surface.area = (new_bg_surface.area * bg_space.floor_area / bg_cfa).round(1)
if bg_surface.is_a? HPXML::Slab
new_bg_surface.exposed_perimeter = (new_bg_surface.exposed_perimeter * bg_space.floor_area / bg_cfa).round(1)
end
new_bg_surface.attached_to_space_idref = bg_space.id
if bg_surface.is_a? HPXML::RimJoist
hpxml_bldg.foundations[0].attached_to_rim_joist_idrefs << new_bg_surface.id
elsif bg_surface.is_a? HPXML::FoundationWall
hpxml_bldg.foundations[0].attached_to_foundation_wall_idrefs << new_bg_surface.id
elsif bg_surface.is_a? HPXML::Slab
hpxml_bldg.foundations[0].attached_to_slab_idrefs << new_bg_surface.id
end
end
bg_surface.delete
end
hpxml_bldg.surfaces.each do |s|
next unless s.interior_adjacent_to == HPXML::LocationGarage
s.attached_to_space_idref = hpxml_bldg.zones[-1].spaces[0].id
end
end
# --------------- #
# HPXML Enclosure #
# --------------- #
(hpxml_bldg.roofs + hpxml_bldg.walls + hpxml_bldg.rim_joists).each do |surface|
surface.solar_absorptance = 0.7
surface.emittance = 0.92
if surface.is_a? HPXML::Roof
surface.roof_color = nil
else
surface.color = nil
end
end
hpxml_bldg.roofs.each do |roof|
next unless roof.interior_adjacent_to == HPXML::LocationConditionedSpace
roof.interior_finish_type = HPXML::InteriorFinishGypsumBoard
end
(hpxml_bldg.walls + hpxml_bldg.foundation_walls + hpxml_bldg.floors).each do |surface|
if surface.is_a?(HPXML::FoundationWall) && surface.interior_adjacent_to != HPXML::LocationBasementConditioned
surface.interior_finish_type = HPXML::InteriorFinishNone
end
next unless [HPXML::LocationConditionedSpace,
HPXML::LocationBasementConditioned].include?(surface.interior_adjacent_to) &&
[HPXML::LocationOutside,
HPXML::LocationGround,
HPXML::LocationGarage,
HPXML::LocationAtticUnvented,
HPXML::LocationAtticVented,
HPXML::LocationOtherHousingUnit,
HPXML::LocationBasementConditioned].include?(surface.exterior_adjacent_to)
next if surface.is_a?(HPXML::Floor) && surface.is_floor
surface.interior_finish_type = HPXML::InteriorFinishGypsumBoard
end
hpxml_bldg.attics.each do |attic|
if attic.attic_type == HPXML::AtticTypeUnvented
attic.within_infiltration_volume = false
elsif attic.attic_type == HPXML::AtticTypeVented
attic.vented_attic_sla = 0.003
end
end
hpxml_bldg.foundations.each do |foundation|
if foundation.foundation_type == HPXML::FoundationTypeCrawlspaceUnvented
foundation.within_infiltration_volume = false
elsif foundation.foundation_type == HPXML::FoundationTypeCrawlspaceVented
foundation.vented_crawlspace_sla = 0.00667
end
end
hpxml_bldg.skylights.each do |skylight|
skylight.interior_shading_factor_summer = 1.0
skylight.interior_shading_factor_winter = 1.0
end
if ['base-bldgtype-mf-unit-adjacent-to-multifamily-buffer-space.xml',
'base-bldgtype-mf-unit-adjacent-to-non-freezing-space.xml',
'base-bldgtype-mf-unit-adjacent-to-other-heated-space.xml',
'base-bldgtype-mf-unit-adjacent-to-other-housing-unit.xml'].include? hpxml_file
if hpxml_file == 'base-bldgtype-mf-unit-adjacent-to-multifamily-buffer-space.xml'
adjacent_to = HPXML::LocationOtherMultifamilyBufferSpace
elsif hpxml_file == 'base-bldgtype-mf-unit-adjacent-to-non-freezing-space.xml'
adjacent_to = HPXML::LocationOtherNonFreezingSpace
elsif hpxml_file == 'base-bldgtype-mf-unit-adjacent-to-other-heated-space.xml'
adjacent_to = HPXML::LocationOtherHeatedSpace
elsif hpxml_file == 'base-bldgtype-mf-unit-adjacent-to-other-housing-unit.xml'
adjacent_to = HPXML::LocationOtherHousingUnit
end
wall = hpxml_bldg.walls.select { |w|
w.interior_adjacent_to == HPXML::LocationConditionedSpace &&
w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit
}[0]
wall.exterior_adjacent_to = adjacent_to
hpxml_bldg.floors[0].exterior_adjacent_to = adjacent_to
hpxml_bldg.floors[1].exterior_adjacent_to = adjacent_to
if hpxml_file != 'base-bldgtype-mf-unit-adjacent-to-other-housing-unit.xml'
wall.insulation_assembly_r_value = 23
hpxml_bldg.floors[0].insulation_assembly_r_value = 18.7
hpxml_bldg.floors[1].insulation_assembly_r_value = 18.7
end
hpxml_bldg.windows.each do |window|
window.area = (window.area * 0.35).round(1)
end
hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}",
attached_to_wall_idref: wall.id,
area: 20,
azimuth: 0,
r_value: 4.4)
hpxml_bldg.hvac_distributions[0].ducts[0].duct_location = adjacent_to
hpxml_bldg.hvac_distributions[0].ducts[1].duct_location = adjacent_to
hpxml_bldg.water_heating_systems[0].location = adjacent_to
hpxml_bldg.clothes_washers[0].location = adjacent_to
hpxml_bldg.clothes_dryers[0].location = adjacent_to
hpxml_bldg.dishwashers[0].location = adjacent_to
hpxml_bldg.refrigerators[0].location = adjacent_to
hpxml_bldg.cooking_ranges[0].location = adjacent_to
elsif ['base-bldgtype-mf-unit-adjacent-to-multiple.xml',
'base-bldgtype-mf-unit-adjacent-to-multiple-hvac-none.xml'].include? hpxml_file
wall = hpxml_bldg.walls.select { |w|
w.interior_adjacent_to == HPXML::LocationConditionedSpace &&
w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit
}[0]
wall.delete
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherHeatedSpace,
interior_adjacent_to: HPXML::LocationConditionedSpace,
wall_type: HPXML::WallTypeWoodStud,
area: 100,
solar_absorptance: 0.7,
emittance: 0.92,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 23.0)
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherMultifamilyBufferSpace,
interior_adjacent_to: HPXML::LocationConditionedSpace,
wall_type: HPXML::WallTypeWoodStud,
area: 100,
solar_absorptance: 0.7,
emittance: 0.92,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 23.0)
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherNonFreezingSpace,
interior_adjacent_to: HPXML::LocationConditionedSpace,
wall_type: HPXML::WallTypeWoodStud,
area: 100,
solar_absorptance: 0.7,
emittance: 0.92,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 23.0)
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherHousingUnit,
interior_adjacent_to: HPXML::LocationConditionedSpace,
wall_type: HPXML::WallTypeWoodStud,
area: 100,
solar_absorptance: 0.7,
emittance: 0.92,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 4.0)
hpxml_bldg.floors[0].delete
hpxml_bldg.floors[0].id = 'Floor1'
hpxml_bldg.floors[0].insulation_id = 'Floor1Insulation'
hpxml_bldg.floors.add(id: "Floor#{hpxml_bldg.floors.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherNonFreezingSpace,
interior_adjacent_to: HPXML::LocationConditionedSpace,
floor_type: HPXML::FloorTypeWoodFrame,
area: 550,
insulation_assembly_r_value: 18.7,
floor_or_ceiling: HPXML::FloorOrCeilingFloor)
hpxml_bldg.floors.add(id: "Floor#{hpxml_bldg.floors.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherMultifamilyBufferSpace,
interior_adjacent_to: HPXML::LocationConditionedSpace,
floor_type: HPXML::FloorTypeWoodFrame,
area: 200,
insulation_assembly_r_value: 18.7,
floor_or_ceiling: HPXML::FloorOrCeilingFloor)
hpxml_bldg.floors.add(id: "Floor#{hpxml_bldg.floors.size + 1}",
exterior_adjacent_to: HPXML::LocationOtherHeatedSpace,
interior_adjacent_to: HPXML::LocationConditionedSpace,
floor_type: HPXML::FloorTypeWoodFrame,
area: 150,
insulation_assembly_r_value: 2.1,
floor_or_ceiling: HPXML::FloorOrCeilingFloor)
wall = hpxml_bldg.walls.select { |w|
w.interior_adjacent_to == HPXML::LocationConditionedSpace &&
w.exterior_adjacent_to == HPXML::LocationOtherMultifamilyBufferSpace
}[0]
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 50,
azimuth: 270,
ufactor: 0.33,
shgc: 0.45,
fraction_operable: 0.67,
attached_to_wall_idref: wall.id)
wall = hpxml_bldg.walls.select { |w|
w.interior_adjacent_to == HPXML::LocationConditionedSpace &&
w.exterior_adjacent_to == HPXML::LocationOtherHeatedSpace
}[0]
hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}",
attached_to_wall_idref: wall.id,
area: 20,
azimuth: 0,
r_value: 4.4)
wall = hpxml_bldg.walls.select { |w|
w.interior_adjacent_to == HPXML::LocationConditionedSpace &&
w.exterior_adjacent_to == HPXML::LocationOtherHousingUnit
}[0]
hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}",
attached_to_wall_idref: wall.id,
area: 20,
azimuth: 0,
r_value: 4.4)
elsif ['base-enclosure-orientations.xml'].include? hpxml_file
hpxml_bldg.windows.each do |window|
window.orientation = { 0 => 'north', 90 => 'east', 180 => 'south', 270 => 'west' }[window.azimuth]
window.azimuth = nil
end
hpxml_bldg.doors[0].delete
hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}",
attached_to_wall_idref: 'Wall1',
area: 20,
orientation: HPXML::OrientationNorth,
r_value: 4.4)
hpxml_bldg.doors.add(id: "Door#{hpxml_bldg.doors.size + 1}",
attached_to_wall_idref: 'Wall1',
area: 20,
orientation: HPXML::OrientationSouth,
r_value: 4.4)
elsif ['base-foundation-unconditioned-basement.xml'].include? hpxml_file
hpxml_bldg.foundations[0].within_infiltration_volume = false
elsif ['base-atticroof-conditioned.xml'].include? hpxml_file
hpxml_bldg.attics.add(id: "Attic#{hpxml_bldg.attics.size + 1}",
attic_type: HPXML::AtticTypeUnvented,
within_infiltration_volume: false)
hpxml_bldg.roofs.each do |roof|
roof.area = 1006.0 / hpxml_bldg.roofs.size
roof.insulation_assembly_r_value = 25.8
end
hpxml_bldg.roofs.add(id: "Roof#{hpxml_bldg.roofs.size + 1}",
interior_adjacent_to: HPXML::LocationAtticUnvented,
area: 504,
roof_type: HPXML::RoofTypeAsphaltShingles,
solar_absorptance: 0.7,
emittance: 0.92,
pitch: 6,
radiant_barrier: false,
insulation_assembly_r_value: 2.3)
hpxml_bldg.rim_joists.each do |rim_joist|
rim_joist.area = 116.0 / hpxml_bldg.rim_joists.size
end
hpxml_bldg.walls.each do |wall|
wall.area = 1200.0 / hpxml_bldg.walls.size
end
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationAtticUnvented,
interior_adjacent_to: HPXML::LocationConditionedSpace,
wall_type: HPXML::WallTypeWoodStud,
area: 316,
solar_absorptance: 0.7,
emittance: 0.92,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 23.0)
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationOutside,
interior_adjacent_to: HPXML::LocationConditionedSpace,
wall_type: HPXML::WallTypeWoodStud,
siding: HPXML::SidingTypeWood,
area: 240,
solar_absorptance: 0.7,
emittance: 0.92,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 22.3)
hpxml_bldg.walls.add(id: "Wall#{hpxml_bldg.walls.size + 1}",
exterior_adjacent_to: HPXML::LocationOutside,
interior_adjacent_to: HPXML::LocationAtticUnvented,
attic_wall_type: HPXML::AtticWallTypeGable,
wall_type: HPXML::WallTypeWoodStud,
siding: HPXML::SidingTypeWood,
area: 50,
solar_absorptance: 0.7,
emittance: 0.92,
insulation_assembly_r_value: 4.0)
hpxml_bldg.foundation_walls.each do |foundation_wall|
foundation_wall.area = 1200.0 / hpxml_bldg.foundation_walls.size
end
hpxml_bldg.floors.add(id: "Floor#{hpxml_bldg.floors.size + 1}",
exterior_adjacent_to: HPXML::LocationAtticUnvented,
interior_adjacent_to: HPXML::LocationConditionedSpace,
floor_type: HPXML::FloorTypeWoodFrame,
area: 450,
interior_finish_type: HPXML::InteriorFinishGypsumBoard,
insulation_assembly_r_value: 39.3,
floor_or_ceiling: HPXML::FloorOrCeilingCeiling)
hpxml_bldg.slabs[0].area = 1350
hpxml_bldg.slabs[0].exposed_perimeter = 150
hpxml_bldg.windows[1].area = 108
hpxml_bldg.windows[3].area = 108
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 12,
azimuth: 90,
ufactor: 0.33,
shgc: 0.45,
fraction_operable: 0,
attached_to_wall_idref: hpxml_bldg.walls[-2].id)
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 62,
azimuth: 270,
ufactor: 0.3,
shgc: 0.45,
fraction_operable: 0,
attached_to_wall_idref: hpxml_bldg.walls[-2].id)
elsif ['base-foundation-unconditioned-basement-above-grade.xml'].include? hpxml_file
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 20,
azimuth: 0,
ufactor: 0.33,
shgc: 0.45,
fraction_operable: 0.0,
attached_to_wall_idref: hpxml_bldg.foundation_walls[0].id)
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 10,
azimuth: 90,
ufactor: 0.33,
shgc: 0.45,
fraction_operable: 0.0,
attached_to_wall_idref: hpxml_bldg.foundation_walls[0].id)
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 20,
azimuth: 180,
ufactor: 0.33,
shgc: 0.45,
fraction_operable: 0.0,
attached_to_wall_idref: hpxml_bldg.foundation_walls[0].id)
hpxml_bldg.windows.add(id: "Window#{hpxml_bldg.windows.size + 1}",
area: 10,
azimuth: 270,
ufactor: 0.33,
shgc: 0.45,
fraction_operable: 0.0,
attached_to_wall_idref: hpxml_bldg.foundation_walls[0].id)
elsif hpxml_file.include? 'base-enclosure-skylights-cathedral.xml'
hpxml_bldg.skylights.each do |skylight|
skylight.curb_area = 5.25
skylight.curb_assembly_r_value = 1.96
end
elsif hpxml_file.include? 'base-enclosure-skylights'
hpxml_bldg.skylights.each do |skylight|
skylight.shaft_area = 60.0
skylight.shaft_assembly_r_value = 6.25
end
if ['base-enclosure-skylights-physical-properties.xml'].include? hpxml_file
hpxml_bldg.skylights[0].ufactor = nil
hpxml_bldg.skylights[0].shgc = nil
hpxml_bldg.skylights[0].glass_layers = HPXML::WindowLayersSinglePane
hpxml_bldg.skylights[0].frame_type = HPXML::WindowFrameTypeWood
hpxml_bldg.skylights[0].glass_type = HPXML::WindowGlassTypeTinted
hpxml_bldg.skylights[1].ufactor = nil
hpxml_bldg.skylights[1].shgc = nil
hpxml_bldg.skylights[1].glass_layers = HPXML::WindowLayersDoublePane
hpxml_bldg.skylights[1].frame_type = HPXML::WindowFrameTypeMetal
hpxml_bldg.skylights[1].thermal_break = true
hpxml_bldg.skylights[1].glass_type = HPXML::WindowGlassTypeLowE
hpxml_bldg.skylights[1].gas_fill = HPXML::WindowGasKrypton
elsif ['base-enclosure-skylights-shading.xml'].include? hpxml_file
hpxml_bldg.skylights[0].exterior_shading_factor_summer = 0.1
hpxml_bldg.skylights[0].exterior_shading_factor_winter = 0.9
hpxml_bldg.skylights[0].interior_shading_factor_summer = 0.01
hpxml_bldg.skylights[0].interior_shading_factor_winter = 0.99
hpxml_bldg.skylights[1].exterior_shading_factor_summer = 0.5
hpxml_bldg.skylights[1].exterior_shading_factor_winter = 0.0
hpxml_bldg.skylights[1].interior_shading_factor_summer = 0.5
hpxml_bldg.skylights[1].interior_shading_factor_winter = 1.0
end
elsif ['base-enclosure-windows-physical-properties.xml'].include? hpxml_file
hpxml_bldg.windows[0].ufactor = nil
hpxml_bldg.windows[0].shgc = nil
hpxml_bldg.windows[0].glass_layers = HPXML::WindowLayersSinglePane
hpxml_bldg.windows[0].frame_type = HPXML::WindowFrameTypeWood
hpxml_bldg.windows[0].glass_type = HPXML::WindowGlassTypeTinted
hpxml_bldg.windows[1].ufactor = nil
hpxml_bldg.windows[1].shgc = nil
hpxml_bldg.windows[1].glass_layers = HPXML::WindowLayersDoublePane
hpxml_bldg.windows[1].frame_type = HPXML::WindowFrameTypeVinyl
hpxml_bldg.windows[1].glass_type = HPXML::WindowGlassTypeLowELowSolarGain
hpxml_bldg.windows[1].gas_fill = HPXML::WindowGasAir
hpxml_bldg.windows[2].ufactor = nil
hpxml_bldg.windows[2].shgc = nil
hpxml_bldg.windows[2].glass_layers = HPXML::WindowLayersDoublePane
hpxml_bldg.windows[2].frame_type = HPXML::WindowFrameTypeMetal
hpxml_bldg.windows[2].thermal_break = true
hpxml_bldg.windows[2].glass_type = HPXML::WindowGlassTypeLowE
hpxml_bldg.windows[2].gas_fill = HPXML::WindowGasArgon
hpxml_bldg.windows[3].ufactor = nil
hpxml_bldg.windows[3].shgc = nil
hpxml_bldg.windows[3].glass_layers = HPXML::WindowLayersGlassBlock
elsif ['base-enclosure-windows-shading-factors.xml'].include? hpxml_file
hpxml_bldg.windows[1].exterior_shading_factor_summer = 0.5
hpxml_bldg.windows[1].exterior_shading_factor_winter = 0.5
hpxml_bldg.windows[1].interior_shading_factor_summer = 0.5
hpxml_bldg.windows[1].interior_shading_factor_winter = 0.5
hpxml_bldg.windows[2].exterior_shading_factor_summer = 0.1
hpxml_bldg.windows[2].exterior_shading_factor_winter = 0.9
hpxml_bldg.windows[2].interior_shading_factor_summer = 0.01
hpxml_bldg.windows[2].interior_shading_factor_winter = 0.99
hpxml_bldg.windows[3].exterior_shading_factor_summer = 0.0
hpxml_bldg.windows[3].exterior_shading_factor_winter = 1.0
hpxml_bldg.windows[3].interior_shading_factor_summer = 0.0
hpxml_bldg.windows[3].interior_shading_factor_winter = 1.0
elsif ['base-enclosure-windows-shading-types-detailed.xml'].include? hpxml_file
hpxml_bldg.windows.each do |window|
window.interior_shading_factor_summer = nil
window.interior_shading_factor_winter = nil
window.exterior_shading_factor_summer = nil
window.exterior_shading_factor_winter = nil
end
# Interior shading
hpxml_bldg.windows[0].interior_shading_type = HPXML::InteriorShadingTypeNone
hpxml_bldg.windows[1].interior_shading_type = HPXML::InteriorShadingTypeOther
hpxml_bldg.windows[2].interior_shading_type = HPXML::InteriorShadingTypeMediumCurtains
hpxml_bldg.windows[2].interior_shading_coverage_summer = 0.5
hpxml_bldg.windows[2].interior_shading_coverage_winter = 0.0
hpxml_bldg.windows[3].interior_shading_type = HPXML::InteriorShadingTypeLightBlinds
hpxml_bldg.windows[3].interior_shading_blinds_summer_closed_or_open = HPXML::BlindsClosed
hpxml_bldg.windows[3].interior_shading_blinds_winter_closed_or_open = HPXML::BlindsHalfOpen
hpxml_bldg.windows[3].interior_shading_coverage_summer = 0.5
hpxml_bldg.windows[3].interior_shading_coverage_winter = 1.0
# Exterior shading
hpxml_bldg.windows[0].exterior_shading_type = HPXML::ExteriorShadingTypeDeciduousTree
hpxml_bldg.windows[1].exterior_shading_type = HPXML::ExteriorShadingTypeSolarScreens
hpxml_bldg.windows[2].exterior_shading_type = HPXML::ExteriorShadingTypeExternalOverhangs
hpxml_bldg.windows[2].overhangs_depth = 2.0
hpxml_bldg.windows[2].overhangs_distance_to_top_of_window = 1.0
hpxml_bldg.windows[2].overhangs_distance_to_bottom_of_window = 4.0
hpxml_bldg.windows[3].exterior_shading_type = HPXML::ExteriorShadingTypeBuilding
# Insect screens
hpxml_bldg.windows[0].insect_screen_present = true
hpxml_bldg.windows[0].insect_screen_location = HPXML::LocationInterior
hpxml_bldg.windows[0].insect_screen_coverage_summer = 1.0
hpxml_bldg.windows[0].insect_screen_coverage_winter = 0.0
hpxml_bldg.windows[1].insect_screen_present = true
hpxml_bldg.windows[1].insect_screen_location = HPXML::LocationExterior
hpxml_bldg.windows[1].insect_screen_coverage_summer = 1.0
hpxml_bldg.windows[1].insect_screen_coverage_winter = 1.0
hpxml_bldg.windows[2].insect_screen_present = true
hpxml_bldg.windows[2].insect_screen_location = HPXML::LocationExterior
hpxml_bldg.windows[3].insect_screen_present = true
elsif ['base-enclosure-thermal-mass.xml'].include? hpxml_file
hpxml_bldg.partition_wall_mass.area_fraction = 0.8
hpxml_bldg.partition_wall_mass.interior_finish_type = HPXML::InteriorFinishGypsumBoard
hpxml_bldg.partition_wall_mass.interior_finish_thickness = 0.25
hpxml_bldg.furniture_mass.area_fraction = 0.8
hpxml_bldg.furniture_mass.type = HPXML::FurnitureMassTypeHeavyWeight
elsif ['base-misc-defaults.xml'].include? hpxml_file
hpxml_bldg.attics.reverse_each do |attic|
attic.delete
end
hpxml_bldg.foundations.reverse_each do |foundation|