| import numpy as np |
| import matplotlib.pyplot as plt |
|
|
| def calBe(xy): |
| |
|
|
| |
| dN = np.array([[-1, 1, 0], |
| [-1, 0, 1]], dtype=float) |
|
|
| |
|
|
| |
|
|
| |
| |
|
|
| |
| A = xy.T @ dN.T |
|
|
| |
| DN = np.linalg.inv(A).T @ dN |
|
|
| |
|
|
| Be = np.array([ |
| [DN[0, 0], 0.0, DN[0, 1], 0.0, DN[0, 2], 0.0], |
| [0.0, DN[1, 0], 0.0, DN[1, 1], 0.0, DN[1, 2]], |
| [DN[1, 0], DN[0, 0], DN[1, 1], DN[0, 1], DN[1, 2], DN[0, 2]] |
| ]) |
| return Be |
|
|
| def calDet(xy): |
| dN = np.array([[-1, 1, 0], |
| [-1, 0, 1]], dtype=float) |
| A = xy.T @ dN.T |
| Det = -np.linalg.det(A) |
| return Det |
|
|
| |
|
|
| Forces = np.zeros((11, 1)) |
| Deplacements = np.zeros((11, 1)) |
|
|
| for j in range(0, 11): |
|
|
| |
|
|
| |
|
|
| |
| |
|
|
| |
| nodeData = np.loadtxt('NODE.txt') |
| elementData = np.loadtxt('ELEMENT.txt') |
|
|
| nodes = nodeData[:, 6:8] |
|
|
| |
| ne = nodes.shape[0] |
|
|
| elements = elementData[:, 5:8].astype(int) |
|
|
| |
|
|
| |
|
|
| |
| K = np.zeros((2*ne, 2*ne)) |
| F = np.zeros((2*ne, 1)) |
|
|
| |
|
|
| |
| E = 210000.0 |
| NU = 0.3 |
| C = E / ((1 + NU) * (1 - 2*NU)) * np.array([ |
| [1 - NU, NU, 0.0], |
| [NU, 1 - NU, 0.0], |
| [0.0, 0.0, (1 - 2*NU)/2] |
| ]) |
|
|
| |
|
|
| |
| for e in range(elements.shape[0]): |
| |
|
|
| |
| n1, n2, n3 = elements[e, :] |
|
|
| |
|
|
| |
|
|
| |
| xy = np.vstack((nodes[n1-1, :], |
| nodes[n2-1, :], |
| nodes[n3-1, :])) |
|
|
| Be = calBe(xy) |
| Ke = Be.T @ C @ Be * calDet(xy) / 2.0 |
|
|
| |
|
|
| |
| ind1 = (n1 - 1)*2 |
| ind2 = (n1 - 1)*2 + 1 |
| ind3 = (n2 - 1)*2 |
| ind4 = (n2 - 1)*2 + 1 |
| ind5 = (n3 - 1)*2 |
| ind6 = (n3 - 1)*2 + 1 |
|
|
| IndiceGlobal = np.array([ind1, ind2, ind3, ind4, ind5, ind6]) |
|
|
| |
|
|
| |
| |
|
|
| |
| for a in range(6): |
| for b in range(6): |
| K[IndiceGlobal[a], IndiceGlobal[b]] += Ke[a, b] |
|
|
| Kreac = K.copy() |
| Freac = F.copy() |
|
|
| |
|
|
| |
| P = np.max(K) * 10.0 |
|
|
| for i in range(ne): |
| x, y = nodes[i, 0], nodes[i, 1] |
| ind1 = 2*i |
| ind2 = 2*i + 1 |
|
|
| if (x == 12.5) and (y == 13.75): |
| F[ind2, 0] += 1000.0 |
|
|
| if (x == 12.5) and (y == -13.75): |
| F[ind2, 0] -= 1000.0 |
|
|
| if (x > 23.75 + j) and (abs(y) < 0.01): |
| |
|
|
| |
| K[ind2, ind2] += P |
|
|
| |
|
|
| |
| U = np.linalg.solve(K, F) |
| np.savetxt("U.txt",U) |
|
|
| Reac = Kreac @ U - Freac |
|
|
| Forces[j, 0] = abs(Reac[1, 0]) |
|
|
| |
| Deplacements[j, 0] = abs(U[1, 0]) |
|
|
| |
|
|
| |
| L = np.zeros((10, 1)) |
| G = np.zeros((10, 1)) |
| G_D = np.zeros((10, 1)) |
|
|
| for j in range(1, 11): |
| G[j-1, 0] = (-Forces[j, 0] + Forces[j-1, 0]) * 0.05 |
| G_D[j-1, 0] = (Deplacements[j, 0] - Deplacements[j-1, 0]) * 1000.0 |
| L[j-1, 0] = j - 1 |
|
|
| plt.figure() |
| plt.plot(L, G, '*', label='G (déplacement imposé)') |
| plt.plot(L, G_D, '-', label='G_D (effort imposé)') |
| plt.xlabel('L') |
| plt.ylabel('G') |
| plt.legend() |
| plt.grid(True) |
| |
|
|