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 are 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 (Union[Sequence[Sequence[float]], Sequence[Vertex], Sequence[float], 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 (Optional[float]) – EA

  • EI (Optional[float]) – EI

  • g (float) – Weight per meter. [kN/m] / [N/m]

  • mp (Optional[Dict[int, float]]) –

    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 (Optional[Dict[int, float]]) –

    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}
    

Return type

int

Returns

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 (Union[Sequence[Sequence[float]], Sequence[Vertex], Sequence[float], Vertex]) – See ‘add_element’ method

  • n (Optional[int]) – Number of elements.

  • dl (Optional[float]) – Distance between the elements nodes.

  • EA (Optional[float]) – See ‘add_element’ method

  • EI (Optional[float]) – See ‘add_element’ method

  • g (float) – See ‘add_element’ method

  • mp (Optional[Dict[int, float]]) – See ‘add_element’ method

  • spring (Optional[Dict[int, float]]) – See ‘add_element’ method

Keyword Args:

Parameters
  • element_type – See ‘add_element’ method

  • first – Different arguments for the first element

  • last – Different arguments for the last element

  • steelsection – Steel section name like IPE 300

  • orient – Steel section axis for moment of inertia - ‘y’ and ‘z’ possible

  • b – Width of generic rectangle section

  • h – Height of generic rectangle section

  • d – Diameter of generic circle section

  • sw – If true self weight of section is considered as dead load

  • E – Modulus of elasticity for section material

  • gamma

    Weight of section material per volume unit. [kN/m3] / [N/m3]s

    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 (Union[List[float], ndarray]) – x coordinates.

  • y (Union[List[float], ndarray]) – y coordinates.

  • EA (Union[List[float], ndarray, None]) – See ‘add_element’ method

  • EI (Union[List[float], ndarray, None]) – See ‘add_element’ method

  • g (Union[List[float], ndarray, None]) – See ‘add_element’ method

  • mp (Optional[Dict[int, float]]) – See ‘add_element’ method

  • spring (Optional[Dict[int, float]]) – 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, **kwargs)[source]

Add an element that only has axial force.

Parameters
  • location (Union[Sequence[Sequence[float]], Sequence[Vertex], Sequence[float], 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 (Optional[float]) – EA

Return type

int

Returns

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 (Union[Sequence[float], Vertex, None]) –

    The nodes of the element or the next node of the element.

    Example

    location=[x, y]
    location=Vertex
    

Param

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