Professional Documents
Culture Documents
Code Output Fem
Code Output Fem
n = len(nodes)
K = np.zeros((n*2, n*2))
D = displacement_matrix(nodes)
displacements.append(u)
internal_forces.append(internal_force)
# Ví dụ dữ liệu
material = {'E': 200e9} # Độ cứng của vật liệu (Pa)
section = {'A': 0.01} # Diện tích mặt cắt (m^2)
nodes = {0: [0, 0], 1: [2, 0], 2: [4, 0]} # Tọa độ nút
elements = [(0, 1), (1, 2)] # Các phần tử (liên kết nút)
boundary_conditions = {0: {'x': 0, 'y': 0}, 2: {'y': 0}} # Điều kiện biên tại nút
loads = {1: {'x': 10000}} # Tải tại nút (N)
# Tính toán
displacements, internal_forces = calculate_deformation_and_internal_force(material,
section, nodes, elements, boundary_conditions, loads)
# In kết quả
for i, (u, f) in enumerate(zip(displacements, internal_forces)):
print(f"Element {i+1}:")
print(f"Displacement:\n{u}")
print(f"Internal force: {f} N\n")
# Vẽ biểu đồ
for i, (u, f) in enumerate(zip(displacements, internal_forces)):
node1, node2 = elements[i]
x1, y1 = nodes[node1]
x2, y2 = nodes[node2]