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



