### ===================================================================================================================
### FUNCTION: Run the analysis
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
import time
from pathlib import Path
from datetime import datetime
from typing import TYPE_CHECKING, Tuple
# 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
from viiapackage.analyses.helper_functions import viia_run_analysis_diana
### ===================================================================================================================
### 2. Function viia_run_analysis
### ===================================================================================================================
[docs]def viia_run_analysis(project: ViiaProject, analysis: Analysis) -> Tuple[Path, float]:
"""
This function performs the analysis in the DIANA GUI in the VIIA workflow. It will collect the generated files by
DIANA and moves them to the current analysis folder.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- analysis (obj): Object reference of the analysis for which the files are created / collected.
Output:
- Returns tuple with the out-file generated in DIANA (as path) and the runtime of the analysis in DIANA GUI
(as float).
- The files created conform VIIA convention are moved to the current analysis folder. These include the out-file
and the result files.
"""
if project.software != 'diana':
raise ValueError("ERROR: Only direct performance of analysis is available for DIANA in VIIA workflow.")
# Save start of the runtime of the required analysis
start_runtime = datetime.now()
# Run calculation in DIANA GUI directly
viia_run_analysis_diana(project=project, analysis=analysis)
# Calculating the runtime of the required analysis
runtime = datetime.now() - start_runtime
runtime = round(runtime.total_seconds(), 2)
# DIANA needs some time to write files
time.sleep(10)
# Files created by running calculation in GUI are moved to project.current_analysis_folder
out_file = project.viia_analysis_diana_gui_files(analysis=analysis)
# Return the out-file of the analysis and the runtime
return out_file, runtime
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================