Skip to content
Advertisement

Creating a network-like figure a truss in Python

I would like to create the graphic of a truss. I have two lists of lists; one gives the bar number and the nodes that make them, it looks like this:

JavaScript

For example, element one is composed by node 1 and node 2. The other dataset gives the nodes followed by its coordinates in the 2D plane. It looks like this:

JavaScript

For example, node 1 has the (0.0, 1.2) coordinates.

I want to recreate with pyplot the following graphic using the lists of list above. Where A is 1.5m and B 1.2m.

Example of required image

I thought doing something like this:

JavaScript

I know I am not doing the for right (out of index) but I don´t really know how to solve it.

Advertisement

Answer

enter image description here

Your question is too wide, I provide an answer only to the first part of it, given a list of nodal coordinates and a list of connectivities, how to draw a truss?

First, if you are implementing a program for truss analysis, you will probably use a dataclass and store much more info about each one of the bars, but as a starter we need only the connectivity and I write:

JavaScript

Next, a list of nodal coordinates and a list of bars

JavaScript

The drawing, abstracted in a function

JavaScript

And finally, we execute our function

JavaScript

Does the above helps you?

Because I will not expand my answer, if you cannot proceed from this starting block then you should ask further, more focused questions.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement