Source code for viiapackage.results.results_a2

### ===================================================================================================================
###  A2 Rob-test result handling
### ===================================================================================================================
# Copyright ©2026 Haskoning Nederland B.V.
# For use by VIIA

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

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

# References for functions and classes in the haskoning-structural package
from haskoning_structural.analyses import AnalysisReference
from haskoning_structural.pictures import View

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


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

[docs]def viia_results_a2(project: ViiaProject, load_model: bool = True, view: Optional[View] = None): """ Combination of functions to be performed on output of A2 Rob-test. Includes: - Boolean of the outcome of the Rob-test analysis. - Elapsed time of the Rob-test analysis. - Image of the displacements in the Rob-test analysis. The values should all be -1m, resulting in a green model. Input: - project (obj): Project object containing collections and of fem objects and project variables. - load_model (bool): Select to reload the model from json-file. Default value is True, but when directly creating analysis and running continuously, it needs to be switched off. - 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 A2 calculation are saved in project. """ # Checking for version number if project.version != 1: raise ValueError("ERROR: The A2 analysis is to be applied only on non-strengthened models.") if project.software == 'abaqus': raise NotImplementedError( "ERROR: Result handling for A2 analysis in ABAQUS is not available and not required for VIIA workflow in " "ABAQUS software.") # Check if model needs to be loaded if load_model: viia_results_load_model(project=project, analysis_nr='A2') # Collect the analysis analysis = project.viia_get(collection='analyses', name='A2 - Rob-test - Lineair statische analyse met fixed base') if analysis is None: raise RuntimeError("ERROR: The analysis object for A2 analysis could not be found.") # Collect the DIANA out-file with the summary of the A2 analysis out_file = project.viia_get_file(path=project.current_analysis_folder, suffix='.out') analysis_logs = project.read_diana_outfile(file=out_file, analysis=analysis) if analysis_logs and analysis_logs[0].elapsed_time: elapsed_time = analysis_logs[0].elapsed_time else: elapsed_time = None # Collect the DIANA result tb-file with tabulated results for the A2 analysis tb_file = project.viia_get_file(path=project.current_analysis_folder, suffix='.tb', in_name='ROBTEST') project.read_diana_tbfile(file=tb_file, analysis=analysis) # Collect the analysis-reference combination = project.viia_get(collection='load_combinations', name='Rob-test') analysis_reference = project.get_analysis_reference(analysis=analysis, loading=combination) # Determine the success of the rob-test analysis check_result = _viia_check_rob_test(project=project, analysis_reference=analysis_reference) if check_result: project.write_log("Rob-test was successful.") else: message = "WARNING: Rob-test was not successful." project.write_log(message, False) warn(message) # Create result plot for displacements in z-direction if view is None: view = project.create_view(name='ISO1') back_view = project.create_view( name='Back', viewpoint=project.create_reference_point(coordinates=[-1.25, 1.25, 1.25]), focal_point=project.create_reference_point(coordinates=[0, 0, 0]), upward_direction=project.create_direction(name='Z'), view_angle=45, parallel_scale_factor=1.0) else: back_view = view.create_back_side_view() image_front = project.plot_results_3d( output_item='U_z_tot', analysis_reference=analysis_reference, save_file=project.current_analysis_folder / 'rob_test_image_front.png', axis_arrows='best', show_plot=False, show_mesh=True, view=view) image_back = project.plot_results_3d( output_item='U_z_tot', analysis_reference=analysis_reference, save_file=project.current_analysis_folder / 'rob_test_image_back.png', axis_arrows='best', show_plot=False, show_mesh=True, view=back_view) # Save the results to the result dictionary project.results['A2'] = { 'rob_test': check_result, 'elapsed_time': elapsed_time, 'rob_test_image_front': image_front, 'rob_test_image_back': image_back} return project.results['A2']
### =================================================================================================================== ### 3. Sub-function to check if the Rob-test complies ### =================================================================================================================== def _viia_check_rob_test(project: ViiaProject, analysis_reference: AnalysisReference) -> bool: """ Function to check if the criteria of Rob-test are met. Input: - project (obj): Project object containing collections and of fem objects and project variables. - analysis_reference (obj): Analysis reference containing the A2 analysis settings and the relevant loading. Output: - Notification on screen and in log whether the Rob-test was successful or not. - Returns boolean: the Rob-test was successful 'True' and if not 'False'. """ # Check if results are available if len(project.collections.result_collections) == 0: raise RuntimeError( "ERROR: The results of the A2 analysis were not properly loaded into the model. Please check your input.") # Check if all displacement results in z-direction are equal to -1 meter tolerance = 0.5 * 10 ** (-project.rounding_precision) for result_collection in project.collections.result_collections: if result_collection.analysis_reference != analysis_reference: continue if result_collection.output_item.engineering_notation != 'U_z_tot': continue if not all(abs(x + 1) < tolerance for x in result_collection.node_results): return False return True ### =================================================================================================================== ### 4. End of script ### ===================================================================================================================