ACCESS THE COMPLETE LIBRARY OF COURSES & TUTORIALS ➡️
50. Automating the output visualisation
Building a Generalised Truss Solver in Python
📂 Please log in or enroll to access resources

Summary

In this lecture, we'll cover:

  • Creating a plotting section using Matplotlib to visualise the structure
  • Looping through members to plot the undeformed structural geometry
  • Extracting nodal coordinates from the nodes array with correct Python indexing
  • Identifying global degrees of freedom to obtain nodal displacements
  • Plotting the deformed shape using scaled displacements from the global displacement vector
  • Adding node markers and improving plot presentation with labels, grid and formatting

In this lecture, we focus on visualising the structural model and its deflected shape. We begin by setting up a Matplotlib figure, defining axes and enforcing an equal aspect ratio. Using a for loop, we cycle through each member in the structure, extract the corresponding nodal coordinates from the nodes array and plot each member as a line between its two nodes. This allows us to generate the undeformed geometry of the structure automatically from the input data.

We then extend this approach to plot the deformed shape. To do this, we determine the indices of the global degrees of freedom associated with each node of a member and extract the relevant displacements from the global displacement vector. By adding scaled displacement components to the original nodal coordinates, we plot the displaced structure as a dashed line, introducing a scaling factor to make small deflections visible. Finally, we enhance the visual output by plotting node markers and adding labels, a title and a grid. By the end of the lecture, we have a fully automated plotting routine capable of displaying both undeformed and deformed configurations for any structure defined in the notebook.

Next up:

In the next lecture, we add an automated text summary of reactions, member forces, and nodal displacements, completing the full output suite of our generalised solver.

Tags

matplotlib plottingstructural deflection visualisationglobal displacement vector

Please log in or enroll to continue

If you've already enrolled, please log in to continue.

The Direct Stiffness Method for Truss Analysis with Python

Build your own finite element truss analysis software using Python and tackle large scale structures.

After completing this course...

  • You’ll understand how to use the Direct Stiffness Method to build complete structural models that can be solved using Python.
  • You’ll have your own analysis programme to identify displacements, reactions and internal member forces for any truss.
  • You’ll understand how common models of elastic behaviour such as plane stress and plane strain apply to real-world structures.
Next Lesson
51. Automating the text summary