Source code for viiapackage.supports.shallow_foundation.collect_shallow_foundation_myviia

### ===================================================================================================================
###   Collect the data for shallow foundations from MYVIIA
### ===================================================================================================================
# Copyright ©VIIA 2024

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

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

# References for functions and classes in the viiaPackage
from viiapackage.database import myviia_get_shallow_foundation

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


### ===================================================================================================================
###   2. Function to collect data for material from MYVIIA
### ===================================================================================================================

[docs]def viia_collect_shallow_foundation_from_myviia(project: ViiaProject) -> List[Dict[str, Any]]: """ 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. Output: - Returns list with the different named shallow foundation properties.The list contains the unique named records in MYVIIA, filtered for the latest date. """ # Get data from MYVIIA myviia_data = myviia_get_shallow_foundation(object_deel_id=project.get_myviia_object_deel_id(), token=project.token) # Filter for names materials = {} for item in myviia_data: if item['name'] not in materials: materials[item['name']] = [item] else: materials[item['name']].append(item) # Filter to get the most recent record output = [] for name, value_list in materials.items(): output.append(sorted(value_list, key=lambda d: d['date'])[-1]) # Return the required items return output
[docs]def viia_calculate_shallow_foundation_from_myviia( project: ViiaProject, data: Dict[str, Any]) \ -> Tuple[str, Dict[str, Union[float, int, List[Union[float, int]]]]]: """ Function to convert the geotechnical properties for the shallow foundations that are retrieved from MYVIIA to the required input for the create function of the flexbase shallow foundation material. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - data (dict): Dictionary with the properties retrieved from MYVIIA. Output: - Returns tuple with name of the material as string and the material properties in a dictionary. """ # Calculate the friction angle weight_area = data['eng_a1_id']['weight_of_building'] / data['eng_a1_id']['area_foundation'] friction_coefficient = (data['capacity_horizontal'] / 1000 / weight_area) * 180 / math.pi # Check value for the conversion of friction coefficient friction_coefficient_geo_excel = 0.287 cap_hor = \ friction_coefficient_geo_excel * math.pi * 1000 * ( data['eng_a1_id']['weight_of_building'] / data['eng_a1_id']['area_foundation']) / 180 return f'USRDEFMYVIIA_{project.name}_100%', { 'normal_stiffness_modulus_z': data['normal_stiffness'], 'shear_stiffness_modulus_x': data['shear_stiffness'], 'shear_stiffness_modulus_y': data['shear_stiffness'], 'material_parameters': [friction_coefficient, data['capacity_vertical']], 'initial_state_values': 0.0}
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================