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.29 s
Generate movie 02/20 (10.00 %) 1.72 s
Generate movie 03/20 (15.00 %) 1.62 s
Generate movie 04/20 (20.00 %) 1.54 s
Generate movie 05/20 (25.00 %) 1.44 s
Generate movie 06/20 (30.00 %) 1.34 s
Generate movie 07/20 (35.00 %) 1.24 s
Generate movie 08/20 (40.00 %) 1.14 s
Generate movie 09/20 (45.00 %) 1.05 s
Generate movie 10/20 (50.00 %) 947.21 ms
Generate movie 11/20 (55.00 %) 877.29 ms
Generate movie 12/20 (60.00 %) 770.05 ms
Generate movie 13/20 (65.00 %) 686.66 ms
Generate movie 14/20 (70.00 %) 587.62 ms
Generate movie 15/20 (75.00 %) 479.90 ms
Generate movie 16/20 (80.00 %) 387.67 ms
Generate movie 17/20 (85.00 %) 290.51 ms
Generate movie 18/20 (90.00 %) 195.89 ms
Generate movie 19/20 (95.00 %) 96.36 ms
Generate movie 20/20 (100.00 %) 0.00 µs
==================== Mesh ====================
elemType: SEG3
Ne: 14
Nn: 30
==================== Model ====================
<EasyFEA.Models.Beam._beam.BeamStructure object at 0x7942259a4250>
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.091 ms
Boundary Conditions: 201.225 µs
Matrix: 56.843 ms
Solver: 149.816 ms
Matplotlib: 14.754 ms
PyVista_Interface: 3.151 s
13 import matplotlib.pyplot as plt
14
15 from EasyFEA import (
16 Folder,
17 Terminal,
18 Matplotlib,
19 Models,
20 Mesher,
21 ElemType,
22 Simulations,
23 Paraview,
24 PyVista,
25 )
26 from EasyFEA.Geoms import Circle, Line
27
28 if __name__ == "__main__":
29 Terminal.Clear()
30
31 # ----------------------------------------------
32 # Configuration
33 # ----------------------------------------------
34
35 # outputs
36 folder = Folder.Results_Dir()
37 makeParaview = False
38 makeMovie = True
39 result = "uy"
40
41 # geom
42 L = 120
43 h = 13
44 b = 13
45
46 # model
47 E = 210000
48 v = 0.3
49 rho = 7850 * 1e-9
50
51 # load
52 load = 800
53
54 # time
55 Tmax = 1 / 4
56 N = 50
57 dt = Tmax / N
58
59 # ----------------------------------------------
60 # Mesh
61 # ----------------------------------------------
62
63 # Create a section object for the beam mesh
64 mesher = Mesher()
65 section = mesher.Mesh_2D(Circle((0, 0), h), elemType=ElemType.TRI6)
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)
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 simu.rho = rho
88 dof_n = simu.Get_dof_n()
89
90 # Apply boundary conditions
91 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
92 simu.add_neumann(mesh.Nodes_Point(p3), [-load, load], ["y", "z"])
93 if beamStructure.nBeam > 1:
94 simu.add_connection_fixed(mesh.Nodes_Point(p2))
95
96 # Solve the beam problem and get displacement results
97 sol = simu.Solve()
98 simu.Save_Iter()
99
100 simu.Solver_Set_Hyperbolic_Algorithm(dt)
101 simu.Bc_Init()
102 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
103 if beamStructure.nBeam > 1:
104 simu.add_connection_fixed(mesh.Nodes_Point(p2))
105
106 for _ in range(N):
107 simu.Solve()
108 simu.Save_Iter()
109
110 # ----------------------------------------------
111 # Results
112 # ----------------------------------------------
113
114 Matplotlib.Plot_BoundaryConditions(simu)
115
116 if makeParaview:
117 Paraview.Save_simu(simu, folder)
118
119 deform = 10
120 if makeMovie:
121 PyVista.Movie_simu(
122 simu,
123 f"{result}",
124 folder,
125 f"{result}.gif",
126 N=20,
127 deformFactor=deform,
128 plotMesh=True,
129 )
130
131 print(simu)
132
133 Matplotlib.Plot(simu, result, deformFactor=deform)
134 ax = Matplotlib.Plot_Mesh(section)
135 ax.set_title("Section")
136 Matplotlib.Plot_Mesh(simu, deformFactor=deform)
137
138 plt.show()
Total running time of the script: (0 minutes 3.573 seconds)



