Elements

The SystemElements class has several methods that help you model a structure. These methods are;

  • add_truss_element
  • add_element
  • add_multiple_elements
  • discretize

A structure is defined by elements, which have their own state.

The elements are stored in SystemElement.element_map. This is a dictionary with keys representing the element ids, and values being the element objects. The element objects ar implicitly created by the SystemElements object.

The state of an element can be interesting when post-processing results. For now we’ll focus on the modelling part. Below you see the different methods for modelling a structure.

Standard elements

Standard elements have bending and axial stiffness and therefore will implement shear force, bending moment, axial force, extension, and deflection. Standard elements can be added with the following methods.

Add a single element

SystemElements.add_element(location, EA=None, EI=None, g=0, mp=None, spring=None, **kwargs)[source]
Parameters:
  • location

    (list/ Vertex) The two nodes of the element or the next node of the element.

    Example:
    location=[[x, y], [x, y]]
    location=[Vertex, Vertex]
    location=[x, y]
    location=Vertex
    
  • EA – (flt) EA
  • EI – (flt) EI
  • g – (flt) Weight per meter. [kN/m] / [N/m]
  • mp
    (dict) Set a maximum plastic moment capacity. Keys are integers representing the nodes. Values
    are the bending moment capacity.
    Example:
    mp={1: 210e3,
        2: 180e3}
    
  • spring

    (dict) Set a rotational spring or a hinge (k=0) at node 1 or node 2.

    Example:
    spring={1: k
            2: k}
    
    
    # Set a hinged node:
    spring={1: 0}
    
Returns:

(int) Elements ID.

Example

ss = SystemElements(EA=15000, EI=5000)
ss.add_element(location=[[0, 0], [0, 5]])
ss.add_element(location=[[0, 5], [5, 5]])
ss.add_element(location=[[5, 5], [5, 0]])
ss.show_structure()
_images/add_element.png

Add multiple elements

SystemElements.add_multiple_elements(location, n=None, dl=None, EA=None, EI=None, g=0, mp=None, spring=None, **kwargs)[source]

Add multiple elements defined by the first and the last point.

Parameters:
  • location – See ‘add_element’ method
  • n – (int) Number of elements.
  • dl – (flt) Distance between the elements nodes.
  • EA – See ‘add_element’ method
  • EI – See ‘add_element’ method
  • g – See ‘add_element’ method
  • mp – See ‘add_element’ method
  • spring – See ‘add_element’ method

Keyword Args:

Parameters:
  • element_type – (str) See ‘add_element’ method
  • first – (dict) Different arguments for the first element
  • last

    (dict) Different arguments for the last element

    Example:
    last={'EA': 1e3, 'mp': 290}
    
Returns:

(list) Element IDs

Example add_multiple_elements

ss = SystemElements(EI=5e3, EA=1e5)
ss.add_multiple_elements([[0, 0], [0, 10]], 10)
ss.show_structure()
_images/add_multiple_elements.png
SystemElements.add_element_grid(x, y, EA=None, EI=None, g=None, mp=None, spring=None, **kwargs)[source]

Add multiple elements defined by two containers with coordinates.

Parameters:
  • x – (list/ np.array) x coordinates.
  • y – (list/ np.array) y coordinates.
  • EA – See ‘add_element’ method
  • EI – See ‘add_element’ method
  • g – See ‘add_element’ method
  • mp – See ‘add_element’ method
  • spring – See ‘add_element’ method
Paramg **kwargs**kwargs:
 

See ‘add_element’ method

Returns:

None

Example add_element_grid

from anastruct import SystemElements
import numpy as np

# <3
t = np.linspace(-1, 1)
x = np.sin(t) * np.cos(t) * np.log(np.abs(t))
y = np.abs(t)**0.3 * np.cos(t)**0.5 + 1
# Scaling to positive interval
x = (x - x.min()) / (x - x.min()).max()
y = (y - y.min()) / (y - y.min()).max()

ss = SystemElements()
ss.add_element_grid(x, y)
ss.show_structure()
_images/heart.png

Truss elements

Truss elements don’t have bending stiffness and will therefore not implement shear force, bending moment and deflection. It does model axial force and extension.

add_truss_element

SystemElements.add_truss_element(location, EA=None)[source]

Add an element that only has axial force.

Parameters:
  • location

    (list/ Vertex) The two nodes of the element or the next node of the element.

    Example:
    location=[[x, y], [x, y]]
    location=[Vertex, Vertex]
    location=[x, y]
    location=Vertex
    
  • EA – (flt) EA
Returns:

(int) Elements ID.

Discretization

You can discretize an element in multiple smaller elements with the discretize method.

SystemElements.discretize(n=10)[source]

Takes an already defined SystemElements object and increases the number of elements.

Parameters:n – (int) Divide the elements into n sub-elements.

Insert node

Most of the nodes are defined when creating an element by passing the vertices (x, y coordinates) as the location parameter. It is also to add a node to elements that already exist via the insert_node method.

SystemElements.insert_node(element_id, location=None, factor=None)[source]

Insert a node into an existing structure. This can be done by adding a new Vertex at any given location, or by setting a factor of the elements length. E.g. if you want a node at 40% of the elements length, you pass factor = 0.4.

Note: this method completely rebuilds the SystemElements object and is therefore slower then building a model with add_element methods.

Parameters:
  • element_id – (int) Id number of the element you want to insert the node.
  • location

    (list/ Vertex) The nodes of the element or the next node of the element.

    Example:
    location=[x, y]
    location=Vertex
    
Param:

factor: (flt) Value between 0 and 1 to determine the new node location.