sajou.plot.display module¶
Define all the functions needed to plot the created structures and the results
TODO: plot hinges
-
class
sajou.plot.display.
Display
(backend)¶ Bases:
object
Class to present the pre and postprocessing graphically.
This class is not intended to be used directly, but rather their sublclasses, which implement different plotting backends (at the moent only matplotlib).
Parameters: - width (float) – width of the window in pixels
- height (float) – height of the window in pixels
- theme (str) – color theme used for the plots. Options are: ‘dark’, ‘light’ and ‘publication’
- backend (str) –
backend used to display the results
- ‘matplotlib’
- ‘python-occ’ (not implemented yet)
- ‘mayavi’ (not implemented yet)
-
class
sajou.plot.display.
Display_mpl
(width=10.0, height=10.0, theme='dark', backend='matplotlib')¶ Bases:
sajou.plot.display.Display
Matplotlib backend for the visualization
Parameters: - width (float) – width of the window in pixels
- height (float) – height of the window in pixels
- theme (str) – color theme used for the plots. Options are: ‘dark’, ‘light’ and ‘publication’
-
plot_deformed_element
(element, result, ax)¶ Plot the given element in its deformed state
Parameters: - element (Element instance) – The element to be plotted
- result (Result instance) – The result obtained after solving the system
- ax (matplotlib Axis) – the axis where to plot the deformed element to
Returns: the axis used to plot the element
Return type: matplotlib Axis
-
plot_deformed_geometry
(result, ax, show_undeformed=False, scale=1.0)¶ Plot the system in its deformed configuration.
Parameters: - result (Result object) – result object returned by the Solver
- ax (matplotlib axis) – Axis where to draw to
- scale (float) – scale used to plot the deformations
Returns: the same axis object passed
Return type: matplotlib axis
-
plot_element_loads
(ax, model)¶ Plot the element loads.
Element loads like uniformly distributed loads are drawn accordinlgy.
Parameters: - ax (matplotlib axis) – axis where to draw to
- result (Result object) – Result object returned by the Solver
Returns: the same axis originally passed
Return type: matplotlib axis
-
plot_geometry
(model, ax, ls='-', **kwargs)¶ Plot the geometry of the model passed.
Parameters: - model (sajou.Model) – Model to plot
- ax (a matplotlib axis object) – Axis where to draw to
Returns: the same axis object given
Return type: matplotlib axis
-
plot_internal_forces
(ax, result, component, scale=1)¶ Plot the diagrams of internal forces.
Parameters: - ax (matplotlib axis) – the Axis instance where to draw the internal forces
- result (Result object) – obtained after solving the system
- component (str) –
component that want to be displayed. Options are
- ‘axial’
- ‘shear’
- ‘moment’
- scale (float) – scale for the member forces (the member forces are already automatically scaled to fit in the display. This is a scale factor that multiplies that automatically calulated factor)
Returns: the axis with the drawn internal forces
Return type: matplotlib axis
-
plot_nodal_force
(ax, dof, at, val)¶ TODO: Docstring for plot_forces.
Parameters: - ax (matplotlib Axis) – axis to plot to
- dof (int) – Degree of freedom to which the force is being applied
- at (Node object) – node at which the load is applied
- val (float) – value of the force
Returns: the same axis passed as asrgument
Return type: matplotlib Axis
-
plot_nodal_reaction
(ax, dof, at, val)¶ Plot the nodal reactions of the system
Parameters: - ax (matplotlib Axis) – axis to plot to
- dof (int) – Degree of freedom to which the force is being applied
- at (Node object) – node at which the load is applied
- val (float) – value of the reaction
Returns: the same Axis passed as argument
Return type: matplotlib Axis
-
plot_support
(ax, dof, at)¶ Plot the respective support
Parameters: - ax (matplotlib Axis) – axis where to plot the support
- dof (ndarray, list[int]) – DOF that are restrained
- at (Node object) – node at which the contraints are applied
Returns: the same axis passed
Return type: matplotlib Axis
-
sajou.plot.display.
get_deformed_node_coords
(nodes, result, scale=1)¶ Get the deformed coordinates of the given nodes
Parameters: - nodes (List[Node], str) – Node from which the deformed position will be computed
- result (Result object) – results obtained from the solver
- sacele (float) – scale applied to the deformations (default to 1)
Returns: node deformed coordinates
Return type: dict
-
sajou.plot.display.
get_element_deformed_node_coords
(element, result, scale=1)¶ Get the deformed coordinates of the nodes of the given element
Parameters: - element (ELement instance) – Element from which the deformed position of its nodes will be computed
- result (Result object) – results obtained from the solver
- sacele (float) – scale applied to the deformations (default to 1)
Returns: node deformed coordinates
Return type: dict
-
sajou.plot.display.
range_with_ratio
(x1, x2, n, a)¶ Create an array with numbers increasing their relative distance according to the ratio ‘a’.
The range is divided such that:
\[\ell_{tot} = \ell_1 + \ell_2 + ... + \ell_n\]where:
\[\begin{split}\ell_i &= \ell_i - 1 + b \\ b &= \frac{\ell_{tot} - (\frac{\ell_{tot}}{n} \cdot a)}{n}\end{split}\]Parameters: - x1 (float) – begin of the range
- x2 (float) – end of the range
- n (int) – number of points
- a (float) – ratio between the beginning and end
Returns: a range with increasingly separated values
Return type: ndarray