-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
import numpy as np
Element stiffness matrices for 2D 4-node element
k_element = [
np.array([[2, -1, -1, 0],
[-1, 1, 0, 0],
[-1, 0, 1, -1],
[0, 0, -1, 1]]),
np.array([[1, -1, 0, 0],
[-1, 2, -1, 0],
[0, -1, 1, 0],
[0, 0, 0, 0]])
]
Connectivity matrix (element connectivity)
connectivity = [
[1, 2, 3, 4], # Nodes for element 1
[3, 4, 5, 6] # Nodes for element 2
]
Total number of nodes
num_nodes = max(max(connectivity))
Initialize global stiffness matrix
k_global = np.zeros((num_nodes, num_nodes))
Assemble global stiffness matrix
for i, element_nodes in enumerate(connectivity):
for ni, i_global in enumerate(element_nodes):
for nj, j_global in enumerate(element_nodes):
k_global[i_global - 1, j_global - 1] += k_element[i][ni, nj]
print("Global Stiffness Matrix:")
print(k_global)
Metadata
Metadata
Assignees
Labels
No labels