Beam1#

Beam subjected to pure tensile loading.

  • SEG2: Ne = 10, Nn = 11
  • Boundary conditions
  • $ux^{e}$
  • $u_x(x)$
err ux: 3.05e-14 %

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

Element type: SEG2
Ne = 10, Nn = 11

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

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

solver : scipy

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

Unspecified.

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



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

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

Mesh : 9.015 ms
Boundary Conditions : 19.312 µs
Matrix : 4.470 ms
Solver : 755.072 µs
Display : 28.634 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 = 10
 28     nL = 10
 29     h = 0.1
 30     b = 0.1
 31
 32     # model
 33     E = 200000e6
 34     ro = 7800
 35     v = 0.3
 36
 37     # load
 38     g = 10
 39     q = ro * g * (h * b)
 40     load = 5000
 41
 42     # ----------------------------------------------
 43     # Mesh
 44     # ----------------------------------------------
 45
 46     elemType = ElemType.SEG2
 47     beamDim = 1
 48
 49     # Create a section for the beam
 50     mesher = Mesher()
 51     section = mesher.Mesh_2D(Domain((0, 0), (b, h)))
 52
 53     p1 = (0, 0)
 54     p2 = (L, 0)
 55     line = Line(p1, p2, L / nL)
 56     beam = Models.Beam.Isotropic(beamDim, line, section, E, v)
 57
 58     mesh = mesher.Mesh_Beams([beam], elemType=elemType)
 59
 60     # ----------------------------------------------
 61     # Simulation
 62     # ----------------------------------------------
 63
 64     # Initialize the beam structure with the defined beam segments
 65     beamStructure = Models.Beam.BeamStructure([beam])
 66
 67     # Create the beam simulation
 68     simu = Simulations.Beam(mesh, beamStructure)
 69     dof_n = simu.Get_dof_n()
 70
 71     # Apply boundary conditions
 72     simu.add_dirichlet(mesh.Nodes_Point(p1), [0] * dof_n, simu.Get_unknowns())
 73     simu.add_lineLoad(mesh.nodes, [q], ["x"])
 74     simu.add_neumann(mesh.Nodes_Point(p2), [load], ["x"])
 75
 76     # Solve the beam problem and get displacement results
 77     sol = simu.Solve()
 78     simu.Save_Iter()
 79
 80     # ----------------------------------------------
 81     # Results
 82     # ----------------------------------------------
 83
 84     Display.Plot_Mesh(simu, deformFactor=L / 10 / sol.max())
 85     Display.Plot_BoundaryConditions(simu)
 86     Display.Plot_Result(simu, "ux")
 87
 88     ux = simu.Result("ux")
 89
 90     x_array = np.linspace(0, L, 100)
 91     u_x = (load * x_array / (E * (section.area))) + (
 92         ro * g * x_array / 2 / E * (2 * L - x_array)
 93     )
 94     err_ux = np.abs(u_x[-1] - ux.max()) / ux.max()
 95     Display.MyPrint(f"err ux: {err_ux * 100:.2e} %")
 96
 97     # Plot the analytical and finite element solutions for displacement (u)
 98     ax = Display.Init_Axes()
 99     ax.plot(x_array, u_x, label="Analytical", c="blue")
100     ax.scatter(mesh.coord[:, 0], ux, label="FE", c="red", marker="x", zorder=2)
101     ax.set_title("$u_x(x)$")
102     ax.legend()
103
104     print(simu)
105
106     plt.show()

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

Gallery generated by Sphinx-Gallery