You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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)
The text was updated successfully, but these errors were encountered: