Source code for viiapackage.results.result_functions.viia_read_diana_outfile_linear_static

### ===================================================================================================================
###   Function to read the out-file for linear static analysis
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING, Union, Dict

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

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


### ===================================================================================================================
###   2. Function to retrieve data required for VIIA from out-file linear static analysis
### ===================================================================================================================

[docs]def viia_read_diana_outfile_linear_static( project: ViiaProject, outfile: Union[Path, str], load_combination_id: int = 1) -> Dict[str, float]: """ Function calculates the center of mass based on the output file of a linear static calculation. Input: - project (obj): Project object containing collections and of fem objects and project variables. - outfile (Path): File name and location as single string or path of the output file of a linear static calculation. Alternative file location of the out-file can be provided as string. - load_combination_id (str): Load-combination ID in DIANA software. Default value is 1. Output: - Notification on screen and in log of the position of the center of mass. - Returns 3 floats: sum of vertical loads in [N], center of mass in x-direction [m] and center of mass in y-direction [m]. """ # Collect the results from the outfile outfile_data = project.read_diana_outfile(file=outfile, outfile_type='linear static') # Calculate the values sum_vertical_loads = -float(outfile_data['loadsets'][load_combination_id]['z']) center_of_mass_x = 0 center_of_mass_y = 0 if not fem_compare_values(value1=sum_vertical_loads, value2=0, precision=project.check_precision): center_of_mass_x = float(outfile_data['loadsets'][load_combination_id]['ry']) / sum_vertical_loads center_of_mass_y = -float(outfile_data['loadsets'][load_combination_id]['rx']) / sum_vertical_loads # Return the required results return { 'sum_vertical_loads': sum_vertical_loads, 'center_of_mass_x': center_of_mass_x, 'center_of_mass_y': center_of_mass_y}
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================