diff --git a/archetypes.py b/archetypes.py index a4b72f0..e558479 100644 --- a/archetypes.py +++ b/archetypes.py @@ -4,6 +4,7 @@ import json from urllib.request import urlopen from bs4 import BeautifulSoup + def process_formula(formula, hdd): formula = formula.replace('( hdd < ', '').replace(') ', '').split(':') for equation in formula: @@ -14,6 +15,7 @@ def process_formula(formula, hdd): else: return float(equation) + with open(c.nrcan_urls, 'r') as f: urls = xmltodict.parse(f.read(), force_list=['standards_per_period']) @@ -100,6 +102,6 @@ for standard in standards['standard']: archetype["constructions"]["GroundFloor"] = { "opaque_surface_name": f'{period}_{climate_zone}' } - dictionary["archetypes"].append({"archetype": archetype}) + dictionary["archetypes"].append(archetype) with open(f'{c.output_path}/archetypes.json', 'w') as f: json.dump(dictionary, f, indent=2) diff --git a/configuration.py b/configuration.py index 5bb9d36..6ef1933 100644 --- a/configuration.py +++ b/configuration.py @@ -51,15 +51,15 @@ surface_types = { { "Brickwork Outer": 0.1, "virtual_no_mass": 0, - "XPS Extruded Polystyrene - CO2 Blowing": 0.0794, + "XPS Extruded Polystyrene- CO2 Blowing": 0.0794, "Concrete Block (Medium)": 0.1, "Gypsum Plastering": 0.013 }, { "Lightweight Metallic Cladding": 0.006, "virtual_no_mass": 0, - "XPS Extruded Polystyrene - CO2 Blowing": 0.0877, - "Gypsum Plasterboard": 0.013 + "XPS Extruded Polystyrene- CO2 Blowing": 0.0877, + "Gypsum Plastering": 0.013 } ] } diff --git a/opaque_surfaces.py b/opaque_surfaces.py index 3d67a18..a649e47 100644 --- a/opaque_surfaces.py +++ b/opaque_surfaces.py @@ -3,6 +3,7 @@ import xmltodict import json from urllib.request import urlopen + def process_formula(formula, hdd): formula = formula.replace('( hdd < ', '').replace(') ', '').split(':') for equation in formula: @@ -13,16 +14,20 @@ def process_formula(formula, hdd): else: return float(equation) + def create_virtual_no_mass_material(u_value, name, materials, construction): r_value = 0 for key in construction: if key != 'virtual_no_mass': material_thickness = construction[key] + material_conductivity = 0 for material in materials: if key in material.keys(): - print(material[key]['conductivity']) material_conductivity = material[key]['conductivity'] - r_value += (material_thickness/material_conductivity) + if material_conductivity != 0: + r_value += (material_thickness/material_conductivity) + else: + r_value += 0 r_value = 1/u_value - r_value new_virtual_no_mass_material = { name: { @@ -59,8 +64,7 @@ for standard in urls['nrcan']['standards_per_period']['standard']: no_mass_index += 1 create_virtual_no_mass_material(u_value,material_name, materials, construction) opaque_surface = { - "opaque_surface": { - "name": f'{standard["@period_of_construction"]}_{climate_zone}', + f'{standard["@period_of_construction"]}_{climate_zone}': { "period_of_construction": f'{standard["@period_of_construction"]}', "climate_zone": f'{climate_zone}', "type": f"{table['boundary_condition']}{table['surface']}", diff --git a/transparent_surfaces.py b/transparent_surfaces.py index a865fb0..b5dfa1f 100644 --- a/transparent_surfaces.py +++ b/transparent_surfaces.py @@ -29,15 +29,13 @@ for standard in urls['nrcan']['standards_per_period']['standard']: u_value = process_formula(table['formula'], c.hdd_canadian_climate_zones[climate_zone]) windows_dictionary['transparent_surfaces'].append( { - "transparent_surface": { - "name": f'{ table["surface"]}_{standard["@period_of_construction"]}_{climate_zone}', + f'{ table["surface"]}_{standard["@period_of_construction"]}_{climate_zone}': { "period_of_construction": f'{standard["@period_of_construction"]}', "climate_zone": f'{climate_zone}', "shgc": c.shgc_for_canadian_climate_zones[climate_zone], "type": table['surface'], "frame_ratio": 0, "u_value": u_value - } }) with open(f'{c.output_path}/transparent_surfaces.json', 'w') as f: