Note
Go to the end to download the full example code.
Beam5#
Frame with six beams
The beam's vertical axis has been selected incorrectly (collinear with the beam x-axis).
Axis [-1. 0. 0.] has been assigned for beam7.
Node 0 at [200. 0. 0.]
ux=-1.30e+01 mm, uy=-5.51e+01 mm, rz=-4.11e-01 rad
fx=3.87e+02 N, fy=-3.88e+02 N, cz=-9.11e+01 N.mm
Node 1 at [100. 100. 0.]
ux=4.26e+00 mm, uy=-2.54e+01 mm, rz=-2.01e-02 rad
fx=-3.87e+02 N, fy=3.88e+02 N, cz=1.69e+02 N.mm
Node 2 at [200. 0. 0.]
ux=-1.30e+01 mm, uy=-5.51e+01 mm, rz=-4.11e-01 rad
fx=-3.87e+02 N, fy=-4.72e+00 N, cz=9.11e+01 N.mm
Node 3 at [100. 0. 0.]
ux=-8.64e+00 mm, uy=-2.10e+01 mm, rz=-1.03e-01 rad
fx=3.87e+02 N, fy=4.72e+00 N, cz=3.81e+02 N.mm
Node 4 at [100. 0. 0.]
ux=-8.64e+00 mm, uy=-2.10e+01 mm, rz=-1.03e-01 rad
fx=-1.08e+01 N, fy=3.84e+02 N, cz=-5.78e+02 N.mm
12 from EasyFEA import Display, Models, np, 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 = 100 # mm
24
25 # model
26 E = 276 # MPa
27 v = 0.3
28
29 # ----------------------------------------------
30 # Mesh
31 # ----------------------------------------------
32
33 elemType = ElemType.SEG2
34 dim = 3 # must be >= 2
35
36 pA = (2 * L, 0)
37 pB = (L, 0)
38 pC = (L, L)
39 pD = (0, 0)
40 pE = (0, L)
41
42 line1 = Line(pA, pC)
43 line2 = Line(pA, pB)
44 line3 = Line(pB, pC)
45 line4 = Line(pC, pE)
46 line5 = Line(pB, pD)
47 line6 = Line(pB, pE)
48 lines = [line1, line2, line3, line4, line5, line6]
49
50 contour = Domain((-4 / 2, -8 / 2), (4 / 2, 8 / 2))
51 section = Mesher().Mesh_2D(contour)
52
53 beams = [Models.Beam.Isotropic(dim, line, section, E, v) for line in lines]
54 structure = Models.Beam.BeamStructure(beams)
55
56 mesh = Mesher().Mesh_Beams(beams, elemType)
57 # Display.Plot_Mesh(mesh)
58 # Display.Plot_Tags(mesh)
59
60 # ----------------------------------------------
61 # Simulation
62 # ----------------------------------------------
63 simu = Simulations.Beam(mesh, structure)
64
65 nodesRigi = mesh.Nodes_Point(pE)
66 nodesRigi = np.append(nodesRigi, mesh.Nodes_Point(pD))
67 nodesA = mesh.Nodes_Point(pA)
68
69 # link beams at specified points
70 for point in [pA, pB, pC]:
71 nodes = mesh.Nodes_Point(point)
72 firstNodes = nodes[0]
73 others = nodes[1:]
74 [simu.add_connection_hinged([firstNodes, n]) for n in others]
75
76 simu.add_dirichlet(nodesRigi, [0, 0], ["x", "y"])
77 simu.add_neumann(nodesA, [-40 * 9.81], ["y"])
78
79 simu.Solve()
80
81 # ----------------------------------------------
82 # Results
83 # ----------------------------------------------
84 matrixDep = simu.Results_displacement_matrix()
85 depMax = np.max(np.linalg.norm(matrixDep, axis=1))
86
87 Display.Plot_Mesh(simu, deformFactor=10 / depMax)
88 Display.Plot_Mesh(section, title="Cross section")
89 Display.Plot_BoundaryConditions(simu)
90 Display.Plot_Result(simu, "ux", deformFactor=5 / depMax)
91 Display.Plot_Result(simu, "uy", deformFactor=5 / depMax)
92 Display.Plot_Result(simu, "rz", deformFactor=5 / depMax)
93 Display.Plot_Result(simu, "fx", deformFactor=5 / depMax)
94 Display.Plot_Result(simu, "fy", deformFactor=5 / depMax)
95
96 Epsilon_e_pg = simu._Calc_Epsilon_e_pg(simu.displacement)
97 Internal_e = simu._Calc_InternalForces_e_pg(Epsilon_e_pg).mean(1)
98 Sigma_e = simu._Calc_Sigma_e_pg(Epsilon_e_pg).mean(1)
99 Display.Plot_Result(simu, Sigma_e[:, 0], title="Sxx")
100 Display.Plot_Result(simu, Internal_e[:, 0], title="N")
101
102 ux, uy, rz = simu.Result("ux"), simu.Result("uy"), simu.Result("rz")
103 fx, fy, cz = simu.Result("fx"), simu.Result("fy"), simu.Result("cz")
104
105 for i in range(5):
106 print(f"\nNode {i} at {simu.mesh.coord[i]}")
107 print(f" ux={ux[i]:.2e} mm, uy={uy[i]:.2e} mm, rz={rz[i]:.2e} rad")
108 print(f" fx={fx[i]:.2e} N, fy={fy[i]:.2e} N, cz={cz[i]:.2e} N.mm")
109
110 Display.plt.show()
Total running time of the script: (0 minutes 0.698 seconds)









