Note
Go to the end to download the full example code.
Beam3#
A bi-fixed beam undergoing bending deformation.
err uy : 0.00 %
==================== Mesh ====================
Element type: SEG2
Ne = 10, Nn = 11
==================== Model ====================
<EasyFEA.models._beam.BeamStructure object at 0x79b855d5be50>
solver : pypardiso
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
Ux max = 0.00e+00
Ux min = 0.00e+00
Uy max = 0.00e+00
Uy min = -6.71e-03
=================== TicTac ===================
Mesh : 84.845 ms
Boundary Conditions : 84.400 µs
Matrix : 27.835 ms
Solver : 83.650 ms
Display : 191.196 ms
PostProcessing : 189.543 µs
12 from EasyFEA import Display, Models, plt, np, Mesher, ElemType, Simulations
13 from EasyFEA.Geoms import Line, Point, Points
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 # ----------------------------------------------
19 # Configuration
20 # ----------------------------------------------
21
22 # geom
23 L = 120
24 h = 20
25 b = 13
26 e = 2
27
28 # model
29 E = 210000
30 v = 0.3
31
32 # load
33 load = 800
34
35 # ----------------------------------------------
36 # Section
37 # ----------------------------------------------
38
39 def DoSym(p: Point, n: np.ndarray) -> Point:
40 pc = p.copy()
41 pc.Symmetry(n=n)
42 return pc
43
44 p1 = Point(-b / 2, -h / 2)
45 p2 = Point(b / 2, -h / 2)
46 p3 = Point(b / 2, -h / 2 + e)
47 p4 = Point(e / 2, -h / 2 + e, r=e)
48 p5 = DoSym(p4, (0, 1))
49 p6 = DoSym(p3, (0, 1))
50 p7 = DoSym(p2, (0, 1))
51 p8 = DoSym(p1, (0, 1))
52 p9 = DoSym(p6, (1, 0))
53 p10 = DoSym(p5, (1, 0))
54 p11 = DoSym(p4, (1, 0))
55 p12 = DoSym(p3, (1, 0))
56 contour = Points([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12], e / 6)
57 section = Mesher().Mesh_2D(contour)
58
59 # ----------------------------------------------
60 # Mesh
61 # ----------------------------------------------
62
63 elemType = ElemType.SEG2
64 beamDim = 2 # must be >= 2
65
66 p1 = Point()
67 pL = Point(x=L / 2)
68 p2 = Point(x=L)
69 line = Line(p1, p2, L / 9)
70 beam = Models.BeamElasIsot(beamDim, line, section, E, v)
71
72 mesh = Mesher().Mesh_Beams([beam], additionalPoints=[pL], elemType=elemType)
73
74 # ----------------------------------------------
75 # Simulation
76 # ----------------------------------------------
77
78 # Initialize the beam structure with the defined beam segments
79 beamStructure = Models.BeamStructure([beam])
80
81 # Create the beam simulation
82 simu = Simulations.BeamSimu(mesh, beamStructure)
83 dof_n = simu.Get_dof_n()
84
85 # Apply boundary conditions
86 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
87 simu.add_dirichlet(mesh.Nodes_Point(p2), [0] * dof_n, simu.Get_unknowns())
88 simu.add_neumann(mesh.Nodes_Point(pL), [-load], ["y"])
89
90 # Solve the beam problem and get displacement results
91 sol = simu.Solve()
92 simu.Save_Iter()
93
94 # ----------------------------------------------
95 # Results
96 # ----------------------------------------------
97
98 u_an = load * L**3 / (192 * E * beam.Iz)
99
100 uy_1d = np.abs(simu.Result("uy").min())
101
102 Display.MyPrint(f"err uy : {np.abs(u_an - uy_1d) / u_an * 100:.2f} %")
103
104 Display.Plot_Mesh(simu, L / 20 / sol.min())
105 ax = Display.Plot_Mesh(section)
106 ax.set_title("Section")
107 Display.Plot_BoundaryConditions(simu)
108 Display.Plot_Result(simu, "uy", L / 20 / sol.min())
109
110 print(simu)
111
112 plt.show()
Total running time of the script: (0 minutes 0.326 seconds)



