Note
Go to the end to download the full example code.
Beam7#
Frame with two beams in dynamic.

The beam's vertical axis has been selected incorrectly (collinear with the beam x-axis).
Axis [-1. 0. 0.] has been assigned for beam12.
Generate movie 01/20 (5.00 %) 2.38 s
Generate movie 02/20 (10.00 %) 1.77 s
Generate movie 03/20 (15.00 %) 1.67 s
Generate movie 04/20 (20.00 %) 1.58 s
Generate movie 05/20 (25.00 %) 1.44 s
Generate movie 06/20 (30.00 %) 1.36 s
Generate movie 07/20 (35.00 %) 1.27 s
Generate movie 08/20 (40.00 %) 1.20 s
Generate movie 09/20 (45.00 %) 1.08 s
Generate movie 10/20 (50.00 %) 995.32 ms
Generate movie 11/20 (55.00 %) 880.84 ms
Generate movie 12/20 (60.00 %) 778.02 ms
Generate movie 13/20 (65.00 %) 678.31 ms
Generate movie 14/20 (70.00 %) 586.86 ms
Generate movie 15/20 (75.00 %) 486.20 ms
Generate movie 16/20 (80.00 %) 390.55 ms
Generate movie 17/20 (85.00 %) 298.77 ms
Generate movie 18/20 (90.00 %) 197.34 ms
Generate movie 19/20 (95.00 %) 97.91 ms
Generate movie 20/20 (100.00 %) 0.00 µs
==================== Mesh ====================
Element type: SEG3
Ne = 14, Nn = 30
==================== Model ====================
<EasyFEA.Models.Beam._beam.BeamStructure object at 0x722fcf406f10>
solver:scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
Ux max = 0.00e+00
Ux min = -1.08e+00
Uy max = 1.34e-02
Uy min = -3.88e-01
Uz max = 0.00e+00
Uz min = -1.95e+00
=================== TicTac ===================
Mesh: 15.069 ms
Boundary Conditions: 161.886 µs
Matrix: 24.778 ms
Solver: 157.148 ms
Display: 16.139 ms
PyVista_Interface: 3.206 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 Circle, 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 h = 13
43 b = 13
44
45 # model
46 E = 210000
47 v = 0.3
48
49 # load
50 load = 800
51
52 # time
53 Tmax = 2.0
54 N = 50
55 dt = Tmax / N
56
57 # ----------------------------------------------
58 # Mesh
59 # ----------------------------------------------
60
61 elemType = ElemType.SEG3
62
63 # Create a section object for the beam mesh
64 mesher = Mesher()
65 section = mesher.Mesh_2D(Circle((0, 0), h))
66
67 p1 = (0, 0)
68 p2 = (0, L)
69 p3 = (L / 2, L)
70 line1 = Line(p1, p2, L / 9)
71 line2 = Line(p2, p3, L / 9)
72 beam1 = Models.Beam.Isotropic(3, line1, section, E, v)
73 beam2 = Models.Beam.Isotropic(3, line2, section, E, v)
74 beams = [beam1, beam2]
75
76 mesh = mesher.Mesh_Beams(beams=beams, elemType=elemType)
77
78 # ----------------------------------------------
79 # Simulation
80 # ----------------------------------------------
81
82 # Initialize the beam structure with the defined beam segments
83 beamStructure = Models.Beam.BeamStructure(beams)
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(p3), [-load, load], ["y", "z"])
92 if beamStructure.nBeam > 1:
93 simu.add_connection_fixed(mesh.Nodes_Point(p2))
94
95 # Solve the beam problem and get displacement results
96 sol = simu.Solve()
97 simu.Save_Iter()
98
99 simu.Solver_Set_Hyperbolic_Algorithm(dt)
100 simu.Bc_Init()
101 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
102 if beamStructure.nBeam > 1:
103 simu.add_connection_fixed(mesh.Nodes_Point(p2))
104
105 for _ in range(N):
106 simu.Solve()
107 simu.Save_Iter()
108
109 # ----------------------------------------------
110 # Results
111 # ----------------------------------------------
112
113 Display.Plot_BoundaryConditions(simu)
114
115 if makeParaview:
116 Paraview.Save_simu(simu, folder)
117
118 deform = 10
119 if makeMovie:
120 PyVista.Movie_simu(
121 simu,
122 f"{result}",
123 folder,
124 f"{result}.gif",
125 N=20,
126 deformFactor=deform,
127 plotMesh=True,
128 )
129
130 print(simu)
131
132 Display.Plot_Result(simu, result, deformFactor=deform)
133 ax = Display.Plot_Mesh(section)
134 ax.set_title("Section")
135 Display.Plot_Mesh(simu, deformFactor=deform)
136
137 plt.show()
Total running time of the script: (0 minutes 3.546 seconds)



