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.42 s
Generate movie 02/20 (10.00 %) 1.78 s
Generate movie 03/20 (15.00 %) 1.67 s
Generate movie 04/20 (20.00 %) 1.55 s
Generate movie 05/20 (25.00 %) 1.45 s
Generate movie 06/20 (30.00 %) 1.36 s
Generate movie 07/20 (35.00 %) 1.26 s
Generate movie 08/20 (40.00 %) 1.17 s
Generate movie 09/20 (45.00 %) 1.07 s
Generate movie 10/20 (50.00 %) 973.08 ms
Generate movie 11/20 (55.00 %) 871.15 ms
Generate movie 12/20 (60.00 %) 774.95 ms
Generate movie 13/20 (65.00 %) 687.69 ms
Generate movie 14/20 (70.00 %) 593.86 ms
Generate movie 15/20 (75.00 %) 485.98 ms
Generate movie 16/20 (80.00 %) 393.85 ms
Generate movie 17/20 (85.00 %) 293.38 ms
Generate movie 18/20 (90.00 %) 196.16 ms
Generate movie 19/20 (95.00 %) 97.74 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 0x70da16b2f4d0>
solver:scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
Ux max = 1.23e-01
Ux min = 0.00e+00
Uy max = 1.90e-01
Uy min = 0.00e+00
Uz max = 4.62e-02
Uz min = -5.45e-01
=================== TicTac ===================
Mesh: 16.861 ms
Boundary Conditions: 180.721 µs
Matrix: 69.345 ms
Solver: 147.937 ms
Display: 15.886 ms
PyVista_Interface: 3.192 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 rho = 7850 * 1e-9
49
50 # load
51 load = 800
52
53 # time
54 Tmax = 1 / 4
55 N = 50
56 dt = Tmax / N
57
58 # ----------------------------------------------
59 # Mesh
60 # ----------------------------------------------
61
62 # Create a section object for the beam mesh
63 mesher = Mesher()
64 section = mesher.Mesh_2D(Circle((0, 0), h), elemType=ElemType.TRI6)
65
66 p1 = (0, 0)
67 p2 = (0, L)
68 p3 = (L / 2, L)
69 line1 = Line(p1, p2, L / 9)
70 line2 = Line(p2, p3, L / 9)
71 beam1 = Models.Beam.Isotropic(3, line1, section, E, v)
72 beam2 = Models.Beam.Isotropic(3, line2, section, E, v)
73 beams = [beam1, beam2]
74
75 mesh = mesher.Mesh_Beams(beams=beams)
76
77 # ----------------------------------------------
78 # Simulation
79 # ----------------------------------------------
80
81 # Initialize the beam structure with the defined beam segments
82 beamStructure = Models.Beam.BeamStructure(beams)
83
84 # Create the beam simulation
85 simu = Simulations.Beam(mesh, beamStructure)
86 simu.rho = rho
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.619 seconds)



