Every member at once
Up to now, every check we've written has been about one member. Real structures have many members, and a check you'd write for one of them usually applies to all of them. In this step, we'll write a check once and run it over every member of a truss. Our structure is a 12 m Pratt truss of thirteen members, with both tension and compression forces. This is too many to check one at a time comfortably, but few enough that we can still check every force by hand, using the method of sections and the method of joints. We'll loop over the members, set out every axial force in a table, work out the utilisation of the members in tension, and draw the forces as a bar chart.
If you need a refresher on the two methods, take a look at this EngineeringSkills tutorial, Truss Analysis using the Method of Joints and Method of Sections.
1.0 The idea
A loop runs the same lines of Python once for each item in a collection. In a sheet, the collection is usually the model's members, sb.model.members, so a check written inside the loop runs on every member, reading each one's own section, material, length and forces. The result is a list of rows, one per member, and the tidiest way to present a list of rows is usually a table.
For tables, we'll use pandas, the standard Python library for tabular data, and for plots, matplotlib. Both are ready to import in every sheet. A pandas table, called a DataFrame, can be sorted, filtered and grouped in a line or two, and a sheet shows it as a formatted table under its cell.
2.0 The model
Our model is a Pratt truss 12 m long and 2 m deep, with four panels of 3 m. The bottom chord runs the full 12 m between a pin at the left and a roller at the right. The top chord is 6 m long, between the two inner panel points, and sloping end posts run from each support up to it. The chords and end posts are SHS 100 x 100 x 6.3, and the verticals and diagonals are CHS 88.9 x 5.0, all in S355. In a Pratt truss, the diagonals slope down towards the middle, so under gravity load they carry tension and the verticals carry compression.