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









