Note
Go to the end to download the full example code.
Beam4#
Frame with two beams.
The beam's vertical axis has been selected incorrectly (collinear with the beam x-axis).
Axis [-1. 0. 0.] has been assigned for beam3.
==================== Mesh ====================
Element type: SEG2
Ne = 14, Nn = 16
==================== Model ====================
<EasyFEA.models._beam.BeamStructure object at 0x742188bd1d50>
solver : pypardiso
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
Ux max = 0.00e+00
Ux min = -6.91e-01
Uy max = 0.00e+00
Uy min = -8.09e-01
Uz max = 1.94e+00
Uz min = 0.00e+00
=================== TicTac ===================
Mesh : 93.570 ms
Boundary Conditions : 125.647 µs
Matrix : 32.668 ms
Solver : 80.210 ms
Display : 231.217 ms
PostProcessing : 188.828 µs
12 from EasyFEA import Display, Models, plt, Mesher, ElemType, Simulations
13 from EasyFEA.Geoms import Domain, Line
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 # ----------------------------------------------
19 # Configuration
20 # ----------------------------------------------
21
22 # geom
23 L = 120
24 h = 13
25 b = 13
26
27 # model
28 E = 210000
29 v = 0.3
30
31 # load
32 load = 800
33
34 # ----------------------------------------------
35 # Mesh
36 # ----------------------------------------------
37
38 elemType = ElemType.SEG2
39
40 # Create a section object for the beam mesh
41 mesher = Mesher()
42 section = mesher.Mesh_2D(Domain((0, 0), (b, h)))
43
44 p1 = (0, 0)
45 p2 = (0, L)
46 p3 = (L / 2, L)
47 line1 = Line(p1, p2, L / 9)
48 line2 = Line(p2, p3, L / 9)
49 beam1 = Models.BeamElasIsot(3, line1, section, E, v)
50 beam2 = Models.BeamElasIsot(3, line2, section, E, v)
51 beams = [beam1, beam2]
52
53 mesh = mesher.Mesh_Beams(beams=beams, elemType=elemType)
54
55 # ----------------------------------------------
56 # Simulation
57 # ----------------------------------------------
58
59 # Initialize the beam structure with the defined beam segments
60 beamStructure = Models.BeamStructure(beams)
61
62 # Create the beam simulation
63 simu = Simulations.BeamSimu(mesh, beamStructure)
64 dof_n = simu.Get_dof_n()
65
66 # Apply boundary conditions
67 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
68 simu.add_neumann(mesh.Nodes_Point(p3), [-load, load], ["y", "z"])
69 if beamStructure.nBeam > 1:
70 simu.add_connection_fixed(mesh.Nodes_Point(p2))
71
72 # Solve the beam problem and get displacement results
73 sol = simu.Solve()
74 simu.Save_Iter()
75
76 # ----------------------------------------------
77 # Results
78 # ----------------------------------------------
79
80 Display.Plot_Mesh(simu, L / 10 / sol.max())
81 Display.Plot_BoundaryConditions(simu)
82 Display.Plot_Result(simu, "ux", L / 10 / sol.max())
83 Display.Plot_Result(simu, "uy", L / 10 / sol.max())
84
85 print(simu)
86
87 plt.show()
Total running time of the script: (0 minutes 0.277 seconds)



