Source code for viiapackage.supports.pile_foundation.pile_properties.get_building_fundamental_frequency

### ===================================================================================================================
###   FUNCTION viia_get_building_fundamental_frequency
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
from pathlib import Path
import json

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.fem_math import fem_greater

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


### ===================================================================================================================
###   2. Function to collect the building fundamental frequency from A3 analysis
### ===================================================================================================================

[docs]def viia_get_building_fundamental_frequency(project: ViiaProject, folder: Optional[Path] = None) -> float: """ Function to retrieve building fundamental frequency from latest A3 results. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - folder (path): Optional input to specify the input folder. By default the default location for the file is used, which should be the location for the VIIA workflow. Input used for component testing. Output: - Returns fundamental frequency of the building as a float. """ if not folder: # Find the latest created A3 folder folder = project.viia_get_latest_model_folder(analysis_nr='A3', version=1) if not folder: raise FileNotFoundError( "ERROR: The folder for A3 analysis could not be found. Please make sure the A3 analysis has been performed " "before you continue with the modelling of piles in flexbase model.") # Find the Eigenvalue json-file, that should have been generated after running analysis A3 json_file = project.viia_get_file(path=folder, starts_with='Eigen', suffix='.json') # If file could not be found if not json_file.exists(): raise FileNotFoundError( f"ERROR: The json-file (Eigen.json) with the building eigenfrequencies from A3 analysis could not be " f"found in {folder.as_posix()}. Please check, did you perform the result handling for this A3 analysis?") # Read the information on the eigenfrequencies of the building with open(json_file) as file: json_data = json.load(file) # Get the maximum value is the x- and y-direction max_percentage_x = max(json_data['Eigen']['modal_x']) max_percentage_y = max(json_data['Eigen']['modal_y']) # Select governing direction x_dominate = False max_percentage = max_percentage_y if fem_greater(max_percentage_x, max_percentage_y): max_percentage = max_percentage_x x_dominate = True # Find the value of the frequency if x_dominate: index = json_data['Eigen']['modal_x'].index(max_percentage_x) else: index = json_data['Eigen']['modal_y'].index(max_percentage_y) fundamental_frequency = json_data['Eigen']['frequency_list'][index] # Notification for the user project.write_log( f"The Fundamental frequency of the building is {fundamental_frequency} with mass participation " f" {max_percentage}%. Results are extracted from folder: {folder.as_posix()}.") # Return the fundamental frequency return fundamental_frequency
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================