Source code for viiapackage.connections.get_dimensions

### ===================================================================================================================
###   Helper functions
### ===================================================================================================================
# Copyright ©VIIA 2024

### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================

# General imports
from typing import Dict

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.shapes import Shapes
from rhdhv_fem.geometries import ProfileGeometryModel, IsotropicThickness, \
    PredefinedProfile, Rectangle, Box, LShape, UShape, IShape, TShape, CircleProfile, Pipe


### ===================================================================================================================
###   2. Functions to get dimensions for geometry of interfaces
### ===================================================================================================================

[docs]def viia_get_thickness_from_geometry_model(shape: Shapes) -> float: """ Function to get the thickness or height of a geometry model. Input: - shape (obj): Shape for which the thickness should be retrieved. Output: - Returns the thickness as float, in [m]. """ if isinstance(shape.geometry.geometry_model, IsotropicThickness): return shape.geometry.geometry_model.thickness elif isinstance(shape.geometry.geometry_model, ProfileGeometryModel): return shape.geometry.geometry_model.height else: raise NotImplementedError( f"ERROR: The thickness of the shape can't be derived from the geometry-model for " f"{shape.geometry.geometry_model.__class__.__name__}.")
[docs]def viia_get_width_from_geometry_model(shape: Shapes) -> float: """ Get the width a geometry model. Input: - shape (obj): Shape for which the width should be retrieved. Output: - Returns the width as float, in [m]. """ if isinstance(shape.geometry.geometry_model, PredefinedProfile): if shape.geometry.geometry_model.profile_properties['class'] in ['IShape']: return max(shape.geometry.geometry_model.profile_properties['width_flange_bottom'], shape.geometry.geometry_model.profile_properties['width_flange_top']) if shape.geometry.geometry_model.profile_properties['class'] in ['UShape', 'LShape']: return shape.geometry.geometry_model.profile_properties['width'] elif isinstance(shape.geometry.geometry_model, (Rectangle, Box, LShape, UShape)): return shape.geometry.geometry_model.width elif isinstance(shape.geometry.geometry_model, IShape): return max(shape.geometry.geometry_model.width_flange_bottom, shape.geometry.geometry_model.width_flange_top) elif isinstance(shape.geometry.geometry_model, TShape): return shape.geometry.geometry_model.width elif isinstance(shape.geometry.geometry_model, (CircleProfile, Pipe)): return shape.geometry.geometry_model.diameter else: raise NotImplementedError( f"ERROR: The width of the shape can't be derived from the geometry-model for " f"{shape.geometry.geometry_model.__class__.__name__}.")
[docs]def viia_get_timberfloor_dimensions(shape: Shapes) -> Dict[str, float]: """ Get the dimensions for the timber floors with joists (modelled with equivalent plates). Input: - shape (obj): Shape for which the thickness should be retrieved. Output: - Returns dictionary with thickness as float, in [m]. """ # Get width and ctc of beams # For example "LIN-HBV-PLANKEN-0.018-0.05-0.2-0.6-6.0-12.0-DENSIT926" if 'PLANKEN' not in shape.name and 'PLATEN' not in shape.name: raise ValueError(f"ERROR: Expected timber floor with joists, but retrieved {shape.name}, please check.") # Collect the profile dimensions profile = None if 'PLANKEN' in shape.name: profile = shape.name.split('PLANKEN')[-1].split('-') elif 'PLATEN' in shape.name: profile = shape.name.split('PLATEN')[-1].split('-') if profile is None: raise ValueError("ERROR: Profile dimensions for connection could not be retrieved.") dimensions = { 'thickness': float(profile[1]), 'joist_width': float(profile[2]), 'joist_height': float(profile[3]), 'joist_ctc': float(profile[4])} # Add span and width of floor if present if len(profile) > 5 and 'DENSIT' not in profile[5]: dimensions['floor_span']: float(profile[5]) if len(profile) > 6 and 'DENSIT' not in profile[6]: dimensions['floor_width']: float(profile[6]) return dimensions
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================