Source code for viiapackage.supports.shallow_foundation.calculate_standard_values

### ===================================================================================================================
###   Calculate standard values for the shallow foundations
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List, Dict, Tuple, Union
from warnings import warn
import math

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.database import myviia_get_a1_results, myviia_get_progress, myviia_login


### ===================================================================================================================
###   2. Function to calculate the properties
### ===================================================================================================================

[docs]def viia_calculate_shallow_foundation_stiffness( project: ViiaProject, mass: float, area: float, cut_off_frequency: float = 50) -> float: """ Function to calculate the cut-off value for spring stiffness for the pile foundation based on the mass on the pile. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - total_mass (float): Total mass of the building, in [kg]. - cut_off_frequency (float): Limit for the stiffness calculation to prevent base isolation behaviour, in [Hz]. Default value for shallow foundations is 50 Hz. Output: - Returns the value for the spring stiffness to be used in the model, in [N/m2/m], as a float. """ # Check values if not isinstance(mass, (float, int)) or mass < 1 or not isinstance(area, (float, int)) or area < 1: raise ValueError( "ERROR the mass of the building and area of the shallow foundation should be provided as positive numbers.") # Calculate the required spring stiffness for cut-off frequency return mass * (cut_off_frequency * 2 * math.pi) ** 2 / area
[docs]def viia_calculate_standard_values( project: ViiaProject, cut_off_frequency: float = 50) \ -> Tuple[str, Dict[str, Union[float, int, List[Union[float, int]]]]]: """ Function to retrieve the geotechnical properties for the shallow foundations in MYVIIA. This function does not validate the data. It filters the properties retrieved based on name and then returns the latest record. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - cut_off_frequency (float): Limit for the stiffness calculation to prevent base isolation behaviour, in [Hz]. Default value for shallow foundations is 50 Hz. Output: - Returns list with the different named shallow foundation properties.The list contains the unique named records in MYVIIA, filtered for the latest date. """ # Check if token is already present in project if not project.token: # Login to MYVIIA webtool for multiple requests project.token = myviia_login() # Collect the results of the latest A1 calculation try: a1_results = myviia_get_a1_results(object_deel_id=project.get_myviia_object_deel_id(), token=project.token) except ConnectionError: project.write_log("WARNING: There is an issue connecting to MYVIIA. A second attempt is now executed.") project.token = myviia_login() a1_results = myviia_get_a1_results(object_deel_id=project.get_myviia_object_deel_id(), token=project.token) vg_phase_2 = myviia_get_progress( progress='engineering_fase2', viia_object_id=project.project_information['id'], object_deel_id=project.get_myviia_object_deel_id(), token=project.token) # Check contents if not a1_results: raise ValueError( "ERROR: You first need to perform the A1 analysis, before the standard shallow foundation material " "properties can be calculated.") # Filter for the latest date latest_a1 = sorted(a1_results, key=lambda d: d['date'])[-1] latest_vg = None if vg_phase_2: latest_vg = sorted(vg_phase_2, key=lambda d: d['date'])[-1] # Check if the A1 is already final, if not provide warning if latest_vg is None or latest_vg['static_analysis'] is False: warn( "WARNING: The properties for the shallow foundation are derived from the latest linear static A1 analysis " f"performed ({latest_a1['date']}). Please first complete the fixed base analysis (check your progress on " f"MYVIIA) before proceeding.") stiffness = viia_calculate_shallow_foundation_stiffness( project=project, mass=latest_a1['weight_of_building'] / project.gravitational_acceleration, area=latest_a1['area_foundation'], cut_off_frequency=cut_off_frequency) return \ f'USRDEF_{project.name}_100%', { 'normal_stiffness_modulus_z': stiffness, 'shear_stiffness_modulus_x': stiffness, 'shear_stiffness_modulus_y': stiffness, 'material_parameters': [1.0, 1.00000E+07], 'initial_state_values': 0.0}
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================