Source code for viiapackage.results.results_eigenvalue

### ===================================================================================================================
###   Eigenvalue analysis result handling
### ===================================================================================================================
# Copyright ©VIIA 2025

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

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

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.analyses import Analysis
from rhdhv_fem.analyses.analysis_log import EigenvalueAnalysisLog
from rhdhv_fem.pictures import View

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.pictures import viia_create_result_pictures_eigenvalue
from viiapackage.results.result_functions import viia_eigen_frequency_graph, viia_create_eigenvalue_json


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

[docs]def viia_results_eigenvalue( project: ViiaProject, analysis: Analysis, analysis_nr: str, out_file: Optional[Union[Path, str]] = None, result_pictures: bool = True, view: Optional[View] = None) -> EigenvalueAnalysisLog: """ Combination of functions to be performed on output of eigen value analysis in VIIA. Includes: - Graph of eigenfrequency distribution. - Graphs of governing modes plotted in response spectrum. - Result pictures of the eigenmodes. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - analysis (obj): Instance of analysis class that contains the eigenvalue analysis. - analysis_nr (str): Number of analysis in VIIA for the eigenvalue analysis. Select from A3 or A7. - out_file (path): The DIANA out-file location and filename of the analysis requested as path. Optional input, if not provided the out-file will be retrieved from the analysis folder. Alternative (str): The DIANA out-file location and filename of the analysis requested as string. - result_pictures (bool): Toggle to generate result pictures. 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 eigenvalue analysis are saved in workfolder. - Returns the analysis-log of the Eigenvalue analysis-block. """ # Read out-file of the Eigenvalue analysis if not out_file: out_file = project.viia_get_file(path=project.current_analysis_folder, suffix='.out') if not out_file or not out_file.exists(): raise FileNotFoundError( f"ERROR: Could not retrieve the DIANA out-file for result handling {analysis_nr} analysis.") analysis_logs = project.read_diana_outfile(file=out_file, analysis=analysis) # Collect the analysis log analysis_logs = [log for log in analysis_logs if isinstance(log, EigenvalueAnalysisLog)] if not analysis_logs: raise ValueError( f"ERROR: The analysis {analysis.name} does not have any Eigenvalue analysis-logs. Make sure to load the " f"out-file or the Eigenvalue analysis first.") if len(analysis_logs) != 1: raise ValueError( f"ERROR: The analysis {analysis.name} has multiple Eigenvalue analysis-logs, this is not expected in the " f"VIIA workflow. Please check the out-file and your input.") analysis_log = analysis_logs[0] # Create json-file viia_create_eigenvalue_json(project=project, analysis_log=analysis_log, analysis_nr=analysis_nr) # Generate graphs viia_eigen_frequency_graph(project=project, analysis_log=analysis_log) # Result pictures for the eigenvalue analysis if result_pictures: viia_create_result_pictures_eigenvalue(project=project, analysis=analysis, view=view) # Return the collected modes return analysis_log
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================