Source code for viiapackage.results.results_a15

### ===================================================================================================================
###   A15 Analysis NLTH result handling with strengthening measures
### ===================================================================================================================
# Copyright ©VIIA 2024

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

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

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.pictures import View

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.database import myviia_post_a15_results
from viiapackage.analyses.helper_functions.set_base_node import viia_set_base_node
from viiapackage.pictures import viia_create_result_pictures_nlth
from viiapackage.results.collect_results_for_myviia import viia_collect_results_a15
from viiapackage.results.results_load_model import viia_results_load_model


### ===================================================================================================================
###   2. Function to handle results for A15 analysis
### ===================================================================================================================

[docs]def viia_results_a15( project: ViiaProject, signal: str, bsc_nls_dir: Path, tva_nls_dir: Path, convergence_graphs: bool = True, base_shear_graphs: bool = True, wall_displacement_graphs: bool = True, acceleration_graphs: bool = True, geo_output: bool = True, result_pictures: bool = True, post_on_myviia: bool = True, load_model: bool = True, view: Optional[View] = None): """ Combination of functions to be performed on output of A15 nonlinear time history analysis with strengthening. Includes: - Graph of convergence. - Graph of base shear in time-history. - Graphs of relative out-of-plane wall displacements. - Graphs of building acceleration at base, foundation and selected nodes on floors. - Generating json-file with data for the geotechnical advisor. - Result pictures for A15 analysis. Input: - project (obj): Project object containing collections and of fem objects and project variables. - signal (str): Signal to consider. Can be S1-S11. - bsc_nls_dir (Path): The path for BSC A10, which contains the geo_output_nls json-file. - tva_nls_dir (Path): The path for TVA A13, which contains the geo_output_nls json-file. - convergence_graphs (bool): Toggle to generate convergence graphs. Default value is True. - base_shear_graphs (bool): Toggle to generate base shear graphs. Default value is True. - wall_displacement_graphs (bool): Toggle to generate wall displacement graphs. Default value is True. - acceleration_graphs (bool): Toggle to generate acceleration graphs. Default value is True. - geo_output (bool): This allows the user to choose if the geo output needs to be created. This can be handy if the user wants to create results for multiple signals together. Then the user does not need to create the geo output each time. Default value is set to True. - result_pictures (bool): Toggle to generate result pictures. Default value is True. - load_model (bool): Select to reload the model. Default value is True, but when directly creating analysis and running, it needs to be switched off. - post_on_myviia (bool): Select to post the collected data to MYVIIA. Default value is True. - view (obj): View that should be used for the pictures. When None the default view will be used. Default is None. Output: - Result items of A15 analysis are created. """ # Checking for version number if project.version < 2: raise ValueError( "ERROR: The strengthening models should have a version number of at least 2. When you continue, " "you might encounter unexpected behaviour or errors in code.") # Check if model needs to be loaded if load_model: # Load the model viia_results_load_model(project=project, analysis_nr='A15', signal=signal) # Collect the analysis analysis = project.viia_get( collection='analyses', name='A15 - Niet-lineair seismische analyse met flexbase met versterkingen') if analysis is None: raise ValueError("ERROR: The analysis object for A15 analysis could not be found.") # Plot convergence graphs if desired if convergence_graphs: out_file = project.viia_get_file(path=project.current_analysis_folder, suffix='.out') if out_file: project.viia_convergence_graph(file=out_file, signal=signal, analysis=analysis, show=False) else: project.write_log("WARNING: No convergence graph is created because no out-file has been found.") # Collect files required for geo-output fos = project.shallow_foundation_present() piles = project.pile_foundation_present() if not piles and not fos: raise ValueError( "ERROR: No shallow or pile foundation present in the model, please check. Maybe you are using the model " "json not the analysis json.") output_5a = None output_5b = None if base_shear_graphs or geo_output: if fos: output_5a = project.viia_get_file(path=project.current_analysis_folder, in_name='_OUTPUT_5A', suffix='.tb') if piles: output_5b = project.viia_get_file(path=project.current_analysis_folder, in_name='_OUTPUT_5B', suffix='.tb') # Create base shear graphs if base_shear_graphs: if output_5a or output_5b: project.viia_base_shear(analysis, [output_5a, output_5b]) else: project.write_log("WARNING: OUTPUT_5A and/or OUTPUT_5B not found. Base shear plot cannot be created.") # Create graph of wall displacements if wall_displacement_graphs: output_2 = project.viia_get_file(path=project.current_analysis_folder, in_name='_OUTPUT_2', suffix='.tb') if output_2: project.viia_wall_displacements(wall_oop_tbfile=output_2, signal=signal, analysis=analysis) else: project.write_log("WARNING: OUTPUT_2 not found. Wall displacement plot cannot be created.") # Create acceleration graphs if acceleration_graphs: # Set the base point if not project.base_point: viia_set_base_node(project=project) # Add basemotion signals project.viia_add_basemotion_signals(signal_list=[int(signal.split('S')[-1])]) # Create graphs of building acceleration output_3 = project.viia_get_file(path=project.current_analysis_folder, in_name='_OUTPUT_3', suffix='.tb') if output_3: project.viia_acceleration_graphs(tb_file=output_3, signal=signal, analysis=analysis) else: project.write_log("WARNING: OUTPUT_3 not found. Acceleration graphs cannot be created.") # Create geo output if geo_output and (output_5a or output_5b): nls_bsc_json = None if bsc_nls_dir: nls_bsc_json = bsc_nls_dir / 'geo_output_nls.json' if nls_bsc_json is None or not nls_bsc_json.exists(): project.write_log( "ERROR: The A10 BSC geo-output geo-output json-file is required for generating the merged geo-output. " "Json-file for geo-output cannot be created.") else: project.viia_create_geo_output_nlth( signal=signal, output_5a=output_5a, output_5b=output_5b, bsc_nls_dir=bsc_nls_dir, tva_nls_dir=tva_nls_dir, analysis=analysis) elif geo_output: project.write_log("WARNING: OUTPUT_5A and OUTPUT_5B not found. Json-file for geo-output cannot be created.") # Collect all available data for A15 analysis base_shear_data = None if 'A15' in project.results and 'base_shear' in project.results['A15'] \ and signal in project.results['A15']['base_shear']: base_shear_data = project.results['A15']['base_shear'][signal] eng_a15 = viia_collect_results_a15(project=project, base_shear_data=base_shear_data, signal=signal) # Upload results of the A15 analysis to MYVIIA if post_on_myviia: response = myviia_post_a15_results(data=eng_a15, token=project.token) if not response: warnings.warn( f"WARNING: An issue occurred during uploading the A15 analysis results for signal {signal} to MYVIIA. " f"No response received, this could be due to debugging. Data that was sent: {eng_a15}.") elif response.status_code >= 300: warnings.warn( f"WARNING: An issue occurred during uploading the A15 analysis results for signal {signal} to MYVIIA. " f"Please check the outputs of the base shear for the NLTH analysis, or contact the automation-team. " f"Response: {response.status_code} | {response.text}.\n") else: project.write_log( f"Results for base-shear for A12 signal {signal} have been successfully uploaded to MYVIIA.", print_message=False) # Collect the pile reactions if project.pile_foundation_present(): output_5b = project.viia_get_file(path=project.current_analysis_folder, in_name='OUTPUT_5B', suffix='.tb') if output_5b: project.viia_collect_pile_reactions(pile_output_file=output_5b, analysis=analysis, signal=signal) else: project.write_log("WARNING: OUTPUT_5B not found. Pile force plots cannot be created.") # Result pictures for A15 if result_pictures: viia_create_result_pictures_nlth(project=project, analysis=analysis, view=view)
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================