### ===================================================================================================================
### Check strengthening measures in model with MYVIIA
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING, List, Dict
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
### ===================================================================================================================
### 2. Function to check if strengthening measure in MYVIIA is the same as in the FEM model
### ===================================================================================================================
[docs]def viia_check_measures(
project: ViiaProject, object_measures: List[Dict[str, str]], myviia_measures: List[Dict[str, str]]) -> bool:
"""
This function checks that the measures filled in myviia are the same as the measures in the model.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- object_measures (list of dict): A list of dictionaries of all the strengthening measures in the model combined
with the NSCE measures provided by the user.
- myviia_measures (list of dict): A list of dictionaries of all measures applied in MYVIIA.
Output
- Returns a boolean with the result of the check.
- Notification of verification is printed in log.
- In case of differences, this is reported to user with a warning, but process will continue.
"""
# Create a list of the measures in the model and the NSCE elements
object_measure_names = [measure['measure_name'] for measure in object_measures]
# Create a list of the measures reported in MYVIIA
myviia_measure_names = [measure['name'] for measure in myviia_measures]
# Find any measures in model that are not in MYVIIA
diff_model = list(set([item for item in object_measure_names if item not in myviia_measure_names]))
if diff_model:
warnings.warn(
f"WARNING: In the model (or NSCE measures) the following measures are present, that are missing on "
f"MYVIIA: {', '.join(diff_model)}. Please add measures on MYVIIA.")
# Find any measures in model that are not in MYVIIA
diff_model_2 = list(set([item for item in myviia_measure_names if item not in object_measure_names]))
if diff_model_2:
warnings.warn(
f"WARNING: In MYVIIA the following measures are present, but they are missing in the model or the list of "
f"NSCE measures provided by the user: {', '.join(diff_model_2)}. Please add measures in model or in the "
f"list of NSCE elements.")
if not diff_model and not diff_model_2:
project.write_log("It is verified that the measures in your model are the same as the ones in MYVIIA!")
return True
return False
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================