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



