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 0x700eaf4de050>

solver : scipy

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

Unspecified.

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



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

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

Mesh : 16.242 ms
Boundary Conditions : 32.902 µs
Matrix : 8.332 ms
Solver : 1.527 ms
Display : 54.967 ms

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

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

Gallery generated by Sphinx-Gallery