Source code for viiapackage.results.overburden_load.get_diana_load_case

### ===================================================================================================================
###   Function to collect the load-case in DIANA
### ===================================================================================================================
# Copyright ©VIIA 2024

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

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

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.analyses import Analysis

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


### ===================================================================================================================
###   2. Function to get the DIANA load-case name
### ===================================================================================================================

[docs]def get_diana_load_case(project: ViiaProject, analysis: Analysis, load_case: Optional[str] = None) -> str: """ This function gets the correct load-case name in DIANA software. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - analysis (obj): Object reference of the analysis for which the load case must be found. - load-case (str): The name of the requested load-case. Output: - The name of the load-case in DIANA software. """ if not load_case: # No load-case given, find the load-case if float(project.rhdhvDIANA.diana_version.replace('diana ', '')) < 10.4: load_case = project.rhdhvDIANA.resultCases(analysis.name)[0] else: if len(project.collections.load_combinations) == 1: load_case = project.collections.load_combinations[0].name if load_case not in project.rhdhvDIANA.resultCases(analysis.name): raise NameError("ERROR: Load-case name is not present in the analysis.") else: raise ValueError( f"ERROR: {len(project.collections.load_combinations)} load-combinations found, expected only 1.") elif float(project.rhdhvDIANA.diana_version.replace('diana ', '')) < 10.4: # Usage in DIANA10.3 if load_case not in project.rhdhvDIANA.resultCases(analysis.name): load_cases = [case.name for case in project.collections.load_cases] if load_case in load_cases: load_case_adjusted = "Load-combination " + str(load_cases.index(load_case)+1) if load_case_adjusted not in project.rhdhvDIANA.resultCases(analysis.name): raise ValueError(f"ERROR: Wrong input for load-case {load_case}") load_case = load_case_adjusted else: # Usage in DIANA10.4 and higher if not (any([load_case == load_combination.name for load_combination in project.collections.load_combinations]) and load_case in project.rhdhvDIANA.resultCases(analysis.name)): raise ValueError(f"ERROR: Wrong input for load-case {load_case}.") return load_case
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================