-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgeometry.rb
2045 lines (1803 loc) · 95.9 KB
/
geometry.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
# Collection of methods related to geometry.
module Geometry
# Adds any HPXML Roofs to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @return [nil]
def self.apply_roofs(runner, model, spaces, hpxml_bldg, hpxml_header)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
walls_top, _foundation_top = get_foundation_and_walls_top(hpxml_bldg)
hpxml_bldg.roofs.each do |roof|
next if roof.net_area < 1.0 # skip modeling net surface area for surfaces comprised entirely of subsurface area
if roof.azimuth.nil?
if roof.pitch > 0
azimuths = default_azimuths # Model as four directions for average exterior incident solar
else
azimuths = [default_azimuths[0]] # Arbitrary azimuth for flat roof
end
else
azimuths = [roof.azimuth]
end
surfaces = []
azimuths.each do |azimuth|
width = Math::sqrt(roof.net_area)
length = (roof.net_area / width) / azimuths.size
tilt = roof.pitch / 12.0
z_origin = walls_top + 0.5 * Math.sin(Math.atan(tilt)) * width
vertices = create_roof_vertices(length, width, z_origin, azimuth, tilt)
surface = OpenStudio::Model::Surface.new(vertices, model)
surfaces << surface
surface.additionalProperties.setFeature('Length', length)
surface.additionalProperties.setFeature('Width', width)
surface.additionalProperties.setFeature('Azimuth', azimuth)
surface.additionalProperties.setFeature('Tilt', tilt)
surface.additionalProperties.setFeature('SurfaceType', 'Roof')
if azimuths.size > 1
surface.setName("#{roof.id}:#{azimuth}")
else
surface.setName(roof.id)
end
surface.setSurfaceType(EPlus::SurfaceTypeRoofCeiling)
surface.setOutsideBoundaryCondition(EPlus::BoundaryConditionOutdoors)
set_surface_interior(model, spaces, surface, roof, hpxml_bldg)
end
next if surfaces.empty?
# Apply construction
has_radiant_barrier = roof.radiant_barrier
if has_radiant_barrier
radiant_barrier_grade = roof.radiant_barrier_grade
end
# FUTURE: Create Constructions.get_air_film(surface) method; use in measure.rb and hpxml_translator_test.rb
inside_film = Material.AirFilmRoof(get_roof_pitch([surfaces[0]]))
outside_film = Material.AirFilmOutside
mat_roofing = Material.RoofMaterial(roof.roof_type)
if hpxml_header.apply_ashrae140_assumptions
inside_film = Material.AirFilmRoofASHRAE140
outside_film = Material.AirFilmOutsideASHRAE140
end
mat_int_finish = Material.InteriorFinishMaterial(roof.interior_finish_type, roof.interior_finish_thickness)
if mat_int_finish.nil?
fallback_mat_int_finish = nil
else
fallback_mat_int_finish = Material.InteriorFinishMaterial(mat_int_finish.name, 0.1) # Try thin material
end
install_grade = 1
assembly_r = roof.insulation_assembly_r_value
if not mat_int_finish.nil?
# Closed cavity
constr_sets = [
WoodStudConstructionSet.new(Material.Stud2x(8.0), 0.07, 20.0, 0.75, mat_int_finish, mat_roofing), # 2x8, 24" o.c. + R20
WoodStudConstructionSet.new(Material.Stud2x(8.0), 0.07, 10.0, 0.75, mat_int_finish, mat_roofing), # 2x8, 24" o.c. + R10
WoodStudConstructionSet.new(Material.Stud2x(8.0), 0.07, 0.0, 0.75, mat_int_finish, mat_roofing), # 2x8, 24" o.c.
WoodStudConstructionSet.new(Material.Stud2x6, 0.07, 0.0, 0.75, mat_int_finish, mat_roofing), # 2x6, 24" o.c.
WoodStudConstructionSet.new(Material.Stud2x4, 0.07, 0.0, 0.5, mat_int_finish, mat_roofing), # 2x4, 16" o.c.
WoodStudConstructionSet.new(Material.Stud2x4, 0.01, 0.0, 0.0, fallback_mat_int_finish, mat_roofing), # Fallback
]
match, constr_set, cavity_r = Constructions.pick_wood_stud_construction_set(assembly_r, constr_sets, inside_film, outside_film)
Constructions.apply_closed_cavity_roof(model, surfaces, "#{roof.id} construction",
cavity_r, install_grade,
constr_set.stud.thick_in,
true, constr_set.framing_factor,
constr_set.mat_int_finish,
constr_set.osb_thick_in, constr_set.rigid_r,
constr_set.mat_ext_finish, has_radiant_barrier,
inside_film, outside_film, radiant_barrier_grade,
roof.solar_absorptance, roof.emittance)
else
# Open cavity
constr_sets = [
GenericConstructionSet.new(10.0, 0.5, nil, mat_roofing), # w/R-10 rigid
GenericConstructionSet.new(0.0, 0.5, nil, mat_roofing), # Standard
GenericConstructionSet.new(0.0, 0.0, nil, mat_roofing), # Fallback
]
match, constr_set, layer_r = Constructions.pick_generic_construction_set(assembly_r, constr_sets, inside_film, outside_film)
cavity_r = 0
cavity_ins_thick_in = 0
framing_factor = 0
framing_thick_in = 0
Constructions.apply_open_cavity_roof(model, surfaces, "#{roof.id} construction",
cavity_r, install_grade, cavity_ins_thick_in,
framing_factor, framing_thick_in,
constr_set.osb_thick_in, layer_r + constr_set.rigid_r,
constr_set.mat_ext_finish, has_radiant_barrier,
inside_film, outside_film, radiant_barrier_grade,
roof.solar_absorptance, roof.emittance)
end
Constructions.check_surface_assembly_rvalue(runner, surfaces, inside_film, outside_film, assembly_r, match)
end
end
# Adds any HPXML Walls to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @return [nil]
def self.apply_walls(runner, model, spaces, hpxml_bldg, hpxml_header)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
_walls_top, foundation_top = get_foundation_and_walls_top(hpxml_bldg)
hpxml_bldg.walls.each do |wall|
next if wall.net_area < 1.0 # skip modeling net surface area for surfaces comprised entirely of subsurface area
if wall.azimuth.nil?
if wall.is_exterior
azimuths = default_azimuths # Model as four directions for average exterior incident solar
else
azimuths = [default_azimuths[0]] # Arbitrary direction, doesn't receive exterior incident solar
end
else
azimuths = [wall.azimuth]
end
surfaces = []
azimuths.each do |azimuth|
height = 8.0 * hpxml_bldg.building_construction.number_of_conditioned_floors_above_grade
length = (wall.net_area / height) / azimuths.size
z_origin = foundation_top
vertices = create_wall_vertices(length, height, z_origin, azimuth)
surface = OpenStudio::Model::Surface.new(vertices, model)
surfaces << surface
surface.additionalProperties.setFeature('Length', length)
surface.additionalProperties.setFeature('Azimuth', azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'Wall')
if azimuths.size > 1
surface.setName("#{wall.id}:#{azimuth}")
else
surface.setName(wall.id)
end
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, wall, hpxml_bldg)
set_surface_exterior(model, spaces, surface, wall, hpxml_bldg)
if wall.is_interior
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
end
end
next if surfaces.empty?
# Apply construction
# The code below constructs a reasonable wall construction based on the
# wall type while ensuring the correct assembly R-value.
has_radiant_barrier = wall.radiant_barrier
if has_radiant_barrier
radiant_barrier_grade = wall.radiant_barrier_grade
end
inside_film = Material.AirFilmVertical
if wall.is_exterior
outside_film = Material.AirFilmOutside
mat_ext_finish = Material.ExteriorFinishMaterial(wall.siding)
else
outside_film = Material.AirFilmVertical
mat_ext_finish = nil
end
if hpxml_header.apply_ashrae140_assumptions
inside_film = Material.AirFilmVerticalASHRAE140
outside_film = Material.AirFilmOutsideASHRAE140
end
mat_int_finish = Material.InteriorFinishMaterial(wall.interior_finish_type, wall.interior_finish_thickness)
Constructions.apply_wall_construction(runner, model, surfaces, wall.id, wall.wall_type, wall.insulation_assembly_r_value,
mat_int_finish, has_radiant_barrier, inside_film, outside_film,
radiant_barrier_grade, mat_ext_finish, wall.solar_absorptance,
wall.emittance)
end
end
# Adds any HPXML RimJoists to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [nil]
def self.apply_rim_joists(runner, model, spaces, hpxml_bldg)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
_walls_top, foundation_top = get_foundation_and_walls_top(hpxml_bldg)
hpxml_bldg.rim_joists.each do |rim_joist|
if rim_joist.azimuth.nil?
if rim_joist.is_exterior
azimuths = default_azimuths # Model as four directions for average exterior incident solar
else
azimuths = [default_azimuths[0]] # Arbitrary direction, doesn't receive exterior incident solar
end
else
azimuths = [rim_joist.azimuth]
end
surfaces = []
azimuths.each do |azimuth|
height = 1.0
length = (rim_joist.area / height) / azimuths.size
z_origin = foundation_top
vertices = create_wall_vertices(length, height, z_origin, azimuth)
surface = OpenStudio::Model::Surface.new(vertices, model)
surfaces << surface
surface.additionalProperties.setFeature('Length', length)
surface.additionalProperties.setFeature('Azimuth', azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'RimJoist')
if azimuths.size > 1
surface.setName("#{rim_joist.id}:#{azimuth}")
else
surface.setName(rim_joist.id)
end
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, rim_joist, hpxml_bldg)
set_surface_exterior(model, spaces, surface, rim_joist, hpxml_bldg)
if rim_joist.is_interior
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
end
end
# Apply construction
inside_film = Material.AirFilmVertical
if rim_joist.is_exterior
outside_film = Material.AirFilmOutside
mat_ext_finish = Material.ExteriorFinishMaterial(rim_joist.siding)
else
outside_film = Material.AirFilmVertical
mat_ext_finish = nil
end
assembly_r = rim_joist.insulation_assembly_r_value
constr_sets = [
WoodStudConstructionSet.new(Material.Stud2x(2.0), 0.17, 20.0, 2.0, nil, mat_ext_finish), # 2x4 + R20
WoodStudConstructionSet.new(Material.Stud2x(2.0), 0.17, 10.0, 2.0, nil, mat_ext_finish), # 2x4 + R10
WoodStudConstructionSet.new(Material.Stud2x(2.0), 0.17, 0.0, 2.0, nil, mat_ext_finish), # 2x4
WoodStudConstructionSet.new(Material.Stud2x(2.0), 0.01, 0.0, 0.0, nil, mat_ext_finish), # Fallback
]
match, constr_set, cavity_r = Constructions.pick_wood_stud_construction_set(assembly_r, constr_sets, inside_film, outside_film)
install_grade = 1
Constructions.apply_rim_joist(model, surfaces, "#{rim_joist.id} construction",
cavity_r, install_grade, constr_set.framing_factor,
constr_set.mat_int_finish, constr_set.osb_thick_in,
constr_set.rigid_r, constr_set.mat_ext_finish,
inside_film, outside_film, rim_joist.solar_absorptance,
rim_joist.emittance)
Constructions.check_surface_assembly_rvalue(runner, surfaces, inside_film, outside_film, assembly_r, match)
end
end
# Adds any HPXML Floors to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @return [nil]
def self.apply_floors(runner, model, spaces, hpxml_bldg, hpxml_header)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
walls_top, foundation_top = get_foundation_and_walls_top(hpxml_bldg)
hpxml_bldg.floors.each do |floor|
next if floor.net_area < 1.0 # skip modeling net surface area for surfaces comprised entirely of subsurface area
area = floor.net_area
width = Math::sqrt(area)
length = area / width
if floor.interior_adjacent_to.include?('attic') || floor.exterior_adjacent_to.include?('attic')
z_origin = walls_top
else
z_origin = foundation_top
end
if floor.is_ceiling
vertices = create_ceiling_vertices(length, width, z_origin, default_azimuths)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('SurfaceType', 'Ceiling')
else
vertices = create_floor_vertices(length, width, z_origin, default_azimuths)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('SurfaceType', 'Floor')
end
surface.additionalProperties.setFeature('Tilt', 0.0)
set_surface_interior(model, spaces, surface, floor, hpxml_bldg)
set_surface_exterior(model, spaces, surface, floor, hpxml_bldg)
surface.setName(floor.id)
if floor.is_interior
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
elsif floor.is_floor
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
if floor.exterior_adjacent_to == HPXML::LocationManufacturedHomeUnderBelly
foundation = hpxml_bldg.foundations.find { |x| x.to_location == floor.exterior_adjacent_to }
if foundation.belly_wing_skirt_present
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
end
end
end
# Apply construction
if floor.is_ceiling
if hpxml_header.apply_ashrae140_assumptions
# Attic floor
inside_film = Material.AirFilmFloorASHRAE140
outside_film = Material.AirFilmFloorASHRAE140
else
inside_film = Material.AirFilmFloorAverage
outside_film = Material.AirFilmFloorAverage
end
mat_int_finish_or_covering = Material.InteriorFinishMaterial(floor.interior_finish_type, floor.interior_finish_thickness)
has_radiant_barrier = floor.radiant_barrier
if has_radiant_barrier
radiant_barrier_grade = floor.radiant_barrier_grade
end
else # Floor
if hpxml_header.apply_ashrae140_assumptions
# Raised floor
inside_film = Material.AirFilmFloorASHRAE140
outside_film = Material.AirFilmFloorZeroWindASHRAE140
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
mat_int_finish_or_covering = Material.CoveringBare(1.0)
else
inside_film = Material.AirFilmFloorReduced
if floor.is_exterior
outside_film = Material.AirFilmOutside
else
outside_film = Material.AirFilmFloorReduced
end
if floor.interior_adjacent_to == HPXML::LocationConditionedSpace
mat_int_finish_or_covering = Material.CoveringBare
end
end
end
Constructions.apply_floor_ceiling_construction(runner, model, [surface], floor.id, floor.floor_type, floor.is_ceiling, floor.insulation_assembly_r_value,
mat_int_finish_or_covering, has_radiant_barrier, inside_film, outside_film, radiant_barrier_grade)
end
end
# Adds any HPXML Foundation Walls and Slabs to the OpenStudio model.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param weather [WeatherFile] Weather object containing EPW information
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @return [nil]
def self.apply_foundation_walls_slabs(runner, model, spaces, weather, hpxml_bldg, hpxml_header, schedules_file)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
foundation_types = hpxml_bldg.slabs.map { |s| s.interior_adjacent_to }.uniq
foundation_types.each do |foundation_type|
# Get attached slabs/foundation walls
slabs = []
hpxml_bldg.slabs.each do |slab|
next unless slab.interior_adjacent_to == foundation_type
slabs << slab
slab.exposed_perimeter = [slab.exposed_perimeter, 1.0].max # minimum value to prevent error if no exposed slab
end
slabs.each do |slab|
slab_frac = slab.exposed_perimeter / slabs.map { |s| s.exposed_perimeter }.sum
ext_fnd_walls = slab.connected_foundation_walls.select { |fw| fw.net_area >= 1.0 && fw.is_exterior }
if ext_fnd_walls.empty?
# Slab w/o foundation walls
apply_foundation_slab(model, weather, spaces, hpxml_bldg, hpxml_header, slab, -1 * slab.depth_below_grade.to_f, slab.exposed_perimeter, nil, default_azimuths, schedules_file)
else
# Slab w/ foundation walls
ext_fnd_walls_length = ext_fnd_walls.map { |fw| fw.area / fw.height }.sum
remaining_exposed_length = slab.exposed_perimeter
# Since we don't know which FoundationWalls are adjacent to which Slabs, we apportion
# each FoundationWall to each slab.
ext_fnd_walls.each do |fnd_wall|
# Both the foundation wall and slab must have same exposed length to prevent Kiva errors.
# For the foundation wall, we are effectively modeling the net *exposed* area.
fnd_wall_length = fnd_wall.area / fnd_wall.height
apportioned_exposed_length = fnd_wall_length / ext_fnd_walls_length * slab.exposed_perimeter # Slab exposed perimeter apportioned to this foundation wall
apportioned_total_length = fnd_wall_length * slab_frac # Foundation wall length apportioned to this slab
exposed_length = [apportioned_exposed_length, apportioned_total_length].min
remaining_exposed_length -= exposed_length
kiva_foundation = apply_foundation_wall(runner, model, spaces, hpxml_bldg, fnd_wall, exposed_length, fnd_wall_length, default_azimuths)
apply_foundation_slab(model, weather, spaces, hpxml_bldg, hpxml_header, slab, -1 * fnd_wall.depth_below_grade, exposed_length, kiva_foundation, default_azimuths, schedules_file)
end
if remaining_exposed_length > 1 # Skip if a small length (e.g., due to rounding)
# The slab's exposed perimeter exceeds the sum of attached exterior foundation wall lengths.
# This may legitimately occur for a walkout basement, where a portion of the slab has no
# adjacent foundation wall.
apply_foundation_slab(model, weather, spaces, hpxml_bldg, hpxml_header, slab, 0, remaining_exposed_length, nil, default_azimuths, schedules_file)
end
end
end
# Interzonal foundation wall surfaces
# The above-grade portion of these walls are modeled as EnergyPlus surfaces with standard adjacency.
# The below-grade portion of these walls (in contact with ground) are not modeled, as Kiva does not
# calculate heat flow between two zones through the ground.
int_fnd_walls = hpxml_bldg.foundation_walls.select { |fw| fw.is_interior && fw.interior_adjacent_to == foundation_type }
int_fnd_walls.each do |fnd_wall|
next unless fnd_wall.is_interior
ag_height = fnd_wall.height - fnd_wall.depth_below_grade
ag_net_area = fnd_wall.net_area * ag_height / fnd_wall.height
next if ag_net_area < 1.0
length = ag_net_area / ag_height
z_origin = -1 * ag_height
if fnd_wall.azimuth.nil?
azimuth = default_azimuths[0] # Arbitrary direction, doesn't receive exterior incident solar
else
azimuth = fnd_wall.azimuth
end
vertices = create_wall_vertices(length, ag_height, z_origin, azimuth)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', length)
surface.additionalProperties.setFeature('Azimuth', azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'FoundationWall')
surface.setName(fnd_wall.id)
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, fnd_wall, hpxml_bldg)
set_surface_exterior(model, spaces, surface, fnd_wall, hpxml_bldg)
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
# Apply construction
wall_type = HPXML::WallTypeConcrete
inside_film = Material.AirFilmVertical
outside_film = Material.AirFilmVertical
assembly_r = fnd_wall.insulation_assembly_r_value
mat_int_finish = Material.InteriorFinishMaterial(fnd_wall.interior_finish_type, fnd_wall.interior_finish_thickness)
if assembly_r.nil?
concrete_thick_in = fnd_wall.thickness
int_r = fnd_wall.insulation_interior_r_value
ext_r = fnd_wall.insulation_exterior_r_value
mat_concrete = Material.Concrete(concrete_thick_in)
mat_int_finish_rvalue = mat_int_finish.nil? ? 0.0 : mat_int_finish.rvalue
assembly_r = int_r + ext_r + mat_concrete.rvalue + mat_int_finish_rvalue + inside_film.rvalue + outside_film.rvalue
end
mat_ext_finish = nil
Constructions.apply_wall_construction(runner, model, [surface], fnd_wall.id, wall_type, assembly_r, mat_int_finish,
false, inside_film, outside_film, nil, mat_ext_finish, nil, nil)
end
end
end
# Adds an HPXML Foundation Wall to the OpenStudio model.
#
# Note: Since we don't know which FoundationWalls are adjacent to which Slabs, we may call this method multiple times
# for the same HPXML Foundation Wall, each time with a different exposed_length and fnd_wall_length, specific to an
# adjacent HPXML Slab.
#
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param foundation_wall [HPXML::FoundationWall] The HPXML foundation wall of interest
# @param exposed_length [Double] Length of foundation wall exposed to ambient conditions, specific to an associated HPXML Slab (ft)
# @param fnd_wall_length [Double] The total length of the foundation wall (ft)
# @param default_azimuths [Array<Double>] Default azimuths for the four sides of the home, used for surfaces without an orientation
# @return [OpenStudio::Model::FoundationKiva] OpenStudio Foundation Kiva object
def self.apply_foundation_wall(runner, model, spaces, hpxml_bldg, foundation_wall, exposed_length, fnd_wall_length, default_azimuths)
exposed_fraction = exposed_length / fnd_wall_length
net_exposed_area = foundation_wall.net_area * exposed_fraction
gross_exposed_area = foundation_wall.area * exposed_fraction
height = foundation_wall.height
height_ag = height - foundation_wall.depth_below_grade
z_origin = -1 * foundation_wall.depth_below_grade
if foundation_wall.azimuth.nil?
azimuth = default_azimuths[0] # Arbitrary; solar incidence in Kiva is applied as an orientation average (to the above grade portion of the wall)
else
azimuth = foundation_wall.azimuth
end
return if exposed_length < 0.1 # Avoid Kiva error if exposed wall length is too small
if gross_exposed_area > net_exposed_area
# Create a "notch" in the wall to account for the subsurfaces. This ensures that
# we preserve the appropriate wall height, length, and area for Kiva.
subsurface_area = gross_exposed_area - net_exposed_area
else
subsurface_area = 0
end
vertices = create_wall_vertices(exposed_length, height, z_origin, azimuth, subsurface_area: subsurface_area)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', exposed_length)
surface.additionalProperties.setFeature('Azimuth', azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'FoundationWall')
surface.setName(foundation_wall.id)
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, foundation_wall, hpxml_bldg)
set_surface_exterior(model, spaces, surface, foundation_wall, hpxml_bldg)
assembly_r = foundation_wall.insulation_assembly_r_value
mat_int_finish = Material.InteriorFinishMaterial(foundation_wall.interior_finish_type, foundation_wall.interior_finish_thickness)
mat_wall = Material.FoundationWallMaterial(foundation_wall.type, foundation_wall.thickness)
if not assembly_r.nil?
ext_rigid_height = height
ext_rigid_offset = 0.0
inside_film = Material.AirFilmVertical
mat_int_finish_rvalue = mat_int_finish.nil? ? 0.0 : mat_int_finish.rvalue
ext_rigid_r = assembly_r - mat_wall.rvalue - mat_int_finish_rvalue - inside_film.rvalue
int_rigid_r = 0.0
if ext_rigid_r < 0 # Try without interior finish
mat_int_finish = nil
ext_rigid_r = assembly_r - mat_wall.rvalue - inside_film.rvalue
end
if (ext_rigid_r > 0) && (ext_rigid_r < 0.1)
ext_rigid_r = 0.0 # Prevent tiny strip of insulation
end
if ext_rigid_r < 0
ext_rigid_r = 0.0
match = false
else
match = true
end
else
ext_rigid_offset = foundation_wall.insulation_exterior_distance_to_top
ext_rigid_height = foundation_wall.insulation_exterior_distance_to_bottom - ext_rigid_offset
ext_rigid_r = foundation_wall.insulation_exterior_r_value
int_rigid_offset = foundation_wall.insulation_interior_distance_to_top
int_rigid_height = foundation_wall.insulation_interior_distance_to_bottom - int_rigid_offset
int_rigid_r = foundation_wall.insulation_interior_r_value
end
soil_k_in = UnitConversions.convert(hpxml_bldg.site.ground_conductivity, 'ft', 'in')
Constructions.apply_foundation_wall(model, [surface], "#{foundation_wall.id} construction",
ext_rigid_offset, int_rigid_offset, ext_rigid_height, int_rigid_height,
ext_rigid_r, int_rigid_r, mat_int_finish, mat_wall, height_ag,
soil_k_in)
if not assembly_r.nil?
Constructions.check_surface_assembly_rvalue(runner, [surface], inside_film, nil, assembly_r, match)
end
return surface.adjacentFoundation.get
end
# Adds an HPXML Slab to the OpenStudio model.
#
# Note: Since we don't know which FoundationWalls are adjacent to which Slabs, we may call this method multiple times
# for the same HPXML Slab, each time with a different exposed_length, specific to an adjacent HPXML FoundationWall.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param weather [WeatherFile] Weather object containing EPW information
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @param slab [HPXML::Slab] The HPXML slab of interest
# @param z_origin [Double] The z-coordinate for which the slab is relative (ft)
# @param exposed_length [Double] Length of foundation wall exposed to ambient conditions, specific to an associated HPXML Slab (ft)
# @param kiva_foundation [OpenStudio::Model::FoundationKiva] OpenStudio Foundation Kiva object
# @param default_azimuths [Array<Double>] Default azimuths for the four sides of the home, used for surfaces without an orientation
# @param schedules_file [SchedulesFile] SchedulesFile wrapper class instance of detailed schedule files
# @return [OpenStudio::Model::FoundationKiva] OpenStudio Foundation Kiva object
def self.apply_foundation_slab(model, weather, spaces, hpxml_bldg, hpxml_header, slab, z_origin,
exposed_length, kiva_foundation, default_azimuths, schedules_file)
exposed_fraction = exposed_length / slab.exposed_perimeter
slab_tot_perim = exposed_length
slab_area = slab.area * exposed_fraction
if slab_tot_perim**2 - 16.0 * slab_area <= 0
# Cannot construct rectangle with this perimeter/area. Some of the
# perimeter is presumably not exposed, so bump up perimeter value.
slab_tot_perim = Math.sqrt(16.0 * slab_area)
end
sqrt_term = [slab_tot_perim**2 - 16.0 * slab_area, 0.0].max
slab_length = slab_tot_perim / 4.0 + Math.sqrt(sqrt_term) / 4.0
slab_width = slab_tot_perim / 4.0 - Math.sqrt(sqrt_term) / 4.0
vertices = create_floor_vertices(slab_length, slab_width, z_origin, default_azimuths)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.setName(slab.id)
surface.setSurfaceType(EPlus::SurfaceTypeFloor)
surface.setOutsideBoundaryCondition(EPlus::BoundaryConditionFoundation)
surface.additionalProperties.setFeature('SurfaceType', 'Slab')
set_surface_interior(model, spaces, surface, slab, hpxml_bldg)
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
slab_perim_r = slab.perimeter_insulation_r_value
slab_perim_depth = slab.perimeter_insulation_depth
if (slab_perim_r == 0) || (slab_perim_depth == 0)
slab_perim_r = 0
slab_perim_depth = 0
end
if slab.under_slab_insulation_spans_entire_slab
slab_whole_r = slab.under_slab_insulation_r_value
slab_under_r = 0
slab_under_width = 0
else
slab_under_r = slab.under_slab_insulation_r_value
slab_under_width = slab.under_slab_insulation_width
if (slab_under_r == 0) || (slab_under_width == 0)
slab_under_r = 0
slab_under_width = 0
end
slab_whole_r = 0
end
slab_gap_r = slab.gap_insulation_r_value
mat_carpet = nil
if (slab.carpet_fraction > 0) && (slab.carpet_r_value > 0)
mat_carpet = Material.CoveringBare(slab.carpet_fraction,
slab.carpet_r_value)
end
soil_k_in = UnitConversions.convert(hpxml_bldg.site.ground_conductivity, 'ft', 'in')
ext_horiz_r = slab.exterior_horizontal_insulation_r_value
ext_horiz_width = slab.exterior_horizontal_insulation_width
ext_horiz_depth = slab.exterior_horizontal_insulation_depth_below_grade
Constructions.apply_foundation_slab(model, surface, "#{slab.id} construction",
slab_under_r, slab_under_width, slab_gap_r, slab_perim_r,
slab_perim_depth, slab_whole_r, slab.thickness,
exposed_length, mat_carpet, soil_k_in, kiva_foundation,
ext_horiz_r, ext_horiz_width, ext_horiz_depth)
kiva_foundation = surface.adjacentFoundation.get
Constructions.apply_kiva_initial_temperature(kiva_foundation, weather, hpxml_bldg, hpxml_header,
spaces, schedules_file, slab.interior_adjacent_to)
return kiva_foundation
end
# Adds any HPXML Windows to the OpenStudio model.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @return [nil]
def self.apply_windows(model, spaces, hpxml_bldg, hpxml_header)
# We already stored @fraction_of_windows_operable, so lets remove the
# fraction_operable properties from windows and re-collapse the enclosure
# so as to prevent potentially modeling multiple identical windows in E+,
# which can increase simulation runtime.
hpxml_bldg.windows.each do |window|
window.fraction_operable = nil
end
hpxml_bldg.collapse_enclosure_surfaces()
_walls_top, foundation_top = get_foundation_and_walls_top(hpxml_bldg)
shading_schedules = {}
surfaces = []
hpxml_bldg.windows.each do |window|
window_height = 4.0 # ft, default
overhang_depth = nil
if (not window.overhangs_depth.nil?) && (window.overhangs_depth > 0)
overhang_depth = window.overhangs_depth
overhang_distance_to_top = window.overhangs_distance_to_top_of_window
overhang_distance_to_bottom = window.overhangs_distance_to_bottom_of_window
window_height = overhang_distance_to_bottom - overhang_distance_to_top
end
window_length = window.area / window_height
z_origin = foundation_top
ufactor, shgc = Constructions.get_ufactor_shgc_adjusted_by_storms(window.storm_type, window.ufactor, window.shgc)
if window.is_exterior
# Create parent surface slightly bigger than window
vertices = create_wall_vertices(window_length, window_height, z_origin, window.azimuth, add_buffer: true)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', window_length)
surface.additionalProperties.setFeature('Azimuth', window.azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'Window')
surface.setName("surface #{window.id}")
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, window.wall, hpxml_bldg)
vertices = create_wall_vertices(window_length, window_height, z_origin, window.azimuth)
sub_surface = OpenStudio::Model::SubSurface.new(vertices, model)
sub_surface.setName(window.id)
sub_surface.setSurface(surface)
sub_surface.setSubSurfaceType(EPlus::SubSurfaceTypeWindow)
set_subsurface_exterior(surface, spaces, model, window.wall, hpxml_bldg)
surfaces << surface
if not overhang_depth.nil?
overhang = sub_surface.addOverhang(UnitConversions.convert(overhang_depth, 'ft', 'm'), UnitConversions.convert(overhang_distance_to_top, 'ft', 'm'))
overhang.get.setName("#{sub_surface.name} overhangs")
end
# Apply construction
Constructions.apply_window(model, sub_surface, 'WindowConstruction', ufactor, shgc)
# Apply interior/exterior shading (as needed)
Constructions.apply_window_skylight_shading(model, window, sub_surface, shading_schedules, hpxml_header, hpxml_bldg)
else
# Window is on an interior surface, which E+ does not allow. Model
# as a door instead so that we can get the appropriate conduction
# heat transfer; there is no solar gains anyway.
# Create parent surface slightly bigger than window
vertices = create_wall_vertices(window_length, window_height, z_origin, window.azimuth, add_buffer: true)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', window_length)
surface.additionalProperties.setFeature('Azimuth', window.azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'Door')
surface.setName("surface #{window.id}")
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, window.wall, hpxml_bldg)
vertices = create_wall_vertices(window_length, window_height, z_origin, window.azimuth)
sub_surface = OpenStudio::Model::SubSurface.new(vertices, model)
sub_surface.setName(window.id)
sub_surface.setSurface(surface)
sub_surface.setSubSurfaceType(EPlus::SubSurfaceTypeDoor)
set_subsurface_exterior(surface, spaces, model, window.wall, hpxml_bldg)
surfaces << surface
# Apply construction
inside_film = Material.AirFilmVertical
outside_film = Material.AirFilmVertical
Constructions.apply_door(model, [sub_surface], 'Window', ufactor, inside_film, outside_film)
end
end
Constructions.apply_adiabatic_construction(model, surfaces, 'wall')
end
# Adds any HPXML Doors to the OpenStudio model.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [nil]
def self.apply_doors(model, spaces, hpxml_bldg)
_walls_top, foundation_top = get_foundation_and_walls_top(hpxml_bldg)
surfaces = []
hpxml_bldg.doors.each do |door|
door_height = 6.67 # ft
door_length = door.area / door_height
z_origin = foundation_top
# Create parent surface slightly bigger than door
vertices = create_wall_vertices(door_length, door_height, z_origin, door.azimuth, add_buffer: true)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', door_length)
surface.additionalProperties.setFeature('Azimuth', door.azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'Door')
surface.setName("surface #{door.id}")
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, door.wall, hpxml_bldg)
vertices = create_wall_vertices(door_length, door_height, z_origin, door.azimuth)
sub_surface = OpenStudio::Model::SubSurface.new(vertices, model)
sub_surface.setName(door.id)
sub_surface.setSurface(surface)
sub_surface.setSubSurfaceType(EPlus::SubSurfaceTypeDoor)
set_subsurface_exterior(surface, spaces, model, door.wall, hpxml_bldg)
surfaces << surface
# Apply construction
ufactor = 1.0 / door.r_value
inside_film = Material.AirFilmVertical
if door.wall.is_exterior
outside_film = Material.AirFilmOutside
else
outside_film = Material.AirFilmVertical
end
Constructions.apply_door(model, [sub_surface], 'Door', ufactor, inside_film, outside_film)
end
Constructions.apply_adiabatic_construction(model, surfaces, 'wall')
end
# Adds any HPXML Skylights to the OpenStudio model.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @param hpxml_header [HPXML::Header] HPXML Header object (one per HPXML file)
# @return [nil]
def self.apply_skylights(model, spaces, hpxml_bldg, hpxml_header)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
walls_top, _foundation_top = get_foundation_and_walls_top(hpxml_bldg)
surfaces = []
shading_schedules = {}
hpxml_bldg.skylights.each do |skylight|
if not skylight.is_conditioned
fail "Skylight '#{skylight.id}' not connected to conditioned space; if it's a skylight with a shaft, use AttachedToFloor to connect it to conditioned space."
end
tilt = skylight.roof.pitch / 12.0
width = Math::sqrt(skylight.area)
length = skylight.area / width
z_origin = walls_top + 0.5 * Math.sin(Math.atan(tilt)) * width
ufactor, shgc = Constructions.get_ufactor_shgc_adjusted_by_storms(skylight.storm_type, skylight.ufactor, skylight.shgc)
if not skylight.curb_area.nil?
# Create parent surface that includes curb heat transfer
total_area = skylight.area + skylight.curb_area
total_width = Math::sqrt(total_area)
total_length = total_area / total_width
vertices = create_roof_vertices(total_length, total_width, z_origin, skylight.azimuth, tilt, add_buffer: true)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', total_length)
surface.additionalProperties.setFeature('Width', total_width)
# Assign curb construction
curb_assembly_r = [skylight.curb_assembly_r_value - Material.AirFilmVertical.rvalue - Material.AirFilmOutside.rvalue, 0.1].max
curb_mat = Model.add_massless_material(
model,
name: 'SkylightCurbMaterial',
rvalue: UnitConversions.convert(curb_assembly_r, 'hr*ft^2*f/btu', 'm^2*k/w')
)
curb_const = Model.add_construction(
model,
name: 'SkylightCurbConstruction',
layers: [curb_mat]
)
surface.setConstruction(curb_const)
else
# Create parent surface slightly bigger than skylight
vertices = create_roof_vertices(length, width, z_origin, skylight.azimuth, tilt, add_buffer: true)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', length)
surface.additionalProperties.setFeature('Width', width)
surfaces << surface # Add to surfaces list so it's assigned an adiabatic construction
end
surface.additionalProperties.setFeature('Azimuth', skylight.azimuth)
surface.additionalProperties.setFeature('Tilt', tilt)
surface.additionalProperties.setFeature('SurfaceType', 'Skylight')
surface.setName("surface #{skylight.id}")
surface.setSurfaceType(EPlus::SurfaceTypeRoofCeiling)
surface.setSpace(create_or_get_space(model, spaces, HPXML::LocationConditionedSpace, hpxml_bldg))
surface.setOutsideBoundaryCondition(EPlus::BoundaryConditionOutdoors) # cannot be adiabatic because subsurfaces won't be created
vertices = create_roof_vertices(length, width, z_origin, skylight.azimuth, tilt)
sub_surface = OpenStudio::Model::SubSurface.new(vertices, model)
sub_surface.setName(skylight.id)
sub_surface.setSurface(surface)
sub_surface.setSubSurfaceType('Skylight')
# Apply construction
Constructions.apply_skylight(model, sub_surface, 'SkylightConstruction', ufactor, shgc)
# Apply interior/exterior shading (as needed)
Constructions.apply_window_skylight_shading(model, skylight, sub_surface, shading_schedules, hpxml_header, hpxml_bldg)
next unless (not skylight.shaft_area.nil?) && (not skylight.floor.nil?)
# Add skylight shaft heat transfer, similar to attic knee walls
shaft_height = Math::sqrt(skylight.shaft_area)
shaft_width = skylight.shaft_area / shaft_height
shaft_azimuth = default_azimuths[0] # Arbitrary direction, doesn't receive exterior incident solar
shaft_z_origin = walls_top - shaft_height
vertices = create_wall_vertices(shaft_width, shaft_height, shaft_z_origin, shaft_azimuth)
surface = OpenStudio::Model::Surface.new(vertices, model)
surface.additionalProperties.setFeature('Length', shaft_width)
surface.additionalProperties.setFeature('Width', shaft_height)
surface.additionalProperties.setFeature('Azimuth', shaft_azimuth)
surface.additionalProperties.setFeature('Tilt', 90.0)
surface.additionalProperties.setFeature('SurfaceType', 'Skylight')
surface.setName("surface #{skylight.id} shaft")
surface.setSurfaceType(EPlus::SurfaceTypeWall)
set_surface_interior(model, spaces, surface, skylight.floor, hpxml_bldg)
set_surface_exterior(model, spaces, surface, skylight.floor, hpxml_bldg)
surface.setSunExposure(EPlus::SurfaceSunExposureNo)
surface.setWindExposure(EPlus::SurfaceWindExposureNo)
# Apply construction
shaft_assembly_r = [skylight.shaft_assembly_r_value - 2 * Material.AirFilmVertical.rvalue, 0.1].max
shaft_mat = Model.add_massless_material(
model,
name: 'SkylightShaftMaterial',
rvalue: UnitConversions.convert(shaft_assembly_r, 'hr*ft^2*f/btu', 'm^2*k/w')
)
shaft_const = Model.add_construction(
model,
name: 'SkylightShaftConstruction',
layers: [shaft_mat]
)
surface.setConstruction(shaft_const)
end
Constructions.apply_adiabatic_construction(model, surfaces, 'roof')
end
# Check if we need to add floors between conditioned spaces (e.g., between first
# and second story or conditioned basement ceiling).
# This ensures that the E+ reported Conditioned Floor Area is correct.
#
# @param model [OpenStudio::Model::Model] OpenStudio Model object
# @param spaces [Hash] Map of HPXML locations => OpenStudio Space objects
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
# @return [nil]
def self.apply_conditioned_floor_area(model, spaces, hpxml_bldg)
default_azimuths = Defaults.get_azimuths(hpxml_bldg)
_walls_top, foundation_top = get_foundation_and_walls_top(hpxml_bldg)
sum_cfa = 0.0
hpxml_bldg.floors.each do |floor|
next unless floor.is_floor
next unless [HPXML::LocationConditionedSpace, HPXML::LocationBasementConditioned].include?(floor.interior_adjacent_to) ||
[HPXML::LocationConditionedSpace, HPXML::LocationBasementConditioned].include?(floor.exterior_adjacent_to)
sum_cfa += floor.area
end
hpxml_bldg.slabs.each do |slab|
next unless [HPXML::LocationConditionedSpace, HPXML::LocationBasementConditioned].include? slab.interior_adjacent_to
sum_cfa += slab.area
end
addtl_cfa = hpxml_bldg.building_construction.conditioned_floor_area - sum_cfa
fail if addtl_cfa < -1.0 # Allow some rounding; EPvalidator.sch should prevent this
return unless addtl_cfa > 1.0 # Allow some rounding
floor_width = Math::sqrt(addtl_cfa)
floor_length = addtl_cfa / floor_width
z_origin = foundation_top + 8.0 * (hpxml_bldg.building_construction.number_of_conditioned_floors_above_grade - 1)
# Add floor surface
vertices = create_floor_vertices(floor_length, floor_width, z_origin, default_azimuths)
floor_surface = OpenStudio::Model::Surface.new(vertices, model)
floor_surface.setSunExposure(EPlus::SurfaceSunExposureNo)
floor_surface.setWindExposure(EPlus::SurfaceWindExposureNo)