Source code for viiapackage.materials.viia_change_damping_explicit

### ===================================================================================================================
###   Function to update the damping parameters for explicit analysis
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING
import re

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.viiaGeneral import _viia_get_material_database
from viiapackage.materials.viia_get_material_group import viia_get_material_group


### ===================================================================================================================
###    2. Convert damping parameters
### ===================================================================================================================

[docs]def viia_change_damping_explicit(project: ViiaProject): """ This function will change the beta damping for any material in the project to corresponding value for explicit analysis. It will overrule the default set for materials in the VIIA database, according latest BoD. Function use: ``ABAQUS`` Input: - project (obj): VIIA project object containing collections of fem objects and project variables. Output: - The beta damping for all materials in the object will be change to corresponding explicit value from BoD. The material properties will be updated. """ # Get the database from the viiaPackage json_data = _viia_get_material_database(project=project) # Check materials collections if project.collections.materials is None: raise ValueError("ERROR: No material is found, please check before proceding.") # Loop through all the materials in the project for material in project.collections.materials: # Next 2 lines are using regex to get rid of mesh size part in the material name. # i.e for MW-KLEI<1945-0.25x0.25, we want to detect the -0.25x0.25 and remove it for following steps. # The following expression can detect this pattern "-[one-digit number before decimal].[any digit number] # x[one-digit number before decimal].[any digit number]" mesh_part = r"\-\d[\.|\,][\d]*x\d[\.|\,][\d]*" material_name = re.sub(mesh_part, '', material.name) if '-DENSIT' in material_name: material_name = material_name.split('-DENSIT')[0] try: material_group = viia_get_material_group(project=project, material_name=material_name) except NotImplementedError: project.write_log( f"WARNING: {material_name} is not recognised from material database, therefore, " f"beta damping is not changed.") continue if material_group == 'LineMass-Truss': material_group = 'Linear' line_mass_value = material_name.split('LIN-LIJNMASSA')[1] material_name = 'LIN-LIJNMASSA' project.write_log( f"The material group of {material_name}{line_mass_value} is LineMass-Truss, " f"now it is set to"f" Linear to be able to change beta damping.") if material_group in json_data[0]: if material_name in json_data[0][material_group]: material_analysis_dict = json_data[0][material_group][material_name]['analysis_specific'] material_model = material.material_model beta_old = material_model.aspects[0].stiffness_factor if beta_old == material_analysis_dict['NLTH_explicit']['rayleigh damping parameters'][1]: continue elif beta_old != material_analysis_dict['NLTH_explicit']['rayleigh damping parameters'][1]: beta = material_analysis_dict['NLTH_explicit']['rayleigh damping parameters'][1] material_model.aspects[0].stiffness_factor = beta
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================