Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assemblage 2D 4-node element #1

Open
GEORMC opened this issue Aug 18, 2023 · 0 comments
Open

Assemblage 2D 4-node element #1

GEORMC opened this issue Aug 18, 2023 · 0 comments

Comments

@GEORMC
Copy link
Owner

GEORMC commented Aug 18, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant