Beam2#

A cantilever beam undergoing bending deformation.

  • SEG3: Ne = 10, Nn = 21
  • Boundary conditions
  • $uy^{e}$
  • $u_y(x)$
  • $r_z(x)$
  • $M_z(x)$
  • $T_y(x)$
err uy: 1.32e-10%
err rz: 1.32e-10%
err Mz: 1.37e-10%
err Ty: 1.63e-10%

==================== Mesh ====================

Element type: SEG3
Ne = 10, Nn = 21

==================== Model ====================

<EasyFEA.Models.Beam._beam.BeamStructure object at 0x74a3ad6fe490>

solver:scipy

============= Boundary Conditions =============

Unspecified.

=================== Results ===================



Ux max = -0.00e+00
Ux min = -0.00e+00

Uy max = 0.00e+00
Uy min = -9.30e-01

=================== TicTac ===================

Mesh: 13.050 ms
Boundary Conditions: 37.670 µs
Matrix: 45.905 ms
Solver: 5.341 ms
Display: 38.053 ms

 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 = 120
 28     nL = 10
 29     h = 13
 30     b = 13
 31
 32     # model
 33     E = 210000
 34     v = 0.3
 35     beamDim = 2  # must be >= 2
 36     useTimoshenko = True
 37
 38     # load
 39     F = -800  # applied tip force in y (negative = downward)
 40
 41     # ----------------------------------------------
 42     # Mesh
 43     # ----------------------------------------------
 44
 45     # Create a section object for the beam mesh
 46     mesher = Mesher()
 47     section = mesher.Mesh_2D(Domain((0, 0), (b, h)), elemType=ElemType.TRI6)
 48
 49     p1 = (0, 0)
 50     p2 = (L, 0)
 51     line = Line(p1, p2, L / nL)
 52     beam = Models.Beam.Isotropic(beamDim, line, section, E, v)
 53
 54     mesh = mesher.Mesh_Beams([beam])
 55
 56     # ----------------------------------------------
 57     # Simulation
 58     # ----------------------------------------------
 59
 60     # Initialize the beam structure with the defined beam segments
 61     beamStructure = Models.Beam.BeamStructure([beam])
 62
 63     # Create the beam simulation
 64     simu = Simulations.Beam(mesh, beamStructure, useTimoshenko=useTimoshenko)
 65     dof_n = simu.Get_dof_n()
 66
 67     # Apply boundary conditions
 68     simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
 69     simu.add_neumann(mesh.Nodes_Point(p2), [F], ["y"])
 70
 71     # Solve the beam problem and get displacement results
 72     sol = simu.Solve()
 73     simu.Save_Iter()
 74
 75     # ----------------------------------------------
 76     # Results
 77     # ----------------------------------------------
 78
 79     Display.Plot_Mesh(simu, deformFactor=-L / 10 / sol.min())
 80     Display.Plot_BoundaryConditions(simu)
 81     Display.Plot_Result(simu, "uy")
 82
 83     # beam properties
 84     G = beam.mu
 85     A = section.area
 86     Iy = beam.Iy
 87     Iz = beam.Iz
 88
 89     # ------------------------
 90     # uy
 91     # ------------------------
 92
 93     x = np.linspace(0, L, 100)
 94     uy_x_eb = lambda x: F * (L * x**2 / 2 - x**3 / 6) / (E * Iz)
 95     if simu.useTimoshenko:
 96         kappa = beam._Get_shear_correction_factor()
 97         uy_x = lambda x: uy_x_eb(x) + F * x / (kappa * G * A)
 98     else:
 99         uy_x = uy_x_eb
100
101     uy = simu.Result("uy")
102     x_n = mesh.coord[:, 0]
103     err_uy = np.abs(uy_x(x_n) - uy).max() / np.abs(uy_x(L))
104     Display.MyPrint(f"\nerr uy: {err_uy * 100:.2e}%")
105
106     axUy = Display.Init_Axes()
107     axUy.plot(x, uy_x(x), label="Analytical", c="blue")
108     axUy.scatter(x_n, uy, label="FE", c="red", marker="x", zorder=2)
109     axUy.set_title("$u_y(x)$")
110     axUy.legend()
111
112     # ------------------------
113     # rz
114     # ------------------------
115
116     rz_x = lambda x: F / E / Iz * (L * x - x**2 / 2)
117
118     rz = simu.Result("rz")
119     err_rz = np.abs(rz_x(x_n) - rz).max() / np.abs(rz_x(L))
120     Display.MyPrint(f"\nerr rz: {err_rz * 100:.2e}%")
121
122     axRz = Display.Init_Axes()
123     axRz.plot(x, rz_x(x), label="Analytical", c="blue")
124     axRz.scatter(x_n, rz, label="FE", c="red", marker="x", zorder=2)
125     axRz.set_title("$r_z(x)$")
126     axRz.legend()
127
128     # ------------------------
129     # Mz
130     # ------------------------
131
132     Mz_x = lambda x: F * (L - x)
133
134     x_e = x_n[mesh.connect].mean(1)  # element centroid x-coords
135     Mz = simu.Result("Mz", nodeValues=False)
136     err_Mz = np.abs(Mz_x(x_e) - Mz).max() / np.abs(Mz_x(x_e)).max()
137     Display.MyPrint(f"\nerr Mz: {err_Mz * 100:.2e}%")
138
139     axMz = Display.Init_Axes()
140     axMz.plot(x, Mz_x(x), label="Analytical", c="blue")
141     axMz.scatter(x_e, Mz, label="FE", c="red", marker="x", zorder=2)
142     axMz.set_title("$M_z(x)$")
143     axMz.legend()
144
145     # ------------------------
146     # Ty
147     # ------------------------
148
149     Ty = simu.Result("Ty", nodeValues=False)
150     err_Ty = np.abs(F - Ty).max() / np.abs(F)
151     Display.MyPrint(f"\nerr Ty: {err_Ty * 100:.2e}%")
152
153     axTy = Display.Init_Axes()
154     axTy.axhline(F, label="Analytical", c="blue")
155     axTy.scatter(x_e, Ty, label="FE", c="red", marker="x", zorder=2)
156     axTy.set_ylim(min(1.5 * F, -0.5 * F), max(1.5 * F, -0.5 * F))
157     axTy.set_title("$T_y(x)$")
158     axTy.legend()
159
160     print(simu)
161
162     plt.show()

Total running time of the script: (0 minutes 0.496 seconds)

Gallery generated by Sphinx-Gallery