Modelling methods
- class anastruct.fem.system.SystemElements(figsize=(12, 8), EA=15000.0, EI=5000.0, load_factor=1.0, mesh=50, invert_y_loads=True)[source]
Modelling any structure starts with an object of this class.
- Attributes:
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.
- Methods:
add_element: Add a new element to the structure. add_element_grid: Add multiple elements based upon sequential x and y coordinates. add_sequential_elements: Add multiple elements based upon any number of sequential points. add_multiple_elements: Add multiple elements defined by the first and the last point. add_truss_element: Add a new truss element (an element that only has axial force) to the structure. add_support_hinged: Add a hinged support to a node. add_support_fixed: Add a fixed support to a node. add_support_roll: Add a roll support to a node. add_support_rotational: Add a rotational support to a node. add_support_spring: Add a spring support to a node. insert_node: Insert a node into an existing structure. solve: Compute the results of current model. validate: Validate the current model.
Add elements
- SystemElements.add_truss_element(location, EA=None, **kwargs)[source]
- Return type:
Add a new truss element (an element that only has axial force) to the structure Example:
location=[[x, y], [x, y]] location=[Vertex, Vertex] location=[x, y] location=Vertex
- Args:
- location (Union[Sequence[VertexLike], VertexLike]):
The two nodes of the element or the next node of the element.
EA (Optional[float], optional): Axial stiffness of the new element. Defaults to None.
- Returns:
int: ID of the new element
- SystemElements.add_element(location, EA=None, EI=None, g=0, mp=None, spring=None, **kwargs)[source]
- Return type:
Add a new general element (an element with axial and lateral force) to the structure Example:
location=[[x, y], [x, y]] location=[Vertex, Vertex] location=[x, y] location=Vertex mp={1: 210e3, 2: 180e3} spring={1: k, 2: k} # Set a hinged node: spring={1: 0}
- Args:
- location (Union[Sequence[VertexLike], VertexLike]):
The two nodes of the element or the next node of the element
EA (Optional[float], optional): Axial stiffness of the new element. Defaults to None. EI (Optional[float], optional): Bending stiffness of the new element. Defaults to None. g (float, optional): Self-weight of the new element. Defaults to 0. mp (Optional[MpType], optional): Maximum plastic moment of each end node. Keys are integers representing
the nodes. Values are the bending moment capacity. Defaults to None.
- spring (Optional[Spring], optional): Rotational spring or hinge (k=0) of each end node.
Keys are integers representing the nodes. Values are the bending moment capacity. Defaults to None.
- Optional Keyword Args:
element_type (ElementType): “general” (axial and lateral force) or “truss” (axial force only) steelsection (str): Steel section name like IPE 300 orient (OrientAxis): Steel section axis for moment of inertia - ‘y’ and ‘z’ possible b (float): Width of generic rectangle section h (float): Height of generic rectangle section d (float): Diameter of generic circle section sw (bool): If true self weight of section is considered as dead load E (float): Modulus of elasticity for section material gamma (float): Weight of section material per volume unit. [kN/m3] / [N/m3]s
- Returns:
int: ID of the new element
- 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.
last={'EA': 1e3, 'mp': 290}
- Args:
- location (Union[Sequence[VertexLike], VertexLike]):
The two nodes of the element or the next node of the element.
n (Optional[int], optional): Number of elements to add between the first and last nodes. Defaults to None. dl (Optional[float], optional): Length of sub-elements to add between the first and last nodes.
Length will be rounded down if necessary such that all sub-elements will have the same length. Defaults to None.
EA (Optional[float], optional): Axial stiffness. Defaults to None. EI (Optional[float], optional): Bending stiffness. Defaults to None. g (float, optional): Self-weight. Defaults to 0. mp (Optional[MpType], optional): Maximum plastic moment capacity at ends of element. Defaults to None. spring (Optional[Spring], optional): Rotational springs or hinges (k=0) at ends of element.
Defaults to None.
- Optional Keyword Args:
element_type (ElementType): “general” (axial and lateral force) or “truss” (axial force only) first (dict): Different arguments for the first element last (dict): Different arguments for the last element steelsection (str): Steel section name like IPE 300 orient (OrientAxis): Steel section axis for moment of inertia - ‘y’ and ‘z’ possible b (float): Width of generic rectangle section h (float): Height of generic rectangle section d (float): Diameter of generic circle section sw (bool): If true self weight of section is considered as dead load E (float): Modulus of elasticity for section material gamma (float): Weight of section material per volume unit. [kN/m3] / [N/m3]s
- Raises:
FEMException: One, and only one, of n and dl should be passed as argument.
- Returns:
List[int]: IDs of the new elements
- SystemElements.add_element_grid(x, y, EA=None, EI=None, g=None, mp=None, spring=None, **kwargs)[source]
Add multiple elements based upon sequential x and y coordinates.
- Return type:
- Args:
x (Union[List[float], np.ndarray]): X coordinates of the grid y (Union[List[float], np.ndarray]): Y coordinates of the grid EA (Optional[Union[List[float], np.ndarray, float]], optional): Axial stiffnesses. Defaults to None. EI (Optional[Union[List[float], np.ndarray, float]], optional): Bending stiffnesses. Defaults to None. g (Optional[Union[List[float], np.ndarray, float]], optional): Self-weights. Defaults to None. mp (Optional[MpType], optional): Maximum plastic moment capacities for all elements. Defaults to None. spring (Optional[Spring], optional): Springs for all elements. Defaults to None.
- Raises:
FEMException: x and y should have the same length.
- SystemElements.discretize(n=10)[source]
Discretize the elements. Takes an already defined
SystemElementsobject and increases the number of elements.
- Return type:
- Args:
n (int, optional): Divide the elements into n sub-elements.. Defaults to 10.
Apply forces
- SystemElements.point_load(node_id, Fx=0.0, Fy=0.0, rotation=0.0, Fz=None)[source]
Apply a point load to a node.
- Return type:
- Args:
node_id (Union[int, Sequence[int]]): The node ID to which to apply the load Fx (Union[float, Sequence[float]], optional): Force in the global X direction. Defaults to 0.0. Fy (Union[float, Sequence[float]], optional): Force in the global Y direction. Defaults to 0.0. rotation (Union[float, Sequence[float]], optional): Rotate the force clockwise by the given
angle in degrees. Defaults to 0.0.
- Raises:
FEMException: Point loads may not be placed at the location of inclined roller supports
- SystemElements.q_load(q, element_id, direction='element', rotation=None, q_perp=None)[source]
Apply a q-load (distributed load) to an element.
- Return type:
- Args:
q (Union[float, Sequence[float]]): Value of the q-load element_id (Union[int, Sequence[int]]): The element ID to which to apply the load direction (Union["LoadDirection", Sequence["LoadDirection"]], optional):
“element”, “x”, “y”, “parallel”, or “perpendicular”. Defaults to “element”.
- rotation (Optional[Union[float, Sequence[float]]], optional): Rotate the force clockwise.
Rotation is in degrees. Defaults to None.
- q_perp (Optional[Union[float, Sequence[float]]], optional): Value of any q-load perpendicular
to the indicated direction/rotatione. Defaults to None.
- Raises:
FEMException: _description_
Supporting conditions
- SystemElements.add_support_hinged(node_id)[source]
Model a hinged support at a given node.
- Return type:
- Args:
node_id (Union[int, Sequence[int]]): Represents the nodes ID
- SystemElements.add_support_roll(node_id, direction='x', angle=None, rotate=True)[source]
Add a rolling support at a given node.
- Return type:
- Args:
node_id (Union[Sequence[int], int]): Represents the nodes ID direction (Union[Sequence[SupportDirection], SupportDirection], optional): Represents the direction
that is free (“x”, “y”, “1”, or “2”). Defaults to “x”.
- angle (Union[Sequence[Optional[float]], Optional[float]], optional): Angle in degrees relative to
global x-axis. If angle is given, the support will be inclined. Defaults to None.
- rotate (Union[Sequence[bool], bool], optional): If set to False, rotation at the roller will also
be restrianed. Defaults to True.
- Raises:
FEMException: Invalid direction, if the direction parameter is invalid
- SystemElements.add_support_fixed(node_id)[source]
Add a fixed support at a given node.
- Return type:
- Args:
node_id (Union[Sequence[int], int]): Represents the nodes ID
- SystemElements.add_support_spring(node_id, translation, k, roll=False)[source]
Add a spring support at a given node.
- Return type:
- Args:
node_id (Union[Sequence[int], int]): Represents the nodes ID translation (Union[Sequence[AxisNumber], AxisNumber]): Represents the prevented translation or rotation.
1 = translation in x, 2 = translation in y, 3 = rotation about z
k (Union[Sequence[float], float]): Stiffness of the spring roll (Union[Sequence[bool], bool], optional): If set to True, only the translation of the
spring is controlled. Defaults to False.
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.
- Return type:
ndarray
- Args:
- force_linear (bool, optional): Force a linear calculation, even when the system has non-linear nodes.
Defaults to False.
verbosity (int, optional): Log calculation outputs (0), or silence (1). Defaults to 0. max_iter (int, optional): Maximum allowed iterations. Defaults to 200. geometrical_non_linear (int, optional): Calculate second order effects and determine the buckling factor.
Defaults to False.
- Optional Keyword Args:
naked (bool): Whether or not to run the solve function without doing post processing. discretize_kwargs (dict): 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
- Raises:
- FEMException: The eigenvalues of the stiffness matrix are non zero, which indicates an unstable structure.
Check your support conditions
- Returns:
np.ndarray: Displacements vector.
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.
- Args:
verbosity (int, optional): 0: All information, 1: Suppress information. Defaults to 0. scale (float, optional): Scale of the plot. Defaults to 1.0. offset (Tuple[float, float], optional): Offset the plots location on the figure. Defaults to (0, 0). figsize (Optional[Tuple[float, float]], optional): Change the figure size. Defaults to None. show (bool, optional): Plot the result or return a figure. Defaults to True. supports (bool, optional): Plot the supports. Defaults to True. values_only (bool, optional): Return the values that would be plotted as tuple containing
two arrays: (x, y). Defaults to False.
annotations (bool, optional): if True, structure annotations are plotted. It includes section name.
- Returns:
Figure: If show is False, return a 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.
- Args:
factor (Optional[float], optional): Influence the plotting scale. Defaults to None. verbosity (int, optional): 0: All information, 1: Suppress information. Defaults to 0. scale (float, optional): Scale of the plot. Defaults to 1. offset (Tuple[float, float], optional): Offset the plots location on the figure. Defaults to (0, 0). figsize (Optional[Tuple[float, float]], optional): Change the figure size. Defaults to None. show (bool, optional): Plot the result or return a figure. Defaults to True. values_only (bool, optional): Return the values that would be plotted as tuple containing
two arrays: (x, y). Defaults to False.
- Returns:
Figure: If show is False, return a 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.
- Args:
factor (Optional[float], optional): Influence the plotting scale. Defaults to None. verbosity (int, optional): 0: All information, 1: Suppress information. Defaults to 0. scale (float, optional): Scale of the plot. Defaults to 1. offset (Tuple[float, float], optional): Offset the plots location on the figure. Defaults to (0, 0). figsize (Optional[Tuple[float, float]], optional): Change the figure size. Defaults to None. show (bool, optional): Plot the result or return a figure. Defaults to True. values_only (bool, optional): Return the values that would be plotted as tuple containing
two arrays: (x, y). Defaults to False.
- Returns:
Figure: If show is False, return a 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.
- Args:
factor (Optional[float], optional): Influence the plotting scale. Defaults to None. verbosity (int, optional): 0: All information, 1: Suppress information. Defaults to 0. scale (float, optional): Scale of the plot. Defaults to 1. offset (Tuple[float, float], optional): Offset the plots location on the figure. Defaults to (0, 0). figsize (Optional[Tuple[float, float]], optional): Change the figure size. Defaults to None. show (bool, optional): Plot the result or return a figure. Defaults to True. values_only (bool, optional): Return the values that would be plotted as tuple containing
two arrays: (x, y). Defaults to False.
- Returns:
Figure: If show is False, return a figure.
- SystemElements.show_reaction_force(verbosity=0, scale=1, offset=(0, 0), figsize=None, show=True)[source]
Plot the reaction force.
- Return type:
Optional[Figure]
- Args:
verbosity (int, optional): 0: All information, 1: Suppress information. Defaults to 0. scale (float, optional): Scale of the plot. Defaults to 1. offset (Tuple[float, float], optional): Offset the plots location on the figure. Defaults to (0, 0). figsize (Optional[Tuple[float, float]], optional): Change the figure size. Defaults to None. show (bool, optional): Plot the result or return a figure. Defaults to True.
- Returns:
Figure: If show is False, 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.
- Args:
factor (Optional[float], optional): Influence the plotting scale. Defaults to None. verbosity (int, optional): 0: All information, 1: Suppress information. Defaults to 0. scale (float, optional): Scale of the plot. Defaults to 1. offset (Tuple[float, float], optional): Offset the plots location on the figure. Defaults to (0, 0). figsize (Optional[Tuple[float, float]], optional): Change the figure size. Defaults to None. show (bool, optional): Plot the result or return a figure. Defaults to True. linear (bool, optional): Don’t evaluate the displacement values in between the elements. Defaults to False. values_only (bool, optional): Return the values that would be plotted as tuple containing
two arrays: (x, y). Defaults to False.
- Returns:
Figure: If show is False, return a figure.
Numerical feedback
- SystemElements.get_node_results_system(node_id=None)[source]
Get the node results. These are the opposite of the forces and displacements working on the elements and may seem counter intuitive.
- Args:
- node_id (int, optional): The node’s ID. If node_id == None or 0, the results of all nodes are returned.
Defaults to None.
- Returns:
- Union[ List[Dict[str, Union[int, float]]], Dict[str, Union[int, float]] ]:
If node_id == 0, returns a list containing tuples with the results: [(id, Fx, Fy, Tz, ux, uy, phi_z), (id, Fx, Fy…), () .. ] If node_id > 0, returns a dict with the results: {“id”: id, “Fx”: Fx, “Fy”: Fy, “Tz”: Tz, “ux”: ux, “uy”: uy, “phi_z”: phi_z}
- SystemElements.get_node_displacements(node_id=None)[source]
Get the node displacements.
- Args:
- node_id (int, optional): The node’s ID. If node_id == None or 0, the results of all nodes are returned.
Defaults to None.
- Returns:
- Union[List[Dict[str, Any]], Dict[str, Any]]: If node_id == 0, returns a list containing
tuples with the results: [(id, ux, uy, phi_z), (id, ux, uy, phi_z), … (id, ux, uy, phi_z) ] If node_id > 0, returns a dict with the results: {“id”: id, “ux”: ux, “uy”: uy, “phi_z”: phi_z}
- SystemElements.get_node_result_range(unit)[source]
Get the node results. Returns a list with the node results for a certain unit.
- Args:
unit (str): “uy”, “ux”, or “phi_z”
- Raises:
NotImplementedError: If the unit is not implemented.
- Returns:
List[float]: List with the node results for a certain unit.
- SystemElements.get_element_results(element_id=None, verbose=False)[source]
Get the element results.
- Args:
- element_id (int, optional): The element’s ID. If element_id == None or 0, the results of all elements
are returned. Defaults to None.
- verbose (bool, optional): If set to True, then numerical results for the deflection and the bending
moment are also returned. Defaults to False.
- Returns:
- Union[List[Dict[str, Any]], Dict[str, Any]]: If element_id == 0,
- returns a list containing dicts with the results: [{“id”: id, “length”: length, “alpha”: alpha,
“umax”: umax, “umin”: umin, “u”: u, “wmax”: wmax, “wmin”: wmin, “w”: w, “Mmin”: Mmin, “Mmax”: Mmax, “M”: M, “Qmin”: Qmin, “Qmax”: Qmax, “Q”: Q, “Nmin”: Nmin, “Nmax”: Nmax, “N”: N, “q”: q}, … ]
- If element_id > 0, returns a dict with the results: {“id”: id, “length”: length, “alpha”: alpha,
“umax”: umax, “umin”: umin, “u”: u, “wmax”: wmax, “wmin”: wmin, “w”: w, “Mmin”: Mmin, “Mmax”: Mmax, “M”: M, “Qmin”: Qmin, “Qmax”: Qmax, “Q”: Q, “Nmin”: Nmin, “Nmax”: Nmax, “N”: N, “q”: q}
- SystemElements.get_element_result_range(unit, minmax='abs')[source]
Get the element results. Returns a list with the min/max results of each element for a certain unit.
- Args:
unit (str): “shear”, “moment”, or “axial” minmax (str), optional: “min”, “max”, “abs”, or “both”. Defaults to “abs”.
Note that “both” returns a tuple with two values: (min, max)
- Raises:
NotImplementedError: If the unit is not implemented.
- Returns:
List[Union[float, Tuple[float]]]: List with min and/or max results of each element for a certain unit.
Utility methods for interacting with the elements and nodes
- SystemElements.find_node_id(vertex, tolerance=1e-09)[source]
Find the ID of a certain location.
- Args:
vertex (Union[Vertex, Sequence[float]]): Vertex_xz, [x, y], (x, y) tolerance (float): Tolerance for matching existing node locations (length units). Defaults to 1e-9.
- Raises:
TypeError: vertex must be a list, tuple or Vertex
- Returns:
Optional[int]: id of the node at the location of the vertex