Note
Go to the end to download the full example code.
Beam5#
Frame with six beams
Beam: section uses linear TRI3 elements — _Get_shear_correction_factor converges at O(h²). Use TRI6 / QUAD8 (or finer mesh) for accurate k.
Beam: section uses linear TRI3 elements — _Get_shear_correction_factor converges at O(h²). Use TRI6 / QUAD8 (or finer mesh) for accurate k.
The beam's vertical axis has been selected incorrectly (collinear with the beam x-axis).
Axis [-1. 0. 0.] has been assigned for beam7.
Beam: section uses linear TRI3 elements — _Get_shear_correction_factor converges at O(h²). Use TRI6 / QUAD8 (or finer mesh) for accurate k.
Beam: section uses linear TRI3 elements — _Get_shear_correction_factor converges at O(h²). Use TRI6 / QUAD8 (or finer mesh) for accurate k.
Beam: section uses linear TRI3 elements — _Get_shear_correction_factor converges at O(h²). Use TRI6 / QUAD8 (or finer mesh) for accurate k.
Beam: section uses linear TRI3 elements — _Get_shear_correction_factor converges at O(h²). Use TRI6 / QUAD8 (or finer mesh) for accurate k.
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 beamDim = 3 # must be >= 2
33
34 # ----------------------------------------------
35 # Mesh
36 # ----------------------------------------------
37
38 pA = (2 * L, 0)
39 pB = (L, 0)
40 pC = (L, L)
41 pD = (0, 0)
42 pE = (0, L)
43
44 line1 = Line(pA, pC)
45 line2 = Line(pA, pB)
46 line3 = Line(pB, pC)
47 line4 = Line(pC, pE)
48 line5 = Line(pB, pD)
49 line6 = Line(pB, pE)
50 lines = [line1, line2, line3, line4, line5, line6]
51
52 contour = Domain((-4 / 2, -8 / 2), (4 / 2, 8 / 2))
53 section = Mesher().Mesh_2D(contour)
54
55 beams = [Models.Beam.Isotropic(beamDim, line, section, E, v) for line in lines]
56 structure = Models.Beam.BeamStructure(beams)
57
58 mesh = Mesher().Mesh_Beams(beams, ElemType.SEG2)
59 # Display.Plot_Mesh(mesh)
60 # Display.Plot_Tags(mesh)
61
62 # ----------------------------------------------
63 # Simulation
64 # ----------------------------------------------
65 simu = Simulations.Beam(mesh, structure)
66
67 nodesRigi = mesh.Nodes_Point(pE)
68 nodesRigi = np.append(nodesRigi, mesh.Nodes_Point(pD))
69 nodesA = mesh.Nodes_Point(pA)
70
71 # link beams at specified points
72 for point in [pA, pB, pC]:
73 nodes = mesh.Nodes_Point(point)
74 firstNodes = nodes[0]
75 others = nodes[1:]
76 [simu.add_connection_hinged([firstNodes, n]) for n in others]
77
78 simu.add_dirichlet(nodesRigi, [0, 0], ["x", "y"])
79 simu.add_neumann(nodesA, [-4 * 9.81], ["y"])
80
81 simu.Solve()
82
83 # ----------------------------------------------
84 # Results
85 # ----------------------------------------------
86 matrixDep = simu.Results_displacement_matrix()
87 depMax = np.max(np.linalg.norm(matrixDep, axis=1))
88
89 Display.Plot_Mesh(simu, deformFactor=10 / depMax)
90 Display.Plot_Mesh(section, title="Cross section")
91 Display.Plot_BoundaryConditions(simu)
92 Display.Plot_Result(simu, "ux", deformFactor=5 / depMax)
93 Display.Plot_Result(simu, "uy", deformFactor=5 / depMax)
94 Display.Plot_Result(simu, "rz", deformFactor=5 / depMax)
95 Display.Plot_Result(simu, "fx", deformFactor=5 / depMax)
96 Display.Plot_Result(simu, "fy", deformFactor=5 / depMax)
97
98 Epsilon_e_pg = simu._Calc_Epsilon_e_pg(simu.displacement)
99 Internal_e = simu._Calc_InternalForces_e_pg(Epsilon_e_pg).mean(1)
100 Sigma_e = simu._Calc_Sigma_e_pg(Epsilon_e_pg).mean(1)
101 Display.Plot_Result(simu, Sigma_e[:, 0], title="Sxx")
102 Display.Plot_Result(simu, Internal_e[:, 0], title="N")
103
104 ux, uy, rz = simu.Result("ux"), simu.Result("uy"), simu.Result("rz")
105 fx, fy, cz = simu.Result("fx"), simu.Result("fy"), simu.Result("cz")
106
107 for i in range(5):
108 print(f"\nNode {i} at {simu.mesh.coord[i]}")
109 print(f" ux={ux[i]:.2e} mm, uy={uy[i]:.2e} mm, rz={rz[i]:.2e} rad")
110 print(f" fx={fx[i]:.2e} N, fy={fy[i]:.2e} N, cz={cz[i]:.2e} N.mm")
111
112 plt.show()
Total running time of the script: (0 minutes 1.060 seconds)









