diff --git a/generate_geometry.py b/generate_geometry.py index d2d1961..135d92f 100644 --- a/generate_geometry.py +++ b/generate_geometry.py @@ -149,32 +149,62 @@ apm = ApertureManager(rplus1) for pattern in "front", "back": apm.fix_face(pattern) - apm.add_from_border(window_pvc, count=24) + apm.add_from_border( + construction=window_pvc, + count=24 + ) for pattern in "left", "right": apm.fix_face(pattern) - apm.add_from_border(window_pvc, count=6) + apm.add_from_border( + construction=window_pvc, + count=6 + ) apm.fix_dim(3.8,2.9,0) for pattern in ["wall8", "wall6", "wall4"]: apm.set(rdc, pattern, use_orientation=False) - apm.add_from_center(simple_glass_wall, count=1) + apm.add_from_center( + construction=simple_glass_wall, + count=1 + ) apm.fix_face("wall7", use_orientation=False) -apm.add_from_center(simple_glass_wall, aperture_type="door", count=1) +apm.add_from_center( + construction=simple_glass_wall, + aperture_type="door", + count=1 +) apm.fix_dim(1.2,1.3,1) apm.fix_face("wall9", use_orientation=False) -apm.add_from_border(window_pvc, count=22) +apm.add_from_border( + construction=window_pvc, + count=22 +) apm.fix_face("wall0", use_orientation=False) -apm.add_from_border(window_pvc, count=6) +apm.add_from_border( + construction=window_pvc, + count=6 +) apm.fix_face("wall1", use_orientation=False) -apm.add_from_border(window_pvc, count=24) +apm.add_from_border( + construction=window_pvc, + count=24 +) apm.fix_dim(2,2,0) apm.fix_face("wall2", use_orientation=False) -apm.add_from_center(simple_glass_wall, aperture_type="door", count=1) +apm.add_from_center( + construction=simple_glass_wall, + aperture_type="door", + count=1 +) apm.fix_dim(4,2,0) for pattern in ["Face3", "Face4"]: apm.set(meeting, pattern, use_orientation=False) - apm.add_from_center(simple_glass_wall, aperture_type="door", count=1) + apm.add_from_center( + construction=simple_glass_wall, + aperture_type="door", + count=1 + ) geom = Face3D([ diff --git a/generate_geometry_from_yaml.py b/generate_geometry_from_yaml.py index 7fb8028..34e9c13 100644 --- a/generate_geometry_from_yaml.py +++ b/generate_geometry_from_yaml.py @@ -112,23 +112,27 @@ def get_variables(metadata: dict) -> dict: level_walls: list[Wall] = [] for face in site[building_name][level_name].faces: if isinstance(face.type, Wall): - construction = constructions.get("walls", "wall_parpaing") - face.properties.energy.construction = CONSTLIB[construction] + construction_name = constructions.get("walls") + construction = CONSTLIB.get(construction_name) + if construction is not None: + face.properties.energy.construction = construction level_walls.append(face) if isinstance(face.type, Floor): - construction = constructions.get("floors") - if not construction or construction not in CONSTLIB: + construction_name = constructions.get("floors") + construction = CONSTLIB.get(construction_name) + if construction is None: continue if face.boundary_condition != Ground(): - LOGGER.info("Setting floor construction %s on %s", construction, face) - face.properties.energy.construction = CONSTLIB[construction] + LOGGER.info("Setting floor construction %s on %s", construction_name, face) + face.properties.energy.construction = construction if isinstance(face.type, RoofCeiling): - construction = constructions.get("roofs") - if not construction or construction not in CONSTLIB: + construction_name = constructions.get("roofs") + construction = CONSTLIB.get(construction_name) + if construction is None: continue if face.boundary_condition != Outdoors(): - LOGGER.info("Setting roof construction %s on %s", construction, face) - face.properties.energy.construction = CONSTLIB[construction] + LOGGER.info("Setting roof construction %s on %s", construction_name, face) + face.properties.energy.construction = construction # now we can add apertures apertures = level_metadata.get("apertures", {}) if "numbers" not in apertures: @@ -187,13 +191,14 @@ def get_variables(metadata: dict) -> dict: sill_height = sill_height ) try: - construction = constructions[i] + construction_name = constructions[i] except IndexError: - construction = apertures.get("construction", "window_pvc") + construction_name = apertures.get("construction") + construction=CONSTLIB.get(construction_name) apm.face = face apm.set_u_v_bounds() apm.add_from_border( - CONSTLIB[construction], + construction=construction, count=count, aperture_type=aperture_type ) @@ -204,18 +209,17 @@ def get_variables(metadata: dict) -> dict: if "geometry" not in element_metadata: continue face = level_walls[element_metadata.get("index", 0)] - # design choice, maybe not perfect # we add an aperture so boundary conditions need to be outdoors + # design choice, maybe not perfect, we could have an indoor aperture face.boundary_condition = Outdoors() points = prepare(element_metadata["geometry"], variables=level_variables) - construction = element_metadata.get("construction", "simple_glass_wall") - if construction not in CONSTLIB: - continue + construction_name = element_metadata.get("construction") + construction = CONSTLIB.get(construction_name) LOGGER.warning("GOT ELEMENT %s on %s", element_name, face) add_aperture( face, Face3D(points), - construction=CONSTLIB[construction], + construction=construction, label=element_name, aperture_type=element_metadata.get("type", "door") ) diff --git a/src/idfhub/helpers/geometry.py b/src/idfhub/helpers/geometry.py index 40bc268..8234e49 100644 --- a/src/idfhub/helpers/geometry.py +++ b/src/idfhub/helpers/geometry.py @@ -256,25 +256,31 @@ def aperture_geometry( def add_aperture( face: Face, geometry: Face3D, - construction: WindowConstruction|OpaqueConstruction, + construction: WindowConstruction | OpaqueConstruction | None, label: str, aperture_type: str ): """create the aperture given its geometry""" - if aperture_type == "door" and isinstance(construction, WindowConstruction): + identifier = f"{face.identifier}_{label}" + if aperture_type == "door" : aperture = Door( - identifier=f"{face.identifier}_{label}", + identifier=identifier, geometry=geometry, - is_glass=True + is_glass=isinstance(construction, WindowConstruction) ) - face.add_door(aperture) - if aperture_type != "door": + else: aperture = Aperture( - identifier=f"{face.identifier}_{label}", + identifier=identifier, geometry=geometry ) + if construction is not None: + aperture.properties.energy.construction = construction + if aperture_type == "door": + face.add_door(aperture) + else: face.add_aperture(aperture) + @dataclass class Dims: """paramètre dimensionnels des ouvertures""" @@ -348,7 +354,7 @@ def set_u_v_bounds(self): def _add( self, origin: Point3D, - construction: WindowConstruction, + construction: WindowConstruction | None, label: str, aperture_type: str = "aperture", ): @@ -369,10 +375,10 @@ def _add( def add_from_center( self, - construction: WindowConstruction, + construction: WindowConstruction | None, aperture_type: str = "aperture", - ecart:float|None = None, - count:int = 1 + ecart: float | None = None, + count: int = 1 ): """ajoute les ouvertures symétriquement par rapport au centre""" translate = self.dims.width if not ecart else self.dims.width + ecart @@ -390,10 +396,10 @@ def add_from_center( def add_from_border( self, - construction: WindowConstruction, + construction: WindowConstruction | None, aperture_type: str = "aperture", - ecart:float|None = None, - count:int = 1 + ecart: float | None = None, + count: int = 1 ): """ajoute les ouvertures depuis un bord""" if not ecart: