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._beam.BeamStructure object at 0x700eb190e8d0>
solver : scipy
============= 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 : 16.356 ms
Boundary Conditions : 114.679 µs
Matrix : 10.380 ms
Solver : 2.818 ms
Display : 89.333 ms
12 import matplotlib.pyplot as plt
13
14 from EasyFEA import Display, Models, Mesher, ElemType, Simulations
15 from EasyFEA.Geoms import Domain, Line
16
17 if __name__ == "__main__":
18 Display.Clear()
19
20 # ----------------------------------------------
21 # Configuration
22 # ----------------------------------------------
23
24 # geom
25 L = 120
26 h = 13
27 b = 13
28
29 # model
30 E = 210000
31 v = 0.3
32
33 # load
34 load = 800
35
36 # ----------------------------------------------
37 # Mesh
38 # ----------------------------------------------
39
40 elemType = ElemType.SEG2
41
42 # Create a section object for the beam mesh
43 mesher = Mesher()
44 section = mesher.Mesh_2D(Domain((0, 0), (b, h)))
45
46 p1 = (0, 0)
47 p2 = (0, L)
48 p3 = (L / 2, L)
49 line1 = Line(p1, p2, L / 9)
50 line2 = Line(p2, p3, L / 9)
51 beam1 = Models.Beam.Isotropic(3, line1, section, E, v)
52 beam2 = Models.Beam.Isotropic(3, line2, section, E, v)
53 beams = [beam1, beam2]
54
55 mesh = mesher.Mesh_Beams(beams=beams, elemType=elemType)
56
57 # ----------------------------------------------
58 # Simulation
59 # ----------------------------------------------
60
61 # Initialize the beam structure with the defined beam segments
62 beamStructure = Models.Beam.BeamStructure(beams)
63
64 # Create the beam simulation
65 simu = Simulations.Beam(mesh, beamStructure)
66 dof_n = simu.Get_dof_n()
67
68 # Apply boundary conditions
69 simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
70 simu.add_neumann(mesh.Nodes_Point(p3), [-load, load], ["y", "z"])
71 if beamStructure.nBeam > 1:
72 simu.add_connection_fixed(mesh.Nodes_Point(p2))
73
74 # Solve the beam problem and get displacement results
75 sol = simu.Solve()
76 simu.Save_Iter()
77
78 # ----------------------------------------------
79 # Results
80 # ----------------------------------------------
81
82 Display.Plot_Mesh(simu, L / 10 / sol.max())
83 Display.Plot_BoundaryConditions(simu)
84 Display.Plot_Result(simu, "ux", L / 10 / sol.max())
85 Display.Plot_Result(simu, "uy", L / 10 / sol.max())
86
87 print(simu)
88
89 plt.show()
Total running time of the script: (0 minutes 0.489 seconds)



