-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
1227 lines (1153 loc) · 59.9 KB
/
functions.py
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
"""Holds the main functions to process and outputs the XML file"""
import xml.etree.ElementTree as ET
from xml.dom import minidom
import math
import pandas as pd
from TBs import TBs
from levels_naming import levels_naming
import uuid
import datetime
import os
import streamlit as st
def generate_unique_name(base_name):
"""Generate a unique name for the temp XML files to be saved locally"""
timestamp = datetime.datetime.now()
unique_string = str(uuid.uuid4().hex)
run_name = f"{base_name}_{str(timestamp).replace(':','-')}_{unique_string}"
return run_name
def delete_files_in_directory(directory):
"""Deleting all temp files"""
# Get the list of files in the directory
file_list = os.listdir(directory)
# Iterate over each file and delete it
for file_name in file_list:
file_path = os.path.join(directory, file_name)
try:
if os.path.isfile(file_path):
os.remove(file_path)
print(f"Deleted: {file_path}")
except Exception as e:
print(f"Error deleting {file_path}: {e}")
pass
def data_to_xml(dictionary, root_name='AssessmentFull'):
"""Converts the dictionary element to a string suitable for XML"""
root = ET.Element(root_name)
def _data_to_xml(element, data):
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, (list, dict)):
sub_element = ET.SubElement(element, key)
_data_to_xml(sub_element, value)
else:
ET.SubElement(element, key).text = str(value)
elif isinstance(data, list):
for item in data:
sub_element = ET.SubElement(element, 'item')
_data_to_xml(sub_element, item)
else:
element.text = str(data)
_data_to_xml(root, dictionary)
return ET.tostring(root, encoding='unicode',xml_declaration=None)
def prettify(elem):
"""Formats the outputs with the releveant XML criteria"""
reparsed = minidom.parseString(elem)
prettified = reparsed.toprettyxml(indent=" ")
final = prettified.replace('<?xml version="1.0" ?>\n', '')
return final
def check_missing_data(unit, sheet, input_list):
"""Checks for any missing data and raises error if there's a mismatch"""
for info in input_list:
non_nan = sheet[info][sheet[info].notna()]
if len(non_nan)==0:
raise st.error(f'Error for {unit["propertyName"]}: "{info}" has not been entered')
unit[info] = sheet[info].tolist()[1]
def check_opening_type_data(unit, sheet, main, inputs, this_type):
"""Counts Openings on input types and raises error if there's a mismatch"""
sheet = sheet[sheet['Type']==this_type]
filtered_main = sheet[main][sheet[main].notna()]
for data in inputs:
filtered_input = sheet[data][sheet[data].notna()]
if len(filtered_input)!=len(filtered_main):
raise st.error(f'''Error for {unit["propertyName"]}:
There is a mismatch between the number of "{main}"
elements and the corresponding "{data}"''')
def check_openings_data(unit, sheet, main, inputs):
"""Counts Openings on input and raises error if there's a mismatch"""
filtered_main = sheet[main][sheet[main].notna()]
for data in inputs:
filtered_input = sheet[data][sheet[data].notna()]
if len(filtered_input)!=len(filtered_main):
raise st.error(f'''Error for {unit["propertyName"]}:
There is a mismatch between the number of "{main}"
elements and the corresponding "{data}"''')
def check_op_element_types_names(unit, sheet):
"""Checks if there is an inconsitant number of Element Types and Names. Also, checks Element Names to ensure each is unique"""
filtered_op_elem_type = sheet['Element type'][sheet['Element type'].notna()]
filtered_op_elem_name = sheet['Element name'][sheet['Element name'].notna()]
# Check if all element types have a name assigned
if len(filtered_op_elem_type)!=len(filtered_op_elem_name):
raise st.error(f'''Error for {unit["propertyName"]}:
There is a mismatch between the number of
"Element type" entries and the assigned "Element name"''')
# Check if there are non-unique element names
if len(set(filtered_op_elem_name)) != len(filtered_op_elem_name):
# print(set(sheet['Element name']))
# print(sheet['Element name'])
raise st.error(f'''Error for {unit["propertyName"]}:
Two or more opaque element entries have the same name.
All elements require a unique name.''')
def input_reader(sheet):
"""Takes in the excel sheet to begin transforming into a dictionary"""
# Instantiate unit dict. this will hold all the inputs from the excel sheet
unit = {}
# General information
unit['propertyName'] = sheet['Property name'].tolist()[1]
gen_info_list = [
'Dwelling orientation',
'Calculation type',
'Terrain type',
'Property type 1',
'Property type 2',
'Position of flat',
'Which floor',
'Tot no. storeys in block',
'No. storeys',
'Date built',
'Sheltered sides',
'Sunlight/sunshade',
'Living area'
]
check_missing_data(unit, sheet, gen_info_list)
# Thermal mass parameter
tmp = 'Thermal mass parameter'
if len(sheet[tmp][sheet[tmp].notna()])>0:
unit[tmp] = sheet[tmp].tolist()[1]
unit['Thermal mass'] = 'EnterTmpValue'
else:
unit['Thermal mass'] = 'PreciseCalculation'
unit['Thermal mass parameter'] = '1'
# Level information
# unit['floorToSlab'] = sheet['Floor to slab'].tolist()[1:]
unit['floorToSlab'] = sheet['Floor to slab'][sheet['Floor to slab'].notna()].tolist()
# unit['heatedIntArea'] = sheet['Heated internal floor area'].tolist()[1:]
unit['heatedIntArea'] = sheet['Heated internal floor area'][sheet['Heated internal floor area'].notna()].tolist()
# unit['heatLossPerim'] = sheet['Heat loss perimeter'].tolist()[1:]
unit['heatLossPerim'] = sheet['Heat loss perimeter'][sheet['Heat loss perimeter'].notna()].tolist()
# Opaque elements
unit['opaqElementLevel'] = sheet['Level of opaque element'].tolist()[1:]
# unit['opaqElementLevel'] = sheet['Level of opaque element'][sheet['Level of opaque element'].notna()].tolist() # THIS IS NOT APPLICABLE AT THIS STAGE BECAUSE THE MATCH_XML FUNCTION REQUIRES A DATAFRAME WITH ALL ELEMENT PROPERTIES WITH SAME LENGTH
unit['opaqElementType'] = sheet['Element type'].tolist()[1:]
unit['opaqElementName'] = sheet['Element name'].tolist()[1:]
unit['externalWallArea'] = sheet['External wall area'].tolist()[1:]
unit['externalWallUvalue'] = sheet['External wall U-value'].tolist()[1:]
unit['shelteredWallArea'] = sheet['Sheltered wall area'].tolist()[1:]
unit['shelteredWallUvalue'] = sheet['Sheltered wall U-value'].tolist()[1:]
unit['shelterFactor'] = sheet['Sheltered wall shelter factor'].tolist()[1:]
unit['partylWallArea'] = sheet['Party wall area'].tolist()[1:]
unit['externalRoofArea'] = sheet['External roof area'].tolist()[1:]
unit['externalRoofUvalue'] = sheet['External roof U-value'].tolist()[1:]
unit['externalRoofType'] = sheet['External roof type'].tolist()[1:]
unit['externalRoofShelterFactor'] = sheet['External roof shelter factor'].tolist()[1:]
unit['heatLossFloorArea'] = sheet['Heat loss floor area'].tolist()[1:]
unit['heatLossFloorUvalue'] = sheet['Heat loss floor U-value'].tolist()[1:]
unit['heatLossFloorType'] = sheet['Heat loss floor type'].tolist()[1:]
unit['heatLossFloorShelterFactor'] = sheet['Heat loss floor shelter factor'].tolist()[1:]
unit['partyCeilingArea'] = sheet['Party ceiling area'].tolist()[1:]
unit['partyFloorArea'] = sheet['Party floor area'].tolist()[1:]
unit['internalPartitionArea'] = sheet['Internal partition area'].tolist()[1:]
unit['internalPartitionConstruction'] = sheet['Internal partition construction'].tolist()[1:]
unit['internalCeilingArea'] = sheet['Internal ceiling area'].tolist()[1:]
unit['internalCeilingConstruction'] = sheet['Internal ceiling construction'].tolist()[1:]
unit['internalFloorArea'] = sheet['Internal floor area'].tolist()[1:]
unit['internalFloorConstruction'] = sheet['Internal floor construction'].tolist()[1:]
# Check inconsistencies in opaque elements inputs
check_op_element_types_names(unit, sheet)
# Checking if number of area inputs matches the number of entries of element type
op_elements = [
'External wall',
'Sheltered wall',
'Party wall',
'External roof',
'Heat loss floor',
'Party ceiling',
'Party floor',
'Internal partition',
'Internal ceiling',
'Internal floor'
]
op_elements_titles = [
'External wall area',
'Sheltered wall area',
'Party wall area',
'External roof area',
'Heat loss floor area',
'Party ceiling area',
'Party floor area',
'Internal partition area',
'Internal ceiling area',
'Internal floor area'
]
for this_id, element in enumerate(op_elements):
filtered_elements = sheet['Element type'][sheet['Element type'] == element]
if len(filtered_elements) != len(sheet[op_elements_titles[this_id]][sheet[op_elements_titles[this_id]].notna()]):
raise st.error(f'''Error for {unit["propertyName"]}:
An "{element}" element is missing 1 or more required inputs''')
# Opening types
unit['openTypeName'] = sheet['Opening type name'].tolist()[1:]
# unit['openTypeName'] = sheet['Opening type name'][sheet['Opening type name'].notna()].tolist() # THIS IS NOT APPLICABLE AT THIS STAGE BECAUSE THE MATCH_XML FUNCTION REQUIRES A DATAFRAME WITH ALL OPENING PROPERTIES WITH SAME LENGTH
unit['openingType'] = sheet['Type'].tolist()[1:]
unit['glzgType'] = sheet['Glazing type'].tolist()[1:]
unit['uVal'] = sheet['U-value'].tolist()[1:]
unit['gVal'] = sheet['Solar transmittance'].tolist()[1:]
unit['frameFactor'] = sheet['Frame factor'].tolist()[1:]
inputs_window = ['Type','U-value','Solar transmittance','Frame factor']
inputs_door = ['Type','U-value','Frame factor']
main = 'Opening type name'
check_opening_type_data(unit, sheet, main, inputs_window, this_type='Window')
check_opening_type_data(unit, sheet, main, inputs_door, this_type='Door')
# Openings
unit['openLevel'] = sheet['Opening level ref.'].tolist()[1:]
unit['openName'] = sheet['Opening name'].tolist()[1:]
unit['openType'] = sheet['Opening type'].tolist()[1:]
unit['parentElem'] = sheet['Belongs to opaque element'].tolist()[1:]
unit['openOrientation'] = sheet['Orientation'].tolist()[1:]
unit['openArea'] = sheet['Area'].tolist()[1:]
inputs_openings= [
'Opening level ref.',
'Opening type',
'Belongs to opaque element',
'Orientation',
'Width',
'Height',
'Area',
'Floor to ceiling?'
]
main = 'Opening name'
check_openings_data(unit, sheet, main, inputs_openings)
# Thermal bridges
thermal_bridges = unit['thermalBridges'] = {}
for tb, _ in TBs.items():
thermal_bridge = {}
if sheet[tb][0] == 'ERROR':
raise st.error(f'Error for {unit["propertyName"]}: Psi value not entered for thermal bridge {tb}')
thermal_bridge['psi'] = sheet[tb][sheet[tb].notna()].tolist()[0]
thermal_bridge['length'] = sum(sheet[tb][2:][sheet[tb].notna()].tolist())
thermal_bridges[tb] = thermal_bridge
# Mechanical ventilation
mech_vent_list = [
'Mech vent present',
'Ventilation data type',
'Mech vent type',
'Vent brand model',
'MVHR SFP','MVHR HR',
'Wet rooms',
'System location',
'Duct insulation',
'Duct installation specs',
'Duct type',
'Air permeability @50Pa'
]
check_missing_data(unit, sheet, mech_vent_list)
# Lighting
lighting_list = [
'Lighting name',
'Efficacy',
'Power',
'Capacity',
'Count'
]
check_missing_data(unit, sheet, lighting_list)
# Assessment setup
assessment_setup_list = [
'Assessment mode',
'Heating system type'
]
check_missing_data(unit, sheet, assessment_setup_list)
# Main heating 1
main_heating_list = [
'Heating data type',
'Model name',
'Manufacturer',
'Fuel type MHS',
'System type',
'Fraction',
'Database reference number',
'Winter efficiency',
'Summer efficiency',
'Is MHS pumped',
'Heating pump age',
'Heat emitter',
'Flow temperature value',
'Control SAP code'
]
if unit['Heating system type'] == "Local heating":
check_missing_data(unit, sheet, main_heating_list)
# Heat networks
heat_networks_list = [
'Heating network type',
'Distribution type space',
'Distribution loss space',
'Heating controls',
'Existing space heat network',
'Use new space heat network notional dwelling',
'HS1 - Source',
'HS1 - Fuel type',
'HS1 - Fuel factor',
'HS1 - Percentage of heat',
'HS1 - Overall efficiency',
'HS1 - Heating use',
'HS2 - Source',
'HS2 - Fuel type',
'HS2 - Fuel factor',
'HS2 - Percentage of heat',
'HS2 - Overall efficiency',
'HS2 - Heating use',
]
if unit['Heating system type'] == "Heat network":
check_missing_data(unit, sheet, heat_networks_list)
# Water heating
water_heating_list = [
'Water heating',
'Cold water source',
'Low water use?',
'Bath count',
'Shower type',
'Shower flowrate',
'Storage type',
'Loss factor',
'Cylinder volume',
'Pipework insulation'
]
check_missing_data(unit, sheet, water_heating_list)
# PV data
PV_list = [
'PV present?',
'PV type',
'Cells kW peak',
'PV orientation',
'PV elevation',
'PV overshading'
]
check_missing_data(unit, sheet, PV_list)
return unit
def match_xml(input_unit):
"""Begins matchings the dict format to a nested dictionaries for easier export to XML"""
# Instantiate output_data dict
output_data = {}
# main error opening string
err_open_str = f'Error for {input_unit["propertyName"]}: '
# Output data for general unit info
assessment = output_data['Assessment'] = {}
assessment['Reference'] = input_unit['propertyName']
assessment['DwellingOrientation'] = input_unit['Dwelling orientation']
assessment['CalculationType'] = input_unit['Calculation type']
assessment['Tenure'] = 'ND'
assessment['TransactionType'] = int(6)
assessment['TerrainType'] = input_unit['Terrain type']
assessment['SimpleComplianceScotland'] = 'false'
assessment['PropertyType1'] = input_unit['Property type 1']
assessment['PropertyType2'] = input_unit['Property type 2']
assessment['PositionOfFlat'] = input_unit['Position of flat']
assessment['FlatWhichFloor'] = int(input_unit['Which floor'])
assessment['StoreysInBlock'] = int(input_unit['Tot no. storeys in block'])
assessment['Storeys'] = len([1 for x in input_unit['floorToSlab'] if x > 0])
assessment['DateBuilt'] = int(input_unit['Date built'])
assessment['PropertyAgeBand'] = 'replace_xsi:nul'
assessment['ShelteredSides'] = int(input_unit['Sheltered sides'])
assessment['SunlightShade'] = input_unit['Sunlight/sunshade']
assessment['Basement'] = 'false'
assessment['LivingArea'] = input_unit['Living area']
assessment['ThermalMass'] = input_unit['Thermal mass']
assessment['ThermalMassValue'] = input_unit['Thermal mass parameter']
assessment['LowestFloorHasUnheatedSpace'] = 'replace_xsi:nul'
assessment['UnheatedFloorArea'] = 'replace_xsi:nul'
# Output data for measurements
measurements = assessment['Measurements'] = {}
# Looping through 10 measurements (storeys), as expected by the XML input in Elmhurst
# If the storey is not present in the sheet, the output will be just all Os.
filtered_heat_loss_perim = [x for x in input_unit['heatLossPerim'] if not math.isnan(x)]
filtered_heated_int_area = [x for x in input_unit['heatedIntArea'] if not math.isnan(x)]
filtered_floor_to_slab = [x for x in input_unit['floorToSlab'] if not math.isnan(x)]
if len(filtered_heat_loss_perim) == len(filtered_heated_int_area) == len(filtered_floor_to_slab):
pass
else:
raise st.error(f'''{err_open_str}
One or multiple inputs among ["Floor to slab", "Heat loss perimeter",
"Heated internal area"] have not been entered''')
for msrmt in range(9):
measurement = {}
if msrmt>0:
try:
if math.isnan(input_unit['heatLossPerim'][msrmt-1]):
measurement['Storey'] = msrmt
measurement['InternalPerimeter'] = 0
measurement['InternalFloorArea'] = 0
measurement['StoreyHeight'] = 0
else:
measurement['Storey'] = msrmt
measurement['InternalPerimeter'] = input_unit['heatLossPerim'][msrmt-1]
measurement['InternalFloorArea'] = input_unit['heatedIntArea'][msrmt-1]
measurement['StoreyHeight'] = input_unit['floorToSlab'][msrmt-1]
except:
measurement['Storey'] = msrmt
measurement['InternalPerimeter'] = 0
measurement['InternalFloorArea'] = 0
measurement['StoreyHeight'] = 0
else: #for some reason, Elmhurst expects an empty Storey 0
measurement['Storey'] = msrmt
measurement['InternalPerimeter'] = 0
measurement['InternalFloorArea'] = 0
measurement['StoreyHeight'] = 0
measurements[f'Measurement{msrmt}'] = measurement
project_area = sum(input_unit['heatedIntArea'])
# Instantiate empty dictionaries for opqaue elements
ext_walls = assessment['ExternalWalls'] = {}
party_walls = assessment['PartyWalls'] = {}
internal_partitions = assessment['InternalPartitions'] = {}
internal_ceilings = assessment['InternalCeilings'] = {}
internal_floors = assessment['InternalFloors'] = {}
ext_roofs = assessment['ExternalRoofs'] = {}
party_roofs = assessment['PartyRoofs'] = {}
heatloss_floors = assessment['HeatlossFloors'] = {}
party_floors = assessment['PartyFloors'] = {}
op_elements = [
"opaqElementType",
"externalWallArea",
"externalWallUvalue",
"shelteredWallArea",
"shelteredWallUvalue",
"shelterFactor",
"partylWallArea",
"externalRoofArea",
"externalRoofUvalue",
"externalRoofType",
"externalRoofShelterFactor",
"heatLossFloorArea",
"heatLossFloorUvalue",
"heatLossFloorType",
"heatLossFloorShelterFactor",
"partyCeilingArea",
"partyFloorArea",
"internalPartitionArea",
"internalPartitionConstruction",
"internalCeilingArea",
"internalCeilingConstruction",
"internalFloorArea",
"internalFloorConstruction"
]
op_elements_dict = {col: input_unit[col] for col in op_elements}
op_elements_df = pd.DataFrame.from_dict(op_elements_dict)
# Looping through the opaque elements and checking what element type it is.
# Each type has different outputs
for this_id, this_type in enumerate(input_unit['opaqElementType']):
row = op_elements_df.loc[this_id]
if this_type == 'External wall':
filtered_row = row[1:3][row[1:3].notna()]
if len(filtered_row)>1:
ext_wall = {}
ext_wall['Description'] = input_unit['opaqElementName'][this_id]
ext_wall['Construction'] = 'Other'
ext_wall['Kappa'] = 0
ext_wall['GrossArea'] = round(input_unit['externalWallArea'][this_id],3)
ext_wall['Uvalue'] = input_unit['externalWallUvalue'][this_id]
ext_wall['ShelterFactor'] = 0
ext_wall['ShelterCode'] = None
ext_wall['Type'] = 'Cavity'
ext_wall['AreaCalculationType'] = 'Gross'
ext_wall['OpeningsArea'] = 'replace_xsi:nul'
ext_wall['NettArea'] = 0
ext_walls[f'ExternalWall{this_id}'] = ext_wall
else:
raise st.error(f'''{err_open_str}
An "External wall" element is missing 1 or more required inputs''')
elif this_type == 'Sheltered wall':
filtered_row = row[2:6][row[2:6].notna()]
if len(filtered_row)>2:
shelt_wall = {}
shelt_wall['Description'] = input_unit['opaqElementName'][this_id]
shelt_wall['Construction'] = 'Other'
shelt_wall['Kappa'] = 0
shelt_wall['GrossArea'] = round(input_unit['shelteredWallArea'][this_id],3)
shelt_wall['Uvalue'] = input_unit['shelteredWallUvalue'][this_id]
shelt_wall['ShelterFactor'] = input_unit['shelterFactor'][this_id]
shelt_wall['ShelterCode'] = None
shelt_wall['Type'] = 'Cavity'
shelt_wall['AreaCalculationType'] = 'Gross'
shelt_wall['OpeningsArea'] = 'replace_xsi:nul'
shelt_wall['NettArea'] = 0
ext_walls[f'ExternalWall{this_id}'] = shelt_wall
else:
raise st.error(f'''{err_open_str}
A "Sheltered wall" element is missing 1 or more required inputs''')
elif this_type == 'Party wall':
if row.iloc[6]>0:
party_wall = {}
party_wall['Description'] = input_unit['opaqElementName'][this_id]
party_wall['Construction'] = 'Other'
party_wall['Kappa'] = 0
party_wall['GrossArea'] = round(input_unit['partylWallArea'][this_id],3)
party_wall['Uvalue'] = 0
party_wall['ShelterFactor'] = 0
party_wall['ShelterCode'] = None
party_wall['Type'] = 'FilledWithEdge'
party_walls[f'PartyWall{this_id}'] = party_wall
else:
raise st.error(f'''{err_open_str}
A "Party wall" element is missing 1 or more required inputs''')
elif this_type == 'External roof':
filtered_row = row[7:11][row[7:11].notna()]
if len(filtered_row)==4:
ext_roof = {}
ext_roof['Description'] = input_unit['opaqElementName'][this_id]
try:
ext_roof['StoreyIndex'] = levels_naming[str(int(input_unit['opaqElementLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'''{err_open_str}
The level reference entered for {this_type} is not listed under "Levels"''') from exc
ext_roof['Construction'] = 'Other'
ext_roof['Kappa'] = 0
ext_roof['GrossArea'] = input_unit['externalRoofArea'][this_id]
ext_roof['Type'] = input_unit['externalRoofType'][this_id]
ext_roof['UValue'] = input_unit['externalRoofUvalue'][this_id]
ext_roof['ShelterFactor'] = input_unit['externalRoofShelterFactor'][this_id]
ext_roof['ShelterCode'] = None
ext_roof['AreaCalculationType'] = 'Gross'
ext_roof['OpeningsArea'] = 'replace_xsi:nul'
ext_roof['NettArea'] = 0
ext_roofs[f'ExternalRoof{this_id}'] = ext_roof
else:
raise st.error(f'''{err_open_str}
An "External roof" element is missing 1 or more required inputs''')
elif this_type == 'Heat loss floor':
filtered_row = row[11:15][row[11:15].notna()]
if len(filtered_row)==4:
heatloss_floor = {}
heatloss_floor['Description'] = input_unit['opaqElementName'][this_id]
heatloss_floor['Construction'] = 'Other'
heatloss_floor['Kappa'] = 0
heatloss_floor['Area'] = input_unit['heatLossFloorArea'][this_id]
try:
heatloss_floor['StoreyIndex'] = levels_naming[str(int(input_unit['opaqElementLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'{err_open_str}The level reference entered for {this_type} is not listed under "Levels"') from exc
heatloss_floor['Type'] = input_unit['heatLossFloorType'][this_id]
heatloss_floor['UValue'] = input_unit['heatLossFloorUvalue'][this_id]
heatloss_floor['ShelterFactor'] = input_unit['heatLossFloorShelterFactor'][this_id]
heatloss_floor['ShelterCode'] = None
heatloss_floors[f'HeatLossFloor{this_id}'] = heatloss_floor
else:
raise st.error(f''''{err_open_str}
A "Heat loss floor" element is missing 1 or more required inputs''')
elif this_type == 'Party ceiling':
if row.iloc[15]>0:
party_roof = {}
party_roof['Description'] = input_unit['opaqElementName'][this_id]
try:
party_roof['StoreyIndex'] = levels_naming[str(int(input_unit['opaqElementLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'''{err_open_str}
The level reference entered for {this_type} is not listed under "Levels"''') from exc
party_roof['Construction'] = 'Other'
party_roof['Kappa'] = 0
party_roof['GrossArea'] = input_unit['partyCeilingArea'][this_id]
party_roofs[f'Roof{this_id}'] = party_roof
else:
raise st.error(f'''{err_open_str}
A "Party ceiling" element is missing 1 or more required inputs''')
elif this_type == 'Party floor':
if row.iloc[16]>0:
party_floor = {}
party_floor['Description'] = input_unit['opaqElementName'][this_id]
party_floor['Construction'] = 'Other'
party_floor['Kappa'] = 0
party_floor['Area'] = input_unit['partyFloorArea'][this_id]
try:
party_floor['StoreyIndex'] = levels_naming[str(int(input_unit['opaqElementLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'''{err_open_str}
The level reference entered for {this_type} is not listed under "Levels"''') from exc
party_floors[f'Floor{this_id}'] = party_floor
else:
raise st.error(f'''{err_open_str}
A "Party floor" element is missing 1 or more required inputs''')
elif this_type == 'Internal partition':
filtered_row = row[17:19][row[17:19].notna()]
if len(filtered_row)==2:
internal_partition = {}
internal_partition['Description'] = input_unit['opaqElementName'][this_id]
internal_partition['Construction'] = input_unit['internalPartitionConstruction'][this_id]
internal_partition['Kappa'] = 0
internal_partition['GrossArea'] = input_unit['internalPartitionArea'][this_id]
internal_partitions[f'Wall{this_id}'] = internal_partition
else:
raise st.error(f'''{err_open_str}
An "Internal partition" element is missing 1 or more required inputs''')
elif this_type == 'Internal ceiling':
filtered_row = row[19:21][row[19:21].notna()]
if len(filtered_row)==2:
internal_ceiling = {}
internal_ceiling['Description'] = input_unit['opaqElementName'][this_id]
try:
internal_ceiling['StoreyIndex'] = levels_naming[str(int(input_unit['opaqElementLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'''{err_open_str}
The level reference entered for {this_type} is not listed under "Levels"''') from exc
internal_ceiling['Construction'] = input_unit['internalCeilingConstruction'][this_id]
internal_ceiling['Kappa'] = 0
internal_ceiling['GrossArea'] = input_unit['internalCeilingArea'][this_id]
internal_ceilings[f'Roof{this_id}'] = internal_ceiling
else:
raise st.error(f'''{err_open_str}
An "Internal ceiling" element is missing 1 or more required inputs''')
elif this_type == 'Internal floor':
filtered_row = row[21:23][row[21:23].notna()]
if len(filtered_row)==2:
internal_floor = {}
internal_floor['Description'] = input_unit['opaqElementName'][this_id]
internal_floor['Construction'] = input_unit['internalFloorConstruction'][this_id]
internal_floor['Kappa'] = 0
internal_floor['Area'] = input_unit['internalFloorArea'][this_id]
try:
internal_floor['StoreyIndex'] = levels_naming[str(int(input_unit['opaqElementLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'''{err_open_str}
The level reference entered for {this_type} is not listed under "Levels"''') from exc
internal_floors[f'Floor{this_id}'] = internal_floor
else:
raise st.error(f'''{err_open_str}
An "Internal floor" element is missing 1 or more required inputs''')
# Misc objects that need to be included in the XML for Elmhurst
# (but currently are not allowed to be entered in the excel sheet)
assessment['ThermalBridgesCalculation'] = 'CalculateBridges'
assessment['ThermalBridgingSpreadsheet'] = 'Summary'
assessment['ThermalBridgesYvalue'] = 0
assessment['ThermalBridgesDescription'] = []
assessment['PointThermalBridgingX'] = 'replace_xsi:nul'
assessment['OpenChimneys'] = 0
assessment['OpenFlues'] = 0
assessment['ChimneysFluesClosedFire'] = 0
assessment['FluesSolidFuelBoiler'] = 0
assessment['FluesOtherHeater'] = 0
assessment['BlockedChimneys'] = 0
assessment['IntermittentFans'] = 0
assessment['PassiveVents'] = 0
assessment['FluelessGasFires'] = 0
assessment['NoFixedLighting'] = 'false'
assessment['LightingCapacityCalculation'] = 'replace_xsi:nul'
# Output data for lighting
lightings = assessment['Lightings'] = {}
lighting = lightings['Lighting'] = {}
lighting['Name'] = input_unit['Lighting name']
lighting['Efficacy'] = input_unit['Efficacy']
lighting['Power'] = int(input_unit['Power'])
lighting['Capacity'] = int(input_unit['Capacity'])
lighting['Count'] = int(input_unit['Count'])
# Misc objects that need to be included in the XML for Elmhurst
# (but currently are not allowed to be entered in the excel sheet)
assessment['ElectricityTariff'] ='Standard'
assessment['SmartElectricityMeterFitted'] = 'false'
assessment['SmartGasMeterFitted'] = 'false'
assessment['SolarPanelPresent'] = 'false'
assessment['PressureTest'] = 'true'
assessment['PressureTestMethod'] = 'BlowerDoor'
assessment['Designed_AP50_AP4'] = input_unit['Air permeability @50Pa']
assessment['AsBuilt_AP50_AP4'] = 0.1
assessment['PropertyTested'] = 'true'
assessment['SmokeControlArea'] = 'Unknown'
assessment['ThermallySeparated'] = 'NoConservatory'
assessment['DraughtProofing'] = 100
assessment['DraughtLobby'] = 'false'
assessment['Floor1AreaCalculated'] = 'false'
assessment['PhotovoltaicUnitApportionedEnergy'] = 'replace_xsi:nul'
assessment['ConnectedToDwelling'] = 'Yes'
assessment['Diverter'] = 'No'
assessment['BatteryCapacity'] = 0
# Output data for PV panels. Checks if PVs are present, otherwise retuns empty tag
if input_unit['PV type'] != '-':
assessment['PhotovoltaicUnitType'] = input_unit['PV type']
pvs = assessment['PhotovoltaicUnits'] = {}
pv = pvs['PhotovoltaicUnit'] = {}
pv['CellsPeak'] = input_unit['Cells kW peak']
pv['Orientation'] = input_unit['PV orientation']
pv['Elevation'] = input_unit['PV elevation']
pv['Overshading'] = input_unit['PV overshading']
pv['Fghrs'] = 'false'
pv['MCSCertificate'] = 'false'
pv['OvershadingFactor'] = 0
else:
assessment['PhotovoltaicUnitType'] = None
assessment['PhotovoltaicUnits'] = {}
# Output data for opening types
assessment['OpeningTypes'] = {}
opening_types = assessment['OpeningTypes'] = {}
# Looping through each opening type and only including if data is entered
for this_id, name in enumerate(input_unit['openTypeName']):
if input_unit['uVal'][this_id]>0:
opening_type = {}
opening_type['Description'] = name
opening_type['DataSource'] = 'Manufacturer'
opening_type['Type'] = input_unit['openingType'][this_id]
if input_unit['openingType'][this_id]=='Window' or input_unit['openingType'][this_id]=='RoofWindow':
opening_type['Glazing'] = input_unit['glzgType'][this_id]
opening_type['GlazingGap'] = 'replace_xsi:nul'
opening_type['GlazingFillingType'] = None
opening_type['SolarTrans'] = input_unit['gVal'][this_id]
else:
opening_type['Glazing'] = 'replace_xsi:nul'
opening_type['GlazingGap'] = 'replace_xsi:nul'
opening_type['GlazingFillingType'] = None
opening_type['SolarTrans'] = 0
opening_type['FrameType'] = 'Wood'
opening_type['FrameFactor'] = input_unit['frameFactor'][this_id]
opening_type['UValue'] = input_unit['uVal'][this_id]
opening_types[f'OpeningType{this_id}'] = opening_type
# Output data for openings
openings = assessment['Openings'] = {}
# Looping through each opening and only including if data is entered
for this_id, name in enumerate(input_unit['openName']):
# Write inputs only if area is entered
if input_unit['openArea'][this_id]>0:
# Check for refernece levels that have not been listed in "levels"
try:
levels_naming[str(int(input_unit['openLevel'][this_id]-1))]
except Exception as exc:
raise st.error(f'''{err_open_str}
The level reference entered for opening "{name}" is not listed under "Levels"''') from exc
opening = {}
opening['this_id'] = this_id
counter = 0
for this_ido,this_type in enumerate(input_unit['openTypeName']):
if input_unit['openType'][this_id] == this_type:
opening['OpeningTypeIndex'] = this_ido
counter+=1
if counter == 0:
raise st.error(f'''{err_open_str}
The opening type assigned to "{name}" opening element does not exist''')
opening['Description'] = name
opening['LocationBuildingPartIndex'] = 0
wall_list = []
roof_list = []
for this_ido, this_type in enumerate(input_unit['opaqElementType']):
if this_type == "External wall" or this_type == "Sheltered wall":
wall_list.append(input_unit['opaqElementName'][this_ido])
elif this_type == "External roof":
roof_list.append(input_unit['opaqElementName'][this_ido])
counter = 0
for this_ido,parent in enumerate(wall_list):
if input_unit['parentElem'][this_id] == parent:
opening['LocationWallIndex'] = this_ido
counter+=1
for this_ido,parent in enumerate(roof_list):
if input_unit['parentElem'][this_id] == parent:
opening['LocationRoofIndex'] = this_ido
counter+=1
if counter == 0:
raise st.error(f'''{err_open_str}
The parent element "{input_unit["parentElem"][this_id]}"
referred by the "{name}" opening element does not exist
or it is not an External wall, a Sheltered wall or an External roof''')
# opening['LocationRoofIndex'] = 'replace_xsi:nul'
opening['Orientation'] = input_unit['openOrientation'][this_id]
opening['AreaType'] = 'Total'
opening['AreaScaleType'] = 'Meters'
opening['Area'] = input_unit['openArea'][this_id]
opening['AreaRecCalculation'] = []
opening['RoofLightsPitch'] = 0
openings[f'Opening{this_id}'] = opening
# Output data for thermal bridges
thermal_bridges = assessment['ThermalBridges'] = {}
# Looping through each TB and only including if data is entered
for tb,name in TBs.items():
length = input_unit['thermalBridges'][tb]['length']
psi = input_unit['thermalBridges'][tb]['psi']
if length > 0:
thermal_bridge = {}
thermal_bridge['TypeSource'] = 'IndependentlyAssessed'
thermal_bridge['Length'] = length
thermal_bridge['PsiValue'] = psi
thermal_bridge['K1Index'] = name
thermal_bridge['Imported'] = 'False'
thermal_bridge['Adjusted'] = psi
thermal_bridge['Reference'] = []
thermal_bridges[f'ThermalBridge-{tb}-{this_id}'] = thermal_bridge
# output data for mech vent
if input_unit['Mech vent present'] == "Yes":
mechvent = assessment['MechanicalVentilation'] = {}
mechvent['DataType'] = input_unit['Ventilation data type']
mechvent['Type'] = input_unit['Mech vent type']
mechvent['PcdfIndex'] = 'replace_xsi:nul'
mechvent['PcdfItem'] = 'replace_xsi:nul'
mechvent['ManufacturerSFP'] = input_unit['MVHR SFP']
mechvent['DuctType'] = input_unit['Duct type']
mechvent['WetRooms'] = int(input_unit['Wet rooms'])
mechvent['BrandModel'] = input_unit['Vent brand model']
mechvent['MVHRDuctInsulated'] = 'replace_xsi:nul'
mechvent['DuctInsulation'] = 'replace_xsi:nul'
mechvent['MVHREfficiency'] = input_unit['MVHR HR']
mechvent['ApprovedInstallation'] = "false"
mechvent['SFPFromInstallerCertificate'] = "false"
mechvent['MVHRSystemLocation'] = input_unit['System location']
if mechvent['MVHRSystemLocation'] == "Outside":
mechvent['MVHRDuctInsulated'] = input_unit['Duct insulation']
mechvent['DuctInsulationLevel'] = input_unit['Duct installation specs']
assessment['MechanicalVentilationDecentralised'] = []
assessment['HeatingsInteraction'] = 'SeparatePartsOfHouse'
# Output data for the main heating systems
# Check if heating type is local heating or heat network
if input_unit['Heating system type'] == "Local heating":
main_heating_system1 = assessment[f'MainHeatingSystem1'] = {}
main_heating_system1['HeatingDataType'] = input_unit['Heating data type']
main_heating_system1['Fraction'] = input_unit['Fraction']
main_heating_system1['PcdfIndex'] = int(input_unit['Database reference number'])
main_heating_system1['BoilerEfficiencyType'] = 'SplitEfficiences'
main_heating_system1['EfficiencyWinter'] = input_unit['Winter efficiency']
main_heating_system1['EfficiencySummer'] = input_unit['Summer efficiency']
main_heating_system1['TestMethod'] = 'replace_xsi:nul'
main_heating_system1['MHSCtrlPcdfIndex'] = 'replace_xsi:nul'
main_heating_system1['CompensatorPcdfIndex'] = 'replace_xsi:nul'
main_heating_system1['HetasApprovedSystem'] = 'false'
main_heating_system1['FlueType'] = 'NoneOrUnknown'
main_heating_system1['FanAssistedFlue'] = 'false'
main_heating_system1['McsCertificate'] = 'false'
main_heating_system1['Pumped'] = input_unit['Is MHS pumped']
main_heating_system1['HeatingPumpAge'] = input_unit['Heating pump age']
main_heating_system1['OilPumpInside'] = 'false'
main_heating_system1['HeatEmitter'] = input_unit['Heat emitter']
main_heating_system1['UnderfloorHeating'] = 'replace_xsi:nul'
main_heating_system1['CombiType'] = 'replace_xsi:nul'
main_heating_system1['CombiKeepHotType'] = 'replace_xsi:nul'
main_heating_system1['CombiStoreType'] = 'replace_xsi:nul'
main_heating_system1['ElectricCPSUtemperature'] = 'replace_xsi:nul'
main_heating_system1['FIcase'] = 0
main_heating_system1['FIwater'] = 'replace_xsi:nul'
main_heating_system1['ModelName'] = input_unit['Model name']
main_heating_system1['Manufacturer'] = input_unit['Manufacturer']
main_heating_system1['BurnerControl'] = 'replace_xsi:nul'
main_heating_system1['DelayedStartStat'] = 'false'
main_heating_system1['FlowTemperature'] = 'EnterValue'
main_heating_system1['BoilerInterlock'] = 'false'
main_heating_system1['StorageHeaters'] = {}
main_heating_system1['FlowTemperatureValue'] = input_unit['Flow temperature value']
main_heating_system1['SapCode'] = 'replace_xsi:nul'
main_heating_system1['FuelType'] = input_unit['Fuel type MHS']
main_heating_system1['CtrlSapCode'] = int(input_unit['Control SAP code'])
# Output data for the main heating system 2
# Currently left empty
main_heating_system2 = assessment[f'MainHeatingSystem2'] = {}
main_heating_system2['HeatingDataType'] = 'None'
main_heating_system2['Fraction'] = '0'
main_heating_system2['PcdfIndex'] = '0'
main_heating_system2['BoilerEfficiencyType'] = 'replace_xsi:nul'
main_heating_system2['EfficiencyWinter'] = 'replace_xsi:nul'
main_heating_system2['EfficiencySummer'] = 'replace_xsi:nul'
main_heating_system2['TestMethod'] = 'replace_xsi:nul'
main_heating_system2['MHSCtrlPcdfIndex'] = 'replace_xsi:nul'
main_heating_system2['CompensatorPcdfIndex'] = 'replace_xsi:nul'
main_heating_system2['HetasApprovedSystem'] = 'false'
main_heating_system2['FlueType'] = 'replace_xsi:nul'
main_heating_system2['FanAssistedFlue'] = 'false'
main_heating_system2['McsCertificate'] = 'false'
main_heating_system2['Pumped'] = 'replace_xsi:nul'
main_heating_system2['HeatingPumpAge'] = 'replace_xsi:nul'
main_heating_system2['OilPumpInside'] = 'false'
main_heating_system2['HeatEmitter'] = 'replace_xsi:nul'
main_heating_system2['UnderfloorHeating'] = 'replace_xsi:nul'
main_heating_system2['CombiType'] = 'replace_xsi:nul'
main_heating_system2['CombiKeepHotType'] = 'replace_xsi:nul'
main_heating_system2['CombiStoreType'] = 'replace_xsi:nul'
main_heating_system2['ElectricCPSUtemperature'] = 'replace_xsi:nul'
main_heating_system2['FIcase'] = 'replace_xsi:nul'
main_heating_system2['FIwater'] = 'replace_xsi:nul'
main_heating_system2['BurnerControl'] = 'replace_xsi:nul'
main_heating_system2['DelayedStartStat'] = 'false'
main_heating_system2['FlowTemperature'] = 'EnterValue'
main_heating_system2['BoilerInterlock'] = 'false'
main_heating_system2['StorageHeaters'] = {}
main_heating_system2['FlowTemperatureValue'] = 'replace_xsi:nul'
main_heating_system2['SapCode'] = 'replace_xsi:nul'
main_heating_system2['FuelType'] = 'replace_xsi:nul'
main_heating_system2['CtrlSapCode'] = '2100'
else:
# Left empty as system is defined as heat network
# Elmhurst requires two main heating systems
for mhs in range(2):
main_heating_system = assessment[f'MainHeatingSystem{mhs+1}'] = {}
main_heating_system['HeatingDataType'] = 'None'
main_heating_system['Fraction'] = 0
main_heating_system['PcdfIndex'] = 0
main_heating_system['BoilerEfficiencyType'] = 'replace_xsi:nul'
main_heating_system['EfficiencyWinter'] = 0
main_heating_system['EfficiencySummer'] = 0
main_heating_system['TestMethod'] = 'replace_xsi:nul'
main_heating_system['MHSCtrlPcdfIndex'] = 'replace_xsi:nul'
main_heating_system['CompensatorPcdfIndex'] = 'replace_xsi:nul'
main_heating_system['HetasApprovedSystem'] = 'false'
main_heating_system['FlueType'] = 'replace_xsi:nul'
main_heating_system['FanAssistedFlue'] = 'false'
main_heating_system['McsCertificate'] = 'false'
main_heating_system['Pumped'] = 'replace_xsi:nul'
main_heating_system['HeatingPumpAge'] = 'replace_xsi:nul'
main_heating_system['OilPumpInside'] = 'false'
main_heating_system['HeatEmitter'] = 'replace_xsi:nul'
main_heating_system['UnderfloorHeating'] = 'replace_xsi:nul'
main_heating_system['CombiType'] = 'replace_xsi:nul'
main_heating_system['CombiKeepHotType'] = 'replace_xsi:nul'
main_heating_system['CombiStoreType'] = 'replace_xsi:nul'
main_heating_system['ElectricCPSUtemperature'] = 'replace_xsi:nul'
main_heating_system['FIcase'] = 'replace_xsi:nul'
main_heating_system['FIwater'] = 'replace_xsi:nul'
main_heating_system['BurnerControl'] = 'replace_xsi:nul'
main_heating_system['DelayedStartStat'] = 'false'
main_heating_system['FlowTemperature'] = 'replace_xsi:nul'
main_heating_system['BoilerInterlock'] = 'false'
main_heating_system['StorageHeaters'] = {}
main_heating_system['FlowTemperatureValue'] = 'replace_xsi:nul'
main_heating_system['SapCode'] = 'replace_xsi:nul'
main_heating_system['FuelType'] = 'replace_xsi:nul'
main_heating_system['CtrlSapCode'] = 'replace_xsi:nul'
# Output data for the secondary heating systems.
# This is an empty item that Elmhurst requires as input
secondary_heating = assessment['SecondaryHeating'] = {}
secondary_heating['HeatingDataType'] = 'None'
secondary_heating['TestMethod'] = 'replace_xsi:nul'
secondary_heating['HetasApprovedSystems'] = 'false'
secondary_heating['Efficiency'] = 'replace_xsi:nul'
secondary_heating['SapCode'] = 0
secondary_heating['FuelType'] = 'replace_xsi:nul'
# Output data for community heating
# Check if local heating or heat network
if input_unit['Heating system type'] == "Local heating":
# Left empty as heating system defined as local heating
community_heating = assessment['CommunityHeating'] = {}
community_heating['Type'] = 'None'
community_heating['DistributionLossSpace'] = input_unit['Distribution type space']
community_heating['DistributionLossWater'] = 'replace_xsi:nul'
community_heating['ChargingLinked'] = 'replace_xsi:nul'
# Elmhurst expects 5 heat sources as input, even if system is local heating
heat_source = community_heating['HeatSource'] = {}
for chs in range(5):
comm_heat_source = heat_source[f'CommunityHeatSource{chs+1}'] = {}
comm_heat_source['Source'] = 'None'
comm_heat_source['Fraction'] = 'replace_xsi:nul'
comm_heat_source['FuelType'] = 'replace_xsi:nul'
comm_heat_source['OveralEfficiency'] = 'replace_xsi:nul'
comm_heat_source['HeatPowerRatio'] = 'replace_xsi:nul'