Source code for viiapackage.strengthening.l5.l5a

### ===================================================================================================================
###   L5-A strengthening measure
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, Union, Tuple

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.shapes import Wall, MainSurfaceReinforcement
from rhdhv_fem.fem_math import fem_compare_coordinates

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.shape_operations import viia_get_wall_horizontal_direction
from viiapackage.strengthening.helper_functions import viia_check_shape_argument, viia_check_measure_in_gmc


### ===================================================================================================================
###   2. Function to create L5-A strengthening measures
### ===================================================================================================================

[docs]def viia_l5a( project: ViiaProject, variant: int, wall: Union[Wall, str], application_type: str = 'center') \ -> Tuple[Wall, MainSurfaceReinforcement]: """ This function creates a L5-A-measure (Reinforced concrete wall addition) for a selected wall. It adds a concrete wall of 60mm, C20/25 (shotcrete) and applies a grid reinforcement of 1x2R8*-150. *2R12 IS ADDED. Optional is the inclusion of eccentricity. The strengthening measure will be modelled around openings and can be applied on walls in all directions. 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. - wall (obj): The object reference of the wall that has to be strengthened. Alternative (str): Name of the wall to be strengthened. - application_type (str): Default value is 'center', in which case no eccentricity is applied. If 'outward' or 'inward' is provided the eccentricity direction is determined based on the connected floors. If 'positive' or 'negative' is provided the eccentricity direction is determined based on the normal vector of the wall. Accepted input options are 'center', 'outward', 'positive', 'inward' or 'negative'. Output: - The strengthening measure is added to the wall as sub-shapes. - Newly created wall shape and reinforcement shape are returned in a tuple; first is wall and second is the surface reinforcement. - The strengthening measure is created in DIANA (if software is DIANA and model created). For example: .. code-block:: python project.viia_l5a(wall) This example will apply the L5-A measure with a concrete wall and grid reinforcement. No eccentricities applied. .. code-block:: python project.viia_l5a(wall, 'positive') The example has the same result as the previous, but now eccentricity in the direction of the local Z-axis of wall has been applied. """ # Check if measure is in GMC measure_type = 'L5-A' measure_sub_type = f"{measure_type}-{int(variant)}" viia_check_measure_in_gmc(project=project, measure_sub_type=measure_sub_type) # Argument handling wall = viia_check_shape_argument(project, wall, 'viia_l5a') if not isinstance(wall, Wall): raise TypeError(f"ERROR: The provided wall is not of type Wall, Provided was: {wall}.") if application_type.lower() not in ['center', 'positive', 'negative', 'outward', 'inward']: raise ValueError( f"ERROR: Input for viia_l5a function for 'application_type' has to be 'center', 'positive', " f"'negative', 'outward' or 'inward'. Check your input ({application_type}).") application_type = application_type.lower() # Compute normalVector of wall, which can point either inward or outward normal_vector = wall.normal_vector() # Compute normal_vector that points outward, both are used to compute the eccentricities normal_vector_outward = wall.outward_vector() # Material and geometry to be used for strengthening measure new_wall_name = f"{wall.name.split('-')[0]}-WANDEN-L5A-BETON-C20/25-60" # The material for the new wall shape is set in the project constants # Create the new material, if not present new_material_name = project.project_specific['strengthening_measures']['L5-A']['material'] check_bool = False new_material_object = None for material in project.collections.materials: if material.name == new_material_name: check_bool = True new_material_object = material break if not check_bool: new_material_object = project.viia_create_material(material_name=new_material_name) if new_material_object is None: raise RuntimeError( "ERROR: Some error occurred in the generation of the material for the L5-A strengthening measure.") # Eccentricity is half the thickness of the wall and half of the new concrete thickness = project.project_specific['strengthening_measures']['L5-A']['thickness'] eccentricities = {} if application_type == 'center': eccentricity = None else: eccentricity = round(wall.geometry.geometry_model.thickness / 2 + thickness / 2, project.rounding_precision) if application_type == 'positive': pass elif application_type == 'negative': eccentricity *= -1 elif (application_type == 'outward' and not fem_compare_coordinates(coordinate1=normal_vector, coordinate2=normal_vector_outward)): eccentricity *= -1 elif (application_type == 'inward' and fem_compare_coordinates(coordinate1=normal_vector, coordinate2=normal_vector_outward)): eccentricity *= -1 eccentricities = {'z': eccentricity} # always oop eccentricity if not eccentricities: raise RuntimeError( "ERROR: Some error occurred in the calculation of the eccentricity for the L5-A " "strengthening measure.") displacement_vector = [val*eccentricity for val in normal_vector] # The new geometry is created (or checked if it is already present) new_geometry_name = 'WAND-' + str(int(thickness * 1000)) new_geometry_object = None check_bool = False for geometry_object in project.collections.geometries: if geometry_object.name == new_geometry_name: check_bool = True new_geometry_object = geometry_object break if not check_bool: new_geometry_object = project.viia_create_geometry( geometry_name=new_geometry_name, material_object=new_material_object, class_type='Wall') if new_geometry_object is None: raise RuntimeError( "ERROR: Some error occurred in the generation of the geometry for the L5-A strengthening measure.") # The points for the new wall shape are the same as for the existing new_points = wall.contour.get_points() # The material for the reinforcement of the new wall shape is set in the project constants # Create the new material, if not present reinforcement_material_name =\ project.project_specific['strengthening_measures']['L5-A']['reinforcement_material'] check_bool = False reinforcement_material_object = None for material in project.collections.materials: if material.name == reinforcement_material_name: check_bool = True reinforcement_material_object = material break if not check_bool: reinforcement_material_object = project.viia_create_material(material_name=reinforcement_material_name) if reinforcement_material_object is None: raise RuntimeError( "ERROR: Some error occurred in the generation of the reinforcement material for the L5-A " "strengthening measure.") # The new geometry is created (or checked if it is already present) reinforcement_geometry_name = \ 'L5A-WAPENING-' + project.project_specific['strengthening_measures']['L5-A']['reinforcement'] check_bool = False reinforcement_geometry_object = None for geometry_object in project.collections.geometries: if geometry_object.name == reinforcement_geometry_name: check_bool = True reinforcement_geometry_object = geometry_object break if not check_bool: reinforcement_geometry_object = project.viia_create_geometry( geometry_name=reinforcement_geometry_name, material_object=reinforcement_material_object, class_type='Line_Reinforcement') if reinforcement_geometry_object is None: raise RuntimeError( "ERROR: Some error occurred in the generation of the reinforcement geometry for the L5-A " "strengthening measure.") # Create the new shapes in PY-memory and in model if created new_wall_object = project.viia_create_wall( name=wall.layer, material=new_material_object, geometry=new_geometry_object.name.split('-')[-1], points=[new_points]) new_wall_object.name = new_wall_object.name.replace('WANDEN', 'WANDEN-L5A') new_wall_object.openings = wall.openings if eccentricities: new_wall_object.eccentricities = eccentricities points = new_wall_object.contour.get_points() if eccentricities: new_points = [] for point in points: new_points.append([point[i]+displacement_vector[i] for i in range(3)]) points = new_points reinforcement_object = project.viia_create_main_surface_reinforcement( name=new_wall_object.layer, points=[points], material=reinforcement_material_object.name, geometry=reinforcement_geometry_object.name, discretisation='element', host_members=[new_wall_object], element_x_axis=viia_get_wall_horizontal_direction(wall=wall).vector) reinforcement_object.name = \ reinforcement_object.name.replace('L5A-WAPENING-R16_150xR12_150-', '').replace('WAPENING', 'WAPENING-L5A') openings = wall.openings if eccentricities and openings: new_openings = [] for opening in openings: points = opening.get_points() new_points = [] for point in points: new_points.append([point[i] + displacement_vector[i] for i in range(3)]) new_openings.append(project.create_polyline(new_points)) openings = new_openings reinforcement_object.openings = openings # Set the data for strengthening in attribute of wall wall.add_meta_data({'strengthening': measure_sub_type}) project.create_part(name=new_wall_name, shapes=[wall, reinforcement_object, new_wall_object]) # Notifications for user project.write_log(f"L5-A measure applied on wall {wall.name}.") return new_wall_object, reinforcement_object
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================