关键词
MATLAB | Python | 数学 | 物理 | 受力 | 载荷 | 构件 | 钢结构 | 非标件 | 节点 | 位移 | 内力 | 元素 | 几何 | 积分 | 算法 | 矩阵 | 网格 | 二维 | 一维 | 边界值 | 绘图 | 矢量 | 稀疏矩阵 | 刚度 | 平面 | 空间 | 桁架 | 框架 | 承载 | 形变 | 力矩 | 横截面 | 沉降 | 支撑 | 释放 | 弹性 | 线性 | 外力 | 法向应力 | 应变 | 轴对称 | 拉伸 | 弯曲 | 牵引 | 弹塑性 | 微分方程 | 数值
考虑长度为 50 毫米、宽度为 10 毫米、厚度为 1 毫米的条带。使用 200 N 的力,该条带在垂直的平面应变张力下变形。条带的底部保持固定。带材的弹性特性为E=100MPa,ν=0.48。
import numpy as np
import math
from matplotlib import pyplot as plt
def shape(xi):
x,y = tuple(xi)
N = [(1.0-x)*(1.0-y), (1.0+x)*(1.0-y), (1.0+x)*(1.0+y), (1.0-x)*(1.0+y)]
return 0.25*np.array(N)
print('create mesh')
mesh_ex = 9
mesh_ey = 49
mesh_lx = 10.0
mesh_ly = 50.0
# derived
mesh_nx = mesh_ex + 1
mesh_ny = mesh_ey + 1
num_nodes = mesh_nx * mesh_ny
num_elements = mesh_ex * mesh_ey
mesh_hx = mesh_lx / mesh_ex
mesh_hy = mesh_ly / mesh_ey
nodes = []
for y in np.linspace(0.0, mesh_ly, mesh_ny):
for x in np.linspace(0.0, mesh_lx, mesh_nx):
nodes.append([x,y])
nodes = np.array(nodes)
conn = []
for j in range(mesh_ey):
for i in range(mesh_ex):
n0 = i + j*mesh_nx
conn.append([n0, n0 + 1, n0 + 1 + mesh_nx, n0 + mesh_nx])
print ('material model - plane strain')
E = 100.0
v = 0.48
C = E/(1.0+v)/(1.0-2.0*v) * np.array([[1.0-v, v, 0.0],
[ v, 1.0-v, 0.0],
[ 0.0, 0.0, 0.5-v]])
print('create global stiffness matrix')
K = np.zeros((2*num_nodes, 2*num_nodes))
q4 = [[x/math.sqrt(3.0),y/math.sqrt(3.0)] for y in [-1.0,1.0] for x in [-1.0,1.0]]
B = np.zeros((3,8))
for c in conn:
xIe = nodes[c,:]
Ke = np.zeros((8,8))
for q in q4:
dN = gradshape(q)
J = np.dot(dN, xIe).T
dN = np.dot(np.linalg.inv(J), dN)
B[0,0::2] = dN[0,:]
B[1,1::2] = dN[1,:]
B[2,0::2] = dN[1,:]
B[2,1::2] = dN[0,:]
Ke += np.dot(np.dot(B.T,C),B) * np.linalg.det(J)
for i,I in enumerate(c):
for j,J in enumerate(c):
K[2*I,2*J] += Ke[2*i,2*j]
K[2*I+1,2*J] += Ke[2*i+1,2*j]
K[2*I+1,2*J+1] += Ke[2*i+1,2*j+1]
K[2*I,2*J+1] += Ke[2*i,2*j+1]
print('assign nodal forces and boundary conditions')
f = np.zeros((2*num_nodes))
for i in range(num_nodes):
if nodes[i,1] == 0.0:
K[2*i,:] = 0.0
K[2*i+1,:] = 0.0
K[2*i,2*i] = 1.0
K[2*i+1,2*i+1] = 1.0
if nodes[i,1] == mesh_ly:
x = nodes[i,0]
f[2*i+1] = 20.0
if x == 0.0 or x == mesh_lx:
f[2*i+1] *= 0.5
print('solving linear system')
u = np.linalg.solve(K, f)
print('max u=', max(u))
print('plotting displacement')
ux = np.reshape(u[0::2], (mesh_ny,mesh_nx))
uy = np.reshape(u[1::2], (mesh_ny,mesh_nx))
xvec = []
yvec = []
res = []
for i in range(mesh_nx):
for j in range(mesh_ny):
xvec.append(i*mesh_hx + ux[j,i])
yvec.append(j*mesh_hy + uy[j,i])
res.append(uy[j,i])
t = plt.tricontourf(xvec, yvec, res, levels=14, cmap=plt.cm.jet)
plt.scatter(xvec, yvec, marker='o', c='b', s=2)
plt.grid()
plt.colorbar(t)
plt.axis('equal')
plt.show()