Modelling methods

class anastruct.fem.system.SystemElements(figsize=(12, 8), EA=15000.0, EI=5000.0, load_factor=1.0, 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.

  • 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, **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.

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.

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

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

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.0, Fy=0.0, rotation=0)[source]

Apply a point load to a node.

Parameters
  • node_id (Union[int, Sequence[int]]) – Nodes ID.

  • Fx (Union[float, Sequence[float]]) – Force in global x direction.

  • Fy (Union[float, Sequence[float]]) – Force in global x direction.

  • rotation (Union[float, Sequence[float]]) – Rotate the force clockwise. Rotation is in degrees.

SystemElements.q_load(q, element_id, direction='element', rotation=None, q_perp=None)[source]

Apply a q-load to an element.

Parameters
  • element_id (Union[int, Sequence[int]]) – representing the element ID

  • q (Union[float, Sequence[float]]) – value of the q-load

  • direction (Union[str, Sequence[str]]) – “element”, “x”, “y”, “parallel”

  • rotation (Union[float, Sequence[float], None]) – Rotate the force clockwise. Rotation is in degrees

  • q_perp (Union[float, Sequence[float], None]) – value of any q-load perpendicular to the indication direction/rotation

SystemElements.moment_load(node_id, Ty)[source]

Apply a moment on a node.

Parameters
  • node_id (Union[int, Sequence[int]]) – Nodes ID.

  • Ty (Union[float, Sequence[float]]) – 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 (Union[int, Sequence[int]]) – Represents the nodes ID

SystemElements.add_support_roll(node_id, direction='x', angle=None, rotate=True)[source]

Adds a rolling support at a given node.

Parameters
  • node_id (Union[Sequence[int], int]) – Represents the nodes ID

  • direction (Union[Sequence[Union[str, int]], str, int]) – Represents the direction that is free: ‘x’, ‘y’

  • angle (Union[Sequence[Optional[float]], float, None]) – Angle in degrees relative to global x-axis. If angle is given, the support will be inclined.

  • rotate (Union[Sequence[bool], bool]) – If set to False, rotation at the roller will also be restrained.

SystemElements.add_support_fixed(node_id)[source]

Add a fixed support at a given node.

Parameters

node_id (Union[Sequence[int], int]) – 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 (Union[Sequence[int], int]) –

    Represents the prevented translation.

    Note

    1 = translation in x
    2 = translation in z
    3 = rotation in y

  • node_id (Union[Sequence[int], int]) – Integer representing the nodes ID.

  • k (Union[Sequence[float], float]) – Stiffness of the spring

  • roll (Union[Sequence[bool], 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) –

    1. Log calculation outputs. 1. silence.

  • max_iter (int) – Maximum allowed iterations.

  • geometrical_non_linear (int) – Calculate second order effects and determine the buckling factor.

Returns

Displacements vector.

Development **kwargs:
param naked

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, annotations=False)[source]

Plot the structure.

Parameters
  • factor – Influence the plotting scale.

  • verbosity (int) – 0: All information, 1: Suppress information.

  • scale (float) – Scale of the plot.

  • offset (Tuple[float, float]) – Offset the plots location on the figure.

  • figsize (Optional[Tuple[float, float]]) – 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)

  • annotations (bool) – if True, structure annotations are plotted. It includes section name. Note: only works when verbosity is equal to 0.

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 (Optional[float]) – Influence the plotting scale.

  • verbosity (int) – 0: All information, 1: Suppress information.

  • scale (float) – Scale of the plot.

  • offset (Tuple[float, float]) – Offset the plots location on the figure.

  • figsize (Optional[Tuple[float, float]]) – 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)

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 (Optional[float]) – Influence the plotting scale.

  • verbosity (int) – 0: All information, 1: Suppress information.

  • scale (float) – Scale of the plot.

  • offset (Tuple[float, float]) – Offset the plots location on the figure.

  • figsize (Optional[Tuple[float, float]]) – 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)

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.

Parameters
  • factor (Optional[float]) – Influence the plotting scale.

  • verbosity (int) – 0: All information, 1: Suppress information.

  • scale (float) – Scale of the plot.

  • offset (Tuple[float, float]) – Offset the plots location on the figure.

  • figsize (Optional[Tuple[float, float]]) – 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)

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 (float) – Scale of the plot.

  • offset (Tuple[float, float]) – Offset the plots location on the figure.

  • figsize (Optional[Tuple[float, float]]) – Change the figure size.

  • show (bool) – Plot the result or return a 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 (Optional[float]) – Influence the plotting scale.

  • verbosity (int) – 0: All information, 1: Suppress information.

  • scale (float) – Scale of the plot.

  • offset (Tuple[float, float]) – Offset the plots location on the figure.

  • figsize (Optional[Tuple[float, float]]) – 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)

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 (int) – representing the node’s ID. If integer = 0, the results of all nodes are returned

Return type

Union[List[Tuple[Any, Any, Any, Any, Any, Any, Any]], Dict[str, Union[int, float]]]

Returns

if node_id == 0:

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

if node_id > 0:
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.

Return type

Union[List[Tuple[Any, Any, Any, Any]], Dict[str, Any]]

Returns

if node_id == 0:

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.

Return type

List[float]

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.

Return type

Union[List[Dict[str, Any]], Dict[str, Any]]

Returns


if node_id == 0:

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’

Return type

List[float]

Utility methods for interacting with the elements and nodes

SystemElements.find_node_id(vertex)[source]

Retrieve the ID of a certain location.

Parameters

vertex (Union[Vertex, Sequence[float]]) – Vertex_xz, [x, y], (x, y)

Return type

Optional[int]

Returns

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’

Return type

List[Union[float, Tuple[float, float], None]]

SystemElements.nearest_node(dimension, val)[source]

Retrieve the nearest node ID.

Parameters
  • dimension (str) – “both”, ‘x’, ‘y’ or ‘z’

  • val (Union[float, Sequence[float]]) – Value of the dimension.

Return type

Optional[int]

Returns

ID of the node.