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



