def add_element( self, location, EA=None, EI=None, g=0, mp=None, spring=None, **kwargs ): """ :param location: (list/ Vertex) The two nodes of the element or the next node of the element. :Example: .. code-block:: python location=[[x, y], [x, y]] location=[Vertex, Vertex] location=[x, y] location=Vertex :param EA: (flt) EA :param EI: (flt) EI :param g: (flt) Weight per meter. [kN/m] / [N/m] :param mp: (dict) Set a maximum plastic moment capacity. Keys are integers representing the nodes. Values are the bending moment capacity. :Example: .. code-block:: python mp={1: 210e3, 2: 180e3} :param spring: (dict) Set a rotational spring or a hinge (k=0) at node 1 or node 2. :Example: .. code-block:: python spring={1: k 2: k} # Set a hinged node: spring={1: 0} :return: (int) Elements ID. """ element_type = kwargs.get("element_type", "general") EA = self.EA if EA is None else EA EI = self.EI if EI is None else EI section_name = "" # change EA EI and g if steel section specified if "steelsection" in kwargs: section_name, EA, EI, g = properties.steel_section_properties(**kwargs) # change EA EI and g if rectangle section specified if "h" in kwargs: section_name, EA, EI, g = properties.rectangle_properties(**kwargs) # change EA EI and g if circle section specified if "d" in kwargs: section_name, EA, EI, g = properties.circle_properties(**kwargs) if element_type == "truss": EI = 1e-14 # add the element number self.count += 1 point_1, point_2 = system_components.util.det_vertices(self, location) node_id1, node_id2 = system_components.util.det_node_ids(self, point_1, point_2) point_1, point_2, node_id1, node_id2, spring, mp, angle = system_components.util.force_elements_orientation( point_1, point_2, node_id1, node_id2, spring, mp ) system_components.util.append_node_id( self, point_1, point_2, node_id1, node_id2 ) system_components.util.ensure_single_hinge(self, spring, node_id1, node_id2) # add element element = Element( self.count, EA, EI, (point_2 - point_1).modulus(), angle, point_1, point_2, spring, ) element.node_id1 = node_id1 element.node_id2 = node_id2 element.node_map = { node_id1: self.node_map[node_id1], node_id2: self.node_map[node_id2], } # needed for element annotations element.section_name = section_name element.type = element_type self.element_map[self.count] = element for node in (node_id1, node_id2): if node in self.node_element_map: self.node_element_map[node].append(element) else: self.node_element_map[node] = [element] # Register the elements per node for node_id in (node_id1, node_id2): self.node_map[node_id].elements[element.id] = element if mp is not None: assert type(mp) == dict, "The mp parameter should be a dictionary." self.non_linear_elements[element.id] = mp self.non_linear = True system_components.assembly.dead_load(self, g, element.id) return self.count
def add_element(self, location, EA=None, EI=None, g=0, mp=None, spring=None, **kwargs): """ :param location: (list/ Vertex) The two nodes of the element or the next node of the element. :Example: .. code-block:: python location=[[x, y], [x, y]] location=[Vertex, Vertex] location=[x, y] location=Vertex :param EA: (flt) EA :param EI: (flt) EI :param g: (flt) Weight per meter. [kN/m] / [N/m] :param mp: (dict) Set a maximum plastic moment capacity. Keys are integers representing the nodes. Values are the bending moment capacity. :Example: .. code-block:: python mp={1: 210e3, 2: 180e3} :param spring: (dict) Set a rotational spring or a hinge (k=0) at node 1 or node 2. :Example: .. code-block:: python spring={1: k 2: k} # Set a hinged node: spring={1: 0} :return: (int) Elements ID. """ element_type = kwargs.get("element_type", "general") EA = self.EA if EA is None else EA EI = self.EI if EI is None else EI # add the element number self.count += 1 point_1, point_2 = self._det_vertices(location) node_id1, node_id2 = self._det_node_ids(point_1, point_2) point_1, point_2, node_id1, node_id2, spring, mp, ai = \ self._force_elements_orientation(point_1, point_2, node_id1, node_id2, spring, mp) self._append_node_id(point_1, point_2, node_id1, node_id2) self._ensure_single_hinge(spring, node_id1, node_id2) # add element element = Element(self.count, EA, EI, (point_2 - point_1).modulus(), ai, point_1, point_2, spring) element.node_id1 = node_id1 element.node_id2 = node_id2 element.node_map = { node_id1: self.node_map[node_id1], node_id2: self.node_map[node_id2] } element.type = element_type self.element_map[self.count] = element for node in (node_id1, node_id2): if node in self.node_element_map: self.node_element_map[node].append(element) else: self.node_element_map[node] = [element] # Register the elements per node for node_id in (node_id1, node_id2): self.node_map[node_id].elements[element.id] = element if mp is not None: assert type(mp) == dict, "The mp parameter should be a dictionary." self.non_linear_elements[self.count] = mp self.non_linear = True self._dead_load(g, element.id) return self.count