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









