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 : 6.213 ms
Boundary Conditions : 11.683 µs
Matrix : 6.373 ms
Solver : 2.721 ms
PostProcessing : 1.068 ms
=================== Result ===================
err W : 0.24 %
err uy : 0.68 %
13 import matplotlib.pyplot as plt
14 import numpy as np
15
16 from EasyFEA import Display, Models, ElemType, Simulations
17 from EasyFEA.Geoms import Domain
18
19 if __name__ == "__main__":
20 Display.Clear()
21
22 # ----------------------------------------------
23 # Configuration
24 # ----------------------------------------------
25
26 # geom
27 dim = 2
28 L = 120 # mm
29 h = 13
30 I = h**4 / 12 # mm4
31
32 # model
33 E = 210000 # MPa (Young's modulus)
34 v = 0.3 # Poisson's ratio
35 coef = 1
36
37 # load
38 load = 800 # N
39
40 # expected results
41 W_an = 2 * load**2 * L / E / h**2 * (L**2 / h**2 + (1 + v) * 3 / 5) # mJ
42 uy_an = load * L**3 / (3 * E * I)
43
44 # ----------------------------------------------
45 # Mesh
46 # ----------------------------------------------
47
48 N = 3
49 meshSize = h / N
50
51 domain = Domain((0, 0), (L, h), meshSize)
52
53 if dim == 2:
54 mesh = domain.Mesh_2D([], ElemType.QUAD9, isOrganised=True)
55 else:
56 mesh = domain.Mesh_Extrude(
57 [], [0, 0, -h], [N], ElemType.HEXA27, isOrganised=True
58 )
59
60 nodes_x0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
61 nodes_xL = mesh.Nodes_Conditions(lambda x, y, z: x == L)
62
63 # ----------------------------------------------
64 # Simulation
65 # ----------------------------------------------
66
67 material = Models.Elastic.Isotropic(dim, E, v, planeStress=True, thickness=h)
68 simu = Simulations.Elastic(mesh, material)
69
70 simu.add_dirichlet(nodes_x0, [0] * dim, simu.Get_unknowns())
71 simu.add_surfLoad(nodes_xL, [-load / h**2], ["y"])
72
73 sol = simu.Solve()
74 simu.Save_Iter()
75
76 uy_num = -simu.Result("uy").min()
77 W_num = simu._Calc_Psi_Elas()
78
79 # ----------------------------------------------
80 # Results
81 # ----------------------------------------------
82 print(simu)
83
84 Display.Section("Result")
85
86 print(f"err W : {np.abs(W_an - W_num) / W_an * 100:.2f} %")
87
88 print(f"err uy : {np.abs(uy_an - uy_num) / uy_an * 100:.2f} %")
89
90 Display.Plot_Mesh(simu, h / 2 / np.abs(sol).max())
91 Display.Plot_BoundaryConditions(simu)
92 Display.Plot_Result(simu, "uy", nodeValues=True, coef=1 / coef, ncolors=20)
93 Display.Plot_Result(simu, "Svm", plotMesh=True, ncolors=11)
94
95 plt.show()
Total running time of the script: (0 minutes 0.239 seconds)



