Note
Go to the end to download the full example code.
Elas1#
A cantilever beam undergoing bending deformation.
==================== Mesh ====================
Element type: QUAD9
Ne = 81, Nn = 385
==================== Model ====================
Isotropic:
E = 2.10e+05, v = 0.3
planeStress = True
thickness = 1.30e+01
solver : scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
W def = 371.24
Svm max = 166.81
Evm max = 0.09 %
Ux max = 7.49e-02
Ux min = -7.49e-02
Uy max = 0.00e+00
Uy min = -9.28e-01
=================== TicTac ===================
Mesh : 10.583 ms
Boundary Conditions : 20.981 µs
Matrix : 11.657 ms
Solver : 4.129 ms
PostProcessing : 1.621 ms
=================== Result ===================
err W : 0.24 %
err uy : 0.68 %
12 import matplotlib.pyplot as plt
13 import numpy as np
14
15 from EasyFEA import Display, Models, ElemType, Simulations
16 from EasyFEA.Geoms import Domain
17
18 if __name__ == "__main__":
19 Display.Clear()
20
21 # ----------------------------------------------
22 # Configuration
23 # ----------------------------------------------
24
25 # geom
26 dim = 2
27 L = 120 # mm
28 h = 13
29 I = h**4 / 12 # mm4
30
31 # model
32 E = 210000 # MPa (Young's modulus)
33 v = 0.3 # Poisson's ratio
34 coef = 1
35
36 # load
37 load = 800 # N
38
39 # expected results
40 W_an = 2 * load**2 * L / E / h**2 * (L**2 / h**2 + (1 + v) * 3 / 5) # mJ
41 uy_an = load * L**3 / (3 * E * I)
42
43 # ----------------------------------------------
44 # Mesh
45 # ----------------------------------------------
46
47 N = 3
48 meshSize = h / N
49
50 domain = Domain((0, 0), (L, h), meshSize)
51
52 if dim == 2:
53 mesh = domain.Mesh_2D([], ElemType.QUAD9, isOrganised=True)
54 else:
55 mesh = domain.Mesh_Extrude(
56 [], [0, 0, -h], [N], ElemType.HEXA27, isOrganised=True
57 )
58
59 nodes_x0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
60 nodes_xL = mesh.Nodes_Conditions(lambda x, y, z: x == L)
61
62 # ----------------------------------------------
63 # Simulation
64 # ----------------------------------------------
65
66 material = Models.Elastic.Isotropic(dim, E, v, planeStress=True, thickness=h)
67 simu = Simulations.Elastic(mesh, material)
68
69 simu.add_dirichlet(nodes_x0, [0] * dim, simu.Get_unknowns())
70 simu.add_surfLoad(nodes_xL, [-load / h**2], ["y"])
71
72 sol = simu.Solve()
73 simu.Save_Iter()
74
75 uy_num = -simu.Result("uy").min()
76 W_num = simu._Calc_Psi_Elas()
77
78 # ----------------------------------------------
79 # Results
80 # ----------------------------------------------
81 print(simu)
82
83 Display.Section("Result")
84
85 print(f"err W : {np.abs(W_an - W_num) / W_an * 100:.2f} %")
86
87 print(f"err uy : {np.abs(uy_an - uy_num) / uy_an * 100:.2f} %")
88
89 Display.Plot_Mesh(simu, h / 2 / np.abs(sol).max())
90 Display.Plot_BoundaryConditions(simu)
91 Display.Plot_Result(simu, "uy", nodeValues=True, coef=1 / coef, ncolors=20)
92 Display.Plot_Result(simu, "Svm", plotMesh=True, ncolors=11)
93
94 plt.show()
Total running time of the script: (0 minutes 0.453 seconds)



