Source code for viiapackage.analyses.helper_functions.phasing

### ===================================================================================================================
###   _viia_phased_analysis
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from typing import Optional, List

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.groups import Layer
from rhdhv_fem.shapes import Shapes, Surfaces, LineMass
from rhdhv_fem.connections import Connections, Tying
from rhdhv_fem.supports import SupportSet


### ===================================================================================================================
###   2. Class Phase
### ===================================================================================================================

[docs]class Phase: """ This is the class of the phases in the model. It contains the attributes and methods for phases.""" def __init__( self, layer: Layer, shapes: Optional[List[Shapes]] = None, connections: Optional[List[Connections]] = None, support_set: Optional[List[SupportSet]] = None, tying: Optional[List[Tying]] = None): """ Input: - layer (Layer obj): Reference building layer to be phased. - shapes (list of obj): List of shapes that are part of the phase. Default value is None. - connections (list of obj): List of connections that are part of the phase. Default value is None. - support_set (list of obj): List of support sets that are part of the phase. Default value is None. - tying (list of obj): List of tying that are part of the phase. Default value is None. """ # Set the shapes that are active in this phase self.layer = layer # Set the shapes that are active in this phase self.shapes = shapes # Set the connections (except tying) that are active in this phase self.connections = connections # Set the support sets that are active in this phase self.support_set = support_set # Set the tying that are active in this phase self.tying = tying @property def layer(self): return self.__layer @layer.setter def layer(self, new_layer: Layer): self.__layer = new_layer @property def shapes(self): return self.__shapes @shapes.setter def shapes(self, new_list): if new_list is None: self.__shapes = None else: self.__shapes = [] unique_list = list() for item in new_list: if not isinstance(item, Shapes): raise ValueError( "ERROR: Item in the phase shapes should be an instance of Shapes class") if item not in unique_list: unique_list.append(item) self.__shapes = unique_list @property def connections(self): return self.__connections @connections.setter def connections(self, new_list): if new_list is None: self.__connections = None else: self.__connections = [] unique_list = list() for item in new_list: if not isinstance(item, Connections) or isinstance(item, Tying): raise ValueError( "ERROR: Item in the phase connection should be an instance of Connections class but not Tying") if item not in unique_list: unique_list.append(item) self.__connections = unique_list @property def support_set(self): return self.__support_set @support_set.setter def support_set(self, new_list): if new_list is None: self.__support_set = None else: self.__support_set = [] unique_list = list() for item in new_list: if not isinstance(item, SupportSet): raise ValueError( "ERROR: Item in the phase support_set should be an instance of SupportSet class") if item not in unique_list: unique_list.append(item) self.__support_set = unique_list @property def tying(self): return self.__tying @tying.setter def tying(self, new_list): if new_list is None: self.__tying = None else: self.__tying = [] unique_list = list() for item in new_list: if not isinstance(item, Tying): raise ValueError( "ERROR: Item in the phase tying should be an instance of Tying class") if item not in unique_list: unique_list.append(item) self.__tying = unique_list
### =================================================================================================================== ### 3. Function to get the phases for the analyses ### ===================================================================================================================
[docs]def viia_phased_analysis(project: 'ViiaProject'): """ Function to prepare for phased analysis, based on layers following VIIA name convention. Returns list with shapes, connections, supportsets and tyings active per phase. .. warning:: Function makes use of shapes and connections in the dictionaries in Collections. Make sure all elements are present in those dictionaries. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. Output: - A list is generated and returned, containing the elements that are active in different phases list per phase consists of 4 lists of elements: shapes, connections (except for tyings), supports and tyings. """ layer = None layer_dictionary = {} # Collect the shapes per layer for shape in project.collections.shapes: if isinstance(shape, LineMass): layer = shape.host.layer.name else: layer = shape.layer.name # The layers are saved to a dictionary if layer not in layer_dictionary: layer_dictionary.update({layer: {'shape': [], 'connection': [], 'support_set': [], 'tying': []}}) if isinstance(shape, Surfaces) and shape.regions: layer_dictionary[layer]['shape'].append(shape) for region in shape.regions: if region in project.collections.regions: layer_dictionary[layer]['shape'].append(region.surface) else: layer_dictionary[layer]['shape'].append(shape) # Collect the connections, except for tying for connection in project.collections.connections: if not isinstance(connection, Tying): if 'FUNDERING' in connection.name or 'PAAL' in connection.name or 'FOS' in connection.name: layer = 'F' else: layer = connection.name.split('-')[0] if layer not in layer_dictionary: layer_dictionary.update({layer: {'shape': [], 'connection': [], 'support_set': [], 'tying': []}}) layer_dictionary[layer]['connection'].append(connection) # Collect the supports for supportset in project.collections.supportsets: if supportset.name in \ ['FixedBase', 'FlexBaseGlobal', 'FlexBaseFinal', 'PileSupport', 'Shallow-foundation', 'FUNDERING', 'F1', 'F2']: layer = 'F' else: layer = supportset.name.split('-')[0] if layer not in layer_dictionary: layer_dictionary.update({layer: {'shape': [], 'connection': [], 'support_set': [], 'tying': []}}) layer_dictionary[layer]['support_set'].append(supportset) # Collect the tyings # be aware that SSI tyings are added later on to the file for tying in project.collections.tyings: if tying.name in ['FUNDERING', 'F1', 'F2']: layer = 'F' else: layer = tying.name.split('-')[0] if layer not in layer_dictionary: layer_dictionary.update({layer: {'shape': [], 'connection': [], 'support_set': [], 'tying': []}}) layer_dictionary[layer]['tying'].append(tying) # Create phases phasing_list = [] layers = project.viia_get_layers() for layer in layers: shapes = [] connections = [] support_set = [] tying = [] for i in range(layers.index(layer) + 1): shapes += layer_dictionary[layers[i].name]['shape'] connections += layer_dictionary[layers[i].name]['connection'] support_set += layer_dictionary[layers[i].name]['support_set'] tying += layer_dictionary[layers[i].name]['tying'] phasing_list.append( Phase( layer=layer, shapes=shapes, connections=connections, support_set=support_set, tying=tying)) return phasing_list
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================