Source code for viiapackage.strengthening.l2.l2_054

### ===================================================================================================================
###   L2-054 strengthening measure
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import Union, TYPE_CHECKING
from warnings import warn

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.shapes import Wall, Floor
from rhdhv_fem.connections import Interface, NoConnection
from rhdhv_fem.fem_math import fem_purge_points, fem_angle_between_2_vectors

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.strengthening.helper_functions import viia_l2_base


### ===================================================================================================================
###   2. Function to create L2-054 strengthening measure
### ===================================================================================================================

[docs]def viia_l2_054( project: ViiaProject, variant: int, connection: Union[str, Interface, NoConnection] = None, shape_1: Union[str, Wall] = None, shape_2: Union[str, Floor] = None) -> Interface: """ This function creates an L2-054-measure. It can create an interface in between a floor and wall, or make an existing interface linear. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - variant (int): The variant number of the measure that is in the GMC. - connection (str or obj): The interface that has to be made linear or the NoConnection that should be replaced. Both the name or object reference can be provided. Default is None, in this case shape_1 and shape_2 should be provided. - shape_1 (str or obj): The object reference or name of the wall to what the interface should be applied. Default is None, in this case the interface should be provided. - shape_2 (str or obj): The object reference or name of the floor to what the interface should be applied. Default is None, in this case the interface should be provided. Output: - The strengthening measure is added between shape_1 and shape_2 or the interface is made linear. - Returns the interface object reference of the measure. For example: - To make a linear interface from a non-linear interface, the following input can be used: >>> project.viia_l2_054(interface='name_of_interface') - To make a new linear interface between two shapes, the following input can be used: >>> project.viia_l2_054(shape_1='name_of_first_shape', shape_2='name_of_second_shape') """ if connection is not None: if shape_1 or shape_2: raise ValueError( "ERROR: viia_l2_054 only accepts a interface or a combination of two shapes. Not both.") return viia_l2_base( project=project, measure_type='L2-054', variant=variant, connection=connection) if not (shape_1 and shape_2): raise ValueError("ERROR: When no interface two shapes should be given.") # Check if the connecting lines are parallel to the spanning direction of the floor if isinstance(shape_1, str): shape_1 = project.find(description=shape_1, collection='surfaces') if isinstance(shape_2, str): shape_2 = project.find(description=shape_2, collection='surfaces') connecting_lines = shape_1.get_connecting_lines(shape=shape_2, include_openings=False) if connecting_lines: directions = fem_purge_points([line.get_direction().vector for line in connecting_lines]) for direction in directions: if abs(fem_angle_between_2_vectors(a=direction, b=shape_2.x_axis_direction().vector, degrees=True)) < 45: warn(f"L2-054 should be made perpendicular to the spanning direction of the floor, this seems not be " f"the case. Please check the model.") break return viia_l2_base( project=project, measure_type='L2-054', variant=variant, shape_1=shape_1, shape_2=shape_2, shape_1_types=Wall, shape_2_types=Floor)
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================