Modelling methods

class anastruct.fem.system.SystemElements(figsize=(12, 8), EA=15000.0, EI=5000.0, load_factor=1, mesh=50)[source]

Modelling any structure starts with an object of this class.

Variables:
  • EA – Standard axial stiffness of elements, default=15,000
  • EI – Standard bending stiffness of elements, default=5,000
  • figsize – (tpl) Matplotlibs standard figure size
  • element_map – (dict) Keys are the element ids, values are the element objects
  • node_map – (dict) Keys are the node ids, values are the node objects.
  • node_element_map – (dict) maps node ids to element objects.
  • supports_fixed – (list) All the fixed supports in the system.
  • supports_hinged – (list) All the hinged supports in the system.
  • supports_roll – (list) All the roll supports in the system.
  • supports_spring_x – (list) All the spring supports in x-direction in the system.
  • supports_spring_z – (list) All the spring supports in z-direction in the system.
  • supports_spring_y – (list) All the spring supports in y-direction in the system.
  • supports_roll_direction – (list) The directions of the rolling supports.
  • loads_point – (dict) Maps node ids to point loads.
  • loads_q – (dict) Maps element ids to q-loads.
  • loads_moment – (dict) Maps node ids to moment loads.
  • loads_dead_load – (set) Element ids that have a dead load applied.

Add elements

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.

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.

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

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

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.

Apply forces

SystemElements.point_load(node_id, Fx=0, Fy=0, rotation=0)[source]

Apply a point load to a node.

Parameters:
  • node_id – (int/ list) Nodes ID.
  • Fx – (flt/ list) Force in global x direction.
  • Fy – (flt/ list) Force in global x direction.
  • rotation – (flt/ list) Rotate the force clockwise. Rotation is in degrees.
SystemElements.q_load(q, element_id, direction='element')[source]

Apply a q-load to an element.

Parameters:
  • element_id – (int/ list) representing the element ID
  • q – (flt) value of the q-load
  • direction – (str) “element”, “x”, “y”
SystemElements.moment_load(node_id, Ty)[source]

Apply a moment on a node.

Parameters:
  • node_id – (int/ list) Nodes ID.
  • Ty – (flt/ list) Moments acting on the node.

Supporting conditions

SystemElements.add_support_hinged(node_id)[source]

Model a hinged support at a given node.

Parameters:node_id – (int/ list) Represents the nodes ID
SystemElements.add_support_roll(node_id, direction=2)[source]

Adds a rolling support at a given node.

Parameters:
  • node_id – (int/ list) Represents the nodes ID
  • direction – (int/ list) Represents the direction that is fixed: x = 1, y = 2
SystemElements.add_support_fixed(node_id)[source]

Add a fixed support at a given node.

Parameters:node_id – (int/ list) Represents the nodes ID
SystemElements.add_support_spring(node_id, translation, k, roll=False)[source]

Add a translational support at a given node.

Parameters:
  • translation

    (int/ list) Represents the prevented translation.

    Note

    1 = translation in x
    2 = translation in z
    3 = rotation in y
  • node_id – (int/ list) Integer representing the nodes ID.
  • k – (flt) Stiffness of the spring
  • roll – (bool) If set to True, only the translation of the spring is controlled.

Find a solution

SystemElements.solve(force_linear=False, verbosity=0, max_iter=200, geometrical_non_linear=False, **kwargs)[source]

Compute the results of current model.

Parameters:
  • force_linear – (bool) Force a linear calculation. Even when the system has non linear nodes.
  • verbosity – (int) 0. Log calculation outputs. 1. silence.
  • max_iter – (int) Maximum allowed iterations.
  • geometrical_non_linear – (bool) Calculate second order effects and determine the buckling factor.
Returns:

(array) Displacements vector.

Development **kwargs:
param naked:(bool) Whether or not to run the solve function without doing post processing.
param discretize_kwargs:
 When doing a geometric non linear analysis you can reduce or increase the number of elements created that are used for determining the buckling_factor

Visual feedback

SystemElements.show_structure(verbosity=0, scale=1.0, offset=(0, 0), figsize=None, show=True, supports=True, values_only=False)[source]

Plot the structure.

Parameters:
  • verbosity – (int) 0: All information, 1: Suppress information.
  • scale – (flt) Scale of the plot.
  • offset – (tpl) Offset the plots location on the figure.
  • figsize – (tpl) Change the figure size.
  • show – (bool) Plot the result or return a figure.
  • supports – (bool) Show the supports.
  • values_only – (bool) Return the values that would be plotted as tuple containing two arrays: (x, y)
Returns:

(figure)

SystemElements.show_bending_moment(factor=None, verbosity=0, scale=1, offset=(0, 0), figsize=None, show=True, values_only=False)[source]

Plot the bending moment.

Parameters:
  • factor – (flt) Influence the plotting scale.
  • verbosity – (int) 0: All information, 1: Suppress information.
  • scale – (flt) Scale of the plot.
  • offset – (tpl) Offset the plots location on the figure.
  • figsize – (tpl) Change the figure size.
  • show – (bool) Plot the result or return a figure.
  • values_only – (bool) Return the values that would be plotted as tuple containing two arrays: (x, y)
