### ===================================================================================================================
### Collect the strengthening measures in the model
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING, Optional, Dict, List
# References for functions and classes in the viiaPackage
from viiapackage.strengthening.viia_gmc_measures import GMCMeasures
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
### ===================================================================================================================
### 2. Function to collect strengthening measures from the model
### ===================================================================================================================
[docs]def viia_collect_strengthening_measures(
project: ViiaProject, nsce_measures: Optional[Dict[str, str]] = None) -> List[Dict]:
"""
This function collects all the retrofitting measures in the model and returns a dictionary of the measures with its
description and the type of element it is applied to (eg. PSSE or NSCE). The retrofitting measures from the model
can be extended manually by the user for measures applied for NSCE.
.. note:: Some measures of the GMC are not yet available. Please report to automating team.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- nsce_measures (dict): Any applied NSCE measures can be provided manually to be added to the engineering
report. Default value None, no NSCE measures are applied. Provide the information in a dictionary, with the
GMC measure name as key and the explanation as value. For example {'L4-I': 'Replacing load-bearing masonry
wall with HSB wall', 'l4-O': 'Application of quakeshield strips only, inside'}.
Output
- Returns a list of dictionaries of the applied measures for both PSSE and NSCE elements together with their
description.
"""
strengthening = []
measures = GMCMeasures().get_strengthening_measures(project=project)
# Collect all measures in the model assigned to a shape
for shape in project.collections.shapes:
if shape.meta_data:
shape_name = shape.__class__.__name__ + str(shape.id)
if 'strengthening' in shape.meta_data.keys():
measure = shape.meta_data['strengthening']
description = measures.get(measure, None)
if description:
description = description.get('description_en', None)
if not description:
project.write_log(
f"WARNING: For the measure {measure} no description is available. Descriptions are available "
f"for {list(measures.keys())}. It might be that the variant is missing in the meta_data. Please"
f" check/update the meta_data of {shape}.")
description = 'N.A.'
measure_dict = {
'measure_name': measure,
'description': description,
'type': 'PSSE',
'shape_name': [shape_name]}
if len(strengthening) > 0:
case_names = []
for case in strengthening:
if measure_dict['measure_name'] == case['measure_name']:
case['shape_name'].append(shape_name)
case_names.append(case['measure_name'])
if measure_dict['measure_name'] not in case_names:
strengthening.append(measure_dict)
if len(strengthening) == 0:
strengthening.append(measure_dict)
# Extend for the NSCE measures
if nsce_measures:
for key, value in nsce_measures.items():
measure_dict = {'measure_name': key, 'description': value, 'type': 'NSCE'}
strengthening.append(measure_dict)
warnings.warn(
"WARNING: Please manually fill in the name of the NSCEs that require strengthening measure in the table "
"of the 'Conclusions' chapter in Appendix C1.")
# Return the collected applied strengthening measures
return strengthening
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================