.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Dynamic/Dyna1.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_Dynamic_Dyna1.py: Dyna1 ===== A cantilever beam undergoing dynamic bending deformation. .. GENERATED FROM PYTHON SOURCE LINES 11-130 .. image-sg:: /examples/Dynamic/images/sphx_glr_Dyna1_001.gif :alt: Dyna1 :srcset: /examples/Dynamic/images/sphx_glr_Dyna1_001.gif :class: sphx-glr-single-img .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/Dynamic/images/sphx_glr_Dyna1_002.png :alt: QUAD4: Ne = 230, Nn = 282 :srcset: /examples/Dynamic/images/sphx_glr_Dyna1_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/Dynamic/images/sphx_glr_Dyna1_003.png :alt: Boundary conditions :srcset: /examples/Dynamic/images/sphx_glr_Dyna1_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/Dynamic/images/sphx_glr_Dyna1_004.png :alt: $uy^{e}$ :srcset: /examples/Dynamic/images/sphx_glr_Dyna1_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/Dynamic/images/sphx_glr_Dyna1_005.png :alt: $\sigma_{vm}^{e}$ :srcset: /examples/Dynamic/images/sphx_glr_Dyna1_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none 0.000 s 0.010 s 0.020 s 0.030 s 0.040 s 0.050 s 0.060 s 0.070 s 0.080 s 0.090 s 0.100 s 0.110 s 0.120 s 0.130 s 0.140 s 0.150 s 0.160 s 0.170 s 0.180 s 0.190 s 0.200 s 0.210 s 0.220 s 0.230 s 0.240 s 0.250 s 0.260 s 0.270 s 0.280 s 0.290 s 0.300 s 0.310 s 0.320 s 0.330 s 0.340 s 0.350 s 0.360 s 0.370 s 0.380 s 0.390 s 0.400 s 0.410 s 0.420 s 0.430 s 0.440 s 0.450 s 0.460 s 0.470 s 0.480 s 0.490 s 0.500 s Movie_func 0/51 Movie_func 1/51 (1.96 %) 4.94 s Movie_func 2/51 (3.92 %) 4.72 s Movie_func 3/51 (5.88 %) 4.64 s Movie_func 4/51 (7.84 %) 4.72 s Movie_func 5/51 (9.80 %) 4.47 s Movie_func 6/51 (11.76 %) 4.45 s Movie_func 7/51 (13.73 %) 4.22 s Movie_func 8/51 (15.69 %) 4.35 s Movie_func 9/51 (17.65 %) 4.21 s Movie_func 10/51 (19.61 %) 4.07 s Movie_func 11/51 (21.57 %) 3.92 s Movie_func 12/51 (23.53 %) 3.80 s Movie_func 13/51 (25.49 %) 3.71 s Movie_func 14/51 (27.45 %) 3.60 s Movie_func 15/51 (29.41 %) 3.49 s Movie_func 16/51 (31.37 %) 3.54 s Movie_func 17/51 (33.33 %) 3.41 s Movie_func 18/51 (35.29 %) 3.21 s Movie_func 19/51 (37.25 %) 3.12 s Movie_func 20/51 (39.22 %) 3.06 s Movie_func 21/51 (41.18 %) 2.98 s Movie_func 22/51 (43.14 %) 2.83 s Movie_func 23/51 (45.10 %) 2.80 s Movie_func 24/51 (47.06 %) 2.67 s Movie_func 25/51 (49.02 %) 2.55 s Movie_func 26/51 (50.98 %) 2.44 s Movie_func 27/51 (52.94 %) 2.34 s Movie_func 28/51 (54.90 %) 2.27 s Movie_func 29/51 (56.86 %) 2.16 s Movie_func 30/51 (58.82 %) 2.15 s Movie_func 31/51 (60.78 %) 2.10 s Movie_func 32/51 (62.75 %) 1.83 s Movie_func 33/51 (64.71 %) 1.76 s Movie_func 34/51 (66.67 %) 1.71 s Movie_func 35/51 (68.63 %) 1.59 s Movie_func 36/51 (70.59 %) 1.48 s Movie_func 37/51 (72.55 %) 1.36 s Movie_func 38/51 (74.51 %) 1.25 s Movie_func 39/51 (76.47 %) 1.20 s Movie_func 40/51 (78.43 %) 1.13 s Movie_func 41/51 (80.39 %) 991.30 ms Movie_func 42/51 (82.35 %) 878.63 ms Movie_func 43/51 (84.31 %) 811.81 ms Movie_func 44/51 (86.27 %) 696.38 ms Movie_func 45/51 (88.24 %) 583.69 ms Movie_func 46/51 (90.20 %) 516.10 ms Movie_func 47/51 (92.16 %) 413.33 ms Movie_func 48/51 (94.12 %) 310.34 ms Movie_func 49/51 (96.08 %) 206.59 ms Movie_func 50/51 (98.04 %) 98.91 ms Movie_func 51/51 (100.00 %) 0.00 µs ==================== Mesh ==================== Element type: QUAD4 Ne = 230, Nn = 282, dof = 564 ==================== Model ==================== ElasIsot: E = 2.10e+05, v = 0.3 planeStress = True thickness = 1.30e+01 solver : pypardiso ============= Boundary Conditions ============= Unspecified. =================== Results =================== W def = 254.57 Svm max = 230.50 Evm max = 0.13 % Ux max = 4.73e-02 Ux min = -4.73e-02 Uy max = 0.00e+00 Uy min = -7.01e-01 =================== TicTac =================== Mesh : 129.961 ms Boundary Conditions : 679.016 µs Matrix : 49.934 ms Solver : 121.252 ms Display : 358.443 ms PostProcessing : 132.186 ms PyVista_Interface : 22.377 s | .. code-block:: Python :lineno-start: 12 from EasyFEA import ( Display, Folder, Models, plt, ElemType, Simulations, PyVista, Paraview, ) from EasyFEA.Geoms import Domain if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Configuration # ---------------------------------------------- dim = 2 # outputs folder = Folder.Join(Folder.RESULTS_DIR, "Dynamics", "Dyna1") makeParaview = False makeMovie = True result = "uy" # geom L = 120 # mm h = 13 b = 13 # time Tmax = 0.5 N = 50 dt = Tmax / N time = -dt # Dumping coefM = 1e-3 coefK = 1e-3 # ---------------------------------------------- # Mesh # ---------------------------------------------- meshSize = h / 5 if dim == 2: domain = Domain((0, -h / 2), (L, h / 2), meshSize) mesh = domain.Mesh_2D([], ElemType.QUAD4, isOrganised=True) area = mesh.area - L * h elif dim == 3: domain = Domain((0, -h / 2, -b / 2), (L, h / 2, -b / 2), meshSize=meshSize) mesh = domain.Mesh_Extrude([], [0, 0, b], [3], ElemType.HEXA8, isOrganised=True) volume = mesh.volume - L * b * h area = mesh.area - (L * h * 4 + 2 * b * h) nodes_0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0) nodes_L = mesh.Nodes_Conditions(lambda x, y, z: x == L) nodes_h = mesh.Nodes_Conditions(lambda x, y, z: y == h / 2) # ---------------------------------------------- # Simulation # ---------------------------------------------- material = Models.ElasIsot(dim, thickness=b) simu = Simulations.ElasticSimu(mesh, material) simu.rho = 8100 * 1e-9 # static simulation simu.Bc_Init() simu.add_dirichlet(nodes_0, [0] * dim, simu.Get_unknowns(), description="Fixed") simu.add_dirichlet(nodes_L, [-10], ["y"], description="dep") simu.Solve() simu.Save_Iter() Display.Plot_Mesh(simu, deformFactor=1) # dynamic simulation simu.Solver_Set_Hyperbolic_Algorithm(dt) simu.Set_Rayleigh_Damping_Coefs(coefM=coefM, coefK=coefK) simu.Bc_Init() simu.add_dirichlet(nodes_0, [0] * dim, simu.Get_unknowns(), description="Fixed") while time <= Tmax: time += dt simu.Solve() simu.Save_Iter() print(f"{time:.3f} s", end="\r") # ---------------------------------------------- # Results # ---------------------------------------------- Display.Plot_BoundaryConditions(simu) if makeParaview: Paraview.Save_simu(simu, folder) if makeMovie: PyVista.Movie_simu( simu, f"{result}", folder, f"{result}.gif", deformFactor=1, plotMesh=True, ) print(simu) Display.Plot_Result(simu, f"{result}", deformFactor=1, nodeValues=False) Display.Plot_Result(simu, "Svm", plotMesh=False, nodeValues=False) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.732 seconds) .. _sphx_glr_download_examples_Dynamic_Dyna1.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Dyna1.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Dyna1.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Dyna1.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_