Note
Go to the end to download the full example code.
Beam6#
A cantilever beam undergoing bending deformation in dynamic.

Generate movie 01/20 (5.00 %) 4.02 s
Generate movie 02/20 (10.00 %) 1.74 s
Generate movie 03/20 (15.00 %) 1.63 s
Generate movie 04/20 (20.00 %) 1.57 s
Generate movie 05/20 (25.00 %) 1.43 s
Generate movie 06/20 (30.00 %) 1.33 s
Generate movie 07/20 (35.00 %) 1.25 s
Generate movie 08/20 (40.00 %) 1.14 s
Generate movie 09/20 (45.00 %) 1.04 s
Generate movie 10/20 (50.00 %) 947.30 ms
Generate movie 11/20 (55.00 %) 862.89 ms
Generate movie 12/20 (60.00 %) 769.08 ms
Generate movie 13/20 (65.00 %) 665.48 ms
Generate movie 14/20 (70.00 %) 585.85 ms
Generate movie 15/20 (75.00 %) 480.77 ms
Generate movie 16/20 (80.00 %) 387.35 ms
Generate movie 17/20 (85.00 %) 283.17 ms
Generate movie 18/20 (90.00 %) 189.88 ms
Generate movie 19/20 (95.00 %) 95.04 ms
Generate movie 20/20 (100.00 %) 0.00 µs
==================== Mesh ====================
Element type: SEG3
Ne = 10, Nn = 21
==================== Model ====================
<EasyFEA.Models.Beam._beam.BeamStructure object at 0x7422441281d0>
solver:scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
Ux max = 0.00e+00
Ux min = 0.00e+00
Uy max = 0.00e+00
Uy min = -7.69e-01
=================== TicTac ===================
Mesh: 18.599 ms
Boundary Conditions: 20.504 µs
Matrix: 11.366 ms
Solver: 99.710 ms
Display: 14.532 ms
PyVista_Interface: 3.169 s
13 import matplotlib.pyplot as plt
14
15 from EasyFEA import (
16 Folder,
17 Display,
18 Models,
19 Mesher,
20 ElemType,
21 Simulations,
22 Paraview,
23 PyVista,
24 )
25 from EasyFEA.Geoms import Domain, Line
26
27 if __name__ == "__main__":
28 Display.Clear()
29
30 # ----------------------------------------------
31 # Configuration
32 # ----------------------------------------------
33
34 # outputs
35 folder = Folder.Results_Dir()
36 makeParaview = False
37 makeMovie = True
38 result = "uy"
39
40 # geom
41 L = 120
42 nL = 10
43 h = 13
44 b = 13
45 e = 3
46
47 # model
48 E = 210000
49 uy = 0.3
50
51 # load
52 load = 800
53
54 # time
55 Tmax = 2.0
56 N = 50
57 dt = Tmax / N
58
59 # ----------------------------------------------
60 # Mesh
61 # ----------------------------------------------
62
63 elemType = ElemType.SEG3
64 beamDim = 2 # must be >= 2
65
66 # Create a section object for the beam mesh
67 domain1 = Domain((0, 0), (b, h), h / 10)
68 domain2 = Domain((e, e), (b - e, h - e), h / 10)
69 section = domain1.Mesh_2D([domain2])
70
71 p1 = (0, 0)
72 p2 = (L, 0)
73 line = Line(p1, p2, L / nL)
74 beam = Models.Beam.Isotropic(beamDim, line, section, E, uy)
75
76 mesh = Mesher().Mesh_Beams([beam], 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_neumann(mesh.Nodes_Point(p2), [-load], ["y"])
92
93 # Solve the beam problem and get displacement results
94 sol = simu.Solve()
95 simu.Save_Iter()
96
97 simu.Solver_Set_Hyperbolic_Algorithm(dt)
98 simu.Bc_Init()
99 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
100
101 for _ in range(N):
102 simu.Solve()
103 simu.Save_Iter()
104
105 # ----------------------------------------------
106 # Results
107 # ----------------------------------------------
108
109 Display.Plot_BoundaryConditions(simu)
110
111 if makeParaview:
112 Paraview.Save_simu(simu, folder)
113
114 deform = 10
115 if makeMovie:
116 PyVista.Movie_simu(
117 simu,
118 f"{result}",
119 folder,
120 f"{result}.gif",
121 N=20,
122 deformFactor=deform,
123 plotMesh=True,
124 )
125
126 print(simu)
127
128 Display.Plot_Result(simu, result, deformFactor=deform)
129 ax = Display.Plot_Mesh(section)
130 ax.set_title("Section")
131 Display.Plot_Mesh(simu, deformFactor=deform)
132
133 plt.show()
Total running time of the script: (0 minutes 3.733 seconds)



