0% found this document useful (0 votes)
3 views1 page

GRASP Python (17)

The document describes methods for visualizing and analyzing structural elements in a graphical format using Python. It includes functions to draw fixed, pinned, and roller support symbols, as well as a method for performing structural analysis with a global stiffness matrix. The analysis requires nodes and elements to be defined for successful execution.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

GRASP Python (17)

The document describes methods for visualizing and analyzing structural elements in a graphical format using Python. It includes functions to draw fixed, pinned, and roller support symbols, as well as a method for performing structural analysis with a global stiffness matrix. The analysis requires nodes and elements to be defined for successful execution.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

self.ax.

plot([node1['x'], node2['x']], [node1['y'], node2['y']],


'k-')
mid_x = (node1['x'] + node2['x']) / 2
mid_y = (node1['y'] + node2['y']) / 2
self.ax.text(mid_x, mid_y, f'E{elem_id}', color='green')

self.ax.set_aspect('equal')
self.ax.grid(True)
self.ax.set_title('Structural Analysis')
self.fig.canvas.draw()

def draw_fixed_support(self, x, y):


"""Draw a fixed support symbol"""
self.ax.plot([x-0.5, x+0.5], [y, y], 'k-', linewidth=2)
self.ax.plot([x-0.5, x-0.5], [y, y-0.5], 'k-', linewidth=2)
self.ax.plot([x+0.5, x+0.5], [y, y-0.5], 'k-', linewidth=2)
for i in np.linspace(x-0.4, x+0.4, 5):
self.ax.plot([i, i], [y, y-0.3], 'k-', linewidth=1)

def draw_pinned_support(self, x, y):


"""Draw a pinned support symbol"""
self.ax.plot(x, y, 'ko', markersize=8)
self.ax.plot([x-0.5, x+0.5], [y, y], 'k-', linewidth=2)
self.ax.plot([x-0.5, x-0.5], [y, y-0.5], 'k-', linewidth=2)
self.ax.plot([x+0.5, x+0.5], [y, y-0.5], 'k-', linewidth=2)

def draw_roller_support(self, x, y):


"""Draw a roller support symbol"""
self.ax.plot(x, y, 'ko', markersize=8)
self.ax.plot([x-0.5, x+0.5], [y, y], 'k-', linewidth=2)
self.ax.plot([x-0.5, x-0.5], [y, y-0.5], 'k-', linewidth=2)
self.ax.plot([x+0.5, x+0.5], [y, y-0.5], 'k-', linewidth=2)
self.ax.plot(x, y-0.5, 'ko', markersize=4)
self.ax.plot([x-0.3, x+0.3], [y-0.7, y-0.7], 'k-', linewidth=2)

def analyze_structure(self, event=None):


"""Perform structural analysis using the direct stiffness method"""
if not self.nodes or not self.elements:
print("Error: Structure must have nodes and elements to analyze")
return

# Initialize global stiffness matrix


num_nodes = len(self.nodes)
K_global = np.zeros((2*num_nodes, 2*num_nodes))

# Assemble global stiffness matrix


for elem_id, elem in self.elements.items():
node1, node2 = elem['nodes']
n1 = self.nodes[node1]
n2 = self.nodes[node2]

# Element properties
E = elem['E']
A = elem['A']
L = np.sqrt((n2['x']-n1['x'])**2 + (n2['y']-n1['y'])**2)
c = (n2['x']-n1['x'])/L # cosine
s = (n2['y']-n1['y'])/L # sine

P a g e 3 | 62

You might also like