Returns:

(figure)

SystemElements.show_axial_force(factor=None, verbosity=0, scale=1, offset=(0, 0), figsize=None, show=True, values_only=False)[source]

Plot the axial force.

Parameters:
  • factor – (flt) Influence the plotting scale.
  • verbosity – (int) 0: All information, 1: Suppress information.
  • scale – (flt) Scale of the plot.
  • offset – (tpl) Offset the plots location on the figure.
  • figsize – (tpl) Change the figure size.
  • show – (bool) Plot the result or return a figure.
  • values_only – (bool) Return the values that would be plotted as tuple containing two arrays: (x, y)
Returns:

(figure)

SystemElements.show_shear_force(factor=None, verbosity=0, scale=1, offset=(0, 0), figsize=None, show=True, values_only=False)[source]

Plot the shear force. :param factor: (flt) Influence the plotting scale. :param verbosity: (int) 0: All information, 1: Suppress information. :param scale: (flt) Scale of the plot. :param offset: (tpl) Offset the plots location on the figure. :param figsize: (tpl) Change the figure size. :param show: (bool) Plot the result or return a figure. :param values_only: (bool) Return the values that would be plotted as tuple containing two arrays: (x, y) :return: (figure)

SystemElements.show_reaction_force(verbosity=0, scale=1, offset=(0, 0), figsize=None, show=True)[source]

Plot the reaction force.

Parameters:
  • verbosity – (int) 0: All information, 1: Suppress information.
  • scale – (flt) Scale of the plot.
  • offset – (tpl) Offset the plots location on the figure.
  • figsize – (tpl) Change the figure size.
  • show – (bool) Plot the result or return a figure.
Returns:

(figure)

SystemElements.show_displacement(factor=None, verbosity=0, scale=1, offset=(0, 0), figsize=None, show=True, linear=False, values_only=False)[source]

Plot the displacement.

Parameters:
  • factor – (flt) Influence the plotting scale.
  • verbosity – (int) 0: All information, 1: Suppress information.
  • scale – (flt) Scale of the plot.
  • offset – (tpl) Offset the plots location on the figure.
  • figsize – (tpl) Change the figure size.
  • show – (bool) Plot the result or return a figure.
  • linear – (bool) Don’t evaluate the displacement values in between the elements
  • values_only – (bool) Return the values that would be plotted as tuple containing two arrays: (x, y)
Returns:

(figure)

Numerical feedback

SystemElements.get_node_results_system(node_id=0)[source]

These are the node results. These are the opposite of the forces and displacements working on the elements and may seem counter intuitive.

Parameters:node_id – (integer) representing the node’s ID. If integer = 0, the results of all nodes are returned
Returns:
if node_id == 0: (list)

Returns a list containing tuples with the results:
[(id, Fx, Fy, Ty, ux, uy, phi_y), (id, Fx, Fy...), () .. ]

if node_id > 0: (dict)
SystemElements.get_node_displacements(node_id=0)[source]
Parameters:node_id – (int) Represents the node’s ID. If integer = 0, the results of all nodes are returned.
Returns:
if node_id == 0: (list)

Returns a list containing tuples with the results:
[(id, ux, uy, phi_y), (id, ux, uy, phi_y),  ... (id, ux, uy, phi_y) ]

if node_id > 0: (dict)
SystemElements.get_node_result_range(unit)[source]

Query a list with node results.

param unit:(str) - ‘uy’ - ‘ux’ - ‘phi_y’
Returns:(list)
SystemElements.get_element_results(element_id=0, verbose=False)[source]
Parameters:
  • element_id – (int) representing the elements ID. If elementID = 0 the results of all elements are returned.
  • verbose – (bool) If set to True the numerical results for the deflection and the bending moments are returned.
Returns:


if node_id == 0: (list)

Returns a list containing tuples with the results:
[(id, length, alpha, u, N_1, N_2), (id, length, alpha, u, N_1, N_2), ... (id, length, alpha, u, N_1, N_2)]

if node_id > 0: (dict)

SystemElements.get_element_result_range(unit)[source]

Useful when added lots of elements. Returns a list of all the queried unit.

Parameters:unit – (str) - ‘shear’ - ‘moment’ - ‘axial’
Returns:(list)

Utility methods for interacting with the elements and nodes

SystemElements.find_node_id(vertex)[source]

Retrieve the ID of a certain location.

Parameters:vertex – (Vertex/ list/ tpl) Vertex_xz, [x, y], (x, y)
Returns:(int/ None) id of the node at the location of the vertex
SystemElements.nodes_range(dimension)[source]

Retrieve a list with coordinates x or z (y).

Parameters:dimension – (str) “both”, ‘x’, ‘y’ or ‘z’
Returns:(list)
SystemElements.nearest_node(dimension, val)[source]

Retrieve the nearest node ID.

Parameters:
  • dimension – (str) “both”, ‘x’, ‘y’ or ‘z’
  • val – (flt) Value of the dimension.
Returns:

(int) ID of the node.